Loading...
Searching...
No Matches
progrm_nme.c
Go to the documentation of this file.
/*!
* \file lib/gis/progrm_nme.c
*
* \brief GIS Library - Program name
*
* (C) 2001-2014 by the GRASS Development Team
*
* This program is free software under the GNU General Public License
* (>=v2). Read the file COPYING that comes with GRASS for details.
*
* \author Original author CERL
*/
#include <string.h>
#include <grass/gis.h>
static const char *name = "?";
static const char *original_name = "?";
/*!
* \brief Return module name
*
* Routine returns the name of the module as set by the call to
* G_gisinit().
*
* \return pointer to string with program name
*/
const char *G_program_name(void)
{
return name;
}
/*!
* \brief Return original path of the executed program
*
* This function returns the name of the program as set by the call to
* G_gisinit().
*
* Unlike G_program_name() which returns name of the module
* this function return original path which was used to execute
* the program. For standard GRASS modules, it will be the same as
* the result from G_program_name() function.
*
* \return pointer to string with program name or full path
*/
const char *G_original_program_name(void)
{
return original_name;
}
/*!
\brief Set program name
Program name set to name (name will be returned by
G_program_name*())
Extension like .exe or .py is stripped from program name.
\param s program name
*/
void G_set_program_name(const char *s)
{
int i;
char *temp;
original_name = G_store(s);
i = strlen(s);
while (--i >= 0) {
if (G_is_dirsep(s[i])) {
s += i + 1;
break;
}
}
/* strip extension from program name */
temp = G_store(s);
G_basename(temp, "exe");
G_basename(temp, "py");
name = G_store(temp);
G_debug(1, "G_set_program_name(): %s", name);
G_free(temp);
}
G_free
void G_free(void *buf)
Free allocated memory.
Definition alloc.c:147
G_basename
char * G_basename(char *filename, const char *desired_ext)
Truncates filename to the base part (before the last '.') if it matches the extension,...
Definition basename.c:36
G_debug
int G_debug(int level, const char *msg,...)
Print debugging message.
Definition debug.c:66
name
const char * name
Definition named_colr.c:6
G_is_dirsep
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
G_program_name
const char * G_program_name(void)
Return module name.
Definition progrm_nme.c:28
G_set_program_name
void G_set_program_name(const char *s)
Set program name.
Definition progrm_nme.c:61
G_original_program_name
const char * G_original_program_name(void)
Return original path of the executed program.
Definition progrm_nme.c:46
G_store
char * G_store(const char *s)
Copy string to allocated memory.
Definition strings.c:87