lrt_tuxreadenv

Environment Variable Functions

Adds variables to the environment from a file.

int lrt_tuxreadenv( char *file, char *label );

file Pointer to the variable file.
label Label for sections within the file.

The variable file has the following format:
Leading spaces or tabs are ignored; lines beginning with a slash (/), pound sign (#) or exclamation point (!) are treated as comment lines; variable lines are in the format "variable=value" or "set variable=value" where variable must begin with an alphabetic or underscore character and contain only alphanumeric or underscore characters. Value may contain any characters except newline. label follows the same rules as variable.

The lrt_tuxreadenv function reads a file containing environment variables and adds them to the environment. This function is useful for portability of environment values across different platforms that don't normally have environment variables.

Return Values

If the function succeeds, it returns 0. Otherwise, it returns a non-zero value if it was unable to allocate enough space for an expanded environment or if it was unable to open and read a non-NULL file name.

Parameterization

The following argument(s) can be parameterized using standard parameterization: file, label

Example

The following example shows how to work with environment variables in conjunction with lrt functions. The lrt_tuxreadenv function reads the file containing the environment variables.

Copy code
// set the server address
lrt_tuxputenv("WSNADDR=//server:65535");                                                                        
// find out what which natural language used.
lrt_tuxgetenv("NLSPATH");                                                    
// use default settings to get environment information.
lrt_tuxreadenv(NULL, NULL);