aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/ctemplates.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/include/ctemplates.h b/include/ctemplates.h
new file mode 100644
index 0000000..a8855a8
--- /dev/null
+++ b/include/ctemplates.h
@@ -0,0 +1,60 @@
+/*
+ * 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{
+ map_t map;
+}TMPL_varlist;
+
+struct TMPL_loop{
+ struct TMPL_varlist* varlist;
+ size_t loop_len;
+ struct TMPL_loop* next;
+ struct TMPL_loop* tail;
+};
+
+/* Holdes all the data needed for a template*/
+struct TMPL_templates{
+ struct TMPL_buf* out;
+ struct TMPL_buf* errout;
+ struct TMPL_tagnode* roottag;
+ int linenum;
+ int error;
+} TMPL_templates;
+
+
+void TMPL_add_var_to_varlist(struct TMPL_varlist* vl, char* name, char* value);
+void TMPL_add_loop_to_varlist(struct TMPL_varlist* vl, 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(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);
+
+/*A debug function*/
+void print_varlist(struct TMPL_varlist* vl);
+void print_ast(struct TMPL_templates* root);
+
+#endif