mach_name.c

Go to the documentation of this file.
00001 #include <unistd.h>
00002 #include "gis.h"
00003 /* this routine returns a name for the machine
00004  * it returns the empty string, if this info
00005  * not available (it never returns a NULL pointer)
00006  *
00007  * the name is stored in a static array and the pointer to this
00008  * array is returned.
00009  *
00010  * the contents of this array are reset upon each call
00011  *
00012  */
00013 
00014 #include "config.h"
00015 
00016 #ifdef HAVE_SYS_UTSNAME_H
00017 #include <sys/utsname.h>
00018 static struct utsname attname;
00019 #endif
00020 
00021 char *
00022 G__machine_name()
00023 {
00024     static char name[128];
00025 
00026     *name = 0;
00027 
00028 #ifdef HAVE_GETHOSTNAME
00029     gethostname(name, sizeof(name));
00030     name[sizeof(name)-1] = 0;   /* make sure null terminated */
00031 #else
00032 #ifdef HAVE_UNAME
00033     uname (&attname);
00034     strcpy (name, attname.nodename);
00035 #endif
00036 #endif
00037 
00038     return (name);
00039 }

Generated on Mon Jan 1 19:49:25 2007 for GRASS by  doxygen 1.5.1