GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
progrm_nme.c
Go to the documentation of this file.
1 
2 /**********************************************************************
3  *
4  * char *
5  * G_program_name()
6  *
7  * returns the current program name
8  *
9  **********************************************************************
10  *
11  * G_set_program_name(name)
12  * char *name
13  *
14  * program name set to name (name will be returned by G_program_name
15  *
16  **********************************************************************/
17 #include <string.h>
18 #include <grass/gis.h>
19 
20 static const char *name = "?";
21 
22 
33 const char *G_program_name(void)
34 {
35  return name;
36 }
37 
38 int G_set_program_name(const char *s)
39 {
40  int i;
41  char *temp;
42 
43  i = strlen(s);
44  while (--i >= 0) {
45  if (G_is_dirsep(s[i])) {
46  s += i + 1;
47  break;
48  }
49  }
50  temp = G_store(s);
51  G_basename(temp, "exe");
52  name = G_store(temp);
53  G_free(temp);
54 
55  return 0;
56 }
void G_free(void *buf)
Free allocated memory.
Definition: gis/alloc.c:142
char * G_store(const char *s)
Copy string to allocated memory.
Definition: store.c:32
string name
Definition: render.py:1314
char * G_basename(char *filename, const char *desired_ext)
Truncates filename to the base part (before the last &#39;.&#39;) if it matches the extension, otherwise leaves it unchanged.
Definition: basename.c:37
const char * G_program_name(void)
return module name
Definition: progrm_nme.c:33
int G_set_program_name(const char *s)
Definition: progrm_nme.c:38
int G_is_dirsep(char c)
Checks if a specified character is a valid directory separator character on the host system...
Definition: paths.c:35