GRASS Programmer's Manual  6.4.2(2012)
progrm_nme.c
Go to the documentation of this file.
00001 
00002 /**********************************************************************
00003  *
00004  *   char *
00005  *   G_program_name()
00006  *
00007  *   returns the current program name
00008  *
00009  **********************************************************************
00010  *
00011  *   G_set_program_name(name)
00012  *        char *name 
00013  *
00014  *   program name set to name (name will be returned by G_program_name
00015  *
00016  **********************************************************************/
00017 #include <string.h>
00018 #include <grass/gis.h>
00019 
00020 static const char *name = "?";
00021 
00022 
00033 const char *G_program_name(void)
00034 {
00035     return name;
00036 }
00037 
00038 int G_set_program_name(const char *s)
00039 {
00040     int i;
00041     char *temp;
00042 
00043     i = strlen(s);
00044     while (--i >= 0) {
00045         if (G_is_dirsep(s[i])) {
00046             s += i + 1;
00047             break;
00048         }
00049     }
00050     temp = G_store(s);
00051     G_basename(temp, "exe");
00052     name = G_store(temp);
00053     G_free(temp);
00054 
00055     return 0;
00056 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines