1 #include <varlist.h>
2 #include <nclist.h>
3 #include <context.h>
4 #include <staglist.h>
5 #include <tagplist.h>
6 #include <default_tags.h>
7 #include <tokens.h>
8 
9 #ifdef WIN32
10 #define snprintf _snprintf
11 #endif
12 
13 #ifndef __TEMPLATE_H
14 #define __TEMPLATE_H
15 
16 #define TEMPLATE_TRUE           "1"
17 #define TEMPLATE_FALSE          "0"
18 
19 #define TMPL_ENONE              0
20 #define TMPL_EMALLOC		1
21 #define TMPL_ENULLARG		2
22 #define TMPL_EBADARG		3
23 #define TMPL_ENOVALUE		4
24 #define TMPL_ENOCTX		5
25 #define TMPL_ENOSTAG		6
26 #define TMPL_ENOTAGP		7
27 #define TMPL_ENOTFOUND		8
28 #define TMPL_EFOPEN		9
29 #define TMPL_EPARSE		10
30 #define TMPL_ESCREWY		11
31 #define TMPL_ENOTOKEN		12
32 
33 #define TMPL_ERR_MIN            0
34 #define TMPL_ERR_MAX            12
35 
36 #define TMPL_VARNAME_DIR        "INTERNAL_dir"
37 #define TMPL_VARNAME_OTAG       "INTERNAL_otag"
38 #define TMPL_VARNAME_CTAG       "INTERNAL_ctag"
39 
40 #define template_set_value(c, n, v)  context_set_value(c, n, v)
41 #define template_destroy(c)          context_destroy(c)
42 #define template_set_dir(c, d)       template_set_value(c, TMPL_VARNAME_DIR, d)
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif /* __cplusplus */
47 
48 extern int template_errno;
49 
50 extern char *template_errno_strings[];
51 
52 context_p template_init(void);
53 int       template_set_delimiters(context_p ctx, char *opentag,
54                                   char *closetag);
55 int       template_register_simple(context_p ctx, char *name,
56                              void (*function)(context_p, char **, int, char**));
57 int       template_alias_simple(context_p ctx, char *old_name, char *new_name);
58 void      template_remove_simple(context_p ctx, char *name);
59 int       template_register_pair(context_p ctx, char named_context,
60                                  char *open_name, char *close_name,
61                                  void (*function)(context_p, int, char**));
62 int       template_alias_pair(context_p ctx, char *old_open_name,
63                               char *old_close_name, char *new_open_name,
64                               char *new_close_name);
65 void      template_remove_pair(context_p ctx, char *open_name);
66 void      template_set_debug(context_p ctx, int debug_level);
67 void      template_set_strip(context_p ctx, int strip);
68 context_p template_loop_iteration(context_p ctx, char *loop_name);
69 context_p template_fetch_loop_iteration(context_p ctx, char *loop_name,
70                                         int iteration);
71 int       template_parse_string(context_p ctx, char *tmpl, char **output);
72 int       template_parse_file(context_p ctx, char *template_filename,
73                               char **output);
74 char *    template_strerror(void);
75 void      template_free_output(char *output); /* XX: do not use! */
76 
77 #ifdef __cplusplus
78 }
79 #endif /* __cplusplus */
80 
81 #endif /* __TEMPLATE_H */
82