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 |
|
---|
37 | typedef 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 |
|
---|
49 | typedef struct mxml_struct *PMXML_NODE;
|
---|
50 |
|
---|
51 | typedef 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
|
---|
68 | extern "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 |
|
---|
79 | void mxml_suppress_date(int suppress);
|
---|
80 | MXML_WRITER *mxml_open_file(const char *file_name);
|
---|
81 | MXML_WRITER *mxml_open_buffer(void);
|
---|
82 | int mxml_set_translate(MXML_WRITER *writer, int flag);
|
---|
83 | int mxml_start_element(MXML_WRITER *writer, const char *name);
|
---|
84 | int mxml_start_element_noindent(MXML_WRITER *writer, const char *name);
|
---|
85 | int mxml_end_element(MXML_WRITER *writer);
|
---|
86 | int mxml_write_comment(MXML_WRITER *writer, const char *string);
|
---|
87 | int mxml_write_element(MXML_WRITER *writer, const char *name, const char *value);
|
---|
88 | int mxml_write_attribute(MXML_WRITER *writer, const char *name, const char *value);
|
---|
89 | int mxml_write_value(MXML_WRITER *writer, const char *value);
|
---|
90 | int mxml_write_empty_line(MXML_WRITER *writer);
|
---|
91 | char *mxml_close_buffer(MXML_WRITER *writer);
|
---|
92 | int mxml_close_file(MXML_WRITER *writer);
|
---|
93 |
|
---|
94 | int mxml_get_number_of_children(PMXML_NODE pnode);
|
---|
95 | PMXML_NODE mxml_subnode(PMXML_NODE pnode, int idx);
|
---|
96 | PMXML_NODE mxml_find_node(PMXML_NODE tree, const char *xml_path);
|
---|
97 | int mxml_find_nodes(PMXML_NODE tree, const char *xml_path, PMXML_NODE **nodelist);
|
---|
98 | char *mxml_get_name(PMXML_NODE pnode);
|
---|
99 | char *mxml_get_value(PMXML_NODE pnode);
|
---|
100 | char *mxml_get_attribute(PMXML_NODE pnode, const char *name);
|
---|
101 |
|
---|
102 | int mxml_add_attribute(PMXML_NODE pnode, const char *attrib_name, const char *attrib_value);
|
---|
103 | PMXML_NODE mxml_add_special_node(PMXML_NODE parent, int node_type, const char *node_name, const char *value);
|
---|
104 | PMXML_NODE mxml_add_special_node_at(PMXML_NODE parent, int node_type, const char *node_name, const char *value, int idx);
|
---|
105 | PMXML_NODE mxml_add_node(PMXML_NODE parent, const char *node_name, const char *value);
|
---|
106 | PMXML_NODE mxml_add_node_at(PMXML_NODE parent, const char *node_name, const char *value, int idx);
|
---|
107 |
|
---|
108 | PMXML_NODE mxml_clone_tree(PMXML_NODE tree);
|
---|
109 | int mxml_add_tree(PMXML_NODE parent, PMXML_NODE tree);
|
---|
110 | int mxml_add_tree_at(PMXML_NODE parent, PMXML_NODE tree, int idx);
|
---|
111 |
|
---|
112 | int mxml_replace_node_name(PMXML_NODE pnode, const char *new_name);
|
---|
113 | int mxml_replace_node_value(PMXML_NODE pnode, const char *value);
|
---|
114 | int mxml_replace_subvalue(PMXML_NODE pnode, const char *name, const char *value);
|
---|
115 | int mxml_replace_attribute_name(PMXML_NODE pnode, const char *old_name, const char *new_name);
|
---|
116 | int mxml_replace_attribute_value(PMXML_NODE pnode, const char *attrib_name, const char *attrib_value);
|
---|
117 |
|
---|
118 | int mxml_delete_node(PMXML_NODE pnode);
|
---|
119 | int mxml_delete_attribute(PMXML_NODE, const char *attrib_name);
|
---|
120 |
|
---|
121 | PMXML_NODE mxml_create_root_node(void);
|
---|
122 | PMXML_NODE mxml_parse_file(const char *file_name, char *error, int error_size);
|
---|
123 | PMXML_NODE mxml_parse_buffer(const char *buffer, char *error, int error_size);
|
---|
124 | int mxml_parse_entity(char **buf, const char* file_name, char *error, int error_size);
|
---|
125 | int mxml_write_tree(const char *file_name, PMXML_NODE tree);
|
---|
126 | void mxml_debug_tree(PMXML_NODE tree, int level);
|
---|
127 | void mxml_free_tree(PMXML_NODE tree);
|
---|
128 |
|
---|
129 | void mxml_dirname(char* path);
|
---|
130 | void mxml_basename(char *path);
|
---|
131 |
|
---|
132 | #ifdef __cplusplus
|
---|
133 | }
|
---|
134 | #endif
|
---|
135 |
|
---|
136 | #endif /* _MXML_H_ */
|
---|
137 | /*------------------------------------------------------------------*/
|
---|