~ubuntu-branches/ubuntu/saucy/dahdi-tools/saucy-proposed

« back to all changes in this revision

Viewing changes to menuselect/mxml/mxml.h

  • Committer: Package Import Robot
  • Author(s): Jackson Doak
  • Date: 2013-08-25 12:48:37 UTC
  • mfrom: (2.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20130825124837-wtefi7f9dsihg8is
Tags: 1:2.7.0-1ubuntu1
* Merge from debian. Remaining changes:
  - debian/control: Added gawk as dependency for dkms build
  - debian/control: Package dahdi Depends on dahdi-dkms | dahdi-source
  - debian/control: Set ubuntu maintainer    
  - added debian/dahdi.postinst
  - debian/control: Removed Uploaders field.
  - added debian/dahdi.postinst
  - added --error-handler=init_failed to debian/rules
  

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * "$Id: mxml.h 22267 2006-04-24 17:11:45Z kpfleming $"
3
 
 *
4
 
 * Header file for Mini-XML, a small XML-like file parsing library.
5
 
 *
6
 
 * Copyright 2003-2005 by Michael Sweet.
7
 
 *
8
 
 * This program is free software; you can redistribute it and/or
9
 
 * modify it under the terms of the GNU Library General Public
10
 
 * License as published by the Free Software Foundation; either
11
 
 * version 2, or (at your option) any later version.
12
 
 *
13
 
 * This program is distributed in the hope that it will be useful,
14
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 
 * GNU General Public License for more details.
17
 
 */
18
 
 
19
 
/*
20
 
 * Prevent multiple inclusion...
21
 
 */
22
 
 
23
 
#ifndef _mxml_h_
24
 
#  define _mxml_h_
25
 
 
26
 
/*
27
 
 * Include necessary headers...
28
 
 */
29
 
 
30
 
#  include <stdio.h>
31
 
#  include <stdlib.h>
32
 
#  include <string.h>
33
 
#  include <ctype.h>
34
 
#  include <errno.h>
35
 
 
36
 
 
37
 
/*
38
 
 * Constants...
39
 
 */
40
 
 
41
 
#  define MXML_WRAP             72      /* Wrap XML output at this column position */
42
 
#  define MXML_TAB              8       /* Tabs every N columns */
43
 
 
44
 
#  define MXML_NO_CALLBACK      0       /* Don't use a type callback */
45
 
#  define MXML_INTEGER_CALLBACK mxml_integer_cb
46
 
                                        /* Treat all data as integers */
47
 
#  define MXML_OPAQUE_CALLBACK  mxml_opaque_cb
48
 
                                        /* Treat all data as opaque */
49
 
#  define MXML_REAL_CALLBACK    mxml_real_cb
50
 
                                        /* Treat all data as real numbers */
51
 
#  define MXML_TEXT_CALLBACK    0       /* Treat all data as text */
52
 
 
53
 
#  define MXML_NO_PARENT        0       /* No parent for the node */
54
 
 
55
 
#  define MXML_DESCEND          1       /* Descend when finding/walking */
56
 
#  define MXML_NO_DESCEND       0       /* Don't descend when finding/walking */
57
 
#  define MXML_DESCEND_FIRST    -1      /* Descend for first find */
58
 
 
59
 
#  define MXML_WS_BEFORE_OPEN   0       /* Callback for before open tag */
60
 
#  define MXML_WS_AFTER_OPEN    1       /* Callback for after open tag */
61
 
#  define MXML_WS_BEFORE_CLOSE  2       /* Callback for before close tag */
62
 
#  define MXML_WS_AFTER_CLOSE   3       /* Callback for after close tag */
63
 
 
64
 
#  define MXML_ADD_BEFORE       0       /* Add node before specified node */
65
 
#  define MXML_ADD_AFTER        1       /* Add node after specified node */
66
 
#  define MXML_ADD_TO_PARENT    NULL    /* Add node relative to parent */
67
 
 
68
 
 
69
 
/*
70
 
 * Data types...
71
 
 */
72
 
 
73
 
typedef enum mxml_type_e                /**** The XML node type. ****/
74
 
{
75
 
  MXML_ELEMENT,                         /* XML element with attributes */
76
 
  MXML_INTEGER,                         /* Integer value */
77
 
  MXML_OPAQUE,                          /* Opaque string */
78
 
  MXML_REAL,                            /* Real value */
79
 
  MXML_TEXT,                            /* Text fragment */
80
 
  MXML_CUSTOM                           /* Custom data */
81
 
} mxml_type_t;
82
 
 
83
 
typedef struct mxml_attr_s              /**** An XML element attribute value. ****/
84
 
{
85
 
  char                  *name;          /* Attribute name */
86
 
  char                  *value;         /* Attribute value */
87
 
} mxml_attr_t;
88
 
 
89
 
typedef struct mxml_value_s             /**** An XML element value. ****/
90
 
{
91
 
  char                  *name;          /* Name of element */
92
 
  int                   num_attrs;      /* Number of attributes */
93
 
  mxml_attr_t           *attrs;         /* Attributes */
94
 
} mxml_element_t;
95
 
 
96
 
typedef struct mxml_text_s              /**** An XML text value. ****/
97
 
{
98
 
  int                   whitespace;     /* Leading whitespace? */
99
 
  char                  *string;        /* Fragment string */
100
 
} mxml_text_t;
101
 
 
102
 
typedef struct mxml_custom_s            /**** An XML custom value. ****/
103
 
{
104
 
  void                  *data;          /* Pointer to (allocated) custom data */
105
 
  void                  (*destroy)(void *);
106
 
                                        /* Pointer to destructor function */
107
 
} mxml_custom_t;
108
 
 
109
 
typedef union mxml_value_u              /**** An XML node value. ****/
110
 
{
111
 
  mxml_element_t        element;        /* Element */
112
 
  int                   integer;        /* Integer number */
113
 
  char                  *opaque;        /* Opaque string */
114
 
  double                real;           /* Real number */
115
 
  mxml_text_t           text;           /* Text fragment */
116
 
  mxml_custom_t         custom;         /* Custom data */
117
 
} mxml_value_t;
118
 
 
119
 
typedef struct mxml_node_s              /**** An XML node. ****/
120
 
{
121
 
  mxml_type_t           type;           /* Node type */
122
 
  struct mxml_node_s    *next;          /* Next node under same parent */
123
 
  struct mxml_node_s    *prev;          /* Previous node under same parent */
124
 
  struct mxml_node_s    *parent;        /* Parent node */
125
 
  struct mxml_node_s    *child;         /* First child node */
126
 
  struct mxml_node_s    *last_child;    /* Last child node */
127
 
  mxml_value_t          value;          /* Node value */
128
 
} mxml_node_t;
129
 
 
130
 
typedef struct mxml_index_s             /**** An XML node index. ****/
131
 
{
132
 
  char                  *attr;          /* Attribute used for indexing or NULL */
133
 
  int                   num_nodes;      /* Number of nodes in index */
134
 
  int                   alloc_nodes;    /* Allocated nodes in index */
135
 
  int                   cur_node;       /* Current node */
136
 
  mxml_node_t           **nodes;        /* Node array */
137
 
} mxml_index_t;
138
 
 
139
 
typedef int (*mxml_custom_load_cb_t)(mxml_node_t *, const char *);
140
 
                                        /**** Custom data load callback function ****/
141
 
 
142
 
typedef char *(*mxml_custom_save_cb_t)(mxml_node_t *);  
143
 
                                        /**** Custom data save callback function ****/
144
 
 
145
 
 
146
 
/*
147
 
 * C++ support...
148
 
 */
149
 
 
150
 
#  ifdef __cplusplus
151
 
extern "C" {
152
 
#  endif /* __cplusplus */
153
 
 
154
 
/*
155
 
 * Prototypes...
156
 
 */
157
 
 
158
 
extern void             mxmlAdd(mxml_node_t *parent, int where,
159
 
                                mxml_node_t *child, mxml_node_t *node);
160
 
extern void             mxmlDelete(mxml_node_t *node);
161
 
extern const char       *mxmlElementGetAttr(mxml_node_t *node, const char *name);
162
 
extern void             mxmlElementSetAttr(mxml_node_t *node, const char *name,
163
 
                                           const char *value);
164
 
extern int              mxmlEntityAddCallback(int (*cb)(const char *name));
165
 
extern const char       *mxmlEntityGetName(int val);
166
 
extern int              mxmlEntityGetValue(const char *name);
167
 
extern void             mxmlEntityRemoveCallback(int (*cb)(const char *name));
168
 
extern mxml_node_t      *mxmlFindElement(mxml_node_t *node, mxml_node_t *top,
169
 
                                         const char *name, const char *attr,
170
 
                                         const char *value, int descend);
171
 
extern void             mxmlIndexDelete(mxml_index_t *ind);
172
 
extern mxml_node_t      *mxmlIndexEnum(mxml_index_t *ind);
173
 
extern mxml_node_t      *mxmlIndexFind(mxml_index_t *ind,
174
 
                                       const char *element,
175
 
                                       const char *value);
176
 
extern mxml_index_t     *mxmlIndexNew(mxml_node_t *node, const char *element,
177
 
                                      const char *attr);
178
 
extern mxml_node_t      *mxmlIndexReset(mxml_index_t *ind);
179
 
extern mxml_node_t      *mxmlLoadFd(mxml_node_t *top, int fd,
180
 
                                    mxml_type_t (*cb)(mxml_node_t *));
181
 
extern mxml_node_t      *mxmlLoadFile(mxml_node_t *top, FILE *fp,
182
 
                                      mxml_type_t (*cb)(mxml_node_t *));
183
 
extern mxml_node_t      *mxmlLoadString(mxml_node_t *top, const char *s,
184
 
                                        mxml_type_t (*cb)(mxml_node_t *));
185
 
extern mxml_node_t      *mxmlNewCustom(mxml_node_t *parent, void *data,
186
 
                                       void (*destroy)(void *));
187
 
extern mxml_node_t      *mxmlNewElement(mxml_node_t *parent, const char *name);
188
 
extern mxml_node_t      *mxmlNewInteger(mxml_node_t *parent, int integer);
189
 
extern mxml_node_t      *mxmlNewOpaque(mxml_node_t *parent, const char *opaque);
190
 
extern mxml_node_t      *mxmlNewReal(mxml_node_t *parent, double real);
191
 
extern mxml_node_t      *mxmlNewText(mxml_node_t *parent, int whitespace,
192
 
                                     const char *string);
193
 
extern mxml_node_t      *mxmlNewTextf(mxml_node_t *parent, int whitespace,
194
 
                                      const char *format, ...)
195
 
#    ifdef __GNUC__
196
 
__attribute__ ((__format__ (__printf__, 3, 4)))
197
 
#    endif /* __GNUC__ */
198
 
;
199
 
extern void             mxmlRemove(mxml_node_t *node);
200
 
extern char             *mxmlSaveAllocString(mxml_node_t *node,
201
 
                                             const char *(*cb)(mxml_node_t *, int));
202
 
extern int              mxmlSaveFd(mxml_node_t *node, int fd,
203
 
                                   const char *(*cb)(mxml_node_t *, int));
204
 
extern int              mxmlSaveFile(mxml_node_t *node, FILE *fp,
205
 
                                     const char *(*cb)(mxml_node_t *, int));
206
 
extern int              mxmlSaveString(mxml_node_t *node, char *buffer,
207
 
                                       int bufsize,
208
 
                                       const char *(*cb)(mxml_node_t *, int));
209
 
extern int              mxmlSetCustom(mxml_node_t *node, void *data,
210
 
                                      void (*destroy)(void *));
211
 
extern void             mxmlSetCustomHandlers(mxml_custom_load_cb_t load,
212
 
                                              mxml_custom_save_cb_t save);
213
 
extern int              mxmlSetElement(mxml_node_t *node, const char *name);
214
 
extern void             mxmlSetErrorCallback(void (*cb)(const char *));
215
 
extern int              mxmlSetInteger(mxml_node_t *node, int integer);
216
 
extern int              mxmlSetOpaque(mxml_node_t *node, const char *opaque);
217
 
extern int              mxmlSetReal(mxml_node_t *node, double real);
218
 
extern int              mxmlSetText(mxml_node_t *node, int whitespace,
219
 
                                    const char *string);
220
 
extern int              mxmlSetTextf(mxml_node_t *node, int whitespace,
221
 
                                     const char *format, ...)
222
 
#    ifdef __GNUC__
223
 
__attribute__ ((__format__ (__printf__, 3, 4)))
224
 
#    endif /* __GNUC__ */
225
 
;
226
 
extern mxml_node_t      *mxmlWalkNext(mxml_node_t *node, mxml_node_t *top,
227
 
                                      int descend);
228
 
extern mxml_node_t      *mxmlWalkPrev(mxml_node_t *node, mxml_node_t *top,
229
 
                                      int descend);
230
 
 
231
 
 
232
 
/*
233
 
 * Private functions...
234
 
 */
235
 
 
236
 
extern void             mxml_error(const char *format, ...);
237
 
extern mxml_type_t      mxml_integer_cb(mxml_node_t *node);
238
 
extern mxml_type_t      mxml_opaque_cb(mxml_node_t *node);
239
 
extern mxml_type_t      mxml_real_cb(mxml_node_t *node);
240
 
 
241
 
 
242
 
/*
243
 
 * C++ support...
244
 
 */
245
 
 
246
 
#  ifdef __cplusplus
247
 
}
248
 
#  endif /* __cplusplus */
249
 
#endif /* !_mxml_h_ */
250
 
 
251
 
 
252
 
/*
253
 
 * End of "$Id: mxml.h 22267 2006-04-24 17:11:45Z kpfleming $".
254
 
 */