• Main Page
  • Related Pages
  • Data Structures
  • Files
  • File List
  • Globals

whoami.c

Go to the documentation of this file.
00001 
00017 #include <unistd.h>
00018 #include <stdlib.h>
00019 
00020 #ifndef __MINGW32__
00021 #include <pwd.h>
00022 #endif
00023 
00024 #include <grass/gis.h>
00025 
00026 
00040 char *G_whoami(void)
00041 {
00042 #ifdef __MINGW32__
00043     char *name = getenv("USERNAME");
00044 
00045     if (name == NULL) {
00046         name = "user_name";
00047     }
00048 #else
00049     static char *name = NULL;
00050 
00051 #ifdef COMMENTED_OUT
00052     char *getlogin();
00053     char *ttyname();
00054 
00055     if (name == NULL) {
00056         char *x;
00057 
00058         x = ttyname(0);
00059         if (x && *x) {
00060             x = getlogin();
00061             if (x && *x)
00062                 name = G_store(x);
00063         }
00064     }
00065 #endif /* COMMENTED_OUT */
00066 
00067     if (name == NULL) {
00068         struct passwd *p;
00069 
00070         if ((p = getpwuid(getuid())))
00071             name = G_store(p->pw_name);
00072     }
00073     if (name == NULL)
00074         name = G_store("?");
00075 
00076 #endif
00077 
00078     return name;
00079 }

Generated on Wed Oct 13 2010 12:09:30 for GRASS Programmer's Manual by  doxygen 1.7.1