Main Page   Modules   Alphabetical List   Compound List   File List   Compound Members   File Members  

PSConfig

PS library configuration routines. More...

Functions

int psConfigGetValue (char *fileName, char *section, char *name, char *value, char *deflt)
 Retrieve value from configuration file. More...

int psConfigSetValue (char *fileName, char *section, char *name, char *value)
 Sets a configuration value. More...

int psConfigRead (char *sysConfDir)
 Read in libps configuration values. More...


Detailed Description

PS library configuration routines.


Function Documentation

int psConfigGetValue ( char * fileName,
char * section,
char * name,
char * value,
char * deflt )
 

Retrieve value from configuration file.

Retrieves the configuration value associated with name in section section from the file named by fileName.

If deflt is not null and name is not found, it will be added to the file and value will contain deflt and it will return 0.

Parameters:
fileName   pointer to name of config file
section   pointer to section name
name   pointer to value name
value   pointer to buffer to hold value
deflt   pointer to default value (may be NULL)

Returns:
0 on success or the following on error:

1 Unable to open fileName 2 Unable to find section in file 3 Unable to find name in section

Warning:
value should be large enough to hold the largest value possible. The routine is case not sensitive. Max line should not exceed PS_CONFIG_MAX_LINE_LEN chars.

int psConfigRead ( char * sysConfDir )
 

Read in libps configuration values.

This routine first checks the users local config file then the system config file. This function should be called before any other functions in the library.

Parameters:
sysConfDir   pointer to system configuration file directory. By default this is set to PS_DEFAULT_SYSCONFIG_DIR (usually /etc). Set this to your own value or NULL to use the default.

Returns:
non-zero on success or 0 on failure and sets pserrno.

int psConfigSetValue ( char * fileName,
char * section,
char * name,
char * value )
 

Sets a configuration value.

This function sets the configuration value for name in section section to value or adds name and value to the file named by fileName.

NOTES: The main idea here is to scan through the file writing lines to a temporary file. If we find the correct section and name we will modify the value and replace that line. If we don't find the section at all or the file doesn't exist, we will add the section and name. If we find the section but not the name, we will add the name to the section. Comments will be copied faithfully. Once we are done with all of this we will remove the old file and rename the temporary file to the old file's name (should make it salvageable).

Parameters:
fileName   pointer to name of config file
section   pointer to section name
name   pointer to value name
value   pointer to value

Returns:
0 on success or one 1 if unable to open fileName


Generated at Mon Dec 11 22:46:31 2000 for Postscript Utility Library by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000