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

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

Revert "webif: Simplify template loading and checking."

This reverts commit r8346. The subdir logic is used to have different
template directories for different paths comming from http request.

For more info see:

http://www.streamboard.tv/wbb2/thread.php?threadid=37378

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