Commit 01dc476775bc7d8c2e457ec92a72a0dc7d9fc2fd

Authored by Georg Hopp
1 parent 562407c8

utilize libtrdata

Showing 100 changed files with 259 additions and 1984 deletions

Too many changes to show.

To preserve performance only 100 of 100+ files are displayed.

... ... @@ -89,13 +89,9 @@ AC_CONFIG_FILES([Makefile
89 89 src/Makefile
90 90 src/asset/Makefile
91 91 src/auth/Makefile
92   - src/cbuf/Makefile
93   - src/hash/Makefile
94   - src/queue/Makefile
95 92 src/http/Makefile
96 93 src/server/Makefile
97 94 src/session/Makefile
98   - src/tree/Makefile
99 95 src/application/Makefile
100 96 src/storage/Makefile
101 97 src/user/Makefile
... ...
... ... @@ -25,11 +25,11 @@
25 25
26 26 #include <sys/types.h>
27 27
28   -#include <trbase.h>
29   -#include <trhash.h>
  28 +#include "trbase.h"
  29 +#include "trhash.h"
  30 +#include "trdata.h"
30 31
31 32 #include "session.h"
32   -#include "hash.h"
33 33 #include "auth.h"
34 34 #include "auth/credential.h"
35 35 #include "storage/storage.h"
... ... @@ -43,24 +43,24 @@ struct randval {
43 43 };
44 44
45 45 TR_CLASS(Application) {
46   - Hash * active_sessions;
  46 + TR_Hash * active_sessions;
47 47 time_t session_time_ofs;
48 48
49 49 Auth auth;
50 50
51   - struct randval * val;
  51 + struct randval * val;
52 52
53   - Storage users;
54   - Storage passwords;
55   - Storage roles;
  53 + Storage users;
  54 + Storage passwords;
  55 + Storage roles;
56 56
57   - TR_Uuid user_namespace;
  57 + TR_Uuid user_namespace;
58 58
59   - Hash roles_user_index;
60   - Hash roles_resource_index;
  59 + TR_Hash roles_user_index;
  60 + TR_Hash roles_resource_index;
61 61
62   - const char * version;
63   - const char * loc;
  62 + const char * version;
  63 + const char * loc;
64 64 };
65 65
66 66 int applicationLogin(Application, Credential, Session);
... ...
... ... @@ -27,7 +27,6 @@
27 27 #include <sys/types.h>
28 28
29 29 #include "trbase.h"
30   -#include "hash.h"
31 30
32 31
33 32 TR_CLASS(Asset) {
... ...
1   -/**
2   - * \file
3   - * My implementation of a ringbuffer.
4   - * It maps a shared memory object twice directly following
5   - * thus make it possible to read and write from any
6   - * position within the buffer without the nasty wrap
7   - * calculations.
8   - * This is achived because the same memory region is mapped
9   - * at the two addresses.
10   - *
11   - * \author Georg Hopp
12   - *
13   - * \copyright
14   - * Copyright © 2012 Georg Hopp
15   - *
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
18   - * the Free Software Foundation, either version 3 of the License, or
19   - * (at your option) any later version.
20   - *
21   - * This program is distributed in the hope that it will be useful,
22   - * but WITHOUT ANY WARRANTY; without even the implied warranty of
23   - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24   - * GNU General Public License for more details.
25   - *
26   - * You should have received a copy of the GNU General Public License
27   - * along with this program. If not, see <http://www.gnu.org/licenses/>.
28   - */
29   -
30   -#ifndef __CBUF_H__
31   -#define __CBUF_H__
32   -
33   -#include <ctype.h>
34   -#include <string.h>
35   -#include <sys/types.h>
36   -
37   -#include "trbase.h"
38   -#include "trio.h"
39   -
40   -#define ECBUFOVFL 100
41   -
42   -
43   -TR_CLASS(Cbuf) {
44   - char * shm_name; // shared memory identifier
45   -
46   - char * data;
47   - Bool lock;
48   -
49   - size_t bsize;
50   - size_t bused;
51   -
52   - size_t write;
53   - size_t read;
54   -};
55   -
56   -ssize_t cbufRead(Cbuf, TR_Stream);
57   -ssize_t cbufWrite(Cbuf, TR_Stream);
58   -
59   -char * cbufGetLine(Cbuf, char **);
60   -char * cbufGetData(Cbuf, size_t);
61   -char * cbufSetData(Cbuf, const void *, size_t);
62   -void cbufEmpty(Cbuf);
63   -
64   -char * cbufGetRead(Cbuf this);
65   -char * cbufGetWrite(Cbuf this);
66   -char * cbufMemchr(Cbuf this, int c);
67   -size_t cbufAddrIndex(Cbuf this, const void * c);
68   -void cbufIncRead(Cbuf this, size_t n);
69   -void cbufIncWrite(Cbuf this, size_t n);
70   -size_t cbufGetFree(Cbuf this);
71   -char cbufIsEmpty(Cbuf this);
72   -void cbufSkipNonAlpha(Cbuf this);
73   -Bool cbufIsLocked(Cbuf this);
74   -void cbufLock(Cbuf this);
75   -void cbufRelease(Cbuf this);
76   -
77   -#endif // __CBUF_H__
78   -
79   -// vim: set ts=4 sw=4:
... ... @@ -24,15 +24,15 @@
24 24 #define __CONFIG_H__
25 25
26 26 #include "trbase.h"
27   -#include "hash.h"
  27 +#include "trdata.h"
28 28 #include "config/value.h"
29 29
30 30 #define MAX_CONFIG_LINE 256
31 31
32 32
33 33 TR_CLASS(Config) {
34   - char * cnf_file;
35   - Hash config;
  34 + char * cnf_file;
  35 + TR_Hash config;
36 36 };
37 37
38 38 ConfigValue configGet(Config, const char *, size_t);
... ...
... ... @@ -26,7 +26,6 @@
26 26 #include <sys/types.h>
27 27
28 28 #include "trbase.h"
29   -#include "hash.h"
30 29
31 30 #define MAX_CONFIG_LINE 256
32 31
... ...
1   -#ifndef __HASH_H__
2   -#define __HASH_H__
3   -
4   -#include "hash/hash.h"
5   -#include "hash/value.h"
6   -#include "hash/interface/hashable.h"
7   -
8   -#endif // __HASH_H__
9   -
10   -// 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   -
23   -#ifndef __HASH_HASH_H__
24   -#define __HASH_HASH_H__
25   -
26   -#include <sys/types.h>
27   -
28   -#include "trbase.h"
29   -#include "tree.h"
30   -
31   -#define HASH_IS_EMPTY(h) ((h)->root)
32   -
33   -TR_CLASS(Hash) {
34   - Tree root;
35   -};
36   -
37   -void * hashAdd(Hash, void *);
38   -void * hashDelete(Hash, const char *, size_t);
39   -void * hashGet(Hash, const char *, size_t);
40   -void * hashGetFirst(Hash);
41   -void * hashDeleteByVal(Hash, unsigned long);
42   -void * hashGetByVal(Hash, unsigned long);
43   -void hashEach(Hash, void (*)(const void*));
44   -void hashCleanup(Hash);
45   -
46   -#endif // __HASH_HASH_H__
47   -
48   -// vim: set ts=4 sw=4:
1   -/**
2   - * \file
3   - * The logger interface.
4   - *
5   - * \author Georg Hopp
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   -
24   -#ifndef __HASH_INTERFACE_HASHABLE_H__
25   -#define __HASH_INTERFACE_HASHABLE_H__
26   -
27   -#include "trbase.h"
28   -
29   -typedef unsigned long (* fptr_hashableGetHash)(void *);
30   -typedef void (* fptr_hashableHandleDouble)(void *, void *);
31   -
32   -TR_INTERFACE(Hashable) {
33   - TR_IFID;
34   - fptr_hashableGetHash getHash;
35   - fptr_hashableHandleDouble handleDouble;
36   -};
37   -
38   -extern unsigned long hashableGetHash(void *);
39   -extern void hashableHandleDouble(void *, void *);
40   -
41   -#endif // __HASH_INTERFACE_HASHABLE_H__
42   -
43   -// 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   -
23   -#ifndef __HASH_VALUE_H__
24   -#define __HASH_VALUE_H__
25   -
26   -#include <sys/types.h>
27   -
28   -#include "trbase.h"
29   -
30   -TR_CLASS(HashValue) {
31   - unsigned long hash;
32   -
33   - char * key;
34   - void * value;
35   -
36   - size_t nkey;
37   - size_t nvalue;
38   -};
39   -
40   -#endif // __HASH_VALUE_H__
41   -
42   -// vim: set ts=4 sw=4:
... ... @@ -25,20 +25,19 @@
25 25 #define __HTTP_MESSAGE__
26 26
27 27 #include "trbase.h"
28   -#include "trio.h"
29   -#include "hash.h"
  28 +#include "trdata.h"
30 29 #include "asset.h"
31 30
32 31 TR_CLASS(HttpMessage) {
33   - char * version;
  32 + char * version;
34 33
35   - Hash header;
  34 + TR_Hash header;
36 35
37   - Asset asset;
38   - char * body;
  36 + Asset asset;
  37 + char * body;
39 38
40   - int nbody;
41   - int dbody;
  39 + int nbody;
  40 + int dbody;
42 41 };
43 42
44 43 char httpMessageHasKeepAlive(HttpMessage);
... ...
... ... @@ -26,9 +26,8 @@
26 26
27 27 #include "trbase.h"
28 28 #include "trio.h"
  29 +#include "trdata.h"
29 30 #include "http/message.h"
30   -#include "queue.h"
31   -#include "cbuf.h"
32 31
33 32
34 33 #define PARSER_MAX_BUF 131072
... ... @@ -44,13 +43,13 @@ typedef enum e_HttpMessageState {
44 43
45 44
46 45 TR_CLASS(HttpParser) {
47   - Cbuf buffer;
  46 + TR_Cbuf buffer;
48 47 Bool ourLock;
49 48
50 49 char * incomplete;
51 50 size_t isize;
52 51
53   - Queue queue;
  52 + TR_Queue queue;
54 53 HttpMessage current;
55 54
56 55 HttpMessageState state;
... ...
... ... @@ -25,8 +25,8 @@
25 25 #define __HTTP_REQUEST_H__
26 26
27 27 #include "trbase.h"
  28 +#include "trdata.h"
28 29 #include "http/message.h"
29   -#include "hash.h"
30 30
31 31 #define N_HTTP_METHOD 8
32 32
... ... @@ -52,9 +52,9 @@ TR_CLASS(HttpRequest) {
52 52
53 53 HttpMethod method_id;
54 54
55   - Hash get;
56   - Hash post;
57   - Hash cookies;
  55 + TR_Hash get;
  56 + TR_Hash post;
  57 + TR_Hash cookies;
58 58 };
59 59
60 60 HttpMethod httpRequestGetMethodId(HttpRequest);
... ...
... ... @@ -28,32 +28,30 @@
28 28 #include <time.h>
29 29
30 30 #include "trbase.h"
31   -#include "hash.h"
  31 +#include "trdata.h"
32 32 #include "http/parser.h"
33 33 #include "http/writer.h"
34   -#include "cbuf.h"
35 34 #include "session.h"
36 35
37 36 #include "http/request.h"
38 37 #include "http/response.h"
39   -#include "queue.h"
40 38
41 39
42 40 TR_CLASS(HttpWorker) {
43   - char * id;
  41 + char * id;
44 42
45   - Cbuf pbuf;
46   - Hash asset_pool;
  43 + TR_Cbuf pbuf;
  44 + TR_Hash asset_pool;
47 45
48   - void * application_adapter;
  46 + void * application_adapter;
49 47
50   - HttpRequest current_request;
51   - HttpMessage current_response;
  48 + HttpRequest current_request;
  49 + HttpMessage current_response;
52 50
53   - Queue additional_headers;
  51 + TR_Queue additional_headers;
54 52
55   - HttpParser parser;
56   - HttpWriter writer;
  53 + HttpParser parser;
  54 + HttpWriter writer;
57 55 };
58 56
59 57 #endif // __HTTP_WORKER_H__
... ...
... ... @@ -28,8 +28,8 @@
28 28
29 29 #include "trbase.h"
30 30 #include "trio.h"
  31 +#include "trdata.h"
31 32 #include "http/message.h"
32   -#include "queue.h"
33 33
34 34
35 35 /*
... ... @@ -79,7 +79,7 @@ typedef enum e_HttpWriterState {
79 79 TR_CLASS(HttpWriter) {
80 80 char * buffer;
81 81
82   - Queue queue;
  82 + TR_Queue queue;
83 83 HttpMessage current;
84 84
85 85 size_t nbuffer; // size of buffer
... ...
1   -/**
2   - * \file
3   - * Holds requests ready for processing.
4   - *
5   - * \todo change this to a real queue.
6   - *
7   - * \author Georg Hopp
8   - *
9   - * \copyright
10   - * Copyright © 2012 Georg Hopp
11   - *
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
14   - * the Free Software Foundation, either version 3 of the License, or
15   - * (at your option) any later version.
16   - *
17   - * This program is distributed in the hope that it will be useful,
18   - * but WITHOUT ANY WARRANTY; without even the implied warranty of
19   - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20   - * GNU General Public License for more details.
21   - *
22   - * You should have received a copy of the GNU General Public License
23   - * along with this program. If not, see <http://www.gnu.org/licenses/>.
24   - */
25   -
26   -#ifndef __QUEUE_H__
27   -#define __QUEUE_H__
28   -
29   -#include <sys/types.h>
30   -
31   -#include "trbase.h"
32   -
33   -
34   -TR_CLASS(Queue) {
35   - void * msg;
36   - Queue next;
37   -
38   - /**
39   - * first and last are only available in the initial queue
40   - * element (the root). This elelment does not contain any message
41   - * and exists only for organizational purpose.
42   - *
43   - * \todo next and first always have to be the same...so get rid
44   - * of first.
45   - */
46   - Queue first;
47   - Queue last;
48   - size_t nmsg;
49   -};
50   -
51   -void queuePut(Queue, void *);
52   -void * queueGet(Queue);
53   -
54   -#define queueEmpty(this) (0 >= (this)->nmsg)
55   -
56   -#endif // __QUEUE_H__
57   -
58   -// vim: set ts=4 sw=4:
... ... @@ -34,22 +34,22 @@
34 34 #include <dlfcn.h>
35 35
36 36 #include "trbase.h"
37   -#include "hash.h"
  37 +#include "trdata.h"
  38 +
38 39 #include "session.h"
39 40 #include "http/request.h"
40 41 #include "http/response.h"
41 42 #include "application/application.h"
42 43
43   -typedef char * (* fptr_routable)(Application, Session, Hash);
  44 +typedef char * (* fptr_routable)(Application, Session, TR_Hash);
44 45
45 46 TR_CLASS(Router) {
46   - Hash functions;
  47 + TR_Hash functions;
47 48 Application application;
48 49
49 50 void * handle;
50 51 char * prefix;
51 52 size_t nprefix;
52   -
53 53 };
54 54
55 55 HttpResponse routerRoute(Router, HttpRequest, Session);
... ...
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 __TREE_H__
24   -#define __TREE_H__
25   -
26   -#include "trbase.h"
27   -
28   -#define TREE_RIGHT(node) (NULL!=(node)?(node)->right:NULL)
29   -#define TREE_LEFT(node) (NULL!=(node)?(node)->left:NULL)
30   -#define TREE_PARENT(node) (NULL!=(node)?(node)->parent:NULL)
31   -
32   -#define TREE_CHILD(node) \
33   - (NULL==TREE_RIGHT((node))?TREE_LEFT((node)):TREE_RIGHT((node)))
34   -
35   -#define TREE_RIGHT_LEFT(node) \
36   - (NULL!=TREE_RIGHT((node))?TREE_LEFT(TREE_RIGHT((node))):NULL)
37   -
38   -#define TREE_LEFT_RIGHT(node) \
39   - (NULL!=TREE_LEFT((node))?TREE_RIGHT(TREE_LEFT((node))):NULL)
40   -
41   -#define TREE_SIBLING(node) \
42   - (NULL!=TREE_PARENT((node))? \
43   - ((node)==TREE_PARENT((node))->left? \
44   - TREE_PARENT((node))->right: \
45   - TREE_PARENT((node))->left): \
46   - NULL)
47   -
48   -#define TREE_GRANDPARENT(node) \
49   - (NULL!=TREE_PARENT((node))?TREE_PARENT((node))->parent:NULL)
50   -
51   -#define TREE_UNCLE(node) \
52   - (NULL!=TREE_GRANDPARENT((node))? \
53   - (TREE_PARENT((node))==TREE_GRANDPARENT((node))->left? \
54   - TREE_GRANDPARENT((node))->right: \
55   - TREE_GRANDPARENT((node))->left): \
56   - NULL)
57   -
58   -#define TREE_ROTATE_LEFT(root, node) \
59   - do { \
60   - if (NULL != TREE_RIGHT_LEFT((node))) { \
61   - TREE_RIGHT_LEFT((node))->parent = (node); \
62   - } \
63   - TREE_RIGHT((node))->left = (node); \
64   - if (NULL != TREE_PARENT((node))) { \
65   - if (TREE_PARENT((node))->left==(node)) { \
66   - TREE_PARENT((node))->left = (node)->right; \
67   - } else { \
68   - TREE_PARENT((node))->right = (node)->right; \
69   - } \
70   - } else { \
71   - *(root) = (node)->right; \
72   - } \
73   - (node)->right = TREE_RIGHT_LEFT((node)); \
74   - (node)->parent = (node)->right; \
75   - TREE_RIGHT((node))->parent = (node)->parent; \
76   - } while(0)
77   -
78   -#define TREE_ROTATE_RIGHT(root, node) \
79   - do { \
80   - if (NULL != TREE_LEFT_RIGHT((node))) { \
81   - TREE_LEFT_RIGHT((node))->parent = (node); \
82   - } \
83   - TREE_LEFT((node))->right = (node); \
84   - if (NULL != TREE_PARENT((node))) { \
85   - if (TREE_PARENT((node))->left==(node)) { \
86   - TREE_PARENT((node))->left = (node)->left; \
87   - } else { \
88   - TREE_PARENT((node))->right = (node)->left; \
89   - } \
90   - } else { \
91   - *(root) = (node)->left; \
92   - } \
93   - TREE_LEFT((node))->parent = (node)->parent; \
94   - (node)->left = TREE_LEFT_RIGHT((node)); \
95   - (node)->parent = (node)->right; \
96   - } while(0)
97   -
98   -#define TREE_REPLACE_NODE(root, node1, node2) \
99   - do { \
100   - if (NULL != TREE_PARENT((node1))) { \
101   - if ((node1) == TREE_PARENT((node1))->left) { \
102   - TREE_PARENT((node1))->left = (node2); \
103   - } else { \
104   - TREE_PARENT((node1))->right = (node2); \
105   - } \
106   - } else { \
107   - *(root) = (node2); \
108   - } \
109   - if (NULL != (node2)) { \
110   - (node2)->parent = (node1)->parent; \
111   - } \
112   - } while(0)
113   -
114   -
115   -enum rbColor {rbBlack=1, rbRed=2};
116   -
117   -TR_CLASS(Tree) {
118   - void * data;
119   -
120   - enum rbColor color;
121   -
122   - Tree parent;
123   - Tree left;
124   - Tree right;
125   -};
126   -
127   -typedef int (*TreeComp)(const void *, const void *);
128   -typedef void (*TreeAction)(const void *, const int);
129   -
130   -void * treeFind(Tree, const void *, TreeComp);
131   -void * treeInsert(Tree *, const void *, TreeComp);
132   -void * treeDelete(Tree *, const void *, TreeComp);
133   -void treeWalk(Tree, TreeAction);
134   -void treeDestroy(Tree *, TreeAction);
135   -
136   -#endif // __TREE_H__
137   -
138   -// vim: set ts=4 sw=4:
... ... @@ -7,11 +7,6 @@ TRUTILS = utils/http.c \
7 7 utils/signalHandling.c \
8 8 utils/mime_type.c
9 9
10   -TRCOMMONLIBS = cbuf/libcbuf.la \
11   - hash/libhash.la \
12   - queue/libqueue.la \
13   - tree/libtree.la
14   -
15 10 TRHTTPSERVER = http/libhttp.la \
16 11 asset/libasset.la \
17 12 server/libserver.la
... ... @@ -24,22 +19,18 @@ TR = ./application/.libs/libapplication.a \
24 19 ./config/.libs/libconfig.a \
25 20 ./router/.libs/librouter.a
26 21
27   -TRLIBS = -ltrbase -ltrhashing -ltrio -ltrutils -ltrhttpserver -ltrcommon
  22 +TRLIBS = -ltrbase -ltrhashing -ltrio -ltrdata -ltrutils -ltrhttpserver
28 23 USEDLIBS = -lrt -lssl -lcrypto -lldap -lgdbm -luuid
29 24
30 25 AM_CFLAGS += -I../include/
31 26
32 27 bin_PROGRAMS = taskrambler
33   -lib_LTLIBRARIES = libtrutils.la libtrcommon.la libtrhttpserver.la
  28 +lib_LTLIBRARIES = libtrutils.la libtrhttpserver.la
34 29
35 30 libtrutils_la_SOURCES = $(TRUTILS)
36 31 libtrutils_la_CFLAGS = $(AM_CFLAGS)
37 32 libtrutils_la_LIBADD =
38 33
39   -libtrcommon_la_SOURCES =
40   -libtrcommon_la_CFLAGS = $(AM_CFLAGS)
41   -libtrcommon_la_LIBADD = $(TRCOMMONLIBS)
42   -
43 34 libtrhttpserver_la_SOURCES =
44 35 libtrhttpserver_la_CFLAGS = $(AM_CFLAGS)
45 36 libtrhttpserver_la_LIBADD = $(TRHTTPSERVER)
... ... @@ -50,6 +41,6 @@ taskrambler_LDADD = $(TRLIBS) $(TR) $(USEDLIBS)
50 41 taskrambler_LDFLAGS = -Wl,--export-dynamic \
51 42 -Wl,--whole-archive,./application/.libs/libapplication.a,--no-whole-archive
52 43
53   -SUBDIRS = asset auth cbuf hash queue http \
54   - server session tree application \
  44 +SUBDIRS = asset auth http \
  45 + server session application \
55 46 storage user config router
... ...
... ... @@ -26,9 +26,10 @@
26 26 #include <sys/types.h>
27 27
28 28 #include "trbase.h"
  29 +#include "trdata.h"
  30 +
29 31 #include "application/application.h"
30 32 #include "application/adapter/http.h"
31   -#include "hash.h"
32 33 #include "http/worker.h"
33 34 #include "http/header.h"
34 35 #include "http/message.h"
... ... @@ -39,9 +40,9 @@
39 40 static
40 41 inline
41 42 char *
42   -getSessionId(Hash cookies)
  43 +getSessionId(TR_Hash cookies)
43 44 {
44   - HashValue sidstr = hashGet(cookies, CSTRA("sid"));
  45 + TR_HashValue sidstr = TR_hashGet(cookies, CSTRA("sid"));
45 46
46 47 if (NULL != sidstr) {
47 48 return (char*)sidstr->value;
... ... @@ -73,7 +74,7 @@ applicationAdapterHttpUpdate(void * _this, void * subject)
73 74
74 75 // send session cookie
75 76 nbuf = sprintf(buf, "sid=%s;Path=/", session->id);
76   - queuePut(
  77 + TR_queuePut(
77 78 worker->additional_headers,
78 79 TR_new(HttpHeader, CSTRA("Set-Cookie"), buf, nbuf));
79 80
... ...
... ... @@ -24,8 +24,9 @@
24 24
25 25 #include <stdarg.h>
26 26
27   -#include <trbase.h>
28   -#include <trhash.h>
  27 +#include "trbase.h"
  28 +#include "trhash.h"
  29 +#include "trdata.h"
29 30
30 31 #include "application/application.h"
31 32 #include "storage/storage.h"
... ... @@ -56,9 +57,9 @@ applicationCtor(void * _this, va_list * params)
56 57
57 58 this->auth = va_arg(*params, void *);
58 59
59   - this->active_sessions = TR_calloc(SESSION_LIVETIME, sizeof(Hash));
  60 + this->active_sessions = TR_calloc(SESSION_LIVETIME, sizeof(TR_Hash));
60 61 for (i=0; i<SESSION_LIVETIME; i++) {
61   - this->active_sessions[i] = TR_new(Hash);
  62 + this->active_sessions[i] = TR_new(TR_Hash);
62 63 }
63 64
64 65 this->version = VERSION;
... ...
... ... @@ -23,18 +23,18 @@
23 23 #define _GNU_SOURCE
24 24
25 25 #include "trbase.h"
26   -#include "hash.h"
  26 +#include "trdata.h"
27 27 #include "auth/credential.h"
28 28
29 29
30 30 int _controllerValidatePasswordRepeat(char *, size_t, char *, size_t);
31 31
32 32 Credential
33   -_controllerGetCredentialFromArgs(Hash args)
  33 +_controllerGetCredentialFromArgs(TR_Hash args)
34 34 {
35   - HashValue email = hashGet(args, CSTRA("email"));
36   - HashValue password = hashGet(args, CSTRA("password"));
37   - HashValue pwrepeat = hashGet(args, CSTRA("pwrepeat"));
  35 + TR_HashValue email = TR_hashGet(args, CSTRA("email"));
  36 + TR_HashValue password = TR_hashGet(args, CSTRA("password"));
  37 + TR_HashValue pwrepeat = TR_hashGet(args, CSTRA("pwrepeat"));
38 38
39 39 if (
40 40 NULL == email ||
... ...
... ... @@ -25,16 +25,16 @@
25 25 #include <trbase.h>
26 26 #include <trhash.h>
27 27
28   -#include "hash.h"
  28 +#include "trdata.h"
29 29 #include "user.h"
30 30
31 31
32 32 User
33   -_controllerGetUserFromArgs(Hash args)
  33 +_controllerGetUserFromArgs(TR_Hash args)
34 34 {
35   - HashValue email = hashGet(args, CSTRA("email"));
36   - HashValue firstname = hashGet(args, CSTRA("firstname"));
37   - HashValue surname = hashGet(args, CSTRA("surname"));
  35 + TR_HashValue email = TR_hashGet(args, CSTRA("email"));
  36 + TR_HashValue firstname = TR_hashGet(args, CSTRA("firstname"));
  37 + TR_HashValue surname = TR_hashGet(args, CSTRA("surname"));
38 38
39 39 if (
40 40 NULL == email ||
... ...
... ... @@ -23,16 +23,16 @@
23 23 #define _GNU_SOURCE
24 24
25 25 #include "trbase.h"
26   -#include "hash.h"
  26 +#include "trdata.h"
27 27 #include "user.h"
28 28 #include "auth/credential.h"
29 29
30 30
31   -User _controllerGetUserFromArgs(Hash args);
32   -Credential _controllerGetCredentialFromArgs(Hash args);
  31 +User _controllerGetUserFromArgs(TR_Hash args);
  32 +Credential _controllerGetCredentialFromArgs(TR_Hash args);
33 33
34 34 int
35   -_controllerProcessUserCreateArgs(Hash args, User * user, Credential * cred)
  35 +_controllerProcessUserCreateArgs(TR_Hash args, User * user, Credential * cred)
36 36 {
37 37 *user = _controllerGetUserFromArgs(args);
38 38 *cred = _controllerGetCredentialFromArgs(args);
... ...
... ... @@ -24,17 +24,17 @@
24 24
25 25 #include <trbase.h>
26 26 #include <trhash.h>
  27 +#include <trdata.h>
27 28
28   -#include "hash.h"
29 29 #include "user.h"
30 30
31 31
32 32 int
33   -_controllerUpdateUserFromArgs(Hash args, User * user)
  33 +_controllerUpdateUserFromArgs(TR_Hash args, User * user)
34 34 {
35   - HashValue email = hashGet(args, CSTRA("email"));
36   - HashValue firstname = hashGet(args, CSTRA("firstname"));
37   - HashValue surname = hashGet(args, CSTRA("surname"));
  35 + TR_HashValue email = TR_hashGet(args, CSTRA("email"));
  36 + TR_HashValue firstname = TR_hashGet(args, CSTRA("firstname"));
  37 + TR_HashValue surname = TR_hashGet(args, CSTRA("surname"));
38 38 User new_user;
39 39
40 40 if (
... ...
... ... @@ -21,7 +21,6 @@
21 21 */
22 22
23 23 #include "trbase.h"
24   -#include "hash.h"
25 24 #include "auth/credential.h"
26 25
27 26
... ...
... ... @@ -21,7 +21,6 @@
21 21 */
22 22
23 23 #include "trbase.h"
24   -#include "hash.h"
25 24 #include "auth/credential.h"
26 25
27 26 int
... ...
... ... @@ -23,32 +23,33 @@
23 23 #define _GNU_SOURCE
24 24
25 25 #include "trbase.h"
  26 +#include "trdata.h"
  27 +
26 28 #include "application/application.h"
27 29 #include "session.h"
28   -#include "hash.h"
29 30 #include "auth/credential.h"
30 31 #include "user.h"
31 32
32 33
33   -char * controllerCurrentuserRead(Application, Session, Hash);
  34 +char * controllerCurrentuserRead(Application, Session, TR_Hash);
34 35
35 36 char *
36 37 controllerAuthenticateCreate(
37 38 Application application,
38 39 Session session,
39   - Hash args)
  40 + TR_Hash args)
40 41 {
41   - HashValue username;
42   - HashValue password;
43   - Credential credential;
  42 + TR_HashValue username;
  43 + TR_HashValue password;
  44 + Credential credential;
44 45
45   - char * response_data;
  46 + char * response_data;
46 47
47   - username = hashGet(args, CSTRA("username"));
48   - password = hashGet(args, CSTRA("password"));
  48 + username = TR_hashGet(args, CSTRA("username"));
  49 + password = TR_hashGet(args, CSTRA("password"));
49 50
50 51 if (NULL == username) {
51   - username = hashGet(args, CSTRA("email"));
  52 + username = TR_hashGet(args, CSTRA("email"));
52 53 }
53 54
54 55 if (NULL == username || NULL == password) {
... ...
... ... @@ -22,18 +22,18 @@
22 22
23 23 #define _GNU_SOURCE
24 24
  25 +#include "trdata.h"
  26 +
25 27 #include "application/application.h"
26 28 #include "session.h"
27   -#include "hash.h"
28   -
29 29
30   -char * controllerCurrentuserRead(Application, Session, Hash);
  30 +char * controllerCurrentuserRead(Application, Session, TR_Hash);
31 31
32 32 char *
33 33 controllerAuthenticateDelete(
34 34 Application application,
35 35 Session session,
36   - Hash args)
  36 + TR_Hash args)
37 37 {
38 38 applicationLogout(application, session);
39 39 return controllerCurrentuserRead(application, session, NULL);
... ...
... ... @@ -26,16 +26,16 @@
26 26 #include <stdio.h>
27 27
28 28 #include "trbase.h"
  29 +#include "trdata.h"
29 30 #include "application/application.h"
30 31 #include "session.h"
31   -#include "hash.h"
32 32
33 33
34 34 #define USER_JSON \
35 35 "{\"username\":\"%s\",\"email\":\"%s\",\"firstname\":\"%s\",\"surname\":\"%s\"}"
36 36
37 37 char *
38   -controllerCurrentuserRead(Application app, Session sess, Hash args)
  38 +controllerCurrentuserRead(Application app, Session sess, TR_Hash args)
39 39 {
40 40 char * buffer;
41 41 size_t nbuffer;
... ...
... ... @@ -26,14 +26,15 @@
26 26 #include <stdio.h>
27 27
28 28 #include "trbase.h"
  29 +#include "trdata.h"
  30 +
29 31 #include "application/application.h"
30   -#include "hash.h"
31 32 #include "session.h"
32 33
33 34 #define LOC_JSON "{\"loc\":\"%s\"}"
34 35
35 36 char *
36   -controllerLocRead(Application app, Session sess, Hash args)
  37 +controllerLocRead(Application app, Session sess, TR_Hash args)
37 38 {
38 39 char * buffer;
39 40 size_t nbuffer;
... ...
... ... @@ -26,15 +26,16 @@
26 26 #include <stdio.h>
27 27
28 28 #include "trbase.h"
  29 +#include "trdata.h"
  30 +
29 31 #include "application/application.h"
30 32 #include "session.h"
31   -#include "hash.h"
32 33
33 34 #define RANDVAL_JSON "{\"ctime\":%ld,\"vnext\":%ld,\"value\":\"%02d\"}"
34 35
35 36
36 37 char *
37   -controllerRandvalRead(Application app, Session sess, Hash args)
  38 +controllerRandvalRead(Application app, Session sess, TR_Hash args)
38 39 {
39 40 char * buffer;
40 41 size_t nbuffer;
... ...
... ... @@ -26,9 +26,10 @@
26 26 #include <sys/types.h>
27 27
28 28 #include "trbase.h"
  29 +#include "trdata.h"
  30 +
29 31 #include "application/application.h"
30 32 #include "session.h"
31   -#include "hash.h"
32 33
33 34 #define SESSION_JSON "{\"id\":\"%s\",\"timeout\":%d,\"timeleft\":%ld}"
34 35
... ... @@ -37,7 +38,7 @@ char *
37 38 controllerSessinfoRead(
38 39 Application application,
39 40 Session session,
40   - Hash args)
  41 + TR_Hash args)
41 42 {
42 43 char * buffer;
43 44 size_t nbuffer;
... ...
... ... @@ -24,23 +24,23 @@
24 24
25 25 #include <trbase.h>
26 26 #include <trhash.h>
  27 +#include <trdata.h>
27 28
28 29 #include "application/application.h"
29 30 #include "session.h"
30   -#include "hash.h"
31 31 #include "auth/credential.h"
32 32 #include "user.h"
33 33
34 34
35   -char * controllerCurrentuserRead(Application, Session, Hash);
36   -int _controllerProcessUserCreateArgs(Hash, User *, Credential *);
  35 +char * controllerCurrentuserRead(Application, Session, TR_Hash);
  36 +int _controllerProcessUserCreateArgs(TR_Hash, User *, Credential *);
37 37
38 38
39 39 char *
40 40 controllerSignupCreate(
41 41 Application application,
42 42 Session session,
43   - Hash args)
  43 + TR_Hash args)
44 44 {
45 45 Credential credential;
46 46 User user;
... ...
... ... @@ -24,22 +24,22 @@
24 24
25 25 #include <trbase.h>
26 26 #include <trhash.h>
  27 +#include <trdata.h>
27 28
28 29 #include "application/application.h"
29 30 #include "session.h"
30   -#include "hash.h"
31 31 #include "auth/credential.h"
32 32 #include "user.h"
33 33
34 34
35   -char * controllerCurrentuserRead(Application, Session, Hash);
36   -int _controllerProcessUserCreateArgs(Hash, User *, Credential *);
  35 +char * controllerCurrentuserRead(Application, Session, TR_Hash);
  36 +int _controllerProcessUserCreateArgs(TR_Hash, User *, Credential *);
37 37
38 38 char *
39 39 controllerUserCreate(
40 40 Application application,
41 41 Session session,
42   - Hash args)
  42 + TR_Hash args)
43 43 {
44 44 Credential credential;
45 45 User user;
... ...
... ... @@ -27,23 +27,23 @@
27 27
28 28 #include <trbase.h>
29 29 #include <trhash.h>
  30 +#include <trdata.h>
30 31
31 32 #include "application/application.h"
32 33 #include "session.h"
33   -#include "hash.h"
34 34
35 35
36 36 #define USER_JSON \
37 37 "{\"email\":\"%s\",\"firstname\":\"%s\",\"surname\":\"%s\"}"
38 38
39 39 char *
40   -controllerUserRead(Application app, Session sess, Hash args)
  40 +controllerUserRead(Application app, Session sess, TR_Hash args)
41 41 {
42   - char * buffer;
43   - size_t nbuffer;
44   - HashValue id = hashGet(args, CSTRA("id"));
45   - TR_Uuid search = TR_uuidParse(id->value);
46   - User user = applicationGetUser(app, search);
  42 + char * buffer;
  43 + size_t nbuffer;
  44 + TR_HashValue id = TR_hashGet(args, CSTRA("id"));
  45 + TR_Uuid search = TR_uuidParse(id->value);
  46 + User user = applicationGetUser(app, search);
47 47
48 48 nbuffer = snprintf(NULL, 0, USER_JSON,
49 49 user->email,
... ...
... ... @@ -24,21 +24,21 @@
24 24
25 25 #include <trbase.h>
26 26 #include <trhash.h>
  27 +#include <trdata.h>
27 28
28 29 #include "application/application.h"
29 30 #include "session.h"
30   -#include "hash.h"
31 31 #include "user.h"
32 32
33 33
34   -char * controllerCurrentuserRead(Application, Session, Hash);
35   -int _controllerUpdateUserFromArgs(Hash, User *);
  34 +char * controllerCurrentuserRead(Application, Session, TR_Hash);
  35 +int _controllerUpdateUserFromArgs(TR_Hash, User *);
36 36
37 37 char *
38 38 controllerUserUpdate(
39 39 Application application,
40 40 Session session,
41   - Hash args)
  41 + TR_Hash args)
42 42 {
43 43 TR_Uuid user_id;
44 44
... ...
... ... @@ -26,14 +26,14 @@
26 26 #include <stdio.h>
27 27
28 28 #include "trbase.h"
  29 +#include "trdata.h"
29 30 #include "application/application.h"
30   -#include "hash.h"
31 31 #include "session.h"
32 32
33 33 #define VERSION_JSON "{\"version\":\"%s\"}"
34 34
35 35 char *
36   -controllerVersionRead(Application app, Session sess, Hash args)
  36 +controllerVersionRead(Application app, Session sess, TR_Hash args)
37 37 {
38 38 char * buffer;
39 39 size_t nbuffer;
... ...
... ... @@ -25,9 +25,10 @@
25 25 #include <stdlib.h>
26 26 #include <sys/types.h>
27 27
  28 +#include "trdata.h"
  29 +
28 30 #include "trbase.h"
29 31 #include "session.h"
30   -#include "hash.h"
31 32 #include "application/application.h"
32 33
33 34
... ... @@ -42,23 +43,23 @@ applicationSessionCleanup(Application this, time_t now)
42 43 }
43 44
44 45 if (0 < expired && SESSION_LIVETIME > expired) {
45   - Hash * tmp_buf = TR_calloc(SESSION_LIVETIME, sizeof(Hash));
  46 + TR_Hash * tmp_buf = TR_calloc(SESSION_LIVETIME, sizeof(TR_Hash));
46 47
47 48 memcpy(
48 49 &(tmp_buf[expired]),
49 50 this->active_sessions,
50   - (SESSION_LIVETIME - expired) * sizeof(Hash));
  51 + (SESSION_LIVETIME - expired) * sizeof(TR_Hash));
51 52 memcpy(
52 53 tmp_buf,
53 54 &(this->active_sessions[SESSION_LIVETIME - expired]),
54   - expired * sizeof(Hash));
  55 + expired * sizeof(TR_Hash));
55 56
56 57 TR_MEM_FREE(this->active_sessions);
57 58 this->active_sessions = tmp_buf;
58 59 }
59 60
60 61 for (i=0; i<expired; i++) {
61   - hashCleanup(this->active_sessions[i]);
  62 + TR_hashCleanup(this->active_sessions[i]);
62 63 }
63 64
64 65 this->session_time_ofs = now;
... ...
... ... @@ -24,8 +24,9 @@
24 24
25 25 #include <sys/types.h>
26 26
  27 +#include "trdata.h"
  28 +
27 29 #include "session.h"
28   -#include "hash.h"
29 30 #include "application/application.h"
30 31
31 32
... ... @@ -40,7 +41,7 @@ applicationSessionGet(Application this, const char * sid)
40 41 * now get the session if not expired
41 42 */
42 43 for (index=0; index<SESSION_LIVETIME; index++) {
43   - sess = (Session)hashDelete(
  44 + sess = (Session)TR_hashDelete(
44 45 (this->active_sessions)[index], sid, 36);
45 46 if (NULL != sess) {
46 47 break;
... ... @@ -52,7 +53,7 @@ applicationSessionGet(Application this, const char * sid)
52 53 */
53 54 if (NULL != sess) {
54 55 sess->livetime = this->session_time_ofs + SESSION_LIVETIME;
55   - hashAdd((this->active_sessions)[0], sess);
  56 + TR_hashAdd((this->active_sessions)[0], sess);
56 57 }
57 58 }
58 59
... ...
... ... @@ -26,8 +26,9 @@
26 26 #include <sys/types.h>
27 27
28 28 #include "trbase.h"
  29 +#include "trdata.h"
  30 +
29 31 #include "session.h"
30   -#include "hash.h"
31 32 #include "application/application.h"
32 33
33 34
... ... @@ -36,7 +37,7 @@ applicationSessionStart(Application this)
36 37 {
37 38 Session sess = TR_new(Session);
38 39
39   - hashAdd((this->active_sessions)[0], sess);
  40 + TR_hashAdd((this->active_sessions)[0], sess);
40 41
41 42 return sess;
42 43 }
... ...
... ... @@ -24,6 +24,8 @@
24 24
25 25 #include <sys/types.h>
26 26
  27 +#include "trdata.h"
  28 +
27 29 #include "session.h"
28 30 #include "application/application.h"
29 31
... ... @@ -35,7 +37,7 @@ applicationSessionStop(Application this, Session session)
35 37 (session->livetime - this->session_time_ofs);
36 38
37 39 if (SESSION_LIVETIME > index) {
38   - hashDeleteByVal((this->active_sessions)[index], session->hash);
  40 + TR_hashDeleteByVal((this->active_sessions)[index], session->hash);
39 41 }
40 42 }
41 43
... ...
... ... @@ -40,7 +40,6 @@
40 40 #include <trhash.h>
41 41
42 42 #include "asset.h"
43   -#include "hash.h"
44 43
45 44 #include "utils/mime_type.h"
46 45 #include "utils/http.h"
... ... @@ -139,7 +138,7 @@ assetHandleDouble(void * _this, void * _doub)
139 138 }
140 139
141 140 TR_INIT_IFACE(TR_Class, assetCtor, assetDtor, NULL);
142   -TR_INIT_IFACE(Hashable, assetGetHash, assetHandleDouble);
143   -TR_CREATE_CLASS(Asset, NULL, TR_IF(TR_Class), TR_IF(Hashable));
  141 +TR_INIT_IFACE(TR_Hashable, assetGetHash, assetHandleDouble);
  142 +TR_CREATE_CLASS(Asset, NULL, TR_IF(TR_Class), TR_IF(TR_Hashable));
144 143
145 144 // vim: set ts=4 sw=4:
... ...
... ... @@ -26,10 +26,10 @@
26 26 // for strlen
27 27
28 28 #include "trbase.h"
  29 +#include "trdata.h"
29 30 #include "asset.h"
30   -#include "hash.h"
31 31
32   -Hash asset_pool = NULL;
  32 +TR_Hash asset_pool = NULL;
33 33
34 34 static
35 35 inline
... ... @@ -45,15 +45,15 @@ assetPoolGet(const char * path, size_t npath)
45 45 Asset asset = NULL;
46 46
47 47 if (NULL == asset_pool) {
48   - asset_pool = TR_new(Hash);
  48 + asset_pool = TR_new(TR_Hash);
49 49 } else {
50   - asset = hashGet(asset_pool, path, npath);
  50 + asset = TR_hashGet(asset_pool, path, npath);
51 51 }
52 52
53 53 if (NULL == asset) {
54 54 asset = TR_new(Asset, path, npath);
55 55 if (NULL != asset) {
56   - hashAdd(asset_pool, asset);
  56 + TR_hashAdd(asset_pool, asset);
57 57 }
58 58 } else {
59 59 asset->ref_count++;
... ... @@ -71,7 +71,7 @@ assetPoolRelease(Asset asset)
71 71 }
72 72
73 73 if (NULL != asset) {
74   - Asset found = (Asset)hashDelete(
  74 + Asset found = (Asset)TR_hashDelete(
75 75 asset_pool, asset->fname, asset->nfname);
76 76
77 77 if (found == asset) {
... ... @@ -90,7 +90,7 @@ void
90 90 assetPoolCleanup(void)
91 91 {
92 92 if (NULL != asset_pool) {
93   - hashEach(asset_pool, freeAsset);
  93 + TR_hashEach(asset_pool, freeAsset);
94 94 TR_delete(asset_pool);
95 95 }
96 96 }
... ...
1   -ACLOCAL_AMFLAGS = -I m4
2   -AUTOMAKE_OPTIONS = subdir-objects
3   -
4   -CB = cbuf.c read.c \
5   - get_line.c set_data.c get_data.c \
6   - addr_index.c get_free.c get_read.c get_write.c \
7   - inc_read.c inc_write.c is_empty.c memchr.c \
8   - skip_non_alpha.c is_locked.c lock.c release.c \
9   - empty.c
10   -
11   -AM_CFLAGS += -I../../include/
12   -
13   -noinst_LTLIBRARIES = libcbuf.la
14   -
15   -libcbuf_la_SOURCES = $(CB)
16   -libcbuf_la_CFLAGS = $(AM_CFLAGS)
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   -#include <sys/types.h>
24   -
25   -#include "cbuf.h"
26   -
27   -size_t
28   -cbufAddrIndex(Cbuf this, const void * c)
29   -{
30   - return c - (const void *)cbufGetRead(this);
31   -}
32   -
33   -// 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   -
23   -#define _POSIX_SOURCE
24   -#define _POSIX_C_SOURCE 200112L
25   -#define _GNU_SOURCE
26   -
27   -#include <sys/types.h>
28   -#include <sys/stat.h>
29   -#include <sys/mman.h>
30   -#include <stdarg.h>
31   -#include <stdlib.h>
32   -#include <stdio.h>
33   -#include <unistd.h>
34   -#include <fcntl.h>
35   -
36   -#include "trbase.h"
37   -#include "cbuf.h"
38   -
39   -
40   -static void cbufDtor(void*);
41   -
42   -static
43   -int
44   -cbufCtor(void * _this, va_list * params)
45   -{
46   - Cbuf this = _this;
47   - char state = -1;
48   - char * shm_name = va_arg(*params, char*);
49   - long psize = sysconf(_SC_PAGESIZE);
50   - size_t size;
51   - int shm;
52   - char * data;
53   -
54   - this->shm_name = TR_malloc(strlen(shm_name) + 7 + 2);
55   - sprintf(this->shm_name, "/%06d_%s", getpid(), shm_name);
56   -
57   - /**
58   - * align size at page boundary.
59   - * increase as neccessary
60   - */
61   - size = va_arg(*params, size_t);
62   - size = (0 >= size)? 1 : (0 != size%psize)? (size/psize)+1 : size/psize;
63   - this->bsize = psize * size;
64   -
65   - while (-1 == state) {
66   - shm = shm_open(this->shm_name, O_RDWR|O_CREAT|O_EXCL, S_IRWXU);
67   - if (-1 == shm) {
68   - break;
69   - }
70   -
71   - if (-1 == ftruncate(shm, this->bsize)) {
72   - break;
73   - }
74   -
75   - this->data = mmap (0, this->bsize << 1,
76   - PROT_NONE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
77   - if (this->data == MAP_FAILED) {
78   - this->data = NULL;
79   - break;
80   - }
81   -
82   - data = mmap (this->data, this->bsize,
83   - PROT_READ|PROT_WRITE, MAP_FIXED|MAP_SHARED, shm, 0);
84   - if (data != this->data) {
85   - break;
86   - }
87   -
88   - data = mmap (this->data + this->bsize, this->bsize,
89   - PROT_READ|PROT_WRITE, MAP_FIXED|MAP_SHARED, shm, 0);
90   - if (data != this->data + this->bsize) {
91   - break;
92   - }
93   -
94   - state = 0;
95   - }
96   -
97   - if (-1 != shm) {
98   - shm_unlink(this->shm_name);
99   - close(shm);
100   - }
101   -
102   - return state;
103   -}
104   -
105   -static
106   -void
107   -cbufDtor(void * _this)
108   -{
109   - Cbuf this = _this;
110   -
111   - TR_MEM_FREE(this->shm_name);
112   -
113   - if (NULL != this->data && MAP_FAILED != this->data) {
114   - munmap(this->data, this->bsize << 1);
115   - }
116   -
117   - this->data = NULL;
118   -}
119   -
120   -TR_INIT_IFACE(TR_Class, cbufCtor, cbufDtor, NULL);
121   -TR_CREATE_CLASS(Cbuf, NULL, TR_IF(TR_Class));
122   -
123   -// 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   -
23   -#include "cbuf.h"
24   -
25   -void
26   -cbufEmpty(Cbuf this)
27   -{
28   - this->bused = 0;
29   - this->read = this->write;
30   -}
31   -
32   -// 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   -
23   -#include <sys/types.h>
24   -#include <string.h>
25   -
26   -#include "cbuf.h"
27   -
28   -char *
29   -cbufGetData(Cbuf this, size_t n)
30   -{
31   - char * ret = cbufGetRead(this);
32   -
33   - if (n > this->bused) {
34   - return (char *)-1;
35   - }
36   -
37   - cbufIncRead(this, n);
38   - return ret;
39   -}
40   -
41   -// 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   -
23   -#include <sys/types.h>
24   -
25   -#include "cbuf.h"
26   -
27   -size_t
28   -cbufGetFree(Cbuf this)
29   -{
30   - return this->bsize - this->bused;
31   -}
32   -
33   -// 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   -
23   -#include <sys/types.h>
24   -
25   -#include <string.h>
26   -
27   -#include "cbuf.h"
28   -
29   -char *
30   -cbufGetLine(Cbuf this, char ** line_end)
31   -{
32   - char * nl = cbufMemchr(this, '\n');
33   - char * ret = NULL;
34   -
35   - if (NULL != nl) {
36   - size_t len = cbufAddrIndex(this, nl) + 1;
37   -
38   - *line_end = nl - 1;
39   - *nl = 0;
40   - *(nl-1) = ('\r' == *(nl-1))? 0 : *(nl-1);
41   -
42   - ret = cbufGetRead(this);
43   - cbufIncRead(this, len);
44   - }
45   -
46   - return ret;
47   -}
48   -
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   -
23   -#include "cbuf.h"
24   -
25   -char *
26   -cbufGetRead(Cbuf this)
27   -{
28   - return this->data + this->read;
29   -}
30   -
31   -// 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   -
23   -#include "cbuf.h"
24   -
25   -char *
26   -cbufGetWrite(Cbuf this)
27   -{
28   - return this->data + this->write;
29   -}
30   -
31   -// 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   -
23   -#include <sys/types.h>
24   -
25   -#include "cbuf.h"
26   -
27   -void
28   -cbufIncRead(Cbuf this, size_t n)
29   -{
30   - this->read += n;
31   - this->read = (this->read >= this->bsize)?
32   - this->read - this->bsize : this->read;
33   - this->bused -= n;
34   -}
35   -
36   -// 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   -
23   -#include <sys/types.h>
24   -
25   -#include "cbuf.h"
26   -
27   -void
28   -cbufIncWrite(Cbuf this, size_t n)
29   -{
30   - this->write += n;
31   - this->write = (this->write >= this->bsize)?
32   - this->write - this->bsize : this->write;
33   - this->bused += n;
34   -}
35   -
36   -// 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   -
23   -#include "cbuf.h"
24   -
25   -char
26   -cbufIsEmpty(Cbuf this)
27   -{
28   - return (0 == this->bused);
29   -}
30   -
31   -// 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   -
23   -#include "cbuf.h"
24   -
25   -Bool
26   -cbufIsLocked(Cbuf this)
27   -{
28   - return this->lock;
29   -}
30   -
31   -// 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   -
23   -#include "cbuf.h"
24   -
25   -void
26   -cbufLock(Cbuf this)
27   -{
28   - this->lock = TRUE;
29   -}
30   -
31   -// 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   -
23   -#include <string.h>
24   -
25   -#include "cbuf.h"
26   -
27   -char *
28   -cbufMemchr(Cbuf this, int c)
29   -{
30   - return memchr(cbufGetRead(this), c, this->bused);
31   -}
32   -
33   -// 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   -
23   -#include <sys/types.h>
24   -#include <unistd.h>
25   -#include <errno.h>
26   -
27   -#include "trio.h"
28   -#include "cbuf.h"
29   -
30   -
31   -ssize_t
32   -cbufRead(Cbuf this, TR_Stream st)
33   -{
34   - size_t rsize = cbufGetFree(this);
35   - ssize_t rrsize;
36   -
37   - if (0 == rsize) {
38   - errno = ECBUFOVFL;
39   - return -1;
40   - }
41   -
42   - rrsize = TR_streamRead(st, cbufGetWrite(this), rsize);
43   -
44   - if (0 < rrsize) {
45   - cbufIncWrite(this, rrsize);
46   - }
47   -
48   - return rrsize;
49   -}
50   -
51   -// 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   -
23   -#include "cbuf.h"
24   -
25   -void
26   -cbufRelease(Cbuf this)
27   -{
28   - this->lock = FALSE;
29   -}
30   -
31   -// 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   -
23   -#include <sys/types.h>
24   -#include <string.h>
25   -#include <errno.h>
26   -
27   -#include "cbuf.h"
28   -
29   -char *
30   -cbufSetData(Cbuf this, const void * src, size_t n)
31   -{
32   - char * addr;
33   -
34   - if (n > cbufGetFree(this)) {
35   - errno = ECBUFOVFL;
36   - return (char *)-1;
37   - }
38   -
39   - addr = memcpy(cbufGetWrite(this), src, n);
40   - cbufIncWrite(this, n);
41   -
42   - return addr;
43   -}
44   -
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   -
23   -#include <ctype.h>
24   -
25   -#include "cbuf.h"
26   -
27   -void
28   -cbufSkipNonAlpha(Cbuf this)
29   -{
30   - while(0 < this->bused && !isalpha(*cbufGetRead(this)))
31   - cbufIncRead(this, 1);
32   -}
33   -
34   -// vim: set ts=4 sw=4:
... ... @@ -27,6 +27,8 @@
27 27 #include <sys/types.h>
28 28
29 29 #include "trbase.h"
  30 +#include "trdata.h"
  31 +
30 32 #include "config/config.h"
31 33 #include "config/value.h"
32 34
... ... @@ -51,7 +53,7 @@ configCtor(void * _this, va_list * params)
51 53 return -1;
52 54 }
53 55
54   - this->config = TR_new(Hash);
  56 + this->config = TR_new(TR_Hash);
55 57
56 58 line[MAX_CONFIG_LINE] = '\0';
57 59
... ... @@ -96,7 +98,7 @@ configCtor(void * _this, va_list * params)
96 98 value[nvalue] = '\0';
97 99
98 100 if (0 != nkey && 0 != nvalue) {
99   - hashAdd(
  101 + TR_hashAdd(
100 102 this->config,
101 103 TR_new(ConfigValue, key, nkey, value, nvalue));
102 104 }
... ...
... ... @@ -22,7 +22,8 @@
22 22
23 23 #include <sys/types.h>
24 24
25   -#include "hash/hash.h"
  25 +#include "trdata.h"
  26 +
26 27 #include "config/config.h"
27 28 #include "config/value.h"
28 29
... ... @@ -33,7 +34,7 @@ configGet(Config this, const char * key, size_t nkey)
33 34 return NULL;
34 35 }
35 36
36   - return hashGet(this->config, key, nkey);
  37 + return TR_hashGet(this->config, key, nkey);
37 38 }
38 39
39 40 // vim: set ts=4 sw=4:
... ...
... ... @@ -27,6 +27,7 @@
27 27
28 28 #include <trbase.h>
29 29 #include <trhash.h>
  30 +#include <trdata.h>
30 31
31 32 #include "config/value.h"
32 33
... ... @@ -94,7 +95,7 @@ configValueHandleDouble(void * _this, void * _double)
94 95 }
95 96
96 97 TR_INIT_IFACE(TR_Class, configValueCtor, configValueDtor, NULL);
97   -TR_INIT_IFACE(Hashable, configValueGetHash, configValueHandleDouble);
98   -TR_CREATE_CLASS(ConfigValue, NULL, TR_IF(TR_Class), TR_IF(Hashable));
  98 +TR_INIT_IFACE(TR_Hashable, configValueGetHash, configValueHandleDouble);
  99 +TR_CREATE_CLASS(ConfigValue, NULL, TR_IF(TR_Class), TR_IF(TR_Hashable));
99 100
100 101 // vim: set ts=4 sw=4:
... ...
1   -ACLOCAL_AMFLAGS = -I m4
2   -AUTOMAKE_OPTIONS = subdir-objects
3   -
4   -HASH = hash.c add.c get.c get_first.c delete.c each.c value.c \
5   - cleanup.c interface/hashable.c
6   -
7   -AM_CFLAGS += -I../../include/
8   -
9   -noinst_LTLIBRARIES = libhash.la
10   -
11   -libhash_la_SOURCES = $(HASH)
12   -libhash_la_CFLAGS = $(AM_CFLAGS)
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   -#include <search.h>
24   -
25   -#include "hash.h"
26   -
27   -static
28   -inline
29   -int
30   -hashAddComp(const void * a, const void * b)
31   -{
32   - unsigned long hash_a = hashableGetHash((void*)a);
33   - unsigned long hash_b = hashableGetHash((void*)b);
34   -
35   - if (hash_a < hash_b) {
36   - return -1;
37   - }
38   -
39   - if (hash_a > hash_b) {
40   - return 1;
41   - }
42   -
43   - return 0;
44   -}
45   -
46   -void *
47   -hashAdd(Hash this, void * operand)
48   -{
49   - void * found = treeInsert(&this->root, operand, hashAddComp);
50   -
51   - if (NULL == found) {
52   - return NULL;
53   - }
54   -
55   - if (operand != found) {
56   - hashableHandleDouble(found, operand);
57   - TR_delete(operand);
58   - }
59   -
60   - return found;
61   -}
62   -
63   -// 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   -
23   -#include "hash/hash.h"
24   -#include "trbase.h"
25   -
26   -static
27   -inline
28   -void
29   -tDelete(const void * node, const int depth)
30   -{
31   - TR_delete(node);
32   -}
33   -
34   -void
35   -hashCleanup(Hash this)
36   -{
37   - treeDestroy(&(this->root), tDelete);
38   -}
39   -
40   -// 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   -
23   -#include <sys/types.h>
24   -
25   -#include <trhash.h>
26   -
27   -#include "asset.h"
28   -#include "hash.h"
29   -
30   -static
31   -inline
32   -int
33   -hashDeleteComp(const void * a, const void * b)
34   -{
35   - unsigned long hash_a = hashableGetHash((void*)a);
36   -
37   - if (hash_a < *(const unsigned long*)b) {
38   - return -1;
39   - }
40   -
41   - if (hash_a > *(const unsigned long*)b) {
42   - return 1;
43   - }
44   -
45   - return 0;
46   -}
47   -
48   -void *
49   -hashDelete(Hash this, const char * search, size_t nsearch)
50   -{
51   - unsigned long hash = TR_sdbm((const unsigned char *)search, nsearch);
52   - void * found = NULL;
53   -
54   - found = treeDelete(&(this->root), &hash, hashDeleteComp);
55   -
56   - return found;
57   -}
58   -
59   -void *
60   -hashDeleteByVal(Hash this, unsigned long hash)
61   -{
62   - void * found = treeDelete(&(this->root), &hash, hashDeleteComp);
63   -
64   - return found;
65   -}
66   -
67   -// 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   -
23   -#include <search.h>
24   -
25   -#include "hash.h"
26   -
27   -static void (*cb)(const void*);
28   -
29   -static
30   -inline
31   -void
32   -walk(const void * node, const int depth)
33   -{
34   - cb(node);
35   -}
36   -
37   -void
38   -hashEach(Hash this, void (*callback)(const void*))
39   -{
40   - cb = callback;
41   -
42   - treeWalk(this->root, walk);
43   -}
44   -
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   -
23   -#include <stdio.h>
24   -
25   -#include <search.h>
26   -#include <sys/types.h>
27   -
28   -#include <trhash.h>
29   -
30   -#include "hash.h"
31   -#include "tree.h"
32   -
33   -static
34   -inline
35   -int
36   -hashGetComp(const void * a, const void * b)
37   -{
38   - unsigned long hash_a = hashableGetHash((void*)a);
39   -
40   - if (hash_a < *(const unsigned long*)b) {
41   - return -1;
42   - }
43   -
44   - if (hash_a > *(const unsigned long*)b) {
45   - return 1;
46   - }
47   -
48   - return 0;
49   -}
50   -
51   -void *
52   -hashGet(Hash this, const char * search, size_t nsearch)
53   -{
54   - unsigned long hash = TR_sdbm((const unsigned char *)search, nsearch);
55   - void * found = treeFind(this->root, &hash, hashGetComp);
56   -
57   - return found;
58   -}
59   -
60   -void *
61   -hashGetByVal(Hash this, unsigned long hash)
62   -{
63   - void * found = treeFind(this->root, &hash, hashGetComp);
64   -
65   - return found;
66   -}
67   -// 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   -
23   -#include <stdio.h>
24   -
25   -#include <search.h>
26   -#include <sys/types.h>
27   -
28   -#include <trhash.h>
29   -
30   -#include "hash.h"
31   -#include "tree.h"
32   -
33   -void *
34   -hashGetFirst(Hash this)
35   -{
36   - return this->root;
37   -}
38   -
39   -// 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   -
23   -#define _GNU_SOURCE
24   -
25   -#include <search.h>
26   -#include <stdarg.h>
27   -
28   -#include "hash/hash.h"
29   -#include "trbase.h"
30   -
31   -static
32   -int
33   -hashCtor(void * _this, va_list * params)
34   -{
35   - return 0;
36   -}
37   -
38   -static
39   -inline
40   -void
41   -tDelete(const void * node, const int depth)
42   -{
43   - TR_delete(node);
44   -}
45   -
46   -static
47   -void
48   -hashDtor(void * _this)
49   -{
50   - Hash this = _this;
51   -
52   - hashCleanup(this);
53   -}
54   -
55   -TR_INIT_IFACE(TR_Class, hashCtor, hashDtor, NULL);
56   -TR_CREATE_CLASS(Hash, NULL, TR_IF(TR_Class));
57   -
58   -// 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   -
23   -#include <stdlib.h>
24   -#include <stdio.h>
25   -#include <stdarg.h>
26   -
27   -#include "trbase.h"
28   -#include "hash/interface/hashable.h"
29   -
30   -TR_CREATE_INTERFACE(Hashable, 2);
31   -
32   -unsigned long
33   -hashableGetHash(void * hashable)
34   -{
35   - unsigned long ret;
36   -
37   - TR_RETCALL(hashable, Hashable, getHash, ret);
38   -
39   - return ret;
40   -}
41   -
42   -void
43   -hashableHandleDouble(void * hashable, void * new_hashable)
44   -{
45   - TR_CALL(hashable, Hashable, handleDouble, new_hashable);
46   -}
47   -
48   -// 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   -
23   -#include <stdarg.h>
24   -#include <stdlib.h>
25   -#include <string.h>
26   -#include <sys/types.h>
27   -
28   -#include <trbase.h>
29   -#include <trhash.h>
30   -
31   -#include "hash/value.h"
32   -#include "hash/interface/hashable.h"
33   -
34   -static
35   -int
36   -hashValueCtor(void * _this, va_list * params)
37   -{
38   - HashValue this = _this;
39   - char * key = va_arg(* params, char*);
40   - void * value;
41   -
42   - this->nkey = va_arg(* params, size_t);
43   - value = va_arg(* params, void*);
44   - this->nvalue = va_arg(* params, size_t);
45   -
46   - this->key = TR_malloc(this->nkey + 1);
47   - this->key[this->nkey] = 0;
48   - memcpy(this->key, key, this->nkey);
49   -
50   - this->hash = TR_sdbm((unsigned char *)this->key, this->nkey);
51   -
52   - if (NULL != value) {
53   - this->value = TR_malloc(this->nvalue + 1);
54   - ((char*)this->value)[this->nvalue] = 0;
55   - memcpy(this->value, value, this->nvalue);
56   - }
57   -
58   - return 0;
59   -}
60   -
61   -static
62   -void
63   -hashValueDtor(void * _this)
64   -{
65   - HashValue this = _this;
66   -
67   - TR_MEM_FREE(this->key);
68   - TR_MEM_FREE(this->value);
69   -}
70   -
71   -static
72   -unsigned long
73   -hashValueGetHash(void * _this)
74   -{
75   - HashValue this = _this;
76   -
77   - return this->hash;
78   -}
79   -
80   -static
81   -void
82   -hashValueHandleDouble(void * _this, void * _double)
83   -{
84   - HashValue this = _this;
85   - HashValue doub = _double;
86   - void * tmp_value;
87   - size_t tmp_nvalue;
88   -
89   - /**
90   - * here we swap the internal data of both objects,
91   - * effectively overwriting the old entry. We need not
92   - * to free anything here as _double will be deleted
93   - * afterwards anyway (\see hash/add.c).
94   - */
95   - tmp_value = this->value;
96   - this->value = doub->value;
97   - doub->value = tmp_value;
98   -
99   - tmp_nvalue = this->nvalue;
100   - this->nvalue = doub->nvalue;
101   - doub->nvalue = tmp_nvalue;
102   -}
103   -
104   -TR_INIT_IFACE(TR_Class, hashValueCtor, hashValueDtor, NULL);
105   -TR_INIT_IFACE(Hashable, hashValueGetHash, hashValueHandleDouble);
106   -TR_CREATE_CLASS(HashValue, NULL, TR_IF(TR_Class), TR_IF(Hashable));
107   -
108   -// vim: set ts=4 sw=4:
... ... @@ -24,10 +24,10 @@
24 24 #include <stdlib.h>
25 25 #include <string.h>
26 26
27   -#include <trbase.h>
28   -#include <trhash.h>
  27 +#include "trbase.h"
  28 +#include "trhash.h"
  29 +#include "trdata.h"
29 30
30   -#include "hash.h"
31 31 #include "http/header.h"
32 32
33 33 static
... ... @@ -99,7 +99,7 @@ httpHeaderHandleDouble(void * _this, void * _double)
99 99 }
100 100
101 101 TR_INIT_IFACE(TR_Class, httpHeaderCtor, httpHeaderDtor, NULL);
102   -TR_INIT_IFACE(Hashable, httpHeaderGetHash, httpHeaderHandleDouble);
103   -TR_CREATE_CLASS(HttpHeader, NULL, TR_IF(TR_Class), TR_IF(Hashable));
  102 +TR_INIT_IFACE(TR_Hashable, httpHeaderGetHash, httpHeaderHandleDouble);
  103 +TR_CREATE_CLASS(HttpHeader, NULL, TR_IF(TR_Class), TR_IF(TR_Hashable));
104 104
105 105 // vim: set ts=4 sw=4:
... ...
... ... @@ -31,7 +31,7 @@
31 31 #include <unistd.h>
32 32
33 33 #include "trbase.h"
34   -#include "hash.h"
  34 +#include "trdata.h"
35 35 #include "http/message.h"
36 36
37 37
... ... @@ -45,7 +45,7 @@ httpMessageCtor(void * _this, va_list * params)
45 45 this->version = TR_calloc(1, strlen(version)+1);
46 46 strcpy(this->version, version);
47 47
48   - this->header = TR_new(Hash);
  48 + this->header = TR_new(TR_Hash);
49 49
50 50 return 0;
51 51 }
... ...
... ... @@ -29,7 +29,7 @@
29 29 #include "http/header.h"
30 30
31 31 #include "trbase.h"
32   -#include "hash.h"
  32 +#include "trdata.h"
33 33
34 34 char
35 35 httpMessageHasKeepAlive(HttpMessage message)
... ... @@ -38,7 +38,7 @@ httpMessageHasKeepAlive(HttpMessage message)
38 38 size_t size;
39 39 char * value;
40 40
41   - header = hashGet(message->header, CSTRA("connection"));
  41 + header = TR_hashGet(message->header, CSTRA("connection"));
42 42
43 43 if (NULL == header) {
44 44 return 0;
... ...
... ... @@ -24,11 +24,11 @@
24 24 #include <string.h>
25 25 #include <sys/types.h>
26 26
  27 +#include "trdata.h"
27 28 #include "http/message.h"
28 29 #include "http/response.h"
29 30 #include "http/header.h"
30 31 #include "http/interface/http_intro.h"
31   -#include "hash.h"
32 32
33 33 static size_t size;
34 34
... ... @@ -45,7 +45,7 @@ httpMessageHeaderSizeGet(HttpMessage message)
45 45 {
46 46 size = httpIntroSizeGet(message);
47 47
48   - hashEach(message->header, addHeaderSize);
  48 + TR_hashEach(message->header, addHeaderSize);
49 49 size += 2;
50 50
51 51 return size;
... ...
... ... @@ -24,10 +24,10 @@
24 24 #include <string.h>
25 25 #include <stdio.h>
26 26
  27 +#include "trdata.h"
27 28 #include "http/response.h"
28 29 #include "http/header.h"
29 30 #include "http/interface/http_intro.h"
30   -#include "hash.h"
31 31
32 32 static char * string;
33 33
... ... @@ -46,7 +46,7 @@ httpMessageHeaderToString(HttpMessage response, char * _string)
46 46
47 47 string = httpIntroToString(response, _string);
48 48
49   - hashEach(message->header, addHeaderString);
  49 + TR_hashEach(message->header, addHeaderString);
50 50
51 51 *string++ = '\r';
52 52 *string++ = '\n';
... ...
... ... @@ -26,11 +26,10 @@
26 26
27 27 #include "trbase.h"
28 28 #include "trio.h"
  29 +#include "trdata.h"
29 30 #include "http/parser.h"
30   -#include "queue.h"
31 31 #include "http/request.h"
32 32 #include "http/response.h"
33   -#include "cbuf.h"
34 33
35 34
36 35 static
... ... @@ -39,13 +38,13 @@ httpParserCtor(void * _this, va_list * params)
39 38 {
40 39 HttpParser this = _this;
41 40
42   - this->buffer = va_arg(* params, Cbuf);
  41 + this->buffer = va_arg(* params, TR_Cbuf);
43 42
44 43 if (NULL == this->buffer) {
45 44 return -1;
46 45 }
47 46
48   - this->queue = TR_new(Queue);
  47 + this->queue = TR_new(TR_Queue);
49 48
50 49 return 0;
51 50 }
... ... @@ -59,7 +58,7 @@ httpParserDtor(void * _this)
59 58 TR_delete(this->queue);
60 59
61 60 if (TRUE == this->ourLock)
62   - cbufRelease(this->buffer);
  61 + TR_cbufRelease(this->buffer);
63 62
64 63 TR_MEM_FREE(this->incomplete);
65 64 TR_delete(this->current);
... ...
... ... @@ -23,12 +23,11 @@
23 23 #include <stdlib.h>
24 24 #include <sys/types.h>
25 25
  26 +#include "trbase.h"
  27 +
26 28 #include "http/header.h"
27 29 #include "http/message.h"
28 30 #include "http/parser.h"
29   -#include "cbuf.h"
30   -
31   -#include "trbase.h"
32 31
33 32 size_t
34 33 httpParserBody(HttpParser this, const char * buf, size_t nbuf)
... ...
... ... @@ -25,11 +25,11 @@
25 25 #include <sys/types.h>
26 26
27 27 #include "trbase.h"
  28 +#include "trdata.h"
28 29 #include "http/header.h"
29 30 #include "http/parser.h"
30 31 #include "http/message.h"
31 32 #include "http/request.h"
32   -#include "hash.h"
33 33
34 34 void
35 35 httpParserHeader(
... ... @@ -88,15 +88,15 @@ httpParserHeader(
88 88 nval = pair-eqsign-1;
89 89 val = (0 != nval)? eqsign+1 : NULL;
90 90
91   - hashAdd(request->cookies,
92   - TR_new(HashValue, key, eqsign-key, val, nval));
  91 + TR_hashAdd(request->cookies,
  92 + TR_new(TR_HashValue, key, eqsign-key, val, nval));
93 93
94 94 pair++;
95 95 togo -= (pair - eqsign);
96 96 }
97 97 }
98 98
99   - hashAdd(current->header,
  99 + TR_hashAdd(current->header,
100 100 TR_new(HttpHeader, name, nname, value, lend - value));
101 101 }
102 102
... ...
... ... @@ -23,10 +23,10 @@
23 23 #include <string.h>
24 24 #include <sys/types.h>
25 25
  26 +#include "trbase.h"
  27 +#include "trdata.h"
26 28 #include "http/parser.h"
27 29 #include "http/request.h"
28   -#include "hash.h"
29   -#include "trbase.h"
30 30
31 31 #include "utils/http.h"
32 32
... ... @@ -63,8 +63,8 @@ httpParserPostVars(HttpParser this)
63 63 value = (0 != nvalue)? eqsign+1 : NULL;
64 64 nvalue = urldecode(value, nvalue);
65 65
66   - hashAdd(request->post,
67   - TR_new(HashValue, key, eqsign-key, value, nvalue));
  66 + TR_hashAdd(request->post,
  67 + TR_new(TR_HashValue, key, eqsign-key, value, nvalue));
68 68
69 69 pair++;
70 70 togo -= (pair - eqsign);
... ...
... ... @@ -25,9 +25,9 @@
25 25 #include <sys/types.h>
26 26
27 27 #include "trbase.h"
  28 +#include "trdata.h"
28 29 #include "http/parser.h"
29 30 #include "http/request.h"
30   -#include "hash.h"
31 31
32 32 void
33 33 httpParserRequestVars(HttpParser this)
... ... @@ -62,8 +62,8 @@ httpParserRequestVars(HttpParser this)
62 62 nvalue = delim-eqsign-1;
63 63 value = (0 != nvalue)? eqsign+1 : NULL;
64 64
65   - hashAdd(request->get,
66   - TR_new(HashValue, key, eqsign-key, value, nvalue));
  65 + TR_hashAdd(request->get,
  66 + TR_new(TR_HashValue, key, eqsign-key, value, nvalue));
67 67 }
68 68 }
69 69
... ...
... ... @@ -24,8 +24,7 @@
24 24
25 25 #include "trbase.h"
26 26 #include "trio.h"
27   -#include "cbuf.h"
28   -#include "queue.h"
  27 +#include "trdata.h"
29 28
30 29 #include "http/parser.h"
31 30 #include "http/header.h"
... ... @@ -41,22 +40,22 @@ httpParserParse(void * _this, TR_Stream st)
41 40 char * line;
42 41 char * line_end;
43 42
44   - if (cbufIsLocked(this->buffer)) {
  43 + if (TR_cbufIsLocked(this->buffer)) {
45 44 if (FALSE == this->ourLock)
46 45 return 0;
47 46 }
48 47 else {
49   - cbufLock(this->buffer);
  48 + TR_cbufLock(this->buffer);
50 49 this->ourLock = TRUE;
51 50 }
52 51
53 52 if (NULL != this->incomplete) {
54   - cbufSetData(this->buffer, this->incomplete, this->isize);
  53 + TR_cbufSetData(this->buffer, this->incomplete, this->isize);
55 54 TR_MEM_FREE(this->incomplete);
56 55 }
57 56
58   - if (0 > (read = cbufRead(this->buffer, st))) {
59   - cbufRelease(this->buffer);
  57 + if (0 > (read = TR_cbufRead(this->buffer, st))) {
  58 + TR_cbufRelease(this->buffer);
60 59 this->ourLock = FALSE;
61 60 return read;
62 61 }
... ... @@ -64,27 +63,27 @@ httpParserParse(void * _this, TR_Stream st)
64 63 while (cont) {
65 64 switch(this->state) {
66 65 case HTTP_MESSAGE_GARBAGE:
67   - cbufSkipNonAlpha(this->buffer);
68   - if (! cbufIsEmpty(this->buffer)) {
  66 + TR_cbufSkipNonAlpha(this->buffer);
  67 + if (! TR_cbufIsEmpty(this->buffer)) {
69 68 this->state = HTTP_MESSAGE_START;
70 69 }
71 70 else {
72   - cbufRelease(this->buffer);
  71 + TR_cbufRelease(this->buffer);
73 72 this->ourLock = FALSE;
74 73 cont = 0;
75 74 break;
76 75 }
77 76
78 77 case HTTP_MESSAGE_START:
79   - if (NULL == (line = cbufGetLine(this->buffer, &line_end))) {
80   - if (! cbufIsEmpty(this->buffer)) {
  78 + if (NULL == (line = TR_cbufGetLine(this->buffer, &line_end))) {
  79 + if (! TR_cbufIsEmpty(this->buffer)) {
81 80 this->isize = this->buffer->bused;
82 81 this->incomplete = TR_malloc(this->isize);
83 82 memcpy(this->incomplete,
84   - cbufGetData(this->buffer, this->isize),
  83 + TR_cbufGetData(this->buffer, this->isize),
85 84 this->isize);
86 85 }
87   - cbufRelease(this->buffer);
  86 + TR_cbufRelease(this->buffer);
88 87 this->ourLock = FALSE;
89 88 cont = 0;
90 89 break;
... ... @@ -92,7 +91,7 @@ httpParserParse(void * _this, TR_Stream st)
92 91
93 92 httpParserNewMessage(this, line, line_end);
94 93 if (NULL == this->current) {
95   - cbufRelease(this->buffer);
  94 + TR_cbufRelease(this->buffer);
96 95 this->ourLock = FALSE;
97 96 return -2; // a server error occured can't process...
98 97 }
... ... @@ -101,15 +100,15 @@ httpParserParse(void * _this, TR_Stream st)
101 100 this->state = HTTP_MESSAGE_INTRO_DONE;
102 101
103 102 case HTTP_MESSAGE_INTRO_DONE:
104   - if (NULL == (line = cbufGetLine(this->buffer, &line_end))) {
105   - if (! cbufIsEmpty(this->buffer)) {
  103 + if (NULL == (line = TR_cbufGetLine(this->buffer, &line_end))) {
  104 + if (! TR_cbufIsEmpty(this->buffer)) {
106 105 this->isize = this->buffer->bused;
107 106 this->incomplete = TR_malloc(this->isize);
108 107 memcpy(this->incomplete,
109   - cbufGetData(this->buffer, this->isize),
  108 + TR_cbufGetData(this->buffer, this->isize),
110 109 this->isize);
111 110 }
112   - cbufRelease(this->buffer);
  111 + TR_cbufRelease(this->buffer);
113 112 this->ourLock = FALSE;
114 113 cont = 0;
115 114 break;
... ... @@ -126,18 +125,18 @@ httpParserParse(void * _this, TR_Stream st)
126 125 if (this->current->dbody == this->current->nbody) {
127 126 this->state = HTTP_MESSAGE_DONE;
128 127 } else {
129   - if (cbufIsEmpty(this->buffer)) {
130   - cbufRelease(this->buffer);
  128 + if (TR_cbufIsEmpty(this->buffer)) {
  129 + TR_cbufRelease(this->buffer);
131 130 this->ourLock = FALSE;
132 131 cont = 0;
133 132 break;
134 133 }
135 134
136   - cbufIncRead(
  135 + TR_cbufIncRead(
137 136 this->buffer,
138 137 httpParserBody(
139 138 this,
140   - cbufGetRead(this->buffer),
  139 + TR_cbufGetRead(this->buffer),
141 140 this->buffer->bused));
142 141
143 142 break;
... ... @@ -145,7 +144,7 @@ httpParserParse(void * _this, TR_Stream st)
145 144
146 145 case HTTP_MESSAGE_DONE:
147 146 {
148   - HttpHeader enc = hashGet(
  147 + HttpHeader enc = TR_hashGet(
149 148 this->current->header,
150 149 CSTRA("content-type"));
151 150
... ... @@ -164,7 +163,7 @@ httpParserParse(void * _this, TR_Stream st)
164 163 /**
165 164 * enqueue current request
166 165 */
167   - queuePut(this->queue, this->current);
  166 + TR_queuePut(this->queue, this->current);
168 167 this->current = NULL;
169 168
170 169 /**
... ...
... ... @@ -26,7 +26,7 @@
26 26 #include <sys/types.h>
27 27
28 28 #include "trbase.h"
29   -#include "hash.h"
  29 +#include "trdata.h"
30 30 #include "http/interface/http_intro.h"
31 31 #include "http/request.h"
32 32
... ... @@ -66,9 +66,9 @@ httpRequestCtor(void * _this, va_list * params)
66 66 return -1;
67 67 }
68 68
69   - this->get = TR_new(Hash);
70   - this->post = TR_new(Hash);
71   - this->cookies = TR_new(Hash);
  69 + this->get = TR_new(TR_Hash);
  70 + this->post = TR_new(TR_Hash);
  71 + this->cookies = TR_new(TR_Hash);
72 72
73 73 return 0;
74 74 }
... ...
... ... @@ -23,10 +23,10 @@
23 23 #include <sys/types.h>
24 24
25 25 #include "trbase.h"
  26 +#include "trdata.h"
26 27 #include "http/response.h"
27 28 #include "http/message.h"
28 29 #include "http/header.h"
29   -#include "hash.h"
30 30
31 31 HttpResponse
32 32 httpResponse304(
... ... @@ -43,11 +43,11 @@ httpResponse304(
43 43 message->nbody = 0;
44 44 message->body = NULL;
45 45
46   - hashAdd(message->header,
  46 + TR_hashAdd(message->header,
47 47 TR_new(HttpHeader, CSTRA("Content-Type"), mime, nmime));
48   - hashAdd(message->header,
  48 + TR_hashAdd(message->header,
49 49 TR_new(HttpHeader, CSTRA("ETag"), etag, netag));
50   - hashAdd(message->header,
  50 + TR_hashAdd(message->header,
51 51 TR_new(HttpHeader, CSTRA("Last-Modified"), mtime, nmtime));
52 52
53 53 return response;
... ...
... ... @@ -26,10 +26,10 @@
26 26 #include <sys/types.h>
27 27
28 28 #include "trbase.h"
  29 +#include "trdata.h"
29 30 #include "http/response.h"
30 31 #include "http/message.h"
31 32 #include "http/header.h"
32   -#include "hash.h"
33 33
34 34 #define RESP_DATA "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n" \
35 35 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n" \
... ... @@ -49,7 +49,7 @@ httpResponse404()
49 49 response = TR_new(HttpResponse, "HTTP/1.1", 404, "Not Found");
50 50 message = (HttpMessage)response;
51 51
52   - hashAdd(message->header,
  52 + TR_hashAdd(message->header,
53 53 TR_new(HttpHeader, CSTRA("Content-Type"), CSTRA("text/html")));
54 54
55 55 message->nbody = sizeof(RESP_DATA) - 1;
... ...
... ... @@ -26,10 +26,10 @@
26 26 #include <sys/types.h>
27 27
28 28 #include "trbase.h"
  29 +#include "trdata.h"
29 30 #include "http/response.h"
30 31 #include "http/message.h"
31 32 #include "http/header.h"
32   -#include "hash.h"
33 33
34 34 #define RESP_DATA "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n" \
35 35 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n" \
... ... @@ -49,7 +49,7 @@ httpResponse500()
49 49 response = TR_new(HttpResponse, "HTTP/1.1", 500, "Internal Server Error");
50 50 message = (HttpMessage)response;
51 51
52   - hashAdd(message->header,
  52 + TR_hashAdd(message->header,
53 53 TR_new(HttpHeader, CSTRA("Content-Type"), CSTRA("text/html")));
54 54
55 55 message->nbody = sizeof(RESP_DATA) - 1;
... ...
... ... @@ -43,11 +43,11 @@
43 43
44 44 #include "trbase.h"
45 45 #include "trio.h"
  46 +#include "trdata.h"
46 47 #include "http/response.h"
47 48 #include "http/message.h"
48 49 #include "http/header.h"
49 50 #include "utils/http.h"
50   -#include "hash.h"
51 51
52 52 #include "asset.h"
53 53
... ... @@ -74,14 +74,14 @@ httpResponseAsset(const char * fname, size_t nfname, time_t exptime)
74 74
75 75 nexpires = rfc1123Gmt(expires, sizeof(expires), &exptime);
76 76
77   - hashAdd(message->header,
  77 + TR_hashAdd(message->header,
78 78 TR_new(HttpHeader, CSTRA("Content-Type"),
79 79 asset->mime_type, asset->nmime_type));
80   - hashAdd(message->header,
  80 + TR_hashAdd(message->header,
81 81 TR_new(HttpHeader, CSTRA("ETag"), asset->etag, asset->netag));
82   - hashAdd(message->header,
  82 + TR_hashAdd(message->header,
83 83 TR_new(HttpHeader, CSTRA("Expires"), expires, nexpires));
84   - hashAdd(message->header,
  84 + TR_hashAdd(message->header,
85 85 TR_new(HttpHeader, CSTRA("Last-Modified"),
86 86 asset->mtime, asset->nmtime));
87 87
... ...
... ... @@ -27,11 +27,11 @@
27 27 #include <sys/types.h>
28 28
29 29 #include "trbase.h"
  30 +#include "trdata.h"
30 31 #include "http/response.h"
31 32 #include "http/message.h"
32 33 #include "http/header.h"
33 34 #include "session.h"
34   -#include "hash.h"
35 35
36 36 HttpResponse
37 37 httpResponseJson(const char * body, size_t nbody)
... ... @@ -42,7 +42,7 @@ httpResponseJson(const char * body, size_t nbody)
42 42 response = TR_new(HttpResponse, "HTTP/1.1", 200, "OK");
43 43 message = (HttpMessage)response;
44 44
45   - hashAdd(message->header,
  45 + TR_hashAdd(message->header,
46 46 TR_new(
47 47 HttpHeader,
48 48 CSTRA("Content-Type"),
... ...
... ... @@ -32,8 +32,6 @@
32 32
33 33 #include "trbase.h"
34 34 #include "trio.h"
35   -#include "hash.h"
36   -#include "queue.h"
37 35 #include "http/worker.h"
38 36 #include "http/parser.h"
39 37 #include "http/writer.h"
... ... @@ -49,12 +47,12 @@ httpWorkerCtor(void * _this, va_list * params)
49 47 this->id = TR_malloc(strlen(id) + 1);
50 48 strcpy(this->id, id);
51 49
52   - this->asset_pool = TR_new(Hash);
  50 + this->asset_pool = TR_new(TR_Hash);
53 51
54 52 sprintf(cbuf_id, "%s_%s", "parser", id);
55   - this->pbuf = TR_new(Cbuf, cbuf_id, PARSER_MAX_BUF);
  53 + this->pbuf = TR_new(TR_Cbuf, cbuf_id, PARSER_MAX_BUF);
56 54
57   - this->additional_headers = TR_new(Queue);
  55 + this->additional_headers = TR_new(TR_Queue);
58 56
59 57 this->parser = TR_new(HttpParser, this->pbuf);
60 58 this->writer = TR_new(HttpWriter);
... ... @@ -91,7 +89,7 @@ httpWorkerClone(void * _this, void * _base)
91 89 this->asset_pool = base->asset_pool;
92 90 this->application_adapter = base->application_adapter;
93 91
94   - this->additional_headers = TR_new(Queue);
  92 + this->additional_headers = TR_new(TR_Queue);
95 93
96 94 this->parser = TR_new(HttpParser, base->pbuf);
97 95 /*
... ...
... ... @@ -23,10 +23,10 @@
23 23 #include <sys/types.h>
24 24
25 25 #include "trbase.h"
  26 +#include "trdata.h"
26 27 #include "http/message.h"
27 28 #include "http/header.h"
28 29 #include "http/worker.h"
29   -#include "hash.h"
30 30 #include "utils/http.h"
31 31 #include "config.h"
32 32
... ... @@ -38,15 +38,15 @@ httpWorkerAddCommonHeader(HttpWorker this)
38 38 size_t nbuf;
39 39
40 40 if (httpMessageHasKeepAlive((HttpMessage)this->current_request)) {
41   - hashAdd(this->current_response->header,
  41 + TR_hashAdd(this->current_response->header,
42 42 TR_new(HttpHeader, CSTRA("Connection"), CSTRA("Keep-Alive")));
43 43 }
44 44 else {
45   - hashAdd(this->current_response->header,
  45 + TR_hashAdd(this->current_response->header,
46 46 TR_new(HttpHeader, CSTRA("Connection"), CSTRA("Close")));
47 47 }
48 48
49   - hashAdd(this->current_response->header,
  49 + TR_hashAdd(this->current_response->header,
50 50 TR_new(HttpHeader, CSTRA("Server"), CSTRA(PACKAGE_STRING)));
51 51
52 52 switch(((HttpResponse)this->current_response)->status) {
... ... @@ -55,12 +55,12 @@ httpWorkerAddCommonHeader(HttpWorker this)
55 55
56 56 default:
57 57 nbuf = sprintf(buffer, "%d", this->current_response->nbody);
58   - hashAdd(this->current_response->header,
  58 + TR_hashAdd(this->current_response->header,
59 59 TR_new(HttpHeader, CSTRA("Content-Length"), buffer, nbuf));
60 60 }
61 61
62 62 nbuf = rfc1123GmtNow(buffer, sizeof(buffer));
63   - hashAdd(this->current_response->header,
  63 + TR_hashAdd(this->current_response->header,
64 64 TR_new(HttpHeader, CSTRA("Date"), buffer, nbuf));
65 65 }
66 66
... ...
... ... @@ -22,20 +22,20 @@
22 22
23 23 #include <sys/types.h>
24 24
  25 +#include "trdata.h"
25 26 #include "http/message.h"
26 27 #include "http/header.h"
27 28 #include "http/worker.h"
28   -#include "queue.h"
29 29
30 30
31 31 void
32 32 httpWorkerAddComputedHeader(HttpWorker this)
33 33 {
34   - HttpHeader header = (HttpHeader)queueGet(this->additional_headers);
  34 + HttpHeader header = (HttpHeader)TR_queueGet(this->additional_headers);
35 35
36 36 while(NULL != header) {
37   - hashAdd(this->current_response->header, header);
38   - header = (HttpHeader)queueGet(this->additional_headers);
  37 + TR_hashAdd(this->current_response->header, header);
  38 + header = (HttpHeader)TR_queueGet(this->additional_headers);
39 39 }
40 40 }
41 41
... ...
... ... @@ -24,12 +24,12 @@
24 24 #include <time.h>
25 25
26 26 #include "trbase.h"
  27 +#include "trdata.h"
27 28 #include "http/header.h"
28 29 #include "http/message.h"
29 30 #include "http/request.h"
30 31 #include "http/response.h"
31 32 #include "http/worker.h"
32   -#include "hash.h"
33 33
34 34 HttpMessage
35 35 httpWorkerGetAsset(HttpWorker this, const char * fname)
... ... @@ -41,7 +41,7 @@ httpWorkerGetAsset(HttpWorker this, const char * fname)
41 41
42 42 size_t nfname = strlen(fname);
43 43
44   - header = hashGet(
  44 + header = TR_hashGet(
45 45 ((HttpMessage)this->current_request)->header,
46 46 CSTRA("If-None-Match"));
47 47
... ...
... ... @@ -28,7 +28,7 @@
28 28 #include <sys/time.h>
29 29
30 30 #include "trbase.h"
31   -#include "queue.h"
  31 +#include "trdata.h"
32 32
33 33 #include "http/worker.h"
34 34 #include "http/header.h"
... ... @@ -57,8 +57,8 @@ httpWorkerProcess(HttpWorker this, TR_Stream st)
57 57 }
58 58
59 59 if (0 < requests) {
60   - while (! queueEmpty(this->parser->queue)) {
61   - this->current_request = queueGet(this->parser->queue);
  60 + while (! TR_queueEmpty(this->parser->queue)) {
  61 + this->current_request = TR_queueGet(this->parser->queue);
62 62 this->current_response = NULL;
63 63
64 64 /*
... ... @@ -124,7 +124,7 @@ httpWorkerProcess(HttpWorker this, TR_Stream st)
124 124 httpWorkerAddCommonHeader(this);
125 125 httpWorkerAddComputedHeader(this);
126 126 TR_delete(this->current_request);
127   - queuePut(this->writer->queue, this->current_response);
  127 + TR_queuePut(this->writer->queue, this->current_response);
128 128 this->current_response = NULL;
129 129 }
130 130 }
... ...
... ... @@ -24,7 +24,7 @@
24 24
25 25 #include "trbase.h"
26 26 #include "trio.h"
27   -#include "queue.h"
  27 +#include "trdata.h"
28 28 #include "http/writer.h"
29 29
30 30 static
... ... @@ -33,7 +33,7 @@ httpWriterCtor(void * _this, va_list * params)
33 33 {
34 34 HttpWriter this = _this;
35 35
36   - this->queue = TR_new(Queue);
  36 + this->queue = TR_new(TR_Queue);
37 37
38 38 return 0;
39 39 }
... ...
... ... @@ -27,7 +27,7 @@
27 27
28 28 #include "http/message.h"
29 29 #include "trio.h"
30   -#include "queue.h"
  30 +#include "trdata.h"
31 31 #include "http/writer.h"
32 32
33 33
... ... @@ -43,8 +43,8 @@ httpWriterWrite(void * _this, TR_Stream st)
43 43
44 44 case HTTP_WRITER_GET:
45 45
46   - if (! queueEmpty(this->queue)) {
47   - this->current = queueGet(this->queue);
  46 + if (! TR_queueEmpty(this->queue)) {
  47 + this->current = TR_queueGet(this->queue);
48 48
49 49 this->written = 0;
50 50 this->nheader = httpMessageHeaderSizeGet(this->current);
... ...
Please register or login to post a comment