00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include <stdlib.h>
00017 #include <string.h>
00018 #include <grass/gis.h>
00019 #include <grass/glocale.h>
00020
00021
00032 char *G_home(void)
00033 {
00034 char *home = G__home();
00035
00036 if (home)
00037 return home;
00038
00039 G_fatal_error(_("unable to determine user's home directory"));
00040 return NULL;
00041 }
00042
00043 char *G__home(void)
00044 {
00045 static char *home = 0;
00046
00047 if (home)
00048 return home;
00049
00050 #ifdef __MINGW32__
00051 {
00052 char buf[GPATH_MAX];
00053
00054
00055 home = getenv("USERPROFILE");
00056
00057 if (!home) {
00058 sprintf(buf, "%s%s", getenv("HOMEDRIVE"), getenv("HOMEPATH"));
00059
00060 if (strlen(buf) >= 0)
00061 home = G_store(buf);
00062 }
00063
00064 if (!home)
00065 home = getenv("HOME");
00066 }
00067 #else
00068 home = getenv("HOME");
00069 #endif
00070 return home;
00071 }