GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
location.c
Go to the documentation of this file.
1 
16 #include <stdio.h>
17 #include <string.h>
18 #include <unistd.h>
19 #include <sys/types.h>
20 #include <grass/gis.h>
21 #include <grass/glocale.h>
22 
23 
37 char *G_location_path(void)
38 {
39  char *location;
40 
41  location = G__location_path();
42  if (access(location, 0) != 0) {
43  perror("access");
44  G_fatal_error(_("LOCATION << %s >> not available"), location);
45  }
46 
47  return location;
48 }
49 
50 
61 char *G_location(void)
62 {
63  return G_getenv("LOCATION_NAME");
64 }
65 
72 char *G__location_path(void)
73 {
74  char *location = 0;
75  char *base;
76  char *name;
77 
78  name = G_location();
79  base = G_gisdbase();
80  location = G_malloc(strlen(base) + strlen(name) + 2);
81 
82  sprintf(location, "%s/%s", base, name);
83 
84  return location;
85 }
sprintf(buf2,"%s", G3D_CATS_ELEMENT)
string name
Definition: render.py:1314
char * G__location_path(void)
Get current location path.
Definition: location.c:72
char * G_getenv(const char *name)
Get environment variable.
Definition: env.c:267
char * G_location_path(void)
Get current location directory.
Definition: location.c:37
char * G_gisdbase(void)
Get name of top level database directory.
Definition: gisdbase.c:29
char * G_location(void)
Get current location name.
Definition: location.c:61
int G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.