source: fact/drsdaq/DRS/mxml.h@ 10099

Last change on this file since 10099 was 22, checked in by ogrimm, 16 years ago
First commit of drsdaq program
File size: 4.9 KB
Line 
1/********************************************************************\
2
3 Name: mxml.h
4 Created by: Stefan Ritt
5
6 Contents: Header file for mxml.c
7
8 $Id: mxml.h 62 2007-10-23 17:53:45Z sawada $
9
10\********************************************************************/
11
12/*------------------------------------------------------------------*/
13
14#ifndef _MXML_H_
15#define _MXML_H_
16
17#define MXML_NAME_LENGTH 64
18
19#define ELEMENT_NODE 1
20#define TEXT_NODE 2
21#define PROCESSING_INSTRUCTION_NODE 3
22#define COMMENT_NODE 4
23#define DOCUMENT_NODE 5
24
25#define INTERNAL_ENTITY 0
26#define EXTERNAL_ENTITY 1
27#define MXML_MAX_ENTITY 500
28
29#define MXML_MAX_CONDITION 10
30
31#ifdef _MSC_VER
32#define DIR_SEPARATOR '\\'
33#else
34#define DIR_SEPARATOR '/'
35#endif
36
37typedef struct {
38 int fh;
39 char *buffer;
40 int buffer_size;
41 int buffer_len;
42 int level;
43 int element_is_open;
44 int data_was_written;
45 char **stack;
46 int translate;
47} MXML_WRITER;
48
49typedef struct mxml_struct *PMXML_NODE;
50
51typedef struct mxml_struct {
52 char name[MXML_NAME_LENGTH]; // name of element <[name]>[value]</[name]>
53 int node_type; // type of node XXX_NODE
54 char *value; // value of element
55 int n_attributes; // list of attributes
56 char *attribute_name;
57 char **attribute_value;
58 int line_number; // line number for source file
59 PMXML_NODE parent; // pointer to parent element
60 int n_children; // list of children
61 PMXML_NODE child;
62} MXML_NODE;
63
64/*------------------------------------------------------------------*/
65
66/* make functions callable from a C++ program */
67#ifdef __cplusplus
68extern "C" {
69#endif
70
71#ifndef EXPRT
72#if defined(EXPORT_DLL)
73#define EXPRT __declspec(dllexport)
74#else
75#define EXPRT
76#endif
77#endif
78
79void mxml_suppress_date(int suppress);
80MXML_WRITER *mxml_open_file(const char *file_name);
81MXML_WRITER *mxml_open_buffer(void);
82int mxml_set_translate(MXML_WRITER *writer, int flag);
83int mxml_start_element(MXML_WRITER *writer, const char *name);
84int mxml_start_element_noindent(MXML_WRITER *writer, const char *name);
85int mxml_end_element(MXML_WRITER *writer);
86int mxml_write_comment(MXML_WRITER *writer, const char *string);
87int mxml_write_element(MXML_WRITER *writer, const char *name, const char *value);
88int mxml_write_attribute(MXML_WRITER *writer, const char *name, const char *value);
89int mxml_write_value(MXML_WRITER *writer, const char *value);
90int mxml_write_empty_line(MXML_WRITER *writer);
91char *mxml_close_buffer(MXML_WRITER *writer);
92int mxml_close_file(MXML_WRITER *writer);
93
94int mxml_get_number_of_children(PMXML_NODE pnode);
95PMXML_NODE mxml_subnode(PMXML_NODE pnode, int idx);
96PMXML_NODE mxml_find_node(PMXML_NODE tree, const char *xml_path);
97int mxml_find_nodes(PMXML_NODE tree, const char *xml_path, PMXML_NODE **nodelist);
98char *mxml_get_name(PMXML_NODE pnode);
99char *mxml_get_value(PMXML_NODE pnode);
100char *mxml_get_attribute(PMXML_NODE pnode, const char *name);
101
102int mxml_add_attribute(PMXML_NODE pnode, const char *attrib_name, const char *attrib_value);
103PMXML_NODE mxml_add_special_node(PMXML_NODE parent, int node_type, const char *node_name, const char *value);
104PMXML_NODE mxml_add_special_node_at(PMXML_NODE parent, int node_type, const char *node_name, const char *value, int idx);
105PMXML_NODE mxml_add_node(PMXML_NODE parent, const char *node_name, const char *value);
106PMXML_NODE mxml_add_node_at(PMXML_NODE parent, const char *node_name, const char *value, int idx);
107
108PMXML_NODE mxml_clone_tree(PMXML_NODE tree);
109int mxml_add_tree(PMXML_NODE parent, PMXML_NODE tree);
110int mxml_add_tree_at(PMXML_NODE parent, PMXML_NODE tree, int idx);
111
112int mxml_replace_node_name(PMXML_NODE pnode, const char *new_name);
113int mxml_replace_node_value(PMXML_NODE pnode, const char *value);
114int mxml_replace_subvalue(PMXML_NODE pnode, const char *name, const char *value);
115int mxml_replace_attribute_name(PMXML_NODE pnode, const char *old_name, const char *new_name);
116int mxml_replace_attribute_value(PMXML_NODE pnode, const char *attrib_name, const char *attrib_value);
117
118int mxml_delete_node(PMXML_NODE pnode);
119int mxml_delete_attribute(PMXML_NODE, const char *attrib_name);
120
121PMXML_NODE mxml_create_root_node(void);
122PMXML_NODE mxml_parse_file(const char *file_name, char *error, int error_size);
123PMXML_NODE mxml_parse_buffer(const char *buffer, char *error, int error_size);
124int mxml_parse_entity(char **buf, const char* file_name, char *error, int error_size);
125int mxml_write_tree(const char *file_name, PMXML_NODE tree);
126void mxml_debug_tree(PMXML_NODE tree, int level);
127void mxml_free_tree(PMXML_NODE tree);
128
129void mxml_dirname(char* path);
130void mxml_basename(char *path);
131
132#ifdef __cplusplus
133}
134#endif
135
136#endif /* _MXML_H_ */
137/*------------------------------------------------------------------*/
Note: See TracBrowser for help on using the repository browser.