1 /* Copyright (c) 2007-2009 by Adalin B.V.
2 * Copyright (c) 2007-2009 by Erik Hofman
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of (any of) the copyrightholder(s) nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
17 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
18 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
19 * THE COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #define __XML_CONFIG 1
35 #undef XML_NONVALIDATING
37 #ifdef XML_USE_NODECACHE
38 #include "xml_cache.h"
40 void *cacheGet(void *);
48 XML_INVALID_NODE_NAME,
52 XML_INVALID_INFO_BLOCK,
53 XML_ELEMENT_NO_OPENING_TAG,
54 XML_ELEMENT_NO_CLOSING_TAG,
55 XML_ATTRIB_NO_OPENING_QUOTE,
56 XML_ATTRIB_NO_CLOSING_QUOTE,
61 # define WIN32_LEAN_AND_MEAN
71 #ifndef XML_NONVALIDATING
80 * It is required for both the rood node and the normal xml nodes to both
81 * have 'char *name' defined as the first entry. The code tests whether
82 * name == 0 to detect the root node.
90 #ifdef XML_USE_NODECACHE
93 #ifndef XML_NONVALIDATING
94 struct _xml_error *info;
107 #ifndef XML_NONVALIDATING
108 struct _root_id *root;
110 #ifdef XML_USE_NODECACHE
118 * Open an XML file for processing.
120 * @param fname path to the file
121 * @return XML-id which is used for further processing
123 void *xmlOpen(const char *);
126 * Process a section of XML code in a preallocated buffer.
127 * The buffer may not be free'd until xmlClose has been called.
129 * @param buffer pointer to the buffer
130 * @param size size of the buffer
131 * @return XML-id which is used for further processing
133 void *xmlInitBuffer(const char *, size_t);
136 * Close the XML file after which no further processing is possible.
140 void xmlClose(void *);
144 * Locate a subsection of the xml tree for further processing.
145 * This adds processing speed since the reuired nodes will only be searched
148 * The memory allocated for the XML-subsection-id has to be freed by the
152 * @param node path to the node containing the subsection
153 * @return XML-subsection-id for further processing
155 void *xmlNodeGet(const void *, const char *);
158 * Copy a subsection of the xml tree for further processing.
159 * This is useful when it's required to process a section of the XML code
160 * after the file has been closed. The drawback is the added memory
163 * The memory allocated for the XML-subsection-id has to be freed by the
167 * @param node path to the node containing the subsection
168 * @return XML-subsection-id for further processing
170 void *xmlNodeCopy(const void *, const char *);
174 * Return the name of this node.
175 * The returned string has to be freed by the calling process.
178 * @return a newly alocated string containing the node name
180 char *xmlNodeGetName(const void *);
183 * Copy the name of this node in a pre-allocated buffer.
186 * @param buffer the buffer to copy the string to
187 * @param buflen length of the destination buffer
188 * @return the length of the node name
190 size_t xmlNodeCopyName(const void *, char *, size_t);
194 * Create a marker XML-id that starts out with the same settings as the
197 * Marker id's are required when xmlNodeGetNum() and xmlNodeGetPos() are used
198 * to walk a number of nodes. The xmlNodeGetPos function adjusts the contents
199 * of the provided XML-id to keep track of it's position within the xml section.
200 * The returned XML-id is limited to the boundaries of the requested XML tag
201 * and has to be freed by the calling process.
203 * @param xid reference XML-id
204 * @return a copy of the reference XML-id
206 void *xmlMarkId(const void *);
209 * Get the number of nodes with the same name from a specified xml path.
212 * @param path path to the xml node
213 * @return the number count of the nodename
215 unsigned int xmlNodeGetNum(const void *, const char *);
218 * Get the nth occurrence of node in the parent node.
219 * The return value should never be altered or freed by the caller.
221 * @param pid XML-id of the parent node of this node
223 * @param node name of the node to search for
224 * @param num specify which occurence to return
225 * @return XML-subsection-id for further processing or NULL if unsuccessful
227 void *xmlNodeGetPos(const void *, void *, const char *, size_t);
231 * Get a string of characters from the current node.
232 * The returned string has to be freed by the calling process.
235 * @return a newly alocated string containing the contents of the node
237 char *xmlGetString(const void *);
240 * Get a string of characters from the current node.
241 * This function has the advantage of not allocating its own return buffer,
242 * keeping the memory management to an absolute minimum but the disadvantage
243 * is that it's unreliable in multithread environments.
246 * @param buffer the buffer to copy the string to
247 * @param buflen length of the destination buffer
248 * @return the length of the string
250 size_t xmlCopyString(const void *, char *, size_t);
253 * Compare the value of this node to a reference string.
254 * Comparing is done in a case insensitive way.
257 * @param str the string to compare to
258 * @return an integer less than, equal to, ro greater than zero if the value
259 * of the node is found, respectively, to be less than, to match, or be greater
262 int xmlCompareString(const void *, const char *);
265 * Get a string of characters from a specified xml path.
266 * The returned string has to be freed by the calling process.
269 * @param path path to the xml node
270 * @return a newly alocated string containing the contents of the node
272 char *xmlNodeGetString(const void *, const char *);
275 * Get a string of characters from a specified xml path.
276 * This function has the advantage of not allocating its own return buffer,
277 * keeping the memory management to an absolute minimum but the disadvantage
278 * is that it's unreliable in multithread environments.
281 * @param path path to the xml node
282 * @param buffer the buffer to copy the string to
283 * @param buflen length of the destination buffer
284 * @return the length of the string
286 size_t xmlNodeCopyString(const void *, const char *, char *, size_t);
289 * Compare the value of a node to a reference string.
290 * Comparing is done in a case insensitive way.
293 * @param path path to the xml node to compare to
294 * @param str the string to compare to
295 * @return an integer less than, equal to, ro greater than zero if the value
296 * of the node is found, respectively, to be less than, to match, or be greater
299 int xmlNodeCompareString(const void *, const char *, const char *);
302 * Get a string of characters from a named attribute.
303 * The returned string has to be freed by the calling process.
306 * @param name name of the attribute to acquire
307 * @return the contents of the node converted to an integer value
309 char *xmlAttributeGetString(const void *, const char *);
312 * Get a string of characters from a named attribute.
313 * This function has the advantage of not allocating its own return buffer,
314 * keeping the memory management to an absolute minimum but the disadvantage
315 * is that it's unreliable in multithread environments.
318 * @param name name of the attribute to acquire.
319 * @param buffer the buffer to copy the string to
320 * @param buflen length of the destination buffer
321 * @return the length of the string
323 size_t xmlAttributeCopyString(const void *, const char *, char *, size_t);
326 * Compare the value of an attribute to a reference string.
327 * Comparing is done in a case insensitive way.
330 * @param name name of the attribute to acquire.
331 * @param str the string to compare to
332 * @return an integer less than, equal to, ro greater than zero if the value
333 * of the node is found, respectively, to be less than, to match, or be greater
336 int xmlAttributeCompareString(const void *, const char *, const char *);
340 * Get the integer value from the current node/
343 * @return the contents of the node converted to an integer value
345 long int xmlGetInt(const void *);
348 * Get an integer value from a specified xml path.
351 * @param path path to the xml node
352 * @return the contents of the node converted to an integer value
354 long int xmlNodeGetInt(const void *, const char *);
357 * Get the integer value from the named attribute.
360 * @param name name of the attribute to acquire
361 * @return the contents of the node converted to an integer value
363 long int xmlAttributeGetInt(const void *, const char *);
367 * Get the double value from the curent node/
370 * @return the contents of the node converted to a double value
372 double xmlGetDouble(const void *);
375 * Get a double value from a specified xml path/
378 * @param path path to the xml node
379 * @return the contents of the node converted to a double value
381 double xmlNodeGetDouble(const void *, const char *);
384 * Get the double value from the named attribute.
387 * @param name name of the attribute to acquire
388 * @return the contents of the node converted to an integer value
390 double xmlAttributeGetDouble(const void *, const char *);
394 * Get the error number of the last error and clear it.
397 * @param clear clear the error state if non zero
398 * @return the numer of the last error, 0 means no error detected.
400 int xmlErrorGetNo(const void *, int);
403 * Get the line number of the last detected syntax error in the xml file.
406 * @param clear clear the error state if non zero
407 * @return the line number of the detected syntax error.
409 size_t xmlErrorGetLineNo(const void *, int);
412 * Get the column number of the last detected syntax error in the xml file.
415 * @param clear clear the error state if non zero
416 * @return the line number of the detected syntax error.
418 size_t xmlErrorGetColumnNo(const void *, int);
421 * Get a string that explains the last error.
424 * @param clear clear the error state if non zero
425 * @return a string that explains the last error.
427 const char *xmlErrorGetString(const void *, int);
433 #endif /* __XML_CONFIG */