Browse Source

huge refactoring of build structure as well as other changes...sorry for the huge diff. These are the changes done within the sister project taskrambler, including reactivation of the existing tests as well as code coverage reports

master
Georg Hopp 14 years ago
parent
commit
317cc63d20
  1. 10
      .gitignore
  2. 1
      AUTHORS
  3. 4
      Makefile.am
  4. 33
      Makefile.am.coverage
  5. 27
      configure.ac
  6. 40
      include/auth.h
  7. 45
      include/auth/auth.h
  8. 54
      include/auth/credential.h
  9. 10
      include/auth/interface/auth.h
  10. 22
      include/auth/ldap.h
  11. 2
      include/cbuf.h
  12. 128
      include/class.h
  13. 128
      include/class/class.h
  14. 12
      include/class/interface.h
  15. 12
      include/class/interface/class.h
  16. 22
      include/commons.h
  17. 32
      include/credential.h
  18. 16
      include/hash.h
  19. 42
      include/hash/hash.h
  20. 10
      include/hash/interface/hashable.h
  21. 42
      include/hash/value.h
  22. 20
      include/hash_value.h
  23. 17
      include/http.h
  24. 22
      include/http/cookie.h
  25. 2
      include/http/header.h
  26. 2
      include/http/interface/http_intro.h
  27. 3
      include/http/message.h
  28. 2
      include/http/message/queue.h
  29. 2
      include/http/parser.h
  30. 2
      include/http/request.h
  31. 2
      include/http/response.h
  32. 2
      include/http/worker.h
  33. 28
      include/http/writer.h
  34. 2
      include/interface/observer.h
  35. 2
      include/interface/subject.h
  36. 52
      include/logger.h
  37. 10
      include/logger/interface/logger.h
  38. 57
      include/logger/logger.h
  39. 2
      include/server.h
  40. 2
      include/session.h
  41. 2
      include/socket.h
  42. 23
      include/stream.h
  43. 10
      include/stream/interface/reader.h
  44. 10
      include/stream/interface/writer.h
  45. 49
      include/stream/stream.h
  46. 2
      include/utils/hash.h
  47. 22
      include/utils/http.h
  48. 2
      include/utils/memory.h
  49. 2
      include/utils/signalHandling.h
  50. 76
      src/Makefile.am
  51. 6
      src/auth/Makefile.am
  52. 27
      src/auth/credential.c
  53. 6
      src/auth/interface/auth.c
  54. 31
      src/auth/ldap.c
  55. 13
      src/cbuf/Makefile.am
  56. 2
      src/cbuf/addr_index.c
  57. 3
      src/cbuf/cbuf.c
  58. 2
      src/cbuf/empty.c
  59. 2
      src/cbuf/get_data.c
  60. 2
      src/cbuf/get_free.c
  61. 2
      src/cbuf/get_line.c
  62. 2
      src/cbuf/get_read.c
  63. 2
      src/cbuf/get_write.c
  64. 2
      src/cbuf/inc_read.c
  65. 2
      src/cbuf/inc_write.c
  66. 2
      src/cbuf/is_empty.c
  67. 2
      src/cbuf/is_locked.c
  68. 2
      src/cbuf/lock.c
  69. 2
      src/cbuf/memchr.c
  70. 2
      src/cbuf/read.c
  71. 2
      src/cbuf/release.c
  72. 2
      src/cbuf/set_data.c
  73. 2
      src/cbuf/skip_non_alpha.c
  74. 2
      src/cbuf/write.c
  75. 6
      src/class/Makefile.am
  76. 12
      src/class/interface.c
  77. 8
      src/class/interface/i_class.c
  78. 42
      src/hash.c
  79. 9
      src/hash/Makefile.am
  80. 25
      src/hash/add.c
  81. 23
      src/hash/delete.c
  82. 22
      src/hash/each.c
  83. 23
      src/hash/get.c
  84. 63
      src/hash/hash.c
  85. 2
      src/hash/interface/hashable.c
  86. 29
      src/hash/value.c
  87. 41
      src/http/Makefile.am
  88. 28
      src/http/cookie.c
  89. 5
      src/http/header.c
  90. 2
      src/http/header/to_string.c
  91. 2
      src/http/interface/i_http_intro.c
  92. 5
      src/http/message.c
  93. 2
      src/http/message/get_version.c
  94. 2
      src/http/message/has_keep_alive.c
  95. 2
      src/http/message/has_valid_version.c
  96. 4
      src/http/message/header_size_get.c
  97. 4
      src/http/message/header_to_string.c
  98. 3
      src/http/message/queue.c
  99. 5
      src/http/parser.c
  100. 22
      src/http/parser/new_message.c

10
.gitignore

@ -1,5 +1,8 @@
.*.swp .*.swp
*.o *.o
*.a
*.gcda
*.gcno
.dirstamp .dirstamp
.deps/ .deps/
Makefile Makefile
@ -8,6 +11,10 @@ Makefile.in
m4/ m4/
/docs/ /docs/
/INSTALL /INSTALL
coverage.base
coverage.run
coverage.info
coveragereport/
*.m4 *.m4
/autom4te.cache/ /autom4te.cache/
/compile /compile
@ -18,4 +25,5 @@ m4/
/ltmain.sh /ltmain.sh
/missing /missing
stamp-h1 stamp-h1
src/webgameserver
src/taskrambler
/tests/*Test

1
AUTHORS

@ -0,0 +1 @@
Georg Hopp <georg@steffers.org>

4
Makefile.am

@ -5,6 +5,8 @@ ACLOCAL_AMFLAGS = -I m4
#create_token_LDADD = src/libtoken.la $(LIBOBJS) #create_token_LDADD = src/libtoken.la $(LIBOBJS)
#create_token_CFLAGS = -Wall -I include #create_token_CFLAGS = -Wall -I include
EXTRA_DIST = include assets
EXTRA_DIST = include assets certs
SUBDIRS = src tests SUBDIRS = src tests
include $(top_srcdir)/Makefile.am.coverage

33
Makefile.am.coverage

@ -0,0 +1,33 @@
# 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) -C tests $(AM_MAKEFLAGS) -k check-build
$(MAKE) $(AM_MAKEFLAGS) init-coverage-html
-$(MAKE) $(AM_MAKEFLAGS) -k check
$(MAKE) $(AM_MAKEFLAGS) generate-coverage-html
init-coverage-html:
$(LCOV) -d $(top_builddir) -c -i -o coverage.base --no-checksum --compat-libtool
generate-coverage-html:
@echo Collecting coverage data
$(LCOV) -d $(top_builddir) -c -o coverage.run --no-checksum --compat-libtool
$(LCOV) -d $(top_builddir) -a ./coverage.base -a ./coverage.run -o coverage.info --no-checksum --compat-libtool
LANG=C $(GENHTML) --prefix $(top_builddir) --output-directory coveragereport --title "Code Coverage" --legend --branch-coverage --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

27
configure.ac

@ -3,13 +3,22 @@
AC_PREREQ([2.68]) AC_PREREQ([2.68])
AC_INIT([webgameserver], [0.0.2], [Georg Hopp <georg@steffers.org>]) AC_INIT([webgameserver], [0.0.2], [Georg Hopp <georg@steffers.org>])
LT_INIT
AM_INIT_AUTOMAKE AM_INIT_AUTOMAKE
AC_COPYRIGHT([Copyright (C) 2012 Georg Hopp])
AC_REVISION([$Revision: 0.03 $])
#AM_INIT_AUTOMAKE([subdir-objects])
AM_SILENT_RULES([yes])
AC_COPYRIGHT([Copyright © 2012 Georg Hopp])
AC_REVISION([$Revision: 0.04 $])
AC_CONFIG_SRCDIR([src/webgameserver.c]) AC_CONFIG_SRCDIR([src/webgameserver.c])
AC_CONFIG_HEADERS([config.h]) AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4]) 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. # Checks for programs.
AC_PROG_CXX AC_PROG_CXX
AC_PROG_CC AC_PROG_CC
@ -37,5 +46,17 @@ AC_TYPE_SIZE_T
#AC_FUNC_MALLOC #AC_FUNC_MALLOC
AC_CHECK_FUNCS([memset]) AC_CHECK_FUNCS([memset])
AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile])
AC_CONFIG_FILES([Makefile
src/Makefile
src/auth/Makefile
src/cbuf/Makefile
src/class/Makefile
src/hash/Makefile
src/http/Makefile
src/logger/Makefile
src/server/Makefile
src/session/Makefile
src/socket/Makefile
src/stream/Makefile
tests/Makefile])
AC_OUTPUT AC_OUTPUT

40
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 <http://www.gnu.org/licenses/>.
*/
#ifndef __AUTH_H__ #ifndef __AUTH_H__
#define __AUTH_H__ #define __AUTH_H__
#include "class.h"
#include "auth/auth.h"
#include "auth/ldap.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__ #endif // __AUTH_H__

45
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 <http://www.gnu.org/licenses/>.
*/
#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:

54
include/auth/credential.h

@ -0,0 +1,54 @@
/**
* \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 <http://www.gnu.org/licenses/>.
*/
#ifndef __AUTH_CREDENTIAL_H__
#define __AUTH_CREDENTIAL_H__
#include <sys/types.h>
#include "class.h"
#define CRED_PWD(c) (((c)->cred).pwd)
typedef enum e_CredentialType {
CRED_PASSWORD = 0
} CredentialType;
CLASS(Credential) {
CredentialType type;
union {
struct {
char * user;
size_t nuser;
char * pass;
size_t npass;
} pwd;
} cred;
};
#endif // __AUTH_CREDENTIAL_H__
// vim: set ts=4 sw=4:

10
include/interface/auth.h → include/auth/interface/auth.h

@ -25,13 +25,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef __INTERFACE_AUTH_H__
#define __INTERFACE_AUTH_H__
#ifndef __AUTH_INTERFACE_AUTH_H__
#define __AUTH_INTERFACE_AUTH_H__
#include <stdarg.h> #include <stdarg.h>
#include "interface.h"
#include "credential.h"
#include "class.h"
#include "auth/credential.h"
typedef int (* fptr_authenticate)(void *, Credential); typedef int (* fptr_authenticate)(void *, Credential);
@ -44,6 +44,6 @@ struct i_Auth {
extern int authenticate(void *, Credential); extern int authenticate(void *, Credential);
#endif // __INTERFACE_AUTH_H__
#endif // __AUTH_INTERFACE_AUTH_H__
// vim: set ts=4 sw=4: // vim: set ts=4 sw=4:

22
include/auth/ldap.h

@ -1,3 +1,25 @@
/**
* \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 <http://www.gnu.org/licenses/>.
*/
#ifndef __AUTH_LDAP_H__ #ifndef __AUTH_LDAP_H__
#define __AUTH_LDAP_H__ #define __AUTH_LDAP_H__

2
include/cbuf.h

@ -11,7 +11,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

128
include/class.h

@ -1,131 +1,9 @@
/**
* \file
* My own class implementation for C. It combines a data structure
* with a set of dynamically linked methods defined by an interface. A
* dynamically linked method will be called via a selector method which in
* turn gets the implementation stored in the class.
*
* \author Georg Hopp
*
* \copyright
* Copyright (C) 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 <http://www.gnu.org/licenses/>.
*/
#ifndef __CLASS_H__ #ifndef __CLASS_H__
#define __CLASS_H__ #define __CLASS_H__
#include <stdarg.h>
#include <sys/types.h>
#include <string.h>
#include <assert.h>
#include "interface.h"
#ifndef _ISOC99_SOURCE
#define _ISOC99_SOURCE
#endif
#define CLASS_MAGIC 0xFEFE
#define CLASS(name) \
struct c_##name; \
typedef struct c_##name * name; \
extern struct class * const _##name; \
struct c_##name
#define EXTENDS(parent) \
const char _[sizeof(struct c_##parent)]
#define _NULL NULL
#define CREATE_CLASS(name,_parent,...) \
static struct class c_##name; \
static void _classInit_(void) { \
c_##name.parent = _##_parent; \
c_##name.init = NULL; \
} \
static struct class c_##name = { \
CLASS_MAGIC, \
NULL, \
sizeof(struct c_##name), \
_classInit_, \
INIT_IMPL(__VA_ARGS__) \
}; struct class * const _##name = &c_##name
#define GET_CLASS(object) (*(class_ptr *)((object) - sizeof(void*)))
#define IFACE_GET(class,iface) (interfaceGet(&((class)->impl),(iface)))
#define IFACE_EXISTS(class,iface) (NULL != IFACE_GET((class),(iface)))
/**
* \todo actually i use gcc feature ## for variadoc... think about
* a way to make this standard.
*/
#define _CALL(object,_iface,method,...) \
do { \
class_ptr class = GET_CLASS((object)); \
if (class->init) class->init(); \
iface = (struct i_##_iface *)IFACE_GET(class, &i_##_iface); \
while ((NULL == iface || NULL == iface->method) && HAS_PARENT(class)) { \
class = class->parent; \
if (class->init) class->init(); \
iface = (struct i_##_iface *)IFACE_GET(class, &i_##_iface); \
}; \
assert(NULL != iface->method); \
} while(0)
#define CALL(object,_iface,method,...) \
do { \
struct i_##_iface * iface; \
_CALL(object, _iface, method, ##__VA_ARGS__); \
iface->method(object, ##__VA_ARGS__); \
} while(0)
#define RETCALL(object,_iface,method,ret,...) \
do { \
struct i_##_iface * iface; \
_CALL(object, _iface, method, ##__VA_ARGS__); \
ret = iface->method(object, ##__VA_ARGS__); \
} while(0)
#define PARENTCALL(object,_iface,method,...) \
do { \
struct i_##_iface * iface; \
class_ptr class = GET_CLASS((object)); \
if (class->init) class->init(); \
assert(HAS_PARENT(class)); \
class = class->parent; \
if (class->init) class->init(); \
iface = (struct i_##_iface *)IFACE_GET(class, &i_##_iface); \
assert(NULL != iface->method); \
iface->method(object, ##__VA_ARGS__); \
} while(0)
#define HAS_PARENT(class) (NULL != ((class)->parent))
typedef void (* fptr_classInit)(void);
struct class;
typedef struct class * class_ptr;
struct class {
const int magic;
class_ptr parent;
size_t object_size;
fptr_classInit init;
struct iface_impl impl;
};
#include "class/class.h"
#include "class/interface.h"
#include "class/interface/class.h"
#endif // __CLASS_H__ #endif // __CLASS_H__

128
include/class/class.h

@ -0,0 +1,128 @@
/**
* \file
* My own class implementation for C. It combines a data structure
* with a set of dynamically linked methods defined by an interface. A
* dynamically linked method will be called via a selector method which in
* turn gets the implementation stored in the class.
*
* \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 <http://www.gnu.org/licenses/>.
*/
#ifndef __CLASS_CLASS_H__
#define __CLASS_CLASS_H__
#include <stdarg.h>
#include <sys/types.h>
#include <string.h>
#include <assert.h>
#include "class/interface.h"
#ifndef _ISOC99_SOURCE
#define _ISOC99_SOURCE
#endif
#define CLASS_MAGIC 0xFEFE
#define CLASS(name) \
struct c_##name; \
typedef struct c_##name * name; \
extern struct class * const _##name; \
struct c_##name
#define EXTENDS(parent) \
const char _[sizeof(struct c_##parent)]
#define _NULL NULL
#define CREATE_CLASS(name,_parent,...) \
static struct class c_##name; \
static class_ptr _classInit##name##_(void) { \
c_##name.parent = _##_parent; \
c_##name.init = NULL; \
return &c_##name; \
} \
static struct class c_##name = { \
CLASS_MAGIC, \
NULL, \
sizeof(struct c_##name), \
_classInit##name##_, \
INIT_IFACE_IMPL(__VA_ARGS__) \
}; struct class * const _##name = &c_##name
#define INIT_CLASS(class) ((class)->init? (class)->init() : (class))
#define GET_CLASS(object) (INIT_CLASS(*(class_ptr *)((void*)(object) - sizeof(void*))))
#define IFACE_GET(class,iface) (interfaceGet(&((class)->impl),(iface)))
#define HAS_PARENT(class) (NULL != ((class)->parent) && INIT_CLASS((class)->parent))
#define IS_OBJECT(obj) ((GET_CLASS((obj)))->magic == CLASS_MAGIC)
#define INSTANCE_OF(class,obj) ((GET_CLASS((obj))) == _##class)
/**
* \todo actually i use gcc feature ## for variadoc... think about
* a way to make this standard.
*/
#define _CALL(_class,_iface,method,...) \
do { \
class_ptr class = _class; \
iface = (struct i_##_iface *)IFACE_GET(class, &i_##_iface); \
while ((NULL == iface || NULL == iface->method) && HAS_PARENT(class)) { \
class = class->parent; \
iface = (struct i_##_iface *)IFACE_GET(class, &i_##_iface); \
} \
assert(NULL != iface->method); \
} while(0)
#define CALL(object,_iface,method,...) \
do { \
struct i_##_iface * iface; \
_CALL(GET_CLASS(object), _iface, method, ##__VA_ARGS__); \
iface->method(object, ##__VA_ARGS__); \
} while(0)
#define RETCALL(object,_iface,method,ret,...) \
do { \
struct i_##_iface * iface; \
_CALL(GET_CLASS(object), _iface, method, ##__VA_ARGS__); \
ret = iface->method(object, ##__VA_ARGS__); \
} while(0)
#define PARENTCALL(object,_iface,method,...) \
do { \
struct i_##_iface * iface; \
class_ptr pc_class = GET_CLASS((object)); \
assert(HAS_PARENT(pc_class)); \
_CALL(pc_class->parent, _iface, method, ##__VA_ARGS__); \
iface->method(object, ##__VA_ARGS__); \
} while(0)
struct class;
typedef struct class * class_ptr;
typedef class_ptr (* fptr_classInit)(void);
struct class {
const int magic;
class_ptr parent;
size_t object_size;
fptr_classInit init;
struct iface_impl impl;
};
#endif // __CLASS_CLASS_H__
// vim: set ts=4 sw=4:

12
include/interface.h → include/class/interface.h

@ -8,7 +8,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -24,8 +24,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef __INTERFACE_H__
#define __INTERFACE_H__
#ifndef __CLASS_INTERFACE_H__
#define __CLASS_INTERFACE_H__
#include <sys/types.h> #include <sys/types.h>
@ -36,7 +36,7 @@
static const struct i_##name i_##name##_impl = {&i_##name,__VA_ARGS__} static const struct i_##name i_##name##_impl = {&i_##name,__VA_ARGS__}
#define NUMARGS(...) (sizeof((const void*[]){__VA_ARGS__})/sizeof(void*)) #define NUMARGS(...) (sizeof((const void*[]){__VA_ARGS__})/sizeof(void*))
#define INIT_IMPL(...) {NUMARGS(__VA_ARGS__), 0, {__VA_ARGS__}}
#define INIT_IFACE_IMPL(...) {NUMARGS(__VA_ARGS__), 0, {__VA_ARGS__}}
struct interface { struct interface {
@ -52,8 +52,8 @@ struct iface_impl {
}; };
typedef struct iface_impl * iface_impl_ptr; typedef struct iface_impl * iface_impl_ptr;
extern struct interface * interfaceGet(iface_impl_ptr, const iface_ptr);
extern iface_ptr interfaceGet(iface_impl_ptr, const iface_ptr);
#endif // __INTERFACE_H__
#endif // __CLASS_INTERFACE_H__
// vim: set ts=4 sw=4: // vim: set ts=4 sw=4:

12
include/interface/class.h → include/class/interface/class.h

@ -7,7 +7,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -23,13 +23,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef __INTERFACE_CLASS_H__
#define __INTERFACE_CLASS_H__
#ifndef __CLASS_INTERFACE_CLASS_H__
#define __CLASS_INTERFACE_CLASS_H__
#include <stdarg.h> #include <stdarg.h>
#include "class.h"
#include "interface.h"
#include "class/class.h"
#include "class/interface.h"
typedef int (* fptr_ctor)(void *, va_list *); typedef int (* fptr_ctor)(void *, va_list *);
typedef void (* fptr_dtor)(void *); typedef void (* fptr_dtor)(void *);
@ -52,6 +52,6 @@ extern void * classClone(void *);
#define delete(object) classDelete((void **)&(object)) #define delete(object) classDelete((void **)&(object))
#define clone(object) classClone((void *)(object)) #define clone(object) classClone((void *)(object))
#endif // __INTERFACE_CLASS_H__
#endif // __CLASS_INTERFACE_CLASS_H__
// vim: set ts=4 sw=4: // vim: set ts=4 sw=4:

22
include/commons.h

@ -1,3 +1,25 @@
/**
* \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 <http://www.gnu.org/licenses/>.
*/
#ifndef __COMMONS_H__ #ifndef __COMMONS_H__
#define __COMMONS_H__ #define __COMMONS_H__

32
include/credential.h

@ -1,32 +0,0 @@
#ifndef __CREDENTIAL_H__
#define __CREDENTIAL_H__
#include <sys/types.h>
#include "class.h"
#define CRED_PWD(c) (((c)->cred).pwd)
typedef enum e_CredentialType {
CRED_PASSWORD = 0
} CredentialType;
CLASS(Credential) {
CredentialType type;
union {
struct {
char * user;
size_t nuser;
char * pass;
size_t npass;
} pwd;
} cred;
};
#endif // __CREDENTIAL_H__
// vim: set ts=4 sw=4:

16
include/hash.h

@ -1,19 +1,9 @@
#ifndef __HASH_H__ #ifndef __HASH_H__
#define __HASH_H__ #define __HASH_H__
#include <sys/types.h>
#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__ #endif // __HASH_H__

42
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 <http://www.gnu.org/licenses/>.
*/
#ifndef __HASH_HASH_H__
#define __HASH_HASH_H__
#include <sys/types.h>
#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:

10
include/interface/hashable.h → include/hash/interface/hashable.h

@ -5,7 +5,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -21,10 +21,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef __INTERFACE_HASHABLE_H__
#define __INTERFACE_HASHABLE_H__
#ifndef __HASH_INTERFACE_HASHABLE_H__
#define __HASH_INTERFACE_HASHABLE_H__
#include "interface.h"
#include "class.h"
typedef unsigned long (* fptr_hashableGetHash)(void *); typedef unsigned long (* fptr_hashableGetHash)(void *);
typedef void (* fptr_hashableHandleDouble)(void *, void *); typedef void (* fptr_hashableHandleDouble)(void *, void *);
@ -40,6 +40,6 @@ struct i_Hashable {
extern unsigned long hashableGetHash(void *); extern unsigned long hashableGetHash(void *);
extern void hashableHandleDouble(void *, void *); extern void hashableHandleDouble(void *, void *);
#endif // __INTERFACE_HASHABLE_H__
#endif // __HASH_INTERFACE_HASHABLE_H__
// vim: set ts=4 sw=4: // vim: set ts=4 sw=4:

42
include/hash/value.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 <http://www.gnu.org/licenses/>.
*/
#ifndef __HASH_VALUE_H__
#define __HASH_VALUE_H__
#include <sys/types.h>
#include "class.h"
CLASS(HashValue) {
unsigned long hash;
char * key;
void * value;
size_t nkey;
size_t nvalue;
};
#endif // __HASH_VALUE_H__
// vim: set ts=4 sw=4:

20
include/hash_value.h

@ -1,20 +0,0 @@
#ifndef __HASH_VALUE_H__
#define __HASH_VALUE_H__
#include <sys/types.h>
#include "class.h"
CLASS(HashValue) {
unsigned long hash;
char * key;
void * value;
size_t nkey;
size_t nvalue;
};
#endif // __HASH_VALUE_H__
// vim: set ts=4 sw=4:

17
include/http.h

@ -0,0 +1,17 @@
#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"
#include "http/interface/http_intro.h"
#endif // __HTTP_H__
// vim: set ts=4 sw=4:

22
include/http/cookie.h

@ -1,3 +1,25 @@
/**
* \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 <http://www.gnu.org/licenses/>.
*/
#ifndef __HTTP_COOKIE_H__ #ifndef __HTTP_COOKIE_H__
#define __HTTP_COOKIE_H__ #define __HTTP_COOKIE_H__

2
include/http/header.h

@ -6,7 +6,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

2
include/interface/http_intro.h → include/http/interface/http_intro.h

@ -7,7 +7,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

3
include/http/message.h

@ -5,7 +5,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -38,7 +38,6 @@ CLASS(HttpMessage) {
char * version; char * version;
Hash header; Hash header;
Hash cookies;
HttpMessageType type; HttpMessageType type;
Stream handle; Stream handle;

2
include/http/message/queue.h

@ -7,7 +7,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

2
include/http/parser.h

@ -5,7 +5,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

2
include/http/request.h

@ -5,7 +5,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

2
include/http/response.h

@ -5,7 +5,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

2
include/http/worker.h

@ -5,7 +5,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

28
include/http/writer.h

@ -5,20 +5,20 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* - Copyright (C) 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 <http://www.gnu.org/licenses/>.
* 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 <http://www.gnu.org/licenses/>.
*/ */
#ifndef __HTTP_WRITER_H__ #ifndef __HTTP_WRITER_H__

2
include/interface/observer.h

@ -5,7 +5,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

2
include/interface/subject.h

@ -5,7 +5,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

52
include/logger.h

@ -1,56 +1,8 @@
/**
* \file
* A generic logger class and two extended classes, One that logs to
* stderr and one that logs to the system syslog.
*
* \author Georg Hopp
*
* \copyright
* Copyright (C) 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 <http://www.gnu.org/licenses/>.
*/
#ifndef __LOGGER_H__ #ifndef __LOGGER_H__
#define __LOGGER_H__ #define __LOGGER_H__
#include "class.h"
typedef enum logger_level {
LOGGER_DEBUG=0,
LOGGER_INFO,
LOGGER_NOTICE,
LOGGER_WARNING,
LOGGER_ERR,
LOGGER_CRIT,
LOGGER_ALERT,
LOGGER_EMERG
} logger_level;
extern const char * const logger_level_str[];
CLASS(Logger) {
logger_level min_level;
};
CLASS(LoggerStderr) {
EXTENDS(Logger);
};
CLASS(LoggerSyslog) {
EXTENDS(Logger);
};
#include "logger/logger.h"
#include "logger/interface/logger.h"
#endif // __LOGGER_H__ #endif // __LOGGER_H__

10
include/interface/logger.h → include/logger/interface/logger.h

@ -5,7 +5,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -21,12 +21,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef __INTERFACE_LOGGER_H__
#define __INTERFACE_LOGGER_H__
#ifndef __LOGGER_INTERFACE_LOGGER_H__
#define __LOGGER_INTERFACE_LOGGER_H__
#include <stdarg.h> #include <stdarg.h>
#include "interface.h"
#include "class.h"
#include "logger.h" #include "logger.h"
typedef void (* fptr_log)(void *, logger_level, const char * const); typedef void (* fptr_log)(void *, logger_level, const char * const);
@ -40,6 +40,6 @@ struct i_Logger {
extern void loggerLog(void *, logger_level, const char * const, ...); extern void loggerLog(void *, logger_level, const char * const, ...);
#endif // __INTERFACE_LOGGER_H__
#endif // __LOGGER_INTERFACE_LOGGER_H__
// vim: set ts=4 sw=4: // vim: set ts=4 sw=4:

57
include/logger/logger.h

@ -0,0 +1,57 @@
/**
* \file
* A generic logger class and two extended classes, One that logs to
* stderr and one that logs to the system syslog.
*
* \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 <http://www.gnu.org/licenses/>.
*/
#ifndef __LOGGER_LOGGER_H__
#define __LOGGER_LOGGER_H__
#include "class.h"
typedef enum logger_level {
LOGGER_DEBUG=0,
LOGGER_INFO,
LOGGER_NOTICE,
LOGGER_WARNING,
LOGGER_ERR,
LOGGER_CRIT,
LOGGER_ALERT,
LOGGER_EMERG
} logger_level;
extern const char * const logger_level_str[];
CLASS(Logger) {
logger_level min_level;
};
CLASS(LoggerStderr) {
EXTENDS(Logger);
};
CLASS(LoggerSyslog) {
EXTENDS(Logger);
};
#endif // __LOGGER_LOGGER_H__
// vim: set ts=4 sw=4:

2
include/server.h

@ -7,7 +7,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

2
include/session.h

@ -4,7 +4,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

2
include/socket.h

@ -6,7 +6,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

23
include/stream.h

@ -1,26 +1,9 @@
#ifndef __STREAM_H__ #ifndef __STREAM_H__
#define __STREAM_H__ #define __STREAM_H__
#include <sys/types.h>
#include <openssl/ssl.h>
#include "class.h"
typedef enum e_StreamHandleType {
STREAM_FD = 0,
STREAM_SSL
} StreamHandleType;
CLASS(Stream) {
StreamHandleType type;
union {
int fd;
SSL * ssl;
} handle;
};
ssize_t streamRead(Stream, void *, size_t);
ssize_t streamWrite(Stream, void *, size_t);
#include "stream/stream.h"
#include "stream/interface/reader.h"
#include "stream/interface/writer.h"
#endif // __STREAM_H__ #endif // __STREAM_H__

10
include/interface/stream_reader.h → include/stream/interface/reader.h

@ -6,7 +6,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -22,12 +22,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef __STREAM_READER_H__
#define __STREAM_READER_H__
#ifndef __STREAM_INTERFACE_READER_H__
#define __STREAM_INTERFACE_READER_H__
#include <sys/types.h> #include <sys/types.h>
#include "stream.h"
#include "stream/stream.h"
typedef ssize_t (* fptr_streamReaderRead)(void *, Stream); typedef ssize_t (* fptr_streamReaderRead)(void *, Stream);
@ -40,6 +40,6 @@ struct i_StreamReader {
extern ssize_t streamReaderRead(void *, Stream); extern ssize_t streamReaderRead(void *, Stream);
#endif // __STREAM_READER_H__
#endif // __STREAM_INTERFACE_READER_H__
// vim: set ts=4 sw=4: // vim: set ts=4 sw=4:

10
include/interface/stream_writer.h → include/stream/interface/writer.h

@ -6,7 +6,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -22,12 +22,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef __STREAM_WRITER_H__
#define __STREAM_WRITER_H__
#ifndef __STREAM_INTERFACE_WRITER_H__
#define __STREAM_INTERFACE_WRITER_H__
#include <sys/types.h> #include <sys/types.h>
#include "stream.h"
#include "stream/stream.h"
typedef ssize_t (* fptr_streamWriterWrite)(void *, Stream); typedef ssize_t (* fptr_streamWriterWrite)(void *, Stream);
@ -40,6 +40,6 @@ struct i_StreamWriter {
extern ssize_t streamWriterWrite(void *, Stream); extern ssize_t streamWriterWrite(void *, Stream);
#endif // __STREAM_WRITER_H__
#endif // __STREAM_INTERFACE_WRITER_H__
// vim: set ts=4 sw=4: // vim: set ts=4 sw=4:

49
include/stream/stream.h

@ -0,0 +1,49 @@
/**
* \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 <http://www.gnu.org/licenses/>.
*/
#ifndef __STREAM_STREAM_H__
#define __STREAM_STREAM_H__
#include <sys/types.h>
#include <openssl/ssl.h>
#include "class.h"
typedef enum e_StreamHandleType {
STREAM_FD = 0,
STREAM_SSL
} StreamHandleType;
CLASS(Stream) {
StreamHandleType type;
union {
int fd;
SSL * ssl;
} handle;
};
ssize_t streamRead(Stream, void *, size_t);
ssize_t streamWrite(Stream, void *, size_t);
#endif // __STREAM_STREAM_H__
// vim: set ts=4 sw=4:

2
include/utils/hash.h

@ -5,7 +5,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

22
include/utils/http.h

@ -1,3 +1,25 @@
/**
* \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 <http://www.gnu.org/licenses/>.
*/
#ifndef __UTILS_HTTP_H__ #ifndef __UTILS_HTTP_H__
#define __UTILS_HTTP_H__ #define __UTILS_HTTP_H__

2
include/utils/memory.h

@ -4,7 +4,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

2
include/utils/signalHandling.h

@ -5,7 +5,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

76
src/Makefile.am

@ -1,71 +1,31 @@
ACLOCAL_AMFLAGS = -I m4 ACLOCAL_AMFLAGS = -I m4
AUTOMAKE_OPTIONS = subdir-objects
IFACE = interface/class.c interface/stream_reader.c interface/logger.c \
interface/stream_writer.c interface/http_intro.c \
interface/subject.c interface/observer.c interface.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
IFACE = interface/subject.c \
interface/observer.c
UTILS = utils/hash.c \ UTILS = utils/hash.c \
utils/memory.c \ utils/memory.c \
utils/http.c \ utils/http.c \
utils/daemonize.c \ utils/daemonize.c \
utils/signalHandling.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 \
./logger/liblogger.a \
./server/libserver.a \
./session/libsession.a \
./socket/libsocket.a \
./stream/libstream.a
AM_CFLAGS = -Wall -I ../include/ AM_CFLAGS = -Wall -I ../include/
bin_PROGRAMS = webgameserver bin_PROGRAMS = webgameserver
webgameserver_SOURCES = webgameserver.c \
$(IFACE) $(SOCKET) $(SERVER) $(LOGGER) $(MSG) $(REQ) \
$(WRITER) $(RESP) $(HEADER) $(PARSER) $(WORKER) $(CB) \
$(UTILS) $(MSGQ) $(SESSION) $(STREAM) $(HASH) $(AUTH)
webgameserver_CFLAGS = -Wall -I ../include/
webgameserver_LDFLAGS = -lrt -lssl -lldap
webgameserver_SOURCES = webgameserver.c $(IFACE) $(UTILS)
webgameserver_CFLAGS = -Wall -I ../include/# $(COVERAGE_CFLAGS)
webgameserver_LDADD = $(LIBS) -lrt -lssl -lldap
#webgameserver_LDFLAGS = $(COVERAGE_LDFLAGS)
SUBDIRS = auth cbuf class hash http logger server session socket stream

6
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/

27
src/credential.c → src/auth/credential.c

@ -1,14 +1,35 @@
/**
* \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 <http://www.gnu.org/licenses/>.
*/
#include <stdarg.h> #include <stdarg.h>
#include <sys/types.h> #include <sys/types.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "credential.h"
#include "class.h" #include "class.h"
#include "interface/class.h"
#include "utils/memory.h" #include "utils/memory.h"
#include "auth/credential.h"
static static
int int
credentialCtor(void * _this, va_list * params) credentialCtor(void * _this, va_list * params)

6
src/interface/auth.c → src/auth/interface/auth.c

@ -20,9 +20,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#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 = { const struct interface i_Auth = {
"auth", "auth",

31
src/auth/ldap.c

@ -1,18 +1,39 @@
/**
* \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 <http://www.gnu.org/licenses/>.
*/
#include <stdarg.h> #include <stdarg.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <ldap.h> #include <ldap.h>
#include "auth/ldap.h"
#include "class.h" #include "class.h"
#include "credential.h"
#include "interface/class.h"
#include "interface/auth.h"
#include "utils/memory.h" #include "utils/memory.h"
#include "commons.h" #include "commons.h"
#include "auth/ldap.h"
#include "auth/credential.h"
#include "auth/interface/auth.h"
static static
int int
authLdapCtor(void * _this, va_list * params) authLdapCtor(void * _this, va_list * params)

13
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/

2
src/cbuf/addr_index.c

@ -4,7 +4,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

3
src/cbuf.c → src/cbuf/cbuf.c

@ -4,7 +4,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -34,7 +34,6 @@
#include <fcntl.h> #include <fcntl.h>
#include "class.h" #include "class.h"
#include "interface/class.h"
#include "utils/memory.h" #include "utils/memory.h"
#include "cbuf.h" #include "cbuf.h"

2
src/cbuf/empty.c

@ -4,7 +4,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

2
src/cbuf/get_data.c

@ -4,7 +4,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

2
src/cbuf/get_free.c

@ -4,7 +4,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

2
src/cbuf/get_line.c

@ -4,7 +4,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

2
src/cbuf/get_read.c

@ -4,7 +4,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

2
src/cbuf/get_write.c

@ -4,7 +4,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

2
src/cbuf/inc_read.c

@ -4,7 +4,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

2
src/cbuf/inc_write.c

@ -4,7 +4,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

2
src/cbuf/is_empty.c

@ -4,7 +4,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

2
src/cbuf/is_locked.c

@ -4,7 +4,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

2
src/cbuf/lock.c

@ -4,7 +4,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

2
src/cbuf/memchr.c

@ -4,7 +4,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

2
src/cbuf/read.c

@ -4,7 +4,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

2
src/cbuf/release.c

@ -4,7 +4,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

2
src/cbuf/set_data.c

@ -4,7 +4,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

2
src/cbuf/skip_non_alpha.c

@ -4,7 +4,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

2
src/cbuf/write.c

@ -4,7 +4,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

6
src/class/Makefile.am

@ -0,0 +1,6 @@
ACLOCAL_AMFLAGS = -I m4
noinst_LIBRARIES = libclass.a
libclass_a_SOURCES = interface.c interface/i_class.c
libclass_a_CFLAGS = -Wall -I ../../include/

12
src/interface.c → src/class/interface.c

@ -4,7 +4,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -23,7 +23,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <stdlib.h> #include <stdlib.h>
#include "interface.h"
#include "class/interface.h"
#include "commons.h" #include "commons.h"
static static
@ -40,25 +40,25 @@ comp(const void * _a, const void * _b)
* this one is important in selector functions to get the correct interface * this one is important in selector functions to get the correct interface
* implementation of a class. * implementation of a class.
*/ */
struct interface *
iface_ptr
interfaceGet(iface_impl_ptr iface_impl, const iface_ptr _iface) interfaceGet(iface_impl_ptr iface_impl, const iface_ptr _iface)
{ {
const iface_ptr * iface = &_iface; const iface_ptr * iface = &_iface;
void * dummy;
iface_ptr * found;
if (! iface_impl->simpl) { if (! iface_impl->simpl) {
qsort((void**)(iface_impl->impl), iface_impl->nimpl, sizeof(iface_ptr), comp); qsort((void**)(iface_impl->impl), iface_impl->nimpl, sizeof(iface_ptr), comp);
iface_impl->simpl=TRUE; iface_impl->simpl=TRUE;
} }
dummy = bsearch(
found = bsearch(
&iface, &iface,
iface_impl->impl, iface_impl->impl,
iface_impl->nimpl, iface_impl->nimpl,
sizeof(iface_ptr), sizeof(iface_ptr),
comp); comp);
return dummy? *(struct interface **)dummy : dummy;
return found? *found : (iface_ptr)NULL;
} }
// vim: set ts=4 sw=4: // vim: set ts=4 sw=4:

8
src/interface/class.c → src/class/interface/i_class.c

@ -4,7 +4,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -24,8 +24,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
#include "class.h"
#include "interface/class.h"
#include "class/class.h"
#include "class/interface/class.h"
const const
struct interface i_Class = { struct interface i_Class = {
@ -40,8 +40,6 @@ classNew(class_ptr class, ...)
va_list params; va_list params;
int ret; int ret;
if (class->init) class->init();
* (class_ptr *)object = class; * (class_ptr *)object = class;
object += sizeof(void*); object += sizeof(void*);

42
src/hash.c

@ -1,42 +0,0 @@
#define _GNU_SOURCE
#include <search.h>
#include <stdarg.h>
#include "hash.h"
#include "class.h"
#include "interface/class.h"
static
int
hashCtor(void * _this, va_list * params)
{
return 0;
}
static
inline
void
tDelete(void * node)
{
delete(node);
}
static
void
hashDtor(void * _this)
{
Hash this = _this;
/**
* this is a GNU extension...anyway on most non
* GNUish systems i would not use tsearch anyway
* as the trees will be unbalanced.
*/
tdestroy(this->root, tDelete);
}
INIT_IFACE(Class, hashCtor, hashDtor, NULL);
CREATE_CLASS(Hash, NULL, IFACE(Class));
// vim: set ts=4 sw=4:

9
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/

25
src/hash/add.c

@ -1,8 +1,29 @@
/**
* \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 <http://www.gnu.org/licenses/>.
*/
#include <search.h> #include <search.h>
#include "hash.h" #include "hash.h"
#include "interface/hashable.h"
#include "interface/class.h"
#include "class.h"
static static
inline inline

23
src/hash/delete.c

@ -1,8 +1,29 @@
/**
* \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 <http://www.gnu.org/licenses/>.
*/
#include <search.h> #include <search.h>
#include <sys/types.h> #include <sys/types.h>
#include "hash.h" #include "hash.h"
#include "interface/hashable.h"
#include "utils/hash.h" #include "utils/hash.h"
static static

22
src/hash/each.c

@ -1,3 +1,25 @@
/**
* \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 <http://www.gnu.org/licenses/>.
*/
#include <search.h> #include <search.h>
#include "hash.h" #include "hash.h"

23
src/hash/get.c

@ -1,8 +1,29 @@
/**
* \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 <http://www.gnu.org/licenses/>.
*/
#include <search.h> #include <search.h>
#include <sys/types.h> #include <sys/types.h>
#include "hash.h" #include "hash.h"
#include "interface/hashable.h"
#include "utils/hash.h" #include "utils/hash.h"
static static

63
src/hash/hash.c

@ -0,0 +1,63 @@
/**
* \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 <http://www.gnu.org/licenses/>.
*/
#define _GNU_SOURCE
#include <search.h>
#include <stdarg.h>
#include "hash/hash.h"
#include "class.h"
static
int
hashCtor(void * _this, va_list * params)
{
return 0;
}
static
inline
void
tDelete(void * node)
{
delete(node);
}
static
void
hashDtor(void * _this)
{
Hash this = _this;
/**
* this is a GNU extension...anyway on most non
* GNUish systems i would not use tsearch anyway
* as the trees will be unbalanced.
*/
tdestroy(this->root, tDelete);
}
INIT_IFACE(Class, hashCtor, hashDtor, NULL);
CREATE_CLASS(Hash, NULL, IFACE(Class));
// vim: set ts=4 sw=4:

2
src/interface/hashable.c → src/hash/interface/hashable.c

@ -25,7 +25,7 @@
#include <stdarg.h> #include <stdarg.h>
#include "class.h" #include "class.h"
#include "interface/hashable.h"
#include "hash/interface/hashable.h"
const struct interface i_Hashable = { const struct interface i_Hashable = {
"hashable", "hashable",

29
src/hash_value.c → src/hash/value.c

@ -1,14 +1,37 @@
/**
* \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 <http://www.gnu.org/licenses/>.
*/
#include <stdarg.h> #include <stdarg.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include "hash_value.h"
#include "class.h"
#include "utils/hash.h" #include "utils/hash.h"
#include "utils/memory.h" #include "utils/memory.h"
#include "commons.h" #include "commons.h"
#include "interface/class.h"
#include "interface/hashable.h"
#include "hash/value.h"
#include "hash/interface/hashable.h"
static static
int int

41
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/p_header.c \
parser/p_body.c \
parser/p_request_vars.c \
parser/p_post_vars.c
WRITER = writer.c \
writer/write.c
WORKER = worker.c \
worker/process.c \
worker/answer.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) interface/i_http_intro.c
libhttp_a_CFLAGS = -Wall -I ../../include/

28
src/http/cookie.c

@ -1,11 +1,33 @@
/**
* \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 <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdarg.h> #include <stdarg.h>
#include <sys/types.h> #include <sys/types.h>
#include "cookie.h"
#include "interface/class.h"
#include "interface/hashable"
#include "class.h"
#include "hash.h"
#include "http/cookie.h"
#include "utils/hash.h" #include "utils/hash.h"
#include "utils/memory.h" #include "utils/memory.h"

5
src/http/header.c

@ -5,7 +5,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -25,9 +25,8 @@
#include <string.h> #include <string.h>
#include "class.h" #include "class.h"
#include "interface/class.h"
#include "hash.h"
#include "http/header.h" #include "http/header.h"
#include "interface/hashable.h"
#include "utils/hash.h" #include "utils/hash.h"
#include "utils/memory.h" #include "utils/memory.h"

2
src/http/header/to_string.c

@ -5,7 +5,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

2
src/interface/http_intro.c → src/http/interface/i_http_intro.c

@ -21,7 +21,7 @@
*/ */
#include "class.h" #include "class.h"
#include "interface/http_intro.h"
#include "http/interface/http_intro.h"
const struct interface i_HttpIntro = { const struct interface i_HttpIntro = {
"httpIntro", "httpIntro",

5
src/http/message.c

@ -4,7 +4,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -31,7 +31,6 @@
#include <unistd.h> #include <unistd.h>
#include "class.h" #include "class.h"
#include "interface/class.h"
#include "hash.h" #include "hash.h"
#include "http/message.h" #include "http/message.h"
#include "utils/memory.h" #include "utils/memory.h"
@ -48,7 +47,6 @@ httpMessageCtor(void * _this, va_list * params)
strcpy(this->version, version); strcpy(this->version, version);
this->header = new(Hash); this->header = new(Hash);
this->cookies = new(Hash);
return 0; return 0;
} }
@ -60,7 +58,6 @@ httpMessageDtor(void * _this)
HttpMessage this = _this; HttpMessage this = _this;
delete(this->header); delete(this->header);
delete(this->cookies);
FREE(this->version); FREE(this->version);

2
src/http/message/get_version.c

@ -4,7 +4,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

2
src/http/message/has_keep_alive.c

@ -4,7 +4,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

2
src/http/message/has_valid_version.c

@ -4,7 +4,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

4
src/http/message/header_size_get.c

@ -4,7 +4,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -27,7 +27,7 @@
#include "http/message.h" #include "http/message.h"
#include "http/response.h" #include "http/response.h"
#include "http/header.h" #include "http/header.h"
#include "interface/http_intro.h"
#include "http/interface/http_intro.h"
#include "hash.h" #include "hash.h"
static size_t size; static size_t size;

4
src/http/message/header_to_string.c

@ -4,7 +4,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -26,7 +26,7 @@
#include "http/response.h" #include "http/response.h"
#include "http/header.h" #include "http/header.h"
#include "interface/http_intro.h"
#include "http/interface/http_intro.h"
#include "hash.h" #include "hash.h"
static char * string; static char * string;

3
src/http/message/queue.c

@ -4,7 +4,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -23,7 +23,6 @@
#include <stdarg.h> #include <stdarg.h>
#include "class.h" #include "class.h"
#include "interface/class.h"
#include "http/message/queue.h" #include "http/message/queue.h"

5
src/http/parser.c

@ -4,7 +4,7 @@
* \author Georg Hopp * \author Georg Hopp
* *
* \copyright * \copyright
* Copyright (C) 2012 Georg Hopp
* Copyright © 2012 Georg Hopp
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -25,8 +25,7 @@
#include <stdarg.h> #include <stdarg.h>
#include "class.h" #include "class.h"
#include "interface/class.h"
#include "interface/stream_reader.h"
#include "stream.h"
#include "http/parser.h" #include "http/parser.h"
#include "http/message/queue.h" #include "http/message/queue.h"

22
src/http/parser/new_message.c

@ -1,3 +1,25 @@
/**
* \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 <http://www.gnu.org/licenses/>.
*/
#include "http/parser.h" #include "http/parser.h"
#include "utils/http.h" #include "utils/http.h"

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save