Commit 317cc63d2054fdded252779b317c20a2c79ff389
1 parent
4f4e6438
huge refactoring of build structure as well as other changes...sorry for the hug…
…e diff. These are the changes done within the sister project taskrambler, including reactivation of the existing tests as well as code coverage reports
Showing
167 changed files
with
1845 additions
and
833 deletions
1 | .*.swp | 1 | .*.swp |
2 | *.o | 2 | *.o |
3 | +*.a | ||
4 | +*.gcda | ||
5 | +*.gcno | ||
3 | .dirstamp | 6 | .dirstamp |
4 | .deps/ | 7 | .deps/ |
5 | Makefile | 8 | Makefile |
@@ -8,6 +11,10 @@ Makefile.in | @@ -8,6 +11,10 @@ Makefile.in | ||
8 | m4/ | 11 | m4/ |
9 | /docs/ | 12 | /docs/ |
10 | /INSTALL | 13 | /INSTALL |
14 | +coverage.base | ||
15 | +coverage.run | ||
16 | +coverage.info | ||
17 | +coveragereport/ | ||
11 | *.m4 | 18 | *.m4 |
12 | /autom4te.cache/ | 19 | /autom4te.cache/ |
13 | /compile | 20 | /compile |
@@ -18,4 +25,5 @@ m4/ | @@ -18,4 +25,5 @@ m4/ | ||
18 | /ltmain.sh | 25 | /ltmain.sh |
19 | /missing | 26 | /missing |
20 | stamp-h1 | 27 | stamp-h1 |
21 | -src/webgameserver | 28 | +src/taskrambler |
29 | +/tests/*Test |
@@ -5,6 +5,8 @@ ACLOCAL_AMFLAGS = -I m4 | @@ -5,6 +5,8 @@ ACLOCAL_AMFLAGS = -I m4 | ||
5 | #create_token_LDADD = src/libtoken.la $(LIBOBJS) | 5 | #create_token_LDADD = src/libtoken.la $(LIBOBJS) |
6 | #create_token_CFLAGS = -Wall -I include | 6 | #create_token_CFLAGS = -Wall -I include |
7 | 7 | ||
8 | -EXTRA_DIST = include assets | 8 | +EXTRA_DIST = include assets certs |
9 | 9 | ||
10 | SUBDIRS = src tests | 10 | SUBDIRS = src tests |
11 | + | ||
12 | +include $(top_srcdir)/Makefile.am.coverage |
Makefile.am.coverage
0 → 100644
1 | + | ||
2 | +# Coverage targets | ||
3 | + | ||
4 | +#if HAVE_GCOV | ||
5 | + | ||
6 | + .PHONY: clean-gcda | ||
7 | + clean-gcda: | ||
8 | + @echo Removing old coverage results | ||
9 | + -find -name '*.gcda' -print | xargs -r rm | ||
10 | + | ||
11 | + .PHONY: coverage-html generate-coverage-html clean-coverage-html | ||
12 | + coverage-html: clean-gcda | ||
13 | + -$(MAKE) -C tests $(AM_MAKEFLAGS) -k check-build | ||
14 | + $(MAKE) $(AM_MAKEFLAGS) init-coverage-html | ||
15 | + -$(MAKE) $(AM_MAKEFLAGS) -k check | ||
16 | + $(MAKE) $(AM_MAKEFLAGS) generate-coverage-html | ||
17 | + | ||
18 | + init-coverage-html: | ||
19 | + $(LCOV) -d $(top_builddir) -c -i -o coverage.base --no-checksum --compat-libtool | ||
20 | + | ||
21 | + generate-coverage-html: | ||
22 | + @echo Collecting coverage data | ||
23 | + $(LCOV) -d $(top_builddir) -c -o coverage.run --no-checksum --compat-libtool | ||
24 | + $(LCOV) -d $(top_builddir) -a ./coverage.base -a ./coverage.run -o coverage.info --no-checksum --compat-libtool | ||
25 | + LANG=C $(GENHTML) --prefix $(top_builddir) --output-directory coveragereport --title "Code Coverage" --legend --branch-coverage --show-details coverage.info | ||
26 | + | ||
27 | + clean-coverage-html: clean-gcda | ||
28 | + -$(LCOV) --directory $(top_builddir) -z | ||
29 | + -rm -rf coverage.info coveragereport | ||
30 | + | ||
31 | + clean-local: clean-coverage-html | ||
32 | + | ||
33 | +#endif # HAVE_GCOV |
@@ -3,13 +3,22 @@ | @@ -3,13 +3,22 @@ | ||
3 | 3 | ||
4 | AC_PREREQ([2.68]) | 4 | AC_PREREQ([2.68]) |
5 | AC_INIT([webgameserver], [0.0.2], [Georg Hopp <georg@steffers.org>]) | 5 | AC_INIT([webgameserver], [0.0.2], [Georg Hopp <georg@steffers.org>]) |
6 | +LT_INIT | ||
6 | AM_INIT_AUTOMAKE | 7 | AM_INIT_AUTOMAKE |
7 | -AC_COPYRIGHT([Copyright (C) 2012 Georg Hopp]) | ||
8 | -AC_REVISION([$Revision: 0.03 $]) | 8 | +#AM_INIT_AUTOMAKE([subdir-objects]) |
9 | +AM_SILENT_RULES([yes]) | ||
10 | +AC_COPYRIGHT([Copyright © 2012 Georg Hopp]) | ||
11 | +AC_REVISION([$Revision: 0.04 $]) | ||
9 | AC_CONFIG_SRCDIR([src/webgameserver.c]) | 12 | AC_CONFIG_SRCDIR([src/webgameserver.c]) |
10 | AC_CONFIG_HEADERS([config.h]) | 13 | AC_CONFIG_HEADERS([config.h]) |
11 | AC_CONFIG_MACRO_DIR([m4]) | 14 | AC_CONFIG_MACRO_DIR([m4]) |
12 | 15 | ||
16 | +m4_include([m4/gcov.m4]) | ||
17 | +AC_TDD_GCOV | ||
18 | +AC_SUBST(COVERAGE_CFLAGS) | ||
19 | +AC_SUBST(COVERAGE_CXXFLAGS) | ||
20 | +AC_SUBST(COVERAGE_LDFLAGS) | ||
21 | + | ||
13 | # Checks for programs. | 22 | # Checks for programs. |
14 | AC_PROG_CXX | 23 | AC_PROG_CXX |
15 | AC_PROG_CC | 24 | AC_PROG_CC |
@@ -37,5 +46,17 @@ AC_TYPE_SIZE_T | @@ -37,5 +46,17 @@ AC_TYPE_SIZE_T | ||
37 | #AC_FUNC_MALLOC | 46 | #AC_FUNC_MALLOC |
38 | AC_CHECK_FUNCS([memset]) | 47 | AC_CHECK_FUNCS([memset]) |
39 | 48 | ||
40 | -AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile]) | 49 | +AC_CONFIG_FILES([Makefile |
50 | + src/Makefile | ||
51 | + src/auth/Makefile | ||
52 | + src/cbuf/Makefile | ||
53 | + src/class/Makefile | ||
54 | + src/hash/Makefile | ||
55 | + src/http/Makefile | ||
56 | + src/logger/Makefile | ||
57 | + src/server/Makefile | ||
58 | + src/session/Makefile | ||
59 | + src/socket/Makefile | ||
60 | + src/stream/Makefile | ||
61 | + tests/Makefile]) | ||
41 | AC_OUTPUT | 62 | AC_OUTPUT |
1 | -/** | ||
2 | - * \file | ||
3 | - * Authenticatio module factory | ||
4 | - * | ||
5 | - * A factory to get a specific authentication module. | ||
6 | - * An authentication module is a class that implement the Auth interface. | ||
7 | - * | ||
8 | - * \author Georg Hopp | ||
9 | - * | ||
10 | - * \copyright | ||
11 | - * Copyright © 2012 Georg Hopp | ||
12 | - * | ||
13 | - * This program is free software: you can redistribute it and/or modify | ||
14 | - * it under the terms of the GNU General Public License as published by | ||
15 | - * the Free Software Foundation, either version 3 of the License, or | ||
16 | - * (at your option) any later version. | ||
17 | - * | ||
18 | - * This program is distributed in the hope that it will be useful, | ||
19 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
20 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
21 | - * GNU General Public License for more details. | ||
22 | - * | ||
23 | - * You should have received a copy of the GNU General Public License | ||
24 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
25 | - */ | ||
26 | - | ||
27 | #ifndef __AUTH_H__ | 1 | #ifndef __AUTH_H__ |
28 | #define __AUTH_H__ | 2 | #define __AUTH_H__ |
29 | 3 | ||
30 | -#include "class.h" | 4 | +#include "auth/auth.h" |
31 | #include "auth/ldap.h" | 5 | #include "auth/ldap.h" |
32 | - | ||
33 | -typedef enum e_AuthModule { | ||
34 | - AUTH_LDAP = 0 | ||
35 | -} AuthModule; | ||
36 | - | ||
37 | -CLASS(Auth) { | ||
38 | -}; | ||
39 | - | ||
40 | -void * authCreateById(Auth, int); | ||
41 | -AuthLdap authCreateLdap(Auth); | 6 | +#include "auth/credential.h" |
7 | +#include "auth/interface/auth.h" | ||
42 | 8 | ||
43 | #endif // __AUTH_H__ | 9 | #endif // __AUTH_H__ |
44 | 10 |
include/auth/auth.h
0 → 100644
1 | +/** | ||
2 | + * \file | ||
3 | + * Authenticatio module factory | ||
4 | + * | ||
5 | + * A factory to get a specific authentication module. | ||
6 | + * An authentication module is a class that implement the Auth interface. | ||
7 | + * | ||
8 | + * \author Georg Hopp | ||
9 | + * | ||
10 | + * \copyright | ||
11 | + * Copyright © 2012 Georg Hopp | ||
12 | + * | ||
13 | + * This program is free software: you can redistribute it and/or modify | ||
14 | + * it under the terms of the GNU General Public License as published by | ||
15 | + * the Free Software Foundation, either version 3 of the License, or | ||
16 | + * (at your option) any later version. | ||
17 | + * | ||
18 | + * This program is distributed in the hope that it will be useful, | ||
19 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
20 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
21 | + * GNU General Public License for more details. | ||
22 | + * | ||
23 | + * You should have received a copy of the GNU General Public License | ||
24 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
25 | + */ | ||
26 | + | ||
27 | +#ifndef __AUTH_AUTH_H__ | ||
28 | +#define __AUTH_AUTH_H__ | ||
29 | + | ||
30 | +#include "class.h" | ||
31 | +#include "auth/ldap.h" | ||
32 | + | ||
33 | +typedef enum e_AuthModule { | ||
34 | + AUTH_LDAP = 0 | ||
35 | +} AuthModule; | ||
36 | + | ||
37 | +CLASS(Auth) { | ||
38 | +}; | ||
39 | + | ||
40 | +void * authCreateById(Auth, int); | ||
41 | +AuthLdap authCreateLdap(Auth); | ||
42 | + | ||
43 | +#endif // __AUTH_AUTH_H__ | ||
44 | + | ||
45 | +// vim: set ts=4 sw=4: |
1 | -#ifndef __CREDENTIAL_H__ | ||
2 | -#define __CREDENTIAL_H__ | 1 | +/** |
2 | + * \file | ||
3 | + * | ||
4 | + * \author Georg Hopp | ||
5 | + * | ||
6 | + * \copyright | ||
7 | + * Copyright © 2012 Georg Hopp | ||
8 | + * | ||
9 | + * This program is free software: you can redistribute it and/or modify | ||
10 | + * it under the terms of the GNU General Public License as published by | ||
11 | + * the Free Software Foundation, either version 3 of the License, or | ||
12 | + * (at your option) any later version. | ||
13 | + * | ||
14 | + * This program is distributed in the hope that it will be useful, | ||
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | + * GNU General Public License for more details. | ||
18 | + * | ||
19 | + * You should have received a copy of the GNU General Public License | ||
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | + */ | ||
22 | + | ||
23 | +#ifndef __AUTH_CREDENTIAL_H__ | ||
24 | +#define __AUTH_CREDENTIAL_H__ | ||
3 | 25 | ||
4 | #include <sys/types.h> | 26 | #include <sys/types.h> |
5 | 27 | ||
@@ -27,6 +49,6 @@ CLASS(Credential) { | @@ -27,6 +49,6 @@ CLASS(Credential) { | ||
27 | } cred; | 49 | } cred; |
28 | }; | 50 | }; |
29 | 51 | ||
30 | -#endif // __CREDENTIAL_H__ | 52 | +#endif // __AUTH_CREDENTIAL_H__ |
31 | 53 | ||
32 | // vim: set ts=4 sw=4: | 54 | // vim: set ts=4 sw=4: |
@@ -25,13 +25,13 @@ | @@ -25,13 +25,13 @@ | ||
25 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 25 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | -#ifndef __INTERFACE_AUTH_H__ | ||
29 | -#define __INTERFACE_AUTH_H__ | 28 | +#ifndef __AUTH_INTERFACE_AUTH_H__ |
29 | +#define __AUTH_INTERFACE_AUTH_H__ | ||
30 | 30 | ||
31 | #include <stdarg.h> | 31 | #include <stdarg.h> |
32 | 32 | ||
33 | -#include "interface.h" | ||
34 | -#include "credential.h" | 33 | +#include "class.h" |
34 | +#include "auth/credential.h" | ||
35 | 35 | ||
36 | typedef int (* fptr_authenticate)(void *, Credential); | 36 | typedef int (* fptr_authenticate)(void *, Credential); |
37 | 37 | ||
@@ -44,6 +44,6 @@ struct i_Auth { | @@ -44,6 +44,6 @@ struct i_Auth { | ||
44 | 44 | ||
45 | extern int authenticate(void *, Credential); | 45 | extern int authenticate(void *, Credential); |
46 | 46 | ||
47 | -#endif // __INTERFACE_AUTH_H__ | 47 | +#endif // __AUTH_INTERFACE_AUTH_H__ |
48 | 48 | ||
49 | // vim: set ts=4 sw=4: | 49 | // vim: set ts=4 sw=4: |
1 | +/** | ||
2 | + * \file | ||
3 | + * | ||
4 | + * \author Georg Hopp | ||
5 | + * | ||
6 | + * \copyright | ||
7 | + * Copyright © 2012 Georg Hopp | ||
8 | + * | ||
9 | + * This program is free software: you can redistribute it and/or modify | ||
10 | + * it under the terms of the GNU General Public License as published by | ||
11 | + * the Free Software Foundation, either version 3 of the License, or | ||
12 | + * (at your option) any later version. | ||
13 | + * | ||
14 | + * This program is distributed in the hope that it will be useful, | ||
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | + * GNU General Public License for more details. | ||
18 | + * | ||
19 | + * You should have received a copy of the GNU General Public License | ||
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | + */ | ||
22 | + | ||
1 | #ifndef __AUTH_LDAP_H__ | 23 | #ifndef __AUTH_LDAP_H__ |
2 | #define __AUTH_LDAP_H__ | 24 | #define __AUTH_LDAP_H__ |
3 | 25 |
@@ -11,7 +11,7 @@ | @@ -11,7 +11,7 @@ | ||
11 | * \author Georg Hopp | 11 | * \author Georg Hopp |
12 | * | 12 | * |
13 | * \copyright | 13 | * \copyright |
14 | - * Copyright (C) 2012 Georg Hopp | 14 | + * Copyright © 2012 Georg Hopp |
15 | * | 15 | * |
16 | * This program is free software: you can redistribute it and/or modify | 16 | * This program is free software: you can redistribute it and/or modify |
17 | * it under the terms of the GNU General Public License as published by | 17 | * it under the terms of the GNU General Public License as published by |
1 | -/** | ||
2 | - * \file | ||
3 | - * My own class implementation for C. It combines a data structure | ||
4 | - * with a set of dynamically linked methods defined by an interface. A | ||
5 | - * dynamically linked method will be called via a selector method which in | ||
6 | - * turn gets the implementation stored in the class. | ||
7 | - * | ||
8 | - * \author Georg Hopp | ||
9 | - * | ||
10 | - * \copyright | ||
11 | - * Copyright (C) 2012 Georg Hopp | ||
12 | - * | ||
13 | - * This program is free software: you can redistribute it and/or modify | ||
14 | - * it under the terms of the GNU General Public License as published by | ||
15 | - * the Free Software Foundation, either version 3 of the License, or | ||
16 | - * (at your option) any later version. | ||
17 | - * | ||
18 | - * This program is distributed in the hope that it will be useful, | ||
19 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
20 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
21 | - * GNU General Public License for more details. | ||
22 | - * | ||
23 | - * You should have received a copy of the GNU General Public License | ||
24 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
25 | - */ | ||
26 | - | ||
27 | #ifndef __CLASS_H__ | 1 | #ifndef __CLASS_H__ |
28 | #define __CLASS_H__ | 2 | #define __CLASS_H__ |
29 | 3 | ||
30 | -#include <stdarg.h> | ||
31 | -#include <sys/types.h> | ||
32 | -#include <string.h> | ||
33 | -#include <assert.h> | ||
34 | - | ||
35 | -#include "interface.h" | ||
36 | - | ||
37 | -#ifndef _ISOC99_SOURCE | ||
38 | -#define _ISOC99_SOURCE | ||
39 | -#endif | ||
40 | - | ||
41 | -#define CLASS_MAGIC 0xFEFE | ||
42 | - | ||
43 | -#define CLASS(name) \ | ||
44 | - struct c_##name; \ | ||
45 | - typedef struct c_##name * name; \ | ||
46 | - extern struct class * const _##name; \ | ||
47 | - struct c_##name | ||
48 | - | ||
49 | -#define EXTENDS(parent) \ | ||
50 | - const char _[sizeof(struct c_##parent)] | ||
51 | - | ||
52 | -#define _NULL NULL | ||
53 | -#define CREATE_CLASS(name,_parent,...) \ | ||
54 | - static struct class c_##name; \ | ||
55 | - static void _classInit_(void) { \ | ||
56 | - c_##name.parent = _##_parent; \ | ||
57 | - c_##name.init = NULL; \ | ||
58 | - } \ | ||
59 | - static struct class c_##name = { \ | ||
60 | - CLASS_MAGIC, \ | ||
61 | - NULL, \ | ||
62 | - sizeof(struct c_##name), \ | ||
63 | - _classInit_, \ | ||
64 | - INIT_IMPL(__VA_ARGS__) \ | ||
65 | - }; struct class * const _##name = &c_##name | ||
66 | - | ||
67 | -#define GET_CLASS(object) (*(class_ptr *)((object) - sizeof(void*))) | ||
68 | -#define IFACE_GET(class,iface) (interfaceGet(&((class)->impl),(iface))) | ||
69 | -#define IFACE_EXISTS(class,iface) (NULL != IFACE_GET((class),(iface))) | ||
70 | - | ||
71 | -/** | ||
72 | - * \todo actually i use gcc feature ## for variadoc... think about | ||
73 | - * a way to make this standard. | ||
74 | - */ | ||
75 | -#define _CALL(object,_iface,method,...) \ | ||
76 | - do { \ | ||
77 | - class_ptr class = GET_CLASS((object)); \ | ||
78 | - if (class->init) class->init(); \ | ||
79 | - iface = (struct i_##_iface *)IFACE_GET(class, &i_##_iface); \ | ||
80 | - while ((NULL == iface || NULL == iface->method) && HAS_PARENT(class)) { \ | ||
81 | - class = class->parent; \ | ||
82 | - if (class->init) class->init(); \ | ||
83 | - iface = (struct i_##_iface *)IFACE_GET(class, &i_##_iface); \ | ||
84 | - }; \ | ||
85 | - assert(NULL != iface->method); \ | ||
86 | - } while(0) | ||
87 | - | ||
88 | -#define CALL(object,_iface,method,...) \ | ||
89 | - do { \ | ||
90 | - struct i_##_iface * iface; \ | ||
91 | - _CALL(object, _iface, method, ##__VA_ARGS__); \ | ||
92 | - iface->method(object, ##__VA_ARGS__); \ | ||
93 | - } while(0) | ||
94 | - | ||
95 | -#define RETCALL(object,_iface,method,ret,...) \ | ||
96 | - do { \ | ||
97 | - struct i_##_iface * iface; \ | ||
98 | - _CALL(object, _iface, method, ##__VA_ARGS__); \ | ||
99 | - ret = iface->method(object, ##__VA_ARGS__); \ | ||
100 | - } while(0) | ||
101 | - | ||
102 | -#define PARENTCALL(object,_iface,method,...) \ | ||
103 | - do { \ | ||
104 | - struct i_##_iface * iface; \ | ||
105 | - class_ptr class = GET_CLASS((object)); \ | ||
106 | - if (class->init) class->init(); \ | ||
107 | - assert(HAS_PARENT(class)); \ | ||
108 | - class = class->parent; \ | ||
109 | - if (class->init) class->init(); \ | ||
110 | - iface = (struct i_##_iface *)IFACE_GET(class, &i_##_iface); \ | ||
111 | - assert(NULL != iface->method); \ | ||
112 | - iface->method(object, ##__VA_ARGS__); \ | ||
113 | - } while(0) | ||
114 | - | ||
115 | - | ||
116 | -#define HAS_PARENT(class) (NULL != ((class)->parent)) | ||
117 | - | ||
118 | -typedef void (* fptr_classInit)(void); | ||
119 | - | ||
120 | -struct class; | ||
121 | -typedef struct class * class_ptr; | ||
122 | -struct class { | ||
123 | - const int magic; | ||
124 | - class_ptr parent; | ||
125 | - size_t object_size; | ||
126 | - fptr_classInit init; | ||
127 | - struct iface_impl impl; | ||
128 | -}; | 4 | +#include "class/class.h" |
5 | +#include "class/interface.h" | ||
6 | +#include "class/interface/class.h" | ||
129 | 7 | ||
130 | #endif // __CLASS_H__ | 8 | #endif // __CLASS_H__ |
131 | 9 |
include/class/class.h
0 → 100644
1 | +/** | ||
2 | + * \file | ||
3 | + * My own class implementation for C. It combines a data structure | ||
4 | + * with a set of dynamically linked methods defined by an interface. A | ||
5 | + * dynamically linked method will be called via a selector method which in | ||
6 | + * turn gets the implementation stored in the class. | ||
7 | + * | ||
8 | + * \author Georg Hopp | ||
9 | + * | ||
10 | + * \copyright | ||
11 | + * Copyright © 2012 Georg Hopp | ||
12 | + * | ||
13 | + * This program is free software: you can redistribute it and/or modify | ||
14 | + * it under the terms of the GNU General Public License as published by | ||
15 | + * the Free Software Foundation, either version 3 of the License, or | ||
16 | + * (at your option) any later version. | ||
17 | + * | ||
18 | + * This program is distributed in the hope that it will be useful, | ||
19 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
20 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
21 | + * GNU General Public License for more details. | ||
22 | + * | ||
23 | + * You should have received a copy of the GNU General Public License | ||
24 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
25 | + */ | ||
26 | + | ||
27 | +#ifndef __CLASS_CLASS_H__ | ||
28 | +#define __CLASS_CLASS_H__ | ||
29 | + | ||
30 | +#include <stdarg.h> | ||
31 | +#include <sys/types.h> | ||
32 | +#include <string.h> | ||
33 | +#include <assert.h> | ||
34 | + | ||
35 | +#include "class/interface.h" | ||
36 | + | ||
37 | +#ifndef _ISOC99_SOURCE | ||
38 | +#define _ISOC99_SOURCE | ||
39 | +#endif | ||
40 | + | ||
41 | +#define CLASS_MAGIC 0xFEFE | ||
42 | + | ||
43 | +#define CLASS(name) \ | ||
44 | + struct c_##name; \ | ||
45 | + typedef struct c_##name * name; \ | ||
46 | + extern struct class * const _##name; \ | ||
47 | + struct c_##name | ||
48 | + | ||
49 | +#define EXTENDS(parent) \ | ||
50 | + const char _[sizeof(struct c_##parent)] | ||
51 | + | ||
52 | +#define _NULL NULL | ||
53 | +#define CREATE_CLASS(name,_parent,...) \ | ||
54 | + static struct class c_##name; \ | ||
55 | + static class_ptr _classInit##name##_(void) { \ | ||
56 | + c_##name.parent = _##_parent; \ | ||
57 | + c_##name.init = NULL; \ | ||
58 | + return &c_##name; \ | ||
59 | + } \ | ||
60 | + static struct class c_##name = { \ | ||
61 | + CLASS_MAGIC, \ | ||
62 | + NULL, \ | ||
63 | + sizeof(struct c_##name), \ | ||
64 | + _classInit##name##_, \ | ||
65 | + INIT_IFACE_IMPL(__VA_ARGS__) \ | ||
66 | + }; struct class * const _##name = &c_##name | ||
67 | + | ||
68 | +#define INIT_CLASS(class) ((class)->init? (class)->init() : (class)) | ||
69 | +#define GET_CLASS(object) (INIT_CLASS(*(class_ptr *)((void*)(object) - sizeof(void*)))) | ||
70 | +#define IFACE_GET(class,iface) (interfaceGet(&((class)->impl),(iface))) | ||
71 | +#define HAS_PARENT(class) (NULL != ((class)->parent) && INIT_CLASS((class)->parent)) | ||
72 | + | ||
73 | +#define IS_OBJECT(obj) ((GET_CLASS((obj)))->magic == CLASS_MAGIC) | ||
74 | +#define INSTANCE_OF(class,obj) ((GET_CLASS((obj))) == _##class) | ||
75 | + | ||
76 | +/** | ||
77 | + * \todo actually i use gcc feature ## for variadoc... think about | ||
78 | + * a way to make this standard. | ||
79 | + */ | ||
80 | +#define _CALL(_class,_iface,method,...) \ | ||
81 | + do { \ | ||
82 | + class_ptr class = _class; \ | ||
83 | + iface = (struct i_##_iface *)IFACE_GET(class, &i_##_iface); \ | ||
84 | + while ((NULL == iface || NULL == iface->method) && HAS_PARENT(class)) { \ | ||
85 | + class = class->parent; \ | ||
86 | + iface = (struct i_##_iface *)IFACE_GET(class, &i_##_iface); \ | ||
87 | + } \ | ||
88 | + assert(NULL != iface->method); \ | ||
89 | + } while(0) | ||
90 | + | ||
91 | +#define CALL(object,_iface,method,...) \ | ||
92 | + do { \ | ||
93 | + struct i_##_iface * iface; \ | ||
94 | + _CALL(GET_CLASS(object), _iface, method, ##__VA_ARGS__); \ | ||
95 | + iface->method(object, ##__VA_ARGS__); \ | ||
96 | + } while(0) | ||
97 | + | ||
98 | +#define RETCALL(object,_iface,method,ret,...) \ | ||
99 | + do { \ | ||
100 | + struct i_##_iface * iface; \ | ||
101 | + _CALL(GET_CLASS(object), _iface, method, ##__VA_ARGS__); \ | ||
102 | + ret = iface->method(object, ##__VA_ARGS__); \ | ||
103 | + } while(0) | ||
104 | + | ||
105 | +#define PARENTCALL(object,_iface,method,...) \ | ||
106 | + do { \ | ||
107 | + struct i_##_iface * iface; \ | ||
108 | + class_ptr pc_class = GET_CLASS((object)); \ | ||
109 | + assert(HAS_PARENT(pc_class)); \ | ||
110 | + _CALL(pc_class->parent, _iface, method, ##__VA_ARGS__); \ | ||
111 | + iface->method(object, ##__VA_ARGS__); \ | ||
112 | + } while(0) | ||
113 | + | ||
114 | + | ||
115 | +struct class; | ||
116 | +typedef struct class * class_ptr; | ||
117 | +typedef class_ptr (* fptr_classInit)(void); | ||
118 | +struct class { | ||
119 | + const int magic; | ||
120 | + class_ptr parent; | ||
121 | + size_t object_size; | ||
122 | + fptr_classInit init; | ||
123 | + struct iface_impl impl; | ||
124 | +}; | ||
125 | + | ||
126 | +#endif // __CLASS_CLASS_H__ | ||
127 | + | ||
128 | +// vim: set ts=4 sw=4: |
@@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
8 | * \author Georg Hopp | 8 | * \author Georg Hopp |
9 | * | 9 | * |
10 | * \copyright | 10 | * \copyright |
11 | - * Copyright (C) 2012 Georg Hopp | 11 | + * Copyright © 2012 Georg Hopp |
12 | * | 12 | * |
13 | * This program is free software: you can redistribute it and/or modify | 13 | * This program is free software: you can redistribute it and/or modify |
14 | * it under the terms of the GNU General Public License as published by | 14 | * it under the terms of the GNU General Public License as published by |
@@ -24,8 +24,8 @@ | @@ -24,8 +24,8 @@ | ||
24 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 24 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | -#ifndef __INTERFACE_H__ | ||
28 | -#define __INTERFACE_H__ | 27 | +#ifndef __CLASS_INTERFACE_H__ |
28 | +#define __CLASS_INTERFACE_H__ | ||
29 | 29 | ||
30 | #include <sys/types.h> | 30 | #include <sys/types.h> |
31 | 31 | ||
@@ -36,7 +36,7 @@ | @@ -36,7 +36,7 @@ | ||
36 | static const struct i_##name i_##name##_impl = {&i_##name,__VA_ARGS__} | 36 | static const struct i_##name i_##name##_impl = {&i_##name,__VA_ARGS__} |
37 | 37 | ||
38 | #define NUMARGS(...) (sizeof((const void*[]){__VA_ARGS__})/sizeof(void*)) | 38 | #define NUMARGS(...) (sizeof((const void*[]){__VA_ARGS__})/sizeof(void*)) |
39 | -#define INIT_IMPL(...) {NUMARGS(__VA_ARGS__), 0, {__VA_ARGS__}} | 39 | +#define INIT_IFACE_IMPL(...) {NUMARGS(__VA_ARGS__), 0, {__VA_ARGS__}} |
40 | 40 | ||
41 | 41 | ||
42 | struct interface { | 42 | struct interface { |
@@ -52,8 +52,8 @@ struct iface_impl { | @@ -52,8 +52,8 @@ struct iface_impl { | ||
52 | }; | 52 | }; |
53 | typedef struct iface_impl * iface_impl_ptr; | 53 | typedef struct iface_impl * iface_impl_ptr; |
54 | 54 | ||
55 | -extern struct interface * interfaceGet(iface_impl_ptr, const iface_ptr); | 55 | +extern iface_ptr interfaceGet(iface_impl_ptr, const iface_ptr); |
56 | 56 | ||
57 | -#endif // __INTERFACE_H__ | 57 | +#endif // __CLASS_INTERFACE_H__ |
58 | 58 | ||
59 | // vim: set ts=4 sw=4: | 59 | // vim: set ts=4 sw=4: |
@@ -7,7 +7,7 @@ | @@ -7,7 +7,7 @@ | ||
7 | * \author Georg Hopp | 7 | * \author Georg Hopp |
8 | * | 8 | * |
9 | * \copyright | 9 | * \copyright |
10 | - * Copyright (C) 2012 Georg Hopp | 10 | + * Copyright © 2012 Georg Hopp |
11 | * | 11 | * |
12 | * This program is free software: you can redistribute it and/or modify | 12 | * This program is free software: you can redistribute it and/or modify |
13 | * it under the terms of the GNU General Public License as published by | 13 | * it under the terms of the GNU General Public License as published by |
@@ -23,13 +23,13 @@ | @@ -23,13 +23,13 @@ | ||
23 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 23 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | -#ifndef __INTERFACE_CLASS_H__ | ||
27 | -#define __INTERFACE_CLASS_H__ | 26 | +#ifndef __CLASS_INTERFACE_CLASS_H__ |
27 | +#define __CLASS_INTERFACE_CLASS_H__ | ||
28 | 28 | ||
29 | #include <stdarg.h> | 29 | #include <stdarg.h> |
30 | 30 | ||
31 | -#include "class.h" | ||
32 | -#include "interface.h" | 31 | +#include "class/class.h" |
32 | +#include "class/interface.h" | ||
33 | 33 | ||
34 | typedef int (* fptr_ctor)(void *, va_list *); | 34 | typedef int (* fptr_ctor)(void *, va_list *); |
35 | typedef void (* fptr_dtor)(void *); | 35 | typedef void (* fptr_dtor)(void *); |
@@ -52,6 +52,6 @@ extern void * classClone(void *); | @@ -52,6 +52,6 @@ extern void * classClone(void *); | ||
52 | #define delete(object) classDelete((void **)&(object)) | 52 | #define delete(object) classDelete((void **)&(object)) |
53 | #define clone(object) classClone((void *)(object)) | 53 | #define clone(object) classClone((void *)(object)) |
54 | 54 | ||
55 | -#endif // __INTERFACE_CLASS_H__ | 55 | +#endif // __CLASS_INTERFACE_CLASS_H__ |
56 | 56 | ||
57 | // vim: set ts=4 sw=4: | 57 | // vim: set ts=4 sw=4: |
1 | +/** | ||
2 | + * \file | ||
3 | + * | ||
4 | + * \author Georg Hopp | ||
5 | + * | ||
6 | + * \copyright | ||
7 | + * Copyright © 2012 Georg Hopp | ||
8 | + * | ||
9 | + * This program is free software: you can redistribute it and/or modify | ||
10 | + * it under the terms of the GNU General Public License as published by | ||
11 | + * the Free Software Foundation, either version 3 of the License, or | ||
12 | + * (at your option) any later version. | ||
13 | + * | ||
14 | + * This program is distributed in the hope that it will be useful, | ||
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | + * GNU General Public License for more details. | ||
18 | + * | ||
19 | + * You should have received a copy of the GNU General Public License | ||
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | + */ | ||
22 | + | ||
1 | #ifndef __COMMONS_H__ | 23 | #ifndef __COMMONS_H__ |
2 | #define __COMMONS_H__ | 24 | #define __COMMONS_H__ |
3 | 25 |
1 | #ifndef __HASH_H__ | 1 | #ifndef __HASH_H__ |
2 | #define __HASH_H__ | 2 | #define __HASH_H__ |
3 | 3 | ||
4 | -#include <sys/types.h> | ||
5 | - | ||
6 | -#include "class.h" | ||
7 | - | ||
8 | - | ||
9 | -CLASS(Hash) { | ||
10 | - void * root; | ||
11 | -}; | ||
12 | - | ||
13 | -void * hashAdd(Hash, void *); | ||
14 | -void * hashDelete(Hash, const char *, size_t); | ||
15 | -void * hashGet(Hash, const char *, size_t); | ||
16 | -void hashEach(Hash, void (*)(const void*)); | 4 | +#include "hash/hash.h" |
5 | +#include "hash/value.h" | ||
6 | +#include "hash/interface/hashable.h" | ||
17 | 7 | ||
18 | #endif // __HASH_H__ | 8 | #endif // __HASH_H__ |
19 | 9 |
include/hash/hash.h
0 → 100644
1 | +/** | ||
2 | + * \file | ||
3 | + * | ||
4 | + * \author Georg Hopp | ||
5 | + * | ||
6 | + * \copyright | ||
7 | + * Copyright © 2012 Georg Hopp | ||
8 | + * | ||
9 | + * This program is free software: you can redistribute it and/or modify | ||
10 | + * it under the terms of the GNU General Public License as published by | ||
11 | + * the Free Software Foundation, either version 3 of the License, or | ||
12 | + * (at your option) any later version. | ||
13 | + * | ||
14 | + * This program is distributed in the hope that it will be useful, | ||
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | + * GNU General Public License for more details. | ||
18 | + * | ||
19 | + * You should have received a copy of the GNU General Public License | ||
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | + */ | ||
22 | + | ||
23 | +#ifndef __HASH_HASH_H__ | ||
24 | +#define __HASH_HASH_H__ | ||
25 | + | ||
26 | +#include <sys/types.h> | ||
27 | + | ||
28 | +#include "class.h" | ||
29 | + | ||
30 | + | ||
31 | +CLASS(Hash) { | ||
32 | + void * root; | ||
33 | +}; | ||
34 | + | ||
35 | +void * hashAdd(Hash, void *); | ||
36 | +void * hashDelete(Hash, const char *, size_t); | ||
37 | +void * hashGet(Hash, const char *, size_t); | ||
38 | +void hashEach(Hash, void (*)(const void*)); | ||
39 | + | ||
40 | +#endif // __HASH_HASH_H__ | ||
41 | + | ||
42 | +// vim: set ts=4 sw=4: |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | * \author Georg Hopp | 5 | * \author Georg Hopp |
6 | * | 6 | * |
7 | * \copyright | 7 | * \copyright |
8 | - * Copyright (C) 2012 Georg Hopp | 8 | + * Copyright © 2012 Georg Hopp |
9 | * | 9 | * |
10 | * This program is free software: you can redistribute it and/or modify | 10 | * This program is free software: you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License as published by | 11 | * it under the terms of the GNU General Public License as published by |
@@ -21,10 +21,10 @@ | @@ -21,10 +21,10 @@ | ||
21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | -#ifndef __INTERFACE_HASHABLE_H__ | ||
25 | -#define __INTERFACE_HASHABLE_H__ | 24 | +#ifndef __HASH_INTERFACE_HASHABLE_H__ |
25 | +#define __HASH_INTERFACE_HASHABLE_H__ | ||
26 | 26 | ||
27 | -#include "interface.h" | 27 | +#include "class.h" |
28 | 28 | ||
29 | typedef unsigned long (* fptr_hashableGetHash)(void *); | 29 | typedef unsigned long (* fptr_hashableGetHash)(void *); |
30 | typedef void (* fptr_hashableHandleDouble)(void *, void *); | 30 | typedef void (* fptr_hashableHandleDouble)(void *, void *); |
@@ -40,6 +40,6 @@ struct i_Hashable { | @@ -40,6 +40,6 @@ struct i_Hashable { | ||
40 | extern unsigned long hashableGetHash(void *); | 40 | extern unsigned long hashableGetHash(void *); |
41 | extern void hashableHandleDouble(void *, void *); | 41 | extern void hashableHandleDouble(void *, void *); |
42 | 42 | ||
43 | -#endif // __INTERFACE_HASHABLE_H__ | 43 | +#endif // __HASH_INTERFACE_HASHABLE_H__ |
44 | 44 | ||
45 | // vim: set ts=4 sw=4: | 45 | // vim: set ts=4 sw=4: |
1 | +/** | ||
2 | + * \file | ||
3 | + * | ||
4 | + * \author Georg Hopp | ||
5 | + * | ||
6 | + * \copyright | ||
7 | + * Copyright © 2012 Georg Hopp | ||
8 | + * | ||
9 | + * This program is free software: you can redistribute it and/or modify | ||
10 | + * it under the terms of the GNU General Public License as published by | ||
11 | + * the Free Software Foundation, either version 3 of the License, or | ||
12 | + * (at your option) any later version. | ||
13 | + * | ||
14 | + * This program is distributed in the hope that it will be useful, | ||
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | + * GNU General Public License for more details. | ||
18 | + * | ||
19 | + * You should have received a copy of the GNU General Public License | ||
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | + */ | ||
22 | + | ||
1 | #ifndef __HASH_VALUE_H__ | 23 | #ifndef __HASH_VALUE_H__ |
2 | #define __HASH_VALUE_H__ | 24 | #define __HASH_VALUE_H__ |
3 | 25 |
include/http.h
0 → 100644
1 | +#ifndef __HTTP_H__ | ||
2 | +#define __HTTP_H__ | ||
3 | + | ||
4 | +#include "http/cookie.h" | ||
5 | +#include "http/header.h" | ||
6 | +#include "http/message.h" | ||
7 | +#include "http/message/queue.h" | ||
8 | +#include "http/request.h" | ||
9 | +#include "http/response.h" | ||
10 | +#include "http/parser.h" | ||
11 | +#include "http/writer.h" | ||
12 | +#include "http/worker.h" | ||
13 | +#include "http/interface/http_intro.h" | ||
14 | + | ||
15 | +#endif // __HTTP_H__ | ||
16 | + | ||
17 | +// vim: set ts=4 sw=4: |
1 | +/** | ||
2 | + * \file | ||
3 | + * | ||
4 | + * \author Georg Hopp | ||
5 | + * | ||
6 | + * \copyright | ||
7 | + * Copyright © 2012 Georg Hopp | ||
8 | + * | ||
9 | + * This program is free software: you can redistribute it and/or modify | ||
10 | + * it under the terms of the GNU General Public License as published by | ||
11 | + * the Free Software Foundation, either version 3 of the License, or | ||
12 | + * (at your option) any later version. | ||
13 | + * | ||
14 | + * This program is distributed in the hope that it will be useful, | ||
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | + * GNU General Public License for more details. | ||
18 | + * | ||
19 | + * You should have received a copy of the GNU General Public License | ||
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | + */ | ||
22 | + | ||
1 | #ifndef __HTTP_COOKIE_H__ | 23 | #ifndef __HTTP_COOKIE_H__ |
2 | #define __HTTP_COOKIE_H__ | 24 | #define __HTTP_COOKIE_H__ |
3 | 25 |
@@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
6 | * \author Georg Hopp | 6 | * \author Georg Hopp |
7 | * | 7 | * |
8 | * \copyright | 8 | * \copyright |
9 | - * Copyright (C) 2012 Georg Hopp | 9 | + * Copyright © 2012 Georg Hopp |
10 | * | 10 | * |
11 | * This program is free software: you can redistribute it and/or modify | 11 | * This program is free software: you can redistribute it and/or modify |
12 | * it under the terms of the GNU General Public License as published by | 12 | * it under the terms of the GNU General Public License as published by |
@@ -7,7 +7,7 @@ | @@ -7,7 +7,7 @@ | ||
7 | * \author Georg Hopp | 7 | * \author Georg Hopp |
8 | * | 8 | * |
9 | * \copyright | 9 | * \copyright |
10 | - * Copyright (C) 2012 Georg Hopp | 10 | + * Copyright © 2012 Georg Hopp |
11 | * | 11 | * |
12 | * This program is free software: you can redistribute it and/or modify | 12 | * This program is free software: you can redistribute it and/or modify |
13 | * it under the terms of the GNU General Public License as published by | 13 | * it under the terms of the GNU General Public License as published by |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | * \author Georg Hopp | 5 | * \author Georg Hopp |
6 | * | 6 | * |
7 | * \copyright | 7 | * \copyright |
8 | - * Copyright (C) 2012 Georg Hopp | 8 | + * Copyright © 2012 Georg Hopp |
9 | * | 9 | * |
10 | * This program is free software: you can redistribute it and/or modify | 10 | * This program is free software: you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License as published by | 11 | * it under the terms of the GNU General Public License as published by |
@@ -38,7 +38,6 @@ CLASS(HttpMessage) { | @@ -38,7 +38,6 @@ CLASS(HttpMessage) { | ||
38 | char * version; | 38 | char * version; |
39 | 39 | ||
40 | Hash header; | 40 | Hash header; |
41 | - Hash cookies; | ||
42 | 41 | ||
43 | HttpMessageType type; | 42 | HttpMessageType type; |
44 | Stream handle; | 43 | Stream handle; |
@@ -7,7 +7,7 @@ | @@ -7,7 +7,7 @@ | ||
7 | * \author Georg Hopp | 7 | * \author Georg Hopp |
8 | * | 8 | * |
9 | * \copyright | 9 | * \copyright |
10 | - * Copyright (C) 2012 Georg Hopp | 10 | + * Copyright © 2012 Georg Hopp |
11 | * | 11 | * |
12 | * This program is free software: you can redistribute it and/or modify | 12 | * This program is free software: you can redistribute it and/or modify |
13 | * it under the terms of the GNU General Public License as published by | 13 | * it under the terms of the GNU General Public License as published by |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | * \author Georg Hopp | 5 | * \author Georg Hopp |
6 | * | 6 | * |
7 | * \copyright | 7 | * \copyright |
8 | - * Copyright (C) 2012 Georg Hopp | 8 | + * Copyright © 2012 Georg Hopp |
9 | * | 9 | * |
10 | * This program is free software: you can redistribute it and/or modify | 10 | * This program is free software: you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License as published by | 11 | * it under the terms of the GNU General Public License as published by |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | * \author Georg Hopp | 5 | * \author Georg Hopp |
6 | * | 6 | * |
7 | * \copyright | 7 | * \copyright |
8 | - * Copyright (C) 2012 Georg Hopp | 8 | + * Copyright © 2012 Georg Hopp |
9 | * | 9 | * |
10 | * This program is free software: you can redistribute it and/or modify | 10 | * This program is free software: you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License as published by | 11 | * it under the terms of the GNU General Public License as published by |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | * \author Georg Hopp | 5 | * \author Georg Hopp |
6 | * | 6 | * |
7 | * \copyright | 7 | * \copyright |
8 | - * Copyright (C) 2012 Georg Hopp | 8 | + * Copyright © 2012 Georg Hopp |
9 | * | 9 | * |
10 | * This program is free software: you can redistribute it and/or modify | 10 | * This program is free software: you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License as published by | 11 | * it under the terms of the GNU General Public License as published by |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | * \author Georg Hopp | 5 | * \author Georg Hopp |
6 | * | 6 | * |
7 | * \copyright | 7 | * \copyright |
8 | - * Copyright (C) 2012 Georg Hopp | 8 | + * Copyright © 2012 Georg Hopp |
9 | * | 9 | * |
10 | * This program is free software: you can redistribute it and/or modify | 10 | * This program is free software: you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License as published by | 11 | * it under the terms of the GNU General Public License as published by |
@@ -5,20 +5,20 @@ | @@ -5,20 +5,20 @@ | ||
5 | * \author Georg Hopp | 5 | * \author Georg Hopp |
6 | * | 6 | * |
7 | * \copyright | 7 | * \copyright |
8 | - * - Copyright (C) 2012 Georg Hopp | ||
9 | - * - | ||
10 | - * - This program is free software: you can redistribute it and/or modify | ||
11 | - * - it under the terms of the GNU General Public License as published by | ||
12 | - * - the Free Software Foundation, either version 3 of the License, or | ||
13 | - * - (at your option) any later version. | ||
14 | - * - | ||
15 | - * - This program is distributed in the hope that it will be useful, | ||
16 | - * - but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | - * - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | - * - GNU General Public License for more details. | ||
19 | - * - | ||
20 | - * - You should have received a copy of the GNU General Public License | ||
21 | - * - along with this program. If not, see <http://www.gnu.org/licenses/>. | 8 | + * Copyright © 2012 Georg Hopp |
9 | + * | ||
10 | + * This program is free software: you can redistribute it and/or modify | ||
11 | + * it under the terms of the GNU General Public License as published by | ||
12 | + * the Free Software Foundation, either version 3 of the License, or | ||
13 | + * (at your option) any later version. | ||
14 | + * | ||
15 | + * This program is distributed in the hope that it will be useful, | ||
16 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | + * GNU General Public License for more details. | ||
19 | + * | ||
20 | + * You should have received a copy of the GNU General Public License | ||
21 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
22 | */ | 22 | */ |
23 | 23 | ||
24 | #ifndef __HTTP_WRITER_H__ | 24 | #ifndef __HTTP_WRITER_H__ |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | * \author Georg Hopp | 5 | * \author Georg Hopp |
6 | * | 6 | * |
7 | * \copyright | 7 | * \copyright |
8 | - * Copyright (C) 2012 Georg Hopp | 8 | + * Copyright © 2012 Georg Hopp |
9 | * | 9 | * |
10 | * This program is free software: you can redistribute it and/or modify | 10 | * This program is free software: you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License as published by | 11 | * it under the terms of the GNU General Public License as published by |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | * \author Georg Hopp | 5 | * \author Georg Hopp |
6 | * | 6 | * |
7 | * \copyright | 7 | * \copyright |
8 | - * Copyright (C) 2012 Georg Hopp | 8 | + * Copyright © 2012 Georg Hopp |
9 | * | 9 | * |
10 | * This program is free software: you can redistribute it and/or modify | 10 | * This program is free software: you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License as published by | 11 | * it under the terms of the GNU General Public License as published by |
1 | -/** | ||
2 | - * \file | ||
3 | - * A generic logger class and two extended classes, One that logs to | ||
4 | - * stderr and one that logs to the system syslog. | ||
5 | - * | ||
6 | - * \author Georg Hopp | ||
7 | - * | ||
8 | - * \copyright | ||
9 | - * Copyright (C) 2012 Georg Hopp | ||
10 | - * | ||
11 | - * This program is free software: you can redistribute it and/or modify | ||
12 | - * it under the terms of the GNU General Public License as published by | ||
13 | - * the Free Software Foundation, either version 3 of the License, or | ||
14 | - * (at your option) any later version. | ||
15 | - * | ||
16 | - * This program is distributed in the hope that it will be useful, | ||
17 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | - * GNU General Public License for more details. | ||
20 | - * | ||
21 | - * You should have received a copy of the GNU General Public License | ||
22 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
23 | - */ | ||
24 | - | ||
25 | #ifndef __LOGGER_H__ | 1 | #ifndef __LOGGER_H__ |
26 | #define __LOGGER_H__ | 2 | #define __LOGGER_H__ |
27 | 3 | ||
28 | -#include "class.h" | ||
29 | - | ||
30 | -typedef enum logger_level { | ||
31 | - LOGGER_DEBUG=0, | ||
32 | - LOGGER_INFO, | ||
33 | - LOGGER_NOTICE, | ||
34 | - LOGGER_WARNING, | ||
35 | - LOGGER_ERR, | ||
36 | - LOGGER_CRIT, | ||
37 | - LOGGER_ALERT, | ||
38 | - LOGGER_EMERG | ||
39 | -} logger_level; | ||
40 | - | ||
41 | -extern const char * const logger_level_str[]; | ||
42 | - | ||
43 | -CLASS(Logger) { | ||
44 | - logger_level min_level; | ||
45 | -}; | ||
46 | - | ||
47 | -CLASS(LoggerStderr) { | ||
48 | - EXTENDS(Logger); | ||
49 | -}; | ||
50 | - | ||
51 | -CLASS(LoggerSyslog) { | ||
52 | - EXTENDS(Logger); | ||
53 | -}; | 4 | +#include "logger/logger.h" |
5 | +#include "logger/interface/logger.h" | ||
54 | 6 | ||
55 | #endif // __LOGGER_H__ | 7 | #endif // __LOGGER_H__ |
56 | 8 |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | * \author Georg Hopp | 5 | * \author Georg Hopp |
6 | * | 6 | * |
7 | * \copyright | 7 | * \copyright |
8 | - * Copyright (C) 2012 Georg Hopp | 8 | + * Copyright © 2012 Georg Hopp |
9 | * | 9 | * |
10 | * This program is free software: you can redistribute it and/or modify | 10 | * This program is free software: you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License as published by | 11 | * it under the terms of the GNU General Public License as published by |
@@ -21,12 +21,12 @@ | @@ -21,12 +21,12 @@ | ||
21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | -#ifndef __INTERFACE_LOGGER_H__ | ||
25 | -#define __INTERFACE_LOGGER_H__ | 24 | +#ifndef __LOGGER_INTERFACE_LOGGER_H__ |
25 | +#define __LOGGER_INTERFACE_LOGGER_H__ | ||
26 | 26 | ||
27 | #include <stdarg.h> | 27 | #include <stdarg.h> |
28 | 28 | ||
29 | -#include "interface.h" | 29 | +#include "class.h" |
30 | #include "logger.h" | 30 | #include "logger.h" |
31 | 31 | ||
32 | typedef void (* fptr_log)(void *, logger_level, const char * const); | 32 | typedef void (* fptr_log)(void *, logger_level, const char * const); |
@@ -40,6 +40,6 @@ struct i_Logger { | @@ -40,6 +40,6 @@ struct i_Logger { | ||
40 | 40 | ||
41 | extern void loggerLog(void *, logger_level, const char * const, ...); | 41 | extern void loggerLog(void *, logger_level, const char * const, ...); |
42 | 42 | ||
43 | -#endif // __INTERFACE_LOGGER_H__ | 43 | +#endif // __LOGGER_INTERFACE_LOGGER_H__ |
44 | 44 | ||
45 | // vim: set ts=4 sw=4: | 45 | // vim: set ts=4 sw=4: |
include/logger/logger.h
0 → 100644
1 | +/** | ||
2 | + * \file | ||
3 | + * A generic logger class and two extended classes, One that logs to | ||
4 | + * stderr and one that logs to the system syslog. | ||
5 | + * | ||
6 | + * \author Georg Hopp | ||
7 | + * | ||
8 | + * \copyright | ||
9 | + * Copyright © 2012 Georg Hopp | ||
10 | + * | ||
11 | + * This program is free software: you can redistribute it and/or modify | ||
12 | + * it under the terms of the GNU General Public License as published by | ||
13 | + * the Free Software Foundation, either version 3 of the License, or | ||
14 | + * (at your option) any later version. | ||
15 | + * | ||
16 | + * This program is distributed in the hope that it will be useful, | ||
17 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | + * GNU General Public License for more details. | ||
20 | + * | ||
21 | + * You should have received a copy of the GNU General Public License | ||
22 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
23 | + */ | ||
24 | + | ||
25 | +#ifndef __LOGGER_LOGGER_H__ | ||
26 | +#define __LOGGER_LOGGER_H__ | ||
27 | + | ||
28 | +#include "class.h" | ||
29 | + | ||
30 | +typedef enum logger_level { | ||
31 | + LOGGER_DEBUG=0, | ||
32 | + LOGGER_INFO, | ||
33 | + LOGGER_NOTICE, | ||
34 | + LOGGER_WARNING, | ||
35 | + LOGGER_ERR, | ||
36 | + LOGGER_CRIT, | ||
37 | + LOGGER_ALERT, | ||
38 | + LOGGER_EMERG | ||
39 | +} logger_level; | ||
40 | + | ||
41 | +extern const char * const logger_level_str[]; | ||
42 | + | ||
43 | +CLASS(Logger) { | ||
44 | + logger_level min_level; | ||
45 | +}; | ||
46 | + | ||
47 | +CLASS(LoggerStderr) { | ||
48 | + EXTENDS(Logger); | ||
49 | +}; | ||
50 | + | ||
51 | +CLASS(LoggerSyslog) { | ||
52 | + EXTENDS(Logger); | ||
53 | +}; | ||
54 | + | ||
55 | +#endif // __LOGGER_LOGGER_H__ | ||
56 | + | ||
57 | +// vim: set ts=4 sw=4: |
@@ -7,7 +7,7 @@ | @@ -7,7 +7,7 @@ | ||
7 | * \author Georg Hopp | 7 | * \author Georg Hopp |
8 | * | 8 | * |
9 | * \copyright | 9 | * \copyright |
10 | - * Copyright (C) 2012 Georg Hopp | 10 | + * Copyright © 2012 Georg Hopp |
11 | * | 11 | * |
12 | * This program is free software: you can redistribute it and/or modify | 12 | * This program is free software: you can redistribute it and/or modify |
13 | * it under the terms of the GNU General Public License as published by | 13 | * it under the terms of the GNU General Public License as published by |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
6 | * \author Georg Hopp | 6 | * \author Georg Hopp |
7 | * | 7 | * |
8 | * \copyright | 8 | * \copyright |
9 | - * Copyright (C) 2012 Georg Hopp | 9 | + * Copyright © 2012 Georg Hopp |
10 | * | 10 | * |
11 | * This program is free software: you can redistribute it and/or modify | 11 | * This program is free software: you can redistribute it and/or modify |
12 | * it under the terms of the GNU General Public License as published by | 12 | * it under the terms of the GNU General Public License as published by |
1 | #ifndef __STREAM_H__ | 1 | #ifndef __STREAM_H__ |
2 | #define __STREAM_H__ | 2 | #define __STREAM_H__ |
3 | 3 | ||
4 | -#include <sys/types.h> | ||
5 | -#include <openssl/ssl.h> | ||
6 | - | ||
7 | -#include "class.h" | ||
8 | - | ||
9 | -typedef enum e_StreamHandleType { | ||
10 | - STREAM_FD = 0, | ||
11 | - STREAM_SSL | ||
12 | -} StreamHandleType; | ||
13 | - | ||
14 | -CLASS(Stream) { | ||
15 | - StreamHandleType type; | ||
16 | - union { | ||
17 | - int fd; | ||
18 | - SSL * ssl; | ||
19 | - } handle; | ||
20 | -}; | ||
21 | - | ||
22 | -ssize_t streamRead(Stream, void *, size_t); | ||
23 | -ssize_t streamWrite(Stream, void *, size_t); | 4 | +#include "stream/stream.h" |
5 | +#include "stream/interface/reader.h" | ||
6 | +#include "stream/interface/writer.h" | ||
24 | 7 | ||
25 | #endif // __STREAM_H__ | 8 | #endif // __STREAM_H__ |
26 | 9 |
@@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
6 | * \author Georg Hopp | 6 | * \author Georg Hopp |
7 | * | 7 | * |
8 | * \copyright | 8 | * \copyright |
9 | - * Copyright (C) 2012 Georg Hopp | 9 | + * Copyright © 2012 Georg Hopp |
10 | * | 10 | * |
11 | * This program is free software: you can redistribute it and/or modify | 11 | * This program is free software: you can redistribute it and/or modify |
12 | * it under the terms of the GNU General Public License as published by | 12 | * it under the terms of the GNU General Public License as published by |
@@ -22,12 +22,12 @@ | @@ -22,12 +22,12 @@ | ||
22 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 22 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | -#ifndef __STREAM_READER_H__ | ||
26 | -#define __STREAM_READER_H__ | 25 | +#ifndef __STREAM_INTERFACE_READER_H__ |
26 | +#define __STREAM_INTERFACE_READER_H__ | ||
27 | 27 | ||
28 | #include <sys/types.h> | 28 | #include <sys/types.h> |
29 | 29 | ||
30 | -#include "stream.h" | 30 | +#include "stream/stream.h" |
31 | 31 | ||
32 | typedef ssize_t (* fptr_streamReaderRead)(void *, Stream); | 32 | typedef ssize_t (* fptr_streamReaderRead)(void *, Stream); |
33 | 33 | ||
@@ -40,6 +40,6 @@ struct i_StreamReader { | @@ -40,6 +40,6 @@ struct i_StreamReader { | ||
40 | 40 | ||
41 | extern ssize_t streamReaderRead(void *, Stream); | 41 | extern ssize_t streamReaderRead(void *, Stream); |
42 | 42 | ||
43 | -#endif // __STREAM_READER_H__ | 43 | +#endif // __STREAM_INTERFACE_READER_H__ |
44 | 44 | ||
45 | // vim: set ts=4 sw=4: | 45 | // vim: set ts=4 sw=4: |
@@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
6 | * \author Georg Hopp | 6 | * \author Georg Hopp |
7 | * | 7 | * |
8 | * \copyright | 8 | * \copyright |
9 | - * Copyright (C) 2012 Georg Hopp | 9 | + * Copyright © 2012 Georg Hopp |
10 | * | 10 | * |
11 | * This program is free software: you can redistribute it and/or modify | 11 | * This program is free software: you can redistribute it and/or modify |
12 | * it under the terms of the GNU General Public License as published by | 12 | * it under the terms of the GNU General Public License as published by |
@@ -22,12 +22,12 @@ | @@ -22,12 +22,12 @@ | ||
22 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 22 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | -#ifndef __STREAM_WRITER_H__ | ||
26 | -#define __STREAM_WRITER_H__ | 25 | +#ifndef __STREAM_INTERFACE_WRITER_H__ |
26 | +#define __STREAM_INTERFACE_WRITER_H__ | ||
27 | 27 | ||
28 | #include <sys/types.h> | 28 | #include <sys/types.h> |
29 | 29 | ||
30 | -#include "stream.h" | 30 | +#include "stream/stream.h" |
31 | 31 | ||
32 | typedef ssize_t (* fptr_streamWriterWrite)(void *, Stream); | 32 | typedef ssize_t (* fptr_streamWriterWrite)(void *, Stream); |
33 | 33 | ||
@@ -40,6 +40,6 @@ struct i_StreamWriter { | @@ -40,6 +40,6 @@ struct i_StreamWriter { | ||
40 | 40 | ||
41 | extern ssize_t streamWriterWrite(void *, Stream); | 41 | extern ssize_t streamWriterWrite(void *, Stream); |
42 | 42 | ||
43 | -#endif // __STREAM_WRITER_H__ | 43 | +#endif // __STREAM_INTERFACE_WRITER_H__ |
44 | 44 | ||
45 | // vim: set ts=4 sw=4: | 45 | // vim: set ts=4 sw=4: |
include/stream/stream.h
0 → 100644
1 | +/** | ||
2 | + * \file | ||
3 | + * | ||
4 | + * \author Georg Hopp | ||
5 | + * | ||
6 | + * \copyright | ||
7 | + * Copyright © 2012 Georg Hopp | ||
8 | + * | ||
9 | + * This program is free software: you can redistribute it and/or modify | ||
10 | + * it under the terms of the GNU General Public License as published by | ||
11 | + * the Free Software Foundation, either version 3 of the License, or | ||
12 | + * (at your option) any later version. | ||
13 | + * | ||
14 | + * This program is distributed in the hope that it will be useful, | ||
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | + * GNU General Public License for more details. | ||
18 | + * | ||
19 | + * You should have received a copy of the GNU General Public License | ||
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | + */ | ||
22 | + | ||
23 | +#ifndef __STREAM_STREAM_H__ | ||
24 | +#define __STREAM_STREAM_H__ | ||
25 | + | ||
26 | +#include <sys/types.h> | ||
27 | +#include <openssl/ssl.h> | ||
28 | + | ||
29 | +#include "class.h" | ||
30 | + | ||
31 | +typedef enum e_StreamHandleType { | ||
32 | + STREAM_FD = 0, | ||
33 | + STREAM_SSL | ||
34 | +} StreamHandleType; | ||
35 | + | ||
36 | +CLASS(Stream) { | ||
37 | + StreamHandleType type; | ||
38 | + union { | ||
39 | + int fd; | ||
40 | + SSL * ssl; | ||
41 | + } handle; | ||
42 | +}; | ||
43 | + | ||
44 | +ssize_t streamRead(Stream, void *, size_t); | ||
45 | +ssize_t streamWrite(Stream, void *, size_t); | ||
46 | + | ||
47 | +#endif // __STREAM_STREAM_H__ | ||
48 | + | ||
49 | +// vim: set ts=4 sw=4: |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | * \author Georg Hopp | 5 | * \author Georg Hopp |
6 | * | 6 | * |
7 | * \copyright | 7 | * \copyright |
8 | - * Copyright (C) 2012 Georg Hopp | 8 | + * Copyright © 2012 Georg Hopp |
9 | * | 9 | * |
10 | * This program is free software: you can redistribute it and/or modify | 10 | * This program is free software: you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License as published by | 11 | * it under the terms of the GNU General Public License as published by |
1 | +/** | ||
2 | + * \file | ||
3 | + * | ||
4 | + * \author Georg Hopp | ||
5 | + * | ||
6 | + * \copyright | ||
7 | + * Copyright © 2012 Georg Hopp | ||
8 | + * | ||
9 | + * This program is free software: you can redistribute it and/or modify | ||
10 | + * it under the terms of the GNU General Public License as published by | ||
11 | + * the Free Software Foundation, either version 3 of the License, or | ||
12 | + * (at your option) any later version. | ||
13 | + * | ||
14 | + * This program is distributed in the hope that it will be useful, | ||
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | + * GNU General Public License for more details. | ||
18 | + * | ||
19 | + * You should have received a copy of the GNU General Public License | ||
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | + */ | ||
22 | + | ||
1 | #ifndef __UTILS_HTTP_H__ | 23 | #ifndef __UTILS_HTTP_H__ |
2 | #define __UTILS_HTTP_H__ | 24 | #define __UTILS_HTTP_H__ |
3 | 25 |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | * \author Georg Hopp | 5 | * \author Georg Hopp |
6 | * | 6 | * |
7 | * \copyright | 7 | * \copyright |
8 | - * Copyright (C) 2012 Georg Hopp | 8 | + * Copyright © 2012 Georg Hopp |
9 | * | 9 | * |
10 | * This program is free software: you can redistribute it and/or modify | 10 | * This program is free software: you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License as published by | 11 | * it under the terms of the GNU General Public License as published by |
1 | ACLOCAL_AMFLAGS = -I m4 | 1 | ACLOCAL_AMFLAGS = -I m4 |
2 | -AUTOMAKE_OPTIONS = subdir-objects | ||
3 | 2 | ||
4 | -IFACE = interface/class.c interface/stream_reader.c interface/logger.c \ | ||
5 | - interface/stream_writer.c interface/http_intro.c \ | ||
6 | - interface/subject.c interface/observer.c interface.c | ||
7 | -SOCKET = socket.c socket/accept.c socket/connect.c socket/listen.c | ||
8 | -STREAM = stream.c stream/read.c stream/write.c | ||
9 | -HASH = hash.c hash/add.c hash/get.c hash/delete.c \ | ||
10 | - hash/each.c interface/hashable.c hash_value.c | ||
11 | -SERVER = server.c server/run.c server/close_conn.c server/poll.c \ | ||
12 | - server/handle_accept.c server/read.c server/write.c | ||
13 | -LOGGER = logger.c logger/stderr.c logger/syslog.c | ||
14 | -CB = cbuf.c cbuf/read.c cbuf/write.c \ | ||
15 | - cbuf/get_line.c cbuf/set_data.c cbuf/get_data.c \ | ||
16 | - cbuf/addr_index.c cbuf/get_free.c cbuf/get_read.c cbuf/get_write.c \ | ||
17 | - cbuf/inc_read.c cbuf/inc_write.c cbuf/is_empty.c cbuf/memchr.c \ | ||
18 | - cbuf/skip_non_alpha.c cbuf/is_locked.c cbuf/lock.c cbuf/release.c \ | ||
19 | - cbuf/empty.c | ||
20 | -MSG = http/message.c \ | ||
21 | - http/message/has_keep_alive.c \ | ||
22 | - http/message/header_size_get.c \ | ||
23 | - http/message/header_to_string.c \ | ||
24 | - http/message/get_version.c \ | ||
25 | - http/message/has_valid_version.c | ||
26 | -MSGQ = http/message/queue.c | ||
27 | -REQ = http/request.c \ | ||
28 | - http/request/has_valid_method.c | ||
29 | -RESP = http/response.c \ | ||
30 | - http/response/304.c \ | ||
31 | - http/response/404.c \ | ||
32 | - http/response/403.c \ | ||
33 | - http/response/login_form.c \ | ||
34 | - http/response/asset.c \ | ||
35 | - http/response/randval.c \ | ||
36 | - http/response/session.c | ||
37 | -PARSER = http/parser.c \ | ||
38 | - http/parser/parse.c \ | ||
39 | - http/parser/new_message.c \ | ||
40 | - http/parser/header.c \ | ||
41 | - http/parser/body.c \ | ||
42 | - http/parser/request_vars.c \ | ||
43 | - http/parser/post_vars.c | ||
44 | -WRITER = http/writer.c \ | ||
45 | - http/writer/write.c | ||
46 | -WORKER = http/worker.c \ | ||
47 | - http/worker/process.c \ | ||
48 | - http/worker/write.c \ | ||
49 | - http/worker/get_asset.c \ | ||
50 | - http/worker/add_common_header.c | ||
51 | -HEADER = http/header.c \ | ||
52 | - http/header/to_string.c | ||
53 | -SESSION = session.c session/add.c session/get.c session/delete.c | ||
54 | -UTILS = utils/hash.c \ | ||
55 | - utils/memory.c \ | ||
56 | - utils/http.c \ | ||
57 | - utils/daemonize.c \ | ||
58 | - utils/signalHandling.c | ||
59 | -AUTH = interface/auth.c auth/ldap.c credential.c | 3 | +IFACE = interface/subject.c \ |
4 | + interface/observer.c | ||
5 | +UTILS = utils/hash.c \ | ||
6 | + utils/memory.c \ | ||
7 | + utils/http.c \ | ||
8 | + utils/daemonize.c \ | ||
9 | + utils/signalHandling.c | ||
60 | 10 | ||
11 | +LIBS = ./http/libhttp.a \ | ||
12 | + ./auth/libauth.a \ | ||
13 | + ./cbuf/libcbuf.a \ | ||
14 | + ./class/libclass.a \ | ||
15 | + ./hash/libhash.a \ | ||
16 | + ./logger/liblogger.a \ | ||
17 | + ./server/libserver.a \ | ||
18 | + ./session/libsession.a \ | ||
19 | + ./socket/libsocket.a \ | ||
20 | + ./stream/libstream.a | ||
61 | 21 | ||
62 | AM_CFLAGS = -Wall -I ../include/ | 22 | AM_CFLAGS = -Wall -I ../include/ |
63 | 23 | ||
64 | bin_PROGRAMS = webgameserver | 24 | bin_PROGRAMS = webgameserver |
65 | 25 | ||
66 | -webgameserver_SOURCES = webgameserver.c \ | ||
67 | - $(IFACE) $(SOCKET) $(SERVER) $(LOGGER) $(MSG) $(REQ) \ | ||
68 | - $(WRITER) $(RESP) $(HEADER) $(PARSER) $(WORKER) $(CB) \ | ||
69 | - $(UTILS) $(MSGQ) $(SESSION) $(STREAM) $(HASH) $(AUTH) | ||
70 | -webgameserver_CFLAGS = -Wall -I ../include/ | ||
71 | -webgameserver_LDFLAGS = -lrt -lssl -lldap | 26 | +webgameserver_SOURCES = webgameserver.c $(IFACE) $(UTILS) |
27 | +webgameserver_CFLAGS = -Wall -I ../include/# $(COVERAGE_CFLAGS) | ||
28 | +webgameserver_LDADD = $(LIBS) -lrt -lssl -lldap | ||
29 | +#webgameserver_LDFLAGS = $(COVERAGE_LDFLAGS) | ||
30 | + | ||
31 | +SUBDIRS = auth cbuf class hash http logger server session socket stream |
src/auth/Makefile.am
0 → 100644
1 | +/** | ||
2 | + * \file | ||
3 | + * | ||
4 | + * \author Georg Hopp | ||
5 | + * | ||
6 | + * \copyright | ||
7 | + * Copyright © 2012 Georg Hopp | ||
8 | + * | ||
9 | + * This program is free software: you can redistribute it and/or modify | ||
10 | + * it under the terms of the GNU General Public License as published by | ||
11 | + * the Free Software Foundation, either version 3 of the License, or | ||
12 | + * (at your option) any later version. | ||
13 | + * | ||
14 | + * This program is distributed in the hope that it will be useful, | ||
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | + * GNU General Public License for more details. | ||
18 | + * | ||
19 | + * You should have received a copy of the GNU General Public License | ||
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | + */ | ||
22 | + | ||
1 | #include <stdarg.h> | 23 | #include <stdarg.h> |
2 | #include <sys/types.h> | 24 | #include <sys/types.h> |
3 | #include <stdlib.h> | 25 | #include <stdlib.h> |
4 | #include <string.h> | 26 | #include <string.h> |
5 | 27 | ||
6 | -#include "credential.h" | ||
7 | #include "class.h" | 28 | #include "class.h" |
8 | -#include "interface/class.h" | ||
9 | - | ||
10 | #include "utils/memory.h" | 29 | #include "utils/memory.h" |
11 | 30 | ||
31 | +#include "auth/credential.h" | ||
32 | + | ||
12 | static | 33 | static |
13 | int | 34 | int |
14 | credentialCtor(void * _this, va_list * params) | 35 | credentialCtor(void * _this, va_list * params) |
@@ -20,9 +20,9 @@ | @@ -20,9 +20,9 @@ | ||
20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | -#include "auth.h" | ||
24 | -#include "credential.h" | ||
25 | -#include "interface/auth.h" | 23 | +#include "auth/auth.h" |
24 | +#include "auth/credential.h" | ||
25 | +#include "auth/interface/auth.h" | ||
26 | 26 | ||
27 | const struct interface i_Auth = { | 27 | const struct interface i_Auth = { |
28 | "auth", | 28 | "auth", |
1 | +/** | ||
2 | + * \file | ||
3 | + * | ||
4 | + * \author Georg Hopp | ||
5 | + * | ||
6 | + * \copyright | ||
7 | + * Copyright © 2012 Georg Hopp | ||
8 | + * | ||
9 | + * This program is free software: you can redistribute it and/or modify | ||
10 | + * it under the terms of the GNU General Public License as published by | ||
11 | + * the Free Software Foundation, either version 3 of the License, or | ||
12 | + * (at your option) any later version. | ||
13 | + * | ||
14 | + * This program is distributed in the hope that it will be useful, | ||
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | + * GNU General Public License for more details. | ||
18 | + * | ||
19 | + * You should have received a copy of the GNU General Public License | ||
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | + */ | ||
22 | + | ||
1 | #include <stdarg.h> | 23 | #include <stdarg.h> |
2 | #include <stdlib.h> | 24 | #include <stdlib.h> |
3 | #include <string.h> | 25 | #include <string.h> |
4 | #include <stdio.h> | 26 | #include <stdio.h> |
5 | #include <ldap.h> | 27 | #include <ldap.h> |
6 | 28 | ||
7 | -#include "auth/ldap.h" | ||
8 | #include "class.h" | 29 | #include "class.h" |
9 | -#include "credential.h" | ||
10 | -#include "interface/class.h" | ||
11 | -#include "interface/auth.h" | ||
12 | - | ||
13 | #include "utils/memory.h" | 30 | #include "utils/memory.h" |
14 | #include "commons.h" | 31 | #include "commons.h" |
15 | 32 | ||
33 | +#include "auth/ldap.h" | ||
34 | +#include "auth/credential.h" | ||
35 | +#include "auth/interface/auth.h" | ||
36 | + | ||
16 | static | 37 | static |
17 | int | 38 | int |
18 | authLdapCtor(void * _this, va_list * params) | 39 | authLdapCtor(void * _this, va_list * params) |
src/cbuf/Makefile.am
0 → 100644
1 | +ACLOCAL_AMFLAGS = -I m4 | ||
2 | + | ||
3 | +CB = cbuf.c read.c write.c \ | ||
4 | + get_line.c set_data.c get_data.c \ | ||
5 | + addr_index.c get_free.c get_read.c get_write.c \ | ||
6 | + inc_read.c inc_write.c is_empty.c memchr.c \ | ||
7 | + skip_non_alpha.c is_locked.c lock.c release.c \ | ||
8 | + empty.c | ||
9 | + | ||
10 | +noinst_LIBRARIES = libcbuf.a | ||
11 | + | ||
12 | +libcbuf_a_SOURCES = $(CB) | ||
13 | +libcbuf_a_CFLAGS = -Wall -I ../../include/ |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -34,7 +34,6 @@ | @@ -34,7 +34,6 @@ | ||
34 | #include <fcntl.h> | 34 | #include <fcntl.h> |
35 | 35 | ||
36 | #include "class.h" | 36 | #include "class.h" |
37 | -#include "interface/class.h" | ||
38 | #include "utils/memory.h" | 37 | #include "utils/memory.h" |
39 | 38 | ||
40 | #include "cbuf.h" | 39 | #include "cbuf.h" |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
src/class/Makefile.am
0 → 100644
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -23,7 +23,7 @@ | @@ -23,7 +23,7 @@ | ||
23 | #include <sys/types.h> | 23 | #include <sys/types.h> |
24 | #include <stdlib.h> | 24 | #include <stdlib.h> |
25 | 25 | ||
26 | -#include "interface.h" | 26 | +#include "class/interface.h" |
27 | #include "commons.h" | 27 | #include "commons.h" |
28 | 28 | ||
29 | static | 29 | static |
@@ -40,25 +40,25 @@ comp(const void * _a, const void * _b) | @@ -40,25 +40,25 @@ comp(const void * _a, const void * _b) | ||
40 | * this one is important in selector functions to get the correct interface | 40 | * this one is important in selector functions to get the correct interface |
41 | * implementation of a class. | 41 | * implementation of a class. |
42 | */ | 42 | */ |
43 | -struct interface * | 43 | +iface_ptr |
44 | interfaceGet(iface_impl_ptr iface_impl, const iface_ptr _iface) | 44 | interfaceGet(iface_impl_ptr iface_impl, const iface_ptr _iface) |
45 | { | 45 | { |
46 | const iface_ptr * iface = &_iface; | 46 | const iface_ptr * iface = &_iface; |
47 | - void * dummy; | 47 | + iface_ptr * found; |
48 | 48 | ||
49 | if (! iface_impl->simpl) { | 49 | if (! iface_impl->simpl) { |
50 | qsort((void**)(iface_impl->impl), iface_impl->nimpl, sizeof(iface_ptr), comp); | 50 | qsort((void**)(iface_impl->impl), iface_impl->nimpl, sizeof(iface_ptr), comp); |
51 | iface_impl->simpl=TRUE; | 51 | iface_impl->simpl=TRUE; |
52 | } | 52 | } |
53 | 53 | ||
54 | - dummy = bsearch( | 54 | + found = bsearch( |
55 | &iface, | 55 | &iface, |
56 | iface_impl->impl, | 56 | iface_impl->impl, |
57 | iface_impl->nimpl, | 57 | iface_impl->nimpl, |
58 | sizeof(iface_ptr), | 58 | sizeof(iface_ptr), |
59 | comp); | 59 | comp); |
60 | 60 | ||
61 | - return dummy? *(struct interface **)dummy : dummy; | 61 | + return found? *found : (iface_ptr)NULL; |
62 | } | 62 | } |
63 | 63 | ||
64 | // vim: set ts=4 sw=4: | 64 | // vim: set ts=4 sw=4: |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -24,8 +24,8 @@ | @@ -24,8 +24,8 @@ | ||
24 | #include <stdlib.h> | 24 | #include <stdlib.h> |
25 | #include <assert.h> | 25 | #include <assert.h> |
26 | 26 | ||
27 | -#include "class.h" | ||
28 | -#include "interface/class.h" | 27 | +#include "class/class.h" |
28 | +#include "class/interface/class.h" | ||
29 | 29 | ||
30 | const | 30 | const |
31 | struct interface i_Class = { | 31 | struct interface i_Class = { |
@@ -40,8 +40,6 @@ classNew(class_ptr class, ...) | @@ -40,8 +40,6 @@ classNew(class_ptr class, ...) | ||
40 | va_list params; | 40 | va_list params; |
41 | int ret; | 41 | int ret; |
42 | 42 | ||
43 | - if (class->init) class->init(); | ||
44 | - | ||
45 | * (class_ptr *)object = class; | 43 | * (class_ptr *)object = class; |
46 | object += sizeof(void*); | 44 | object += sizeof(void*); |
47 | 45 |
src/hash/Makefile.am
0 → 100644
1 | +/** | ||
2 | + * \file | ||
3 | + * | ||
4 | + * \author Georg Hopp | ||
5 | + * | ||
6 | + * \copyright | ||
7 | + * Copyright © 2012 Georg Hopp | ||
8 | + * | ||
9 | + * This program is free software: you can redistribute it and/or modify | ||
10 | + * it under the terms of the GNU General Public License as published by | ||
11 | + * the Free Software Foundation, either version 3 of the License, or | ||
12 | + * (at your option) any later version. | ||
13 | + * | ||
14 | + * This program is distributed in the hope that it will be useful, | ||
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | + * GNU General Public License for more details. | ||
18 | + * | ||
19 | + * You should have received a copy of the GNU General Public License | ||
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | + */ | ||
22 | + | ||
1 | #include <search.h> | 23 | #include <search.h> |
2 | 24 | ||
3 | #include "hash.h" | 25 | #include "hash.h" |
4 | -#include "interface/hashable.h" | ||
5 | -#include "interface/class.h" | 26 | +#include "class.h" |
6 | 27 | ||
7 | static | 28 | static |
8 | inline | 29 | inline |
1 | +/** | ||
2 | + * \file | ||
3 | + * | ||
4 | + * \author Georg Hopp | ||
5 | + * | ||
6 | + * \copyright | ||
7 | + * Copyright © 2012 Georg Hopp | ||
8 | + * | ||
9 | + * This program is free software: you can redistribute it and/or modify | ||
10 | + * it under the terms of the GNU General Public License as published by | ||
11 | + * the Free Software Foundation, either version 3 of the License, or | ||
12 | + * (at your option) any later version. | ||
13 | + * | ||
14 | + * This program is distributed in the hope that it will be useful, | ||
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | + * GNU General Public License for more details. | ||
18 | + * | ||
19 | + * You should have received a copy of the GNU General Public License | ||
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | + */ | ||
22 | + | ||
1 | #include <search.h> | 23 | #include <search.h> |
2 | #include <sys/types.h> | 24 | #include <sys/types.h> |
3 | 25 | ||
4 | #include "hash.h" | 26 | #include "hash.h" |
5 | -#include "interface/hashable.h" | ||
6 | #include "utils/hash.h" | 27 | #include "utils/hash.h" |
7 | 28 | ||
8 | static | 29 | static |
1 | +/** | ||
2 | + * \file | ||
3 | + * | ||
4 | + * \author Georg Hopp | ||
5 | + * | ||
6 | + * \copyright | ||
7 | + * Copyright © 2012 Georg Hopp | ||
8 | + * | ||
9 | + * This program is free software: you can redistribute it and/or modify | ||
10 | + * it under the terms of the GNU General Public License as published by | ||
11 | + * the Free Software Foundation, either version 3 of the License, or | ||
12 | + * (at your option) any later version. | ||
13 | + * | ||
14 | + * This program is distributed in the hope that it will be useful, | ||
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | + * GNU General Public License for more details. | ||
18 | + * | ||
19 | + * You should have received a copy of the GNU General Public License | ||
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | + */ | ||
22 | + | ||
1 | #include <search.h> | 23 | #include <search.h> |
2 | 24 | ||
3 | #include "hash.h" | 25 | #include "hash.h" |
1 | +/** | ||
2 | + * \file | ||
3 | + * | ||
4 | + * \author Georg Hopp | ||
5 | + * | ||
6 | + * \copyright | ||
7 | + * Copyright © 2012 Georg Hopp | ||
8 | + * | ||
9 | + * This program is free software: you can redistribute it and/or modify | ||
10 | + * it under the terms of the GNU General Public License as published by | ||
11 | + * the Free Software Foundation, either version 3 of the License, or | ||
12 | + * (at your option) any later version. | ||
13 | + * | ||
14 | + * This program is distributed in the hope that it will be useful, | ||
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | + * GNU General Public License for more details. | ||
18 | + * | ||
19 | + * You should have received a copy of the GNU General Public License | ||
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | + */ | ||
22 | + | ||
1 | #include <search.h> | 23 | #include <search.h> |
2 | #include <sys/types.h> | 24 | #include <sys/types.h> |
3 | 25 | ||
4 | #include "hash.h" | 26 | #include "hash.h" |
5 | -#include "interface/hashable.h" | ||
6 | #include "utils/hash.h" | 27 | #include "utils/hash.h" |
7 | 28 | ||
8 | static | 29 | static |
1 | +/** | ||
2 | + * \file | ||
3 | + * | ||
4 | + * \author Georg Hopp | ||
5 | + * | ||
6 | + * \copyright | ||
7 | + * Copyright © 2012 Georg Hopp | ||
8 | + * | ||
9 | + * This program is free software: you can redistribute it and/or modify | ||
10 | + * it under the terms of the GNU General Public License as published by | ||
11 | + * the Free Software Foundation, either version 3 of the License, or | ||
12 | + * (at your option) any later version. | ||
13 | + * | ||
14 | + * This program is distributed in the hope that it will be useful, | ||
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | + * GNU General Public License for more details. | ||
18 | + * | ||
19 | + * You should have received a copy of the GNU General Public License | ||
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | + */ | ||
22 | + | ||
1 | #define _GNU_SOURCE | 23 | #define _GNU_SOURCE |
2 | 24 | ||
3 | #include <search.h> | 25 | #include <search.h> |
4 | #include <stdarg.h> | 26 | #include <stdarg.h> |
5 | 27 | ||
6 | -#include "hash.h" | 28 | +#include "hash/hash.h" |
7 | #include "class.h" | 29 | #include "class.h" |
8 | -#include "interface/class.h" | ||
9 | 30 | ||
10 | static | 31 | static |
11 | int | 32 | int |
@@ -25,7 +25,7 @@ | @@ -25,7 +25,7 @@ | ||
25 | #include <stdarg.h> | 25 | #include <stdarg.h> |
26 | 26 | ||
27 | #include "class.h" | 27 | #include "class.h" |
28 | -#include "interface/hashable.h" | 28 | +#include "hash/interface/hashable.h" |
29 | 29 | ||
30 | const struct interface i_Hashable = { | 30 | const struct interface i_Hashable = { |
31 | "hashable", | 31 | "hashable", |
1 | +/** | ||
2 | + * \file | ||
3 | + * | ||
4 | + * \author Georg Hopp | ||
5 | + * | ||
6 | + * \copyright | ||
7 | + * Copyright © 2012 Georg Hopp | ||
8 | + * | ||
9 | + * This program is free software: you can redistribute it and/or modify | ||
10 | + * it under the terms of the GNU General Public License as published by | ||
11 | + * the Free Software Foundation, either version 3 of the License, or | ||
12 | + * (at your option) any later version. | ||
13 | + * | ||
14 | + * This program is distributed in the hope that it will be useful, | ||
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | + * GNU General Public License for more details. | ||
18 | + * | ||
19 | + * You should have received a copy of the GNU General Public License | ||
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | + */ | ||
22 | + | ||
1 | #include <stdarg.h> | 23 | #include <stdarg.h> |
2 | #include <stdlib.h> | 24 | #include <stdlib.h> |
3 | #include <string.h> | 25 | #include <string.h> |
4 | #include <sys/types.h> | 26 | #include <sys/types.h> |
5 | 27 | ||
6 | -#include "hash_value.h" | 28 | +#include "class.h" |
7 | #include "utils/hash.h" | 29 | #include "utils/hash.h" |
8 | #include "utils/memory.h" | 30 | #include "utils/memory.h" |
9 | #include "commons.h" | 31 | #include "commons.h" |
10 | -#include "interface/class.h" | ||
11 | -#include "interface/hashable.h" | 32 | + |
33 | +#include "hash/value.h" | ||
34 | +#include "hash/interface/hashable.h" | ||
12 | 35 | ||
13 | static | 36 | static |
14 | int | 37 | int |
src/http/Makefile.am
0 → 100644
1 | +ACLOCAL_AMFLAGS = -I m4 | ||
2 | + | ||
3 | +MSG = message.c \ | ||
4 | + message/has_keep_alive.c \ | ||
5 | + message/header_size_get.c \ | ||
6 | + message/header_to_string.c \ | ||
7 | + message/get_version.c \ | ||
8 | + message/has_valid_version.c | ||
9 | +MSGQ = message/queue.c | ||
10 | +REQ = request.c \ | ||
11 | + request/has_valid_method.c | ||
12 | +RESP = response.c \ | ||
13 | + response/304.c \ | ||
14 | + response/404.c \ | ||
15 | + response/403.c \ | ||
16 | + response/login_form.c \ | ||
17 | + response/asset.c \ | ||
18 | + response/randval.c \ | ||
19 | + response/session.c | ||
20 | +PARSER = parser.c \ | ||
21 | + parser/parse.c \ | ||
22 | + parser/new_message.c \ | ||
23 | + parser/p_header.c \ | ||
24 | + parser/p_body.c \ | ||
25 | + parser/p_request_vars.c \ | ||
26 | + parser/p_post_vars.c | ||
27 | +WRITER = writer.c \ | ||
28 | + writer/write.c | ||
29 | +WORKER = worker.c \ | ||
30 | + worker/process.c \ | ||
31 | + worker/answer.c \ | ||
32 | + worker/get_asset.c \ | ||
33 | + worker/add_common_header.c | ||
34 | +HEADER = header.c \ | ||
35 | + header/to_string.c | ||
36 | + | ||
37 | +noinst_LIBRARIES = libhttp.a | ||
38 | + | ||
39 | +libhttp_a_SOURCES = $(MSG) $(MSGQ) $(REQ) $(RESP) $(PARSER) $(WRITER) \ | ||
40 | + $(WORKER) $(HEADER) interface/i_http_intro.c | ||
41 | +libhttp_a_CFLAGS = -Wall -I ../../include/ |
1 | +/** | ||
2 | + * \file | ||
3 | + * | ||
4 | + * \author Georg Hopp | ||
5 | + * | ||
6 | + * \copyright | ||
7 | + * Copyright © 2012 Georg Hopp | ||
8 | + * | ||
9 | + * This program is free software: you can redistribute it and/or modify | ||
10 | + * it under the terms of the GNU General Public License as published by | ||
11 | + * the Free Software Foundation, either version 3 of the License, or | ||
12 | + * (at your option) any later version. | ||
13 | + * | ||
14 | + * This program is distributed in the hope that it will be useful, | ||
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | + * GNU General Public License for more details. | ||
18 | + * | ||
19 | + * You should have received a copy of the GNU General Public License | ||
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | + */ | ||
22 | + | ||
1 | #include <stdlib.h> | 23 | #include <stdlib.h> |
2 | #include <string.h> | 24 | #include <string.h> |
3 | #include <stdarg.h> | 25 | #include <stdarg.h> |
4 | #include <sys/types.h> | 26 | #include <sys/types.h> |
5 | 27 | ||
6 | -#include "cookie.h" | ||
7 | -#include "interface/class.h" | ||
8 | -#include "interface/hashable" | 28 | +#include "class.h" |
29 | +#include "hash.h" | ||
30 | +#include "http/cookie.h" | ||
9 | 31 | ||
10 | #include "utils/hash.h" | 32 | #include "utils/hash.h" |
11 | #include "utils/memory.h" | 33 | #include "utils/memory.h" |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | * \author Georg Hopp | 5 | * \author Georg Hopp |
6 | * | 6 | * |
7 | * \copyright | 7 | * \copyright |
8 | - * Copyright (C) 2012 Georg Hopp | 8 | + * Copyright © 2012 Georg Hopp |
9 | * | 9 | * |
10 | * This program is free software: you can redistribute it and/or modify | 10 | * This program is free software: you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License as published by | 11 | * it under the terms of the GNU General Public License as published by |
@@ -25,9 +25,8 @@ | @@ -25,9 +25,8 @@ | ||
25 | #include <string.h> | 25 | #include <string.h> |
26 | 26 | ||
27 | #include "class.h" | 27 | #include "class.h" |
28 | -#include "interface/class.h" | 28 | +#include "hash.h" |
29 | #include "http/header.h" | 29 | #include "http/header.h" |
30 | -#include "interface/hashable.h" | ||
31 | 30 | ||
32 | #include "utils/hash.h" | 31 | #include "utils/hash.h" |
33 | #include "utils/memory.h" | 32 | #include "utils/memory.h" |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | * \author Georg Hopp | 5 | * \author Georg Hopp |
6 | * | 6 | * |
7 | * \copyright | 7 | * \copyright |
8 | - * Copyright (C) 2012 Georg Hopp | 8 | + * Copyright © 2012 Georg Hopp |
9 | * | 9 | * |
10 | * This program is free software: you can redistribute it and/or modify | 10 | * This program is free software: you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License as published by | 11 | * it under the terms of the GNU General Public License as published by |
@@ -21,7 +21,7 @@ | @@ -21,7 +21,7 @@ | ||
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include "class.h" | 23 | #include "class.h" |
24 | -#include "interface/http_intro.h" | 24 | +#include "http/interface/http_intro.h" |
25 | 25 | ||
26 | const struct interface i_HttpIntro = { | 26 | const struct interface i_HttpIntro = { |
27 | "httpIntro", | 27 | "httpIntro", |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -31,7 +31,6 @@ | @@ -31,7 +31,6 @@ | ||
31 | #include <unistd.h> | 31 | #include <unistd.h> |
32 | 32 | ||
33 | #include "class.h" | 33 | #include "class.h" |
34 | -#include "interface/class.h" | ||
35 | #include "hash.h" | 34 | #include "hash.h" |
36 | #include "http/message.h" | 35 | #include "http/message.h" |
37 | #include "utils/memory.h" | 36 | #include "utils/memory.h" |
@@ -47,8 +46,7 @@ httpMessageCtor(void * _this, va_list * params) | @@ -47,8 +46,7 @@ httpMessageCtor(void * _this, va_list * params) | ||
47 | this->version = calloc(1, strlen(version)+1); | 46 | this->version = calloc(1, strlen(version)+1); |
48 | strcpy(this->version, version); | 47 | strcpy(this->version, version); |
49 | 48 | ||
50 | - this->header = new(Hash); | ||
51 | - this->cookies = new(Hash); | 49 | + this->header = new(Hash); |
52 | 50 | ||
53 | return 0; | 51 | return 0; |
54 | } | 52 | } |
@@ -60,7 +58,6 @@ httpMessageDtor(void * _this) | @@ -60,7 +58,6 @@ httpMessageDtor(void * _this) | ||
60 | HttpMessage this = _this; | 58 | HttpMessage this = _this; |
61 | 59 | ||
62 | delete(this->header); | 60 | delete(this->header); |
63 | - delete(this->cookies); | ||
64 | 61 | ||
65 | FREE(this->version); | 62 | FREE(this->version); |
66 | 63 |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -27,7 +27,7 @@ | @@ -27,7 +27,7 @@ | ||
27 | #include "http/message.h" | 27 | #include "http/message.h" |
28 | #include "http/response.h" | 28 | #include "http/response.h" |
29 | #include "http/header.h" | 29 | #include "http/header.h" |
30 | -#include "interface/http_intro.h" | 30 | +#include "http/interface/http_intro.h" |
31 | #include "hash.h" | 31 | #include "hash.h" |
32 | 32 | ||
33 | static size_t size; | 33 | static size_t size; |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -26,7 +26,7 @@ | @@ -26,7 +26,7 @@ | ||
26 | 26 | ||
27 | #include "http/response.h" | 27 | #include "http/response.h" |
28 | #include "http/header.h" | 28 | #include "http/header.h" |
29 | -#include "interface/http_intro.h" | 29 | +#include "http/interface/http_intro.h" |
30 | #include "hash.h" | 30 | #include "hash.h" |
31 | 31 | ||
32 | static char * string; | 32 | static char * string; |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -23,7 +23,6 @@ | @@ -23,7 +23,6 @@ | ||
23 | #include <stdarg.h> | 23 | #include <stdarg.h> |
24 | 24 | ||
25 | #include "class.h" | 25 | #include "class.h" |
26 | -#include "interface/class.h" | ||
27 | 26 | ||
28 | #include "http/message/queue.h" | 27 | #include "http/message/queue.h" |
29 | 28 |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -25,8 +25,7 @@ | @@ -25,8 +25,7 @@ | ||
25 | #include <stdarg.h> | 25 | #include <stdarg.h> |
26 | 26 | ||
27 | #include "class.h" | 27 | #include "class.h" |
28 | -#include "interface/class.h" | ||
29 | -#include "interface/stream_reader.h" | 28 | +#include "stream.h" |
30 | 29 | ||
31 | #include "http/parser.h" | 30 | #include "http/parser.h" |
32 | #include "http/message/queue.h" | 31 | #include "http/message/queue.h" |
1 | +/** | ||
2 | + * \file | ||
3 | + * | ||
4 | + * \author Georg Hopp | ||
5 | + * | ||
6 | + * \copyright | ||
7 | + * Copyright © 2012 Georg Hopp | ||
8 | + * | ||
9 | + * This program is free software: you can redistribute it and/or modify | ||
10 | + * it under the terms of the GNU General Public License as published by | ||
11 | + * the Free Software Foundation, either version 3 of the License, or | ||
12 | + * (at your option) any later version. | ||
13 | + * | ||
14 | + * This program is distributed in the hope that it will be useful, | ||
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | + * GNU General Public License for more details. | ||
18 | + * | ||
19 | + * You should have received a copy of the GNU General Public License | ||
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | + */ | ||
22 | + | ||
1 | #include "http/parser.h" | 23 | #include "http/parser.h" |
2 | 24 | ||
3 | #include "utils/http.h" | 25 | #include "utils/http.h" |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -25,13 +25,11 @@ | @@ -25,13 +25,11 @@ | ||
25 | #include <sys/types.h> | 25 | #include <sys/types.h> |
26 | 26 | ||
27 | #include "class.h" | 27 | #include "class.h" |
28 | -#include "interface/class.h" | ||
29 | #include "http/header.h" | 28 | #include "http/header.h" |
30 | #include "http/parser.h" | 29 | #include "http/parser.h" |
31 | #include "http/message.h" | 30 | #include "http/message.h" |
32 | #include "http/request.h" | 31 | #include "http/request.h" |
33 | #include "hash.h" | 32 | #include "hash.h" |
34 | -#include "hash_value.h" | ||
35 | 33 | ||
36 | #define MAX(x,y) ((x) > (y) ? (x) : (y)) | 34 | #define MAX(x,y) ((x) > (y) ? (x) : (y)) |
37 | 35 |
1 | +/** | ||
2 | + * \file | ||
3 | + * | ||
4 | + * \author Georg Hopp | ||
5 | + * | ||
6 | + * \copyright | ||
7 | + * Copyright © 2012 Georg Hopp | ||
8 | + * | ||
9 | + * This program is free software: you can redistribute it and/or modify | ||
10 | + * it under the terms of the GNU General Public License as published by | ||
11 | + * the Free Software Foundation, either version 3 of the License, or | ||
12 | + * (at your option) any later version. | ||
13 | + * | ||
14 | + * This program is distributed in the hope that it will be useful, | ||
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | + * GNU General Public License for more details. | ||
18 | + * | ||
19 | + * You should have received a copy of the GNU General Public License | ||
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | + */ | ||
22 | + | ||
1 | #include <string.h> | 23 | #include <string.h> |
2 | #include <sys/types.h> | 24 | #include <sys/types.h> |
3 | 25 | ||
4 | #include "http/parser.h" | 26 | #include "http/parser.h" |
5 | #include "http/request.h" | 27 | #include "http/request.h" |
6 | -#include "hash_value.h" | ||
7 | #include "hash.h" | 28 | #include "hash.h" |
8 | -#include "interface/class.h" | 29 | +#include "class.h" |
9 | 30 | ||
10 | /** | 31 | /** |
11 | * \todo this is very similar to other pair parsing | 32 | * \todo this is very similar to other pair parsing |
1 | +/** | ||
2 | + * \file | ||
3 | + * | ||
4 | + * \author Georg Hopp | ||
5 | + * | ||
6 | + * \copyright | ||
7 | + * Copyright © 2012 Georg Hopp | ||
8 | + * | ||
9 | + * This program is free software: you can redistribute it and/or modify | ||
10 | + * it under the terms of the GNU General Public License as published by | ||
11 | + * the Free Software Foundation, either version 3 of the License, or | ||
12 | + * (at your option) any later version. | ||
13 | + * | ||
14 | + * This program is distributed in the hope that it will be useful, | ||
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | + * GNU General Public License for more details. | ||
18 | + * | ||
19 | + * You should have received a copy of the GNU General Public License | ||
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | + */ | ||
22 | + | ||
1 | #include <stdlib.h> | 23 | #include <stdlib.h> |
2 | #include <string.h> | 24 | #include <string.h> |
3 | #include <sys/types.h> | 25 | #include <sys/types.h> |
4 | 26 | ||
5 | #include "http/parser.h" | 27 | #include "http/parser.h" |
6 | #include "http/request.h" | 28 | #include "http/request.h" |
7 | -#include "hash_value.h" | ||
8 | #include "hash.h" | 29 | #include "hash.h" |
9 | -#include "interface/class.h" | 30 | +#include "class.h" |
10 | 31 | ||
11 | void | 32 | void |
12 | httpParserRequestVars(HttpParser this) | 33 | httpParserRequestVars(HttpParser this) |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -22,13 +22,14 @@ | @@ -22,13 +22,14 @@ | ||
22 | 22 | ||
23 | #include <stdlib.h> | 23 | #include <stdlib.h> |
24 | 24 | ||
25 | -#include "http/parser.h" | ||
26 | -#include "http/header.h" | ||
27 | -#include "interface/class.h" | ||
28 | -#include "interface/http_intro.h" | 25 | +#include "class.h" |
29 | #include "cbuf.h" | 26 | #include "cbuf.h" |
30 | #include "stream.h" | 27 | #include "stream.h" |
31 | 28 | ||
29 | +#include "http/parser.h" | ||
30 | +#include "http/header.h" | ||
31 | +#include "http/interface/http_intro.h" | ||
32 | + | ||
32 | #include "utils/memory.h" | 33 | #include "utils/memory.h" |
33 | #include "commons.h" | 34 | #include "commons.h" |
34 | 35 | ||
@@ -166,16 +167,16 @@ httpParserParse(void * _this, Stream st) | @@ -166,16 +167,16 @@ httpParserParse(void * _this, Stream st) | ||
166 | httpParserPostVars(this); | 167 | httpParserPostVars(this); |
167 | } | 168 | } |
168 | 169 | ||
169 | - /** | ||
170 | - * enqueue current request | ||
171 | - */ | ||
172 | - this->queue->msgs[(this->queue->nmsgs)++] = this->current; | ||
173 | - this->current = NULL; | 170 | + /** |
171 | + * enqueue current request | ||
172 | + */ | ||
173 | + this->queue->msgs[(this->queue->nmsgs)++] = this->current; | ||
174 | + this->current = NULL; | ||
174 | 175 | ||
175 | - /** | ||
176 | - * prepare for next request | ||
177 | - */ | ||
178 | - this->state = HTTP_MESSAGE_GARBAGE; | 176 | + /** |
177 | + * prepare for next request | ||
178 | + */ | ||
179 | + this->state = HTTP_MESSAGE_GARBAGE; | ||
179 | } | 180 | } |
180 | break; | 181 | break; |
181 | 182 |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -26,8 +26,8 @@ | @@ -26,8 +26,8 @@ | ||
26 | #include <sys/types.h> | 26 | #include <sys/types.h> |
27 | 27 | ||
28 | #include "class.h" | 28 | #include "class.h" |
29 | -#include "interface/class.h" | ||
30 | -#include "interface/http_intro.h" | 29 | +#include "hash.h" |
30 | +#include "http/interface/http_intro.h" | ||
31 | 31 | ||
32 | #include "http/request.h" | 32 | #include "http/request.h" |
33 | #include "utils/memory.h" | 33 | #include "utils/memory.h" |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -27,11 +27,10 @@ | @@ -27,11 +27,10 @@ | ||
27 | #include <stdio.h> | 27 | #include <stdio.h> |
28 | 28 | ||
29 | #include "class.h" | 29 | #include "class.h" |
30 | -#include "interface/class.h" | ||
31 | -#include "interface/http_intro.h" | 30 | +#include "utils/memory.h" |
32 | 31 | ||
33 | #include "http/response.h" | 32 | #include "http/response.h" |
34 | -#include "utils/memory.h" | 33 | +#include "http/interface/http_intro.h" |
35 | 34 | ||
36 | 35 | ||
37 | static | 36 | static |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -23,7 +23,6 @@ | @@ -23,7 +23,6 @@ | ||
23 | #include <sys/types.h> | 23 | #include <sys/types.h> |
24 | 24 | ||
25 | #include "class.h" | 25 | #include "class.h" |
26 | -#include "interface/class.h" | ||
27 | 26 | ||
28 | #include "http/response.h" | 27 | #include "http/response.h" |
29 | #include "http/message.h" | 28 | #include "http/message.h" |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -26,7 +26,6 @@ | @@ -26,7 +26,6 @@ | ||
26 | #include <sys/types.h> | 26 | #include <sys/types.h> |
27 | 27 | ||
28 | #include "class.h" | 28 | #include "class.h" |
29 | -#include "interface/class.h" | ||
30 | 29 | ||
31 | #include "http/response.h" | 30 | #include "http/response.h" |
32 | #include "http/message.h" | 31 | #include "http/message.h" |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -26,7 +26,6 @@ | @@ -26,7 +26,6 @@ | ||
26 | #include <sys/types.h> | 26 | #include <sys/types.h> |
27 | 27 | ||
28 | #include "class.h" | 28 | #include "class.h" |
29 | -#include "interface/class.h" | ||
30 | 29 | ||
31 | #include "http/response.h" | 30 | #include "http/response.h" |
32 | #include "http/message.h" | 31 | #include "http/message.h" |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -27,7 +27,6 @@ | @@ -27,7 +27,6 @@ | ||
27 | #include <sys/types.h> | 27 | #include <sys/types.h> |
28 | 28 | ||
29 | #include "class.h" | 29 | #include "class.h" |
30 | -#include "interface/class.h" | ||
31 | #include "stream.h" | 30 | #include "stream.h" |
32 | 31 | ||
33 | #include "http/response.h" | 32 | #include "http/response.h" |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -27,7 +27,6 @@ | @@ -27,7 +27,6 @@ | ||
27 | #include <sys/types.h> | 27 | #include <sys/types.h> |
28 | 28 | ||
29 | #include "class.h" | 29 | #include "class.h" |
30 | -#include "interface/class.h" | ||
31 | 30 | ||
32 | #include "http/response.h" | 31 | #include "http/response.h" |
33 | #include "http/message.h" | 32 | #include "http/message.h" |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -27,7 +27,6 @@ | @@ -27,7 +27,6 @@ | ||
27 | #include <sys/types.h> | 27 | #include <sys/types.h> |
28 | 28 | ||
29 | #include "class.h" | 29 | #include "class.h" |
30 | -#include "interface/class.h" | ||
31 | 30 | ||
32 | #include "http/response.h" | 31 | #include "http/response.h" |
33 | #include "http/message.h" | 32 | #include "http/message.h" |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -27,7 +27,6 @@ | @@ -27,7 +27,6 @@ | ||
27 | #include <sys/types.h> | 27 | #include <sys/types.h> |
28 | 28 | ||
29 | #include "class.h" | 29 | #include "class.h" |
30 | -#include "interface/class.h" | ||
31 | 30 | ||
32 | #include "http/response.h" | 31 | #include "http/response.h" |
33 | #include "http/message.h" | 32 | #include "http/message.h" |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -34,10 +34,6 @@ | @@ -34,10 +34,6 @@ | ||
34 | #include "http/parser.h" | 34 | #include "http/parser.h" |
35 | #include "http/writer.h" | 35 | #include "http/writer.h" |
36 | 36 | ||
37 | -#include "interface/class.h" | ||
38 | -#include "interface/stream_reader.h" | ||
39 | -#include "interface/stream_writer.h" | ||
40 | - | ||
41 | #include "utils/memory.h" | 37 | #include "utils/memory.h" |
42 | 38 | ||
43 | static | 39 | static |
@@ -63,7 +59,6 @@ httpWorkerCtor(void * _this, va_list * params) | @@ -63,7 +59,6 @@ httpWorkerCtor(void * _this, va_list * params) | ||
63 | this->writer = new(HttpWriter, this->wbuf); | 59 | this->writer = new(HttpWriter, this->wbuf); |
64 | 60 | ||
65 | this->sroot = &(this->session); | 61 | this->sroot = &(this->session); |
66 | - | ||
67 | this->auth = va_arg(* params, void *); | 62 | this->auth = va_arg(* params, void *); |
68 | 63 | ||
69 | return 0; | 64 | return 0; |
1 | +/** | ||
2 | + * \file | ||
3 | + * | ||
4 | + * \author Georg Hopp | ||
5 | + * | ||
6 | + * \copyright | ||
7 | + * Copyright © 2012 Georg Hopp | ||
8 | + * | ||
9 | + * This program is free software: you can redistribute it and/or modify | ||
10 | + * it under the terms of the GNU General Public License as published by | ||
11 | + * the Free Software Foundation, either version 3 of the License, or | ||
12 | + * (at your option) any later version. | ||
13 | + * | ||
14 | + * This program is distributed in the hope that it will be useful, | ||
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | + * GNU General Public License for more details. | ||
18 | + * | ||
19 | + * You should have received a copy of the GNU General Public License | ||
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | + */ | ||
22 | + | ||
1 | #include <time.h> | 23 | #include <time.h> |
2 | #include <sys/types.h> | 24 | #include <sys/types.h> |
3 | 25 | ||
4 | #include "class.h" | 26 | #include "class.h" |
5 | -#include "interface/class.h" | ||
6 | 27 | ||
7 | #include "http/message.h" | 28 | #include "http/message.h" |
8 | #include "http/header.h" | 29 | #include "http/header.h" |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
1 | +/** | ||
2 | + * \file | ||
3 | + * | ||
4 | + * \author Georg Hopp | ||
5 | + * | ||
6 | + * \copyright | ||
7 | + * Copyright © 2012 Georg Hopp | ||
8 | + * | ||
9 | + * This program is free software: you can redistribute it and/or modify | ||
10 | + * it under the terms of the GNU General Public License as published by | ||
11 | + * the Free Software Foundation, either version 3 of the License, or | ||
12 | + * (at your option) any later version. | ||
13 | + * | ||
14 | + * This program is distributed in the hope that it will be useful, | ||
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | + * GNU General Public License for more details. | ||
18 | + * | ||
19 | + * You should have received a copy of the GNU General Public License | ||
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | + */ | ||
22 | + | ||
1 | #include <sys/types.h> | 23 | #include <sys/types.h> |
2 | 24 | ||
3 | #include "http/header.h" | 25 | #include "http/header.h" |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -28,8 +28,7 @@ | @@ -28,8 +28,7 @@ | ||
28 | #include <sys/time.h> | 28 | #include <sys/time.h> |
29 | 29 | ||
30 | #include "class.h" | 30 | #include "class.h" |
31 | -#include "interface/class.h" | ||
32 | -#include "interface/auth.h" | 31 | +#include "auth.h" |
33 | 32 | ||
34 | #include "http/worker.h" | 33 | #include "http/worker.h" |
35 | #include "http/header.h" | 34 | #include "http/header.h" |
@@ -40,9 +39,7 @@ | @@ -40,9 +39,7 @@ | ||
40 | #include "http/parser.h" | 39 | #include "http/parser.h" |
41 | #include "session.h" | 40 | #include "session.h" |
42 | #include "stream.h" | 41 | #include "stream.h" |
43 | -#include "hash_value.h" | ||
44 | #include "hash.h" | 42 | #include "hash.h" |
45 | -#include "credential.h" | ||
46 | 43 | ||
47 | #include "utils/memory.h" | 44 | #include "utils/memory.h" |
48 | #include "hash.h" | 45 | #include "hash.h" |
@@ -79,11 +76,11 @@ httpWorkerProcess(HttpWorker this, Stream st) | @@ -79,11 +76,11 @@ httpWorkerProcess(HttpWorker this, Stream st) | ||
79 | if (NULL == this->session) { | 76 | if (NULL == this->session) { |
80 | HashValue sidstr = hashGet(request->cookies, CSTRA("sid")); | 77 | HashValue sidstr = hashGet(request->cookies, CSTRA("sid")); |
81 | 78 | ||
82 | - if (NULL != sidstr) { | ||
83 | - unsigned long sid; | 79 | + if (NULL != sidstr) { |
80 | + unsigned long sid; | ||
84 | 81 | ||
85 | sid = strtoul((char*)(sidstr->value), NULL, 10); | 82 | sid = strtoul((char*)(sidstr->value), NULL, 10); |
86 | - this->session = sessionGet(this->sroot, sid); | 83 | + this->session = sessionGet(this->sroot, sid); |
87 | } | 84 | } |
88 | } | 85 | } |
89 | 86 | ||
@@ -130,8 +127,8 @@ httpWorkerProcess(HttpWorker this, Stream st) | @@ -130,8 +127,8 @@ httpWorkerProcess(HttpWorker this, Stream st) | ||
130 | response = new(HttpResponse, "HTTP/1.1", 403, "Forbidden"); | 127 | response = new(HttpResponse, "HTTP/1.1", 403, "Forbidden"); |
131 | } else { | 128 | } else { |
132 | if (NULL == this->session) { | 129 | if (NULL == this->session) { |
133 | - this->session = sessionAdd( | ||
134 | - this->sroot, | 130 | + this->session = sessionAdd( |
131 | + this->sroot, | ||
135 | new(Session, | 132 | new(Session, |
136 | username->value, | 133 | username->value, |
137 | username->nvalue)); | 134 | username->nvalue)); |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -23,8 +23,7 @@ | @@ -23,8 +23,7 @@ | ||
23 | #include <stdarg.h> | 23 | #include <stdarg.h> |
24 | 24 | ||
25 | #include "class.h" | 25 | #include "class.h" |
26 | -#include "interface/class.h" | ||
27 | -#include "interface/stream_writer.h" | 26 | +#include "stream.h" |
28 | 27 | ||
29 | #include "http/message/queue.h" | 28 | #include "http/message/queue.h" |
30 | #include "http/writer.h" | 29 | #include "http/writer.h" |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -24,7 +24,6 @@ | @@ -24,7 +24,6 @@ | ||
24 | #include <sys/stat.h> | 24 | #include <sys/stat.h> |
25 | 25 | ||
26 | #include "class.h" | 26 | #include "class.h" |
27 | -#include "interface/class.h" | ||
28 | #include "http/message.h" | 27 | #include "http/message.h" |
29 | #include "http/writer.h" | 28 | #include "http/writer.h" |
30 | #include "cbuf.h" | 29 | #include "cbuf.h" |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
src/logger/Makefile.am
0 → 100644
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -24,8 +24,8 @@ | @@ -24,8 +24,8 @@ | ||
24 | #include <stdio.h> | 24 | #include <stdio.h> |
25 | #include <stdarg.h> | 25 | #include <stdarg.h> |
26 | 26 | ||
27 | -#include "logger.h" | ||
28 | -#include "interface/logger.h" | 27 | +#include "logger/logger.h" |
28 | +#include "logger/interface/logger.h" | ||
29 | 29 | ||
30 | const struct interface i_Logger = { | 30 | const struct interface i_Logger = { |
31 | "logger", | 31 | "logger", |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -22,9 +22,9 @@ | @@ -22,9 +22,9 @@ | ||
22 | 22 | ||
23 | #include <stdarg.h> | 23 | #include <stdarg.h> |
24 | 24 | ||
25 | -#include "logger.h" | ||
26 | -#include "interface/class.h" | ||
27 | -#include "interface/logger.h" | 25 | +#include "class.h" |
26 | +#include "logger/logger.h" | ||
27 | +#include "logger/interface/logger.h" | ||
28 | 28 | ||
29 | const | 29 | const |
30 | char * const | 30 | char * const |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -22,8 +22,8 @@ | @@ -22,8 +22,8 @@ | ||
22 | 22 | ||
23 | #include <stdio.h> | 23 | #include <stdio.h> |
24 | 24 | ||
25 | -#include "logger.h" | ||
26 | -#include "interface/logger.h" | 25 | +#include "logger/logger.h" |
26 | +#include "logger/interface/logger.h" | ||
27 | 27 | ||
28 | static | 28 | static |
29 | void | 29 | void |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -22,8 +22,8 @@ | @@ -22,8 +22,8 @@ | ||
22 | 22 | ||
23 | #include <syslog.h> | 23 | #include <syslog.h> |
24 | 24 | ||
25 | -#include "logger.h" | ||
26 | -#include "interface/logger.h" | 25 | +#include "logger/logger.h" |
26 | +#include "logger/interface/logger.h" | ||
27 | 27 | ||
28 | static | 28 | static |
29 | const | 29 | const |
src/server/Makefile.am
0 → 100644
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -24,7 +24,7 @@ | @@ -24,7 +24,7 @@ | ||
24 | #include <string.h> | 24 | #include <string.h> |
25 | 25 | ||
26 | #include "server.h" | 26 | #include "server.h" |
27 | -#include "interface/class.h" | 27 | +#include "class.h" |
28 | #include "stream.h" | 28 | #include "stream.h" |
29 | 29 | ||
30 | void | 30 | void |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -28,15 +28,15 @@ | @@ -28,15 +28,15 @@ | ||
28 | 28 | ||
29 | #include "http/worker.h" | 29 | #include "http/worker.h" |
30 | #include "server.h" | 30 | #include "server.h" |
31 | -#include "interface/class.h" | ||
32 | -#include "interface/logger.h" | 31 | +#include "class.h" |
32 | +#include "logger.h" | ||
33 | #include "stream.h" | 33 | #include "stream.h" |
34 | 34 | ||
35 | int | 35 | int |
36 | serverHandleAccept(Server this, unsigned int i) | 36 | serverHandleAccept(Server this, unsigned int i) |
37 | { | 37 | { |
38 | char remoteAddr[16] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; | 38 | char remoteAddr[16] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; |
39 | - Sock acc = NULL; | 39 | + Sock acc = NULL; |
40 | Stream st; | 40 | Stream st; |
41 | 41 | ||
42 | if (this->nfds >= this->max_fds) { | 42 | if (this->nfds >= this->max_fds) { |
@@ -46,25 +46,25 @@ serverHandleAccept(Server this, unsigned int i) | @@ -46,25 +46,25 @@ serverHandleAccept(Server this, unsigned int i) | ||
46 | acc = socketAccept((0 == i)? this->sock : this->sockSSL, &remoteAddr); | 46 | acc = socketAccept((0 == i)? this->sock : this->sockSSL, &remoteAddr); |
47 | 47 | ||
48 | if (-1 != acc->handle) { | 48 | if (-1 != acc->handle) { |
49 | - switch(i) { | ||
50 | - case 0: | ||
51 | - // no SSL | ||
52 | - st = new(Stream, STREAM_FD, acc->handle); | ||
53 | - break; | ||
54 | - | ||
55 | - case 1: | ||
56 | - // SSL | ||
57 | - { | ||
58 | - SSL * ssl = SSL_new(this->ctx); | ||
59 | - SSL_set_fd(ssl, acc->handle); | ||
60 | - SSL_accept(ssl); | ||
61 | - st = new(Stream, STREAM_SSL, ssl); | ||
62 | - } | ||
63 | - break; | ||
64 | - | ||
65 | - default: | ||
66 | - break; | ||
67 | - } | 49 | + switch(i) { |
50 | + case 0: | ||
51 | + // no SSL | ||
52 | + st = new(Stream, STREAM_FD, acc->handle); | ||
53 | + break; | ||
54 | + | ||
55 | + case 1: | ||
56 | + // SSL | ||
57 | + { | ||
58 | + SSL * ssl = SSL_new(this->ctx); | ||
59 | + SSL_set_fd(ssl, acc->handle); | ||
60 | + SSL_accept(ssl); | ||
61 | + st = new(Stream, STREAM_SSL, ssl); | ||
62 | + } | ||
63 | + break; | ||
64 | + | ||
65 | + default: | ||
66 | + break; | ||
67 | + } | ||
68 | 68 | ||
69 | // save the socket handle | 69 | // save the socket handle |
70 | (this->conns)[acc->handle].sock = acc; | 70 | (this->conns)[acc->handle].sock = acc; |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -24,7 +24,7 @@ | @@ -24,7 +24,7 @@ | ||
24 | #include <errno.h> | 24 | #include <errno.h> |
25 | 25 | ||
26 | #include "server.h" | 26 | #include "server.h" |
27 | -#include "interface/logger.h" | 27 | +#include "logger.h" |
28 | 28 | ||
29 | #include "utils/signalHandling.h" | 29 | #include "utils/signalHandling.h" |
30 | 30 |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -21,8 +21,8 @@ | @@ -21,8 +21,8 @@ | ||
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include "server.h" | 23 | #include "server.h" |
24 | -#include "interface/logger.h" | ||
25 | -#include "interface/stream_reader.h" | 24 | +#include "logger.h" |
25 | +#include "stream.h" | ||
26 | 26 | ||
27 | void serverCloseConn(Server, unsigned int); | 27 | void serverCloseConn(Server, unsigned int); |
28 | 28 |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -21,7 +21,7 @@ | @@ -21,7 +21,7 @@ | ||
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include "server.h" | 23 | #include "server.h" |
24 | -#include "interface/logger.h" | 24 | +#include "logger.h" |
25 | 25 | ||
26 | #include "utils/signalHandling.h" | 26 | #include "utils/signalHandling.h" |
27 | 27 |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -31,7 +31,6 @@ | @@ -31,7 +31,6 @@ | ||
31 | #include "server.h" | 31 | #include "server.h" |
32 | #include "socket.h" | 32 | #include "socket.h" |
33 | #include "logger.h" | 33 | #include "logger.h" |
34 | -#include "interface/class.h" | ||
35 | 34 | ||
36 | #include "utils/memory.h" | 35 | #include "utils/memory.h" |
37 | 36 |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -21,8 +21,8 @@ | @@ -21,8 +21,8 @@ | ||
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include "server.h" | 23 | #include "server.h" |
24 | -#include "interface/logger.h" | ||
25 | -#include "interface/stream_writer.h" | 24 | +#include "logger.h" |
25 | +#include "stream.h" | ||
26 | 26 | ||
27 | void serverCloseConn(Server, unsigned int); | 27 | void serverCloseConn(Server, unsigned int); |
28 | 28 |
src/session/Makefile.am
0 → 100644
1 | +/** | ||
2 | + * \file | ||
3 | + * | ||
4 | + * \author Georg Hopp | ||
5 | + * | ||
6 | + * \copyright | ||
7 | + * Copyright © 2012 Georg Hopp | ||
8 | + * | ||
9 | + * This program is free software: you can redistribute it and/or modify | ||
10 | + * it under the terms of the GNU General Public License as published by | ||
11 | + * the Free Software Foundation, either version 3 of the License, or | ||
12 | + * (at your option) any later version. | ||
13 | + * | ||
14 | + * This program is distributed in the hope that it will be useful, | ||
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | + * GNU General Public License for more details. | ||
18 | + * | ||
19 | + * You should have received a copy of the GNU General Public License | ||
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | + */ | ||
22 | + | ||
1 | #include <search.h> | 23 | #include <search.h> |
2 | 24 | ||
3 | #include "session.h" | 25 | #include "session.h" |
4 | -#include "interface/class.h" | 26 | +#include "class.h" |
5 | 27 | ||
6 | 28 | ||
7 | static | 29 | static |
1 | +/** | ||
2 | + * \file | ||
3 | + * | ||
4 | + * \author Georg Hopp | ||
5 | + * | ||
6 | + * \copyright | ||
7 | + * Copyright © 2012 Georg Hopp | ||
8 | + * | ||
9 | + * This program is free software: you can redistribute it and/or modify | ||
10 | + * it under the terms of the GNU General Public License as published by | ||
11 | + * the Free Software Foundation, either version 3 of the License, or | ||
12 | + * (at your option) any later version. | ||
13 | + * | ||
14 | + * This program is distributed in the hope that it will be useful, | ||
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | + * GNU General Public License for more details. | ||
18 | + * | ||
19 | + * You should have received a copy of the GNU General Public License | ||
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | + */ | ||
22 | + | ||
1 | #include <search.h> | 23 | #include <search.h> |
2 | 24 | ||
3 | #include "session.h" | 25 | #include "session.h" |
4 | -#include "interface/class.h" | 26 | +#include "class.h" |
5 | 27 | ||
6 | 28 | ||
7 | static | 29 | static |
1 | +/** | ||
2 | + * \file | ||
3 | + * | ||
4 | + * \author Georg Hopp | ||
5 | + * | ||
6 | + * \copyright | ||
7 | + * Copyright © 2012 Georg Hopp | ||
8 | + * | ||
9 | + * This program is free software: you can redistribute it and/or modify | ||
10 | + * it under the terms of the GNU General Public License as published by | ||
11 | + * the Free Software Foundation, either version 3 of the License, or | ||
12 | + * (at your option) any later version. | ||
13 | + * | ||
14 | + * This program is distributed in the hope that it will be useful, | ||
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | + * GNU General Public License for more details. | ||
18 | + * | ||
19 | + * You should have received a copy of the GNU General Public License | ||
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | + */ | ||
22 | + | ||
1 | #include <search.h> | 23 | #include <search.h> |
2 | #include <time.h> | 24 | #include <time.h> |
3 | 25 |
1 | +/** | ||
2 | + * \file | ||
3 | + * | ||
4 | + * \author Georg Hopp | ||
5 | + * | ||
6 | + * \copyright | ||
7 | + * Copyright © 2012 Georg Hopp | ||
8 | + * | ||
9 | + * This program is free software: you can redistribute it and/or modify | ||
10 | + * it under the terms of the GNU General Public License as published by | ||
11 | + * the Free Software Foundation, either version 3 of the License, or | ||
12 | + * (at your option) any later version. | ||
13 | + * | ||
14 | + * This program is distributed in the hope that it will be useful, | ||
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | + * GNU General Public License for more details. | ||
18 | + * | ||
19 | + * You should have received a copy of the GNU General Public License | ||
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | + */ | ||
22 | + | ||
1 | #include <time.h> | 23 | #include <time.h> |
2 | #include <stdarg.h> | 24 | #include <stdarg.h> |
3 | #include <stdlib.h> | 25 | #include <stdlib.h> |
@@ -7,7 +29,6 @@ | @@ -7,7 +29,6 @@ | ||
7 | 29 | ||
8 | #include "session.h" | 30 | #include "session.h" |
9 | #include "class.h" | 31 | #include "class.h" |
10 | -#include "interface/class.h" | ||
11 | 32 | ||
12 | #include "utils/hash.h" | 33 | #include "utils/hash.h" |
13 | #include "utils/memory.h" | 34 | #include "utils/memory.h" |
src/socket/Makefile.am
0 → 100644
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -24,8 +24,8 @@ | @@ -24,8 +24,8 @@ | ||
24 | #include <unistd.h> | 24 | #include <unistd.h> |
25 | 25 | ||
26 | #include "socket.h" | 26 | #include "socket.h" |
27 | -#include "interface/class.h" | ||
28 | -#include "interface/logger.h" | 27 | +#include "class.h" |
28 | +#include "logger.h" | ||
29 | 29 | ||
30 | Sock | 30 | Sock |
31 | socketAccept(Sock this, char (*remoteAddr)[16]) | 31 | socketAccept(Sock this, char (*remoteAddr)[16]) |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -24,8 +24,8 @@ | @@ -24,8 +24,8 @@ | ||
24 | #include <errno.h> // for errno | 24 | #include <errno.h> // for errno |
25 | 25 | ||
26 | #include "socket.h" | 26 | #include "socket.h" |
27 | -#include "interface/class.h" | ||
28 | -#include "interface/logger.h" | 27 | +#include "class.h" |
28 | +#include "logger.h" | ||
29 | 29 | ||
30 | 30 | ||
31 | void | 31 | void |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -24,8 +24,8 @@ | @@ -24,8 +24,8 @@ | ||
24 | #include <errno.h> // for errno | 24 | #include <errno.h> // for errno |
25 | 25 | ||
26 | #include "socket.h" | 26 | #include "socket.h" |
27 | -#include "interface/class.h" | ||
28 | -#include "interface/logger.h" | 27 | +#include "class.h" |
28 | +#include "logger.h" | ||
29 | 29 | ||
30 | 30 | ||
31 | void | 31 | void |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -26,8 +26,7 @@ | @@ -26,8 +26,7 @@ | ||
26 | 26 | ||
27 | #include "socket.h" | 27 | #include "socket.h" |
28 | #include "logger.h" | 28 | #include "logger.h" |
29 | -#include "interface/class.h" | ||
30 | -#include "interface/logger.h" | 29 | +#include "class.h" |
31 | 30 | ||
32 | static | 31 | static |
33 | int | 32 | int |
src/stream/Makefile.am
0 → 100644
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -21,8 +21,9 @@ | @@ -21,8 +21,9 @@ | ||
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include "class.h" | 23 | #include "class.h" |
24 | -#include "interface/stream_reader.h" | ||
25 | -#include "stream.h" | 24 | + |
25 | +#include "stream/stream.h" | ||
26 | +#include "stream/interface/reader.h" | ||
26 | 27 | ||
27 | const struct interface i_StreamReader = { | 28 | const struct interface i_StreamReader = { |
28 | "streamReader", | 29 | "streamReader", |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
@@ -21,8 +21,9 @@ | @@ -21,8 +21,9 @@ | ||
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include "class.h" | 23 | #include "class.h" |
24 | -#include "interface/stream_writer.h" | ||
25 | -#include "stream.h" | 24 | + |
25 | +#include "stream/stream.h" | ||
26 | +#include "stream/interface/writer.h" | ||
26 | 27 | ||
27 | const struct interface i_StreamWriter = { | 28 | const struct interface i_StreamWriter = { |
28 | "streamWriter", | 29 | "streamWriter", |
1 | +/** | ||
2 | + * \file | ||
3 | + * | ||
4 | + * \author Georg Hopp | ||
5 | + * | ||
6 | + * \copyright | ||
7 | + * Copyright © 2012 Georg Hopp | ||
8 | + * | ||
9 | + * This program is free software: you can redistribute it and/or modify | ||
10 | + * it under the terms of the GNU General Public License as published by | ||
11 | + * the Free Software Foundation, either version 3 of the License, or | ||
12 | + * (at your option) any later version. | ||
13 | + * | ||
14 | + * This program is distributed in the hope that it will be useful, | ||
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | + * GNU General Public License for more details. | ||
18 | + * | ||
19 | + * You should have received a copy of the GNU General Public License | ||
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | + */ | ||
22 | + | ||
1 | #include <openssl/ssl.h> | 23 | #include <openssl/ssl.h> |
2 | #include <unistd.h> | 24 | #include <unistd.h> |
3 | 25 |
1 | +/** | ||
2 | + * \file | ||
3 | + * | ||
4 | + * \author Georg Hopp | ||
5 | + * | ||
6 | + * \copyright | ||
7 | + * Copyright © 2012 Georg Hopp | ||
8 | + * | ||
9 | + * This program is free software: you can redistribute it and/or modify | ||
10 | + * it under the terms of the GNU General Public License as published by | ||
11 | + * the Free Software Foundation, either version 3 of the License, or | ||
12 | + * (at your option) any later version. | ||
13 | + * | ||
14 | + * This program is distributed in the hope that it will be useful, | ||
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | + * GNU General Public License for more details. | ||
18 | + * | ||
19 | + * You should have received a copy of the GNU General Public License | ||
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | + */ | ||
22 | + | ||
1 | #include <stdarg.h> | 23 | #include <stdarg.h> |
2 | #include <openssl/ssl.h> | 24 | #include <openssl/ssl.h> |
3 | 25 | ||
4 | #include "class.h" | 26 | #include "class.h" |
5 | -#include "interface/class.h" | ||
6 | -#include "stream.h" | 27 | +#include "stream/stream.h" |
7 | 28 | ||
8 | 29 | ||
9 | static | 30 | static |
1 | +/** | ||
2 | + * \file | ||
3 | + * | ||
4 | + * \author Georg Hopp | ||
5 | + * | ||
6 | + * \copyright | ||
7 | + * Copyright © 2012 Georg Hopp | ||
8 | + * | ||
9 | + * This program is free software: you can redistribute it and/or modify | ||
10 | + * it under the terms of the GNU General Public License as published by | ||
11 | + * the Free Software Foundation, either version 3 of the License, or | ||
12 | + * (at your option) any later version. | ||
13 | + * | ||
14 | + * This program is distributed in the hope that it will be useful, | ||
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | + * GNU General Public License for more details. | ||
18 | + * | ||
19 | + * You should have received a copy of the GNU General Public License | ||
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | + */ | ||
22 | + | ||
1 | #include <openssl/ssl.h> | 23 | #include <openssl/ssl.h> |
2 | #include <unistd.h> | 24 | #include <unistd.h> |
3 | 25 |
@@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
6 | * \author Georg Hopp | 6 | * \author Georg Hopp |
7 | * | 7 | * |
8 | * \copyright | 8 | * \copyright |
9 | - * Copyright (C) 2012 Georg Hopp | 9 | + * Copyright © 2012 Georg Hopp |
10 | * | 10 | * |
11 | * This program is free software: you can redistribute it and/or modify | 11 | * This program is free software: you can redistribute it and/or modify |
12 | * it under the terms of the GNU General Public License as published by | 12 | * it under the terms of the GNU General Public License as published by |
1 | +/** | ||
2 | + * \file | ||
3 | + * | ||
4 | + * \author Georg Hopp | ||
5 | + * \author Unknown (find out) | ||
6 | + * | ||
7 | + * \copyright | ||
8 | + * Copyright © 2012 Georg Hopp | ||
9 | + * | ||
10 | + * This program is free software: you can redistribute it and/or modify | ||
11 | + * it under the terms of the GNU General Public License as published by | ||
12 | + * the Free Software Foundation, either version 3 of the License, or | ||
13 | + * (at your option) any later version. | ||
14 | + * | ||
15 | + * This program is distributed in the hope that it will be useful, | ||
16 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | + * GNU General Public License for more details. | ||
19 | + * | ||
20 | + * You should have received a copy of the GNU General Public License | ||
21 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
22 | + */ | ||
23 | + | ||
1 | #include <ctype.h> | 24 | #include <ctype.h> |
2 | #include <sys/types.h> | 25 | #include <sys/types.h> |
3 | 26 |
1 | +/** | ||
2 | + * \file | ||
3 | + * | ||
4 | + * \author Georg Hopp | ||
5 | + * | ||
6 | + * \copyright | ||
7 | + * Copyright © 2012 Georg Hopp | ||
8 | + * | ||
9 | + * This program is free software: you can redistribute it and/or modify | ||
10 | + * it under the terms of the GNU General Public License as published by | ||
11 | + * the Free Software Foundation, either version 3 of the License, or | ||
12 | + * (at your option) any later version. | ||
13 | + * | ||
14 | + * This program is distributed in the hope that it will be useful, | ||
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | + * GNU General Public License for more details. | ||
18 | + * | ||
19 | + * You should have received a copy of the GNU General Public License | ||
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | + */ | ||
22 | + | ||
1 | #include <stdlib.h> | 23 | #include <stdlib.h> |
2 | #include <sys/types.h> | 24 | #include <sys/types.h> |
3 | #include <string.h> | 25 | #include <string.h> |
@@ -6,7 +28,7 @@ | @@ -6,7 +28,7 @@ | ||
6 | #include "http/request.h" | 28 | #include "http/request.h" |
7 | #include "http/response.h" | 29 | #include "http/response.h" |
8 | 30 | ||
9 | -#include "interface/class.h" | 31 | +#include "class.h" |
10 | 32 | ||
11 | #include "commons.h" | 33 | #include "commons.h" |
12 | 34 |
1 | +/** | ||
2 | + * \file | ||
3 | + * | ||
4 | + * \author Georg Hopp | ||
5 | + * | ||
6 | + * \copyright | ||
7 | + * Copyright © 2012 Georg Hopp | ||
8 | + * | ||
9 | + * This program is free software: you can redistribute it and/or modify | ||
10 | + * it under the terms of the GNU General Public License as published by | ||
11 | + * the Free Software Foundation, either version 3 of the License, or | ||
12 | + * (at your option) any later version. | ||
13 | + * | ||
14 | + * This program is distributed in the hope that it will be useful, | ||
15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | + * GNU General Public License for more details. | ||
18 | + * | ||
19 | + * You should have received a copy of the GNU General Public License | ||
20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | + */ | ||
22 | + | ||
1 | #include <stdlib.h> | 23 | #include <stdlib.h> |
2 | 24 | ||
3 | #include "utils/memory.h" | 25 | #include "utils/memory.h" |
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | * \author Georg Hopp | 4 | * \author Georg Hopp |
5 | * | 5 | * |
6 | * \copyright | 6 | * \copyright |
7 | - * Copyright (C) 2012 Georg Hopp | 7 | + * Copyright © 2012 Georg Hopp |
8 | * | 8 | * |
9 | * This program is free software: you can redistribute it and/or modify | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
1 | ACLOCAL_AMFLAGS = -I m4 | 1 | ACLOCAL_AMFLAGS = -I m4 |
2 | -AUTOMAKE_OPTIONS = subdir-objects | ||
3 | 2 | ||
4 | TESTS_ENVIRONMENT = valgrind --error-exitcode=123 --leak-check=full --quiet | 3 | TESTS_ENVIRONMENT = valgrind --error-exitcode=123 --leak-check=full --quiet |
5 | -TESTS = cclassTest loggerTest socketTest serverTest | ||
6 | -check_PROGRAMS = cclassTest loggerTest socketTest serverTest | 4 | +TESTS = classTest loggerTest socketTest serverTest |
5 | +check_PROGRAMS = classTest loggerTest socketTest serverTest | ||
7 | 6 | ||
8 | -COMMON = runtest.c ../src/interface/class.c | ||
9 | -CCLASS = $(COMMON) mock/class.c | ||
10 | -LOGGER = $(COMMON) ../src/logger.c ../src/interface/logger.c \ | ||
11 | - ../src/logger/stderr.c ../src/logger/syslog.c | ||
12 | -SOCKET = $(LOGGER) ../src/socket.c ../src/socket/listen.c \ | ||
13 | - ../src/socket/accept.c ../src/socket/connect.c | ||
14 | -SERVER = $(SOCKET) ../src/server.c ../src/server/run.c \ | ||
15 | - ../src/server/close_conn.c ../src/utils/signalHandling.c | 7 | +COMMON = runtest.c |
8 | +CLASS = $(COMMON) \ | ||
9 | + ../src/class/interface.c \ | ||
10 | + ../src/class/interface/i_class.c \ | ||
11 | + mock/mock_class.c | ||
16 | 12 | ||
17 | -cclassTest_SOURCES = $(CCLASS) cclassTest.c | ||
18 | -cclassTest_CFLAGS = -Wall -ggdb -O0 -finline-functions -I ../include -I .. -I . | 13 | +LOGGER = $(CLASS) \ |
14 | + ../src/logger/logger.c \ | ||
15 | + ../src/logger/stderr.c \ | ||
16 | + ../src/logger/syslog.c \ | ||
17 | + ../src/logger/interface/i_logger.c \ | ||
18 | + mock/mock_logger.c | ||
19 | + | ||
20 | +SOCKET = $(LOGGER) \ | ||
21 | + ../src/socket/socket.c \ | ||
22 | + ../src/socket/listen.c \ | ||
23 | + ../src/socket/accept.c \ | ||
24 | + ../src/socket/connect.c | ||
25 | + | ||
26 | +STREAM_OBJ = ./stream/stream.o \ | ||
27 | + ./stream/read.o \ | ||
28 | + ./stream/write.o \ | ||
29 | + ./stream/reader.o \ | ||
30 | + ./stream/writer.o | ||
31 | + | ||
32 | +SERVER = $(SOCKET) \ | ||
33 | + ../src/server/server.c \ | ||
34 | + ../src/server/run.c \ | ||
35 | + ../src/server/close_conn.c \ | ||
36 | + ../src/server/handle_accept.c \ | ||
37 | + ../src/server/poll.c \ | ||
38 | + ../src/server/read.c \ | ||
39 | + ../src/server/write.c \ | ||
40 | + ../src/utils/signalHandling.c \ | ||
41 | + ../src/utils/memory.c \ | ||
42 | + mock/mock_worker.c | ||
43 | + | ||
44 | +classTest_SOURCES = $(CLASS) classTest.c | ||
45 | +classTest_CFLAGS = -Wall -ggdb -O0 -fprofile-arcs -ftest-coverage -I ../include -I .. -I . | ||
46 | +classTest_LDFLAGS = -lgcov | ||
19 | 47 | ||
20 | loggerTest_SOURCES = $(LOGGER) loggerTest.c | 48 | loggerTest_SOURCES = $(LOGGER) loggerTest.c |
21 | -loggerTest_CFLAGS = -Wall -ggdb -O0 -I ../include -I .. -I . | 49 | +loggerTest_CFLAGS = -Wall -ggdb -O0 -fprofile-arcs -ftest-coverage -I ../include -I .. -I . |
50 | +loggerTest_LDFLAGS = -lgcov | ||
22 | 51 | ||
23 | socketTest_SOURCES = $(SOCKET) socketTest.c | 52 | socketTest_SOURCES = $(SOCKET) socketTest.c |
24 | -socketTest_CFLAGS = -Wall -ggdb -O0 -I ../include -I .. -I . | 53 | +socketTest_CFLAGS = -Wall -ggdb -O0 -fprofile-arcs -ftest-coverage -I ../include -I .. -I . |
54 | +socketTest_LDFLAGS = -lgcov | ||
25 | 55 | ||
26 | serverTest_SOURCES = $(SERVER) serverTest.c | 56 | serverTest_SOURCES = $(SERVER) serverTest.c |
27 | -serverTest_CFLAGS = -Wall -ggdb -O0 -I ../include -I .. -I . | 57 | +serverTest_CFLAGS = -Wall -ggdb -O0 -fprofile-arcs -ftest-coverage -I ../include -I .. -I . |
58 | +serverTest_LDFLAGS = $(STREAM_OBJ) -lgcov | ||
59 | + | ||
60 | +EXTRA_DIST = runtest.h mock/mock_class.h mock/mock_logger.h | ||
61 | + | ||
62 | +.PHONY: stream | ||
63 | +stream: | ||
64 | + $(MAKE) -C stream $(AM_MAKEFLAGS) | ||
65 | + | ||
66 | +$(check_PROGRAMS): stream | ||
67 | +check-build: $(check_PROGRAMS) | ||
68 | + | ||
69 | +all-local: stream | ||
28 | 70 | ||
29 | -EXTRA_DIST = runtest.h mock/class.h | 71 | +SUBDIRS = stream |
@@ -18,15 +18,15 @@ | @@ -18,15 +18,15 @@ | ||
18 | */ | 18 | */ |
19 | #include <stdio.h> | 19 | #include <stdio.h> |
20 | #include <sys/types.h> | 20 | #include <sys/types.h> |
21 | -#include <json/json.h> | ||
22 | 21 | ||
23 | #include "runtest.h" | 22 | #include "runtest.h" |
24 | -#include "mock/class.h" | ||
25 | -#include "cclass.h" | 23 | +#include "mock/mock_class.h" |
24 | + | ||
25 | +#include "class.h" | ||
26 | 26 | ||
27 | const char testname[] = "cclassTest"; | 27 | const char testname[] = "cclassTest"; |
28 | 28 | ||
29 | -MOCK_CLASS mock = NULL; | 29 | +MockClass mock = NULL; |
30 | 30 | ||
31 | static | 31 | static |
32 | int | 32 | int |
@@ -45,7 +45,7 @@ __tearDown() | @@ -45,7 +45,7 @@ __tearDown() | ||
45 | { | 45 | { |
46 | if (NULL != mock) { | 46 | if (NULL != mock) { |
47 | ASSERT_OBJECT(mock); | 47 | ASSERT_OBJECT(mock); |
48 | - delete(&mock); | 48 | + delete(mock); |
49 | } | 49 | } |
50 | 50 | ||
51 | return TEST_OK; | 51 | return TEST_OK; |
@@ -56,27 +56,22 @@ static | @@ -56,27 +56,22 @@ static | ||
56 | int | 56 | int |
57 | testNew(void) | 57 | testNew(void) |
58 | { | 58 | { |
59 | - mock = new(MOCK_CLASS, 123); | 59 | + mock = new(MockClass, 123); |
60 | 60 | ||
61 | ASSERT_OBJECT_NOT_NULL(mock); | 61 | ASSERT_OBJECT_NOT_NULL(mock); |
62 | ASSERT_EQUAL(1, _called); | 62 | ASSERT_EQUAL(1, _called); |
63 | - ASSERT_EQUAL(123, mock_class_getValue(mock)); | 63 | + ASSERT_EQUAL(123, mock->value); |
64 | 64 | ||
65 | return TEST_OK; | 65 | return TEST_OK; |
66 | } | 66 | } |
67 | 67 | ||
68 | static | 68 | static |
69 | int | 69 | int |
70 | -testNewFromJson(void) | 70 | +testNewFail(void) |
71 | { | 71 | { |
72 | - struct json_object * json = json_object_new_int(123); | ||
73 | - | ||
74 | - mock = newFromJson(MOCK_CLASS, json); | ||
75 | - json_object_put(json); | 72 | + mock = new(MockClass, 321); |
76 | 73 | ||
77 | - ASSERT_OBJECT_NOT_NULL(mock); | ||
78 | - ASSERT_EQUAL(1, _called); | ||
79 | - ASSERT_EQUAL(123, mock_class_getValue(mock)); | 74 | + ASSERT_NULL(mock); |
80 | 75 | ||
81 | return TEST_OK; | 76 | return TEST_OK; |
82 | } | 77 | } |
@@ -85,12 +80,12 @@ static | @@ -85,12 +80,12 @@ static | ||
85 | int | 80 | int |
86 | testDelete(void) | 81 | testDelete(void) |
87 | { | 82 | { |
88 | - mock = new(MOCK_CLASS, 123); | 83 | + mock = new(MockClass, 123); |
89 | 84 | ||
90 | ASSERT_NOT_NULL(mock); | 85 | ASSERT_NOT_NULL(mock); |
91 | 86 | ||
92 | _reset(); | 87 | _reset(); |
93 | - delete(&mock); | 88 | + delete(mock); |
94 | 89 | ||
95 | ASSERT_NULL(mock); | 90 | ASSERT_NULL(mock); |
96 | ASSERT_EQUAL(1, _called); | 91 | ASSERT_EQUAL(1, _called); |
@@ -100,31 +95,26 @@ testDelete(void) | @@ -100,31 +95,26 @@ testDelete(void) | ||
100 | 95 | ||
101 | static | 96 | static |
102 | int | 97 | int |
103 | -testToJson(void) | 98 | +testClone(void) |
104 | { | 99 | { |
105 | - struct json_object * json = NULL; | ||
106 | - mock = new(MOCK_CLASS, 123); | ||
107 | - int value; | ||
108 | - | ||
109 | - _reset(); | ||
110 | - toJson(mock, &json); | 100 | + MockClass clone; |
111 | 101 | ||
112 | - ASSERT_NOT_NULL(json); | 102 | + mock = new(MockClass, 123); |
103 | + clone = clone(mock); | ||
113 | 104 | ||
114 | - value = json_object_get_int(json); | ||
115 | - json_object_put(json); | 105 | + ASSERT_INSTANCE_OF(MockClass, clone); |
106 | + ASSERT_EQUAL(mock->value, clone->value); | ||
116 | 107 | ||
117 | - ASSERT_EQUAL(123, value); | ||
118 | - ASSERT_EQUAL(1, _called); | 108 | + delete(clone); |
119 | 109 | ||
120 | return TEST_OK; | 110 | return TEST_OK; |
121 | } | 111 | } |
122 | 112 | ||
123 | const testfunc tests[] = { | 113 | const testfunc tests[] = { |
124 | testNew, | 114 | testNew, |
125 | - testNewFromJson, | 115 | + testNewFail, |
126 | testDelete, | 116 | testDelete, |
127 | - testToJson | 117 | + testClone |
128 | }; | 118 | }; |
129 | const size_t count = FUNCS_COUNT(tests); | 119 | const size_t count = FUNCS_COUNT(tests); |
130 | 120 |
@@ -21,73 +21,94 @@ | @@ -21,73 +21,94 @@ | ||
21 | #include <stdlib.h> | 21 | #include <stdlib.h> |
22 | 22 | ||
23 | #include "runtest.h" | 23 | #include "runtest.h" |
24 | -#include "cclass.h" | 24 | +#include "class.h" |
25 | #include "logger.h" | 25 | #include "logger.h" |
26 | +#include "mock/mock_logger.h" | ||
26 | 27 | ||
27 | 28 | ||
28 | -int level = -1; | ||
29 | -char * msg = NULL; | 29 | +const char testname[] = "loggerTest"; |
30 | +Logger logger = NULL; | ||
31 | + | ||
30 | 32 | ||
31 | -static void | ||
32 | -logfnct_mock(int _level, const char * _msg) | 33 | +static |
34 | +int | ||
35 | +__setUp() | ||
33 | { | 36 | { |
34 | - level = _level; | ||
35 | - msg = malloc(strlen(_msg) + 1); | ||
36 | - strcpy(msg, _msg); | 37 | + return TEST_OK; |
37 | } | 38 | } |
39 | +int (* const setUp)() = __setUp; | ||
38 | 40 | ||
39 | -const char testname[] = "loggerTest"; | ||
40 | -LOGGER logger = NULL; | 41 | +static |
42 | +int | ||
43 | +__tearDown() | ||
44 | +{ | ||
45 | + if (NULL != logger) { | ||
46 | + ASSERT_OBJECT(logger); | ||
47 | + delete(logger); | ||
48 | + } | ||
41 | 49 | ||
50 | + return TEST_OK; | ||
51 | +} | ||
52 | +int (* const tearDown)() = __tearDown; | ||
42 | 53 | ||
43 | static | 54 | static |
44 | int | 55 | int |
45 | -__setUp() | 56 | +testLoggerLevel() |
46 | { | 57 | { |
47 | - logger = new(LOGGER, NULL); | 58 | + logger = new(MockLogger, LOGGER_ERR); |
48 | 59 | ||
49 | - ASSERT_INSTANCE_OF(LOGGER, logger); | 60 | + ASSERT_INSTANCE_OF(MockLogger, logger); |
61 | + ASSERT_EQUAL(LOGGER_ERR, logger->min_level); | ||
50 | 62 | ||
51 | - logger_add(logger, logfnct_mock); | 63 | + loggerLog(logger, LOGGER_WARNING, "foo %d %s", 123, "bar"); |
64 | + | ||
65 | + ASSERT_STRING_EQUAL("", ((MockLogger)logger)->message); | ||
66 | + | ||
67 | + loggerLog(logger, LOGGER_ERR, "foo %d %s", 123, "bar"); | ||
68 | + ASSERT_STRING_EQUAL("[ERR] foo 123 bar", ((MockLogger)logger)->message); | ||
69 | + | ||
70 | + mockLoggerCleanMsg((MockLogger)logger); | ||
71 | + loggerLog(logger, LOGGER_CRIT, "foo %d %s", 123, "bar"); | ||
72 | + ASSERT_STRING_EQUAL("[CRIT] foo 123 bar", ((MockLogger)logger)->message); | ||
52 | 73 | ||
53 | return TEST_OK; | 74 | return TEST_OK; |
54 | } | 75 | } |
55 | -int (* const setUp)() = __setUp; | ||
56 | 76 | ||
57 | static | 77 | static |
58 | int | 78 | int |
59 | -__tearDown() | 79 | +testLoggerStderr() |
60 | { | 80 | { |
61 | - level = -1; | 81 | + logger = new(LoggerStderr, LOGGER_ERR); |
62 | 82 | ||
63 | - if (NULL != msg) { | ||
64 | - free(msg); | ||
65 | - msg = NULL; | ||
66 | - } | 83 | + freopen("/dev/null", "w", stderr); |
84 | + loggerLog(logger, LOGGER_ERR, "foo %d %s", 123, "bar"); | ||
67 | 85 | ||
68 | - if (NULL != logger) { | ||
69 | - ASSERT_OBJECT(logger); | ||
70 | - delete(&logger); | ||
71 | - } | 86 | + /** |
87 | + * \todo think about a way to assert something here | ||
88 | + */ | ||
72 | 89 | ||
73 | return TEST_OK; | 90 | return TEST_OK; |
74 | } | 91 | } |
75 | -int (* const tearDown)() = __tearDown; | ||
76 | 92 | ||
77 | static | 93 | static |
78 | int | 94 | int |
79 | -testLogger() | 95 | +testLoggerSyslog() |
80 | { | 96 | { |
81 | - logger_log(logger, LOGGER_ERR, "foo %d %s", 123, "bar"); | 97 | + logger = new(LoggerSyslog, LOGGER_ERR); |
98 | + | ||
99 | + loggerLog(logger, LOGGER_ERR, "foo %d %s", 123, "bar"); | ||
82 | 100 | ||
83 | - ASSERT_EQUAL(LOGGER_ERR, level); | ||
84 | - ASSERT_STRING_EQUAL("foo 123 bar", msg); | 101 | + /** |
102 | + * \todo think about a way to assert something here | ||
103 | + */ | ||
85 | 104 | ||
86 | return TEST_OK; | 105 | return TEST_OK; |
87 | } | 106 | } |
88 | 107 | ||
89 | const testfunc tests[] = { | 108 | const testfunc tests[] = { |
90 | - testLogger | 109 | + testLoggerLevel, |
110 | + testLoggerStderr, | ||
111 | + testLoggerSyslog | ||
91 | }; | 112 | }; |
92 | const size_t count = FUNCS_COUNT(tests); | 113 | const size_t count = FUNCS_COUNT(tests); |
93 | 114 |
@@ -18,71 +18,55 @@ | @@ -18,71 +18,55 @@ | ||
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <assert.h> | 20 | #include <assert.h> |
21 | -#include <json/json.h> | 21 | +#include <stdarg.h> |
22 | 22 | ||
23 | -#include "cclass.h" | ||
24 | #include "class.h" | 23 | #include "class.h" |
24 | +#include "mock_class.h" | ||
25 | 25 | ||
26 | char _called; | 26 | char _called; |
27 | 27 | ||
28 | -INIT_CLASS(MOCK_CLASS); | ||
29 | - | ||
30 | -__construct(MOCK_CLASS) | 28 | +void |
29 | +_reset() | ||
31 | { | 30 | { |
32 | - _called = 1; | ||
33 | - this->value = va_arg(* params, int); | 31 | + _called = 0; |
34 | } | 32 | } |
35 | 33 | ||
36 | -__jsonConst(MOCK_CLASS) | 34 | +static |
35 | +inline | ||
36 | +int | ||
37 | +mockCtor(void * _this, va_list * params) | ||
37 | { | 38 | { |
38 | - _called = 1; | ||
39 | - assert(json_type_int == json_object_get_type(json)); | 39 | + MockClass this = _this; |
40 | 40 | ||
41 | - this->value = json_object_get_int(json); | ||
42 | -} | 41 | + _called = 1; |
42 | + this->value = va_arg(* params, int); | ||
43 | 43 | ||
44 | -__clear(MOCK_CLASS) {} | 44 | + if (321 == this->value) |
45 | + return -1; | ||
45 | 46 | ||
46 | -__destruct(MOCK_CLASS) | ||
47 | -{ | ||
48 | - _called = 1; | 47 | + return 0; |
49 | } | 48 | } |
50 | 49 | ||
51 | -__toJson(MOCK_CLASS) | 50 | +static |
51 | +inline | ||
52 | +void | ||
53 | +mockDtor(void * _this) | ||
52 | { | 54 | { |
53 | - *json = json_object_new_int(this->value); | ||
54 | _called = 1; | 55 | _called = 1; |
55 | } | 56 | } |
56 | 57 | ||
57 | -/** | ||
58 | - * ~~~ method implementations ~~~~~~~~ | ||
59 | - */ | ||
60 | - | ||
61 | -int | ||
62 | -mock_class_getValue(MOCK_CLASS this) | ||
63 | -{ | ||
64 | - return this->value; | ||
65 | -} | ||
66 | - | 58 | +static |
59 | +inline | ||
67 | void | 60 | void |
68 | -mock_class_setValue(MOCK_CLASS this, int value) | 61 | +mockClone(void * _this, void * _base) |
69 | { | 62 | { |
70 | - this->value = value; | ||
71 | -} | 63 | + MockClass this = _this; |
64 | + MockClass base = _base; | ||
72 | 65 | ||
73 | -/** | ||
74 | - * ~~~ helper for mock assertions ~~~~~~~~ | ||
75 | - */ | ||
76 | -void * | ||
77 | -getConstruct() | ||
78 | -{ | ||
79 | - return __construct; | 66 | + this->value = base->value; |
80 | } | 67 | } |
81 | 68 | ||
82 | -void * | ||
83 | -getJsonConst() | ||
84 | -{ | ||
85 | - return __jsonConst; | ||
86 | -} | 69 | +INIT_IFACE(Class, mockCtor, mockDtor, mockClone); |
70 | +CREATE_CLASS(MockClass, NULL, IFACE(Class)); | ||
87 | 71 | ||
88 | // vim: set et ts=4 sw=4: | 72 | // vim: set et ts=4 sw=4: |
1 | /** | 1 | /** |
2 | * \file | 2 | * \file |
3 | * mock/class.h: definitions for my mock to test my oop stuff | 3 | * mock/class.h: definitions for my mock to test my oop stuff |
4 | + * | ||
5 | + * \author Georg Hopp <georg@steffers.org> | ||
6 | + * | ||
7 | + * \copyright | ||
4 | * Copyright (C) 2011 Georg Hopp | 8 | * Copyright (C) 2011 Georg Hopp |
5 | * | 9 | * |
6 | * This program is free software: you can redistribute it and/or modify | 10 | * This program is free software: you can redistribute it and/or modify |
@@ -16,25 +20,20 @@ | @@ -16,25 +20,20 @@ | ||
16 | * You should have received a copy of the GNU General Public License | 20 | * You should have received a copy of the GNU General Public License |
17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
18 | */ | 22 | */ |
19 | -#ifndef __MOCK_CLASS_H__ | ||
20 | -#define __MOCK_CLASS_H__ | 23 | +#ifndef __MOCK_MOCK_CLASS_H__ |
24 | +#define __MOCK_MOCK_CLASS_H__ | ||
21 | 25 | ||
22 | -#include "cclass.h" | 26 | +#include "class.h" |
23 | 27 | ||
24 | extern char _called; | 28 | extern char _called; |
25 | 29 | ||
26 | #ifndef _RESET | 30 | #ifndef _RESET |
27 | #define _RESET | 31 | #define _RESET |
28 | -void | ||
29 | -inline | ||
30 | -_reset() | ||
31 | -{ | ||
32 | - _called = 0; | ||
33 | -} | ||
34 | -#endif//_RESET | 32 | +void _reset(); |
33 | +#endif // _RESET | ||
35 | 34 | ||
36 | 35 | ||
37 | -CLASS(MOCK_CLASS) { | 36 | +CLASS(MockClass) { |
38 | int value; | 37 | int value; |
39 | }; | 38 | }; |
40 | 39 | ||
@@ -42,8 +41,9 @@ CLASS(MOCK_CLASS) { | @@ -42,8 +41,9 @@ CLASS(MOCK_CLASS) { | ||
42 | * ~~~ method declarations ~~~~~~~~ | 41 | * ~~~ method declarations ~~~~~~~~ |
43 | */ | 42 | */ |
44 | 43 | ||
45 | -int mock_class_getValue(MOCK_CLASS this); | ||
46 | -void mock_class_setValue(MOCK_CLASS this, int value); | 44 | +int mockClassGetValue(MockClass this); |
45 | +void mockClassSetValue(MockClass this, int value); | ||
46 | + | ||
47 | +#endif//__MOCK_MOCK_CLASS_H__ | ||
47 | 48 | ||
48 | -#endif//__MOCK_CLASS_H__ | ||
49 | // vim: set et ts=4 sw=4: | 49 | // vim: set et ts=4 sw=4: |
tests/mock/mock_logger.c
0 → 100644
1 | +#include <stdio.h> | ||
2 | + | ||
3 | +#include "class.h" | ||
4 | +#include "logger.h" | ||
5 | +#include "mock/mock_logger.h" | ||
6 | + | ||
7 | +static | ||
8 | +void | ||
9 | +logMock(void * _this, logger_level level, const char * const msg) | ||
10 | +{ | ||
11 | + MockLogger this = _this; | ||
12 | + | ||
13 | + snprintf(this->message, | ||
14 | + MOCK_MESSAGE_MAX - 1, | ||
15 | + "[%s] %s", | ||
16 | + logger_level_str[level], | ||
17 | + msg); | ||
18 | +} | ||
19 | + | ||
20 | +void | ||
21 | +mockLoggerCleanMsg(MockLogger this) | ||
22 | +{ | ||
23 | + this->message[0] = 0; | ||
24 | +} | ||
25 | + | ||
26 | +INIT_IFACE(Logger, logMock); | ||
27 | +CREATE_CLASS(MockLogger, Logger, IFACE(Logger)); | ||
28 | + | ||
29 | +// vim: set ts=4 sw=4: |
tests/mock/mock_logger.h
0 → 100644
1 | +#ifndef __MOCK_MOCK_LOGGER_H__ | ||
2 | +#define __MOCK_MOCK_LOGGER_H__ | ||
3 | + | ||
4 | +#define MOCK_MESSAGE_MAX 1024 | ||
5 | + | ||
6 | +#include "class.h" | ||
7 | +#include "logger.h" | ||
8 | + | ||
9 | +CLASS(MockLogger) | ||
10 | +{ | ||
11 | + EXTENDS(Logger); | ||
12 | + | ||
13 | + char message[MOCK_MESSAGE_MAX]; | ||
14 | +}; | ||
15 | + | ||
16 | +void mockLoggerCleanMsg(MockLogger); | ||
17 | + | ||
18 | +#endif // __MOCK_MOCK_LOGGER_H__ | ||
19 | + | ||
20 | +// vim: set ts=4 sw=4: |
tests/mock/mock_worker.c
0 → 100644
1 | +#include <stdarg.h> | ||
2 | +#include <stdlib.h> | ||
3 | +#include <unistd.h> | ||
4 | +#include <sys/types.h> | ||
5 | + | ||
6 | +#include "class.h" | ||
7 | +#include "stream.h" | ||
8 | +#include "mock_worker.h" | ||
9 | + | ||
10 | +static | ||
11 | +int | ||
12 | +mockWorkerCtor(void * _this, va_list * params) | ||
13 | +{ | ||
14 | + MockWorker this = _this; | ||
15 | + | ||
16 | + this->rbuf = &(this->_rbuf[0]); | ||
17 | + this->wbuf = &(this->_wbuf[0]); | ||
18 | + | ||
19 | + return 0; | ||
20 | +} | ||
21 | + | ||
22 | +static | ||
23 | +void | ||
24 | +mockWorkerDtor(void * _this) | ||
25 | +{ | ||
26 | +} | ||
27 | + | ||
28 | +static | ||
29 | +void | ||
30 | +mockWorkerClone(void * _this, void * _base) | ||
31 | +{ | ||
32 | + MockWorker this = _this; | ||
33 | + MockWorker base = _base; | ||
34 | + | ||
35 | + this->rbuf = &(base->_rbuf[0]); | ||
36 | + this->wbuf = &(base->_wbuf[0]); | ||
37 | +} | ||
38 | + | ||
39 | +static | ||
40 | +ssize_t | ||
41 | +mockWorkerRead(void * _this, Stream st) | ||
42 | +{ | ||
43 | + MockWorker this = _this; | ||
44 | + size_t size; | ||
45 | + | ||
46 | + size = read((st->handle).fd, this->rbuf, 1024); | ||
47 | + | ||
48 | + return size; | ||
49 | +} | ||
50 | + | ||
51 | +static | ||
52 | +ssize_t | ||
53 | +mockWorkerWrite(void * _this, Stream st) | ||
54 | +{ | ||
55 | + return 0; | ||
56 | +} | ||
57 | + | ||
58 | +INIT_IFACE(Class, mockWorkerCtor, mockWorkerDtor, mockWorkerClone); | ||
59 | +INIT_IFACE(StreamReader, mockWorkerRead); | ||
60 | +INIT_IFACE(StreamWriter, mockWorkerWrite); | ||
61 | +CREATE_CLASS( | ||
62 | + MockWorker, | ||
63 | + NULL, | ||
64 | + IFACE(Class), | ||
65 | + IFACE(StreamReader), | ||
66 | + IFACE(StreamWriter)); | ||
67 | + | ||
68 | +// vim: set ts=4 sw=4: |
tests/mock/mock_worker.h
0 → 100644
@@ -22,7 +22,7 @@ | @@ -22,7 +22,7 @@ | ||
22 | #include <sys/types.h> | 22 | #include <sys/types.h> |
23 | 23 | ||
24 | #include "runtest.h" | 24 | #include "runtest.h" |
25 | -#include "cclass.h" | 25 | +#include "class.h" |
26 | 26 | ||
27 | 27 | ||
28 | #define TEST_OK_CHAR '.' | 28 | #define TEST_OK_CHAR '.' |
@@ -37,15 +37,15 @@ const char results[3] = { | @@ -37,15 +37,15 @@ const char results[3] = { | ||
37 | }; | 37 | }; |
38 | 38 | ||
39 | int | 39 | int |
40 | -isObjectNull(void * _object) | 40 | +isObjectNull(void * object) |
41 | { | 41 | { |
42 | - const CCLASS * class = _object - sizeof(CCLASS); | 42 | + class_ptr class = GET_CLASS(object); |
43 | 43 | ||
44 | - if (! isObject(_object)) { | 44 | + if (! IS_OBJECT(object)) { |
45 | return 0; | 45 | return 0; |
46 | } | 46 | } |
47 | 47 | ||
48 | - return isMemNull(_object, (*class)->size); | 48 | + return isMemNull(object, class->object_size); |
49 | } | 49 | } |
50 | 50 | ||
51 | int | 51 | int |
1 | /** | 1 | /** |
2 | * \file | 2 | * \file |
3 | * runtest.h: assertions and other definitions for all my tests | 3 | * runtest.h: assertions and other definitions for all my tests |
4 | + * | ||
5 | + * \author Georg Hopp <georg@steffers.org> | ||
6 | + * | ||
7 | + * \copyright | ||
4 | * Copyright (C) 2011 Georg Hopp | 8 | * Copyright (C) 2011 Georg Hopp |
5 | * | 9 | * |
6 | * This program is free software: you can redistribute it and/or modify | 10 | * This program is free software: you can redistribute it and/or modify |
@@ -22,6 +26,7 @@ | @@ -22,6 +26,7 @@ | ||
22 | #include <sys/types.h> | 26 | #include <sys/types.h> |
23 | #include <string.h> | 27 | #include <string.h> |
24 | 28 | ||
29 | +#include "class.h" | ||
25 | 30 | ||
26 | enum RESULT_TYPES { | 31 | enum RESULT_TYPES { |
27 | TEST_OK=0, | 32 | TEST_OK=0, |
@@ -90,7 +95,7 @@ enum RESULT_TYPES { | @@ -90,7 +95,7 @@ enum RESULT_TYPES { | ||
90 | return TEST_FAILED; } | 95 | return TEST_FAILED; } |
91 | 96 | ||
92 | #define ASSERT_OBJECT(val) \ | 97 | #define ASSERT_OBJECT(val) \ |
93 | - if (! isObject((val))) { \ | 98 | + if (! IS_OBJECT((val))) { \ |
94 | printf("%s[%d]: Assertion failed that %s IS an object\n", \ | 99 | printf("%s[%d]: Assertion failed that %s IS an object\n", \ |
95 | __FILE__, __LINE__, #val); \ | 100 | __FILE__, __LINE__, #val); \ |
96 | return TEST_FAILED; } | 101 | return TEST_FAILED; } |
@@ -108,7 +113,7 @@ enum RESULT_TYPES { | @@ -108,7 +113,7 @@ enum RESULT_TYPES { | ||
108 | return TEST_FAILED; } | 113 | return TEST_FAILED; } |
109 | 114 | ||
110 | #define ASSERT_INSTANCE_OF(class, val) \ | 115 | #define ASSERT_INSTANCE_OF(class, val) \ |
111 | - if (! instanceOf(class, val)) { \ | 116 | + if (! INSTANCE_OF(class, val)) { \ |
112 | printf("%s[%d]: Assertion failed that %s is instance of %s\n", \ | 117 | printf("%s[%d]: Assertion failed that %s is instance of %s\n", \ |
113 | __FILE__, __LINE__, #val, #class); \ | 118 | __FILE__, __LINE__, #val, #class); \ |
114 | return TEST_FAILED; } | 119 | return TEST_FAILED; } |
@@ -3,61 +3,44 @@ | @@ -3,61 +3,44 @@ | ||
3 | #include <unistd.h> | 3 | #include <unistd.h> |
4 | #include <signal.h> | 4 | #include <signal.h> |
5 | #include <socket.h> | 5 | #include <socket.h> |
6 | +#include <sys/types.h> | ||
6 | 7 | ||
7 | #include "runtest.h" | 8 | #include "runtest.h" |
8 | #include "logger.h" | 9 | #include "logger.h" |
9 | -#include "cclass.h" | 10 | +#include "class.h" |
10 | #include "server.h" | 11 | #include "server.h" |
11 | -#include "signalHandling.h" | 12 | +#include "utils/signalHandling.h" |
13 | +#include "mock/mock_logger.h" | ||
14 | +#include "mock/mock_worker.h" | ||
12 | 15 | ||
13 | 16 | ||
14 | #define TEST_PORT 11212 | 17 | #define TEST_PORT 11212 |
15 | #define TEST_DATA "test" | 18 | #define TEST_DATA "test" |
16 | 19 | ||
17 | 20 | ||
18 | -int level = -1; | ||
19 | -char msg[1024]; | ||
20 | char buffer[1025]; | 21 | char buffer[1025]; |
21 | 22 | ||
22 | -static void | ||
23 | -read_hook(const char * _buffer, size_t size) | ||
24 | -{ | ||
25 | - memset(buffer, 0, 1025); | ||
26 | - | ||
27 | - if (NULL != _buffer) { | ||
28 | - strncpy(buffer, _buffer, 1024>size? size : 1024); | ||
29 | - } | ||
30 | - | ||
31 | - doShutdown = 1; | ||
32 | -} | ||
33 | - | ||
34 | -static void | ||
35 | -logfnct_mock(int _level, const char * _msg) | ||
36 | -{ | ||
37 | - level = _level; | ||
38 | - strncpy(msg, _msg, 1023); | ||
39 | -} | ||
40 | - | ||
41 | const char testname[] = "serverTest"; | 23 | const char testname[] = "serverTest"; |
42 | -LOGGER logger = NULL; | ||
43 | -SERVER server = NULL; | 24 | + |
25 | +MockLogger logger = NULL; | ||
26 | +MockWorker worker = NULL; | ||
27 | +Server server = NULL; | ||
44 | 28 | ||
45 | static | 29 | static |
46 | int | 30 | int |
47 | __setUp() | 31 | __setUp() |
48 | { | 32 | { |
49 | - logger = new(LOGGER, NULL); | ||
50 | - logger_add(logger, logfnct_mock); | 33 | + logger = new(MockLogger, LOGGER_DEBUG); |
34 | + worker = new(MockWorker); | ||
51 | 35 | ||
52 | - server = new(SERVER, logger, TEST_PORT, SOMAXCONN); | 36 | + server = new(Server, logger, worker, TEST_PORT, SOMAXCONN); |
53 | 37 | ||
54 | - ASSERT_INSTANCE_OF(SERVER, server); | ||
55 | - ASSERT_INSTANCE_OF(LOGGER, server->logger); | ||
56 | - ASSERT_INSTANCE_OF(SOCK, server->sock); | 38 | + ASSERT_INSTANCE_OF(Server, server); |
39 | + ASSERT_INSTANCE_OF(MockLogger, server->logger); | ||
40 | + ASSERT_INSTANCE_OF(MockWorker, server->worker); | ||
41 | + ASSERT_INSTANCE_OF(Sock, server->sock); | ||
57 | ASSERT_EQUAL(TEST_PORT, server->sock->port); | 42 | ASSERT_EQUAL(TEST_PORT, server->sock->port); |
58 | 43 | ||
59 | - server->read_hook = read_hook; | ||
60 | - | ||
61 | return TEST_OK; | 44 | return TEST_OK; |
62 | } | 45 | } |
63 | int (* const setUp)() = __setUp; | 46 | int (* const setUp)() = __setUp; |
@@ -66,16 +49,19 @@ static | @@ -66,16 +49,19 @@ static | ||
66 | int | 49 | int |
67 | __tearDown() | 50 | __tearDown() |
68 | { | 51 | { |
69 | - level = -1; | ||
70 | - | ||
71 | if (NULL != server) { | 52 | if (NULL != server) { |
72 | ASSERT_OBJECT(server); | 53 | ASSERT_OBJECT(server); |
73 | - delete(&server); | 54 | + delete(server); |
55 | + } | ||
56 | + | ||
57 | + if (NULL != worker) { | ||
58 | + ASSERT_OBJECT(worker); | ||
59 | + delete(worker); | ||
74 | } | 60 | } |
75 | 61 | ||
76 | if (NULL != logger) { | 62 | if (NULL != logger) { |
77 | ASSERT_OBJECT(logger); | 63 | ASSERT_OBJECT(logger); |
78 | - delete(&logger); | 64 | + delete(logger); |
79 | } | 65 | } |
80 | 66 | ||
81 | return TEST_OK; | 67 | return TEST_OK; |
@@ -86,19 +72,23 @@ static | @@ -86,19 +72,23 @@ static | ||
86 | int | 72 | int |
87 | testDummy() | 73 | testDummy() |
88 | { | 74 | { |
89 | - SOCK con; | ||
90 | - pid_t pid; | 75 | + Sock con; |
76 | + pid_t pid, ppid; | ||
77 | + char addr[16]; | ||
91 | 78 | ||
92 | - pid = fork(); | 79 | + ppid = getpid(); |
80 | + pid = fork(); | ||
93 | 81 | ||
94 | switch(pid) { | 82 | switch(pid) { |
95 | case 0: | 83 | case 0: |
96 | - con = new(SOCK, logger, TEST_PORT); | 84 | + con = new(Sock, logger, TEST_PORT); |
97 | sleep(1); | 85 | sleep(1); |
98 | - sock_connect(con, "127.0.0.1"); | 86 | + socketConnect(con, "127.0.0.1", &addr); |
99 | write(con->handle, TEST_DATA, strlen(TEST_DATA)+1); | 87 | write(con->handle, TEST_DATA, strlen(TEST_DATA)+1); |
100 | - delete(&con); | 88 | + sleep(1); |
89 | + delete(con); | ||
101 | __tearDown(); | 90 | __tearDown(); |
91 | + kill(ppid, SIGINT); | ||
102 | exit(EXIT_SUCCESS); | 92 | exit(EXIT_SUCCESS); |
103 | 93 | ||
104 | case -1: | 94 | case -1: |
@@ -106,10 +96,10 @@ testDummy() | @@ -106,10 +96,10 @@ testDummy() | ||
106 | 96 | ||
107 | default: | 97 | default: |
108 | init_signals(); | 98 | init_signals(); |
109 | - server_run(server); | 99 | + serverRun(server); |
110 | } | 100 | } |
111 | 101 | ||
112 | - ASSERT_STRING_EQUAL(TEST_DATA, buffer); | 102 | + ASSERT_STRING_EQUAL(TEST_DATA, worker->rbuf); |
113 | 103 | ||
114 | return TEST_OK; | 104 | return TEST_OK; |
115 | } | 105 | } |
@@ -3,40 +3,30 @@ | @@ -3,40 +3,30 @@ | ||
3 | #include <unistd.h> | 3 | #include <unistd.h> |
4 | 4 | ||
5 | #include "runtest.h" | 5 | #include "runtest.h" |
6 | -#include "logger.h" | ||
7 | -#include "cclass.h" | 6 | +#include "class.h" |
8 | #include "socket.h" | 7 | #include "socket.h" |
8 | +#include "logger.h" | ||
9 | +#include "mock/mock_logger.h" | ||
9 | 10 | ||
10 | 11 | ||
11 | #define TEST_PORT 11212 | 12 | #define TEST_PORT 11212 |
12 | 13 | ||
13 | 14 | ||
14 | -int level = -1; | ||
15 | -char * msg = NULL; | ||
16 | - | ||
17 | -static void | ||
18 | -logfnct_mock(int _level, const char * _msg) | ||
19 | -{ | ||
20 | - level = _level; | ||
21 | - msg = malloc(strlen(_msg) + 1); | ||
22 | - strcpy(msg, _msg); | ||
23 | -} | ||
24 | - | ||
25 | const char testname[] = "socketTest"; | 15 | const char testname[] = "socketTest"; |
26 | -LOGGER logger = NULL; | ||
27 | -SOCK sock = NULL; | 16 | + |
17 | +MockLogger logger = NULL; | ||
18 | +Sock sock = NULL; | ||
28 | 19 | ||
29 | static | 20 | static |
30 | int | 21 | int |
31 | __setUp() | 22 | __setUp() |
32 | { | 23 | { |
33 | - logger = new(LOGGER, NULL); | ||
34 | - logger_add(logger, logfnct_mock); | 24 | + logger = new(MockLogger, LOGGER_DEBUG); |
35 | 25 | ||
36 | - sock = new(SOCK, logger, TEST_PORT); | 26 | + sock = new(Sock, logger, TEST_PORT); |
37 | 27 | ||
38 | - ASSERT_INSTANCE_OF(SOCK, sock); | ||
39 | - ASSERT_INSTANCE_OF(LOGGER, sock->logger); | 28 | + ASSERT_INSTANCE_OF(Sock, sock); |
29 | + ASSERT_INSTANCE_OF(MockLogger, sock->log); | ||
40 | ASSERT_EQUAL(TEST_PORT, sock->port); | 30 | ASSERT_EQUAL(TEST_PORT, sock->port); |
41 | ASSERT_NOT_EQUAL(0, sock->handle); | 31 | ASSERT_NOT_EQUAL(0, sock->handle); |
42 | 32 | ||
@@ -48,21 +38,14 @@ static | @@ -48,21 +38,14 @@ static | ||
48 | int | 38 | int |
49 | __tearDown() | 39 | __tearDown() |
50 | { | 40 | { |
51 | - level = -1; | ||
52 | - | ||
53 | - if (NULL != msg) { | ||
54 | - free(msg); | ||
55 | - msg = NULL; | ||
56 | - } | ||
57 | - | ||
58 | if (NULL != logger) { | 41 | if (NULL != logger) { |
59 | ASSERT_OBJECT(logger); | 42 | ASSERT_OBJECT(logger); |
60 | - delete(&logger); | 43 | + delete(logger); |
61 | } | 44 | } |
62 | 45 | ||
63 | if (NULL != sock) { | 46 | if (NULL != sock) { |
64 | ASSERT_OBJECT(sock); | 47 | ASSERT_OBJECT(sock); |
65 | - delete(&sock); | 48 | + delete(sock); |
66 | } | 49 | } |
67 | 50 | ||
68 | return TEST_OK; | 51 | return TEST_OK; |
@@ -73,29 +56,29 @@ static | @@ -73,29 +56,29 @@ static | ||
73 | int | 56 | int |
74 | testListen() | 57 | testListen() |
75 | { | 58 | { |
76 | - sock_listen(sock, 10); | 59 | + socketListen(sock, 10); |
77 | 60 | ||
78 | return TEST_OK; | 61 | return TEST_OK; |
79 | } | 62 | } |
80 | 63 | ||
81 | static | 64 | static |
82 | int | 65 | int |
83 | -testAccept() | 66 | +testAcceptConnect() |
84 | { | 67 | { |
85 | - SOCK acc, con; | 68 | + Sock acc, con; |
86 | char addr[16]; | 69 | char addr[16]; |
87 | pid_t pid; | 70 | pid_t pid; |
88 | 71 | ||
89 | - sock_listen(sock, 10); | 72 | + socketListen(sock, 10); |
90 | 73 | ||
91 | pid = fork(); | 74 | pid = fork(); |
92 | 75 | ||
93 | switch(pid) { | 76 | switch(pid) { |
94 | case 0: | 77 | case 0: |
95 | - con = new(SOCK, logger, TEST_PORT); | 78 | + con = new(Sock, logger, TEST_PORT); |
96 | sleep(1); | 79 | sleep(1); |
97 | - sock_connect(con, "127.0.0.1"); | ||
98 | - delete(&con); | 80 | + socketConnect(con, "127.0.0.1", &addr); |
81 | + delete(con); | ||
99 | __tearDown(); | 82 | __tearDown(); |
100 | exit(EXIT_SUCCESS); | 83 | exit(EXIT_SUCCESS); |
101 | 84 | ||
@@ -103,12 +86,12 @@ testAccept() | @@ -103,12 +86,12 @@ testAccept() | ||
103 | return TEST_FAILED; | 86 | return TEST_FAILED; |
104 | 87 | ||
105 | default: | 88 | default: |
106 | - acc = sock_accept(sock, addr); | 89 | + acc = socketAccept(sock, &addr); |
107 | } | 90 | } |
108 | 91 | ||
109 | if (NULL != acc) { | 92 | if (NULL != acc) { |
110 | ASSERT_OBJECT(acc); | 93 | ASSERT_OBJECT(acc); |
111 | - delete(&acc); | 94 | + delete(acc); |
112 | } | 95 | } |
113 | 96 | ||
114 | return TEST_OK; | 97 | return TEST_OK; |
@@ -116,7 +99,7 @@ testAccept() | @@ -116,7 +99,7 @@ testAccept() | ||
116 | 99 | ||
117 | const testfunc tests[] = { | 100 | const testfunc tests[] = { |
118 | testListen, | 101 | testListen, |
119 | - testAccept | 102 | + testAcceptConnect |
120 | }; | 103 | }; |
121 | const size_t count = FUNCS_COUNT(tests); | 104 | const size_t count = FUNCS_COUNT(tests); |
122 | 105 |
Please
register
or
login
to post a comment