Rev 197 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
195 | f9daq | 1 | /********************************************************************\ |
2 | |||
3 | Name: mxml.h |
||
4 | Created by: Stefan Ritt |
||
5 | Copyright 2000 + Stefan Ritt |
||
6 | |||
7 | Contents: Header file for mxml.c |
||
8 | |||
9 | This file is part of MIDAS XML Library. |
||
10 | |||
11 | MIDAS XML Library is free software: you can redistribute it and/or modify |
||
12 | it under the terms of the GNU General Public License as published by |
||
13 | the Free Software Foundation, either version 3 of the License, or |
||
14 | (at your option) any later version. |
||
15 | |||
16 | MIDAS XML Library is distributed in the hope that it will be useful, |
||
17 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
19 | GNU General Public License for more details. |
||
20 | |||
21 | You should have received a copy of the GNU General Public License |
||
22 | along with MIDAS XML Library. If not, see <http://www.gnu.org/licenses/>. |
||
23 | |||
24 | \********************************************************************/ |
||
25 | |||
26 | /*------------------------------------------------------------------*/ |
||
27 | |||
28 | #ifndef _MXML_H_ |
||
29 | #define _MXML_H_ |
||
30 | |||
31 | #define MXML_NAME_LENGTH 64 |
||
32 | |||
33 | #define ELEMENT_NODE 1 |
||
34 | #define TEXT_NODE 2 |
||
35 | #define PROCESSING_INSTRUCTION_NODE 3 |
||
36 | #define COMMENT_NODE 4 |
||
37 | #define DOCUMENT_NODE 5 |
||
38 | |||
39 | #define INTERNAL_ENTITY 0 |
||
40 | #define EXTERNAL_ENTITY 1 |
||
41 | #define MXML_MAX_ENTITY 500 |
||
42 | |||
43 | #define MXML_MAX_CONDITION 10 |
||
44 | |||
45 | #ifdef _MSC_VER |
||
46 | #define DIR_SEPARATOR '\\' |
||
47 | #else |
||
48 | #define DIR_SEPARATOR '/' |
||
49 | #endif |
||
50 | |||
51 | typedef struct { |
||
52 | int fh; |
||
53 | char *buffer; |
||
54 | int buffer_size; |
||
55 | int buffer_len; |
||
56 | int level; |
||
57 | int element_is_open; |
||
58 | int data_was_written; |
||
59 | char **stack; |
||
60 | int translate; |
||
61 | } MXML_WRITER; |
||
62 | |||
63 | typedef struct mxml_struct *PMXML_NODE; |
||
64 | |||
65 | typedef struct mxml_struct { |
||
66 | char name[MXML_NAME_LENGTH]; // name of element <[name]>[value]</[name]> |
||
67 | int node_type; // type of node XXX_NODE |
||
68 | char *value; // value of element |
||
69 | int n_attributes; // list of attributes |
||
70 | char *attribute_name; |
||
71 | char **attribute_value; |
||
72 | int line_number_start; // first line number in XML file, starting from 1 |
||
73 | int line_number_end; // last line number in XML file, starting from 1 |
||
74 | PMXML_NODE parent; // pointer to parent element |
||
75 | int n_children; // list of children |
||
76 | PMXML_NODE child; |
||
77 | } MXML_NODE; |
||
78 | |||
79 | /*------------------------------------------------------------------*/ |
||
80 | |||
81 | /* make functions callable from a C++ program */ |
||
82 | #ifdef __cplusplus |
||
83 | extern "C" { |
||
84 | #endif |
||
85 | |||
86 | #ifndef EXPRT |
||
87 | #if defined(EXPORT_DLL) |
||
88 | #define EXPRT __declspec(dllexport) |
||
89 | #else |
||
90 | #define EXPRT |
||
91 | #endif |
||
92 | #endif |
||
93 | |||
94 | void mxml_suppress_date(int suppress); |
||
95 | MXML_WRITER *mxml_open_file(const char *file_name); |
||
96 | MXML_WRITER *mxml_open_buffer(void); |
||
97 | int mxml_set_translate(MXML_WRITER *writer, int flag); |
||
98 | int mxml_start_element(MXML_WRITER *writer, const char *name); |
||
99 | int mxml_start_element_noindent(MXML_WRITER *writer, const char *name); |
||
100 | int mxml_end_element(MXML_WRITER *writer); |
||
101 | int mxml_write_comment(MXML_WRITER *writer, const char *string); |
||
102 | int mxml_write_element(MXML_WRITER *writer, const char *name, const char *value); |
||
103 | int mxml_write_attribute(MXML_WRITER *writer, const char *name, const char *value); |
||
104 | int mxml_write_value(MXML_WRITER *writer, const char *value); |
||
105 | int mxml_write_empty_line(MXML_WRITER *writer); |
||
106 | char *mxml_close_buffer(MXML_WRITER *writer); |
||
107 | int mxml_close_file(MXML_WRITER *writer); |
||
108 | |||
109 | int mxml_get_number_of_children(PMXML_NODE pnode); |
||
110 | PMXML_NODE mxml_get_parent(PMXML_NODE pnode); |
||
111 | PMXML_NODE mxml_subnode(PMXML_NODE pnode, int idx); |
||
112 | PMXML_NODE mxml_find_node(PMXML_NODE tree, const char *xml_path); |
||
113 | int mxml_find_nodes(PMXML_NODE tree, const char *xml_path, PMXML_NODE **nodelist); |
||
114 | char *mxml_get_name(PMXML_NODE pnode); |
||
115 | char *mxml_get_value(PMXML_NODE pnode); |
||
116 | int mxml_get_line_number_start(PMXML_NODE pnode); |
||
117 | int mxml_get_line_number_end(PMXML_NODE pnode); |
||
118 | PMXML_NODE mxml_get_node_at_line(PMXML_NODE tree, int linenumber); |
||
119 | char *mxml_get_attribute(PMXML_NODE pnode, const char *name); |
||
120 | |||
121 | int mxml_add_attribute(PMXML_NODE pnode, const char *attrib_name, const char *attrib_value); |
||
122 | PMXML_NODE mxml_add_special_node(PMXML_NODE parent, int node_type, const char *node_name, const char *value); |
||
123 | PMXML_NODE mxml_add_special_node_at(PMXML_NODE parent, int node_type, const char *node_name, const char *value, int idx); |
||
124 | PMXML_NODE mxml_add_node(PMXML_NODE parent, const char *node_name, const char *value); |
||
125 | PMXML_NODE mxml_add_node_at(PMXML_NODE parent, const char *node_name, const char *value, int idx); |
||
126 | |||
127 | PMXML_NODE mxml_clone_tree(PMXML_NODE tree); |
||
128 | int mxml_add_tree(PMXML_NODE parent, PMXML_NODE tree); |
||
129 | int mxml_add_tree_at(PMXML_NODE parent, PMXML_NODE tree, int idx); |
||
130 | |||
131 | int mxml_replace_node_name(PMXML_NODE pnode, const char *new_name); |
||
132 | int mxml_replace_node_value(PMXML_NODE pnode, const char *value); |
||
133 | int mxml_replace_subvalue(PMXML_NODE pnode, const char *name, const char *value); |
||
134 | int mxml_replace_attribute_name(PMXML_NODE pnode, const char *old_name, const char *new_name); |
||
135 | int mxml_replace_attribute_value(PMXML_NODE pnode, const char *attrib_name, const char *attrib_value); |
||
136 | |||
137 | int mxml_delete_node(PMXML_NODE pnode); |
||
138 | int mxml_delete_attribute(PMXML_NODE, const char *attrib_name); |
||
139 | |||
140 | PMXML_NODE mxml_create_root_node(void); |
||
141 | PMXML_NODE mxml_parse_file(const char *file_name, char *error, int error_size, int *error_line); |
||
142 | PMXML_NODE mxml_parse_buffer(const char *buffer, char *error, int error_size, int *error_line); |
||
143 | int mxml_parse_entity(char **buf, const char* file_name, char *error, int error_size, int *error_line); |
||
144 | int mxml_write_tree(const char *file_name, PMXML_NODE tree); |
||
145 | void mxml_debug_tree(PMXML_NODE tree, int level); |
||
146 | void mxml_free_tree(PMXML_NODE tree); |
||
147 | |||
148 | void mxml_dirname(char* path); |
||
149 | void mxml_basename(char *path); |
||
150 | |||
151 | #ifdef __cplusplus |
||
152 | } |
||
153 | #endif |
||
154 | |||
155 | #endif /* _MXML_H_ */ |
||
156 | /*------------------------------------------------------------------*/ |