1
0
mirror of https://github.com/apache/httpd.git synced 2025-08-08 15:02:10 +03:00

Fix more ISO C90 forbids mixed declarations and code...

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@728544 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Paul Querna
2008-12-21 22:53:08 +00:00
parent a36f6f7048
commit 2e920b6abf
3 changed files with 41 additions and 28 deletions

View File

@@ -54,13 +54,14 @@ apr_status_t apl_lua_map_handler(apl_dir_cfg *cfg,
const char *function, const char *function,
const char *pattern, const char *scope) const char *pattern, const char *scope)
{ {
ap_regex_t *uri_pattern;
apr_status_t rv; apr_status_t rv;
apl_mapped_handler_spec *handler = apl_mapped_handler_spec *handler =
apr_palloc(cfg->pool, sizeof(apl_mapped_handler_spec)); apr_palloc(cfg->pool, sizeof(apl_mapped_handler_spec));
handler->uri_pattern = NULL; handler->uri_pattern = NULL;
handler->function_name = NULL; handler->function_name = NULL;
ap_regex_t *uri_pattern = apr_palloc(cfg->pool, sizeof(ap_regex_t)); uri_pattern = apr_palloc(cfg->pool, sizeof(ap_regex_t));
if ((rv = ap_regcomp(uri_pattern, pattern, 0)) != APR_SUCCESS) { if ((rv = ap_regcomp(uri_pattern, pattern, 0)) != APR_SUCCESS) {
return rv; return rv;
} }
@@ -162,13 +163,14 @@ static int cmd_foo(lua_State *L)
/* helper function for the logging functions below */ /* helper function for the logging functions below */
static int cmd_log_at(lua_State *L, int level) static int cmd_log_at(lua_State *L, int level)
{ {
const char *msg;
cmd_parms *cmd = check_cmd_parms(L, 1); cmd_parms *cmd = check_cmd_parms(L, 1);
lua_Debug dbg; lua_Debug dbg;
lua_getstack(L, 1, &dbg); lua_getstack(L, 1, &dbg);
lua_getinfo(L, "Sl", &dbg); lua_getinfo(L, "Sl", &dbg);
const char *msg = luaL_checkstring(L, 2); msg = luaL_checkstring(L, 2);
ap_log_error(dbg.source, dbg.currentline, level, 0, cmd->server, msg); ap_log_error(dbg.source, dbg.currentline, level, 0, cmd->server, msg);
return 0; return 0;
} }

View File

@@ -24,10 +24,11 @@ typedef int (*req_field_int_f) (request_rec * r);
void apl_rstack_dump(lua_State *L, request_rec *r, const char *msg) void apl_rstack_dump(lua_State *L, request_rec *r, const char *msg)
{ {
ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, "Lua Stack Dump: [%s]", msg);
int i; int i;
int top = lua_gettop(L); int top = lua_gettop(L);
ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, "Lua Stack Dump: [%s]", msg);
for (i = 1; i <= top; i++) { for (i = 1; i <= top; i++) {
int t = lua_type(L, i); int t = lua_type(L, i);
switch (t) { switch (t) {
@@ -188,10 +189,10 @@ static int req_write(lua_State *L)
/* r:parsebody() */ /* r:parsebody() */
static int req_parsebody(lua_State *L) static int req_parsebody(lua_State *L)
{ {
apr_table_t *form_table;
request_rec *r = apl_check_request_rec(L, 1); request_rec *r = apl_check_request_rec(L, 1);
lua_newtable(L); lua_newtable(L);
lua_newtable(L); lua_newtable(L);
apr_table_t *form_table;
if (ap_body_to_table(r, &form_table) == APR_SUCCESS) { if (ap_body_to_table(r, &form_table) == APR_SUCCESS) {
apr_table_do(req_aprtable2luatable_cb, L, form_table, NULL); apr_table_do(req_aprtable2luatable_cb, L, form_table, NULL);
} }
@@ -308,15 +309,17 @@ static int req_assbackwards_field(request_rec *r)
static int req_dispatch(lua_State *L) static int req_dispatch(lua_State *L)
{ {
apr_hash_t *dispatch;
req_fun_t *rft;
request_rec *r = apl_check_request_rec(L, 1); request_rec *r = apl_check_request_rec(L, 1);
const char *name = luaL_checkstring(L, 2); const char *name = luaL_checkstring(L, 2);
lua_pop(L, 2); lua_pop(L, 2);
lua_getfield(L, LUA_REGISTRYINDEX, "Apache2.Request.dispatch"); lua_getfield(L, LUA_REGISTRYINDEX, "Apache2.Request.dispatch");
apr_hash_t *dispatch = lua_touserdata(L, 1); dispatch = lua_touserdata(L, 1);
lua_pop(L, 1); lua_pop(L, 1);
req_fun_t *rft = apr_hash_get(dispatch, name, APR_HASH_KEY_STRING); rft = apr_hash_get(dispatch, name, APR_HASH_KEY_STRING);
if (rft) { if (rft) {
switch (rft->type) { switch (rft->type) {
case APL_REQ_FUNTYPE_TABLE:{ case APL_REQ_FUNTYPE_TABLE:{
@@ -327,34 +330,37 @@ static int req_dispatch(lua_State *L)
} }
case APL_REQ_FUNTYPE_LUACFUN:{ case APL_REQ_FUNTYPE_LUACFUN:{
lua_CFunction func = rft->fun;
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
"request_rec->dispatching %s -> lua_CFunction", "request_rec->dispatching %s -> lua_CFunction",
name); name);
lua_CFunction func = rft->fun;
lua_pushcfunction(L, func); lua_pushcfunction(L, func);
return 1; return 1;
} }
case APL_REQ_FUNTYPE_STRING:{ case APL_REQ_FUNTYPE_STRING:{
req_field_string_f func = rft->fun;
char *rs;
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
"request_rec->dispatching %s -> string", name); "request_rec->dispatching %s -> string", name);
req_field_string_f func = rft->fun; rs = (*func) (r);
char *rs = (*func) (r);
lua_pushstring(L, rs); lua_pushstring(L, rs);
return 1; return 1;
} }
case APL_REQ_FUNTYPE_INT:{ case APL_REQ_FUNTYPE_INT:{
req_field_int_f func = rft->fun;
int rs;
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
"request_rec->dispatching %s -> int", name); "request_rec->dispatching %s -> int", name);
req_field_int_f func = rft->fun; rs = (*func) (r);
int rs = (*func) (r);
lua_pushnumber(L, rs); lua_pushnumber(L, rs);
return 1; return 1;
} }
case APL_REQ_FUNTYPE_BOOLEAN:{ case APL_REQ_FUNTYPE_BOOLEAN:{
req_field_int_f func = rft->fun;
int rs;
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
"request_rec->dispatching %s -> boolean", name); "request_rec->dispatching %s -> boolean", name);
req_field_int_f func = rft->fun; rs = (*func) (r);
int rs = (*func) (r);
lua_pushboolean(L, rs); lua_pushboolean(L, rs);
return 1; return 1;
} }
@@ -368,13 +374,14 @@ static int req_dispatch(lua_State *L)
/* helper function for the logging functions below */ /* helper function for the logging functions below */
static int req_log_at(lua_State *L, int level) static int req_log_at(lua_State *L, int level)
{ {
const char *msg;
request_rec *r = apl_check_request_rec(L, 1); request_rec *r = apl_check_request_rec(L, 1);
lua_Debug dbg; lua_Debug dbg;
lua_getstack(L, 1, &dbg); lua_getstack(L, 1, &dbg);
lua_getinfo(L, "Sl", &dbg); lua_getinfo(L, "Sl", &dbg);
const char *msg = luaL_checkstring(L, 2); msg = luaL_checkstring(L, 2);
ap_log_rerror(dbg.source, dbg.currentline, level, 0, r, msg); ap_log_rerror(dbg.source, dbg.currentline, level, 0, r, msg);
return 0; return 0;
} }
@@ -424,11 +431,12 @@ static int req_debug(lua_State *L)
/* handle r.status = 201 */ /* handle r.status = 201 */
static int req_newindex(lua_State *L) static int req_newindex(lua_State *L)
{ {
const char *key;
/* request_rec* r = lua_touserdata(L, lua_upvalueindex(1)); */ /* request_rec* r = lua_touserdata(L, lua_upvalueindex(1)); */
/* const char* key = luaL_checkstring(L, -2); */ /* const char* key = luaL_checkstring(L, -2); */
request_rec *r = apl_check_request_rec(L, 1); request_rec *r = apl_check_request_rec(L, 1);
apl_rstack_dump(L, r, "req_newindex"); apl_rstack_dump(L, r, "req_newindex");
const char *key = luaL_checkstring(L, 2); key = luaL_checkstring(L, 2);
apl_rstack_dump(L, r, "req_newindex"); apl_rstack_dump(L, r, "req_newindex");
if (0 == apr_strnatcmp("status", key)) { if (0 == apr_strnatcmp("status", key)) {
int code = luaL_checkinteger(L, 3); int code = luaL_checkinteger(L, 3);

View File

@@ -99,13 +99,14 @@ static apr_status_t luahood(ap_filter_t *f, apr_bucket_brigade *bb) {
*/ */
static int lua_handler(request_rec *r) static int lua_handler(request_rec *r)
{ {
apl_dir_cfg *dcfg;
if (strcmp(r->handler, "lua-script")) { if (strcmp(r->handler, "lua-script")) {
return DECLINED; return DECLINED;
} }
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "handling [%s] in mod_lua", ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "handling [%s] in mod_lua",
r->filename); r->filename);
apl_dir_cfg *dcfg = ap_get_module_config(r->per_dir_config, &lua_module); dcfg = ap_get_module_config(r->per_dir_config, &lua_module);
if (!r->header_only) { if (!r->header_only) {
lua_State *L; lua_State *L;
@@ -173,6 +174,7 @@ static int apl_alias_munger(request_rec *r)
if (OK == if (OK ==
ap_regexec(cnd->uri_pattern, r->uri, AP_MAX_REG_MATCH, matches, ap_regexec(cnd->uri_pattern, r->uri, AP_MAX_REG_MATCH, matches,
0)) { 0)) {
mapped_request_details *d;
r->handler = "lua-script"; r->handler = "lua-script";
spec = apr_pcalloc(r->pool, sizeof(apl_vm_spec)); spec = apr_pcalloc(r->pool, sizeof(apl_vm_spec));
@@ -187,8 +189,7 @@ static int apl_alias_munger(request_rec *r)
spec->pool = r->pool; spec->pool = r->pool;
} }
mapped_request_details *d = d = apr_palloc(r->pool, sizeof(mapped_request_details));
apr_palloc(r->pool, sizeof(mapped_request_details));
d->function_name = d->function_name =
ap_pregsub(r->pool, cnd->function_name, r->uri, ap_pregsub(r->pool, cnd->function_name, r->uri,
@@ -210,6 +211,7 @@ static int apl_alias_munger(request_rec *r)
static int lua_request_rec_hook_harness(request_rec *r, const char *name) static int lua_request_rec_hook_harness(request_rec *r, const char *name)
{ {
int rc;
lua_State *L; lua_State *L;
apl_vm_spec *spec; apl_vm_spec *spec;
apl_server_cfg *server_cfg = ap_get_module_config(r->server->module_config, apl_server_cfg *server_cfg = ap_get_module_config(r->server->module_config,
@@ -268,9 +270,10 @@ static int lua_request_rec_hook_harness(request_rec *r, const char *name)
apl_run_lua_request(L, r); apl_run_lua_request(L, r);
} }
else { else {
int t;
apl_run_lua_request(L, r); apl_run_lua_request(L, r);
int t = lua_gettop(L); t = lua_gettop(L);
lua_setglobal(L, "r"); lua_setglobal(L, "r");
lua_settop(L, t); lua_settop(L, t);
} }
@@ -279,12 +282,12 @@ static int lua_request_rec_hook_harness(request_rec *r, const char *name)
report_lua_error(L, r); report_lua_error(L, r);
return 500; return 500;
} }
apr_status_t rv = DECLINED; rc = DECLINED;
if (lua_isnumber(L, -1)) { if (lua_isnumber(L, -1)) {
rv = lua_tointeger(L, -1); rc = lua_tointeger(L, -1);
} }
if (rv != DECLINED) { if (rc != DECLINED) {
return rv; return rc;
} }
} }
} }
@@ -425,6 +428,7 @@ static const char *register_named_block_function_hook(const char *name,
const char *line) const char *line)
{ {
const char *function; const char *function;
apl_mapped_handler_spec *spec;
if (line && line[0] == '>') { if (line && line[0] == '>') {
function = NULL; function = NULL;
@@ -443,8 +447,7 @@ static const char *register_named_block_function_hook(const char *name,
} }
} }
apl_mapped_handler_spec *spec = spec = apr_pcalloc(cmd->pool, sizeof(apl_mapped_handler_spec));
apr_pcalloc(cmd->pool, sizeof(apl_mapped_handler_spec));
{ {
cr_ctx ctx; cr_ctx ctx;
@@ -453,6 +456,7 @@ static const char *register_named_block_function_hook(const char *name,
char *tmp; char *tmp;
int rv; int rv;
ap_directive_t **current; ap_directive_t **current;
hack_section_baton *baton;
apr_snprintf(buf, sizeof(buf), "%u", cmd->config_file->line_number); apr_snprintf(buf, sizeof(buf), "%u", cmd->config_file->line_number);
spec->file_name = spec->file_name =
@@ -505,8 +509,7 @@ static const char *register_named_block_function_hook(const char *name,
*current = apr_pcalloc(cmd->pool, sizeof(**current)); *current = apr_pcalloc(cmd->pool, sizeof(**current));
} }
hack_section_baton *baton = baton = apr_pcalloc(cmd->pool, sizeof(hack_section_baton));
apr_pcalloc(cmd->pool, sizeof(hack_section_baton));
baton->name = name; baton->name = name;
baton->spec = spec; baton->spec = spec;