GRASS GIS 8 Programmer's Manual  8.2.2dev(2023)-3d2c704037
gisbase.c
Go to the documentation of this file.
1 
2 /**********************************************************************
3  *
4  * char *
5  * G_gisbase()
6  *
7  * returns: pointer to string containing the base directory of
8  * GRASS-GRID
9  **********************************************************************/
10 
11 #include <grass/gis.h>
12 
13 
14 /*!
15  * \brief Get full path name of the top level module directory
16  *
17  * Returns the full path name of the top level directory for GRASS
18  * programs. This directory will have subdirectories which will
19  * contain modules and files required for the running of the
20  * system. Some of these directories are:
21 
22  \verbatim
23  bin commands run by the user
24  etc modules and data files used by GRASS commands
25  \endverbatim
26 
27  * The use of G_gisbase() to find these subdirectories enables GRASS
28  * modules to be written independently of where the GRASS system is
29  * actually installed on the machine. For example, to run the module
30  * <i>sroff</i> in the GRASS <i>etc</i> directory:
31 
32  \code
33  char command[200];
34 
35  sprintf(command, "%s/etc/sroff", G_gisbase());
36  G_spawn(command, "sroff", NULL);
37  \endcode
38  *
39  * \return pointer to a string
40  */
41 const char *G_gisbase(void)
42 {
43  return G_getenv("GISBASE");
44 }
const char * G_gisbase(void)
Get full path name of the top level module directory.
Definition: gisbase.c:41
const char * G_getenv(const char *)
Get environment variable.
Definition: env.c:353