]>
Commit | Line | Data |
---|---|---|
4b292b55 | 1 | /* -*- mode: c; c-file-style: "openbsd" -*- */ |
f4d33e6b AH |
2 | /* |
3 | * Copyright (c) 2010 Andreas Hofmeister <andi@collax.com> | |
4 | * | |
51434125 | 5 | * Permission to use, copy, modify, and/or distribute this software for any |
f4d33e6b AH |
6 | * purpose with or without fee is hereby granted, provided that the above |
7 | * copyright notice and this permission notice appear in all copies. | |
8 | * | |
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
16 | */ | |
17 | ||
18 | #ifndef _WRITER_H | |
19 | #define _WRITER_H | |
20 | ||
21 | #include <stdio.h> | |
22 | ||
23 | struct writer { | |
24 | void * priv; | |
25 | void (*start)(struct writer *, const char * tag, const char * descr); | |
26 | void (*attr)(struct writer *, const char * tag, const char * descr, const char * value); | |
27 | void (*data)(struct writer *, const char * data); | |
28 | void (*end)(struct writer *); | |
29 | void (*finish)(struct writer *); | |
30 | }; | |
31 | ||
32 | #define tag_start(w,...) w->start(w,## __VA_ARGS__) | |
33 | #define tag_attr(w,...) w->attr(w,## __VA_ARGS__) | |
34 | #define tag_data(w,...) w->data(w,## __VA_ARGS__) | |
35 | #define tag_end(w,...) w->end(w,## __VA_ARGS__) | |
a094d3bc | 36 | #define tag_datatag(w,t,d,v) do { if ((v) == NULL) break; w->start(w,t,d); w->data(w,v); w->end(w); } while(0); |
f4d33e6b AH |
37 | |
38 | extern struct writer * txt_init( FILE * ); | |
999509a3 | 39 | extern struct writer * kv_init( FILE * ); |
f4d33e6b | 40 | |
1480ce74 AH |
41 | #ifdef USE_XML |
42 | extern struct writer * xml_init( FILE * ); | |
43 | #endif | |
8ff14a6d MS |
44 | #ifdef USE_JANSSON |
45 | extern struct writer * jansson_init( FILE * ); | |
46 | #endif | |
47 | #ifdef USE_JSONC | |
48 | extern struct writer * jsonc_init( FILE * ); | |
8b7150e4 | 49 | #endif |
1480ce74 | 50 | |
f4d33e6b | 51 | #endif /* _WRITER_H */ |