Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

conf.h File Reference

#include <stdio.h>

Go to the source code of this file.

Defines

#define CONFIGMODE_PATHMUSTEXIST   0x000001
#define CONFIGMODE_PATHMUSTNOTEXIST   0x000002
#define CONFIGMODE_PATHCREATE   0x000004
#define CONFIGMODE_NAMEMUSTEXIST   0x000008
#define CONFIGMODE_NAMEMUSTNOTEXIST   0x000010
#define CONFIGMODE_NAMECREATE_GROUP   0x000020
#define CONFIGMODE_NAMECREATE_VARIABLE   0x000040
#define CONFIGMODE_VARIABLE   0x000080
#define CONFIGMODE_OVERWRITE_VARS   0x000100
#define CONFIGMODE_OVERWRITE_GROUPS   0x000200
#define CONFIGMODE_REMOVE_QUOTES   0x000400
#define CONFIGMODE_REMOVE_STARTING_BLANKS   0x000800
#define CONFIGMODE_REMOVE_TRAILING_BLANKS   0x001000
#define CONFIGMODE_ALLOW_PATH_IN_VARS   0x002000
#define CONFIGMODE_ALLOW_GROUPS   0x004000
#define CONFIGMODE_EMPTY_GROUPS   0x008000

Functions

CHIPCARD_API CONFIGGROUPConfig_new ()
CHIPCARD_API void Config_free (CONFIGGROUP *g)
CHIPCARD_API const char * Config_GetValue (CONFIGGROUP *root, const char *path, const char *defaultValue, int idx)
CHIPCARD_API int Config_GetIntValue (CONFIGGROUP *root, const char *path, int defaultValue, int idx)
CHIPCARD_API int Config_SetValue (CONFIGGROUP *root, unsigned int mode, const char *path, const char *value)
CHIPCARD_API int Config_SetIntValue (CONFIGGROUP *root, unsigned int mode, const char *path, int value)
CHIPCARD_API int Config_AddValue (CONFIGGROUP *root, unsigned int mode, const char *path, const char *value)
CHIPCARD_API int Config_ClearVariable (CONFIGGROUP *root, unsigned int mode, const char *path)
CHIPCARD_API CONFIGGROUPConfig_ParseLine (CONFIGGROUP *root, CONFIGGROUP *group, const char *s, int mode)
CHIPCARD_API int Config_ReadFile (CONFIGGROUP *root, const char *fname, int mode)
CHIPCARD_API int Config_WriteFile (CONFIGGROUP *root, const char *fname, int mode)
CHIPCARD_API void Config_AddVariable (CONFIGGROUP *p, CONFIGVARIABLE *v)
CHIPCARD_API int Config_DumpGroup (FILE *f, CONFIGGROUP *root, int ins)
CHIPCARD_API CONFIGGROUPConfig_GetGroup (CONFIGGROUP *root, const char *path, unsigned int mode)
CHIPCARD_API void Config_AddGroup (CONFIGGROUP *p, CONFIGGROUP *w)
void Config_ImportTreeChildren (CONFIGGROUP *p, CONFIGGROUP *g)
CHIPCARD_API void Config_UnlinkGroup (CONFIGGROUP *p, CONFIGGROUP *w)
CHIPCARD_API void Config_ClearGroup (CONFIGGROUP *g)
CHIPCARD_API CONFIGGROUPConfig_Duplicate (CONFIGGROUP *root)
CHIPCARD_API void Config_ImportGroup (CONFIGGROUP *root, CONFIGGROUP *g)
CHIPCARD_API int Config_Compare (const char *s1, const char *s2)

Variables

typedefCHIPCARD_API struct
CONFIGVALUESTRUCT 
CONFIGVALUE
typedefCHIPCARD_API struct
CONFIGVARIABLESTRUCT 
CONFIGVARIABLE
typedefCHIPCARD_API struct
CONFIGGROUPSTRUCT 
CONFIGGROUP


Detailed Description

This file contains the configuration file parser and generator

Define Documentation

#define CONFIGMODE_ALLOW_GROUPS   0x004000
 

#define CONFIGMODE_ALLOW_PATH_IN_VARS   0x002000
 

#define CONFIGMODE_EMPTY_GROUPS   0x008000
 

#define CONFIGMODE_NAMECREATE_GROUP   0x000020
 

#define CONFIGMODE_NAMECREATE_VARIABLE   0x000040
 

#define CONFIGMODE_NAMEMUSTEXIST   0x000008
 

#define CONFIGMODE_NAMEMUSTNOTEXIST   0x000010
 

#define CONFIGMODE_OVERWRITE_GROUPS   0x000200
 

#define CONFIGMODE_OVERWRITE_VARS   0x000100
 

#define CONFIGMODE_PATHCREATE   0x000004
 

#define CONFIGMODE_PATHMUSTEXIST   0x000001
 

#define CONFIGMODE_PATHMUSTNOTEXIST   0x000002
 

#define CONFIGMODE_REMOVE_QUOTES   0x000400
 

#define CONFIGMODE_REMOVE_STARTING_BLANKS   0x000800
 

#define CONFIGMODE_REMOVE_TRAILING_BLANKS   0x001000
 

#define CONFIGMODE_VARIABLE   0x000080
 


Function Documentation

CHIPCARD_API void Config_AddGroup CONFIGGROUP p,
CONFIGGROUP w
 

Adds a group to another one. The new group becomes the child of the existing one.

Parameters:
p parent (group to which to add the new group)
w new group to add

CHIPCARD_API int Config_AddValue CONFIGGROUP root,
unsigned int  mode,
const char *  path,
const char *  value
 

Adds a value to a given variable.

Parameters:
root root to which the path is relative
mode this specifies how the value is set. This mode consists of one or multiple "CONFIGMODE_XXX" values which may be ORed.
path path of the variable (e.g. "global/settings/var1")
value value to add

CHIPCARD_API void Config_AddVariable CONFIGGROUP p,
CONFIGVARIABLE v
 

Adds a variable to a given group.

CHIPCARD_API void Config_ClearGroup CONFIGGROUP g  ) 
 

Clears a group, so all it's subgroups and variables are destroyed.

CHIPCARD_API int Config_ClearVariable CONFIGGROUP root,
unsigned int  mode,
const char *  path
 

Clears a variable, so all it's values are destroyed.

CHIPCARD_API int Config_Compare const char *  s1,
const char *  s2
 

Just a conveniance function for case insensitive compares. Well, meanwhile I now that there already are such functions ;-)

Returns:
result of "s1-s2"

CHIPCARD_API int Config_DumpGroup FILE *  f,
CONFIGGROUP root,
int  ins
 

Dumps the content of a configuration into an open file. This is used for debugging purposes, where f is stderr.

Parameters:
f file to dump to (most cases "stderr")
root group to dump
ins number of spaces to prepend to each output line, this is used to show hierarchies.

CHIPCARD_API CONFIGGROUP* Config_Duplicate CONFIGGROUP root  ) 
 

Duplicates a group. The new group is a deep copy of the original.

CHIPCARD_API void Config_free CONFIGGROUP g  ) 
 

Destructor.

CHIPCARD_API CONFIGGROUP* Config_GetGroup CONFIGGROUP root,
const char *  path,
unsigned int  mode
 

Lookup a group by its name.

CHIPCARD_API int Config_GetIntValue CONFIGGROUP root,
const char *  path,
int  defaultValue,
int  idx
 

Get an integer value. This internally calls Config_GetValue, please see there for details.

CHIPCARD_API const char* Config_GetValue CONFIGGROUP root,
const char *  path,
const char *  defaultValue,
int  idx
 

Get the value of a variable or a default value if the variable does not exist or doesn't have a value.

Parameters:
root root to which the path is relative
path path and name of the variable (e.g. "global/settings/var1")
defaultValue this value is returned if the variable does not exist or if the variable has no value
idx a variable may have multiple values, so you can choose here which value you want (starting with 0)

CHIPCARD_API void Config_ImportGroup CONFIGGROUP root,
CONFIGGROUP g
 

Imports a new group into an existing configuration (including all the subgroups and variables of the given group)

void Config_ImportTreeChildren CONFIGGROUP p,
CONFIGGROUP g
 

Adds all groups and variables which are the children of the given group to the given parent by making deep copies.

CHIPCARD_API CONFIGGROUP* Config_new  ) 
 

Constructor. Please always use this constructor to create a configuration structure.

CHIPCARD_API CONFIGGROUP* Config_ParseLine CONFIGGROUP root,
CONFIGGROUP group,
const char *  s,
int  mode
 

This function parses a text line and stores variables/groups read in the given root.

Returns:
current group (this may have changed depending on the content of the text line just parsed
Parameters:
root root to which all paths are relative
group current group within the root, this is the group all variables parsed are relative to. Please note that group paths are relative to the root, not to group !
mode specifies how to store the groups and variables. The mode consists of one or multiple CONFIGMODE_XYZ values which may be logically ORed.

CHIPCARD_API int Config_ReadFile CONFIGGROUP root,
const char *  fname,
int  mode
 

Reads a configuration file and parses it.

Parameters:
fname path and name of the file to read.
mode specifies how to store the groups and variables. The mode consists of one or multiple CONFIGMODE_XYZ values which may be logically ORed.

CHIPCARD_API int Config_SetIntValue CONFIGGROUP root,
unsigned int  mode,
const char *  path,
int  value
 

This is just a conveniance function which internally calls Config_SetValue. Please see there for details.

CHIPCARD_API int Config_SetValue CONFIGGROUP root,
unsigned int  mode,
const char *  path,
const char *  value
 

Set the value of a variable in respect to the mode given.

Parameters:
root root to which the path is relative
mode this specifies how the value is set. This mode consists of one or multiple "CONFIGMODE_XXX" values which may be ORed.
path path of the variable (e.g. "global/settings/var1")
value value to set

CHIPCARD_API void Config_UnlinkGroup CONFIGGROUP p,
CONFIGGROUP w
 

Unlinks a group from the configuration. This group will not be destroyed.

Todo:
Hmm, this function may change, since the parent pointer is already stored within the group struct.
Parameters:
p parent of the group

CHIPCARD_API int Config_WriteFile CONFIGGROUP root,
const char *  fname,
int  mode
 

Creates a configuration file from the given configuration.

Parameters:
fname path and name of the file to create
mode specifies how to store the groups and variables. The mode consists of one or multiple CONFIGMODE_XYZ values which may be logically ORed.


Variable Documentation

typedefCHIPCARD_API struct CONFIGGROUPSTRUCT CONFIGGROUP
 

typedefCHIPCARD_API struct CONFIGVALUESTRUCT CONFIGVALUE
 

typedefCHIPCARD_API struct CONFIGVARIABLESTRUCT CONFIGVARIABLE
 


Generated on Sat Feb 11 15:20:28 2006 for libchipcard by  doxygen 1.4.2