aboutsummaryrefslogtreecommitdiff
path: root/include/ctemplates.h
blob: df410851d74b8f7e5cf623dd7f9baac3a182ac8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
 * C TemplateS Library 0.1 -
 * Forked from C Template Library 1.0 by Stephen C. Losen.
 *
 * Copyright 2017 Alexander M. Pickering  Distributed under the terms
 * of the GNU General Public License (GPL)
 */

#ifndef _CTEMPLATE_H
#define _CTEMPLATE_H

#define MAX_TEMPLATE_LENGTH 2147384647

#define ERRBUF_HINTLEN 50

//Length of error messages
#define ERR_MSG_LEN 500

struct TMPL_varlist;

struct TMPL_loop;

/* Holdes all the data needed for a template*/
struct TMPL_templates;

void TMPL_add_var_to_varlist(struct TMPL_varlist* vl, const char* name, const char* value);
void TMPL_add_loop_to_varlist(struct TMPL_varlist* vl, const char* name, struct TMPL_loop* loop);
void TMPL_add_varlist_to_loop(struct TMPL_loop* l, struct TMPL_varlist* vl);


struct TMPL_varlist* TMPL_alloc_varlist(void);
void                 TMPL_free_varlist(struct TMPL_varlist* t);

struct TMPL_templates* TMPL_alloc_template(const char* t);
void                   TMPL_free_template(struct TMPL_templates* t);

struct TMPL_loop* TMPL_alloc_loop(void);
void              TMPL_free_loop(struct TMPL_loop* tl);

char* TMPL_render(struct TMPL_templates* t, struct TMPL_varlist* varlist, size_t* size_p);
const char* TMPL_err(struct TMPL_templates* t,size_t* size);

/*A debug function*/
void print_varlist(struct TMPL_varlist* vl);
void print_ast(struct TMPL_templates* root);

#endif