Browse Source

replace mysql my memcache prototypes, fixes parameter handling

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.3.x@431 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.3.15
Jan Kneschke 17 years ago
parent
commit
673a6cd0a9
  1. 5
      src/mod_cml.h
  2. 32
      src/mod_cml_funcs.c
  3. 11
      src/mod_cml_logic.c

5
src/mod_cml.h

@ -86,8 +86,7 @@ void tnode_val_array_reset(tnode_val_array *tva);
CACHE_FUNC_PROTO(f_unix_time_now);
CACHE_FUNC_PROTO(f_file_mtime);
CACHE_FUNC_PROTO(f_mysql_escape);
CACHE_FUNC_PROTO(f_mysql_connect);
CACHE_FUNC_PROTO(f_mysql_query);
CACHE_FUNC_PROTO(f_memcache_get);
CACHE_FUNC_PROTO(f_memcache_exists);
#endif

32
src/mod_cml_funcs.c

@ -61,53 +61,37 @@ CACHE_FUNC_PROTO(f_file_mtime) {
return 0;
}
CACHE_FUNC_PROTO(f_mysql_escape) {
CACHE_FUNC_PROTO(f_memcache_exists) {
UNUSED(srv);
UNUSED(con);
if (p->params->ptr[0]->type != T_NODE_VALUE_STRING) {
log_error_write(srv, __FILE__, __LINE__, "sd",
"f_mysql_escape: I need a string:",
"f_memcache_exists: I need a string:",
p->params->ptr[0]->type);
return -1;
}
tnode_prepare_string(result);
buffer_copy_string_buffer(VAL_STRING(result), p->params->ptr[0]->data.str);
tnode_prepare_long(result);
VAL_LONG(result) = 0;
return 0;
}
CACHE_FUNC_PROTO(f_mysql_query) {
CACHE_FUNC_PROTO(f_memcache_get) {
UNUSED(srv);
UNUSED(con);
if (p->params->ptr[0]->type != T_NODE_VALUE_STRING) {
log_error_write(srv, __FILE__, __LINE__, "sd",
"f_mysql_query: I need a string:",
"f_memcache_get: I need a string:",
p->params->ptr[0]->type);
return -1;
}
tnode_prepare_long(result);
VAL_LONG(result) = 0;
return 0;
}
CACHE_FUNC_PROTO(f_mysql_connect) {
UNUSED(srv);
UNUSED(con);
if (p->params->ptr[0]->type != T_NODE_VALUE_STRING) return -1;
if (p->params->ptr[1]->type != T_NODE_VALUE_STRING) return -1;
if (p->params->ptr[2]->type != T_NODE_VALUE_STRING) return -1;
if (p->params->ptr[3]->type != T_NODE_VALUE_STRING) return -1;
tnode_prepare_long(result);
VAL_LONG(result) = 0;
tnode_prepare_string(result);
buffer_copy_string_buffer(VAL_STRING(result), p->params->ptr[0]->data.str);
return 0;
}

11
src/mod_cml_logic.c

@ -163,11 +163,10 @@ int cache_trigger_parse(server *srv, connection *con, plugin_data *p, buffer *t
*/
cache_trigger_functions f[] = {
{ "file.mtime", 1, f_file_mtime },
{ "unix.time.now", 0, f_unix_time_now },
{ "mysql.escape", 1, f_mysql_escape },
{ "mysql.connect", 4, f_mysql_connect },
{ "mysql.query", 1, f_mysql_query },
{ "file.mtime", 1, f_file_mtime },
{ "unix.time.now", 0, f_unix_time_now },
{ "memcache.exits", 1, f_memcache_exists },
{ "memcache.get", 1, f_memcache_get },
{ NULL, 0, NULL },
};
@ -341,6 +340,8 @@ int cache_trigger_parse(server *srv, connection *con, plugin_data *p, buffer *t
/* parse parameters */
tnode_val_array_reset(p->params);
if (0 != cache_parse_parameters(srv, con, p, br_open + 1, t->used - slen - 3, p->params)) {
log_error_write(srv, __FILE__, __LINE__, "s",
"parsing parameters failed");

Loading…
Cancel
Save