ROOTANA
Loading...
Searching...
No Matches
mxml.h
Go to the documentation of this file.
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 2 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 50
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
51typedef 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;
62
63typedef struct mxml_struct *PMXML_NODE;
64
65typedef 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
78
79/*------------------------------------------------------------------*/
80
81#ifndef EXPRT
82#if defined(EXPORT_DLL)
83#define EXPRT __declspec(dllexport)
84#else
85#define EXPRT
86#endif
87#endif
88
89void mxml_suppress_date(int suppress);
90MXML_WRITER *mxml_open_file(const char *file_name);
92int mxml_set_translate(MXML_WRITER *writer, int flag);
93int mxml_start_element(MXML_WRITER *writer, const char *name);
94int mxml_start_element_noindent(MXML_WRITER *writer, const char *name);
95int mxml_end_element(MXML_WRITER *writer);
96int mxml_write_comment(MXML_WRITER *writer, const char *string);
97int mxml_write_element(MXML_WRITER *writer, const char *name, const char *value);
98int mxml_write_attribute(MXML_WRITER *writer, const char *name, const char *value);
99int mxml_write_value(MXML_WRITER *writer, const char *value);
101char *mxml_close_buffer(MXML_WRITER *writer);
102int mxml_close_file(MXML_WRITER *writer);
103
106PMXML_NODE mxml_subnode(PMXML_NODE pnode, int idx);
107PMXML_NODE mxml_find_node(PMXML_NODE tree, const char *xml_path);
108int mxml_find_nodes(PMXML_NODE tree, const char *xml_path, PMXML_NODE **nodelist);
109char *mxml_get_name(PMXML_NODE pnode);
110char *mxml_get_value(PMXML_NODE pnode);
113PMXML_NODE mxml_get_node_at_line(PMXML_NODE tree, int linenumber);
114char *mxml_get_attribute(PMXML_NODE pnode, const char *name);
115
116int mxml_add_attribute(PMXML_NODE pnode, const char *attrib_name, const char *attrib_value);
117PMXML_NODE mxml_add_special_node(PMXML_NODE parent, int node_type, const char *node_name, const char *value);
118PMXML_NODE mxml_add_special_node_at(PMXML_NODE parent, int node_type, const char *node_name, const char *value, int idx);
119PMXML_NODE mxml_add_node(PMXML_NODE parent, const char *node_name, const char *value);
120PMXML_NODE mxml_add_node_at(PMXML_NODE parent, const char *node_name, const char *value, int idx);
121
123int mxml_add_tree(PMXML_NODE parent, PMXML_NODE tree);
124int mxml_add_tree_at(PMXML_NODE parent, PMXML_NODE tree, int idx);
125
126int mxml_replace_node_name(PMXML_NODE pnode, const char *new_name);
127int mxml_replace_node_value(PMXML_NODE pnode, const char *value);
128int mxml_replace_subvalue(PMXML_NODE pnode, const char *name, const char *value);
129int mxml_replace_attribute_name(PMXML_NODE pnode, const char *old_name, const char *new_name);
130int mxml_replace_attribute_value(PMXML_NODE pnode, const char *attrib_name, const char *attrib_value);
131
133int mxml_delete_attribute(PMXML_NODE, const char *attrib_name);
134
136PMXML_NODE mxml_parse_file(const char *file_name, char *error, int error_size, int *error_line);
137PMXML_NODE mxml_parse_buffer(const char *buffer, char *error, int error_size, int *error_line);
138int mxml_parse_entity(char **buf, const char* file_name, char *error, int error_size, int *error_line);
139int mxml_print_tree(char *buffer, int *buffer_size, PMXML_NODE tree);
140void mxml_debug_tree(PMXML_NODE tree, int level);
141void mxml_free_tree(PMXML_NODE tree);
142int mxml_write_tree(const char *file_name, PMXML_NODE tree);
143
144void mxml_dirname(char* path);
145void mxml_basename(char *path);
146
147#endif /* _MXML_H_ */
148/*------------------------------------------------------------------*/
void mxml_free_tree(PMXML_NODE tree)
Definition mxml.cxx:2305
char * mxml_close_buffer(MXML_WRITER *writer)
Definition mxml.cxx:632
int mxml_write_comment(MXML_WRITER *writer, const char *string)
Definition mxml.cxx:590
MXML_WRITER * mxml_open_buffer(void)
Definition mxml.cxx:223
PMXML_NODE mxml_parse_file(const char *file_name, char *error, int error_size, int *error_line)
Definition mxml.cxx:2070
PMXML_NODE mxml_add_special_node(PMXML_NODE parent, int node_type, const char *node_name, const char *value)
Definition mxml.cxx:745
int mxml_get_line_number_start(PMXML_NODE pnode)
Definition mxml.cxx:1119
int mxml_start_element(MXML_WRITER *writer, const char *name)
Definition mxml.cxx:466
int mxml_add_attribute(PMXML_NODE pnode, const char *attrib_name, const char *attrib_value)
Definition mxml.cxx:842
int mxml_end_element(MXML_WRITER *writer)
Definition mxml.cxx:483
int mxml_replace_subvalue(PMXML_NODE pnode, const char *name, const char *value)
Definition mxml.cxx:1184
void mxml_dirname(char *path)
Definition mxml.cxx:2403
PMXML_NODE mxml_find_node(PMXML_NODE tree, const char *xml_path)
Definition mxml.cxx:1078
void mxml_suppress_date(int suppress)
Definition mxml.cxx:261
int mxml_delete_node(PMXML_NODE pnode)
Definition mxml.cxx:1245
int mxml_replace_node_value(PMXML_NODE pnode, const char *value)
Definition mxml.cxx:1157
int mxml_replace_attribute_name(PMXML_NODE pnode, const char *old_name, const char *new_name)
Definition mxml.cxx:1203
int mxml_write_tree(const char *file_name, PMXML_NODE tree)
Definition mxml.cxx:2166
int mxml_find_nodes(PMXML_NODE tree, const char *xml_path, PMXML_NODE **nodelist)
Definition mxml.cxx:1060
PMXML_NODE mxml_get_parent(PMXML_NODE pnode)
Definition mxml.cxx:1095
PMXML_NODE mxml_clone_tree(PMXML_NODE tree)
Definition mxml.cxx:2224
int mxml_close_file(MXML_WRITER *writer)
Definition mxml.cxx:657
int mxml_write_attribute(MXML_WRITER *writer, const char *name, const char *value)
Definition mxml.cxx:523
PMXML_NODE mxml_subnode(PMXML_NODE pnode, int idx)
Definition mxml.cxx:878
int mxml_write_empty_line(MXML_WRITER *writer)
Definition mxml.cxx:572
PMXML_NODE mxml_add_node_at(PMXML_NODE parent, const char *node_name, const char *value, int idx)
Definition mxml.cxx:765
PMXML_NODE mxml_create_root_node(void)
Definition mxml.cxx:681
int mxml_add_tree_at(PMXML_NODE parent, PMXML_NODE tree, int idx)
Definition mxml.cxx:775
MXML_WRITER * mxml_open_file(const char *file_name)
Definition mxml.cxx:271
int mxml_parse_entity(char **buf, const char *file_name, char *error, int error_size, int *error_line)
Definition mxml.cxx:1673
void mxml_basename(char *path)
Definition mxml.cxx:2376
char * mxml_get_value(PMXML_NODE pnode)
Definition mxml.cxx:1111
int mxml_replace_node_name(PMXML_NODE pnode, const char *new_name)
Definition mxml.cxx:1149
PMXML_NODE mxml_get_node_at_line(PMXML_NODE tree, int linenumber)
Definition mxml.cxx:2438
struct mxml_struct * PMXML_NODE
Definition mxml.h:63
int mxml_write_value(MXML_WRITER *writer, const char *value)
Definition mxml.cxx:547
int mxml_get_line_number_end(PMXML_NODE pnode)
Definition mxml.cxx:1127
int mxml_write_element(MXML_WRITER *writer, const char *name, const char *value)
Definition mxml.cxx:617
PMXML_NODE mxml_add_special_node_at(PMXML_NODE parent, int node_type, const char *node_name, const char *value, int idx)
Definition mxml.cxx:697
int mxml_replace_attribute_value(PMXML_NODE pnode, const char *attrib_name, const char *attrib_value)
Definition mxml.cxx:1223
void mxml_debug_tree(PMXML_NODE tree, int level)
Definition mxml.cxx:2255
int mxml_delete_attribute(PMXML_NODE, const char *attrib_name)
Definition mxml.cxx:1278
struct mxml_struct MXML_NODE
char * mxml_get_name(PMXML_NODE pnode)
Definition mxml.cxx:1103
char * mxml_get_attribute(PMXML_NODE pnode, const char *name)
Definition mxml.cxx:1135
int mxml_get_number_of_children(PMXML_NODE pnode)
Definition mxml.cxx:867
int mxml_start_element_noindent(MXML_WRITER *writer, const char *name)
Definition mxml.cxx:473
int mxml_print_tree(char *buffer, int *buffer_size, PMXML_NODE tree)
Definition mxml.cxx:2192
int mxml_add_tree(PMXML_NODE parent, PMXML_NODE tree)
Definition mxml.cxx:832
PMXML_NODE mxml_add_node(PMXML_NODE parent, const char *node_name, const char *value)
Definition mxml.cxx:755
PMXML_NODE mxml_parse_buffer(const char *buffer, char *error, int error_size, int *error_line)
Definition mxml.cxx:1355
int mxml_set_translate(MXML_WRITER *writer, int flag)
Definition mxml.cxx:416
#define MXML_NAME_LENGTH
Definition mxml.h:31
int node_type
Definition mxml.h:67
char * value
Definition mxml.h:68
int n_children
Definition mxml.h:75
PMXML_NODE parent
Definition mxml.h:74
char name[MXML_NAME_LENGTH]
Definition mxml.h:66
int line_number_start
Definition mxml.h:72
char * attribute_name
Definition mxml.h:70
int line_number_end
Definition mxml.h:73
char ** attribute_value
Definition mxml.h:71
int n_attributes
Definition mxml.h:69
PMXML_NODE child
Definition mxml.h:76