00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <stdio.h>
00027
00028 #include "xmlconfig.h"
00029 #include "common/dictionary.h"
00030 #include "drivers/backend.h"
00031 #include "drivers/driver.h"
00032
00033 static tag_idx tag_array[] = { ROOT, OUTPUT };
00034 static attr_idx attr_array[] = { ID };
00035
00036 static dict_pair tag_translate[] = {
00037 {"flcdd-config", &tag_array[0]},
00038 {"output", &tag_array[1]}
00039 };
00040
00041 static dict_pair attr_translate[] = {
00042 {"id", &attr_array[0]}
00043 };
00044
00045 static dictionary tag_dict = { tag_translate, 2 };
00046 static dictionary attr_dict = { attr_translate, 1 };
00047
00048 static xml_node *finished_doc;
00049
00050
00051 static void
00052 _finished (void *ignore, xml_node *root_node)
00053 {
00054 finished_doc = root_node;
00055 }
00056
00057 xml_node *
00058 xc_parse_config_file (const char *filename)
00059 {
00060 FILE *fp;
00061 char read_buf[4096];
00062 size_t read_len;
00063 void *context;
00064
00065 finished_doc = 0;
00066
00067
00068 fp = fopen (filename, "r");
00069 if (!fp)
00070 return 0;
00071
00072
00073 context = xmlt_create_context (_finished, 0, &tag_dict, &attr_dict);
00074 if (!context)
00075 {
00076 fclose (fp);
00077 return 0;
00078 }
00079
00080
00081 while (!feof (fp) && !ferror (fp))
00082 {
00083 read_len = fread (read_buf, 1, 4096, fp);
00084 if (read_len > 0)
00085 xmlt_parse (context, read_buf, read_len);
00086 }
00087
00088 xmlt_free_context (context);
00089
00090 return finished_doc;
00091 }