704db070a375c3ff33d61fade595ee0801604be6
[bluesky.git] / libs3-1.4 / inc / simplexml.h
1 /** **************************************************************************
2  * simplexml.h
3  * 
4  * Copyright 2008 Bryan Ischo <bryan@ischo.com>
5  * 
6  * This file is part of libs3.
7  * 
8  * libs3 is free software: you can redistribute it and/or modify it under the
9  * terms of the GNU General Public License as published by the Free Software
10  * Foundation, version 3 of the License.
11  *
12  * In addition, as a special exception, the copyright holders give
13  * permission to link the code of this library and its programs with the
14  * OpenSSL library, and distribute linked combinations including the two.
15  *
16  * libs3 is distributed in the hope that it will be useful, but WITHOUT ANY
17  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
19  * details.
20  *
21  * You should have received a copy of the GNU General Public License version 3
22  * along with libs3, in a file named COPYING.  If not, see
23  * <http://www.gnu.org/licenses/>.
24  *
25  ************************************************************************** **/
26
27 #ifndef SIMPLEXML_H
28 #define SIMPLEXML_H
29
30 #include "libs3.h"
31
32
33 // Simple XML callback.
34 //
35 // elementPath: is the full "path" of the element; i.e.
36 // <foo><bar><baz>data</baz></bar></foo> would have 'data' in the element
37 // foo/bar/baz.
38 // 
39 // Return of anything other than S3StatusOK causes the calling
40 // simplexml_add() function to immediately stop and return the status.
41 //
42 // data is passed in as 0 on end of element
43 typedef S3Status (SimpleXmlCallback)(const char *elementPath, const char *data,
44                                      int dataLen, void *callbackData);
45
46 typedef struct SimpleXml
47 {
48     void *xmlParser;
49
50     SimpleXmlCallback *callback;
51
52     void *callbackData;
53
54     char elementPath[512];
55
56     int elementPathLen;
57
58     S3Status status;
59 } SimpleXml;
60
61
62 // Simple XML parsing
63 // ----------------------------------------------------------------------------
64
65 // Always call this, even if the simplexml doesn't end up being used
66 void simplexml_initialize(SimpleXml *simpleXml, SimpleXmlCallback *callback,
67                           void *callbackData);
68
69 S3Status simplexml_add(SimpleXml *simpleXml, const char *data, int dataLen);
70
71
72 // Always call this
73 void simplexml_deinitialize(SimpleXml *simpleXml);
74
75
76 #endif /* SIMPLEXML_H */