* option only changes the default.
*/
-module include_module;
enum xbithack {
xbithack_off, xbithack_on, xbithack_full
};
/* Sentinel value to store in subprocess_env for items that
* shouldn't be evaluated until/unless they're actually used
*/
-static char lazy_eval_sentinel;
+static const char lazy_eval_sentinel;
+#define LAZY_VALUE (&lazy_eval_sentinel)
/* XXX: could use ap_table_overlap here */
static void add_include_vars(request_rec *r, char *timefmt)
apr_table_t *e = r->subprocess_env;
char *t;
- apr_table_setn(e, "DATE_LOCAL", &lazy_eval_sentinel);
- apr_table_setn(e, "DATE_GMT", &lazy_eval_sentinel);
- apr_table_setn(e, "LAST_MODIFIED", &lazy_eval_sentinel);
+ apr_table_setn(e, "DATE_LOCAL", LAZY_VALUE);
+ apr_table_setn(e, "DATE_GMT", LAZY_VALUE);
+ apr_table_setn(e, "LAST_MODIFIED", LAZY_VALUE);
apr_table_setn(e, "DOCUMENT_URI", r->uri);
if (r->path_info && *r->path_info) {
apr_table_setn(e, "DOCUMENT_PATH_INFO", r->path_info);
}
- apr_table_setn(e, "USER_NAME", &lazy_eval_sentinel);
+ apr_table_setn(e, "USER_NAME", LAZY_VALUE);
if ((t = strrchr(r->filename, '/'))) {
apr_table_setn(e, "DOCUMENT_NAME", ++t);
}
return val;
}
+static const char *get_include_var(request_rec *r, const char *var)
+{
+ const char *val;
+ val = apr_table_get(r->subprocess_env, var);
+
+ if (val == LAZY_VALUE)
+ val = add_include_vars_lazy(r, var);
+
+ return val;
+}
+
/* --------------------------- Parser functions --------------------------- */
/* This function returns either a pointer to the split bucket containing the
if (l != 0) {
tmp_store = *end_of_var_name;
*end_of_var_name = '\0';
- val = apr_table_get(r->subprocess_env, start_of_var_name);
- if (val == &lazy_eval_sentinel) {
- val = add_include_vars_lazy(r, start_of_var_name);
- }
+ val = get_include_var(r, start_of_var_name);
*end_of_var_name = tmp_store;
if (val) {
}
}
if (!strcmp(tag, "var")) {
- const char *val = apr_table_get(r->subprocess_env, tag_val);
-
- if (val == &lazy_eval_sentinel) {
- val = add_include_vars_lazy(r, tag_val);
- }
+ const char *val = get_include_var(r, tag_val);
if (val) {
switch(encode) {
case E_NONE:
*inserted_head = NULL;
for (i = 0; i < arr->nelts; ++i) {
key_text = ap_escape_html(r->pool, elts[i].key);
- if (elts[i].val == &lazy_eval_sentinel) {
- val_text =
- ap_escape_html(r->pool,
- add_include_vars_lazy(r, elts[i].key));
- } else {
- val_text = ap_escape_html(r->pool, elts[i].val);
+ val_text = elts[i].val;
+ if (val_text == LAZY_VALUE) {
+ val_text = add_include_vars_lazy(r, elts[i].key);
}
+ val_text = ap_escape_html(r->pool, elts[i].val);
k_len = strlen(key_text);
v_len = strlen(val_text);