Main Page | Class List | File List | Class Members | File Members | Related Pages

conf.h File Reference

Configuration file routines. More...

Go to the source code of this file.

Classes

struct  ConfigHeader
struct  Config

Functions

EXTERN_C_BEGIN LIBGIFT_EXPORT
Config
config_new (char *file)
LIBGIFT_EXPORT Configconfig_new_ex (char *file, int comments_allowed)
LIBGIFT_EXPORT void config_free (Config *conf)
LIBGIFT_EXPORT void config_write (Config *conf)
LIBGIFT_EXPORT void config_set_str (Config *conf, char *keypath, char *value)
LIBGIFT_EXPORT void config_set_int (Config *conf, char *keypath, int value)
LIBGIFT_EXPORT char * config_get_str (Config *conf, char *keypath)
LIBGIFT_EXPORT int config_get_int (Config *conf, char *keypath)
LIBGIFT_EXPORT Configgift_config_new (char *module)
LIBGIFT_EXPORT char * gift_conf_path (const char *fmt,...)
LIBGIFT_EXPORT char * gift_conf_path_r (char *buf, size_t buf_size, const char *fmt,...)
LIBGIFT_EXPORT char * gift_conf_pathkey (Config *conf, char *key, char *def, char *file)


Detailed Description

Configuration file routines.

Provides routines that can be used to manipulate INI-style configuration files. These routines properly preserve formatting and comments within the original files.


Function Documentation

LIBGIFT_EXPORT void config_free Config conf  ) 
 

Destroys the memory associated with a Config pointer.

Parameters:
conf Location of the Config structure.

LIBGIFT_EXPORT int config_get_int Config conf,
char *  keypath
 

Gets a configuration key's value from memory converted to a signed integer.

See also:
config_get_str

LIBGIFT_EXPORT char* config_get_str Config conf,
char *  keypath
 

Gets a configuration key's value from memory as a string.

Note:
When reading data from the configuration structure the key path format may optionally include append "=DEFAULT". If the key was not found to exist in the structure, "DEFAULT" will be returned as if it did.
Parameters:
conf Location of the Config structure.
keypath Key path in the form "header/key".
Returns:
Configuration value.
Return values:
!NULL pointer to internally used memory, do not write to this pointer or God will kill an innocent puppy.
NULL failure to lookup the requested key (and no default was provided).

EXTERN_C_BEGIN LIBGIFT_EXPORT Config* config_new char *  file  ) 
 

Loads a configuration file into memory.

Parameters:
file Fully qualified path of the conf file.
Returns:
Dynamically allocated Config pointer.

LIBGIFT_EXPORT Config* config_new_ex char *  file,
int  comments_allowed
 

Extended constructor. See config_new.

Parameters:
file 
comments_allowed If FALSE, comments will not be parsed out of configuration file. Literal '#' characters will be saved.

LIBGIFT_EXPORT void config_set_int Config conf,
char *  keypath,
int  value
 

Sets a configuration key in memory using a signed integer value.

See also:
config_set_str

LIBGIFT_EXPORT void config_set_str Config conf,
char *  keypath,
char *  value
 

Sets a configuration key in memory using a string value.

Parameters:
conf Location of the Config structure.
keypath Key path in the form "header/key".
value Value to assign to the key when found.

LIBGIFT_EXPORT void config_write Config conf  ) 
 

Attempts to synch the possibly formatted configuration file on disk with the data loaded into memory.

Parameters:
conf Location of the Config structure.

LIBGIFT_EXPORT char* gift_conf_path const char *  fmt,
  ...
 

Completely unrelated extension that merely interprets the supplied printf format string and prepends the platform-specific local dir, which will be $HOME/.giFT by default on UNIX hosts. For thread-safety, see gift_conf_path_r.

Note:
Requires platform_init before usage.
Parameters:
fmt printf format string.
... c'mon, you know.
Returns:
Pointer to the internal static buffer used to build the configuration path.

LIBGIFT_EXPORT char* gift_conf_path_r char *  buf,
size_t  buf_size,
const char *  fmt,
  ...
 

gift_conf_path with thread-safety. Uses the supplied buffer for storing the resulting path. On success, the calling argument `buf' will be returned.

LIBGIFT_EXPORT char* gift_conf_pathkey Config conf,
char *  key,
char *  def,
char *  file
 

Return an expanded path from the configuration file with a fallback result from gift_conf_path. Example:

gift_conf_pathkey (conf, "search/env_path", gift_conf_path ("OpenFT/db"), "master.idx");

Parameters:
conf 
key 
def 
file 
Returns:
Pointer to local memory from config_get_str or stringf.

LIBGIFT_EXPORT Config* gift_config_new char *  module  ) 
 

Extension specific to giFT that is used to load configuration modules from the ~/.giFT/ directory path.

Note:
Requires platform_init before usage.
Parameters:
module Module name to load (one of giFT, OpenFT, or ui).
See also:
config_new


Generated on Sun Aug 22 08:07:10 2004 by doxygen 1.3.7