summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Kneschke <jan@kneschke.de>2005-07-07 22:39:14 +0000
committerJan Kneschke <jan@kneschke.de>2005-07-07 22:39:14 +0000
commit6d60bcb0400d5952719782cba88b0462adf4cc17 (patch)
tree1eed48bb2e8fe308a0fe58e24064f33218c8d9da /src
parent3c383fe3df48d091428095053c09720a150cc683 (diff)
downloadlighttpd-git-6d60bcb0400d5952719782cba88b0462adf4cc17.tar.gz
use log_* functions for debugging and don't segfault on evaluation
git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.3.x@428 152afb58-edef-0310-8abb-c4023f1b3aa9
Diffstat (limited to 'src')
-rw-r--r--src/mod_cml.c5
-rw-r--r--src/mod_cml.h4
-rw-r--r--src/mod_cml_funcs.c18
-rw-r--r--src/mod_cml_logic.c39
4 files changed, 46 insertions, 20 deletions
diff --git a/src/mod_cml.c b/src/mod_cml.c
index 0cdd9af2..acae66f6 100644
--- a/src/mod_cml.c
+++ b/src/mod_cml.c
@@ -30,6 +30,7 @@ INIT_FUNC(mod_cml_init) {
p->eval = buffer_array_init();
p->trigger_if = buffer_array_init();
p->output_include = buffer_array_init();
+ p->params = tnode_val_array_init();
return p;
}
@@ -54,6 +55,8 @@ FREE_FUNC(mod_cml_free) {
free(p->config_storage);
}
+ tnode_val_array_free(p->params);
+
buffer_array_free(p->eval);
buffer_array_free(p->trigger_if);
buffer_array_free(p->output_include);
@@ -289,6 +292,8 @@ URIHANDLER_FUNC(mod_cml_is_handled) {
buffer_reset(p->session_id);
buffer_reset(p->trigger_handler);
+ tnode_val_array_reset(p->params);
+
if (buffer_is_empty(p->conf.ext)) return HANDLER_GO_ON;
ct_len = p->conf.ext->used - 1;
diff --git a/src/mod_cml.h b/src/mod_cml.h
index b8031e37..2185e8dc 100644
--- a/src/mod_cml.h
+++ b/src/mod_cml.h
@@ -78,6 +78,10 @@ int cache_parse(server *srv, connection *con, plugin_data *p, buffer *fn);
int tnode_prepare_long(tnode *t);
int tnode_prepare_string(tnode *t);
+tnode_val_array *tnode_val_array_init();
+void tnode_val_array_free(tnode_val_array *tva);
+void tnode_val_array_reset(tnode_val_array *tva);
+
#define CACHE_FUNC_PROTO(x) int x(server *srv, connection *con, plugin_data *p, tnode *result)
CACHE_FUNC_PROTO(f_unix_time_now);
diff --git a/src/mod_cml_funcs.c b/src/mod_cml_funcs.c
index e8a8d955..9988975f 100644
--- a/src/mod_cml_funcs.c
+++ b/src/mod_cml_funcs.c
@@ -33,8 +33,9 @@ CACHE_FUNC_PROTO(f_file_mtime) {
UNUSED(con);
if (p->params->ptr[0]->type != T_NODE_VALUE_STRING) {
- fprintf(stderr, "%s.%d: f_file_mtime: I need a string: %d\n",
- __FILE__, __LINE__, p->params->ptr[0]->type);
+ log_error_write(srv, __FILE__, __LINE__, "sd",
+ "f_file_mtime: I need a string:",
+ p->params->ptr[0]->type);
return -1;
}
@@ -46,7 +47,8 @@ CACHE_FUNC_PROTO(f_file_mtime) {
buffer_append_string_buffer(b, p->params->ptr[0]->data.str);
if (-1 == stat(b->ptr, &st)) {
- log_error_write(srv, __FILE__, __LINE__, "sbs", "trigger.if file.mtime():", b, strerror(errno));
+ log_error_write(srv, __FILE__, __LINE__, "sbs",
+ "trigger.if file.mtime():", b, strerror(errno));
buffer_free(b);
return -1;
@@ -64,8 +66,9 @@ CACHE_FUNC_PROTO(f_mysql_escape) {
UNUSED(con);
if (p->params->ptr[0]->type != T_NODE_VALUE_STRING) {
- fprintf(stderr, "%s.%d: f_mysql_escape: I need a string: %d\n",
- __FILE__, __LINE__, p->params->ptr[0]->type);
+ log_error_write(srv, __FILE__, __LINE__, "sd",
+ "f_mysql_escape: I need a string:",
+ p->params->ptr[0]->type);
return -1;
}
@@ -81,8 +84,9 @@ CACHE_FUNC_PROTO(f_mysql_query) {
UNUSED(con);
if (p->params->ptr[0]->type != T_NODE_VALUE_STRING) {
- fprintf(stderr, "%s.%d: f_mysql_escape: I need a string: %d\n",
- __FILE__, __LINE__, p->params->ptr[0]->type);
+ log_error_write(srv, __FILE__, __LINE__, "sd",
+ "f_mysql_query: I need a string:",
+ p->params->ptr[0]->type);
return -1;
}
diff --git a/src/mod_cml_logic.c b/src/mod_cml_logic.c
index dd01694a..69594d4d 100644
--- a/src/mod_cml_logic.c
+++ b/src/mod_cml_logic.c
@@ -92,6 +92,19 @@ void tnode_val_array_free(tnode_val_array *tva) {
free(tva);
}
+void tnode_val_array_reset(tnode_val_array *tva) {
+ size_t i;
+
+ if (!tva) return;
+
+ for (i = 0; i < tva->used; i++) {
+ tnode_val_free(tva->ptr[i]);
+ }
+
+ tva->used = 0;
+}
+
+
tnode *tnode_init() {
tnode *t;
@@ -329,25 +342,25 @@ int cache_trigger_parse(server *srv, connection *con, plugin_data *p, buffer *t
/* parse parameters */
if (0 != cache_parse_parameters(srv, con, p, br_open + 1, t->used - slen - 3, p->params)) {
- fprintf(stderr, "%s.%d: parsing parameters failed\n",
- __FILE__, __LINE__
- );
+ log_error_write(srv, __FILE__, __LINE__, "s",
+ "parsing parameters failed");
+
return -1;
}
if (p->params->used != f[i].params) {
- fprintf(stderr, "%s.%d: wrong param-count for %s: %d, expected %d\n",
- __FILE__, __LINE__,
- f[i].name,
- p->params->used,
- f[i].params
- );
+ log_error_write(srv, __FILE__, __LINE__, "sssdsd",
+ "wrong param-count for", f[i].name,
+ "got", p->params->used,
+ "expected", f[i].params);
return -1;
}
if (0 != f[i].func(srv, con, p, n)) {
- fprintf(stderr, "%s.%d: function %s failed\n", __FILE__, __LINE__, f[i].name);
+ log_error_write(srv, __FILE__, __LINE__, "ss",
+ "calling function failed for",
+ f[i].name);
return -1;
}
@@ -362,9 +375,9 @@ int cache_trigger_parse(server *srv, connection *con, plugin_data *p, buffer *t
if (*err != '\0') {
/* isn't a int */
- fprintf(stderr, "%s.%d: can't evaluate: '%s', '%s'\n",
- __FILE__, __LINE__,
- t->ptr, err);
+ log_error_write(srv, __FILE__, __LINE__, "sss",
+ "can't evaluate:",
+ t->ptr, err);
return -1;
}