GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
env.c File Reference

GIS library - environment routines. More...

#include <signal.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
#include <grass/glocale.h>
Include dependency graph for env.c:

Go to the source code of this file.

Macros

#define ENV   struct env
 

Functions

void G_set_gisrc_mode (int mode)
 Set where to find/store variables. More...
 
int G_get_gisrc_mode (void)
 Get info where variables are stored. More...
 
char * G_getenv (const char *name)
 Get environment variable. More...
 
char * G_getenv2 (const char *name, int loc)
 Read variable from specific place. More...
 
char * G__getenv (const char *name)
 Get environment variable. More...
 
char * G__getenv2 (const char *name, int loc)
 Get environment variable from specific place. More...
 
int G_setenv (const char *name, const char *value)
 Set environment variable. More...
 
int G_setenv2 (const char *name, const char *value, int loc)
 Set environment variable from specific place. More...
 
int G__setenv (const char *name, const char *value)
 Set environment name to value. More...
 
int G__setenv2 (const char *name, const char *value, int loc)
 Set environment name to value from specific place. More...
 
int G_unsetenv (const char *name)
 Remove name from environment. More...
 
int G_unsetenv2 (const char *name, int loc)
 Remove name from environment from specific place. More...
 
int G__write_env (void)
 Writes current environment to .gisrc. More...
 
char * G__env_name (int n)
 Get variable name for index n. More...
 
int G__read_env (void)
 Initialize init array for G_VAR_GISRC. More...
 
int G__set_gisrc_file (const char *name)
 Sets filename for gisrc. More...
 
char * G__get_gisrc_file (void)
 Get gisrc filename. More...
 
int G__create_alt_env (void)
 Set up alternative environment variables. More...
 
int G__switch_env (void)
 Switch environments. More...
 

Variables

 ENV
 
char * name
 
char * value
 

Detailed Description

GIS library - environment routines.

(C) 2001-2008 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

Definition in file env.c.

Macro Definition Documentation

#define ENV   struct env

Definition at line 25 of file env.c.

Referenced by G__switch_env().

Function Documentation

int G__create_alt_env ( void  )

Set up alternative environment variables.

Parameters
\return0

Definition at line 537 of file env.c.

References count, main::env, and NULL.

Referenced by G__make_mapset().

char* G__env_name ( int  n)

Get variable name for index n.

For example:

for (n = 0; ; n++)
if ((name = G__env_name(n)) == NULL)
break;
Parameters
nindex of variable
Returns
pointer to variable name

Definition at line 476 of file env.c.

References count, main::env, and NULL.

char* G__get_gisrc_file ( void  )

Get gisrc filename.

Parameters
\returnchar pointer to filename

Definition at line 525 of file env.c.

char* G__getenv ( const char *  name)

Get environment variable.

Parameters
namevariable name
Returns
char pointer to value for name
NULL if name not set

Definition at line 312 of file env.c.

References getenv().

Referenced by db_start_driver(), dig_angle_next_line(), dig_build_area_with_line(), dig_file_load(), F_generate(), G__mapset(), G_check_overwrite(), G_debug(), G_getenv(), main(), submit(), and Vect_select_areas_by_box().

char* G__getenv2 ( const char *  name,
int  loc 
)

Get environment variable from specific place.

Parameters
namevariable name
loclocation id
Returns
char pointer to value for name
NULL if name not set

Definition at line 331 of file env.c.

References getenv().

Referenced by db_get_connection(), db_get_default_database_name(), db_get_default_driver_name(), db_get_default_group_name(), db_get_default_schema_name(), G_getenv2(), and Vect_default_field_info().

int G__read_env ( void  )

Initialize init array for G_VAR_GISRC.

Parameters
\return0

Definition at line 495 of file env.c.

References init().

Referenced by F_generate().

int G__set_gisrc_file ( const char *  name)

Sets filename for gisrc.

Parameters
namefilename
Returns
0

Definition at line 509 of file env.c.

References G_store(), and NULL.

int G__setenv ( const char *  name,
const char *  value 
)

Set environment name to value.

Parameters
namevariable name
valuevariable value
Returns
0

Definition at line 388 of file env.c.

Referenced by db_driver(), G__make_location(), G__make_mapset(), G_check_overwrite(), main(), and make_location().

int G__setenv2 ( const char *  name,
const char *  value,
int  loc 
)

Set environment name to value from specific place.

Parameters
namevariable name
valuevariable value
loclocation id
Returns
0

Definition at line 404 of file env.c.

int G__switch_env ( void  )

Switch environments.

Parameters
\return0

Definition at line 561 of file env.c.

References count, ENV, main::env, and n.

Referenced by G__make_mapset().

int G__write_env ( void  )

Writes current environment to .gisrc.

Parameters
\return0

Definition at line 454 of file env.c.

References init().

Referenced by main().

int G_get_gisrc_mode ( void  )

Get info where variables are stored.

Parameters
\returnmode

Definition at line 71 of file env.c.

Referenced by db_start_driver().

char* G_getenv ( const char *  name)

Get environment variable.

Calls G_fatal_error() if name not set.

Parameters
namevariable name
Returns
char pointer to value for name

Definition at line 267 of file env.c.

References G__getenv(), G_fatal_error(), NULL, and value.

Referenced by db_driver(), G_gisbase(), G_gisdbase(), G_gishelp(), G_location(), and main().

char* G_getenv2 ( const char *  name,
int  loc 
)

Read variable from specific place.

Locations:

  • G_VAR_GISRC
  • G_VAR_MAPSET

G_fatal_error() is called when variable is not found.

Parameters
namevariable name
loclocation id
Returns
variable value
NULL if not found

Definition at line 293 of file env.c.

References G__getenv2(), G_fatal_error(), NULL, and value.

void G_set_gisrc_mode ( int  mode)

Set where to find/store variables.

Modes:

  • G_GISRC_MODE_FILE
  • G_GISRC_MODE_MEMORY
Parameters
modemode to find/store variables (G_GISRC_MODE_FILE by default)
Returns

Definition at line 59 of file env.c.

References tools::mode.

Referenced by db_driver().

int G_setenv ( const char *  name,
const char *  value 
)

Set environment variable.

If value is NULL, becomes an G_unsetenv(). Updates .gisrc

Parameters
namevariable name
valuevariable value
Returns
0

Definition at line 352 of file env.c.

Referenced by submit().

int G_setenv2 ( const char *  name,
const char *  value,
int  loc 
)

Set environment variable from specific place.

If value is NULL, becomes an G_unsetenv(). Updates .gisrc

Parameters
namevariable name
valuevariable value
loclocation id
Returns
0

Definition at line 372 of file env.c.

Referenced by db_set_connection().

int G_unsetenv ( const char *  name)

Remove name from environment.

Updates .gisrc

Parameters
namevariable name
Returns
0

Definition at line 420 of file env.c.

Referenced by main().

int G_unsetenv2 ( const char *  name,
int  loc 
)

Remove name from environment from specific place.

Updates .gisrc

Parameters
namevariable name
Returns
0

Definition at line 438 of file env.c.

Variable Documentation

ENV
Initial value:
{
int loc

Definition at line 27 of file env.c.

char* name

Definition at line 29 of file env.c.