Delta Chat Core C-API
mrsaxparser.h
1 /*******************************************************************************
2  *
3  * Delta Chat Core
4  * Copyright (C) 2017 Björn Petersen
5  * Contact: r10s@b44t.com, http://b44t.com
6  *
7  * This program is free software: you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later
10  * version.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15  * details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program. If not, see http://www.gnu.org/licenses/ .
19  *
20  ******************************************************************************/
21 
22 
23 #ifndef __MRSAXPARSER_H__
24 #define __MRSAXPARSER_H__
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 typedef void (*mrsaxparser_starttag_cb_t) (void* userdata, const char* tag, char** attr);
31 typedef void (*mrsaxparser_endtag_cb_t) (void* userdata, const char* tag);
32 typedef void (*mrsaxparser_text_cb_t) (void* userdata, const char* text, int len); /* len is only informational, text is already null-terminated */
33 
34 
35 typedef struct mrsaxparser_t
36 {
37  mrsaxparser_starttag_cb_t m_starttag_cb;
38  mrsaxparser_endtag_cb_t m_endtag_cb;
39  mrsaxparser_text_cb_t m_text_cb;
40  void* m_userdata;
41 } mrsaxparser_t;
42 
43 
44 void mrsaxparser_init (mrsaxparser_t*, void* userData);
45 void mrsaxparser_set_tag_handler (mrsaxparser_t*, mrsaxparser_starttag_cb_t, mrsaxparser_endtag_cb_t);
46 void mrsaxparser_set_text_handler (mrsaxparser_t*, mrsaxparser_text_cb_t);
47 
48 void mrsaxparser_parse (mrsaxparser_t*, const char* text);
49 
50 const char* mrattr_find (char** attr, const char* key);
51 
52 
53 /*** library-private **********************************************************/
54 
55 
56 #ifdef __cplusplus
57 } /* /extern "C" */
58 #endif
59 #endif /* __MRSAXPARSER_H__ */
60