#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxml/xmlerror.h>
#include "assert.h"
#include "main.h"
#include "data.h"
#include "chromo.h"
#include "xmlsup.h"
#include "modsup.h"
#include "error.h"
#include "gettext.h"
Defines | |
#define | FAIL(msg, node) fatal(_(msg)) |
Convenience macro for XML parser. Same as fatal(). It automatically appends line number of the XML node with error. | |
#define | NOPROP(prop, node) fatal(_("Tag <%s> without required property '%s'"), node->name, prop) |
Convenience macro for XML parser. Use when a required XML node property is not defined. | |
#define | INVPROP(prop, node) fatal(_("Invalid value of property '%s' in tag <%s>"), prop, node->name) |
Convenience macro for XML parser. Use when a property has an invalid value (e.g. property is not an integer when it should be). | |
#define | XMLCHAR (xmlChar *) |
Cast to (xmlChar *). | |
#define | CHAR (char *) |
Cast to (char *). | |
Functions | |
static void | parser_fatal (const char *fmt, int no,...) |
Replacement for the fatal() function that adds line number to the message. | |
static void | parser_newprop_int (xmlNodePtr cur, const xmlChar *prop, int value) |
Add an integer property to a XML node. | |
static int | parser_getprop_int (xmlNodePtr cur, const xmlChar *prop) |
Get an integer property from a XML node. | |
static xmlChar * | parser_getprop_str (xmlNodePtr cur, const xmlChar *prop) |
Get a string property from a XML node. | |
static resource * | parser_event_get_res (xmlNodePtr cur, resourcetype *restype) |
Get a resource definition for an event from the XML tree. | |
static void | parser_event_add_res (xmlNodePtr cur, resource *res) |
Add a resource definition for an event to the XML tree. | |
static void | parser_info (xmlNodePtr cur) |
Parse miscellaneous information. | |
static moduleoption * | parser_options (xmlNodePtr cur, moduleoption *opt) |
Parse module options. | |
static void | parser_modules (xmlNodePtr cur) |
Parse modules. | |
static int | parser_event_restrictions (xmlNodePtr cur, int tupleid, int repeats) |
Parse restrictions for a single event and call proper restriction handlers. | |
static void | parser_events_restrictions (xmlNodePtr cur) |
Parse all event restrictions. | |
static void | parser_event (xmlNodePtr start, tupleinfo *tuple) |
Parse a single event. | |
static void | parser_events (xmlNodePtr cur) |
Parse all events. | |
static int | parser_resource_restrictions_one (xmlNodePtr cur, resource *res) |
Parse restrictions for a single resource and call proper handlers. | |
static void | parser_resource_restrictions (xmlNodePtr cur, resourcetype *restype) |
Parse all resource restrictions for a single resource type. | |
static void | parser_resources_restrictions (xmlNodePtr cur) |
Parse all resource restrictions. | |
static void | parser_resource (xmlNodePtr cur, resourcetype *restype) |
Parse all resources in a resource type. | |
static void | parser_restype (xmlNodePtr cur, int var) |
Define a new resource type. | |
static void | parser_resources (xmlNodePtr start) |
Parse all resource types. | |
void | parser_handler (void *ctx, const char *msg,...) |
Custom error handler for libxml. | |
static void | parser_libxml_init (char *filename) |
Parser initialization. | |
static void | parser_version_check (xmlNodePtr root) |
Check version of the configuration file. | |
int | parser_main (char *filename) |
Parses an XML configuration file. | |
static void | parser_clean (xmlNodePtr cur) |
Removes definitions of variable resources for an event in the XML tree. | |
static void | parser_remove_repeats (xmlNodePtr cur) |
Replaces event tags with repeats > 1 with multiple tags with repeats = 1. | |
void | parser_gettable (table *tab) |
Loads definitions of variable resources for all events in the XML tree to a table struct.tab Pointer to the table struct. | |
void | parser_addtable (table *tab) |
Saves definitions of variable resources for all events in the table struct to the XML tree.tab Pointer to the table struct. | |
void | parser_dump (FILE *f) |
Dumps XML tree into a file. | |
void | parser_exit () |
Free all memory allocated by the parser. | |
Variables | |
static xmlDocPtr | config |
XML Configuration file. |
|
Cast to (char *). This macro should only be used when it is certain that the pointer contains a valid UTF-8 encoded NULL terminated string. |
|
Convenience macro for XML parser. Same as fatal(). It automatically appends line number of the XML node with error.
|
|
Convenience macro for XML parser. Use when a property has an invalid value (e.g. property is not an integer when it should be).
|
|
Convenience macro for XML parser. Use when a required XML node property is not defined.
|
|
Cast to (xmlChar *). This macro should only be used when it is certain that the pointer contains a valid UTF-8 encoded NULL terminated string. |
|
Saves definitions of variable resources for all events in the table struct to the XML tree.tab Pointer to the table struct. Any previous definitions of variable resources are replaced. |
|
Removes definitions of variable resources for an event in the XML tree.
|
|
Dumps XML tree into a file.
|
|
Parse a single event.
|
|
Add a resource definition for an event to the XML tree.
|
|
Get a resource definition for an event from the XML tree.
|
|
Parse restrictions for a single event and call proper restriction handlers.
|
|
Parse all events.
|
|
Parse all event restrictions.
|
|
Replacement for the fatal() function that adds line number to the message.
|
|
Get an integer property from a XML node. Calls fatal() if property was not found or was not integer.
|
|
Get a string property from a XML node. Calls fatal() if property was not found.
|
|
Parse miscellaneous information.
|
|
Parser initialization.
|
|
Parses an XML configuration file.
|
|
Parse modules.
|
|
Add an integer property to a XML node. If a property with this name already exists it is overwritten.
|
|
Parse module options.
|
|
Replaces event tags with repeats > 1 with multiple tags with repeats = 1.
|
|
Parse all resources in a resource type.
|
|
Parse all resource restrictions for a single resource type.
|
|
Parse restrictions for a single resource and call proper handlers.
|
|
Parse all resource types.
|
|
Parse all resource restrictions.
|
|
Define a new resource type.
|
|
Check version of the configuration file.
|