html-template-pro 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (222) hide show
  1. data/.autotest +9 -0
  2. data/ARTISTIC +131 -0
  3. data/History.txt +4 -0
  4. data/LGPL +504 -0
  5. data/Manifest.txt +221 -0
  6. data/README.rdoc +52 -0
  7. data/Rakefile +18 -0
  8. data/benchmark.rb +136 -0
  9. data/config/website.yml +2 -0
  10. data/ext/html/template/internal/Pro.xs +679 -0
  11. data/ext/html/template/internal/builtin_findfile.inc +361 -0
  12. data/ext/html/template/internal/calc.h +26 -0
  13. data/ext/html/template/internal/calc.inc +120 -0
  14. data/ext/html/template/internal/callback_stubs.inc +63 -0
  15. data/ext/html/template/internal/expr.c +2267 -0
  16. data/ext/html/template/internal/expr.y +476 -0
  17. data/ext/html/template/internal/expr_iface.c +94 -0
  18. data/ext/html/template/internal/exprpstr.h +36 -0
  19. data/ext/html/template/internal/exprpstr.inc +144 -0
  20. data/ext/html/template/internal/exprtool.h +99 -0
  21. data/ext/html/template/internal/exprtool.inc +289 -0
  22. data/ext/html/template/internal/exprtype.h +62 -0
  23. data/ext/html/template/internal/exprval.h +30 -0
  24. data/ext/html/template/internal/extconf.rb +6 -0
  25. data/ext/html/template/internal/internal.c +449 -0
  26. data/ext/html/template/internal/loadfile.h +11 -0
  27. data/ext/html/template/internal/loadfile.inc +171 -0
  28. data/ext/html/template/internal/pabidecl.h +54 -0
  29. data/ext/html/template/internal/pabstract.h +426 -0
  30. data/ext/html/template/internal/parse_expr.h +15 -0
  31. data/ext/html/template/internal/pbuffer.c +76 -0
  32. data/ext/html/template/internal/pbuffer.h +31 -0
  33. data/ext/html/template/internal/pmiscdef.h +54 -0
  34. data/ext/html/template/internal/pparam.h +101 -0
  35. data/ext/html/template/internal/ppport.h +1098 -0
  36. data/ext/html/template/internal/procore.c +1189 -0
  37. data/ext/html/template/internal/procore.h +18 -0
  38. data/ext/html/template/internal/proparam.c +443 -0
  39. data/ext/html/template/internal/proparam.h +571 -0
  40. data/ext/html/template/internal/proscope.h +32 -0
  41. data/ext/html/template/internal/proscope.inc +107 -0
  42. data/ext/html/template/internal/prostate.h +49 -0
  43. data/ext/html/template/internal/prostate.inc +24 -0
  44. data/ext/html/template/internal/provalue.h +14 -0
  45. data/ext/html/template/internal/pstring.h +60 -0
  46. data/ext/html/template/internal/pstrutils.h +25 -0
  47. data/ext/html/template/internal/pstrutils.inc +150 -0
  48. data/ext/html/template/internal/tagstack.h +30 -0
  49. data/ext/html/template/internal/tagstack.inc +65 -0
  50. data/ext/html/template/internal/tmpllog.c +62 -0
  51. data/ext/html/template/internal/tmpllog.h +27 -0
  52. data/ext/html/template/internal/tmplpro.h +218 -0
  53. data/ext/html/template/internal/tmplpro_version.c +35 -0
  54. data/lib/html/template/pro.rb +225 -0
  55. data/script/console +10 -0
  56. data/script/destroy +14 -0
  57. data/script/generate +14 -0
  58. data/script/txt2html +71 -0
  59. data/tasks/extconf.rake +13 -0
  60. data/tasks/extconf/tmplpro.rake +43 -0
  61. data/templates-Pro/a.incl +1 -0
  62. data/templates-Pro/empty.incl +0 -0
  63. data/templates-Pro/include/1/a.incl +1 -0
  64. data/templates-Pro/include/2.out +3 -0
  65. data/templates-Pro/include/2.tmpl +1 -0
  66. data/templates-Pro/include/2/a.incl +1 -0
  67. data/templates-Pro/include/3.tmpl +1 -0
  68. data/templates-Pro/include/4.tmpl +1 -0
  69. data/templates-Pro/include/a.incl +1 -0
  70. data/templates-Pro/test_broken.tmpl +25 -0
  71. data/templates-Pro/test_broken1.out +1 -0
  72. data/templates-Pro/test_broken1.tmpl +1 -0
  73. data/templates-Pro/test_esc1.out +4 -0
  74. data/templates-Pro/test_esc1.tmpl +4 -0
  75. data/templates-Pro/test_esc2.out +5 -0
  76. data/templates-Pro/test_esc2.tmpl +6 -0
  77. data/templates-Pro/test_esc3.out +4 -0
  78. data/templates-Pro/test_esc3.tmpl +4 -0
  79. data/templates-Pro/test_esc4.out +3 -0
  80. data/templates-Pro/test_esc4.tmpl +4 -0
  81. data/templates-Pro/test_expr1.out +26 -0
  82. data/templates-Pro/test_expr1.tmpl +26 -0
  83. data/templates-Pro/test_expr2.out +34 -0
  84. data/templates-Pro/test_expr2.tmpl +34 -0
  85. data/templates-Pro/test_expr3.out +6 -0
  86. data/templates-Pro/test_expr3.tmpl +6 -0
  87. data/templates-Pro/test_expr4.out +4 -0
  88. data/templates-Pro/test_expr4.tmpl +4 -0
  89. data/templates-Pro/test_expr5.out +18 -0
  90. data/templates-Pro/test_expr5.tmpl +18 -0
  91. data/templates-Pro/test_expr6.out +18 -0
  92. data/templates-Pro/test_expr6.tmpl +18 -0
  93. data/templates-Pro/test_expr7.out +44 -0
  94. data/templates-Pro/test_expr7.tmpl +20 -0
  95. data/templates-Pro/test_expr8.out +15 -0
  96. data/templates-Pro/test_expr8.tmpl +15 -0
  97. data/templates-Pro/test_if1.out +25 -0
  98. data/templates-Pro/test_if1.tmpl +28 -0
  99. data/templates-Pro/test_if2.out +17 -0
  100. data/templates-Pro/test_if2.tmpl +25 -0
  101. data/templates-Pro/test_if3.out +12 -0
  102. data/templates-Pro/test_if3.tmpl +14 -0
  103. data/templates-Pro/test_if4.out +15 -0
  104. data/templates-Pro/test_if4.tmpl +31 -0
  105. data/templates-Pro/test_if5.out +16 -0
  106. data/templates-Pro/test_if5.tmpl +16 -0
  107. data/templates-Pro/test_if6.out +15 -0
  108. data/templates-Pro/test_if6.tmpl +31 -0
  109. data/templates-Pro/test_if7.out +14 -0
  110. data/templates-Pro/test_if7.tmpl +18 -0
  111. data/templates-Pro/test_include1.out +23 -0
  112. data/templates-Pro/test_include1.tmpl +7 -0
  113. data/templates-Pro/test_include2.out +120 -0
  114. data/templates-Pro/test_include2.tmpl +10 -0
  115. data/templates-Pro/test_include3.out +8 -0
  116. data/templates-Pro/test_include3.tmpl +8 -0
  117. data/templates-Pro/test_include4.out +7 -0
  118. data/templates-Pro/test_include4.tmpl +6 -0
  119. data/templates-Pro/test_include5.out +7 -0
  120. data/templates-Pro/test_include5.tmpl +6 -0
  121. data/templates-Pro/test_loop1.erb +17 -0
  122. data/templates-Pro/test_loop1.out +12 -0
  123. data/templates-Pro/test_loop1.tmpl +16 -0
  124. data/templates-Pro/test_loop2.erb +19 -0
  125. data/templates-Pro/test_loop2.out +40 -0
  126. data/templates-Pro/test_loop2.tmpl +19 -0
  127. data/templates-Pro/test_loop3.out +38 -0
  128. data/templates-Pro/test_loop3.tmpl +40 -0
  129. data/templates-Pro/test_loop4.out +44 -0
  130. data/templates-Pro/test_loop4.tmpl +20 -0
  131. data/templates-Pro/test_loop5.out +9 -0
  132. data/templates-Pro/test_loop5.tmpl +11 -0
  133. data/templates-Pro/test_loop6.out +33 -0
  134. data/templates-Pro/test_loop6.tmpl +15 -0
  135. data/templates-Pro/test_malloc.tmpl +1 -0
  136. data/templates-Pro/test_userfunc1.out +14 -0
  137. data/templates-Pro/test_userfunc1.tmpl +14 -0
  138. data/templates-Pro/test_userfunc2.out +35 -0
  139. data/templates-Pro/test_userfunc2.tmpl +5 -0
  140. data/templates-Pro/test_userfunc3.out +5 -0
  141. data/templates-Pro/test_userfunc3.tmpl +5 -0
  142. data/templates-Pro/test_userfunc4.out +10 -0
  143. data/templates-Pro/test_userfunc4.tmpl +10 -0
  144. data/templates-Pro/test_userfunc5.out +4 -0
  145. data/templates-Pro/test_userfunc5.tmpl +4 -0
  146. data/templates-Pro/test_userfunc6.out +4 -0
  147. data/templates-Pro/test_userfunc6.tmpl +4 -0
  148. data/templates-Pro/test_var1.erb +23 -0
  149. data/templates-Pro/test_var1.out +20 -0
  150. data/templates-Pro/test_var1.tmpl +23 -0
  151. data/templates-Pro/test_var2.erb +7 -0
  152. data/templates-Pro/test_var2.out +6 -0
  153. data/templates-Pro/test_var2.tmpl +7 -0
  154. data/templates-Pro/test_var3.out +14 -0
  155. data/templates-Pro/test_var3.tmpl +16 -0
  156. data/templates/case_loop.tmpl +3 -0
  157. data/templates/context.tmpl +3 -0
  158. data/templates/counter.tmpl +2 -0
  159. data/templates/default.tmpl +1 -0
  160. data/templates/default_escape.tmpl +4 -0
  161. data/templates/double_loop.tmpl +7 -0
  162. data/templates/escape.tmpl +5 -0
  163. data/templates/global-loops.tmpl +9 -0
  164. data/templates/globals.tmpl +11 -0
  165. data/templates/if.tmpl +7 -0
  166. data/templates/ifelse.tmpl +6 -0
  167. data/templates/include.tmpl +14 -0
  168. data/templates/include_path/a.tmpl +2 -0
  169. data/templates/include_path/b.tmpl +1 -0
  170. data/templates/include_path/inner.tmpl +1 -0
  171. data/templates/include_path/one.tmpl +2 -0
  172. data/templates/include_path2/inner.tmpl +1 -0
  173. data/templates/included.tmpl +4 -0
  174. data/templates/included2.tmpl +3 -0
  175. data/templates/js.tmpl +1 -0
  176. data/templates/long_loops.tmpl +307 -0
  177. data/templates/loop-context.tmpl +2 -0
  178. data/templates/loop-if.tmpl +9 -0
  179. data/templates/medium.tmpl +217 -0
  180. data/templates/multiline_tags.tmpl +7 -0
  181. data/templates/newline_test1.tmpl +1 -0
  182. data/templates/newline_test2.tmpl +1 -0
  183. data/templates/other-loop.tmpl +7 -0
  184. data/templates/outer.tmpl +3 -0
  185. data/templates/query-test.tmpl +21 -0
  186. data/templates/query-test2.tmpl +12 -0
  187. data/templates/recursive.tmpl +2 -0
  188. data/templates/searchpath/included.tmpl +4 -0
  189. data/templates/searchpath/three.tmpl +1 -0
  190. data/templates/searchpath/two.tmpl +2 -0
  191. data/templates/simple-loop-nonames.tmpl +13 -0
  192. data/templates/simple-loop.tmpl +12 -0
  193. data/templates/simple.tmpl +9 -0
  194. data/templates/unless.tmpl +5 -0
  195. data/templates/urlescape.tmpl +3 -0
  196. data/templates/vanguard1.tmpl +2 -0
  197. data/templates/vanguard2.tmpl +3 -0
  198. data/test/templates/complex.tmpl +24 -0
  199. data/test/templates/foo.tmpl +6 -0
  200. data/test/templates/func.tmpl +2 -0
  201. data/test/templates/loop.tmpl +14 -0
  202. data/test/templates/negative.tmpl +1 -0
  203. data/test/templates/numerics.tmpl +6 -0
  204. data/test/templates/register.tmpl +2 -0
  205. data/test/test_basic.rb +23 -0
  206. data/test/test_coderefs.rb +16 -0
  207. data/test/test_complex.rb +106 -0
  208. data/test/test_helper.rb +3 -0
  209. data/test/test_html_template.rb +583 -0
  210. data/test/test_html_template_internal_extn.rb +10 -0
  211. data/test/test_html_template_pro.rb +177 -0
  212. data/test/test_path_like_variable_scope.rb +59 -0
  213. data/test/test_random.rb +21 -0
  214. data/test/test_realloc.rb +16 -0
  215. data/test/test_register.rb +25 -0
  216. data/test/test_tmplpro.rb +9 -0
  217. data/test/tests.rb +9 -0
  218. data/website/index.txt +57 -0
  219. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  220. data/website/stylesheets/screen.css +159 -0
  221. data/website/template.html.erb +50 -0
  222. metadata +303 -0
@@ -0,0 +1,11 @@
1
+ /* -*- c -*-
2
+ * File: loadfile.h
3
+ * Author: Igor Vlasenko <vlasenko@imath.kiev.ua>
4
+ * Created: Thu Sep 8 17:16:48 2005
5
+ *
6
+ * $Id$
7
+ */
8
+
9
+ PSTRING mmap_load_file (const char* filepath);
10
+ int mmap_unload_file (PSTRING memarea);
11
+
@@ -0,0 +1,171 @@
1
+ /* -*- c -*-
2
+ * File: loadfile.h
3
+ * Author: Igor Vlasenko <vlasenko@imath.kiev.ua>
4
+ * Created: Thu Sep 8 17:16:48 2005
5
+ *
6
+ * $Id$
7
+ */
8
+
9
+ #ifdef HAVE_CONFIG_H
10
+ #include "config.h"
11
+ #endif
12
+
13
+ #ifdef USE_MMAP
14
+
15
+ #ifdef WIN32
16
+ /*
17
+ * the win32 code of Viacheslav Sheveliov <slavash@aha.ru>
18
+ * viy: should work for win64 too.
19
+ */
20
+
21
+ #include <windows.h>
22
+ #include <stdio.h>
23
+
24
+ static PSTRING mmap_load_file(const char *filepath) {
25
+ PSTRING memarea = { NULL, NULL };
26
+ HANDLE hFile, hMapObject = NULL;
27
+
28
+ hFile = CreateFile(
29
+ TEXT(filepath),
30
+ GENERIC_READ,
31
+ FILE_SHARE_READ,
32
+ NULL,
33
+ OPEN_EXISTING,
34
+ FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,
35
+ NULL
36
+ );
37
+
38
+ if (hFile != INVALID_HANDLE_VALUE) {
39
+ hMapObject = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
40
+
41
+ if (hMapObject) {
42
+ // Get a pointer to the file-mapped shared memory.
43
+ LPCTSTR lpvMem = (LPTSTR) MapViewOfFile(hMapObject, FILE_MAP_READ, 0, 0, 0);
44
+
45
+ if (lpvMem) {
46
+ // Everything OK!
47
+
48
+ memarea.begin = (char *) lpvMem;
49
+ memarea.endnext = memarea.begin + GetFileSize(hFile, NULL);
50
+ // After MapViewOfFile we don't need file handles no more.
51
+ // Undocumented, but it works! (In read-only mode?)
52
+ CloseHandle(hMapObject);
53
+ CloseHandle(hFile);
54
+
55
+ return memarea;
56
+
57
+ }
58
+ }
59
+ }
60
+
61
+ // Something goes wrong
62
+
63
+ {
64
+ // Save last error code, before any system call
65
+ DWORD dwLastError = GetLastError();
66
+
67
+ // Report error, if file size != 0
68
+ // Mapping of zero-length file cause CreateFileMapping to fail.
69
+ // So skip error messages in this case.
70
+ if (hFile == INVALID_HANDLE_VALUE || GetFileSize(hFile, NULL) != 0)
71
+ fprintf(stderr, "Could not open file '%s'. (system error#%ld)\n", filepath, dwLastError);
72
+
73
+ }
74
+ // Close all opened handles
75
+ if (hMapObject) CloseHandle(hMapObject);
76
+ if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile);
77
+
78
+ return memarea;
79
+ }
80
+
81
+ /* we use function, not define, because someday we may need its address */
82
+ static int mmap_unload_file(PSTRING memarea) { return UnmapViewOfFile((void*) memarea.begin) ? 0 : -1; };
83
+ /* define mmap_unload_file(map) (UnmapViewOfFile((LPCVOID) map.begin) ? 0 : -1) */
84
+
85
+ #else /* unix, sweet unix :) */
86
+ #if defined(HAVE_SYS_MMAN_H) && defined(HAVE_SYS_STAT_H)
87
+
88
+ /* # define NULL 0 */
89
+ #include <sys/stat.h>
90
+ #include <sys/mman.h>
91
+ #include <fcntl.h> /* open */
92
+ #include <unistd.h> /* close */
93
+
94
+ static
95
+ PSTRING
96
+ mmap_load_file (const char* filepath) {
97
+ int fd;
98
+ struct stat st;
99
+ size_t size_in_bytes;
100
+ PSTRING memarea={NULL,NULL};
101
+ fd = open(filepath, O_RDONLY);
102
+ if (fd == -1) return memarea; /* {NULL,NULL} */
103
+ fstat(fd, &st);
104
+ size_in_bytes = st.st_size;
105
+ /* mmap size_in_bytes+1 to avoid crash with empty file */
106
+ memarea.begin = (char *) mmap(0, size_in_bytes+1, PROT_READ, MAP_SHARED, fd, 0);
107
+ close(fd);
108
+ memarea.endnext=memarea.begin+size_in_bytes;
109
+ return memarea;
110
+ }
111
+
112
+ static
113
+ int
114
+ mmap_unload_file (PSTRING memarea) {
115
+ /* destroying */
116
+ return munmap((void *)memarea.begin, memarea.endnext-memarea.begin);
117
+ }
118
+
119
+ #endif /* UNIX */
120
+ #endif /* WIN32 */
121
+
122
+ #else
123
+ /*
124
+ * system seems to have no mmap ;
125
+ * we use standard C buffered read
126
+ */
127
+ #include <stdio.h>
128
+ static
129
+ PSTRING
130
+ mmap_load_file (const char* filepath) {
131
+ FILE *stream;
132
+ size_t size_in_bytes=0;
133
+ size_t realsize;
134
+ size_t chunksize=4096;
135
+ size_t memsize=chunksize;
136
+ PSTRING memarea={NULL,NULL};
137
+ char* writepoint;
138
+ /* text mode for HTML::Template compatibility */
139
+ stream = fopen(filepath, "r");
140
+ if (stream == NULL) return memarea; /* {NULL,NULL} */
141
+ /* mmap size_in_bytes+1 to avoid crash with empty file */
142
+ memarea.begin=(char*) malloc(memsize+1);
143
+ writepoint=memarea.begin;
144
+
145
+ while (1) {
146
+ realsize=fread(writepoint, 1, chunksize, stream);
147
+ size_in_bytes+=realsize;
148
+ if (realsize==chunksize) {
149
+ writepoint+=chunksize;
150
+ if (size_in_bytes+chunksize>memsize) {
151
+ memsize*=2;
152
+ memarea.begin=(char*) realloc(memarea.begin, memsize+1);
153
+ writepoint=memarea.begin+size_in_bytes;
154
+ }
155
+ } else {
156
+ fclose(stream);
157
+ memarea.endnext=memarea.begin+size_in_bytes;
158
+ return memarea;
159
+ }
160
+ }
161
+ }
162
+
163
+ static
164
+ int
165
+ mmap_unload_file (PSTRING memarea) {
166
+ /* destroying */
167
+ free(memarea.begin);
168
+ return 0;
169
+ }
170
+
171
+ #endif /* USE_MMAP */
@@ -0,0 +1,54 @@
1
+ /*! \file pabidecl.h
2
+ \brief calling conventions.
3
+
4
+ * APICALL and BACKCALL can be something like __stdcall or __cdecl (compiler-specific).
5
+
6
+ * APICALL set the calling convention for exported symbols.
7
+
8
+ * BACKCALL set the calling convention for callback pointers.
9
+
10
+ * By default, the code uses C standard (Cdecl) calling conventions.
11
+ * One can override the calling conventions by defining their own
12
+ * APICALL and BACKCALL macro.
13
+ */
14
+
15
+ #ifndef _PABIDECL_H
16
+ #define _PABIDECL_H 1
17
+
18
+ #ifdef __cplusplus
19
+ #define TMPLPRO_EXTERN_C extern "C"
20
+ #else
21
+ #define TMPLPRO_EXTERN_C
22
+ #endif
23
+
24
+ #if defined( __WIN32__ ) || defined( _WIN32 ) || defined __CYGWIN__
25
+ # define TMPLPRO_HIDDEN_SYM
26
+ # if defined(HTMLTMPLPRO_STATIC)
27
+ # define TMPLPRO_EXPORT_SYM
28
+ # else
29
+ # if defined( htmltmplpro_EXPORTS ) || defined (DLL_EXPORT)
30
+ # define TMPLPRO_EXPORT_SYM __declspec(dllexport)
31
+ # else
32
+ # define TMPLPRO_EXPORT_SYM __declspec(dllimport)
33
+ # endif
34
+ # endif
35
+ #elif __GNUC__ >= 4
36
+ # define TMPLPRO_EXPORT_SYM __attribute__ ((visibility("default")))
37
+ # define TMPLPRO_HIDDEN_SYM __attribute__ ((visibility("hidden")))
38
+ #else
39
+ # define TMPLPRO_EXPORT_SYM
40
+ # define TMPLPRO_HIDDEN_SYM
41
+ #endif
42
+
43
+ #ifndef APICALL
44
+ #define APICALL
45
+ #endif
46
+ #ifndef BACKCALL
47
+ #define BACKCALL
48
+ #endif
49
+
50
+ #define TMPLPRO_API TMPLPRO_EXTERN_C TMPLPRO_EXPORT_SYM
51
+ #define API_IMPL TMPLPRO_EXPORT_SYM
52
+ #define TMPLPRO_LOCAL TMPLPRO_HIDDEN_SYM
53
+
54
+ #endif /* pabidecl.h */
@@ -0,0 +1,426 @@
1
+ /*! \file pabstract.h
2
+ \brief description of callbacks.
3
+
4
+ In order to interact with core library a wrapper should provide
5
+ some callback functions.
6
+ This file specifies which callbacks can be provided.
7
+
8
+ \author Igor Vlasenko <vlasenko@imath.kiev.ua>
9
+ \warning This header file should never be included directly.
10
+ Include <tmplpro.h> instead.
11
+ */
12
+
13
+ #ifndef _PROABSTRACT_H
14
+ #define _PROABSTRACT_H 1
15
+
16
+ #include "pstring.h"
17
+ #include "pabidecl.h"
18
+
19
+ struct tmplpro_param;
20
+ struct exprval;
21
+
22
+ typedef void ABSTRACT_WRITER;
23
+ typedef void ABSTRACT_FINDFILE;
24
+ typedef void ABSTRACT_FILTER;
25
+ typedef void ABSTRACT_CALLER;
26
+ typedef void ABSTRACT_DATASTATE;
27
+
28
+ typedef void ABSTRACT_ARRAY;
29
+ typedef void ABSTRACT_MAP;
30
+ typedef void ABSTRACT_VALUE;
31
+
32
+ typedef void ABSTRACT_FUNCMAP;
33
+ typedef void ABSTRACT_ARGLIST;
34
+ typedef void ABSTRACT_USERFUNC;
35
+ typedef struct exprval ABSTRACT_EXPRVAL;
36
+
37
+
38
+ typedef void BACKCALL (*writer_functype) (ABSTRACT_WRITER*,const char* begin, const char* endnext);
39
+
40
+ typedef ABSTRACT_VALUE* BACKCALL (*get_ABSTRACT_VALUE_functype) (ABSTRACT_DATASTATE*, ABSTRACT_MAP*, PSTRING name);
41
+ typedef PSTRING BACKCALL (*ABSTRACT_VALUE2PSTRING_functype) (ABSTRACT_DATASTATE*, ABSTRACT_VALUE*);
42
+ /* optional */
43
+ typedef int BACKCALL (*is_ABSTRACT_VALUE_true_functype) (ABSTRACT_DATASTATE*, ABSTRACT_VALUE*);
44
+
45
+ typedef ABSTRACT_ARRAY* BACKCALL (*ABSTRACT_VALUE2ABSTRACT_ARRAY_functype) (ABSTRACT_DATASTATE*, ABSTRACT_VALUE*);
46
+ typedef int BACKCALL (*get_ABSTRACT_ARRAY_length_functype) (ABSTRACT_DATASTATE*, ABSTRACT_ARRAY*);
47
+ typedef ABSTRACT_MAP* BACKCALL (*get_ABSTRACT_MAP_functype) (ABSTRACT_DATASTATE*, ABSTRACT_ARRAY*,int);
48
+
49
+ /* optional notifier */
50
+ typedef void BACKCALL (*exit_loop_scope_functype) (ABSTRACT_DATASTATE*, ABSTRACT_ARRAY*);
51
+
52
+ typedef const char* BACKCALL (*find_file_functype) (ABSTRACT_FINDFILE*, const char* filename, const char* prevfilename);
53
+
54
+ /* optional; we can use wrapper to load file and apply its filters before running itself */
55
+ /* note that this function should allocate region 1 byte nore than the file size */
56
+ typedef PSTRING BACKCALL (*load_file_functype) (ABSTRACT_FILTER*, const char* filename);
57
+ typedef int BACKCALL (*unload_file_functype) (ABSTRACT_FILTER*, PSTRING memarea);
58
+
59
+ #define HTML_TEMPLATE_OPT_ESCAPE_NO 0
60
+ #define HTML_TEMPLATE_OPT_ESCAPE_HTML 1
61
+ #define HTML_TEMPLATE_OPT_ESCAPE_URL 2
62
+ #define HTML_TEMPLATE_OPT_ESCAPE_JS 3
63
+
64
+ /* -------- Expr extension------------ */
65
+
66
+ /* those are needed for EXPR= extension */
67
+ typedef ABSTRACT_USERFUNC* BACKCALL (*is_expr_userfnc_functype) (ABSTRACT_FUNCMAP*, PSTRING name);
68
+ typedef ABSTRACT_ARGLIST* BACKCALL (*init_expr_arglist_functype) (ABSTRACT_CALLER*);
69
+ typedef void BACKCALL (*push_expr_arglist_functype) (ABSTRACT_ARGLIST*, ABSTRACT_EXPRVAL*);
70
+ typedef void BACKCALL (*free_expr_arglist_functype) (ABSTRACT_ARGLIST*);
71
+ typedef void BACKCALL (*call_expr_userfnc_functype) (ABSTRACT_CALLER*, ABSTRACT_ARGLIST*, ABSTRACT_USERFUNC*, ABSTRACT_EXPRVAL*);
72
+
73
+ /* ------- end Expr extension -------- */
74
+
75
+ #endif /* _PROABSTRACT_H */
76
+
77
+ /** \typedef typedef void (*writer_functype) (ABSTRACT_WRITER*,const char* begin, const char* endnext);
78
+
79
+ \brief optional callback for writing or accumulating a piece of generated text.
80
+
81
+ \param begin, endnext - pointers to memory area containing the output string.
82
+ \param ABSTRACT_WRITER* - pointer stored by tmplpro_set_option_ext_writer_state() or NULL if nothing was stored.
83
+
84
+ Note that outpot string is NOT 0-terminated. Instead, 2 pointers are used, as in PSTRING.
85
+ This callback is called multiple times.
86
+ This callback is optional: if not provided, a built-in stub will output to STDOUT.
87
+
88
+ @see tmplpro_set_option_WriterFuncPtr
89
+ @see tmplpro_set_option_ext_writer_state
90
+ */
91
+
92
+ /** \typedef typedef ABSTRACT_VALUE* (*get_ABSTRACT_VALUE_functype) (ABSTRACT_MAP*, PSTRING name);
93
+ \brief required callback to get a variable value.
94
+
95
+ \param PSTRING name - a name as in &lt;TMPL_VAR NAME="var1"&gt;
96
+ \param ABSTRACT_MAP* pointer returned by callback of get_ABSTRACT_MAP_functype.
97
+ \return NULL if NAME not found or a non-null pointer to be passed to callback
98
+ of ABSTRACT_VALUE2PSTRING_functype or ABSTRACT_VALUE2ABSTRACT_ARRAY_functype.
99
+ @see tmplpro_set_option_GetAbstractValFuncPtr
100
+ */
101
+
102
+ /** \typedef typedef PSTRING (*ABSTRACT_VALUE2PSTRING_functype) (ABSTRACT_VALUE*);
103
+ \brief required callback to transform into PSTRING a variable name passed to callback of get_ABSTRACT_VALUE_functype.
104
+
105
+ \param ABSTRACT_VALUE* optional pointer returned by callback of get_ABSTRACT_VALUE_functype.
106
+ \return PSTRING to a memory area. The memery area can be safely freed in the next call
107
+ to ABSTRACT_VALUE2PSTRING_functype.
108
+
109
+ @see tmplpro_set_option_AbstractVal2pstringFuncPtr
110
+ */
111
+
112
+ /** \typedef typedef int (*is_ABSTRACT_VALUE_true_functype) (ABSTRACT_VALUE*);
113
+ \brief optional callback to fine-tune is ABSTRACT_VALUE* is true or false.
114
+
115
+ \param ABSTRACT_VALUE* optional pointer returned by callback of get_ABSTRACT_VALUE_functype.
116
+ \return 0(false) or 1(true).
117
+
118
+ By default a stub is used that guesses true or false according to PSTRING form of ABSTRACT_VALUE.
119
+
120
+ @see tmplpro_set_option_IsAbstractValTrueFuncPtr
121
+ */
122
+
123
+ /** \typedef typedef ABSTRACT_ARRAY* (*ABSTRACT_VALUE2ABSTRACT_ARRAY_functype) (ABSTRACT_VALUE*);
124
+ \brief required callback to transform into ABSTRACT_ARRAY a variable name passed to callback of get_ABSTRACT_VALUE_functype.
125
+
126
+ \param ABSTRACT_VALUE* optional pointer returned by callback of get_ABSTRACT_VALUE_functype.
127
+ \return NULL if NAME can not be converted to ABSTRACT_ARRAY or a non-null pointer that will be passed
128
+ then to callbacks of get_ABSTRACT_ARRAY_length_functype and get_ABSTRACT_MAP_functype.
129
+
130
+ @see tmplpro_set_option_AbstractVal2abstractArrayFuncPtr
131
+ */
132
+
133
+ /** \typedef typedef int (*get_ABSTRACT_ARRAY_length_functype) (ABSTRACT_ARRAY*);
134
+ \brief optional callback to specify a length of the loop.
135
+
136
+ \param ABSTRACT_ARRAY* optional pointer returned by callback of ABSTRACT_VALUE2ABSTRACT_ARRAY_functype.
137
+ \return the length of the loop or a special value of -1 that indicates that loop has an undefined length
138
+ (useful when one need to iterate over large number of records in database or lines in a file).
139
+
140
+ By default a stub is used that returns -1.
141
+
142
+ @see tmplpro_set_option_GetAbstractArrayLengthFuncPtr
143
+ */
144
+
145
+ /** \typedef typedef ABSTRACT_MAP* (*get_ABSTRACT_MAP_functype) (ABSTRACT_ARRAY*,int n);
146
+ \brief required callback to transform into ABSTRACT_ARRAY a variable name passed to callback of get_ABSTRACT_VALUE_functype.
147
+
148
+ \param ABSTRACT_ARRAY* optional pointer returned by callback of ABSTRACT_VALUE2ABSTRACT_ARRAY_functype.
149
+ \param n - number of current loop iteration.
150
+ \return NULL if loop can no nore be iterated or a non-null pointer that will be passed
151
+ to callback of get_ABSTRACT_VALUE_functype.
152
+
153
+ @see tmplpro_set_option_GetAbstractMapFuncPtr
154
+ */
155
+
156
+ /** \typedef typedef void (*end_loop_functype) (ABSTRACT_MAP* root_param_map, int newlevel);
157
+ \brief optional callback to notify a front-end that the current loop is exited.
158
+
159
+ \param ABSTRACT_MAP* optional pointer stored by tmplpro_set_option_root_param_map().
160
+ \param newlevel current depth of nested loops (0 means a root scope).
161
+
162
+ This callback is useful for front-end implementations which does not return pointers
163
+ to real objects. In that case the corresponding ABSTRACT_MAP*, ABSTRACT_ARRAY*, and ABSTRACT_VALUE*
164
+ pointers are fake non-null values, so instead of those pointers this callback can be used.
165
+
166
+ @see tmplpro_set_option_EndLoopFuncPtr
167
+ */
168
+
169
+ /** \typedef typedef void (*select_loop_scope_functype) (ABSTRACT_MAP* root_param_map, int level);
170
+ \brief optional callback to select a loop.
171
+
172
+ \param ABSTRACT_MAP* optional pointer stored by tmplpro_set_option_root_param_map().
173
+ \param int level level at which a loop will be selected.
174
+
175
+ This callback is useful for front-end implementations which does not return pointers
176
+ to real objects. In that case the corresponding ABSTRACT_MAP*, ABSTRACT_ARRAY*, and ABSTRACT_VALUE*
177
+ pointers are fake non-null values, so instead of those pointers this callback can be used.
178
+
179
+ @see tmplpro_set_option_SelectLoopScopeFuncPtr
180
+ */
181
+
182
+ /** \typedef typedef const char* (*find_file_functype) (ABSTRACT_FINDFILE*, const char* filename, const char* prevfilename);
183
+ \brief optional callback to fine-tune the algorythm of finding template file by name.
184
+
185
+ \param ABSTRACT_FINDFILE* optional pointer stored by tmplpro_set_option_ext_writer_state().
186
+ \param filename file to be found.
187
+ \param prevfilename fully qualified path to containing file, if any.
188
+ \return fully qualified path to a file to be loaded.
189
+
190
+ By default a stub is used (as of 0.82, with limited functionality).
191
+
192
+ @see tmplpro_set_option_FindFileFuncPtr
193
+ */
194
+
195
+ /** \typedef typedef PSTRING (*load_file_functype) (ABSTRACT_FILTER*, const char* filename);
196
+ \brief optional callback to load and preprocess (filter) files.
197
+
198
+ Only called if filters option is true (set by tmplpro_set_option_filters() ).
199
+
200
+ \param ABSTRACT_FILTER* optional pointer stored by tmplpro_set_option_ext_filter_state().
201
+ \param filename fully qualified path to a file to be loaded
202
+ (as returned by callback of find_file_functype).
203
+ \return PSTRING of memory area loaded.
204
+
205
+ @see tmplpro_set_option_filters
206
+ @see tmplpro_set_option_LoadFileFuncPtr
207
+ */
208
+
209
+ /** \typedef typedef int (*unload_file_functype) (ABSTRACT_FILTER*, PSTRING memarea);
210
+ \brief optional callback to free memory accuired by a callback of load_file_functype.
211
+
212
+ Only called if filters option is true (set by tmplpro_set_option_filters() ).
213
+
214
+ \param ABSTRACT_FILTER* optional pointer stored by tmplpro_set_option_ext_filter_state().
215
+ \param memarea pointers to loaded area
216
+ (as returned by callback of load_file_functype).
217
+ \return 0 on success, non-zero otherwise.
218
+
219
+ @see tmplpro_set_option_filters
220
+ @see tmplpro_set_option_UnloadFileFuncPtr
221
+ */
222
+
223
+ /** \typedef typedef ABSTRACT_USERFUNC* (*is_expr_userfnc_functype) (ABSTRACT_FUNCMAP*, PSTRING name);
224
+ \brief optional callback for support of user-provided functions.
225
+
226
+ \param ABSTRACT_FUNCMAP* optional pointer stored by tmplpro_set_option_expr_func_map().
227
+ \param name name of function
228
+ \return NULL if there is no user function with such a name or non-null value to be passed
229
+ to callback of call_expr_userfnc_functype.
230
+
231
+ \warning if is_expr_userfnc_functype callback is set, then callbacks of
232
+ init_expr_arglist_functype, push_expr_arglist_functype, free_expr_arglist_functype
233
+ and call_expr_userfnc_functype also should be set.
234
+
235
+ @see tmplpro_set_option_IsExprUserfncFuncPtr
236
+ */
237
+
238
+ /** \typedef typedef ABSTRACT_ARGLIST* (*init_expr_arglist_functype) (ABSTRACT_CALLER*);
239
+ \brief optional callback to initialize the list of arguments for a user-provided function.
240
+
241
+ Note that if function calls are nested, then the calls to a callbacks of
242
+ ::init_expr_arglist_functype, ::push_expr_arglist_functype, ::free_expr_arglist_functype
243
+ will also be nested.
244
+
245
+ \param ABSTRACT_CALLER* optional pointer stored by tmplpro_set_option_ext_calluserfunc_state().
246
+ \return value to be passed to callbacks of push_expr_arglist_functype,
247
+ free_expr_arglist_functype and call_expr_userfnc_functype.
248
+
249
+ @see tmplpro_set_option_InitExprArglistFuncPtr
250
+ */
251
+
252
+ /** \typedef typedef void (*free_expr_arglist_functype) (ABSTRACT_ARGLIST*);
253
+ \brief optional callback to release the list of arguments for a user-provided function.
254
+
255
+ Note that if function calls are nested, then the calls to a callbacks of
256
+ ::init_expr_arglist_functype, ::push_expr_arglist_functype, ::free_expr_arglist_functype
257
+ will also be nested.
258
+
259
+ \param ABSTRACT_ARGLIST* optional pointer returned by callback of init_expr_arglist_functype.
260
+
261
+ @see tmplpro_set_option_FreeExprArglistFuncPtr
262
+ */
263
+
264
+ /** \typedef typedef void (*push_expr_arglist_functype) (ABSTRACT_ARGLIST*, ABSTRACT_EXPRVAL*);
265
+ \brief optional callback to add new value to the list of arguments for a user-provided function.
266
+
267
+ Note that if function calls are nested, then the calls to a callbacks of
268
+ ::init_expr_arglist_functype, ::push_expr_arglist_functype, ::free_expr_arglist_functype
269
+ will also be nested.
270
+
271
+ \param ABSTRACT_ARGLIST* optional pointer returned by callback of init_expr_arglist_functype.
272
+ \param ABSTRACT_EXPRVAL* pointer required by tmplpro_get_expr_* functions to retrieve the value
273
+ (a place the pushed value is stored).
274
+
275
+ A value to be added to the list of arguments for a user-provided function is not passed
276
+ as argument to a callback of push_expr_arglist_functype. Instead, a pointer to
277
+ struct tmplpro_param is passed, and the callback function should discover the value's type
278
+ using tmplpro_get_expr_type() function, and then should retrieve the value
279
+ using one of the functions
280
+ \li tmplpro_get_expr_as_int64()
281
+ \li tmplpro_get_expr_as_double()
282
+ \li tmplpro_get_expr_as_pstring()
283
+
284
+ @see tmplpro_set_option_PushExprArglistFuncPtr
285
+ */
286
+
287
+ /** \typedef typedef void (*call_expr_userfnc_functype) (ABSTRACT_CALLER*, ABSTRACT_ARGLIST*, ABSTRACT_USERFUNC*, ABSTRACT_EXPRVAL*);
288
+
289
+ \brief optional callback to call a user-provided function with a current list of arguments.
290
+
291
+ \param ABSTRACT_CALLER* optional pointer stored by tmplpro_set_option_ext_calluserfunc_state().
292
+ \param ABSTRACT_ARGLIST* optional pointer returned by callback of init_expr_arglist_functype.
293
+ \param ABSTRACT_USERFUNC* optional pointer returned by callback of is_expr_userfnc_functype.
294
+ \param ABSTRACT_EXPRVAL* pointer required by tmplpro_set_expr_as_* functions
295
+ (a place the return value will be stored).
296
+
297
+ To return the result user function returned the callback of call_expr_userfnc_functype should
298
+ call one of the functions
299
+ \li tmplpro_set_expr_as_null()
300
+ \li tmplpro_set_expr_as_int64()
301
+ \li tmplpro_set_expr_as_double()
302
+ \li tmplpro_set_expr_as_string()
303
+ \li tmplpro_set_expr_as_pstring()
304
+ passing them the ABSTRACT_EXPRVAL* as argument.
305
+
306
+ @see tmplpro_set_option_CallExprUserfncFuncPtr
307
+ */
308
+
309
+ /** \typedef typedef void ABSTRACT_WRITER
310
+
311
+ \brief optional pointer to be passed to a callback of ::writer_functype.
312
+
313
+ Optional pointer to store internal state for a callback of ::writer_functype.
314
+ If used, it should be stored beforehand with tmplpro_set_option_ext_writer_state().
315
+ @see tmplpro_set_option_ext_writer_state
316
+ */
317
+
318
+ /** \typedef typedef void ABSTRACT_FINDFILE
319
+
320
+ \brief optional pointer to be passed to a callback of ::find_file_functype.
321
+
322
+ Optional pointer to store internal state for a callback of ::find_file_functype.
323
+ If used, it should be stored beforehand with tmplpro_set_option_ext_findfile_state().
324
+ @see tmplpro_set_option_ext_findfile_state
325
+ */
326
+
327
+ /** \typedef typedef void ABSTRACT_FILTER
328
+
329
+ \brief optional pointer to be passed to a callback of ::load_file_functype / ::unload_file_functype.
330
+
331
+ Optional pointer to store internal state for a callback of ::load_file_functype / ::unload_file_functype.
332
+ If used, it should be stored beforehand with tmplpro_set_option_ext_filter_state().
333
+ @see tmplpro_set_option_ext_filter_state
334
+ */
335
+
336
+ /** \typedef typedef void ABSTRACT_CALLER
337
+
338
+ \brief optional pointer to be passed to a callback of ::call_expr_userfnc_functype.
339
+
340
+ Optional pointer to store internal state for a callback of ::call_expr_userfnc_functype.
341
+ If used, it should be stored beforehand with tmplpro_set_option_ext_calluserfunc_state().
342
+ @see tmplpro_set_option_ext_calluserfunc_state
343
+ */
344
+
345
+ /** \typedef typedef void ABSTRACT_DATASTATE
346
+
347
+ \brief optional pointer to be passed to data manipulation callbacks of
348
+ ::get_ABSTRACT_VALUE_functype, ::ABSTRACT_VALUE2ABSTRACT_ARRAY_functype,
349
+ ::get_ABSTRACT_ARRAY_length_functype, ::is_ABSTRACT_VALUE_true_functype,
350
+ ::get_ABSTRACT_MAP_functype, exit_loop_scope_functype.
351
+
352
+ Optional pointer to store internal state for a callback of
353
+ ::get_ABSTRACT_VALUE_functype, ::ABSTRACT_VALUE2ABSTRACT_ARRAY_functype,
354
+ ::get_ABSTRACT_ARRAY_length_functype, ::is_ABSTRACT_VALUE_true_functype,
355
+ ::get_ABSTRACT_MAP_functype, exit_loop_scope_functype.
356
+ If used, it should be stored beforehand with tmplpro_set_option_ext_data_state().
357
+ @see tmplpro_set_option_ext_data_state
358
+ */
359
+
360
+
361
+ /** \typedef typedef void ABSTRACT_ARRAY
362
+
363
+ \brief optional pointer representing a loop.
364
+
365
+ It is returned from a callback of ::ABSTRACT_VALUE2ABSTRACT_ARRAY_functype
366
+ and is passed to callbacks of ::get_ABSTRACT_ARRAY_length_functype
367
+ and ::get_ABSTRACT_MAP_functype.
368
+ */
369
+
370
+ /** \typedef typedef void ABSTRACT_MAP
371
+
372
+ \brief optional pointer representing a root scope or a loop scope.
373
+
374
+ Pointer for the loop scope is returned from a callback of ::get_ABSTRACT_MAP_functype.
375
+ Pointer of the root scope should be stored beforehead using tmplpro_set_option_root_param_map().
376
+ Both types of pointers are passed to callback of ::get_ABSTRACT_VALUE_functype.
377
+ Also, root scope pointer is passed to callbacks of ::end_loop_functype and
378
+ ::select_loop_scope_functype.
379
+ @see tmplpro_set_option_root_param_map
380
+ */
381
+
382
+ /** \typedef typedef void ABSTRACT_VALUE
383
+
384
+ \brief optional pointer representing an abstract value that can be converted to a sting or loop.
385
+
386
+ It is returned from callback of ::get_ABSTRACT_VALUE_functype and passed to
387
+ callbacks of ::ABSTRACT_VALUE2ABSTRACT_ARRAY_functype and ::ABSTRACT_VALUE2PSTRING_functype.
388
+ */
389
+
390
+ /** \typedef typedef void ABSTRACT_FUNCMAP
391
+
392
+ \brief optional pointer to be passed to a callback of ::is_expr_userfnc_functype.
393
+
394
+ If used, it should be stored beforehand with tmplpro_set_option_expr_func_map().
395
+ @see tmplpro_set_option_expr_func_map
396
+ */
397
+
398
+ /** \typedef typedef void ABSTRACT_ARGLIST
399
+
400
+ \brief optional pointer representing a list accumulating arguments to user function call.
401
+
402
+ It is returned from a callback of ::init_expr_arglist_functype
403
+ and is passed to callbacks of ::push_expr_arglist_functype, ::call_expr_userfnc_functype
404
+ and ::free_expr_arglist_functype.
405
+ */
406
+
407
+ /** \typedef typedef void ABSTRACT_USERFUNC
408
+
409
+ \brief optional pointer representing user function.
410
+
411
+ It is returned from a callback of ::is_expr_userfnc_functype
412
+ and is passed to callback of ::call_expr_userfnc_functype.
413
+ */
414
+
415
+ /** \typedef typedef void ABSTRACT_EXPRVAL
416
+
417
+ \brief optional pointer representing user function argument or return value.
418
+
419
+ It is passed to callbacks of ::push_expr_arglist_functype and ::call_expr_userfnc_functype.
420
+ */
421
+
422
+ /*
423
+ * Local Variables:
424
+ * mode: c
425
+ * End:
426
+ */