summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBertrand Jacquin <beber@meleeweb.net>2012-12-17 23:28:20 +0100
committerBertrand Jacquin <beber@meleeweb.net>2012-12-17 23:28:20 +0100
commit3fa75a7dcbb56ea056a432f5dc93060a7c8a3627 (patch)
tree21104c3e44a225b0e1b1661585f4cdc40ee6fe4c
parent[MISC] Indent fix to match http://haproxy.1wt.eu/coding-style.html (diff)
downloadmod_virtualvalue-3fa75a7dcbb56ea056a432f5dc93060a7c8a3627.tar.gz
[BUILD] Split rewriter to re_<TAG>.{c,h} to be more readable
-rw-r--r--Makefile3
-rw-r--r--mod_virtualvalue.c73
-rw-r--r--re_env.c21
-rw-r--r--re_env.h6
-rw-r--r--re_http.c21
-rw-r--r--re_http.h6
-rw-r--r--re_sym.c41
-rw-r--r--re_sym.h6
8 files changed, 108 insertions, 69 deletions
diff --git a/Makefile b/Makefile
index 37c7241..0129ed6 100644
--- a/Makefile
+++ b/Makefile
@@ -11,6 +11,9 @@ SRC = \
al_core.c \
al_dumb.c \
al_php5.c \
+ re_env.c \
+ re_http.c \
+ re_sym.c \
mod_virtualvalue.c
DOC_FILES = \
diff --git a/mod_virtualvalue.c b/mod_virtualvalue.c
index 023af69..daab4c4 100644
--- a/mod_virtualvalue.c
+++ b/mod_virtualvalue.c
@@ -13,8 +13,6 @@
#include <apr_strings.h>
-#include <sys/stat.h>
-
#include "mod_virtualvalue.h"
#include "al_alias.h"
@@ -23,6 +21,10 @@
#include "al_dumb.h"
#include "al_php5.h"
+#include "re_env.h"
+#include "re_http.h"
+#include "re_sym.h"
+
#ifdef DEBUG
# warning DEBUG is ON, this will slow every processing. You are warned !
#endif /* DEBUG */
@@ -92,10 +94,6 @@ static virtualvalue_var_t *vv_var_append(virtualvalue_var_t *list,
return list;
}
-static const char *vv_replace_HTTP(char *full __U__, char *search, request_rec *r);
-static const char *vv_replace_ENV (char *full __U__, char *search, request_rec *r);
-static const char *vv_replace_SYM (char *full __U__, char *search, request_rec *r);
-
token_t token_tab[] = {
/*{ Config Token , Token lenght
* , Token handler }, */
@@ -142,69 +140,6 @@ 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)
-{
- const char *header;
-
- header = apr_table_get(r->headers_in, search);
-
- if (!header)
- {
- VV_error("Header %s not found", search);
- header = apr_pstrdup(r->pool, "NULL");
- }
-
- return (header);
-}
-
-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)
- {
- VV_error("ENV %s not found", search);
- env = apr_pstrdup(r->pool, "NULL");
- }
-
- return (env);
-}
-
-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] != '/')
- {
- VV_error("Bad search: %s", search);
- apr_cpystrn(real, "NULL", 5);
- return (real);
- }
-
- real[0] = 0;
-
- if (lstat(search, &st) == -1)
- {
- apr_cpystrn(real, "NULL", 5);
- return (real);
- }
-
- realpath(search, real);
-
- if (lstat(real, &st) == -1)
- {
- apr_cpystrn(real, "NULL", 5);
- return (real);
- }
-
- return (real);
-}
-
char *vv_flat_arg(char *s1, request_rec *r)
{
char *c, *end;
diff --git a/re_env.c b/re_env.c
new file mode 100644
index 0000000..b1a16b5
--- /dev/null
+++ b/re_env.c
@@ -0,0 +1,21 @@
+#include <httpd.h>
+#include <apr_strings.h>
+
+#include "mod_virtualvalue.h"
+
+#include "re_env.h"
+
+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)
+ {
+ VV_error("ENV %s not found", search);
+ env = apr_pstrdup(r->pool, "NULL");
+ }
+
+ return (env);
+}
diff --git a/re_env.h b/re_env.h
new file mode 100644
index 0000000..00d2458
--- /dev/null
+++ b/re_env.h
@@ -0,0 +1,6 @@
+#ifndef RE_ENV_H
+#define RE_ENV_H
+
+const char *vv_replace_ENV(char *, char *, request_rec *);
+
+#endif /* RE_ENV_H */
diff --git a/re_http.c b/re_http.c
new file mode 100644
index 0000000..3867caa
--- /dev/null
+++ b/re_http.c
@@ -0,0 +1,21 @@
+#include <httpd.h>
+#include <apr_strings.h>
+
+#include "mod_virtualvalue.h"
+
+#include "re_http.h"
+
+const char *vv_replace_HTTP(char *full __U__, char *search, request_rec *r)
+{
+ const char *header;
+
+ header = apr_table_get(r->headers_in, search);
+
+ if (!header)
+ {
+ VV_error("Header %s not found", search);
+ header = apr_pstrdup(r->pool, "NULL");
+ }
+
+ return (header);
+}
diff --git a/re_http.h b/re_http.h
new file mode 100644
index 0000000..f75dc5b
--- /dev/null
+++ b/re_http.h
@@ -0,0 +1,6 @@
+#ifndef RE_HTTP_H
+#define RE_HTTP_H
+
+const char *vv_replace_HTTP(char *, char *, request_rec *);
+
+#endif /* RE_HTTP_H */
diff --git a/re_sym.c b/re_sym.c
new file mode 100644
index 0000000..4955385
--- /dev/null
+++ b/re_sym.c
@@ -0,0 +1,41 @@
+#include <httpd.h>
+#include <apr_strings.h>
+
+#include <sys/stat.h>
+
+#include "mod_virtualvalue.h"
+
+#include "re_sym.h"
+
+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] != '/')
+ {
+ VV_error("Bad search: %s", search);
+ apr_cpystrn(real, "NULL", 5);
+ return (real);
+ }
+
+ real[0] = 0;
+
+ if (lstat(search, &st) == -1)
+ {
+ apr_cpystrn(real, "NULL", 5);
+ return (real);
+ }
+
+ realpath(search, real);
+
+ if (lstat(real, &st) == -1)
+ {
+ apr_cpystrn(real, "NULL", 5);
+ return (real);
+ }
+
+ return (real);
+}
diff --git a/re_sym.h b/re_sym.h
new file mode 100644
index 0000000..73265cf
--- /dev/null
+++ b/re_sym.h
@@ -0,0 +1,6 @@
+#ifndef RE_SYM_H
+#define RE_SYM_H
+
+const char *vv_replace_SYM(char *, char *, request_rec *);
+
+#endif /* RE_SYM_H */