Codebase list libhtml-template-pro-perl / 4e077a5
[svn-upgrade] Integrating new upstream version, libhtml-template-pro-perl (0.92) Jonathan Yu 14 years ago
19 changed file(s) with 83 addition(s) and 54 deletion(s). Raw diff Collapse all Expand all
4141 parse_expr.h
4242 pbuffer.c
4343 pbuffer.h
44 pconst.h
4445 perl-HTML-Template-Pro.spec
4546 pmiscdef.h
4647 pparam.h
00 --- #YAML:1.0
11 name: HTML-Template-Pro
2 version: 0.91
2 version: 0.92
33 abstract: Perl/XS module to use HTML Templates from CGI scripts
44 license: perl or LGPL2+
55 author:
2424 }
2525
2626 my %DEF=(
27 MAINTAINER => $^O eq 'linux' && -d '.git' ? 1 : 0,
2728 PCRE => 1,
2829 DEBUG => 0,
2930 MMAP => 1,
7778 );
7879
7980 sub MY::postamble {
81 return '' unless $DEF{MAINTAINER};
8082 return <<'MAKE_FRAG';
8183 expr.c: calc.inc exprtool.inc exprpstr.inc
8284 procore\$(OBJ_EXT): loadfile.inc tagstack.inc
0 HTML-Template-Pro version 0.91
0 HTML-Template-Pro version 0.92
11 ==============================
22
33 DESCRIPTION
168168 }
169169 /* old prev_slash_next now current, so we need to recalculate it */
170170 /* first find a 'slash' char */
171 while (!IS_FILE_SEP(*prev_slash_next) && prev_slash_next>=slash_begin) prev_slash_next--;
171 while (prev_slash_next>=slash_begin && !IS_FILE_SEP(*prev_slash_next)) prev_slash_next--;
172172 if (prev_slash_next>slash_begin) prev_slash_next++;/* step next to slash */
173173 } else {
174174 prev_slash_next=pos+1;
22 #include "pabidecl.h"
33 #include "pabstract.h"
44 #include "pparam.h"
5 #include "procore.h"
5 #include "pconst.h"
66
77 API_IMPL
88 int
00 #include "pabidecl.h"
11 #include "pabstract.h"
22 #include "pparam.h"
3 #include "procore.h"
3 #include "pconst.h"
44
55 API_IMPL
66 int
00 #include "pabidecl.h"
11 #include "pabstract.h"
22 #include "pparam.h"
3 #include "procore.h"
3 #include "pconst.h"
44
55 API_IMPL
66 int
1111 use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS);
1212 @ISA = qw(DynaLoader Exporter);
1313
14 $VERSION = '0.91';
14 $VERSION = '0.92';
1515
1616 @EXPORT_OK = qw/ASK_NAME_DEFAULT ASK_NAME_AS_IS ASK_NAME_LOWERCASE ASK_NAME_UPPERCASE ASK_NAME_MASK/;
1717 %EXPORT_TAGS = (const => [qw/ASK_NAME_DEFAULT ASK_NAME_AS_IS ASK_NAME_LOWERCASE ASK_NAME_UPPERCASE ASK_NAME_MASK/]);
0 #ifndef _PCONST_H
1 #define _PCONST_H 1
2
3 /* internal constants */
4
5 #define ERR_PRO_INVALID_ARGUMENT 1
6 #define ERR_PRO_FILE_NOT_FOUND 2
7 #define ERR_PRO_CANT_OPEN_FILE 3
8 #define ERR_PRO_TEMPLATE_SYNTAX_ERROR 4
9
10 #endif /* pconst.h */
11
12 /*
13 * Local Variables:
14 * mode: c
15 * End:
16 */
55 %define module HTML-Template-Pro
66
77 Name: perl-%module
8 Version: 0.91
8 Version: 0.92
99 Release: alt1
1010
1111 Packager: Igor Yu. Vlasenko <viy@altlinux.org>
5353 %perl_vendor_man3dir/*
5454
5555 %changelog
56 * Tue Sep 29 2009 Igor Vlasenko <viy@altlinux.ru> 0.92-alt1
57 - new version; see Changes
58
5659 * Tue Sep 22 2009 Igor Vlasenko <viy@altlinux.ru> 0.91-alt1
5760 - new version; see Changes
5861
2121 # define MOD_TD "%ld"
2222 #endif
2323
24 #if ! HAVE_STRDUP && ! defined strdup
25 # if HAVE__STRDUP
24 #if ! defined HAVE_STRDUP && ! defined strdup
25 # if defined HAVE__STRDUP
2626 # define strdup _strdup
2727 # else
2828 # define strdup(str) strcpy(malloc(strlen(str) + 1), str)
33 #include <ctype.h>
44
55 #include "tmplpro.h"
6 #include "pconst.h"
67 #include "procore.h"
78 #include "prostate.h"
89 #include "provalue.h"
8384 { 0, 0, 0, 0, 0, 0 }, /**/
8485 };
8586
86 /* max offset to ensure we are not out of file when try <!--/ */
87 #define TAG_WIDTH_OFFSET 4
87 typedef void (*tag_handler_func)(struct tmplpro_state *state, const PSTRING* const TagOptVal);
88
89 static const tag_handler_func const output_closetag_handler[]={
90 tag_handler_unknown, /*Bad or unsupported tag*/
91 tag_handler_unknown, /*VAR*/
92 tag_handler_unknown, /*INCLUDE*/
93 tag_handler_closeloop, /*LOOP*/
94 tag_handler_closeif, /*IF*/
95 tag_handler_unknown, /*ELSE*/
96 tag_handler_closeunless, /*UNLESS*/
97 tag_handler_unknown, /*ELSIF*/
98 tag_handler_unknown, /**/
99 };
100 static const tag_handler_func const output_opentag_handler[]={
101 tag_handler_unknown, /*Bad or unsupported tag*/
102 tag_handler_var, /*VAR*/
103 tag_handler_include, /*INCLUDE*/
104 tag_handler_loop, /*LOOP*/
105 tag_handler_if, /*IF*/
106 tag_handler_else, /*ELSE*/
107 tag_handler_unless, /*UNLESS*/
108 tag_handler_elsif, /*ELSIF*/
109 tag_handler_unknown, /**/
110 };
88111
89112 static
90113 int
320343 (state->param->WriterFuncPtr)(state->param->ext_writer_state,state->last_processed_pos,state->tag_start);
321344 state->last_processed_pos=state->cur_pos;
322345 }
323 /* TODO: call tag_specific handler by array of handlers
324 var_tag_handler(..) */
325346 if (is_tag_closed) {
326 switch (tag_type) {
327 case HTML_TEMPLATE_TAG_IF: tag_handler_closeif(state);break;
328 case HTML_TEMPLATE_TAG_UNLESS: tag_handler_closeunless(state);break;
329 case HTML_TEMPLATE_TAG_LOOP: tag_handler_closeloop(state);break;
330 default: tag_handler_unknown(state);break;
331 }
347 output_closetag_handler[tag_type](state,TagOptVal);
332348 } else {
333 switch (tag_type) {
334 case HTML_TEMPLATE_TAG_VAR: tag_handler_var(state,TagOptVal); break;
335 case HTML_TEMPLATE_TAG_IF: tag_handler_if(state,TagOptVal); break;
336 case HTML_TEMPLATE_TAG_UNLESS: tag_handler_unless(state,TagOptVal); break;
337 case HTML_TEMPLATE_TAG_ELSE: tag_handler_else(state,TagOptVal); break;
338 case HTML_TEMPLATE_TAG_ELSIF: tag_handler_elsif(state,TagOptVal); break;
339 case HTML_TEMPLATE_TAG_LOOP: tag_handler_loop(state,TagOptVal); break;
340 case HTML_TEMPLATE_TAG_INCLUDE: tag_handler_include(state,TagOptVal);break;
341 default: tag_handler_unknown(state);break;
342 }
343 }
344 }
345
349 output_opentag_handler[tag_type](state,TagOptVal);
350 }
351 }
352
353
354 /* max offset to ensure we are not out of file when try <!--/ */
355 #define TAG_WIDTH_OFFSET 4
346356 static
347357 void
348358 process_state (struct tmplpro_state * state)
0 #define ERR_PRO_INVALID_ARGUMENT 1
1 #define ERR_PRO_FILE_NOT_FOUND 2
2 #define ERR_PRO_CANT_OPEN_FILE 3
3 #define ERR_PRO_TEMPLATE_SYNTAX_ERROR 4
4
50 #include "pstring.h"
61 #include "tmpllog.h"
72 #include "pabstract.h"
7070 } else return 1;
7171 }
7272
73 #define MAX_ESCAPE_SEQ sizeof("&quot;")
7374 static
7475 PSTRING
7576 htmlencode_pstring (pbuffer* StrBuffer, PSTRING pstring) {
76 char* buf=pbuffer_resize(StrBuffer, pstring.endnext-pstring.begin+1);
77 char* buf=pbuffer_resize(StrBuffer, pstring.endnext-pstring.begin+1+MAX_ESCAPE_SEQ);
7778 const char* curpos=pstring.begin;
7879 size_t offset=0;
7980 size_t buflen=pbuffer_size(StrBuffer);
8182 while (curpos<pstring.endnext) {
8283 unsigned char curchar=*curpos++;
8384 int bufdelta=1;
84 if (offset>=buflen) {
85 buf=pbuffer_resize(StrBuffer, 2*offset);
85 if (offset>=buflen-MAX_ESCAPE_SEQ) {
86 buf=pbuffer_resize(StrBuffer, 2*(offset+MAX_ESCAPE_SEQ));
8687 buflen=pbuffer_size(StrBuffer);
8788 }
8889 switch (curchar) {
104105 static
105106 PSTRING
106107 jsencode_pstring (pbuffer* StrBuffer, PSTRING pstring) {
107 char* buf=pbuffer_resize(StrBuffer, pstring.endnext-pstring.begin+1);
108 char* buf=pbuffer_resize(StrBuffer, pstring.endnext-pstring.begin+1+MAX_ESCAPE_SEQ);
108109 const char* curpos=pstring.begin;
109110 size_t offset=0;
110111 size_t buflen=pbuffer_size(StrBuffer);
112113 while (curpos<pstring.endnext) {
113114 unsigned char curchar=*curpos++;
114115 int bufdelta=1;
115 if (offset>=buflen) {
116 buf=pbuffer_resize(StrBuffer, 2*offset);
116 if (offset>=buflen-MAX_ESCAPE_SEQ) {
117 buf=pbuffer_resize(StrBuffer, 2*(offset+MAX_ESCAPE_SEQ));
117118 buflen=pbuffer_size(StrBuffer);
118119 }
119120 switch (curchar) {
134135 static
135136 PSTRING
136137 urlencode_pstring (pbuffer* StrBuffer, PSTRING pstring) {
137 char* buf=pbuffer_resize(StrBuffer, pstring.endnext-pstring.begin+1);
138 char* buf=pbuffer_resize(StrBuffer, pstring.endnext-pstring.begin+1+MAX_ESCAPE_SEQ);
138139 const char* curpos=pstring.begin;
139140 size_t offset=0;
140141 size_t buflen=pbuffer_size(StrBuffer);
142143 while (curpos<pstring.endnext) {
143144 unsigned char curchar=*curpos++;
144145 int bufdelta=1;
145 if (offset>=buflen) {
146 buf=pbuffer_resize(StrBuffer, 2*offset);
146 if (offset>=buflen-MAX_ESCAPE_SEQ) {
147 buf=pbuffer_resize(StrBuffer, 2*(offset+MAX_ESCAPE_SEQ));
147148 buflen=pbuffer_size(StrBuffer);
148149 }
149150 /*
22 #include "pabidecl.h"
33 #include "pabstract.h"
44 #include "pparam.h"
5 #include "procore.h"
5 #include "pconst.h"
66
77 API_IMPL
88 int
00 #include "pabidecl.h"
11 #include "pabstract.h"
22 #include "pparam.h"
3 #include "procore.h"
3 #include "pconst.h"
44
55 API_IMPL
66 int
00 #include "pabidecl.h"
11 #include "pabstract.h"
22 #include "pparam.h"
3 #include "procore.h"
3 #include "pconst.h"
44
55 API_IMPL
66 int
317317
318318 static
319319 void
320 tag_handler_closeif (struct tmplpro_state *state)
320 tag_handler_closeif (struct tmplpro_state *state, const PSTRING* const TagOptVal)
321321 {
322322 struct tagstack_entry iftag;
323323 if (! test_stack(HTML_TEMPLATE_TAG_IF)) {
331331
332332 static
333333 void
334 tag_handler_closeunless (struct tmplpro_state *state)
334 tag_handler_closeunless (struct tmplpro_state *state, const PSTRING* const TagOptVal)
335335 {
336336 struct tagstack_entry iftag;
337337 if (! test_stack(HTML_TEMPLATE_TAG_UNLESS)) {
467467
468468 static
469469 void
470 tag_handler_closeloop (struct tmplpro_state *state)
470 tag_handler_closeloop (struct tmplpro_state *state, const PSTRING* const TagOptVal)
471471 {
472472 struct tagstack_entry* iftag_ptr;
473473 if (! test_stack(HTML_TEMPLATE_TAG_LOOP)) {
491491
492492 static
493493 void
494 tag_handler_unknown (struct tmplpro_state *state)
494 tag_handler_unknown (struct tmplpro_state *state, const PSTRING* const TagOptVal)
495495 {
496496 log_state(state,TMPL_LOG_ERROR,"tag_handler_unknown: unknown tag\n");
497497 }