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