summaryrefslogtreecommitdiff
path: root/src/libfast
diff options
context:
space:
mode:
authorYves-Alexis Perez <corsac@corsac.net>2012-06-28 21:16:07 +0200
committerYves-Alexis Perez <corsac@corsac.net>2012-06-28 21:16:07 +0200
commitb34738ed08c2227300d554b139e2495ca5da97d6 (patch)
tree62f33b52820f2e49f0e53c0f8c636312037c8054 /src/libfast
parent0a9d51a49042a68daa15b0c74a2b7f152f52606b (diff)
downloadvyos-strongswan-b34738ed08c2227300d554b139e2495ca5da97d6.tar.gz
vyos-strongswan-b34738ed08c2227300d554b139e2495ca5da97d6.zip
Imported Upstream version 4.6.4
Diffstat (limited to 'src/libfast')
-rw-r--r--src/libfast/Makefile.am4
-rw-r--r--src/libfast/Makefile.in63
-rw-r--r--src/libfast/dispatcher.c104
-rw-r--r--src/libfast/request.c183
-rw-r--r--src/libfast/session.c56
-rw-r--r--src/libfast/session.h2
-rw-r--r--src/libfast/smtp.h2
7 files changed, 181 insertions, 233 deletions
diff --git a/src/libfast/Makefile.am b/src/libfast/Makefile.am
index 5a1193658..35d102109 100644
--- a/src/libfast/Makefile.am
+++ b/src/libfast/Makefile.am
@@ -1,8 +1,8 @@
-lib_LTLIBRARIES = libfast.la
+ipseclib_LTLIBRARIES = libfast.la
libfast_la_SOURCES = context.h dispatcher.c request.h session.h \
controller.h dispatcher.h request.c session.c filter.h smtp.c smtp.h
libfast_la_LIBADD = $(top_builddir)/src/libstrongswan/libstrongswan.la \
- -lfcgi -lneo_cgi -lneo_cs -lneo_utl -lz $(PTHREADLIB)
+ -lfcgi $(clearsilver_LIBS) $(PTHREADLIB)
INCLUDES = -I$(top_srcdir)/src/libstrongswan -I/usr/include/ClearSilver
AM_CFLAGS = -rdynamic
diff --git a/src/libfast/Makefile.in b/src/libfast/Makefile.in
index 47678029f..abb721758 100644
--- a/src/libfast/Makefile.in
+++ b/src/libfast/Makefile.in
@@ -72,12 +72,12 @@ am__nobase_list = $(am__nobase_strip_setup); \
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
-am__installdirs = "$(DESTDIR)$(libdir)"
-LTLIBRARIES = $(lib_LTLIBRARIES)
+am__installdirs = "$(DESTDIR)$(ipseclibdir)"
+LTLIBRARIES = $(ipseclib_LTLIBRARIES)
am__DEPENDENCIES_1 =
libfast_la_DEPENDENCIES = \
$(top_builddir)/src/libstrongswan/libstrongswan.la \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
am_libfast_la_OBJECTS = dispatcher.lo request.lo session.lo smtp.lo
libfast_la_OBJECTS = $(am_libfast_la_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@
@@ -189,6 +189,9 @@ am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
+attest_plugins = @attest_plugins@
+axis2c_CFLAGS = @axis2c_CFLAGS@
+axis2c_LIBS = @axis2c_LIBS@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
@@ -197,6 +200,7 @@ build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
c_plugins = @c_plugins@
+clearsilver_LIBS = @clearsilver_LIBS@
datadir = @datadir@
datarootdir = @datarootdir@
dbusservicedir = @dbusservicedir@
@@ -213,11 +217,13 @@ host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
+imcvdir = @imcvdir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
ipsecgroup = @ipsecgroup@
+ipseclibdir = @ipseclibdir@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -261,6 +267,7 @@ sharedstatedir = @sharedstatedir@
soup_CFLAGS = @soup_CFLAGS@
soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
+starter_plugins = @starter_plugins@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
systemdsystemunitdir = @systemdsystemunitdir@
@@ -271,12 +278,12 @@ top_srcdir = @top_srcdir@
urandom_device = @urandom_device@
xml_CFLAGS = @xml_CFLAGS@
xml_LIBS = @xml_LIBS@
-lib_LTLIBRARIES = libfast.la
+ipseclib_LTLIBRARIES = libfast.la
libfast_la_SOURCES = context.h dispatcher.c request.h session.h \
controller.h dispatcher.h request.c session.c filter.h smtp.c smtp.h
libfast_la_LIBADD = $(top_builddir)/src/libstrongswan/libstrongswan.la \
- -lfcgi -lneo_cgi -lneo_cs -lneo_utl -lz $(PTHREADLIB)
+ -lfcgi $(clearsilver_LIBS) $(PTHREADLIB)
INCLUDES = -I$(top_srcdir)/src/libstrongswan -I/usr/include/ClearSilver
AM_CFLAGS = -rdynamic
@@ -314,39 +321,39 @@ $(top_srcdir)/configure: $(am__configure_deps)
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
-install-libLTLIBRARIES: $(lib_LTLIBRARIES)
+install-ipseclibLTLIBRARIES: $(ipseclib_LTLIBRARIES)
@$(NORMAL_INSTALL)
- test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
- @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+ test -z "$(ipseclibdir)" || $(MKDIR_P) "$(DESTDIR)$(ipseclibdir)"
+ @list='$(ipseclib_LTLIBRARIES)'; test -n "$(ipseclibdir)" || list=; \
list2=; for p in $$list; do \
if test -f $$p; then \
list2="$$list2 $$p"; \
else :; fi; \
done; \
test -z "$$list2" || { \
- echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
- $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(ipseclibdir)'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(ipseclibdir)"; \
}
-uninstall-libLTLIBRARIES:
+uninstall-ipseclibLTLIBRARIES:
@$(NORMAL_UNINSTALL)
- @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+ @list='$(ipseclib_LTLIBRARIES)'; test -n "$(ipseclibdir)" || list=; \
for p in $$list; do \
$(am__strip_dir) \
- echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
- $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(ipseclibdir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(ipseclibdir)/$$f"; \
done
-clean-libLTLIBRARIES:
- -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
- @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+clean-ipseclibLTLIBRARIES:
+ -test -z "$(ipseclib_LTLIBRARIES)" || rm -f $(ipseclib_LTLIBRARIES)
+ @list='$(ipseclib_LTLIBRARIES)'; for p in $$list; do \
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
test "$$dir" != "$$p" || dir=.; \
echo "rm -f \"$${dir}/so_locations\""; \
rm -f "$${dir}/so_locations"; \
done
libfast.la: $(libfast_la_OBJECTS) $(libfast_la_DEPENDENCIES)
- $(LINK) -rpath $(libdir) $(libfast_la_OBJECTS) $(libfast_la_LIBADD) $(LIBS)
+ $(LINK) -rpath $(ipseclibdir) $(libfast_la_OBJECTS) $(libfast_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@@ -472,7 +479,7 @@ check-am: all-am
check: check-am
all-am: Makefile $(LTLIBRARIES)
installdirs:
- for dir in "$(DESTDIR)$(libdir)"; do \
+ for dir in "$(DESTDIR)$(ipseclibdir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
@@ -502,7 +509,7 @@ maintainer-clean-generic:
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
-clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
+clean-am: clean-generic clean-ipseclibLTLIBRARIES clean-libtool \
mostlyclean-am
distclean: distclean-am
@@ -523,13 +530,13 @@ info: info-am
info-am:
-install-data-am:
+install-data-am: install-ipseclibLTLIBRARIES
install-dvi: install-dvi-am
install-dvi-am:
-install-exec-am: install-libLTLIBRARIES
+install-exec-am:
install-html: install-html-am
@@ -569,23 +576,23 @@ ps: ps-am
ps-am:
-uninstall-am: uninstall-libLTLIBRARIES
+uninstall-am: uninstall-ipseclibLTLIBRARIES
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
- clean-libLTLIBRARIES clean-libtool ctags distclean \
+ clean-ipseclibLTLIBRARIES clean-libtool ctags distclean \
distclean-compile distclean-generic distclean-libtool \
distclean-tags distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am \
- install-libLTLIBRARIES install-man install-pdf install-pdf-am \
- install-ps install-ps-am install-strip installcheck \
- installcheck-am installdirs maintainer-clean \
+ install-ipseclibLTLIBRARIES install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
- tags uninstall uninstall-am uninstall-libLTLIBRARIES
+ tags uninstall uninstall-am uninstall-ipseclibLTLIBRARIES
# Tell versions [3.59,3.63) of GNU make to not export all variables.
diff --git a/src/libfast/dispatcher.c b/src/libfast/dispatcher.c
index 7690230d3..e5fca7074 100644
--- a/src/libfast/dispatcher.c
+++ b/src/libfast/dispatcher.c
@@ -180,14 +180,12 @@ static session_entry_t *session_entry_create(private_dispatcher_t *this,
{
session_entry_t *entry;
- entry = malloc_thing(session_entry_t);
- entry->in_use = FALSE;
- entry->closed = FALSE;
- entry->cond = condvar_create(CONDVAR_TYPE_DEFAULT);
- entry->session = load_session(this);
- entry->used = time_monotonic(NULL);
- entry->host = strdup(host);
-
+ INIT(entry,
+ .cond = condvar_create(CONDVAR_TYPE_DEFAULT),
+ .session = load_session(this),
+ .host = strdup(host),
+ .used = time_monotonic(NULL),
+ );
return entry;
}
@@ -202,29 +200,28 @@ static void session_entry_destroy(session_entry_t *entry)
free(entry);
}
-/**
- * Implementation of dispatcher_t.add_controller.
- */
-static void add_controller(private_dispatcher_t *this,
- controller_constructor_t constructor, void *param)
+METHOD(dispatcher_t, add_controller, void,
+ private_dispatcher_t *this, controller_constructor_t constructor,
+ void *param)
{
- controller_entry_t *entry = malloc_thing(controller_entry_t);
+ controller_entry_t *entry;
- entry->constructor = constructor;
- entry->param = param;
+ INIT(entry,
+ .constructor = constructor,
+ .param = param,
+ );
this->controllers->insert_last(this->controllers, entry);
}
-/**
- * Implementation of dispatcher_t.add_filter.
- */
-static void add_filter(private_dispatcher_t *this,
- filter_constructor_t constructor, void *param)
+METHOD(dispatcher_t, add_filter, void,
+ private_dispatcher_t *this, filter_constructor_t constructor, void *param)
{
- filter_entry_t *entry = malloc_thing(filter_entry_t);
+ filter_entry_t *entry;
- entry->constructor = constructor;
- entry->param = param;
+ INIT(entry,
+ .constructor = constructor,
+ .param = param,
+ );
this->filters->insert_last(this->filters, entry);
}
@@ -349,10 +346,8 @@ static void dispatch(private_dispatcher_t *this)
}
}
-/**
- * Implementation of dispatcher_t.run.
- */
-static void run(private_dispatcher_t *this, int threads)
+METHOD(dispatcher_t, run, void,
+ private_dispatcher_t *this, int threads)
{
this->thread_count = threads;
this->threads = malloc(sizeof(thread_t*) * threads);
@@ -367,10 +362,8 @@ static void run(private_dispatcher_t *this, int threads)
}
}
-/**
- * Implementation of dispatcher_t.waitsignal.
- */
-static void waitsignal(private_dispatcher_t *this)
+METHOD(dispatcher_t, waitsignal, void,
+ private_dispatcher_t *this)
{
sigset_t set;
int sig;
@@ -383,10 +376,8 @@ static void waitsignal(private_dispatcher_t *this)
sigwait(&set, &sig);
}
-/**
- * Implementation of dispatcher_t.destroy
- */
-static void destroy(private_dispatcher_t *this)
+METHOD(dispatcher_t, destroy, void,
+ private_dispatcher_t *this)
{
char *sid;
session_entry_t *entry;
@@ -419,26 +410,27 @@ static void destroy(private_dispatcher_t *this)
dispatcher_t *dispatcher_create(char *socket, bool debug, int timeout,
context_constructor_t constructor, void *param)
{
- private_dispatcher_t *this = malloc_thing(private_dispatcher_t);
-
- this->public.add_controller = (void(*)(dispatcher_t*, controller_constructor_t, void*))add_controller;
- this->public.add_filter = (void(*)(dispatcher_t*,filter_constructor_t constructor, void *param))add_filter;
- this->public.run = (void(*)(dispatcher_t*, int threads))run;
- this->public.waitsignal = (void(*)(dispatcher_t*))waitsignal;
- this->public.destroy = (void(*)(dispatcher_t*))destroy;
-
- this->sessions = hashtable_create((void*)session_hash,
- (void*)session_equals, 4096);
- this->controllers = linked_list_create();
- this->filters = linked_list_create();
- this->context_constructor = constructor;
- this->mutex = mutex_create(MUTEX_TYPE_DEFAULT);
- this->param = param;
- this->fd = 0;
- this->timeout = timeout;
- this->last_cleanup = time_monotonic(NULL);
- this->debug = debug;
- this->threads = NULL;
+ private_dispatcher_t *this;
+
+ INIT(this,
+ .public = {
+ .add_controller = _add_controller,
+ .add_filter = _add_filter,
+ .run = _run,
+ .waitsignal = _waitsignal,
+ .destroy = _destroy,
+ },
+ .sessions = hashtable_create((void*)session_hash,
+ (void*)session_equals, 4096),
+ .controllers = linked_list_create(),
+ .filters = linked_list_create(),
+ .context_constructor = constructor,
+ .mutex = mutex_create(MUTEX_TYPE_DEFAULT),
+ .param = param,
+ .timeout = timeout,
+ .last_cleanup = time_monotonic(NULL),
+ .debug = debug,
+ );
FCGX_Init();
diff --git a/src/libfast/request.c b/src/libfast/request.c
index a3db70e82..3acd831b2 100644
--- a/src/libfast/request.c
+++ b/src/libfast/request.c
@@ -160,86 +160,66 @@ static int iterenv_cb(void *null, int num, char **key, char **value)
return 0;
}
-/**
- * Implementation of request_t.get_cookie.
- */
-static char* get_cookie(private_request_t *this, char *name)
+METHOD(request_t, get_cookie, char*,
+ private_request_t *this, char *name)
{
return hdf_get_valuef(this->hdf, "Cookie.%s", name);
}
-/**
- * Implementation of request_t.get_path.
- */
-static char* get_path(private_request_t *this)
+METHOD(request_t, get_path, char*,
+ private_request_t *this)
{
char * path = FCGX_GetParam("PATH_INFO", this->req.envp);
return path ? path : "";
}
-/**
- * Implementation of request_t.get_host.
- */
-static char* get_host(private_request_t *this)
+METHOD(request_t, get_host, char*,
+ private_request_t *this)
{
char *addr = FCGX_GetParam("REMOTE_ADDR", this->req.envp);
return addr ? addr : "";
}
-/**
- * Implementation of request_t.get_user_agent.
- */
-static char* get_user_agent(private_request_t *this)
+METHOD(request_t, get_user_agent, char*,
+ private_request_t *this)
{
char *agent = FCGX_GetParam("HTTP_USER_AGENT", this->req.envp);
return agent ? agent : "";
}
-/**
- * Implementation of request_t.get_post_data.
- */
-static char* get_query_data(private_request_t *this, char *name)
+METHOD(request_t, get_query_data, char*,
+ private_request_t *this, char *name)
{
return hdf_get_valuef(this->hdf, "Query.%s", name);
}
-/**
- * Implementation of request_t.get_env_var.
- */
-static char* get_env_var(private_request_t *this, char *name)
+METHOD(request_t, get_env_var, char*,
+ private_request_t *this, char *name)
{
return FCGX_GetParam(name, this->req.envp);
}
-/**
- * Implementation of request_t.read_data.
- */
-static int read_data(private_request_t *this, char *buf, int len)
+METHOD(request_t, read_data, int,
+ private_request_t *this, char *buf, int len)
{
return FCGX_GetStr(buf, len, this->req.in);
}
-/**
- * Implementation of request_t.get_base.
- */
-static char* get_base(private_request_t *this)
+METHOD(request_t, get_base, char*,
+ private_request_t *this)
{
return FCGX_GetParam("SCRIPT_NAME", this->req.envp);
}
-/**
- * Implementation of request_t.add_cookie.
- */
-static void add_cookie(private_request_t *this, char *name, char *value)
+METHOD(request_t, add_cookie, void,
+ private_request_t *this, char *name, char *value)
{
thread_this->set(thread_this, this);
- cgi_cookie_set (this->cgi, name, value, get_base(this), NULL, NULL, 0, 0);
+ cgi_cookie_set(this->cgi, name, value, NULL, NULL, NULL, 0, 0);
}
-/**
- * Implementation of request_t.redirect.
- */
-static void redirect(private_request_t *this, char *fmt, ...)
+METHOD(request_t, redirect, void,
+ private_request_t *this, char *fmt, ...)
{
va_list args;
@@ -252,18 +232,14 @@ static void redirect(private_request_t *this, char *fmt, ...)
FCGX_FPrintF(this->req.out, "\n\n");
}
-/**
- * Implementation of request_t.get_referer.
- */
-static char* get_referer(private_request_t *this)
+METHOD(request_t, get_referer, char*,
+ private_request_t *this)
{
return FCGX_GetParam("HTTP_REFERER", this->req.envp);
}
-/**
- * Implementation of request_t.to_referer.
- */
-static void to_referer(private_request_t *this)
+METHOD(request_t, to_referer, void,
+ private_request_t *this)
{
char *referer;
@@ -279,36 +255,28 @@ static void to_referer(private_request_t *this)
}
}
-/**
- * Implementation of request_t.session_closed.
- */
-static bool session_closed(private_request_t *this)
+METHOD(request_t, session_closed, bool,
+ private_request_t *this)
{
return this->closed;
}
-/**
- * Implementation of request_t.close_session.
- */
-static void close_session(private_request_t *this)
+METHOD(request_t, close_session, void,
+ private_request_t *this)
{
this->closed = TRUE;
}
-/**
- * Implementation of request_t.serve.
- */
-static void serve(private_request_t *this, char *headers, chunk_t chunk)
+METHOD(request_t, serve, void,
+ private_request_t *this, char *headers, chunk_t chunk)
{
FCGX_FPrintF(this->req.out, "%s\n\n", headers);
FCGX_PutStr(chunk.ptr, chunk.len, this->req.out);
}
-/**
- * Implementation of request_t.render.
- */
-static void render(private_request_t *this, char *template)
+METHOD(request_t, render, void,
+ private_request_t *this, char *template)
{
NEOERR* err;
@@ -319,13 +287,10 @@ static void render(private_request_t *this, char *template)
cgi_neo_error(this->cgi, err);
nerr_log_error(err);
}
- return;
}
-/**
- * Implementation of request_t.streamf.
- */
-static int streamf(private_request_t *this, char *format, ...)
+METHOD(request_t, streamf, int,
+ private_request_t *this, char *format, ...)
{
va_list args;
int written;
@@ -341,18 +306,14 @@ static int streamf(private_request_t *this, char *format, ...)
return written;
}
-/**
- * Implementation of request_t.set.
- */
-static void set(private_request_t *this, char *key, char *value)
+METHOD(request_t, set, void,
+ private_request_t *this, char *key, char *value)
{
hdf_set_value(this->hdf, key, value);
}
-/**
- * Implementation of request_t.setf.
- */
-static void setf(private_request_t *this, char *format, ...)
+METHOD(request_t, setf, void,
+ private_request_t *this, char *format, ...)
{
va_list args;
@@ -361,19 +322,15 @@ static void setf(private_request_t *this, char *format, ...)
va_end(args);
}
-/**
- * Implementation of request_t.get_ref.
- */
-static request_t* get_ref(private_request_t *this)
+METHOD(request_t, get_ref, request_t*,
+ private_request_t *this)
{
ref_get(&this->ref);
return &this->public;
}
-/**
- * Implementation of request_t.destroy
- */
-static void destroy(private_request_t *this)
+METHOD(request_t, destroy, void,
+ private_request_t *this)
{
if (ref_put(&this->ref))
{
@@ -401,9 +358,36 @@ static void init(void)
request_t *request_create(int fd, bool debug)
{
NEOERR* err;
- private_request_t *this = malloc_thing(private_request_t);
+ private_request_t *this;
bool failed = FALSE;
+ INIT(this,
+ .public = {
+ .get_path = _get_path,
+ .get_base = _get_base,
+ .get_host = _get_host,
+ .get_user_agent = _get_user_agent,
+ .add_cookie = _add_cookie,
+ .get_cookie = _get_cookie,
+ .get_query_data = _get_query_data,
+ .get_env_var = _get_env_var,
+ .read_data = _read_data,
+ .session_closed = _session_closed,
+ .close_session = _close_session,
+ .redirect = _redirect,
+ .get_referer = _get_referer,
+ .to_referer = _to_referer,
+ .render = _render,
+ .streamf = _streamf,
+ .serve = _serve,
+ .set = _set,
+ .setf = _setf,
+ .get_ref = _get_ref,
+ .destroy = _destroy,
+ },
+ .ref = 1,
+ );
+
thread_cleanup_push(free, this);
if (FCGX_InitRequest(&this->req, fd, 0) != 0 ||
FCGX_Accept_r(&this->req) != 0)
@@ -416,34 +400,9 @@ request_t *request_create(int fd, bool debug)
return NULL;
}
- this->public.get_path = (char*(*)(request_t*))get_path;
- this->public.get_base = (char*(*)(request_t*))get_base;
- this->public.get_host = (char*(*)(request_t*))get_host;
- this->public.get_user_agent = (char*(*)(request_t*))get_user_agent;
- this->public.add_cookie = (void(*)(request_t*, char *name, char *value))add_cookie;
- this->public.get_cookie = (char*(*)(request_t*,char*))get_cookie;
- this->public.get_query_data = (char*(*)(request_t*, char *name))get_query_data;
- this->public.get_env_var = (char*(*)(request_t*, char *name))get_env_var;
- this->public.read_data = (int(*)(request_t*, char*, int))read_data;
- this->public.session_closed = (bool(*)(request_t*))session_closed;
- this->public.close_session = (void(*)(request_t*))close_session;
- this->public.redirect = (void(*)(request_t*, char *fmt,...))redirect;
- this->public.get_referer = (char*(*)(request_t*))get_referer;
- this->public.to_referer = (void(*)(request_t*))to_referer;
- this->public.render = (void(*)(request_t*,char*))render;
- this->public.streamf = (int(*)(request_t*, char *format, ...))streamf;
- this->public.serve = (void(*)(request_t*,char*,chunk_t))serve;
- this->public.set = (void(*)(request_t*, char *, char*))set;
- this->public.setf = (void(*)(request_t*, char *format, ...))setf;
- this->public.get_ref = (request_t*(*)(request_t*))get_ref;
- this->public.destroy = (void(*)(request_t*))destroy;
-
pthread_once(&once, init);
thread_this->set(thread_this, this);
- this->ref = 1;
- this->closed = FALSE;
- this->req_env_len = 0;
while (this->req.envp[this->req_env_len] != NULL)
{
this->req_env_len++;
diff --git a/src/libfast/session.c b/src/libfast/session.c
index 7c4548ee5..1d9ed0107 100644
--- a/src/libfast/session.c
+++ b/src/libfast/session.c
@@ -63,18 +63,14 @@ struct private_session_t {
context_t *context;
};
-/**
- * Implementation of session_t.add_controller.
- */
-static void add_controller(private_session_t *this, controller_t *controller)
+METHOD(session_t, add_controller, void,
+ private_session_t *this, controller_t *controller)
{
this->controllers->insert_last(this->controllers, controller);
}
-/**
- * Implementation of session_t.add_filter.
- */
-static void add_filter(private_session_t *this, filter_t *filter)
+METHOD(session_t, add_filter, void,
+ private_session_t *this, filter_t *filter)
{
this->filters->insert_last(this->filters, filter);
}
@@ -120,10 +116,8 @@ static bool run_filter(private_session_t *this, request_t *request, char *p0,
return TRUE;
}
-/**
- * Implementation of session_t.process.
- */
-static void process(private_session_t *this, request_t *request)
+METHOD(session_t, process, void,
+ private_session_t *this, request_t *request)
{
char *pos, *start, *param[6] = {NULL, NULL, NULL, NULL, NULL, NULL};
enumerator_t *enumerator;
@@ -184,18 +178,14 @@ static void process(private_session_t *this, request_t *request)
}
}
-/**
- * Implementation of session_t.get_sid.
- */
-static char* get_sid(private_session_t *this)
+METHOD(session_t, get_sid, char*,
+ private_session_t *this)
{
return this->sid;
}
-/**
- * Implementation of session_t.destroy
- */
-static void destroy(private_session_t *this)
+METHOD(session_t, destroy, void,
+ private_session_t *this)
{
this->controllers->destroy_offset(this->controllers, offsetof(controller_t, destroy));
this->filters->destroy_offset(this->filters, offsetof(filter_t, destroy));
@@ -208,19 +198,21 @@ static void destroy(private_session_t *this)
*/
session_t *session_create(context_t *context)
{
- private_session_t *this = malloc_thing(private_session_t);
-
- this->public.add_controller = (void(*)(session_t*, controller_t*))add_controller;
- this->public.add_filter = (void(*)(session_t*, filter_t*))add_filter;
- this->public.process = (void(*)(session_t*,request_t*))process;
- this->public.get_sid = (char*(*)(session_t*))get_sid;
- this->public.destroy = (void(*)(session_t*))destroy;
-
+ private_session_t *this;
+
+ INIT(this,
+ .public = {
+ .add_controller = _add_controller,
+ .add_filter = _add_filter,
+ .process = _process,
+ .get_sid = _get_sid,
+ .destroy = _destroy,
+ },
+ .controllers = linked_list_create(),
+ .filters = linked_list_create(),
+ .context = context,
+ );
create_sid(this);
- this->cookie_sent = FALSE;
- this->controllers = linked_list_create();
- this->filters = linked_list_create();
- this->context = context;
return &this->public;
}
diff --git a/src/libfast/session.h b/src/libfast/session.h
index c6633f9ae..f60fa9ef2 100644
--- a/src/libfast/session.h
+++ b/src/libfast/session.h
@@ -62,8 +62,6 @@ struct session_t {
/**
* Destroy the session_t.
- *
- * @param this calling object
*/
void (*destroy) (session_t *this);
};
diff --git a/src/libfast/smtp.h b/src/libfast/smtp.h
index 910f18127..9589ea2a6 100644
--- a/src/libfast/smtp.h
+++ b/src/libfast/smtp.h
@@ -34,7 +34,7 @@ struct smtp_t {
* Send an e-mail message.
*
* @param from sender address
- * @param to receipient address
+ * @param to recipient address
* @param subject mail subject
* @param fmt mail body format string
* @param ... arguments for body format string