00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include <stdlib.h>
00017 #include "gis.h"
00018 #include "glocale.h"
00019
00020
00031 char *
00032 G_home ()
00033 {
00034 char *home;
00035
00046 char *G_home();
00047
00048 if ((home = G__home()))
00049 return home;
00050
00051 G_fatal_error (_("unable to determine user's home directory"));
00052 exit(-1);
00053 }
00054
00055 char *
00056 G__home ()
00057 {
00058 static char *home = 0;
00059 char buf[1024];
00060 FILE *fd,*G_popen();
00061
00062
00063
00064
00065
00066 if (!home)
00067 {
00068 if((fd = G_popen ("cd; pwd","r")))
00069 {
00070 if (fscanf (fd,"%s", buf) == 1)
00071 home = G_store (buf);
00072 G_pclose (fd);
00073 }
00074 }
00075
00076 return home;
00077 }