Main Page | Modules | Data Structures | File List | Data Fields | Related Pages

Helper for parsing config file
[MNT daemon]

Some helper functions for parsing the XML config file with expat. More...

Data Structures

struct  ParsingContext
 Parsing Context. More...

Defines

#define MAX_DEPTH   32
 Maximum nesting depth.
#define CDATA_BUF_SIZE   1024
 Maximum amount of CDATA.
#define MAX_KEY_SIZE   128
 Max length of property key.

Enumerations

enum  {
  CURELEM_UNKNOWN = -1, CURELEM_MNTD = 0, CURELEM_MOUNTPATH = 1, CURELEM_USER = 2,
  CURELEM_GROUP = 3, CURELEM_WDIR = 4, CURELEM_PIDFILE = 5, CURELEM_FILESYSTEMS = 6,
  CURELEM_FILESYSTEM = 7, CURELEM_DBUS_RECONNECT = 8, CURELEM_LOGLEVEL = 9, CURELEM_UMOUNT_ON_EXIT = 10,
  CURELEM_MOUNTPREFIX = 11
}
 Possible elements the parser can process. More...

Functions

void mntd_volume_config_parsing_abort (ParsingContext *pc)
 Abort parsing of document.
void mntd_volume_config_start (ParsingContext *pc, const char *el, const char **attr)
 Called by expat when an element begins.
void mntd_volume_config_end (ParsingContext *pc, const char *el)
 Called by expat when an element ends.
void mntd_volume_config_cdata (ParsingContext *pc, const char *s, int len)
 Called when there is CDATA.
ConfigDatamntd_volume_config_parse (char *config, char *pidfile)
 Parse the config file.
int mntd_volume_config_free (ConfigData **cfg)
 Free config file data.
void compare_filesystems (gpointer key, gpointer value, gpointer user_data)
 Specifies the type of the function passed to g_hash_table_foreach().
int mntd_volume_config_reload (ConfigData **cfg, char *pidfile)
 Reload config file data.

Detailed Description

Some helper functions for parsing the XML config file with expat.


Enumeration Type Documentation

anonymous enum
 

Possible elements the parser can process.

Enumeration values:
CURELEM_UNKNOWN  Not processing a known tag.
CURELEM_MNTD  Processing the root element.
CURELEM_MOUNTPATH  Processing a mountpath element.
CURELEM_USER  Processing a user element.
CURELEM_GROUP  Processing a group element.
CURELEM_WDIR  Processing a wdir element.
CURELEM_PIDFILE  Processing a pidfile element.
CURELEM_FILESYSTEMS  Processing a filesystems element.
CURELEM_FILESYSTEM  Processing a filesystem element.
CURELEM_DBUS_RECONNECT  Processing a dbus_reconnect element.
CURELEM_LOGLEVEL  Processing a loglevel element.
CURELEM_UMOUNT_ON_EXIT  Processing a umount_on_exit element.
CURELEM_MOUNTPREFIX  Processing a mountprefix element.

Definition at line 59 of file mntd_volume_config.c.


Function Documentation

void compare_filesystems gpointer  key,
gpointer  value,
gpointer  user_data
 

Specifies the type of the function passed to g_hash_table_foreach().

It is called with each key/value pair, together with the user_data parameter which is passed to g_hash_table_foreach().

Parameters:
key a key
value the value corresponding to the key
user_data user data passed to g_hash_table_foreach()

Definition at line 778 of file mntd_volume_config.c.

References MSG_NOTICE.

Referenced by mntd_volume_config_reload().

void mntd_volume_config_cdata ParsingContext pc,
const char *  s,
int  len
 

Called when there is CDATA.

Parameters:
pc Parsing context
s Pointer to data
len Length of data

Definition at line 486 of file mntd_volume_config.c.

References ParsingContext::aborted, ParsingContext::cdata_buf, ParsingContext::cdata_buf_len, CDATA_BUF_SIZE, and MSG_ERR.

Referenced by mntd_volume_config_parse().

void mntd_volume_config_end ParsingContext pc,
const char *  el
 

Called by expat when an element ends.

Parameters:
pc Parsing context
el Element name

Definition at line 375 of file mntd_volume_config.c.

References ParsingContext::aborted, ParsingContext::c, ParsingContext::cdata_buf, ParsingContext::cdata_buf_len, ParsingContext::curelem, ParsingContext::curelem_stack, ConfigData::dbus_reconnect, ParsingContext::depth, ConfigData::group, ConfigData::loglevel, ConfigData::mountpath, ConfigData::mountprefix, MSG_DEBUG, MSG_WARNING, ConfigData::umount_on_exit, ConfigData::user, and ConfigData::wdir.

Referenced by mntd_volume_config_parse().

int mntd_volume_config_free ConfigData **  cfg  ) 
 

Free config file data.

Parameters:
cfg &pointer to config data structure
Returns:
0 if successful, -1 otherwise

Definition at line 721 of file mntd_volume_config.c.

References ConfigData::absfilepath, ConfigData::filesystems, ConfigData::group, ConfigData::mountpath, ConfigData::pidfile, ConfigData::user, and ConfigData::wdir.

Referenced by main().

ConfigData* mntd_volume_config_parse char *  config,
char *  pidfile
 

Parse the config file.

Parameters:
config Path of configfile
pidfile Path of pidfile
Returns:
pointer to configdata, or NULL if error

Definition at line 546 of file mntd_volume_config.c.

References ParsingContext::aborted, ConfigData::absfilepath, ParsingContext::c, ParsingContext::cdata_buf, ParsingContext::cdata_buf_len, ParsingContext::config, ParsingContext::curelem, ConfigData::dbus_reconnect, ParsingContext::depth, ConfigData::filesystems, ConfigData::group, ConfigData::loglevel, mntd_volume_config_cdata(), mntd_volume_config_end(), mntd_volume_config_start(), ConfigData::mountpath, ConfigData::mountprefix, MSG_EMERG, MSG_ERR, MSG_INF, ParsingContext::parser, ConfigData::pidfile, sb_file_get_size(), sb_file_is_file(), sb_file_read(), ConfigData::sleep_millis, ConfigData::umount_on_exit, ConfigData::user, and ConfigData::wdir.

Referenced by main(), and mntd_volume_config_reload().

void mntd_volume_config_parsing_abort ParsingContext pc  ) 
 

Abort parsing of document.

Parameters:
pc Parsing context

Definition at line 151 of file mntd_volume_config.c.

References ParsingContext::aborted, and MSG_ERR.

Referenced by mntd_volume_config_start().

int mntd_volume_config_reload ConfigData **  cfg,
char *  pidfile
 

Reload config file data.

Parameters:
cfg &pointer to config data structure
pidfile Path of pidfile
Returns:
0 if successful, -1 otherwise

Definition at line 800 of file mntd_volume_config.c.

References ConfigData::absfilepath, compare_filesystems(), ConfigData::dbus_reconnect, EM_TYPE_SYSLOG, emInit(), ConfigData::filesystems, ConfigData::group, ConfigData::loglevel, mntd_volume_config_parse(), ConfigData::mountpath, MSG_ERR, MSG_NOTICE, MSG_WARNING, ConfigData::pidfile, ConfigData::sleep_millis, ConfigData::umount_on_exit, ConfigData::user, and ConfigData::wdir.

Referenced by main().

void mntd_volume_config_start ParsingContext pc,
const char *  el,
const char **  attr
 

Called by expat when an element begins.

Parameters:
pc Parsing context
el Element name
attr Attribute key/value pairs

Definition at line 169 of file mntd_volume_config.c.

References ParsingContext::aborted, ParsingContext::c, ParsingContext::cdata_buf_len, ParsingContext::config, ParsingContext::curelem, ParsingContext::curelem_stack, ParsingContext::depth, ConfigData::filesystems, MAX_DEPTH, mntd_volume_config_parsing_abort(), MSG_DEBUG, MSG_ERR, MSG_INF, MSG_WARNING, ParsingContext::parser, and ConfigData::sleep_millis.

Referenced by mntd_volume_config_parse().


Generated on Wed Mar 30 13:43:27 2005 for Mntd by  doxygen 1.3.9.1