GRASS Programmer's Manual  6.4.3(2013)-r
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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 }