Commit db197db18288fb98577acec549a6fcd14415925b
1 parent
25f6a1f9
Now all classes are moved in according archives. Coming closer to the original p…
…urpose of the class construct to build small independent reusable code fragments.
Showing
21 changed files
with
120 additions
and
80 deletions
@@ -53,5 +53,9 @@ AC_CONFIG_FILES([Makefile | @@ -53,5 +53,9 @@ AC_CONFIG_FILES([Makefile | ||
53 | src/hash/Makefile | 53 | src/hash/Makefile |
54 | src/http/Makefile | 54 | src/http/Makefile |
55 | src/logger/Makefile | 55 | src/logger/Makefile |
56 | + src/server/Makefile | ||
57 | + src/session/Makefile | ||
58 | + src/socket/Makefile | ||
59 | + src/stream/Makefile | ||
56 | tests/Makefile]) | 60 | tests/Makefile]) |
57 | AC_OUTPUT | 61 | AC_OUTPUT |
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_H__ | 1 | #ifndef __STREAM_H__ |
24 | #define __STREAM_H__ | 2 | #define __STREAM_H__ |
25 | 3 | ||
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); | 4 | +#include "stream/stream.h" |
5 | +#include "stream/interface/reader.h" | ||
6 | +#include "stream/interface/writer.h" | ||
46 | 7 | ||
47 | #endif // __STREAM_H__ | 8 | #endif // __STREAM_H__ |
48 | 9 |
@@ -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: |
@@ -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: |
1 | ACLOCAL_AMFLAGS = -I m4 | 1 | ACLOCAL_AMFLAGS = -I m4 |
2 | 2 | ||
3 | -IFACE = interface/stream_reader.c \ | ||
4 | - interface/stream_writer.c \ | ||
5 | - interface/subject.c interface/observer.c | ||
6 | -SOCKET = socket.c socket/accept.c socket/connect.c socket/listen.c | ||
7 | -STREAM = stream.c stream/read.c stream/write.c | ||
8 | -SERVER = server.c server/run.c server/close_conn.c server/poll.c \ | ||
9 | - server/handle_accept.c server/read.c server/write.c | ||
10 | -SESSION = session.c session/add.c session/get.c session/delete.c | ||
11 | -UTILS = utils/hash.c \ | ||
12 | - utils/memory.c \ | ||
13 | - utils/http.c \ | ||
14 | - utils/daemonize.c \ | ||
15 | - utils/signalHandling.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 | ||
16 | 10 | ||
17 | LIBS = ./http/libhttp.a \ | 11 | LIBS = ./http/libhttp.a \ |
18 | ./auth/libauth.a \ | 12 | ./auth/libauth.a \ |
19 | ./cbuf/libcbuf.a \ | 13 | ./cbuf/libcbuf.a \ |
20 | ./class/libclass.a \ | 14 | ./class/libclass.a \ |
21 | ./hash/libhash.a \ | 15 | ./hash/libhash.a \ |
22 | - ./logger/liblogger.a | 16 | + ./logger/liblogger.a \ |
17 | + ./server/libserver.a \ | ||
18 | + ./session/libsession.a \ | ||
19 | + ./socket/libsocket.a \ | ||
20 | + ./stream/libstream.a | ||
23 | 21 | ||
24 | AM_CFLAGS = -Wall -I ../include/ | 22 | AM_CFLAGS = -Wall -I ../include/ |
25 | 23 | ||
26 | bin_PROGRAMS = taskrambler | 24 | bin_PROGRAMS = taskrambler |
27 | 25 | ||
28 | -taskrambler_SOURCES = taskrambler.c \ | ||
29 | - $(IFACE) $(SOCKET) $(SERVER) \ | ||
30 | - $(UTILS) $(SESSION) $(STREAM) | 26 | +taskrambler_SOURCES = taskrambler.c $(IFACE) $(UTILS) |
31 | taskrambler_CFLAGS = -Wall -I ../include/ $(COVERAGE_CFLAGS) | 27 | taskrambler_CFLAGS = -Wall -I ../include/ $(COVERAGE_CFLAGS) |
32 | taskrambler_LDADD = $(LIBS) -lrt -lssl -lldap | 28 | taskrambler_LDADD = $(LIBS) -lrt -lssl -lldap |
33 | taskrambler_LDFLAGS = $(COVERAGE_LDFLAGS) | 29 | taskrambler_LDFLAGS = $(COVERAGE_LDFLAGS) |
34 | 30 | ||
35 | -SUBDIRS = auth cbuf class hash http logger | 31 | +SUBDIRS = auth cbuf class hash http logger server session socket stream |
@@ -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/stream_reader.h" | 28 | +#include "stream.h" |
29 | 29 | ||
30 | #include "http/parser.h" | 30 | #include "http/parser.h" |
31 | #include "http/message/queue.h" | 31 | #include "http/message/queue.h" |
@@ -34,9 +34,6 @@ | @@ -34,9 +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/stream_reader.h" | ||
38 | -#include "interface/stream_writer.h" | ||
39 | - | ||
40 | #include "utils/memory.h" | 37 | #include "utils/memory.h" |
41 | 38 | ||
42 | static | 39 | static |
@@ -23,7 +23,7 @@ | @@ -23,7 +23,7 @@ | ||
23 | #include <stdarg.h> | 23 | #include <stdarg.h> |
24 | 24 | ||
25 | #include "class.h" | 25 | #include "class.h" |
26 | -#include "interface/stream_writer.h" | 26 | +#include "stream.h" |
27 | 27 | ||
28 | #include "http/message/queue.h" | 28 | #include "http/message/queue.h" |
29 | #include "http/writer.h" | 29 | #include "http/writer.h" |
src/server/Makefile.am
0 → 100644
@@ -22,7 +22,7 @@ | @@ -22,7 +22,7 @@ | ||
22 | 22 | ||
23 | #include "server.h" | 23 | #include "server.h" |
24 | #include "logger.h" | 24 | #include "logger.h" |
25 | -#include "interface/stream_reader.h" | 25 | +#include "stream.h" |
26 | 26 | ||
27 | void serverCloseConn(Server, unsigned int); | 27 | void serverCloseConn(Server, unsigned int); |
28 | 28 |
@@ -22,7 +22,7 @@ | @@ -22,7 +22,7 @@ | ||
22 | 22 | ||
23 | #include "server.h" | 23 | #include "server.h" |
24 | #include "logger.h" | 24 | #include "logger.h" |
25 | -#include "interface/stream_writer.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
src/socket/Makefile.am
0 → 100644
src/stream/Makefile.am
0 → 100644
@@ -21,8 +21,9 @@ | @@ -21,8 +21,9 @@ | ||
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include "class.h" | 23 | #include "class.h" |
24 | -#include "stream.h" | ||
25 | -#include "interface/stream_reader.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", |
@@ -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", |
Please
register
or
login
to post a comment