diff --git a/.gitignore b/.gitignore index 6b8107e..fdcb6d0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ .*.swp *.o +*.gcda +*.gcno .dirstamp .deps/ Makefile @@ -8,6 +10,8 @@ Makefile.in m4/ /docs/ /INSTALL +coverage.info +coveragereport/ *.m4 /autom4te.cache/ /compile @@ -19,3 +23,4 @@ m4/ /missing stamp-h1 src/taskrambler + diff --git a/Makefile.am b/Makefile.am index 392bb5a..c413a9b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,3 +8,5 @@ ACLOCAL_AMFLAGS = -I m4 EXTRA_DIST = include assets certs SUBDIRS = src tests + +include $(top_srcdir)/Makefile.am.coverage diff --git a/Makefile.am.coverage b/Makefile.am.coverage new file mode 100644 index 0000000..af82e7d --- /dev/null +++ b/Makefile.am.coverage @@ -0,0 +1,27 @@ + +# Coverage targets + +if HAVE_GCOV + + .PHONY: clean-gcda + clean-gcda: + @echo Removing old coverage results + -find -name '*.gcda' -print | xargs -r rm + + .PHONY: coverage-html generate-coverage-html clean-coverage-html + coverage-html: clean-gcda + -$(MAKE) $(AM_MAKEFLAGS) -k check + $(MAKE) $(AM_MAKEFLAGS) generate-coverage-html + + generate-coverage-html: + @echo Collecting coverage data + $(LCOV) --directory $(top_builddir) --capture --output-file coverage.info --no-checksum --compat-libtool + LANG=C $(GENHTML) --prefix $(top_builddir) --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info + + clean-coverage-html: clean-gcda + -$(LCOV) --directory $(top_builddir) -z + -rm -rf coverage.info coveragereport + + clean-local: clean-coverage-html + +endif # HAVE_GCOV diff --git a/configure.ac b/configure.ac index 1cc1e30..4c6f6cc 100644 --- a/configure.ac +++ b/configure.ac @@ -3,14 +3,21 @@ AC_PREREQ([2.68]) AC_INIT([taskrambler], [0.0.1], [Georg Hopp ]) +LT_INIT AM_INIT_AUTOMAKE([subdir-objects]) -AM_SILENT_RULES([yes]) +#AM_SILENT_RULES([yes]) AC_COPYRIGHT([Copyright © 2012 Georg Hopp]) AC_REVISION([$Revision: 0.01 $]) AC_CONFIG_SRCDIR([src/taskrambler.c]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) +m4_include([m4/gcov.m4]) +AC_TDD_GCOV +AC_SUBST(COVERAGE_CFLAGS) +AC_SUBST(COVERAGE_CXXFLAGS) +AC_SUBST(COVERAGE_LDFLAGS) + # Checks for programs. AC_PROG_CXX AC_PROG_CC @@ -38,5 +45,12 @@ AC_TYPE_SIZE_T #AC_FUNC_MALLOC AC_CHECK_FUNCS([memset]) -AC_CONFIG_FILES([Makefile src/Makefile src/class/Makefile tests/Makefile]) +AC_CONFIG_FILES([Makefile + src/Makefile + src/auth/Makefile + src/cbuf/Makefile + src/class/Makefile + src/hash/Makefile + src/http/Makefile + tests/Makefile]) AC_OUTPUT diff --git a/include/auth.h b/include/auth.h index a83eb51..db49b3c 100644 --- a/include/auth.h +++ b/include/auth.h @@ -1,44 +1,10 @@ -/** - * \file - * Authenticatio module factory - * - * A factory to get a specific authentication module. - * An authentication module is a class that implement the Auth interface. - * - * \author Georg Hopp - * - * \copyright - * Copyright © 2012 Georg Hopp - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - #ifndef __AUTH_H__ #define __AUTH_H__ -#include "class.h" +#include "auth/auth.h" #include "auth/ldap.h" - -typedef enum e_AuthModule { - AUTH_LDAP = 0 -} AuthModule; - -CLASS(Auth) { -}; - -void * authCreateById(Auth, int); -AuthLdap authCreateLdap(Auth); +#include "auth/credential.h" +#include "auth/interface/auth.h" #endif // __AUTH_H__ diff --git a/include/auth/auth.h b/include/auth/auth.h new file mode 100644 index 0000000..2518918 --- /dev/null +++ b/include/auth/auth.h @@ -0,0 +1,45 @@ +/** + * \file + * Authenticatio module factory + * + * A factory to get a specific authentication module. + * An authentication module is a class that implement the Auth interface. + * + * \author Georg Hopp + * + * \copyright + * Copyright © 2012 Georg Hopp + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef __AUTH_AUTH_H__ +#define __AUTH_AUTH_H__ + +#include "class.h" +#include "auth/ldap.h" + +typedef enum e_AuthModule { + AUTH_LDAP = 0 +} AuthModule; + +CLASS(Auth) { +}; + +void * authCreateById(Auth, int); +AuthLdap authCreateLdap(Auth); + +#endif // __AUTH_AUTH_H__ + +// vim: set ts=4 sw=4: diff --git a/include/credential.h b/include/auth/credential.h similarity index 92% rename from include/credential.h rename to include/auth/credential.h index 945f780..01394e8 100644 --- a/include/credential.h +++ b/include/auth/credential.h @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef __CREDENTIAL_H__ -#define __CREDENTIAL_H__ +#ifndef __AUTH_CREDENTIAL_H__ +#define __AUTH_CREDENTIAL_H__ #include @@ -49,6 +49,6 @@ CLASS(Credential) { } cred; }; -#endif // __CREDENTIAL_H__ +#endif // __AUTH_CREDENTIAL_H__ // vim: set ts=4 sw=4: diff --git a/include/interface/auth.h b/include/auth/interface/auth.h similarity index 90% rename from include/interface/auth.h rename to include/auth/interface/auth.h index ec55000..8dccfa2 100644 --- a/include/interface/auth.h +++ b/include/auth/interface/auth.h @@ -25,13 +25,13 @@ * along with this program. If not, see . */ -#ifndef __INTERFACE_AUTH_H__ -#define __INTERFACE_AUTH_H__ +#ifndef __AUTH_INTERFACE_AUTH_H__ +#define __AUTH_INTERFACE_AUTH_H__ #include #include "class.h" -#include "credential.h" +#include "auth/credential.h" typedef int (* fptr_authenticate)(void *, Credential); @@ -44,6 +44,6 @@ struct i_Auth { extern int authenticate(void *, Credential); -#endif // __INTERFACE_AUTH_H__ +#endif // __AUTH_INTERFACE_AUTH_H__ // vim: set ts=4 sw=4: diff --git a/include/hash.h b/include/hash.h index 4c6eb92..54868d7 100644 --- a/include/hash.h +++ b/include/hash.h @@ -1,41 +1,9 @@ -/** - * \file - * - * \author Georg Hopp - * - * \copyright - * Copyright © 2012 Georg Hopp - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - #ifndef __HASH_H__ #define __HASH_H__ -#include - -#include "class.h" - - -CLASS(Hash) { - void * root; -}; - -void * hashAdd(Hash, void *); -void * hashDelete(Hash, const char *, size_t); -void * hashGet(Hash, const char *, size_t); -void hashEach(Hash, void (*)(const void*)); +#include "hash/hash.h" +#include "hash/value.h" +#include "hash/interface/hashable.h" #endif // __HASH_H__ diff --git a/include/hash/hash.h b/include/hash/hash.h new file mode 100644 index 0000000..1ddcf2e --- /dev/null +++ b/include/hash/hash.h @@ -0,0 +1,42 @@ +/** + * \file + * + * \author Georg Hopp + * + * \copyright + * Copyright © 2012 Georg Hopp + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef __HASH_HASH_H__ +#define __HASH_HASH_H__ + +#include + +#include "class.h" + + +CLASS(Hash) { + void * root; +}; + +void * hashAdd(Hash, void *); +void * hashDelete(Hash, const char *, size_t); +void * hashGet(Hash, const char *, size_t); +void hashEach(Hash, void (*)(const void*)); + +#endif // __HASH_HASH_H__ + +// vim: set ts=4 sw=4: diff --git a/include/interface/hashable.h b/include/hash/interface/hashable.h similarity index 91% rename from include/interface/hashable.h rename to include/hash/interface/hashable.h index a4dbc49..1a33d58 100644 --- a/include/interface/hashable.h +++ b/include/hash/interface/hashable.h @@ -21,8 +21,8 @@ * along with this program. If not, see . */ -#ifndef __INTERFACE_HASHABLE_H__ -#define __INTERFACE_HASHABLE_H__ +#ifndef __HASH_INTERFACE_HASHABLE_H__ +#define __HASH_INTERFACE_HASHABLE_H__ #include "class.h" @@ -40,6 +40,6 @@ struct i_Hashable { extern unsigned long hashableGetHash(void *); extern void hashableHandleDouble(void *, void *); -#endif // __INTERFACE_HASHABLE_H__ +#endif // __HASH_INTERFACE_HASHABLE_H__ // vim: set ts=4 sw=4: diff --git a/include/hash_value.h b/include/hash/value.h similarity index 100% rename from include/hash_value.h rename to include/hash/value.h diff --git a/include/http.h b/include/http.h new file mode 100644 index 0000000..fde505b --- /dev/null +++ b/include/http.h @@ -0,0 +1,16 @@ +#ifndef __HTTP_H__ +#define __HTTP_H__ + +#include "http/cookie.h" +#include "http/header.h" +#include "http/message.h" +#include "http/message/queue.h" +#include "http/request.h" +#include "http/response.h" +#include "http/parser.h" +#include "http/writer.h" +#include "http/worker.h" + +#endif // __HTTP_H__ + +// vim: set ts=4 sw=4: diff --git a/include/http/message.h b/include/http/message.h index b85ec93..2161793 100644 --- a/include/http/message.h +++ b/include/http/message.h @@ -38,7 +38,6 @@ CLASS(HttpMessage) { char * version; Hash header; - Hash cookies; HttpMessageType type; Stream handle; diff --git a/m4/gcov.m4 b/m4/gcov.m4 new file mode 100644 index 0000000..d34f1e9 --- /dev/null +++ b/m4/gcov.m4 @@ -0,0 +1,77 @@ +# Checks for existence of coverage tools: +# * gcov +# * lcov +# * genhtml +# * gcovr +# +# Sets ac_cv_check_gcov to yes if tooling is present +# and reports the executables to the variables LCOV, GCOVR and GENHTML. +AC_DEFUN([AC_TDD_GCOV], +[ + AC_ARG_ENABLE(gcov, + AS_HELP_STRING([--enable-gcov], + [enable coverage testing with gcov]), + [use_gcov=$enableval], [use_gcov=no]) + AM_CONDITIONAL(HAVE_GCOV, test "x$use_gcov" = "xyes") + + if test "x$use_gcov" = "xyes"; then + # we need gcc: + if test "$GCC" != "yes"; then + AC_MSG_ERROR([GCC is required for --enable-gcov]) + fi + + # Check if ccache is being used + AC_CHECK_PROG(SHTOOL, shtool, shtool) + case `$SHTOOL path $CC` in + *ccache*[)] gcc_ccache=yes;; + *[)] gcc_ccache=no;; + esac + + if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then + AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.]) + fi + + lcov_version_list="1.6 1.7 1.8 1.9" + AC_CHECK_PROG(LCOV, lcov, lcov) + AC_CHECK_PROG(GENHTML, genhtml, genhtml) + + if test "$LCOV"; then + AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [ + glib_cv_lcov_version=invalid + lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'` + for lcov_check_version in $lcov_version_list; do + if test "$lcov_version" = "$lcov_check_version"; then + glib_cv_lcov_version="$lcov_check_version (ok)" + fi + done + ]) + else + lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list" + AC_MSG_ERROR([$lcov_msg]) + fi + + case $glib_cv_lcov_version in + ""|invalid[)] + lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)." + AC_MSG_ERROR([$lcov_msg]) + LCOV="exit 0;" + ;; + esac + + if test -z "$GENHTML"; then + AC_MSG_ERROR([Could not find genhtml from the lcov package]) + fi + + # Remove all optimization flags from CFLAGS + changequote({,}) + CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'` + changequote([,]) + + # Add the special gcc flags + COVERAGE_CFLAGS="-O0 -fprofile-arcs -ftest-coverage" + COVERAGE_CXXFLAGS="-O0 -fprofile-arcs -ftest-coverage" + COVERAGE_LDFLAGS="-lgcov" + +fi +]) # AC_TDD_GCOV + diff --git a/src/Makefile.am b/src/Makefile.am index 3386774..076900a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,68 +5,31 @@ IFACE = interface/stream_reader.c interface/logger.c \ interface/subject.c interface/observer.c SOCKET = socket.c socket/accept.c socket/connect.c socket/listen.c STREAM = stream.c stream/read.c stream/write.c -HASH = hash.c hash/add.c hash/get.c hash/delete.c \ - hash/each.c interface/hashable.c hash_value.c SERVER = server.c server/run.c server/close_conn.c server/poll.c \ server/handle_accept.c server/read.c server/write.c LOGGER = logger.c logger/stderr.c logger/syslog.c -CB = cbuf.c cbuf/read.c cbuf/write.c \ - cbuf/get_line.c cbuf/set_data.c cbuf/get_data.c \ - cbuf/addr_index.c cbuf/get_free.c cbuf/get_read.c cbuf/get_write.c \ - cbuf/inc_read.c cbuf/inc_write.c cbuf/is_empty.c cbuf/memchr.c \ - cbuf/skip_non_alpha.c cbuf/is_locked.c cbuf/lock.c cbuf/release.c \ - cbuf/empty.c -MSG = http/message.c \ - http/message/has_keep_alive.c \ - http/message/header_size_get.c \ - http/message/header_to_string.c \ - http/message/get_version.c \ - http/message/has_valid_version.c -MSGQ = http/message/queue.c -REQ = http/request.c \ - http/request/has_valid_method.c -RESP = http/response.c \ - http/response/304.c \ - http/response/404.c \ - http/response/403.c \ - http/response/login_form.c \ - http/response/asset.c \ - http/response/randval.c \ - http/response/session.c -PARSER = http/parser.c \ - http/parser/parse.c \ - http/parser/new_message.c \ - http/parser/header.c \ - http/parser/body.c \ - http/parser/request_vars.c \ - http/parser/post_vars.c -WRITER = http/writer.c \ - http/writer/write.c -WORKER = http/worker.c \ - http/worker/process.c \ - http/worker/write.c \ - http/worker/get_asset.c \ - http/worker/add_common_header.c -HEADER = http/header.c \ - http/header/to_string.c SESSION = session.c session/add.c session/get.c session/delete.c UTILS = utils/hash.c \ utils/memory.c \ utils/http.c \ utils/daemonize.c \ utils/signalHandling.c -AUTH = interface/auth.c auth/ldap.c credential.c +LIBS = ./http/libhttp.a \ + ./auth/libauth.a \ + ./cbuf/libcbuf.a \ + ./class/libclass.a \ + ./hash/libhash.a AM_CFLAGS = -Wall -I ../include/ bin_PROGRAMS = taskrambler taskrambler_SOURCES = taskrambler.c \ - $(IFACE) $(SOCKET) $(SERVER) $(LOGGER) $(MSG) $(REQ) \ - $(WRITER) $(RESP) $(HEADER) $(PARSER) $(WORKER) $(CB) \ - $(UTILS) $(MSGQ) $(SESSION) $(STREAM) $(HASH) $(AUTH) -taskrambler_CFLAGS = -Wall -I ../include/ -taskrambler_LDFLAGS = -L./class -lclass -lrt -lssl -lldap + $(IFACE) $(SOCKET) $(SERVER) $(LOGGER) \ + $(UTILS) $(SESSION) $(STREAM) +taskrambler_CFLAGS = -Wall -I ../include/ $(COVERAGE_CFLAGS) +taskrambler_LDADD = $(LIBS) -lrt -lssl -lldap +taskrambler_LDFLAGS = $(COVERAGE_LDFLAGS) -SUBDIRS = class +SUBDIRS = auth cbuf class hash http diff --git a/src/auth/Makefile.am b/src/auth/Makefile.am new file mode 100644 index 0000000..f35a61c --- /dev/null +++ b/src/auth/Makefile.am @@ -0,0 +1,6 @@ +ACLOCAL_AMFLAGS = -I m4 + +noinst_LIBRARIES = libauth.a + +libauth_a_SOURCES = interface/auth.c credential.c ldap.c +libauth_a_CFLAGS = -Wall -I ../../include/ diff --git a/src/credential.c b/src/auth/credential.c similarity index 98% rename from src/credential.c rename to src/auth/credential.c index 663cfe2..f5c3ef1 100644 --- a/src/credential.c +++ b/src/auth/credential.c @@ -25,11 +25,11 @@ #include #include -#include "credential.h" #include "class.h" - #include "utils/memory.h" +#include "auth/credential.h" + static int credentialCtor(void * _this, va_list * params) diff --git a/src/interface/auth.c b/src/auth/interface/auth.c similarity index 91% rename from src/interface/auth.c rename to src/auth/interface/auth.c index bc2e1bc..fa98183 100644 --- a/src/interface/auth.c +++ b/src/auth/interface/auth.c @@ -20,9 +20,9 @@ * along with this program. If not, see . */ -#include "auth.h" -#include "credential.h" -#include "interface/auth.h" +#include "auth/auth.h" +#include "auth/credential.h" +#include "auth/interface/auth.h" const struct interface i_Auth = { "auth", diff --git a/src/auth/ldap.c b/src/auth/ldap.c index 28f37d2..3ac2cfd 100644 --- a/src/auth/ldap.c +++ b/src/auth/ldap.c @@ -26,14 +26,14 @@ #include #include -#include "auth/ldap.h" #include "class.h" -#include "credential.h" -#include "interface/auth.h" - #include "utils/memory.h" #include "commons.h" +#include "auth/ldap.h" +#include "auth/credential.h" +#include "auth/interface/auth.h" + static int authLdapCtor(void * _this, va_list * params) diff --git a/src/auth/libauth.a b/src/auth/libauth.a new file mode 100644 index 0000000..7c72fa3 Binary files /dev/null and b/src/auth/libauth.a differ diff --git a/src/cbuf/Makefile.am b/src/cbuf/Makefile.am new file mode 100644 index 0000000..c9d9f29 --- /dev/null +++ b/src/cbuf/Makefile.am @@ -0,0 +1,13 @@ +ACLOCAL_AMFLAGS = -I m4 + +CB = cbuf.c read.c write.c \ + get_line.c set_data.c get_data.c \ + addr_index.c get_free.c get_read.c get_write.c \ + inc_read.c inc_write.c is_empty.c memchr.c \ + skip_non_alpha.c is_locked.c lock.c release.c \ + empty.c + +noinst_LIBRARIES = libcbuf.a + +libcbuf_a_SOURCES = $(CB) +libcbuf_a_CFLAGS = -Wall -I ../../include/ diff --git a/src/cbuf.c b/src/cbuf/cbuf.c similarity index 100% rename from src/cbuf.c rename to src/cbuf/cbuf.c diff --git a/src/cbuf/libcbuf.a b/src/cbuf/libcbuf.a new file mode 100644 index 0000000..b04e394 Binary files /dev/null and b/src/cbuf/libcbuf.a differ diff --git a/src/class/Makefile.am b/src/class/Makefile.am index c457e13..0f13153 100644 --- a/src/class/Makefile.am +++ b/src/class/Makefile.am @@ -1,7 +1,5 @@ ACLOCAL_AMFLAGS = -I m4 -AM_CFLAGS = -Wall -I ../include/ - noinst_LIBRARIES = libclass.a libclass_a_SOURCES = interface.c interface/class.c diff --git a/src/class/libclass.a b/src/class/libclass.a index 0892538..6d3c5ba 100644 Binary files a/src/class/libclass.a and b/src/class/libclass.a differ diff --git a/src/hash/Makefile.am b/src/hash/Makefile.am new file mode 100644 index 0000000..8eb86ff --- /dev/null +++ b/src/hash/Makefile.am @@ -0,0 +1,9 @@ +ACLOCAL_AMFLAGS = -I m4 + +HASH = hash.c add.c get.c delete.c each.c value.c \ + interface/hashable.c + +noinst_LIBRARIES = libhash.a + +libhash_a_SOURCES = $(HASH) +libhash_a_CFLAGS = -Wall -I ../../include/ diff --git a/src/hash/add.c b/src/hash/add.c index 32e9101..7613034 100644 --- a/src/hash/add.c +++ b/src/hash/add.c @@ -23,7 +23,6 @@ #include #include "hash.h" -#include "interface/hashable.h" #include "class.h" static diff --git a/src/hash/delete.c b/src/hash/delete.c index 76dd374..1731fbe 100644 --- a/src/hash/delete.c +++ b/src/hash/delete.c @@ -24,7 +24,6 @@ #include #include "hash.h" -#include "interface/hashable.h" #include "utils/hash.h" static diff --git a/src/hash/get.c b/src/hash/get.c index 44240cb..2d64514 100644 --- a/src/hash/get.c +++ b/src/hash/get.c @@ -24,7 +24,6 @@ #include #include "hash.h" -#include "interface/hashable.h" #include "utils/hash.h" static diff --git a/src/hash.c b/src/hash/hash.c similarity index 98% rename from src/hash.c rename to src/hash/hash.c index bb2fb7a..ba8cba2 100644 --- a/src/hash.c +++ b/src/hash/hash.c @@ -25,7 +25,7 @@ #include #include -#include "hash.h" +#include "hash/hash.h" #include "class.h" static diff --git a/src/interface/hashable.c b/src/hash/interface/hashable.c similarity index 96% rename from src/interface/hashable.c rename to src/hash/interface/hashable.c index 7e4b280..0113388 100644 --- a/src/interface/hashable.c +++ b/src/hash/interface/hashable.c @@ -25,7 +25,7 @@ #include #include "class.h" -#include "interface/hashable.h" +#include "hash/interface/hashable.h" const struct interface i_Hashable = { "hashable", diff --git a/src/hash/libhash.a b/src/hash/libhash.a new file mode 100644 index 0000000..b9c9147 Binary files /dev/null and b/src/hash/libhash.a differ diff --git a/src/hash_value.c b/src/hash/value.c similarity index 97% rename from src/hash_value.c rename to src/hash/value.c index 0df0ecb..c32b760 100644 --- a/src/hash_value.c +++ b/src/hash/value.c @@ -25,12 +25,13 @@ #include #include -#include "hash_value.h" +#include "class.h" #include "utils/hash.h" #include "utils/memory.h" #include "commons.h" -#include "class.h" -#include "interface/hashable.h" + +#include "hash/value.h" +#include "hash/interface/hashable.h" static int diff --git a/src/http/Makefile.am b/src/http/Makefile.am new file mode 100644 index 0000000..0285899 --- /dev/null +++ b/src/http/Makefile.am @@ -0,0 +1,41 @@ +ACLOCAL_AMFLAGS = -I m4 + +MSG = message.c \ + message/has_keep_alive.c \ + message/header_size_get.c \ + message/header_to_string.c \ + message/get_version.c \ + message/has_valid_version.c +MSGQ = message/queue.c +REQ = request.c \ + request/has_valid_method.c +RESP = response.c \ + response/304.c \ + response/404.c \ + response/403.c \ + response/login_form.c \ + response/asset.c \ + response/randval.c \ + response/session.c +PARSER = parser.c \ + parser/parse.c \ + parser/new_message.c \ + parser/header.c \ + parser/body.c \ + parser/request_vars.c \ + parser/post_vars.c +WRITER = writer.c \ + writer/write.c +WORKER = worker.c \ + worker/process.c \ + worker/write.c \ + worker/get_asset.c \ + worker/add_common_header.c +HEADER = header.c \ + header/to_string.c + +noinst_LIBRARIES = libhttp.a + +libhttp_a_SOURCES = $(MSG) $(MSGQ) $(REQ) $(RESP) $(PARSER) $(WRITER) \ + $(WORKER) $(HEADER) +libhttp_a_CFLAGS = -Wall -I ../../include/ diff --git a/src/http/cookie.c b/src/http/cookie.c index 29ca5a7..8b0a50b 100644 --- a/src/http/cookie.c +++ b/src/http/cookie.c @@ -25,9 +25,9 @@ #include #include -#include "cookie.h" #include "class.h" -#include "interface/hashable" +#include "hash.h" +#include "http/cookie.h" #include "utils/hash.h" #include "utils/memory.h" diff --git a/src/http/header.c b/src/http/header.c index 8067569..42ecfd9 100644 --- a/src/http/header.c +++ b/src/http/header.c @@ -25,8 +25,8 @@ #include #include "class.h" +#include "hash.h" #include "http/header.h" -#include "interface/hashable.h" #include "utils/hash.h" #include "utils/memory.h" diff --git a/src/http/libhttp.a b/src/http/libhttp.a new file mode 100644 index 0000000..4c65377 Binary files /dev/null and b/src/http/libhttp.a differ diff --git a/src/http/message.c b/src/http/message.c index 663d710..5786b76 100644 --- a/src/http/message.c +++ b/src/http/message.c @@ -46,8 +46,7 @@ httpMessageCtor(void * _this, va_list * params) this->version = calloc(1, strlen(version)+1); strcpy(this->version, version); - this->header = new(Hash); - this->cookies = new(Hash); + this->header = new(Hash); return 0; } @@ -59,7 +58,6 @@ httpMessageDtor(void * _this) HttpMessage this = _this; delete(this->header); - delete(this->cookies); FREE(this->version); diff --git a/src/http/parser/header.c b/src/http/parser/header.c index 4f226f3..8fce76c 100644 --- a/src/http/parser/header.c +++ b/src/http/parser/header.c @@ -30,7 +30,6 @@ #include "http/message.h" #include "http/request.h" #include "hash.h" -#include "hash_value.h" void httpParserHeader( diff --git a/src/http/parser/post_vars.c b/src/http/parser/post_vars.c index fe01658..b266940 100644 --- a/src/http/parser/post_vars.c +++ b/src/http/parser/post_vars.c @@ -25,7 +25,6 @@ #include "http/parser.h" #include "http/request.h" -#include "hash_value.h" #include "hash.h" #include "class.h" diff --git a/src/http/parser/request_vars.c b/src/http/parser/request_vars.c index cb82a08..fbcf192 100644 --- a/src/http/parser/request_vars.c +++ b/src/http/parser/request_vars.c @@ -26,7 +26,6 @@ #include "http/parser.h" #include "http/request.h" -#include "hash_value.h" #include "hash.h" #include "class.h" diff --git a/src/http/request.c b/src/http/request.c index 097a62e..a352687 100644 --- a/src/http/request.c +++ b/src/http/request.c @@ -26,6 +26,7 @@ #include #include "class.h" +#include "hash.h" #include "interface/http_intro.h" #include "http/request.h" diff --git a/src/http/worker.c b/src/http/worker.c index f64ccdb..cc85af1 100644 --- a/src/http/worker.c +++ b/src/http/worker.c @@ -62,7 +62,6 @@ httpWorkerCtor(void * _this, va_list * params) this->writer = new(HttpWriter, this->wbuf); this->sroot = &(this->session); - this->auth = va_arg(* params, void *); return 0; diff --git a/src/http/worker/process.c b/src/http/worker/process.c index 60b22dd..def6d1c 100644 --- a/src/http/worker/process.c +++ b/src/http/worker/process.c @@ -28,7 +28,7 @@ #include #include "class.h" -#include "interface/auth.h" +#include "auth.h" #include "http/worker.h" #include "http/header.h" @@ -39,9 +39,7 @@ #include "http/parser.h" #include "session.h" #include "stream.h" -#include "hash_value.h" #include "hash.h" -#include "credential.h" #include "utils/memory.h" #include "hash.h" diff --git a/src/taskrambler.c b/src/taskrambler.c index 9b731d5..f01b06a 100644 --- a/src/taskrambler.c +++ b/src/taskrambler.c @@ -38,7 +38,7 @@ #include "server.h" #include "logger.h" #include "http/worker.h" -#include "auth/ldap.h" +#include "auth.h" #include "class.h" #include "interface/logger.h" diff --git a/tests/Makefile.am b/tests/Makefile.am index f2906f6..c3138ae 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,28 +1,28 @@ ACLOCAL_AMFLAGS = -I m4 -TESTS_ENVIRONMENT = valgrind --error-exitcode=123 --leak-check=full --quiet -TESTS = cclassTest loggerTest socketTest serverTest -check_PROGRAMS = cclassTest loggerTest socketTest serverTest - -COMMON = runtest.c ../src/interface/class.c -CCLASS = $(COMMON) mock/class.c -LOGGER = $(COMMON) ../src/logger.c ../src/interface/logger.c \ - ../src/logger/stderr.c ../src/logger/syslog.c -SOCKET = $(LOGGER) ../src/socket.c ../src/socket/listen.c \ - ../src/socket/accept.c ../src/socket/connect.c -SERVER = $(SOCKET) ../src/server.c ../src/server/run.c \ - ../src/server/close_conn.c ../src/utils/signalHandling.c - -cclassTest_SOURCES = $(CCLASS) cclassTest.c -cclassTest_CFLAGS = -Wall -ggdb -O0 -finline-functions -I ../include -I .. -I . - -loggerTest_SOURCES = $(LOGGER) loggerTest.c -loggerTest_CFLAGS = -Wall -ggdb -O0 -I ../include -I .. -I . - -socketTest_SOURCES = $(SOCKET) socketTest.c -socketTest_CFLAGS = -Wall -ggdb -O0 -I ../include -I .. -I . - -serverTest_SOURCES = $(SERVER) serverTest.c -serverTest_CFLAGS = -Wall -ggdb -O0 -I ../include -I .. -I . +#TESTS_ENVIRONMENT = valgrind --error-exitcode=123 --leak-check=full --quiet +#TESTS = cclassTest loggerTest socketTest serverTest +#check_PROGRAMS = cclassTest loggerTest socketTest serverTest +# +#COMMON = runtest.c ../src/interface/class.c +#CCLASS = $(COMMON) mock/class.c +#LOGGER = $(COMMON) ../src/logger.c ../src/interface/logger.c \ +# ../src/logger/stderr.c ../src/logger/syslog.c +#SOCKET = $(LOGGER) ../src/socket.c ../src/socket/listen.c \ +# ../src/socket/accept.c ../src/socket/connect.c +#SERVER = $(SOCKET) ../src/server.c ../src/server/run.c \ +# ../src/server/close_conn.c ../src/utils/signalHandling.c +# +#cclassTest_SOURCES = $(CCLASS) cclassTest.c +#cclassTest_CFLAGS = -Wall -ggdb -O0 -finline-functions -I ../include -I .. -I . +# +#loggerTest_SOURCES = $(LOGGER) loggerTest.c +#loggerTest_CFLAGS = -Wall -ggdb -O0 -I ../include -I .. -I . +# +#socketTest_SOURCES = $(SOCKET) socketTest.c +#socketTest_CFLAGS = -Wall -ggdb -O0 -I ../include -I .. -I . +# +#serverTest_SOURCES = $(SERVER) serverTest.c +#serverTest_CFLAGS = -Wall -ggdb -O0 -I ../include -I .. -I . EXTRA_DIST = runtest.h mock/class.h