GRASS GIS 7 Programmer's Manual  7.0.2(2015)-r00000
progrm_nme.c
Go to the documentation of this file.
1 
14 #include <string.h>
15 #include <grass/gis.h>
16 
17 static const char *name = "?";
18 
27 const char *G_program_name(void)
28 {
29  return name;
30 }
31 
42 void G_set_program_name(const char *s)
43 {
44  int i;
45  char *temp;
46 
47  i = strlen(s);
48  while (--i >= 0) {
49  if (G_is_dirsep(s[i])) {
50  s += i + 1;
51  break;
52  }
53  }
54 
55  /* strip extension from program name */
56  temp = G_store(s);
57  G_basename(temp, "exe");
58  G_basename(temp, "py");
59  name = G_store(temp);
60 
61  G_debug(1, "G_set_program_name(): %s", name);
62 
63  G_free(temp);
64 }
char * G_store(const char *s)
Copy string to allocated memory.
Definition: strings.c:86
void G_set_program_name(const char *s)
Set program name.
Definition: progrm_nme.c:42
int G_debug(int level, const char *msg,...)
Print debugging message.
Definition: debug.c:65
char * G_basename(char *filename, const char *desired_ext)
Truncates filename to the base part (before the last '.') if it matches the extension, otherwise leaves it unchanged.
Definition: basename.c:38
const char * G_program_name(void)
Return module name.
Definition: progrm_nme.c:27
const char * name
Definition: named_colr.c:7
int G_is_dirsep(char c)
Checks if a specified character is a valid directory separator character on the host system...
Definition: paths.c:45
void G_free(void *buf)
Free allocated memory.
Definition: alloc.c:149