location.c

Go to the documentation of this file.
00001 /**********************************************************************
00002  *
00003  *   char *
00004  *   G_location_path()
00005  *
00006  *   returns pointer to the full path name to the current location
00007  *
00008  *   note:
00009  *      exits with message if path not accessible to user
00010  **********************************************************************
00011  *
00012  *   char *
00013  *   G_location()
00014  *
00015  *   returns:    pointer to string containing the one word location
00016  *               name.
00017  **********************************************************************/
00018 
00019 #include <string.h>
00020 #include <unistd.h>
00021 #include "gis.h"
00022 #include "glocale.h"
00023 
00024 
00038 char *
00039 G_location_path()
00040 {
00041     char *location;
00042 
00043     location = G__location_path();
00044     if(access(location,0) != 0) 
00045     {
00046         char msg[400];
00047 
00048         sprintf(msg,_("LOCATION  << %s >>  not available"), location) ;
00049         G_fatal_error (msg);
00050     }
00051 
00052     return location;
00053 }
00054 
00055 
00068 char *
00069 G_location()
00070 {
00071     return G_getenv ("LOCATION_NAME");
00072 }
00073 
00074 char *
00075 G__location_path()
00076 {
00077     char *location = 0;
00078     char *base;
00079     char *name;
00080 
00081     name      = G_location();
00082     base      = G_gisdbase();
00083     location  = G_malloc (strlen (base) + strlen (name) + 2);
00084     sprintf (location, "%s/%s", base, name);
00085 
00086     return location;
00087 }

Generated on Wed Aug 23 17:49:22 2006 for GRASS by  doxygen 1.4.7