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

More style fixes, no func changes

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1174937 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stefan Fritsch
2011-09-23 18:20:43 +00:00
parent 1951a037bf
commit 374a42b9a0

View File

@@ -112,8 +112,8 @@ static int lua_handler(request_rec *r)
lua_State *L; lua_State *L;
const ap_lua_dir_cfg *cfg = ap_get_module_config(r->per_dir_config, const ap_lua_dir_cfg *cfg = ap_get_module_config(r->per_dir_config,
&lua_module); &lua_module);
ap_lua_request_cfg *rcfg = ap_lua_request_cfg *rcfg = ap_get_module_config(r->request_config,
ap_get_module_config(r->request_config, &lua_module); &lua_module);
mapped_request_details *d = rcfg->mapped_request_details; mapped_request_details *d = rcfg->mapped_request_details;
ap_lua_vm_spec *spec = NULL; ap_lua_vm_spec *spec = NULL;
@@ -176,8 +176,8 @@ static int lua_alias_munger(request_rec *r)
ap_lua_vm_spec *spec; ap_lua_vm_spec *spec;
ap_lua_request_cfg *rcfg = ap_get_module_config(r->request_config, ap_lua_request_cfg *rcfg = ap_get_module_config(r->request_config,
&lua_module); &lua_module);
const ap_lua_dir_cfg *cfg = const ap_lua_dir_cfg *cfg = ap_get_module_config(r->per_dir_config,
ap_get_module_config(r->per_dir_config, &lua_module); &lua_module);
int i; int i;
ap_regmatch_t matches[AP_MAX_REG_MATCH]; ap_regmatch_t matches[AP_MAX_REG_MATCH];
@@ -185,16 +185,14 @@ static int lua_alias_munger(request_rec *r)
const ap_lua_mapped_handler_spec *cnd = const ap_lua_mapped_handler_spec *cnd =
((const ap_lua_mapped_handler_spec **) cfg->mapped_handlers->elts)[i]; ((const ap_lua_mapped_handler_spec **) cfg->mapped_handlers->elts)[i];
if (OK == if (OK == ap_regexec(cnd->uri_pattern, r->uri, AP_MAX_REG_MATCH,
ap_regexec(cnd->uri_pattern, r->uri, AP_MAX_REG_MATCH, matches, matches, 0)) {
0)) {
mapped_request_details *d; mapped_request_details *d;
r->handler = "lua-script"; r->handler = "lua-script";
spec = apr_pcalloc(r->pool, sizeof(ap_lua_vm_spec)); spec = apr_pcalloc(r->pool, sizeof(ap_lua_vm_spec));
spec->file = spec->file = ap_pregsub(r->pool, cnd->file_name, r->uri,
ap_pregsub(r->pool, cnd->file_name, r->uri, AP_MAX_REG_MATCH, AP_MAX_REG_MATCH, matches);
matches);
spec->scope = cnd->scope; spec->scope = cnd->scope;
spec->code_cache_style = cnd->code_cache_style; spec->code_cache_style = cnd->code_cache_style;
spec->bytecode = cnd->bytecode; spec->bytecode = cnd->bytecode;
@@ -205,8 +203,7 @@ static int lua_alias_munger(request_rec *r)
d = apr_palloc(r->pool, sizeof(mapped_request_details)); d = 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,
AP_MAX_REG_MATCH, matches); AP_MAX_REG_MATCH, matches);
d->spec = spec; d->spec = spec;
@@ -230,11 +227,10 @@ static int lua_request_rec_hook_harness(request_rec *r, const char *name)
ap_lua_vm_spec *spec; ap_lua_vm_spec *spec;
ap_lua_server_cfg *server_cfg = ap_get_module_config(r->server->module_config, ap_lua_server_cfg *server_cfg = ap_get_module_config(r->server->module_config,
&lua_module); &lua_module);
const ap_lua_dir_cfg *cfg = const ap_lua_dir_cfg *cfg = ap_get_module_config(r->per_dir_config,
(ap_lua_dir_cfg *) ap_get_module_config(r->per_dir_config,
&lua_module); &lua_module);
apr_array_header_t *hook_specs = apr_array_header_t *hook_specs = apr_hash_get(cfg->hooks, name,
apr_hash_get(cfg->hooks, name, APR_HASH_KEY_STRING); APR_HASH_KEY_STRING);
if (hook_specs) { if (hook_specs) {
int i; int i;
for (i = 0; i < hook_specs->nelts; i++) { for (i = 0; i < hook_specs->nelts; i++) {
@@ -261,10 +257,7 @@ static int lua_request_rec_hook_harness(request_rec *r, const char *name)
apr_filepath_merge(&spec->file, server_cfg->root_path, apr_filepath_merge(&spec->file, server_cfg->root_path,
spec->file, APR_FILEPATH_NOTRELATIVE, r->pool); spec->file, APR_FILEPATH_NOTRELATIVE, r->pool);
L = ap_lua_get_lua_state(r->pool, L = ap_lua_get_lua_state(r->pool, spec);
spec);
if (!L) { if (!L) {
ap_log_rerror(APLOG_MARK, APLOG_CRIT, 0, r, ap_log_rerror(APLOG_MARK, APLOG_CRIT, 0, r,
@@ -423,11 +416,11 @@ static const char *hack_section_handler(cmd_parms *cmd, void *_cfg,
ap_directive_t *directive = cmd->directive; ap_directive_t *directive = cmd->directive;
hack_section_baton *baton = directive->data; hack_section_baton *baton = directive->data;
apr_array_header_t *hook_specs = apr_array_header_t *hook_specs = apr_hash_get(cfg->hooks, baton->name,
apr_hash_get(cfg->hooks, baton->name, APR_HASH_KEY_STRING); APR_HASH_KEY_STRING);
if (!hook_specs) { if (!hook_specs) {
hook_specs = hook_specs = apr_array_make(cmd->pool, 2,
apr_array_make(cmd->pool, 2, sizeof(ap_lua_mapped_handler_spec *)); sizeof(ap_lua_mapped_handler_spec *));
apr_hash_set(cfg->hooks, apr_pstrdup(cmd->pool, baton->name), apr_hash_set(cfg->hooks, apr_pstrdup(cmd->pool, baton->name),
APR_HASH_KEY_STRING, hook_specs); APR_HASH_KEY_STRING, hook_specs);
} }
@@ -476,8 +469,8 @@ static const char *register_named_block_function_hook(const char *name,
hack_section_baton *baton; 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 = apr_pstrcat(cmd->pool, cmd->config_file->name, ":",
apr_pstrcat(cmd->pool, cmd->config_file->name, ":", buf, NULL); buf, NULL);
if (function) { if (function) {
spec->function_name = (char *) function; spec->function_name = (char *) function;
} }
@@ -501,9 +494,8 @@ static const char *register_named_block_function_hook(const char *name,
rv = lua_load(lvm, direct_chunkreader, &ctx, spec->file_name); rv = lua_load(lvm, direct_chunkreader, &ctx, spec->file_name);
if (rv != 0) { if (rv != 0) {
const char *errstr = const char *errstr = apr_pstrcat(cmd->pool, "Lua Error:",
apr_pstrcat(cmd->pool, "Lua Error:", lua_tostring(lvm, -1), lua_tostring(lvm, -1), NULL);
NULL);
lua_close(lvm); lua_close(lvm);
return errstr; return errstr;
} }
@@ -513,8 +505,7 @@ static const char *register_named_block_function_hook(const char *name,
lua_dump(lvm, ldump_writer, &b); lua_dump(lvm, ldump_writer, &b);
luaL_pushresult(&b); luaL_pushresult(&b);
spec->bytecode_len = lua_strlen(lvm, -1); spec->bytecode_len = lua_strlen(lvm, -1);
spec->bytecode = spec->bytecode = apr_pstrmemdup(cmd->pool, lua_tostring(lvm, -1),
apr_pstrmemdup(cmd->pool, lua_tostring(lvm, -1),
spec->bytecode_len); spec->bytecode_len);
lua_close(lvm); lua_close(lvm);
} }
@@ -532,8 +523,7 @@ static const char *register_named_block_function_hook(const char *name,
(*current)->filename = cmd->config_file->name; (*current)->filename = cmd->config_file->name;
(*current)->line_num = cmd->config_file->line_number; (*current)->line_num = cmd->config_file->line_number;
(*current)->directive = (*current)->directive = apr_pstrdup(cmd->pool, "Lua_____ByteCodeHack");
apr_pstrdup(cmd->pool, "Lua_____ByteCodeHack");
(*current)->args = NULL; (*current)->args = NULL;
(*current)->data = baton; (*current)->data = baton;
} }
@@ -550,11 +540,11 @@ static const char *register_named_file_function_hook(const char *name,
ap_lua_mapped_handler_spec *spec; ap_lua_mapped_handler_spec *spec;
ap_lua_dir_cfg *cfg = (ap_lua_dir_cfg *) _cfg; ap_lua_dir_cfg *cfg = (ap_lua_dir_cfg *) _cfg;
apr_array_header_t *hook_specs = apr_array_header_t *hook_specs = apr_hash_get(cfg->hooks, name,
apr_hash_get(cfg->hooks, name, APR_HASH_KEY_STRING); APR_HASH_KEY_STRING);
if (!hook_specs) { if (!hook_specs) {
hook_specs = hook_specs = apr_array_make(cmd->pool, 2,
apr_array_make(cmd->pool, 2, sizeof(ap_lua_mapped_handler_spec *)); sizeof(ap_lua_mapped_handler_spec *));
apr_hash_set(cfg->hooks, apr_pstrdup(cmd->pool, name), apr_hash_set(cfg->hooks, apr_pstrdup(cmd->pool, name),
APR_HASH_KEY_STRING, hook_specs); APR_HASH_KEY_STRING, hook_specs);
} }
@@ -805,8 +795,10 @@ static const char *register_code_cache(cmd_parms *cmd, void *_cfg,
} }
else { else {
return apr_psprintf(cmd->pool, return apr_psprintf(cmd->pool,
"Invalid value for LuaCodeCache, '%s', acceptable values are %s", "Invalid value for LuaCodeCache, '%s', "
arg, "'stat', 'forever', and 'never'"); "acceptable values are 'stat', 'forever', and "
"'never'",
arg);
} }
return NULL; return NULL;
} }
@@ -834,8 +826,10 @@ static const char *register_lua_scope(cmd_parms *cmd, void *_cfg,
} }
else { else {
return apr_psprintf(cmd->pool, return apr_psprintf(cmd->pool,
"Invalid value for LuaScope, '%s', acceptable values are %s", "Invalid value for LuaScope, '%s', acceptable "
scope, "'once', 'request', 'conn', and 'server'"); "values are 'once', 'request', 'conn', and "
"'server'",
scope);
} }
return NULL; return NULL;
} }
@@ -856,7 +850,8 @@ static const char *lua_map_handler(cmd_parms *cmd, void *_cfg,
rv = ap_lua_map_handler(cfg, file, function_name, path, "once"); rv = ap_lua_map_handler(cfg, file, function_name, path, "once");
if (rv != APR_SUCCESS) { if (rv != APR_SUCCESS) {
return apr_psprintf(cmd->pool, return apr_psprintf(cmd->pool,
"Unable to configure a lua handler for path '%s', handler %s#%s", "Unable to configure a lua handler for path "
"'%s', handler %s#%s",
path, file, function_name); path, file, function_name);
} }
return NULL; return NULL;
@@ -866,8 +861,8 @@ static const char *register_lua_root(cmd_parms *cmd, void *_cfg,
const char *root) const char *root)
{ {
/* ap_lua_dir_cfg* cfg = (ap_lua_dir_cfg*)_cfg; */ /* ap_lua_dir_cfg* cfg = (ap_lua_dir_cfg*)_cfg; */
ap_lua_server_cfg *cfg = ap_lua_server_cfg *cfg = ap_get_module_config(cmd->server->module_config,
ap_get_module_config(cmd->server->module_config, &lua_module); &lua_module);
cfg->root_path = root; cfg->root_path = root;
return NULL; return NULL;
@@ -880,7 +875,6 @@ command_rec lua_commands[] = {
AP_INIT_TAKE1("LuaRoot", register_lua_root, NULL, OR_ALL, AP_INIT_TAKE1("LuaRoot", register_lua_root, NULL, OR_ALL,
"Specify the base path for resolving relative paths for mod_lua directives"), "Specify the base path for resolving relative paths for mod_lua directives"),
AP_INIT_TAKE1("LuaPackagePath", register_package_dir, NULL, OR_ALL, AP_INIT_TAKE1("LuaPackagePath", register_package_dir, NULL, OR_ALL,
"Add a directory to lua's package.path"), "Add a directory to lua's package.path"),