GRASS GIS 7 Programmer's Manual  7.5.svn(2018)-r73001
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
location.c File Reference

GIS library - environment routines (location) More...

#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <grass/gis.h>
#include <grass/glocale.h>
#include "gis_local_proto.h"
Include dependency graph for location.c:

Go to the source code of this file.

Functions

const char * G_location (void)
 Get current location name. More...
 
char * G_location_path (void)
 Get current location UNIX-like path. More...
 
char * G__location_path (void)
 Get current location UNIX-like path (internal use only) More...
 

Detailed Description

GIS library - environment routines (location)

(C) 2001-2008, 2012 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
Original author CERL

Definition in file location.c.

Function Documentation

char* G__location_path ( void  )

Get current location UNIX-like path (internal use only)

Allocated buffer should be freed by G_free(). See also G_location_path().

Todo:
Support also Windows-like path (?)
Returns
buffer with location path

Definition at line 78 of file location.c.

References G_gisdbase(), G_location(), HOST_DIRSEP, and name.

Referenced by G_location_path().

const char* G_location ( void  )

Get current location name.

Returns the name of the current database location. This routine should be used by modules that need to display the current location to the user. See Locations for an explanation of locations.

Returns
location name

Definition at line 32 of file location.c.

References G_getenv().

Referenced by G__location_path(), G__mapset_path(), G_get_projepsg(), G_get_projinfo(), G_get_projunits(), G_make_mapset(), I_location_info(), Vect__open_old(), and Vect_hist_command().

char* G_location_path ( void  )

Get current location UNIX-like path.

Allocated buffer should be freed by G_free(). See G__location_path().

Returns the full UNIX path name of the current database location. For example, if the user is working in location spearfish in the /home/user/grassdata database directory, this routine will return a string which looks like /home/user/grassdata/spearfish.

This function also checks if location path is readable by the current user. It calls G_fatal_error() on failure.

Returns
buffer with location path

Definition at line 54 of file location.c.

References _, G__location_path(), and G_fatal_error().

Referenced by db_set_default_connection(), G__gisinit(), and G_get_available_mapsets().