summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBertrand Jacquin <beber@meleeweb.net>2012-12-04 12:18:18 +0100
committerBertrand Jacquin <beber@meleeweb.net>2012-12-04 12:18:18 +0100
commit630822a42e77f3ea6f603389b93252f163b8d920 (patch)
treed763b644ea5710d04a72fde80ffe830f93a47ee9
parent[BUILD] Cleanup stripped lib with make clean (diff)
downloadmod_virtualvalue-630822a42e77f3ea6f603389b93252f163b8d920.tar.gz
[CLEANUP] Reindent open braces
-rw-r--r--mod_virtualvalue.c138
1 files changed, 46 insertions, 92 deletions
diff --git a/mod_virtualvalue.c b/mod_virtualvalue.c
index 54b081e..5914047 100644
--- a/mod_virtualvalue.c
+++ b/mod_virtualvalue.c
@@ -110,8 +110,7 @@ typedef struct {
/*
* Create new configuration element
*/
-static virtualvalue_var_t *vv_var_new (void)
-{
+static virtualvalue_var_t *vv_var_new (void) {
virtualvalue_var_t *elm;
elm = (virtualvalue_var_t *)malloc(sizeof(virtualvalue_var_t));
@@ -127,8 +126,7 @@ static virtualvalue_var_t *vv_var_new (void)
return (elm);
}
-static virtualvalue_var_t *vv_var_append (virtualvalue_var_t *list, virtualvalue_var_t *elm)
-{
+static virtualvalue_var_t *vv_var_append (virtualvalue_var_t *list, virtualvalue_var_t *elm) {
virtualvalue_var_t *c;
if (!list || !elm)
@@ -136,8 +134,7 @@ static virtualvalue_var_t *vv_var_append (virtualvalue_var_t *list, virtualvalue
c = list;
- while (c->next)
- {
+ while (c->next) {
c = (virtualvalue_var_t *)c->next;
}
@@ -182,17 +179,14 @@ tag_t tag_tab[] = {
{ NULL , 0, NULL }
};
-static char *vv_strrrstr (char *start, char *cur, const char *needle)
-{
+static char *vv_strrrstr (char *start, char *cur, const char *needle) {
char *s;
int len = strlen (needle);
s = NULL;
- while (cur >= start)
- {
- if (strncmp(cur, needle, len) == 0)
- {
+ while (cur >= start) {
+ if (strncmp(cur, needle, len) == 0) {
s = cur;
break;
}
@@ -203,14 +197,12 @@ static char *vv_strrrstr (char *start, char *cur, const char *needle)
return s;
}
-static const char *vv_replace_HTTP (char *full __U__, char *search, request_rec *r)
-{
+static const char *vv_replace_HTTP (char *full __U__, char *search, request_rec *r) {
const char *host;
host = apr_table_get(r->headers_in, search);
- if (!host)
- {
+ if (!host) {
VV_error("Header %s not found", search);
host = apr_pstrdup (r->pool, "NULL");
}
@@ -218,14 +210,12 @@ static const char *vv_replace_HTTP (char *full __U__, char *search, request_rec
return (host);
}
-static const char *vv_replace_ENV (char *full __U__, char *search, request_rec *r)
-{
+static const char *vv_replace_ENV (char *full __U__, char *search, request_rec *r) {
const char *env;
env = apr_table_get(r->subprocess_env, search);
- if (!env)
- {
+ if (!env) {
VV_error("ENV %s not found", search);
env = apr_pstrdup (r->pool, "NULL");
}
@@ -233,15 +223,13 @@ static const char *vv_replace_ENV (char *full __U__, char *search, request_rec *
return (env);
}
-static const char *vv_replace_SYM (char *full __U__, char *search, request_rec *r)
-{
+static const char *vv_replace_SYM (char *full __U__, char *search, request_rec *r) {
struct stat st;
char *real;
real = (char *)apr_palloc (r->pool, PATH_MAX * sizeof(char));
- if (search[0] != '/')
- {
+ if (search[0] != '/') {
VV_error("Bad search: %s", search);
apr_cpystrn (real, "NULL", 5);
return (real);
@@ -249,16 +237,14 @@ static const char *vv_replace_SYM (char *full __U__, char *search, request_rec *
real[0] = 0;
- if (lstat(search, &st) == -1)
- {
+ if (lstat(search, &st) == -1) {
apr_cpystrn (real, "NULL", 5);
return (real);
}
realpath (search, real);
- if (lstat(real, &st) == -1)
- {
+ if (lstat(real, &st) == -1) {
apr_cpystrn (real, "NULL", 5);
return (real);
}
@@ -266,8 +252,7 @@ static const char *vv_replace_SYM (char *full __U__, char *search, request_rec *
return (real);
}
-static char *vv_flat_arg (char *s1, request_rec *r)
-{
+static char *vv_flat_arg (char *s1, request_rec *r) {
char *c, *end;
const char *s2;
@@ -280,20 +265,16 @@ static char *vv_flat_arg (char *s1, request_rec *r)
c = final + strlen(s1);
- while ((c = vv_strrrstr(final, c, "%{")))
- {
+ while ((c = vv_strrrstr(final, c, "%{"))) {
end = strchr(c+2, '}');
- if (!end)
- {
+ if (!end) {
VV_error("No end found for %s", c);
return NULL;
}
- for (i = tag_tab, s2 = NULL ; i->tag != NULL ; i++)
- {
- if (strncmp (c+2, i->tag, i->len) == 0)
- {
+ for (i = tag_tab, s2 = NULL ; i->tag != NULL ; i++) {
+ if (strncmp (c+2, i->tag, i->len) == 0) {
memcpy (&search, c+2 + i->len +1, end - (c+2 + i->len) -1);
search[end - (c+2 + i->len) -1] = '\0';
@@ -303,8 +284,7 @@ static char *vv_flat_arg (char *s1, request_rec *r)
}
}
- if (s2)
- {
+ if (s2) {
memmove (c + strlen(s2), end+1, strlen(c));
memcpy (c, s2, strlen(s2));
}
@@ -315,8 +295,7 @@ static char *vv_flat_arg (char *s1, request_rec *r)
return apr_pstrndup(r->pool, final, strlen(final));
}
-static int vv_echo (int argc __U__, char **argv, request_rec *r)
-{
+static int vv_echo (int argc __U__, char **argv, request_rec *r) {
char *s2;
VV_error("%s", "");
@@ -331,8 +310,7 @@ static int vv_echo (int argc __U__, char **argv, request_rec *r)
}
#ifdef HAVE_PHP
-static int vv_php_alter_ini (int argc __U__, char **argv, request_rec *r)
-{
+static int vv_php_alter_ini (int argc __U__, char **argv, request_rec *r) {
char *arg;
VV_debug("Translating %s %s", argv[0], argv[1]);
@@ -347,8 +325,7 @@ static int vv_php_alter_ini (int argc __U__, char **argv, request_rec *r)
}
#endif /* HAVE_PHP */
-static int vv_core_docroot (request_rec *r, char *n_root)
-{
+static int vv_core_docroot (request_rec *r, char *n_root) {
request_rec *top;
core_server_config *core;
@@ -368,14 +345,12 @@ static int vv_core_docroot (request_rec *r, char *n_root)
return (OK);
}
-static int vv_alter_docroot (int argc __U__, char **argv, request_rec *r)
-{
+static int vv_alter_docroot (int argc __U__, char **argv, request_rec *r) {
char *docroot;
docroot = vv_flat_arg (argv[0], r);
- if (!docroot)
- {
+ if (!docroot) {
VV_error("%s", "Can't build DocumentRoot");
return (DECLINED);
}
@@ -387,8 +362,7 @@ static int vv_alter_docroot (int argc __U__, char **argv, request_rec *r)
return (OK);
}
-static int vv_alter_scriptalias (int argc __U__, char **argv, request_rec *r)
-{
+static int vv_alter_scriptalias (int argc __U__, char **argv, request_rec *r) {
char *scriptalias;
if (!strstr(r->uri, argv[0]))
@@ -396,8 +370,7 @@ static int vv_alter_scriptalias (int argc __U__, char **argv, request_rec *r)
scriptalias = vv_flat_arg (argv[1], r);
- if (!scriptalias)
- {
+ if (!scriptalias) {
VV_error("%s", "Can't build ScriptAlias");
return (DECLINED);
}
@@ -412,14 +385,12 @@ static int vv_alter_scriptalias (int argc __U__, char **argv, request_rec *r)
return (OK);
}
-static int vv_alter_serveradmin (int argc __U__, char **argv, request_rec *r)
-{
+static int vv_alter_serveradmin (int argc __U__, char **argv, request_rec *r) {
char *serveradmin;
serveradmin = vv_flat_arg (argv[0], r);
- if (!serveradmin)
- {
+ if (!serveradmin) {
VV_error ("%s", "Can't build ServerAdmin");
return (DECLINED);
}
@@ -431,14 +402,12 @@ static int vv_alter_serveradmin (int argc __U__, char **argv, request_rec *r)
return (OK);
}
-static int vv_alter_servername (int argc __U__, char **argv, request_rec *r)
-{
+static int vv_alter_servername (int argc __U__, char **argv, request_rec *r) {
char *servername;
servername = vv_flat_arg (argv[0], r);
- if (!servername)
- {
+ if (!servername) {
VV_error ("%s", "Can't build ServerName");
return (DECLINED);
}
@@ -449,22 +418,19 @@ static int vv_alter_servername (int argc __U__, char **argv, request_rec *r)
return (OK);
}
-static void *vv_create_server_config (apr_pool_t *p, server_rec *s __U__)
-{
+static void *vv_create_server_config (apr_pool_t *p, server_rec *s __U__) {
virtualvalue_cfg_t *cfg = (virtualvalue_cfg_t *)apr_pcalloc(p, sizeof(virtualvalue_cfg_t));
return (void *)cfg;
}
-static void *vv_merge_server_config (apr_pool_t *p __U__, void *parent __U__, void *child)
-{
+static void *vv_merge_server_config (apr_pool_t *p __U__, void *parent __U__, void *child) {
virtualvalue_cfg_t *c_cfg = (virtualvalue_cfg_t *) child;
return (void *)c_cfg;
}
-static int vv_translate(request_rec *r)
-{
+static int vv_translate(request_rec *r) {
virtualvalue_cfg_t *c = (virtualvalue_cfg_t *)ap_get_module_config(r->server->module_config, &virtualvalue_module);
virtualvalue_var_t *n;
@@ -475,8 +441,7 @@ static int vv_translate(request_rec *r)
n = c->vars;
- while (n)
- {
+ while (n) {
n->handler (n->argc, n->argv, r);
n = (virtualvalue_var_t *)n->next;
@@ -486,58 +451,49 @@ static int vv_translate(request_rec *r)
return (DECLINED);
}
-static const char *vv_set (cmd_parms *cmd, void *struct_ptr __U__, int argc, char *const argv[])
-{
+static const char *vv_set (cmd_parms *cmd, void *struct_ptr __U__, int argc, char *const argv[]) {
virtualvalue_cfg_t *c = (virtualvalue_cfg_t *)ap_get_module_config(cmd->server->module_config, &virtualvalue_module);
virtualvalue_var_t *n;
token_t *i;
- if (!c->enable)
- {
+ if (!c->enable) {
VV_debug("c->enable: %d", c->enable);
return NULL;
}
n = vv_var_new ();
- if (!c->vars)
- {
+ if (!c->vars) {
c->vars = n;
}
- else
- {
+ else {
vv_var_append (c->vars, n);
}
n->tok = argv[0];
n->argc = argc - 1;
- for (i = token_tab ; i->tok != NULL ; i++)
- {
- if (strncmp(i->tok, n->tok, i->len) == 0)
- {
+ for (i = token_tab ; i->tok != NULL ; i++) {
+ if (strncmp(i->tok, n->tok, i->len) == 0) {
n->handler = i->func;
break;
}
}
- if (i->tok == NULL)
- {
+ if (i->tok == NULL) {
return apr_pstrcat(cmd->pool, "Invalid Token ", n->tok, NULL);
}
n->argv = (char **)malloc(n->argc * sizeof(char*));
- while (--argc > 0) /* Or --argc >= 1, We don't need argv[0], as is tok */
- {
+ while (--argc > 0) { /* Or --argc >= 1, We don't need argv[0], as is tok */
n->argv[argc-1] = argv[argc];
}
return NULL;
}
-static const char *vv_on (cmd_parms *cmd, void *struct_ptr __U__, int flag)
-{
+static const char *vv_on (cmd_parms *cmd, void *struct_ptr __U__, int flag) {
virtualvalue_cfg_t *cfg = (virtualvalue_cfg_t *)ap_get_module_config(cmd->server->module_config, &virtualvalue_module);
cfg->enable = (flag ? 1 : 0);
@@ -546,8 +502,7 @@ static const char *vv_on (cmd_parms *cmd, void *struct_ptr __U__, int flag)
return NULL;
}
-static void register_hooks(apr_pool_t *p __U__)
-{
+static void register_hooks(apr_pool_t *p __U__) {
/* Theses modules need to be loaded *before* mod_virtualvalue */
static const char *const aszPre[] = {
"mod_alias.c",
@@ -585,8 +540,7 @@ static const command_rec vv_cmds[] = {
{ NULL, { NULL }, NULL, 0, NO_ARGS, NULL}
};
-module AP_MODULE_DECLARE_DATA virtualvalue_module =
-{
+module AP_MODULE_DECLARE_DATA virtualvalue_module = {
STANDARD20_MODULE_STUFF,
NULL,
NULL,