summaryrefslogtreecommitdiff
path: root/src/libfast
diff options
context:
space:
mode:
Diffstat (limited to 'src/libfast')
-rw-r--r--src/libfast/Makefile.am21
-rw-r--r--src/libfast/Makefile.in225
-rw-r--r--src/libfast/fast_context.h (renamed from src/libfast/context.h)18
-rw-r--r--src/libfast/fast_controller.h (renamed from src/libfast/controller.h)25
-rw-r--r--src/libfast/fast_dispatcher.c (renamed from src/libfast/dispatcher.c)96
-rw-r--r--src/libfast/fast_dispatcher.h (renamed from src/libfast/dispatcher.h)46
-rw-r--r--src/libfast/fast_filter.h (renamed from src/libfast/filter.h)25
-rw-r--r--src/libfast/fast_request.c (renamed from src/libfast/request.c)182
-rw-r--r--src/libfast/fast_request.h (renamed from src/libfast/request.h)65
-rw-r--r--src/libfast/fast_session.c (renamed from src/libfast/session.c)71
-rw-r--r--src/libfast/fast_session.h (renamed from src/libfast/session.h)31
-rw-r--r--src/libfast/fast_smtp.c (renamed from src/libfast/smtp.c)42
-rw-r--r--src/libfast/fast_smtp.h (renamed from src/libfast/smtp.h)20
13 files changed, 551 insertions, 316 deletions
diff --git a/src/libfast/Makefile.am b/src/libfast/Makefile.am
index 35d102109..edc2ab1ca 100644
--- a/src/libfast/Makefile.am
+++ b/src/libfast/Makefile.am
@@ -1,8 +1,21 @@
+AM_CPPFLAGS = \
+ -I$(top_srcdir)/src/libstrongswan \
+ -I/usr/include/ClearSilver
+
+AM_CFLAGS = \
+ -rdynamic
+
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_SOURCES = \
+ fast_dispatcher.c fast_request.c fast_session.c fast_smtp.c
+
+if USE_DEV_HEADERS
+fast_includedir = ${dev_headers}/fast
+nobase_fast_include_HEADERS = \
+ fast_context.h fast_controller.h fast_dispatcher.h fast_filter.h \
+ fast_request.h fast_session.h fast_smtp.h
+endif
+
libfast_la_LIBADD = $(top_builddir)/src/libstrongswan/libstrongswan.la \
-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 abb721758..d5b511e56 100644
--- a/src/libfast/Makefile.in
+++ b/src/libfast/Makefile.in
@@ -1,9 +1,9 @@
-# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# Makefile.in generated by automake 1.11.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
-# Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@@ -15,7 +15,25 @@
@SET_MAKE@
+
VPATH = @srcdir@
+am__make_dryrun = \
+ { \
+ am__dry=no; \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
+ | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
+ *) \
+ for am__flg in $$MAKEFLAGS; do \
+ case $$am__flg in \
+ *=*|--*) ;; \
+ *n*) am__dry=yes; break;; \
+ esac; \
+ done;; \
+ esac; \
+ test $$am__dry = yes; \
+ }
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
@@ -35,7 +53,8 @@ POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = src/libfast
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+DIST_COMMON = $(am__nobase_fast_include_HEADERS_DIST) \
+ $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/config/libtool.m4 \
$(top_srcdir)/m4/config/ltoptions.m4 \
@@ -45,10 +64,11 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/config/libtool.m4 \
$(top_srcdir)/m4/macros/with.m4 \
$(top_srcdir)/m4/macros/enable-disable.m4 \
$(top_srcdir)/m4/macros/add-plugin.m4 \
- $(top_srcdir)/configure.in
+ $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
@@ -72,50 +92,90 @@ 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)$(ipseclibdir)"
+am__uninstall_files_from_dir = { \
+ test -z "$$files" \
+ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+ $(am__cd) "$$dir" && rm -f $$files; }; \
+ }
+am__installdirs = "$(DESTDIR)$(ipseclibdir)" \
+ "$(DESTDIR)$(fast_includedir)"
LTLIBRARIES = $(ipseclib_LTLIBRARIES)
am__DEPENDENCIES_1 =
libfast_la_DEPENDENCIES = \
$(top_builddir)/src/libstrongswan/libstrongswan.la \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
-am_libfast_la_OBJECTS = dispatcher.lo request.lo session.lo smtp.lo
+am_libfast_la_OBJECTS = fast_dispatcher.lo fast_request.lo \
+ fast_session.lo fast_smtp.lo
libfast_la_OBJECTS = $(am_libfast_la_OBJECTS)
-DEFAULT_INCLUDES = -I.@am__isrc@
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
- --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
- $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo " CC " $@;
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
CCLD = $(CC)
-LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
- --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
- $(LDFLAGS) -o $@
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo " CCLD " $@;
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
SOURCES = $(libfast_la_SOURCES)
DIST_SOURCES = $(libfast_la_SOURCES)
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+am__nobase_fast_include_HEADERS_DIST = fast_context.h \
+ fast_controller.h fast_dispatcher.h fast_filter.h \
+ fast_request.h fast_session.h fast_smtp.h
+HEADERS = $(nobase_fast_include_HEADERS)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
ALLOCA = @ALLOCA@
AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
+BFDLIB = @BFDLIB@
BTLIB = @BTLIB@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
+CHECK_CFLAGS = @CHECK_CFLAGS@
+CHECK_LIBS = @CHECK_LIBS@
+COVERAGE_CFLAGS = @COVERAGE_CFLAGS@
+COVERAGE_LDFLAGS = @COVERAGE_LDFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLIB = @DLLIB@
+DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -124,13 +184,16 @@ ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
+GENHTML = @GENHTML@
GPERF = @GPERF@
+GPRBUILD = @GPRBUILD@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LCOV = @LCOV@
LD = @LD@
LDFLAGS = @LDFLAGS@
LEX = @LEX@
@@ -143,6 +206,7 @@ LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MYSQLCFLAG = @MYSQLCFLAG@
MYSQLCONFIG = @MYSQLCONFIG@
@@ -170,11 +234,13 @@ RANLIB = @RANLIB@
RTLIB = @RTLIB@
RUBY = @RUBY@
RUBYINCLUDE = @RUBYINCLUDE@
+RUBYLIB = @RUBYLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SOCKLIB = @SOCKLIB@
STRIP = @STRIP@
+UNWINDLIB = @UNWINDLIB@
VERSION = @VERSION@
YACC = @YACC@
YFLAGS = @YFLAGS@
@@ -182,6 +248,7 @@ abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
@@ -190,8 +257,6 @@ 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@
@@ -200,14 +265,19 @@ build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
c_plugins = @c_plugins@
+charon_natt_port = @charon_natt_port@
+charon_plugins = @charon_plugins@
+charon_udp_port = @charon_udp_port@
clearsilver_LIBS = @clearsilver_LIBS@
+cmd_plugins = @cmd_plugins@
datadir = @datadir@
datarootdir = @datarootdir@
dbusservicedir = @dbusservicedir@
-default_pkcs11 = @default_pkcs11@
+dev_headers = @dev_headers@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
+fips_mode = @fips_mode@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
h_plugins = @h_plugins@
@@ -221,17 +291,17 @@ imcvdir = @imcvdir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
+ipsec_script = @ipsec_script@
+ipsec_script_upper = @ipsec_script_upper@
ipsecdir = @ipsecdir@
ipsecgroup = @ipsecgroup@
ipseclibdir = @ipseclibdir@
ipsecuser = @ipsecuser@
-libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
libexecdir = @libexecdir@
linux_headers = @linux_headers@
localedir = @localedir@
localstatedir = @localstatedir@
-lt_ECHO = @lt_ECHO@
maemo_CFLAGS = @maemo_CFLAGS@
maemo_LIBS = @maemo_LIBS@
manager_plugins = @manager_plugins@
@@ -241,16 +311,15 @@ mkdir_p = @mkdir_p@
nm_CFLAGS = @nm_CFLAGS@
nm_LIBS = @nm_LIBS@
nm_ca_dir = @nm_ca_dir@
+nm_plugins = @nm_plugins@
oldincludedir = @oldincludedir@
openac_plugins = @openac_plugins@
-p_plugins = @p_plugins@
pcsclite_CFLAGS = @pcsclite_CFLAGS@
pcsclite_LIBS = @pcsclite_LIBS@
pdfdir = @pdfdir@
piddir = @piddir@
pki_plugins = @pki_plugins@
plugindir = @plugindir@
-pluto_plugins = @pluto_plugins@
pool_plugins = @pool_plugins@
prefix = @prefix@
program_transform_name = @program_transform_name@
@@ -278,15 +347,25 @@ top_srcdir = @top_srcdir@
urandom_device = @urandom_device@
xml_CFLAGS = @xml_CFLAGS@
xml_LIBS = @xml_LIBS@
+AM_CPPFLAGS = \
+ -I$(top_srcdir)/src/libstrongswan \
+ -I/usr/include/ClearSilver
+
+AM_CFLAGS = \
+ -rdynamic
+
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_SOURCES = \
+ fast_dispatcher.c fast_request.c fast_session.c fast_smtp.c
+
+@USE_DEV_HEADERS_TRUE@fast_includedir = ${dev_headers}/fast
+@USE_DEV_HEADERS_TRUE@nobase_fast_include_HEADERS = \
+@USE_DEV_HEADERS_TRUE@ fast_context.h fast_controller.h fast_dispatcher.h fast_filter.h \
+@USE_DEV_HEADERS_TRUE@ fast_request.h fast_session.h fast_smtp.h
libfast_la_LIBADD = $(top_builddir)/src/libstrongswan/libstrongswan.la \
-lfcgi $(clearsilver_LIBS) $(PTHREADLIB)
-INCLUDES = -I$(top_srcdir)/src/libstrongswan -I/usr/include/ClearSilver
-AM_CFLAGS = -rdynamic
all: all-am
.SUFFIXES:
@@ -323,7 +402,6 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps)
$(am__aclocal_m4_deps):
install-ipseclibLTLIBRARIES: $(ipseclib_LTLIBRARIES)
@$(NORMAL_INSTALL)
- 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 \
@@ -331,6 +409,8 @@ install-ipseclibLTLIBRARIES: $(ipseclib_LTLIBRARIES)
else :; fi; \
done; \
test -z "$$list2" || { \
+ echo " $(MKDIR_P) '$(DESTDIR)$(ipseclibdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(ipseclibdir)" || exit 1; \
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)"; \
}
@@ -352,8 +432,8 @@ clean-ipseclibLTLIBRARIES:
echo "rm -f \"$${dir}/so_locations\""; \
rm -f "$${dir}/so_locations"; \
done
-libfast.la: $(libfast_la_OBJECTS) $(libfast_la_DEPENDENCIES)
- $(LINK) -rpath $(ipseclibdir) $(libfast_la_OBJECTS) $(libfast_la_LIBADD) $(LIBS)
+libfast.la: $(libfast_la_OBJECTS) $(libfast_la_DEPENDENCIES) $(EXTRA_libfast_la_DEPENDENCIES)
+ $(AM_V_CCLD)$(LINK) -rpath $(ipseclibdir) $(libfast_la_OBJECTS) $(libfast_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@@ -361,37 +441,61 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dispatcher.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/request.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/session.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/smtp.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fast_dispatcher.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fast_request.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fast_session.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fast_smtp.Plo@am__quote@
.c.o:
-@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $<
.c.obj:
-@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
.c.lo:
-@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
+install-nobase_fast_includeHEADERS: $(nobase_fast_include_HEADERS)
+ @$(NORMAL_INSTALL)
+ @list='$(nobase_fast_include_HEADERS)'; test -n "$(fast_includedir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(fast_includedir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(fast_includedir)" || exit 1; \
+ fi; \
+ $(am__nobase_list) | while read dir files; do \
+ xfiles=; for file in $$files; do \
+ if test -f "$$file"; then xfiles="$$xfiles $$file"; \
+ else xfiles="$$xfiles $(srcdir)/$$file"; fi; done; \
+ test -z "$$xfiles" || { \
+ test "x$$dir" = x. || { \
+ echo " $(MKDIR_P) '$(DESTDIR)$(fast_includedir)/$$dir'"; \
+ $(MKDIR_P) "$(DESTDIR)$(fast_includedir)/$$dir"; }; \
+ echo " $(INSTALL_HEADER) $$xfiles '$(DESTDIR)$(fast_includedir)/$$dir'"; \
+ $(INSTALL_HEADER) $$xfiles "$(DESTDIR)$(fast_includedir)/$$dir" || exit $$?; }; \
+ done
+
+uninstall-nobase_fast_includeHEADERS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(nobase_fast_include_HEADERS)'; test -n "$(fast_includedir)" || list=; \
+ $(am__nobase_strip_setup); files=`$(am__nobase_strip)`; \
+ dir='$(DESTDIR)$(fast_includedir)'; $(am__uninstall_files_from_dir)
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
@@ -477,9 +581,9 @@ distdir: $(DISTFILES)
done
check-am: all-am
check: check-am
-all-am: Makefile $(LTLIBRARIES)
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
installdirs:
- for dir in "$(DESTDIR)$(ipseclibdir)"; do \
+ for dir in "$(DESTDIR)$(ipseclibdir)" "$(DESTDIR)$(fast_includedir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
@@ -492,10 +596,15 @@ install-am: all-am
installcheck: installcheck-am
install-strip:
- $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
- install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
- `test -z '$(STRIP)' || \
- echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
mostlyclean-generic:
clean-generic:
@@ -530,7 +639,8 @@ info: info-am
info-am:
-install-data-am: install-ipseclibLTLIBRARIES
+install-data-am: install-ipseclibLTLIBRARIES \
+ install-nobase_fast_includeHEADERS
install-dvi: install-dvi-am
@@ -576,7 +686,8 @@ ps: ps-am
ps-am:
-uninstall-am: uninstall-ipseclibLTLIBRARIES
+uninstall-am: uninstall-ipseclibLTLIBRARIES \
+ uninstall-nobase_fast_includeHEADERS
.MAKE: install-am install-strip
@@ -587,12 +698,14 @@ uninstall-am: uninstall-ipseclibLTLIBRARIES
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-ipseclibLTLIBRARIES 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-nobase_fast_includeHEADERS 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-ipseclibLTLIBRARIES
+ tags uninstall uninstall-am uninstall-ipseclibLTLIBRARIES \
+ uninstall-nobase_fast_includeHEADERS
# Tell versions [3.59,3.63) of GNU make to not export all variables.
diff --git a/src/libfast/context.h b/src/libfast/fast_context.h
index 4f8d11d2c..4922703ca 100644
--- a/src/libfast/context.h
+++ b/src/libfast/fast_context.h
@@ -14,29 +14,29 @@
*/
/**
- * @defgroup context context
+ * @defgroup fast_context fast_context
* @{ @ingroup libfast
*/
-#ifndef CONTEXT_H_
-#define CONTEXT_H_
+#ifndef FAST_CONTEXT_H_
+#define FAST_CONTEXT_H_
-typedef struct context_t context_t;
+typedef struct fast_context_t fast_context_t;
/**
* Constructor function for a user specific context.
*/
-typedef context_t *(*context_constructor_t)(void *param);
+typedef fast_context_t *(*fast_context_constructor_t)(void *param);
/**
* User specific session context, to extend.
*/
-struct context_t {
+struct fast_context_t {
/**
- * Destroy the context_t.
+ * Destroy the fast_context_t.
*/
- void (*destroy) (context_t *this);
+ void (*destroy) (fast_context_t *this);
};
-#endif /** CONTEXT_H_ @}*/
+#endif /** FAST_CONTEXT_H_ @}*/
diff --git a/src/libfast/controller.h b/src/libfast/fast_controller.h
index 1edf72e90..bbd0214fc 100644
--- a/src/libfast/controller.h
+++ b/src/libfast/fast_controller.h
@@ -14,17 +14,17 @@
*/
/**
- * @defgroup controller_i controller
+ * @defgroup fast_controller fast_controller
* @{ @ingroup libfast
*/
-#ifndef CONTROLLER_H_
-#define CONTROLLER_H_
+#ifndef FAST_CONTROLLER_H_
+#define FAST_CONTROLLER_H_
-#include "request.h"
-#include "context.h"
+#include "fast_request.h"
+#include "fast_context.h"
-typedef struct controller_t controller_t;
+typedef struct fast_controller_t fast_controller_t;
/**
* Constructor function for a controller.
@@ -32,7 +32,8 @@ typedef struct controller_t controller_t;
* @param context session specific context, implements context_t
* @param param user supplied param, as registered to the dispatcher
*/
-typedef controller_t *(*controller_constructor_t)(context_t* context, void *param);
+typedef fast_controller_t *(*fast_controller_constructor_t)(
+ fast_context_t* context, void *param);
/**
* Controller interface, to be implemented by users controllers.
@@ -41,14 +42,14 @@ typedef controller_t *(*controller_constructor_t)(context_t* context, void *para
* associated set of private controller instances.
* The controller handle function is called for each incoming request.
*/
-struct controller_t {
+struct fast_controller_t {
/**
* Get the name of the controller.
*
* @return name of the controller
*/
- char* (*get_name)(controller_t *this);
+ char* (*get_name)(fast_controller_t *this);
/**
* Handle a HTTP request for that controller.
@@ -65,13 +66,13 @@ struct controller_t {
* @param p5 fifth parameter
* @return
*/
- void (*handle)(controller_t *this, request_t *request,
+ void (*handle)(fast_controller_t *this, fast_request_t *request,
char *p1, char *p2, char *p3, char *p4, char *p5);
/**
* Destroy the controller instance.
*/
- void (*destroy) (controller_t *this);
+ void (*destroy) (fast_controller_t *this);
};
-#endif /** CONTROLLER_H_ @}*/
+#endif /** FAST_CONTROLLER_H_ @}*/
diff --git a/src/libfast/dispatcher.c b/src/libfast/fast_dispatcher.c
index e5fca7074..4daf91905 100644
--- a/src/libfast/dispatcher.c
+++ b/src/libfast/fast_dispatcher.c
@@ -13,36 +13,36 @@
* for more details.
*/
-#include "dispatcher.h"
+#include "fast_dispatcher.h"
-#include "request.h"
-#include "session.h"
+#include "fast_request.h"
+#include "fast_session.h"
#include <fcgiapp.h>
#include <signal.h>
#include <unistd.h>
-#include <debug.h>
+#include <utils/debug.h>
#include <threading/thread.h>
#include <threading/condvar.h>
#include <threading/mutex.h>
-#include <utils/linked_list.h>
-#include <utils/hashtable.h>
+#include <collections/linked_list.h>
+#include <collections/hashtable.h>
/** Intervall to check for expired sessions, in seconds */
#define CLEANUP_INTERVAL 30
-typedef struct private_dispatcher_t private_dispatcher_t;
+typedef struct private_fast_dispatcher_t private_fast_dispatcher_t;
/**
* private data of the task manager
*/
-struct private_dispatcher_t {
+struct private_fast_dispatcher_t {
/**
* public functions
*/
- dispatcher_t public;
+ fast_dispatcher_t public;
/**
* fcgi socket fd
@@ -97,7 +97,7 @@ struct private_dispatcher_t {
/**
* constructor function to create session context (in controller_entry_t)
*/
- context_constructor_t context_constructor;
+ fast_context_constructor_t context_constructor;
/**
* user param to context constructor
@@ -107,21 +107,21 @@ struct private_dispatcher_t {
typedef struct {
/** constructor function */
- controller_constructor_t constructor;
+ fast_controller_constructor_t constructor;
/** parameter to constructor */
void *param;
} controller_entry_t;
typedef struct {
/** constructor function */
- filter_constructor_t constructor;
+ fast_filter_constructor_t constructor;
/** parameter to constructor */
void *param;
} filter_entry_t;
typedef struct {
/** session instance */
- session_t *session;
+ fast_session_t *session;
/** condvar to wait for session */
condvar_t *cond;
/** client host address, to prevent session hijacking */
@@ -137,21 +137,25 @@ typedef struct {
/**
* create a session and instanciate controllers
*/
-static session_t* load_session(private_dispatcher_t *this)
+static fast_session_t* load_session(private_fast_dispatcher_t *this)
{
enumerator_t *enumerator;
controller_entry_t *centry;
filter_entry_t *fentry;
- session_t *session;
- context_t *context = NULL;
- controller_t *controller;
- filter_t *filter;
+ fast_session_t *session;
+ fast_context_t *context = NULL;
+ fast_controller_t *controller;
+ fast_filter_t *filter;
if (this->context_constructor)
{
context = this->context_constructor(this->param);
}
- session = session_create(context);
+ session = fast_session_create(context);
+ if (!session)
+ {
+ return NULL;
+ }
enumerator = this->controllers->create_enumerator(this->controllers);
while (enumerator->enumerate(enumerator, &centry))
@@ -175,14 +179,20 @@ static session_t* load_session(private_dispatcher_t *this)
/**
* create a new session entry
*/
-static session_entry_t *session_entry_create(private_dispatcher_t *this,
+static session_entry_t *session_entry_create(private_fast_dispatcher_t *this,
char *host)
{
session_entry_t *entry;
+ fast_session_t *session;
+ session = load_session(this);
+ if (!session)
+ {
+ return NULL;
+ }
INIT(entry,
.cond = condvar_create(CONDVAR_TYPE_DEFAULT),
- .session = load_session(this),
+ .session = session,
.host = strdup(host),
.used = time_monotonic(NULL),
);
@@ -200,8 +210,8 @@ static void session_entry_destroy(session_entry_t *entry)
free(entry);
}
-METHOD(dispatcher_t, add_controller, void,
- private_dispatcher_t *this, controller_constructor_t constructor,
+METHOD(fast_dispatcher_t, add_controller, void,
+ private_fast_dispatcher_t *this, fast_controller_constructor_t constructor,
void *param)
{
controller_entry_t *entry;
@@ -213,8 +223,9 @@ METHOD(dispatcher_t, add_controller, void,
this->controllers->insert_last(this->controllers, entry);
}
-METHOD(dispatcher_t, add_filter, void,
- private_dispatcher_t *this, filter_constructor_t constructor, void *param)
+METHOD(fast_dispatcher_t, add_filter, void,
+ private_fast_dispatcher_t *this, fast_filter_constructor_t constructor,
+ void *param)
{
filter_entry_t *entry;
@@ -244,7 +255,7 @@ static bool session_equals(char *sid1, char *sid2)
/**
* Cleanup unused sessions
*/
-static void cleanup_sessions(private_dispatcher_t *this, time_t now)
+static void cleanup_sessions(private_fast_dispatcher_t *this, time_t now)
{
if (this->last_cleanup < now - CLEANUP_INTERVAL)
{
@@ -282,24 +293,24 @@ static void cleanup_sessions(private_dispatcher_t *this, time_t now)
/**
* Actual dispatching code
*/
-static void dispatch(private_dispatcher_t *this)
+static void dispatch(private_fast_dispatcher_t *this)
{
thread_cancelability(FALSE);
while (TRUE)
{
- request_t *request;
+ fast_request_t *request;
session_entry_t *found = NULL;
time_t now;
char *sid;
thread_cancelability(TRUE);
- request = request_create(this->fd, this->debug);
+ request = fast_request_create(this->fd, this->debug);
thread_cancelability(FALSE);
if (request == NULL)
{
- continue;
+ break;
}
now = time_monotonic(NULL);
sid = request->get_cookie(request, "SID");
@@ -324,6 +335,12 @@ static void dispatch(private_dispatcher_t *this)
else
{ /* create a new session if not found */
found = session_entry_create(this, request->get_host(request));
+ if (!found)
+ {
+ request->destroy(request);
+ this->mutex->unlock(this->mutex);
+ continue;
+ }
sid = found->session->get_sid(found->session);
this->sessions->put(this->sessions, sid, found);
}
@@ -346,8 +363,8 @@ static void dispatch(private_dispatcher_t *this)
}
}
-METHOD(dispatcher_t, run, void,
- private_dispatcher_t *this, int threads)
+METHOD(fast_dispatcher_t, run, void,
+ private_fast_dispatcher_t *this, int threads)
{
this->thread_count = threads;
this->threads = malloc(sizeof(thread_t*) * threads);
@@ -362,8 +379,8 @@ METHOD(dispatcher_t, run, void,
}
}
-METHOD(dispatcher_t, waitsignal, void,
- private_dispatcher_t *this)
+METHOD(fast_dispatcher_t, waitsignal, void,
+ private_fast_dispatcher_t *this)
{
sigset_t set;
int sig;
@@ -376,8 +393,8 @@ METHOD(dispatcher_t, waitsignal, void,
sigwait(&set, &sig);
}
-METHOD(dispatcher_t, destroy, void,
- private_dispatcher_t *this)
+METHOD(fast_dispatcher_t, destroy, void,
+ private_fast_dispatcher_t *this)
{
char *sid;
session_entry_t *entry;
@@ -407,10 +424,10 @@ METHOD(dispatcher_t, destroy, void,
/*
* see header file
*/
-dispatcher_t *dispatcher_create(char *socket, bool debug, int timeout,
- context_constructor_t constructor, void *param)
+fast_dispatcher_t *fast_dispatcher_create(char *socket, bool debug, int timeout,
+ fast_context_constructor_t constructor, void *param)
{
- private_dispatcher_t *this;
+ private_fast_dispatcher_t *this;
INIT(this,
.public = {
@@ -441,4 +458,3 @@ dispatcher_t *dispatcher_create(char *socket, bool debug, int timeout,
}
return &this->public;
}
-
diff --git a/src/libfast/dispatcher.h b/src/libfast/fast_dispatcher.h
index 16223fe76..6546385c6 100644
--- a/src/libfast/dispatcher.h
+++ b/src/libfast/fast_dispatcher.h
@@ -28,20 +28,20 @@
* The session context is instanciated per session. Sessions are managed
* automatically through session cookies. The session context is kept alive
* until the session times out. It must implement the context_t interface and
- * a #context_constructor_t is needed to create instances. To each session,
+ * a #fast_context_constructor_t is needed to create instances. To each session,
* a set of controllers gets instanciated. The controller instances are per
* session, so you can hold private data for each user.
* Controllers need to implement the controller_t interface and need a
- * #controller_constructor_t function to create instances.
+ * #fast_controller_constructor_t function to create instances.
*
* A small example shows how to set up libfast:
* @code
- dispatcher_t *dispatcher;
+ fast_fast_dispatcher_t *dispatcher;
your_global_context_implementation_t *global;
global = initialize_your_global_context();
- dispatcher = dispatcher_create(NULL, FALSE, 180,
+ dispatcher = fast_dispatcher_create(NULL, FALSE, 180,
(context_constructor_t)your_session_context_create, global);
dispatcher->add_controller(dispatcher, your_controller1_create, param1);
dispatcher->add_controller(dispatcher, your_controller2_create, param2);
@@ -55,17 +55,17 @@
@endcode
* @}
*
- * @defgroup dispatcher dispatcher
+ * @defgroup fast_dispatcher fast_dispatcher
* @{ @ingroup libfast
*/
-#ifndef DISPATCHER_H_
-#define DISPATCHER_H_
+#ifndef FAST_DISPATCHER_H_
+#define FAST_DISPATCHER_H_
-#include "controller.h"
-#include "filter.h"
+#include "fast_controller.h"
+#include "fast_filter.h"
-typedef struct dispatcher_t dispatcher_t;
+typedef struct fast_dispatcher_t fast_dispatcher_t;
/**
* Dispatcher, accepts connections using multiple threads.
@@ -75,7 +75,7 @@ typedef struct dispatcher_t dispatcher_t;
* Each controller is instanciated in the session using the controller
* constructor added with add_controller.
*/
-struct dispatcher_t {
+struct fast_dispatcher_t {
/**
* Register a controller to the dispatcher.
@@ -86,8 +86,9 @@ struct dispatcher_t {
* @param constructor constructor function to the conntroller
* @param param param to pass to constructor
*/
- void (*add_controller)(dispatcher_t *this,
- controller_constructor_t constructor, void *param);
+ void (*add_controller)(fast_dispatcher_t *this,
+ fast_controller_constructor_t constructor,
+ void *param);
/**
* Add a filter to the dispatcher.
@@ -95,8 +96,8 @@ struct dispatcher_t {
* @param constructor constructor to create filter in session
* @param param param to pass to constructor
*/
- void (*add_filter)(dispatcher_t *this,
- filter_constructor_t constructor, void *param);
+ void (*add_filter)(fast_dispatcher_t *this,
+ fast_filter_constructor_t constructor, void *param);
/**
* Start with dispatching.
@@ -105,18 +106,17 @@ struct dispatcher_t {
*
* @param threads number of dispatching threads
*/
- void (*run)(dispatcher_t *this, int threads);
+ void (*run)(fast_dispatcher_t *this, int threads);
/**
* Wait for a relevant signal action.
- *
*/
- void (*waitsignal)(dispatcher_t *this);
+ void (*waitsignal)(fast_dispatcher_t *this);
/**
- * Destroy the dispatcher_t.
+ * Destroy the fast_dispatcher_t.
*/
- void (*destroy) (dispatcher_t *this);
+ void (*destroy) (fast_dispatcher_t *this);
};
/**
@@ -131,7 +131,7 @@ struct dispatcher_t {
* @param constructor construction function for session context
* @param param parameter to supply to context constructor
*/
-dispatcher_t *dispatcher_create(char *socket, bool debug, int timeout,
- context_constructor_t constructor, void *param);
+fast_dispatcher_t *fast_dispatcher_create(char *socket, bool debug, int timeout,
+ fast_context_constructor_t constructor, void *param);
-#endif /** DISPATCHER_H_ @}*/
+#endif /** FAST_DISPATCHER_H_ @}*/
diff --git a/src/libfast/filter.h b/src/libfast/fast_filter.h
index 305a8bb6e..57367bd5a 100644
--- a/src/libfast/filter.h
+++ b/src/libfast/fast_filter.h
@@ -14,18 +14,18 @@
*/
/*
- * @defgroup filter filter
+ * @defgroup fast_filter fast_filter
* @{ @ingroup libfast
*/
-#ifndef FILTER_H_
-#define FILTER_H_
+#ifndef FAST_FILTER_H_
+#define FAST_FILTER_H_
-#include "request.h"
-#include "context.h"
-#include "controller.h"
+#include "fast_request.h"
+#include "fast_context.h"
+#include "fast_controller.h"
-typedef struct filter_t filter_t;
+typedef struct fast_filter_t fast_filter_t;
/**
* Constructor function for a filter
@@ -33,12 +33,13 @@ typedef struct filter_t filter_t;
* @param context session specific context
* @param param user supplied param
*/
-typedef filter_t *(*filter_constructor_t)(context_t* context, void *param);
+typedef fast_filter_t *(*fast_filter_constructor_t)(fast_context_t* context,
+ void *param);
/**
* Filter interface, to be implemented by users filters.
*/
-struct filter_t {
+struct fast_filter_t {
/**
* Called before the controller handles the request.
@@ -51,13 +52,13 @@ struct filter_t {
* @param p5 fifth parameter
* @return TRUE to continue request handling
*/
- bool (*run)(filter_t *this, request_t *request,
+ bool (*run)(fast_filter_t *this, fast_request_t *request,
char *p0, char *p1, char *p2, char *p3, char *p4, char *p5);
/**
* Destroy the filter instance.
*/
- void (*destroy) (filter_t *this);
+ void (*destroy) (fast_filter_t *this);
};
-#endif /* FILTER_H_ @} */
+#endif /* FAST_FILTER_H_ @} */
diff --git a/src/libfast/request.c b/src/libfast/fast_request.c
index 3acd831b2..0673750b7 100644
--- a/src/libfast/request.c
+++ b/src/libfast/fast_request.c
@@ -15,29 +15,34 @@
#define _GNU_SOURCE
-#include "request.h"
+#include "fast_request.h"
#include <library.h>
-#include <debug.h>
+#include <utils/debug.h>
#include <stdlib.h>
#include <pthread.h>
#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
#include <ClearSilver/ClearSilver.h>
#include <threading/thread.h>
#include <threading/thread_value.h>
-typedef struct private_request_t private_request_t;
+typedef struct private_fast_request_t private_fast_request_t;
/**
* private data of the task manager
*/
-struct private_request_t {
+struct private_fast_request_t {
/**
* public functions
*/
- request_t public;
+ fast_request_t public;
/**
* FastCGI request object
@@ -86,7 +91,9 @@ pthread_once_t once = PTHREAD_ONCE_INIT;
*/
static int read_cb(void *null, char *buf, int size)
{
- private_request_t *this = (private_request_t*)thread_this->get(thread_this);
+ private_fast_request_t *this;
+
+ this = (private_fast_request_t*)thread_this->get(thread_this);
return FCGX_GetStr(buf, size, this->req.in);
}
@@ -96,7 +103,9 @@ static int read_cb(void *null, char *buf, int size)
*/
static int writef_cb(void *null, const char *format, va_list args)
{
- private_request_t *this = (private_request_t*)thread_this->get(thread_this);
+ private_fast_request_t *this;
+
+ this = (private_fast_request_t*)thread_this->get(thread_this);
FCGX_VFPrintF(this->req.out, format, args);
return 0;
@@ -106,7 +115,9 @@ static int writef_cb(void *null, const char *format, va_list args)
*/
static int write_cb(void *null, const char *buf, int size)
{
- private_request_t *this = (private_request_t*)thread_this->get(thread_this);
+ private_fast_request_t *this;
+
+ this = (private_fast_request_t*)thread_this->get(thread_this);
return FCGX_PutStr(buf, size, this->req.out);
}
@@ -117,7 +128,9 @@ static int write_cb(void *null, const char *buf, int size)
static char *getenv_cb(void *null, const char *key)
{
char *value;
- private_request_t *this = (private_request_t*)thread_this->get(thread_this);
+ private_fast_request_t *this;
+
+ this = (private_fast_request_t*)thread_this->get(thread_this);
value = FCGX_GetParam(key, this->req.envp);
return strdupnull(value);
@@ -137,9 +150,12 @@ static int putenv_cb(void *null, const char *key, const char *value)
*/
static int iterenv_cb(void *null, int num, char **key, char **value)
{
+ private_fast_request_t *this;
+
*key = NULL;
*value = NULL;
- private_request_t *this = (private_request_t*)thread_this->get(thread_this);
+ this = (private_fast_request_t*)thread_this->get(thread_this);
+
if (num < this->req_env_len)
{
char *eq;
@@ -160,66 +176,66 @@ static int iterenv_cb(void *null, int num, char **key, char **value)
return 0;
}
-METHOD(request_t, get_cookie, char*,
- private_request_t *this, char *name)
+METHOD(fast_request_t, get_cookie, char*,
+ private_fast_request_t *this, char *name)
{
return hdf_get_valuef(this->hdf, "Cookie.%s", name);
}
-METHOD(request_t, get_path, char*,
- private_request_t *this)
+METHOD(fast_request_t, get_path, char*,
+ private_fast_request_t *this)
{
- char * path = FCGX_GetParam("PATH_INFO", this->req.envp);
+ char *path = FCGX_GetParam("PATH_INFO", this->req.envp);
return path ? path : "";
}
-METHOD(request_t, get_host, char*,
- private_request_t *this)
+METHOD(fast_request_t, get_host, char*,
+ private_fast_request_t *this)
{
char *addr = FCGX_GetParam("REMOTE_ADDR", this->req.envp);
return addr ? addr : "";
}
-METHOD(request_t, get_user_agent, char*,
- private_request_t *this)
+METHOD(fast_request_t, get_user_agent, char*,
+ private_fast_request_t *this)
{
char *agent = FCGX_GetParam("HTTP_USER_AGENT", this->req.envp);
return agent ? agent : "";
}
-METHOD(request_t, get_query_data, char*,
- private_request_t *this, char *name)
+METHOD(fast_request_t, get_query_data, char*,
+ private_fast_request_t *this, char *name)
{
return hdf_get_valuef(this->hdf, "Query.%s", name);
}
-METHOD(request_t, get_env_var, char*,
- private_request_t *this, char *name)
+METHOD(fast_request_t, get_env_var, char*,
+ private_fast_request_t *this, char *name)
{
return FCGX_GetParam(name, this->req.envp);
}
-METHOD(request_t, read_data, int,
- private_request_t *this, char *buf, int len)
+METHOD(fast_request_t, read_data, int,
+ private_fast_request_t *this, char *buf, int len)
{
return FCGX_GetStr(buf, len, this->req.in);
}
-METHOD(request_t, get_base, char*,
- private_request_t *this)
+METHOD(fast_request_t, get_base, char*,
+ private_fast_request_t *this)
{
return FCGX_GetParam("SCRIPT_NAME", this->req.envp);
}
-METHOD(request_t, add_cookie, void,
- private_request_t *this, char *name, char *value)
+METHOD(fast_request_t, add_cookie, void,
+ private_fast_request_t *this, char *name, char *value)
{
thread_this->set(thread_this, this);
cgi_cookie_set(this->cgi, name, value, NULL, NULL, NULL, 0, 0);
}
-METHOD(request_t, redirect, void,
- private_request_t *this, char *fmt, ...)
+METHOD(fast_request_t, redirect, void,
+ private_fast_request_t *this, char *fmt, ...)
{
va_list args;
@@ -232,14 +248,14 @@ METHOD(request_t, redirect, void,
FCGX_FPrintF(this->req.out, "\n\n");
}
-METHOD(request_t, get_referer, char*,
- private_request_t *this)
+METHOD(fast_request_t, get_referer, char*,
+ private_fast_request_t *this)
{
return FCGX_GetParam("HTTP_REFERER", this->req.envp);
}
-METHOD(request_t, to_referer, void,
- private_request_t *this)
+METHOD(fast_request_t, to_referer, void,
+ private_fast_request_t *this)
{
char *referer;
@@ -255,28 +271,82 @@ METHOD(request_t, to_referer, void,
}
}
-METHOD(request_t, session_closed, bool,
- private_request_t *this)
+METHOD(fast_request_t, session_closed, bool,
+ private_fast_request_t *this)
{
return this->closed;
}
-METHOD(request_t, close_session, void,
- private_request_t *this)
+METHOD(fast_request_t, close_session, void,
+ private_fast_request_t *this)
{
this->closed = TRUE;
}
-METHOD(request_t, serve, void,
- private_request_t *this, char *headers, chunk_t chunk)
+METHOD(fast_request_t, serve, void,
+ private_fast_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);
}
-METHOD(request_t, render, void,
- private_request_t *this, char *template)
+METHOD(fast_request_t, sendfile, bool,
+ private_fast_request_t *this, char *path, char *mime)
+{
+ struct stat sb;
+ chunk_t data;
+ void *addr;
+ int fd, written;
+ char buf[24];
+
+ fd = open(path, O_RDONLY);
+ if (fd == -1)
+ {
+ return FALSE;
+ }
+ if (fstat(fd, &sb) == -1)
+ {
+ close(fd);
+ return FALSE;
+ }
+ addr = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
+ if (addr == MAP_FAILED)
+ {
+ close(fd);
+ return FALSE;
+ }
+
+ /* FCGX does not like large integers, print to a buffer using libc */
+ snprintf(buf, sizeof(buf), "%lld", (int64_t)sb.st_size);
+ FCGX_FPrintF(this->req.out, "Content-Length: %s\n", buf);
+ if (mime)
+ {
+ FCGX_FPrintF(this->req.out, "Content-Type: %s\n", mime);
+ }
+ FCGX_FPrintF(this->req.out, "\n");
+
+ data = chunk_create(addr, sb.st_size);
+
+ while (data.len)
+ {
+ written = FCGX_PutStr(data.ptr, data.len, this->req.out);
+ if (written == -1)
+ {
+ munmap(addr, sb.st_size);
+ close(fd);
+ return FALSE;
+ }
+ data = chunk_skip(data, written);
+ }
+
+ munmap(addr, sb.st_size);
+ close(fd);
+ return TRUE;
+}
+
+METHOD(fast_request_t, render, void,
+ private_fast_request_t *this, char *template)
{
NEOERR* err;
@@ -289,8 +359,8 @@ METHOD(request_t, render, void,
}
}
-METHOD(request_t, streamf, int,
- private_request_t *this, char *format, ...)
+METHOD(fast_request_t, streamf, int,
+ private_fast_request_t *this, char *format, ...)
{
va_list args;
int written;
@@ -306,14 +376,14 @@ METHOD(request_t, streamf, int,
return written;
}
-METHOD(request_t, set, void,
- private_request_t *this, char *key, char *value)
+METHOD(fast_request_t, set, void,
+ private_fast_request_t *this, char *key, char *value)
{
hdf_set_value(this->hdf, key, value);
}
-METHOD(request_t, setf, void,
- private_request_t *this, char *format, ...)
+METHOD(fast_request_t, setf, void,
+ private_fast_request_t *this, char *format, ...)
{
va_list args;
@@ -322,15 +392,15 @@ METHOD(request_t, setf, void,
va_end(args);
}
-METHOD(request_t, get_ref, request_t*,
- private_request_t *this)
+METHOD(fast_request_t, get_ref, fast_request_t*,
+ private_fast_request_t *this)
{
ref_get(&this->ref);
return &this->public;
}
-METHOD(request_t, destroy, void,
- private_request_t *this)
+METHOD(fast_request_t, destroy, void,
+ private_fast_request_t *this)
{
if (ref_put(&this->ref))
{
@@ -355,10 +425,10 @@ static void init(void)
/*
* see header file
*/
-request_t *request_create(int fd, bool debug)
+fast_request_t *fast_request_create(int fd, bool debug)
{
NEOERR* err;
- private_request_t *this;
+ private_fast_request_t *this;
bool failed = FALSE;
INIT(this,
@@ -380,6 +450,7 @@ request_t *request_create(int fd, bool debug)
.render = _render,
.streamf = _streamf,
.serve = _serve,
+ .sendfile = _sendfile,
.set = _set,
.setf = _setf,
.get_ref = _get_ref,
@@ -436,4 +507,3 @@ request_t *request_create(int fd, bool debug)
free(this);
return NULL;
}
-
diff --git a/src/libfast/request.h b/src/libfast/fast_request.h
index c9c1f13e2..678cf54d5 100644
--- a/src/libfast/request.h
+++ b/src/libfast/fast_request.h
@@ -14,24 +14,24 @@
*/
/**
- * @defgroup request request
+ * @defgroup fast_request fast_request
* @{ @ingroup libfast
*/
-#ifndef REQUEST_H_
-#define REQUEST_H_
+#ifndef FAST_REQUEST_H_
+#define FAST_REQUEST_H_
#include <fcgiapp.h>
#include <library.h>
-typedef struct request_t request_t;
+typedef struct fast_request_t fast_request_t;
/**
* A HTTP request, encapsulates FCGX_Request.
*
* The response is also handled through the request object.
*/
-struct request_t {
+struct fast_request_t {
/**
* Add a cookie to the reply (Set-Cookie header).
@@ -39,7 +39,7 @@ struct request_t {
* @param name name of the cookie to set
* @param value value of the cookie
*/
- void (*add_cookie)(request_t *this, char *name, char *value);
+ void (*add_cookie)(fast_request_t *this, char *name, char *value);
/**
* Get a cookie the client sent in the request.
@@ -47,35 +47,35 @@ struct request_t {
* @param name name of the cookie
* @return cookie value, NULL if no such cookie found
*/
- char* (*get_cookie)(request_t *this, char *name);
+ char* (*get_cookie)(fast_request_t *this, char *name);
/**
* Get the request path relative to the application.
*
* @return path
*/
- char* (*get_path)(request_t *this);
+ char* (*get_path)(fast_request_t *this);
/**
* Get the base path of the application.
*
* @return base path
*/
- char* (*get_base)(request_t *this);
+ char* (*get_base)(fast_request_t *this);
/**
* Get the remote host address of this request.
*
* @return host address as string
*/
- char* (*get_host)(request_t *this);
+ char* (*get_host)(fast_request_t *this);
/**
* Get the user agent string.
*
* @return user agent string
*/
- char* (*get_user_agent)(request_t *this);
+ char* (*get_user_agent)(fast_request_t *this);
/**
* Get a post/get variable included in the request.
@@ -83,7 +83,7 @@ struct request_t {
* @param name name of the POST/GET variable
* @return value, NULL if not found
*/
- char* (*get_query_data)(request_t *this, char *name);
+ char* (*get_query_data)(fast_request_t *this, char *name);
/**
* Get an arbitrary environment variable.
@@ -91,7 +91,7 @@ struct request_t {
* @param name name of the environment variable
* @return value, NULL if not found
*/
- char* (*get_env_var)(request_t *this, char *name);
+ char* (*get_env_var)(fast_request_t *this, char *name);
/**
* Read raw POST/PUT data from HTTP request.
@@ -100,19 +100,19 @@ struct request_t {
* @param len size of the supplied buffer
* @return number of bytes read, < 0 on error
*/
- int (*read_data)(request_t *this, char *buf, int len);
+ int (*read_data)(fast_request_t *this, char *buf, int len);
/**
* Close the session and it's context after handling.
*/
- void (*close_session)(request_t *this);
+ void (*close_session)(fast_request_t *this);
/**
* Has the session been closed by close_session()?
*
* @return TRUE if session has been closed
*/
- bool (*session_closed)(request_t *this);
+ bool (*session_closed)(fast_request_t *this);
/**
* Redirect the client to another location.
@@ -120,19 +120,19 @@ struct request_t {
* @param fmt location format string
* @param ... variable argument for fmt
*/
- void (*redirect)(request_t *this, char *fmt, ...);
+ void (*redirect)(fast_request_t *this, char *fmt, ...);
/**
* Get the HTTP referer.
*
* @return HTTP referer
*/
- char* (*get_referer)(request_t *this);
+ char* (*get_referer)(fast_request_t *this);
/**
* Redirect back to the referer.
*/
- void (*to_referer)(request_t *this);
+ void (*to_referer)(fast_request_t *this);
/**
* Set a template value.
@@ -140,7 +140,7 @@ struct request_t {
* @param key key to set
* @param value value to set key to
*/
- void (*set)(request_t *this, char *key, char *value);
+ void (*set)(fast_request_t *this, char *key, char *value);
/**
* Set a template value using format strings.
@@ -151,7 +151,7 @@ struct request_t {
* @param format printf like format string
* @param ... variable argument list
*/
- void (*setf)(request_t *this, char *format, ...);
+ void (*setf)(fast_request_t *this, char *format, ...);
/**
* Render a template.
@@ -162,7 +162,7 @@ struct request_t {
*
* @param template clearsilver template file location
*/
- void (*render)(request_t *this, char *template);
+ void (*render)(fast_request_t *this, char *template);
/**
* Stream a format string to the client.
@@ -174,7 +174,7 @@ struct request_t {
* @param ... argmuent list to format string
* @return number of streamed bytes, < 0 if stream closed
*/
- int (*streamf)(request_t *this, char *format, ...);
+ int (*streamf)(fast_request_t *this, char *format, ...);
/**
* Serve a request with headers and a body.
@@ -182,19 +182,28 @@ struct request_t {
* @param headers HTTP headers, \n separated
* @param chunk body to write to output
*/
- void (*serve)(request_t *this, char *headers, chunk_t chunk);
+ void (*serve)(fast_request_t *this, char *headers, chunk_t chunk);
+
+ /**
+ * Send a file from the file system.
+ *
+ * @param path path to file to serve
+ * @param mime mime type of file to send, or NULL
+ * @return TRUE if file served successfully
+ */
+ bool (*sendfile)(fast_request_t *this, char *path, char *mime);
/**
* Increase the reference count to the stream.
*
* @return this with increased refcount
*/
- request_t* (*get_ref)(request_t *this);
+ fast_request_t* (*get_ref)(fast_request_t *this);
/**
- * Destroy the request_t.
+ * Destroy the fast_request_t.
*/
- void (*destroy) (request_t *this);
+ void (*destroy) (fast_request_t *this);
};
/**
@@ -203,6 +212,6 @@ struct request_t {
* @param fd file descripter opened with FCGX_OpenSocket
* @param debug no stripping, no compression, timing information
*/
-request_t *request_create(int fd, bool debug);
+fast_request_t *fast_request_create(int fd, bool debug);
#endif /** REQUEST_H_ @}*/
diff --git a/src/libfast/session.c b/src/libfast/fast_session.c
index 1d9ed0107..56d4a0443 100644
--- a/src/libfast/session.c
+++ b/src/libfast/fast_session.c
@@ -15,27 +15,27 @@
#define _GNU_SOURCE
-#include "session.h"
+#include "fast_session.h"
#include <string.h>
#include <fcgiapp.h>
#include <stdio.h>
-#include <utils/linked_list.h>
+#include <collections/linked_list.h>
#define COOKIE_LEN 16
-typedef struct private_session_t private_session_t;
+typedef struct private_fast_session_t private_fast_session_t;
/**
* private data of the task manager
*/
-struct private_session_t {
+struct private_fast_session_t {
/**
* public functions
*/
- session_t public;
+ fast_session_t public;
/**
* session ID
@@ -60,17 +60,17 @@ struct private_session_t {
/**
* user defined session context
*/
- context_t *context;
+ fast_context_t *context;
};
-METHOD(session_t, add_controller, void,
- private_session_t *this, controller_t *controller)
+METHOD(fast_session_t, add_controller, void,
+ private_fast_session_t *this, fast_controller_t *controller)
{
this->controllers->insert_last(this->controllers, controller);
}
-METHOD(session_t, add_filter, void,
- private_session_t *this, filter_t *filter)
+METHOD(fast_session_t, add_filter, void,
+ private_fast_session_t *this, fast_filter_t *filter)
{
this->filters->insert_last(this->filters, filter);
}
@@ -78,30 +78,34 @@ METHOD(session_t, add_filter, void,
/**
* Create a session ID and a cookie
*/
-static void create_sid(private_session_t *this)
+static bool create_sid(private_fast_session_t *this)
{
char buf[COOKIE_LEN];
rng_t *rng;
- memset(buf, 0, sizeof(buf));
- memset(this->sid, 0, sizeof(this->sid));
rng = lib->crypto->create_rng(lib->crypto, RNG_WEAK);
- if (rng)
+ if (!rng)
+ {
+ return FALSE;
+ }
+ if (!rng->get_bytes(rng, sizeof(buf), buf))
{
- rng->get_bytes(rng, sizeof(buf), buf);
rng->destroy(rng);
+ return FALSE;
}
+ rng->destroy(rng);
chunk_to_hex(chunk_create(buf, sizeof(buf)), this->sid, FALSE);
+ return TRUE;
}
/**
* run all registered filters
*/
-static bool run_filter(private_session_t *this, request_t *request, char *p0,
- char *p1, char *p2, char *p3, char *p4, char *p5)
+static bool run_filter(private_fast_session_t *this, fast_request_t *request,
+ char *p0, char *p1, char *p2, char *p3, char *p4, char *p5)
{
enumerator_t *enumerator;
- filter_t *filter;
+ fast_filter_t *filter;
enumerator = this->filters->create_enumerator(this->filters);
while (enumerator->enumerate(enumerator, &filter))
@@ -116,13 +120,13 @@ static bool run_filter(private_session_t *this, request_t *request, char *p0,
return TRUE;
}
-METHOD(session_t, process, void,
- private_session_t *this, request_t *request)
+METHOD(fast_session_t, process, void,
+ private_fast_session_t *this, fast_request_t *request)
{
char *pos, *start, *param[6] = {NULL, NULL, NULL, NULL, NULL, NULL};
enumerator_t *enumerator;
bool handled = FALSE;
- controller_t *current;
+ fast_controller_t *current;
int i = 0;
if (!this->cookie_sent)
@@ -178,17 +182,19 @@ METHOD(session_t, process, void,
}
}
-METHOD(session_t, get_sid, char*,
- private_session_t *this)
+METHOD(fast_session_t, get_sid, char*,
+ private_fast_session_t *this)
{
return this->sid;
}
-METHOD(session_t, destroy, void,
- private_session_t *this)
+METHOD(fast_session_t, destroy, void,
+ private_fast_session_t *this)
{
- this->controllers->destroy_offset(this->controllers, offsetof(controller_t, destroy));
- this->filters->destroy_offset(this->filters, offsetof(filter_t, destroy));
+ this->controllers->destroy_offset(this->controllers,
+ offsetof(fast_controller_t, destroy));
+ this->filters->destroy_offset(this->filters,
+ offsetof(fast_filter_t, destroy));
DESTROY_IF(this->context);
free(this);
}
@@ -196,9 +202,9 @@ METHOD(session_t, destroy, void,
/*
* see header file
*/
-session_t *session_create(context_t *context)
+fast_session_t *fast_session_create(fast_context_t *context)
{
- private_session_t *this;
+ private_fast_session_t *this;
INIT(this,
.public = {
@@ -212,8 +218,11 @@ session_t *session_create(context_t *context)
.filters = linked_list_create(),
.context = context,
);
- create_sid(this);
+ if (!create_sid(this))
+ {
+ destroy(this);
+ return NULL;
+ }
return &this->public;
}
-
diff --git a/src/libfast/session.h b/src/libfast/fast_session.h
index f60fa9ef2..2ff450b93 100644
--- a/src/libfast/session.h
+++ b/src/libfast/fast_session.h
@@ -14,63 +14,64 @@
*/
/**
- * @defgroup session session
+ * @defgroup fast_session fast_session
* @{ @ingroup libfast
*/
-#ifndef SESSION_H_
-#define SESSION_H_
+#ifndef FAST_SESSION_H_
+#define FAST_SESSION_H_
-#include "request.h"
-#include "controller.h"
-#include "filter.h"
+#include "fast_request.h"
+#include "fast_controller.h"
+#include "fast_filter.h"
-typedef struct session_t session_t;
+typedef struct fast_session_t fast_session_t;
/**
* Session handling class, instanciated for each user session.
*/
-struct session_t {
+struct fast_session_t {
/**
* Get the session ID of the session.
*
* @return session ID
*/
- char* (*get_sid)(session_t *this);
+ char* (*get_sid)(fast_session_t *this);
/**
* Add a controller instance to the session.
*
* @param controller controller to add
*/
- void (*add_controller)(session_t *this, controller_t *controller);
+ void (*add_controller)(fast_session_t *this, fast_controller_t *controller);
/**
* Add a filter instance to the session.
*
* @param filter filter to add
*/
- void (*add_filter)(session_t *this, filter_t *filter);
+ void (*add_filter)(fast_session_t *this, fast_filter_t *filter);
/**
* Process a request in this session.
*
* @param request request to process
*/
- void (*process)(session_t *this, request_t *request);
+ void (*process)(fast_session_t *this, fast_request_t *request);
/**
- * Destroy the session_t.
+ * Destroy the fast_session_t.
*/
- void (*destroy) (session_t *this);
+ void (*destroy) (fast_session_t *this);
};
/**
* Create a session new session.
*
* @param context user defined session context instance
+ * @return client session, NULL on error
*/
-session_t *session_create(context_t *context);
+fast_session_t *fast_session_create(fast_context_t *context);
#endif /** SESSION_H_ @}*/
diff --git a/src/libfast/smtp.c b/src/libfast/fast_smtp.c
index 4118c74a6..89e74d79b 100644
--- a/src/libfast/smtp.c
+++ b/src/libfast/fast_smtp.c
@@ -13,24 +13,24 @@
* for more details.
*/
-#include "smtp.h"
+#include "fast_smtp.h"
#include <unistd.h>
#include <errno.h>
-#include <debug.h>
+#include <utils/debug.h>
-typedef struct private_smtp_t private_smtp_t;
+typedef struct private_fast_smtp_t private_fast_smtp_t;
/**
- * Private data of an smtp_t object.
+ * Private data of an fast_smtp_t object.
*/
-struct private_smtp_t {
+struct private_fast_smtp_t {
/**
- * Public smtp_t interface.
+ * Public fast_smtp_t interface.
*/
- smtp_t public;
+ fast_smtp_t public;
/**
* file stream to SMTP server
@@ -41,7 +41,7 @@ struct private_smtp_t {
/**
* Read the response code from an SMTP server
*/
-static int read_response(private_smtp_t *this)
+static int read_response(private_fast_smtp_t *this)
{
char buf[256], *end;
int res = 0;
@@ -72,7 +72,7 @@ static int read_response(private_smtp_t *this)
/**
* write a SMTP command to the server, read response code
*/
-static int write_cmd(private_smtp_t *this, char *fmt, ...)
+static int write_cmd(private_fast_smtp_t *this, char *fmt, ...)
{
char buf[256];
va_list args;
@@ -89,8 +89,8 @@ static int write_cmd(private_smtp_t *this, char *fmt, ...)
return read_response(this);
}
-METHOD(smtp_t, send_mail, bool,
- private_smtp_t *this, char *from, char *to, char *subject, char *fmt, ...)
+METHOD(fast_smtp_t, send_mail, bool,
+ private_fast_smtp_t *this, char *from, char *to, char *subject, char *fmt, ...)
{
va_list args;
@@ -122,8 +122,8 @@ METHOD(smtp_t, send_mail, bool,
}
-METHOD(smtp_t, destroy, void,
- private_smtp_t *this)
+METHOD(fast_smtp_t, destroy, void,
+ private_fast_smtp_t *this)
{
write_cmd(this, "QUIT");
fclose(this->f);
@@ -133,10 +133,16 @@ METHOD(smtp_t, destroy, void,
/**
* See header
*/
-smtp_t *smtp_create()
+fast_smtp_t *fast_smtp_create()
{
- private_smtp_t *this;
- struct sockaddr_in addr;
+ private_fast_smtp_t *this;
+ struct sockaddr_in addr = {
+ .sin_family = AF_INET,
+ .sin_port = htons(25),
+ .sin_addr = {
+ .s_addr = htonl(INADDR_LOOPBACK),
+ },
+ };
int s;
INIT(this,
@@ -153,9 +159,6 @@ smtp_t *smtp_create()
free(this);
return NULL;
}
- addr.sin_family = AF_INET;
- addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
- addr.sin_port = htons(25);
if (connect(s, (struct sockaddr*)&addr, sizeof(addr)) < 0)
{
DBG1(DBG_LIB, "connecting to SMTP server failed: %s", strerror(errno));
@@ -182,4 +185,3 @@ smtp_t *smtp_create()
}
return &this->public;
}
-
diff --git a/src/libfast/smtp.h b/src/libfast/fast_smtp.h
index 9589ea2a6..962ba2cc7 100644
--- a/src/libfast/smtp.h
+++ b/src/libfast/fast_smtp.h
@@ -14,21 +14,21 @@
*/
/**
- * @defgroup smtp smtp
+ * @defgroup fast_smtp fast_smtp
* @{ @ingroup libfast
*/
-#ifndef SMTP_H_
-#define SMTP_H_
+#ifndef FAST_SMTP_H_
+#define FAST_SMTP_H_
-typedef struct smtp_t smtp_t;
+typedef struct fast_smtp_t fast_smtp_t;
#include <library.h>
/**
* Ultra-minimalistic SMTP client. Works at most with Exim on localhost.
*/
-struct smtp_t {
+struct fast_smtp_t {
/**
* Send an e-mail message.
@@ -39,18 +39,18 @@ struct smtp_t {
* @param fmt mail body format string
* @param ... arguments for body format string
*/
- bool (*send_mail)(smtp_t *this, char *from, char *to,
+ bool (*send_mail)(fast_smtp_t *this, char *from, char *to,
char *subject, char *fmt, ...);
/**
- * Destroy a smtp_t.
+ * Destroy a fast_smtp_t.
*/
- void (*destroy)(smtp_t *this);
+ void (*destroy)(fast_smtp_t *this);
};
/**
* Create a smtp instance.
*/
-smtp_t *smtp_create();
+fast_smtp_t *fast_smtp_create();
-#endif /** SMTP_H_ @}*/
+#endif /** FAST_SMTP_H_ @}*/