1 /* -*- c -*-
2  * File: pparam.h
3  * Author: Igor Vlasenko <vlasenko@imath.kiev.ua>
4  * Created: Thu Jul  9 20:05:37 2009
5  */
6 
7 #ifndef _PPARAM_H
8 #define _PPARAM_H	1
9 
10 #include "proscope.h"
11 #include "pbuffer.h"
12 #include "exprval.h" /* TODO: remove together with buffer */
13 
14 /* for wrappers; flag better always be int32 - useful for Mono */
15 #if HAVE_INTTYPES_H
16 # include <inttypes.h>
17    typedef int32_t flag;
18 #else
19 # if HAVE_STDINT_H
20 #  include <stdint.h>
21    typedef int32_t flag;
22 # else
23    typedef int flag;
24 # endif
25 #endif
26 
27 struct tmplpro_param {
28   int global_vars;
29   int max_includes; /*default:16 */
30   int debug;
31   int tmpl_var_case;
32   flag no_includes;
33   flag loop_context_vars;
34   flag strict;
35   /* filters --- indicates whether to use
36    * external file loader hook specified as LoadFileFuncPtr.
37    * Set it to 1 if you want to preprocess file with filters
38    * before they'll be processed by exec_tmpl */
39   flag filters;
40   int default_escape; /* one of HTML_TEMPLATE_OPT_ESCAPE_* */
41   const char* filename; /* template file */
42   PSTRING scalarref; /* memory area */
43   flag path_like_variable_scope;
44   flag search_path_on_include;
45   char** path;
46   char* template_root;
47   /* flag vanguard_compatibility_mode; */
48 
49   /* hooks to perl or other container */
50   /* HTML::Template callback hooks */
51   writer_functype WriterFuncPtr;
52   get_ABSTRACT_VALUE_functype GetAbstractValFuncPtr;
53   ABSTRACT_VALUE2PSTRING_functype AbstractVal2pstringFuncPtr;
54   ABSTRACT_VALUE2ABSTRACT_ARRAY_functype AbstractVal2abstractArrayFuncPtr;
55   get_ABSTRACT_ARRAY_length_functype GetAbstractArrayLengthFuncPtr;
56   get_ABSTRACT_MAP_functype GetAbstractMapFuncPtr;
57   /* user-supplied --- optional; we use it for full emulation of perl quirks */
58   is_ABSTRACT_VALUE_true_functype IsAbstractValTrueFuncPtr;
59   find_file_functype FindFileFuncPtr;
60   load_file_functype LoadFileFuncPtr;
61 unload_file_functype UnloadFileFuncPtr;
62   exit_loop_scope_functype ExitLoopScopeFuncPtr;
63   /* external state references to be supplied to callbacks */
64   ABSTRACT_WRITER* ext_writer_state;
65   ABSTRACT_FILTER* ext_filter_state;
66   ABSTRACT_FINDFILE* ext_findfile_state;
67   ABSTRACT_DATASTATE* ext_data_state;
68   ABSTRACT_CALLER* ext_calluserfunc_state;
69   /* HTML::Template::Expr hooks */
70   init_expr_arglist_functype InitExprArglistFuncPtr;
71   free_expr_arglist_functype FreeExprArglistFuncPtr;
72   /**
73      important note:
74      PushExprArglistFuncPtr should always copy the supplied pstring arg
75      as it could point to a temporary location.
76    */
77   push_expr_arglist_functype PushExprArglistFuncPtr;
78   call_expr_userfnc_functype CallExprUserfncFuncPtr;
79   is_expr_userfnc_functype   IsExprUserfncFuncPtr;
80   ABSTRACT_FUNCMAP*  expr_func_map;
81 
82   /* private */
83   /* flags to be declared */
84   /* TODO use in walk_through_nested_loops */
85   flag warn_unused;
86 
87   /* private */
88   int found_syntax_error;
89   int htp_errno;
90 
91   int cur_includes; /* internal counter of include depth */
92   const char* masterpath; /* file that has included this file, or NULL */
93 
94   /* variable scope (nested loops) passed to include */
95   struct scope_stack var_scope_stack;
96   int param_map_count; /* internal counter of pushed scope roots */
97 
98   /* private buffer of builtin tmpl2string */
99   pbuffer builtin_tmpl2string_buffer;
100   /* private buffer of builtin_findfile */
101   pbuffer builtin_findfile_buffer;
102   /* private buffer of write_chars_to_pbuffer */
103   pbuffer builtin_writer_buffer;
104   /* private buffers of walk_through_nested_loops */
105   PSTRING lowercase_varname;
106   pbuffer lowercase_varname_buffer;
107   PSTRING uppercase_varname;
108   pbuffer uppercase_varname_buffer;
109 
110   /* private buffer for escape_pstring */
111   pbuffer escape_pstring_buffer;
112   /* private buffer for get_loop_context_vars_value */
113   char loopvarbuf[20]; /* for snprintf %d */
114 };
115 
116 #endif /* _PPARAM_H */
117 
118 /*
119  *  Local Variables:
120  *  mode: c
121  *  End:
122  */
123