source: trunk/module-webif-tpl.h@ 8421

Last change on this file since 8421 was 8421, checked in by gf, 9 years ago

webif: Move template functions to module-webif-tpl.c

File size: 2.2 KB
Line 
1#ifndef MODULE_WEBIF_TPL_H_
2#define MODULE_WEBIF_TPL_H_
3
4/* Templates: Adds a variable. The variable can be used as often as wanted. */
5#define TPLADD 0
6/* Templates: Appends a variable or adds it if doesn't exist yet. The variable can be used as often as wanted. */
7#define TPLAPPEND 1
8/* Templates: Adds a variable which will be reset to "" after being used once, either through tpl_getVar or when used in a template.
9 tpl_addVar/tpl_printf don't do a reset and will overwrite the appendmode with a new value. */
10#define TPLADDONCE 2
11/* Templates: Appends a variable or adds it if doesn't exist yet. The variable will be reset to "" after being used once. See TPLADDONCE for details. */
12#define TPLAPPENDONCE 3
13
14#define TOUCH_SUBDIR "touch/"
15
16struct templatevars {
17 uint32_t varscnt;
18 uint32_t varsalloc;
19 uint32_t tmpcnt;
20 uint32_t tmpalloc;
21 char **names;
22 char **values;
23 uint8_t *vartypes;
24 char **tmp;
25 uint8_t messages;
26};
27
28struct templatevars *tpl_create(void);
29void tpl_clear(struct templatevars *vars);
30
31char *tpl_addVar(struct templatevars *vars, uint8_t addmode, char *name, char *value);
32char *tpl_addMsg(struct templatevars *vars, char *value);
33char *tpl_addTmp(struct templatevars *vars, char *value);
34char *tpl_printf(struct templatevars *vars, uint8_t addmode, char *varname, char *fmtstring, ...) __attribute__ ((format (printf, 4, 5)));
35
36char *tpl_getVar(struct templatevars *vars, char *name);
37char *tpl_getFilePathInSubdir(const char *path, const char* subdir, const char *name, const char* ext, char *result, uint32_t resultsize);
38char *tpl_getTplPath(const char *name, const char *path, char *result, uint32_t resultsize);
39char *tpl_getTpl(struct templatevars *vars, const char* name);
40char *tpl_getUnparsedTpl(const char* name, int8_t removeHeader, const char* subdir);
41
42int32_t tpl_saveIncludedTpls(const char *path);
43
44void tpl_checkOneDirDiskRevisions(const char* subdir);
45void tpl_checkDiskRevisions(void);
46
47void prepareTplChecksums(void);
48
49char *urlencode(struct templatevars *vars, char *str);
50char *xml_encode(struct templatevars *vars, char *chartoencode);
51char *sec2timeformat(struct templatevars *vars, int32_t seconds);
52
53#endif
Note: See TracBrowser for help on using the repository browser.