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

Device Info File Parsing
[HAL daemon]

Parsing of device info files. 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_DEVICE_INFO = 0, CURELEM_DEVICE = 1, CURELEM_MATCH = 2,
  CURELEM_MERGE = 3
}
 Possible elements the parser can process. More...


Functions

dbus_bool_t handle_match (ParsingContext *pc, const char **attr)
 Called when the match element begins.

void handle_merge (ParsingContext *pc, const char **attr)
 Called when the merge element begins.

void parsing_abort (ParsingContext *pc)
 Abort parsing of document.

void start (ParsingContext *pc, const char *el, const char **attr)
 Called by expat when an element begins.

void end (ParsingContext *pc, const char *el)
 Called by expat when an element ends.

void cdata (ParsingContext *pc, const char *s, int len)
 Called when there is CDATA.

dbus_bool_t process_fdi_file (const char *dir, const char *filename, HalDevice *device)
 Process a device information info file.

int scan_fdi_files (const char *dir, HalDevice *d)
 Scan all directories and subdirectories in the given directory and process each *.fdi file.

dbus_bool_t di_search_and_merge (HalDevice *d)
 Search the device info file repository for a .fdi file to merge more information into the device object.


Detailed Description

Parsing of device info files.


Enumeration Type Documentation

anonymous enum
 

Possible elements the parser can process.

Enumeration values:
CURELEM_UNKNOWN  Not processing a known tag.
CURELEM_DEVICE_INFO  Processing a deviceinfo element.
CURELEM_DEVICE  Processing a device element.
CURELEM_MATCH  Processing a match element.
CURELEM_MERGE  Processing a merge element.

Definition at line 62 of file device_info.c.


Function Documentation

void cdata ParsingContext pc,
const char *  s,
int  len
[static]
 

Called when there is CDATA.

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

Definition at line 458 of file device_info.c.

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

Referenced by process_fdi_file().

dbus_bool_t di_search_and_merge HalDevice d  ) 
 

Search the device info file repository for a .fdi file to merge more information into the device object.

Parameters:
d Device to merge information into
Returns:
#TRUE if information was merged

Definition at line 679 of file device_info.c.

References HalDevice, and scan_fdi_files().

Referenced by rename_and_merge().

void end ParsingContext pc,
const char *  el
[static]
 

Called by expat when an element ends.

Parameters:
pc Parsing context
el Element name

Todo:
FIXME: Check error condition

Definition at line 386 of file device_info.c.

References ParsingContext::aborted, ParsingContext::cdata_buf, ParsingContext::cdata_buf_len, ParsingContext::curelem, CURELEM_MERGE, ParsingContext::curelem_stack, ParsingContext::depth, ParsingContext::device, ParsingContext::device_matched, ds_property_set_bool(), ds_property_set_double(), ds_property_set_int(), ds_property_set_string(), ParsingContext::match_depth_first_fail, ParsingContext::match_ok, ParsingContext::merge_key, and ParsingContext::merge_type.

Referenced by process_fdi_file().

dbus_bool_t handle_match ParsingContext pc,
const char **  attr
[static]
 

Called when the match element begins.

Parameters:
pc Parsing context
attr Attribute key/value pairs
Returns:
#FALSE if the device in question didn't match the data in the attributes

Todo:
Check error condition

Definition at line 137 of file device_info.c.

References ParsingContext::device, ds_property_get_bool(), ds_property_get_int(), ds_property_get_string(), and ds_property_get_type().

Referenced by start().

void handle_merge ParsingContext pc,
const char **  attr
[static]
 

Called when the merge element begins.

Parameters:
pc Parsing context
attr Attribute key/value pairs

Definition at line 225 of file device_info.c.

References MAX_KEY_SIZE, ParsingContext::merge_key, and ParsingContext::merge_type.

Referenced by start().

void parsing_abort ParsingContext pc  )  [static]
 

Abort parsing of document.

Parameters:
pc Parsing context

Definition at line 269 of file device_info.c.

References ParsingContext::aborted.

Referenced by start().

dbus_bool_t process_fdi_file const char *  dir,
const char *  filename,
HalDevice device
[static]
 

Process a device information info file.

Parameters:
dir Directory file resides in
filename File name
device Device to match on
Returns:
#TRUE if file matched device and information was merged

Definition at line 493 of file device_info.c.

References ParsingContext::aborted, cdata(), ParsingContext::curelem, CURELEM_UNKNOWN, ParsingContext::depth, ParsingContext::device, ParsingContext::device_matched, end(), ParsingContext::file, HalDevice, ParsingContext::match_ok, ParsingContext::parser, and start().

Referenced by scan_fdi_files().

int scan_fdi_files const char *  dir,
HalDevice d
[static]
 

Scan all directories and subdirectories in the given directory and process each *.fdi file.

Parameters:
d Device to merge information into
Returns:
#TRUE if information was merged

Definition at line 590 of file device_info.c.

References HalDevice, and process_fdi_file().

Referenced by di_search_and_merge().

void start ParsingContext pc,
const char *  el,
const char **  attr
[static]
 

Called by expat when an element begins.

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

Definition at line 283 of file device_info.c.

References ParsingContext::aborted, ParsingContext::cdata_buf_len, ParsingContext::curelem, CURELEM_DEVICE, CURELEM_DEVICE_INFO, CURELEM_MATCH, CURELEM_MERGE, ParsingContext::curelem_stack, CURELEM_UNKNOWN, ParsingContext::depth, ParsingContext::file, handle_match(), handle_merge(), ParsingContext::match_depth_first_fail, ParsingContext::match_ok, MAX_DEPTH, ParsingContext::parser, and parsing_abort().

Referenced by process_fdi_file().


Generated on Thu Mar 11 21:32:24 2004 for HAL by doxygen 1.3.6-20040222