Commit 1307358fbdcb52eed419bc561f55a1c00b95187f

Authored by Georg Hopp
1 parent 85ecaa4d

moved the class and memory management into a separate project libtrbase / prefix…

… all of the public interface of libtrbase with TR_
Showing 100 changed files with 280 additions and 1094 deletions

Too many changes to show.

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

... ... @@ -18,8 +18,9 @@ AC_CONFIG_MACRO_DIR([m4])
18 18 m4_include([m4/gcov.m4])
19 19 AC_TDD_GCOV
20 20
21   -m4_include([m4/memopt.m4])
22   -AC_MEM_OPT
  21 +m4_include([m4/trlibs.m4])
  22 +AC_TRLIBS_ROOT
  23 +AC_NEED_TRBASE
23 24
24 25 m4_include([m4/chkamd.m4])
25 26 AC_CHK_AMD
... ... @@ -89,7 +90,6 @@ AC_CONFIG_FILES([Makefile
89 90 src/asset/Makefile
90 91 src/auth/Makefile
91 92 src/cbuf/Makefile
92   - src/class/Makefile
93 93 src/hash/Makefile
94 94 src/queue/Makefile
95 95 src/http/Makefile
... ...
... ... @@ -23,12 +23,12 @@
23 23 #ifndef __APPLICATION_ADAPTER_HTTP_H__
24 24 #define __APPLICATION_ADAPTER_HTTP_H__
25 25
26   -#include "class.h"
  26 +#include "trbase.h"
27 27 #include "router.h"
28 28 #include "application/application.h"
29 29
30 30
31   -CLASS(ApplicationAdapterHttp) {
  31 +TR_CLASS(ApplicationAdapterHttp) {
32 32 Application application;
33 33 Router router;
34 34 };
... ...
... ... @@ -25,7 +25,7 @@
25 25
26 26 #include <sys/types.h>
27 27
28   -#include "class.h"
  28 +#include "trbase.h"
29 29
30 30 #include "session.h"
31 31 #include "hash.h"
... ... @@ -42,7 +42,7 @@ struct randval {
42 42 int value;
43 43 };
44 44
45   -CLASS(Application) {
  45 +TR_CLASS(Application) {
46 46 Hash * active_sessions;
47 47 time_t session_time_ofs;
48 48
... ...
... ... @@ -26,12 +26,11 @@
26 26
27 27 #include <sys/types.h>
28 28
29   -#include "class.h"
30   -#include "commons.h"
  29 +#include "trbase.h"
31 30 #include "hash.h"
32 31
33 32
34   -CLASS(Asset) {
  33 +TR_CLASS(Asset) {
35 34 unsigned long hash;
36 35
37 36 char fname[2049];
... ...
... ... @@ -42,7 +42,7 @@
42 42 #ifndef __AUTH_AUTH_H__
43 43 #define __AUTH_AUTH_H__
44 44
45   -#include "class.h"
  45 +#include "trbase.h"
46 46 #include "uuid.h"
47 47 #include "auth.h"
48 48 #include "auth/credential.h"
... ... @@ -55,7 +55,7 @@ typedef enum e_AuthModule {
55 55
56 56 #define MAX_AUTH AUTH_STORAGE
57 57
58   -CLASS(Auth) {
  58 +TR_CLASS(Auth) {
59 59 void * auth[MAX_AUTH + 1];
60 60 };
61 61
... ...
... ... @@ -25,7 +25,7 @@
25 25
26 26 #include <sys/types.h>
27 27
28   -#include "class.h"
  28 +#include "trbase.h"
29 29
30 30 #define CRED_PWD(c) (((c)->cred).pwd)
31 31
... ... @@ -34,7 +34,7 @@ typedef enum e_CredentialType {
34 34 } CredentialType;
35 35
36 36
37   -CLASS(Credential) {
  37 +TR_CLASS(Credential) {
38 38 CredentialType type;
39 39
40 40 union {
... ...
... ... @@ -28,19 +28,15 @@
28 28 #ifndef __AUTH_INTERFACE_AUTH_H__
29 29 #define __AUTH_INTERFACE_AUTH_H__
30 30
31   -#include <stdarg.h>
32   -
33   -#include "class.h"
  31 +#include "trbase.h"
34 32 #include "uuid.h"
35 33 #include "auth/credential.h"
36 34
37 35 typedef int (* fptr_authenticate)(void *, Credential, Uuid);
38 36
39   -extern const struct interface i_Auth;
40   -
41   -struct i_Auth {
42   - const struct interface * const _;
43   - fptr_authenticate authenticate;
  37 +TR_INTERFACE(Auth) {
  38 + TR_IFID;
  39 + fptr_authenticate authenticate;
44 40 };
45 41
46 42 extern int authenticate(void *, Credential, Uuid);
... ...
... ... @@ -26,9 +26,9 @@
26 26 #include <ldap.h>
27 27 #include <sys/types.h>
28 28
29   -#include "class.h"
  29 +#include "trbase.h"
30 30
31   -CLASS(AuthLdap) {
  31 +TR_CLASS(AuthLdap) {
32 32 LDAP * ldap;
33 33 char * url;
34 34 char * base_dn;
... ...
... ... @@ -27,7 +27,7 @@
27 27
28 28 #include <openssl/sha.h>
29 29
30   -#include "class.h"
  30 +#include "trbase.h"
31 31 #include "storage/storage.h"
32 32
33 33
... ... @@ -35,7 +35,7 @@
35 35 #define HASH_SIZE SHA512_DIGEST_LENGTH
36 36
37 37
38   -CLASS(AuthStorage) {
  38 +TR_CLASS(AuthStorage) {
39 39 Storage store;
40 40 };
41 41
... ...
... ... @@ -34,16 +34,13 @@
34 34 #include <string.h>
35 35 #include <sys/types.h>
36 36
37   -#include "class.h"
  37 +#include "trbase.h"
38 38 #include "stream.h"
39 39
40   -#include "commons.h"
41   -#include "utils/memory.h"
42   -
43 40 #define ECBUFOVFL 100
44 41
45 42
46   -CLASS(Cbuf) {
  43 +TR_CLASS(Cbuf) {
47 44 char * shm_name; // shared memory identifier
48 45
49 46 char * data;
... ...
1   -#ifndef __CLASS_H__
2   -#define __CLASS_H__
3   -
4   -#include "class/class.h"
5   -#include "class/interface.h"
6   -#include "class/interface/class.h"
7   -
8   -#endif // __CLASS_H__
9   -
10   -// vim: set ts=4 sw=4:
1   -/**
2   - * \file
3   - * My own class implementation for C. It combines a data structure
4   - * with a set of dynamically linked methods defined by an interface. A
5   - * dynamically linked method will be called via a selector method which in
6   - * turn gets the implementation stored in the class.
7   - *
8   - * \author Georg Hopp
9   - *
10   - * \copyright
11   - * Copyright © 2012 Georg Hopp
12   - *
13   - * This program is free software: you can redistribute it and/or modify
14   - * it under the terms of the GNU General Public License as published by
15   - * the Free Software Foundation, either version 3 of the License, or
16   - * (at your option) any later version.
17   - *
18   - * This program is distributed in the hope that it will be useful,
19   - * but WITHOUT ANY WARRANTY; without even the implied warranty of
20   - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21   - * GNU General Public License for more details.
22   - *
23   - * You should have received a copy of the GNU General Public License
24   - * along with this program. If not, see <http://www.gnu.org/licenses/>.
25   - */
26   -
27   -#ifndef __CLASS_CLASS_H__
28   -#define __CLASS_CLASS_H__
29   -
30   -#include <stdarg.h>
31   -#include <sys/types.h>
32   -#include <string.h>
33   -#include <assert.h>
34   -
35   -#include "class/interface.h"
36   -
37   -#ifndef _ISOC99_SOURCE
38   -#define _ISOC99_SOURCE
39   -#endif
40   -
41   -#define CLASS_MAGIC 0xFEFE
42   -
43   -#define CLASS(name) \
44   - struct c_##name; \
45   - typedef struct c_##name * name; \
46   - extern struct class * const _##name; \
47   - struct c_##name
48   -
49   -#define EXTENDS(parent) \
50   - const char _[sizeof(struct c_##parent)]
51   -
52   -#define _NULL NULL
53   -#define CREATE_CLASS(name,_parent,...) \
54   - static struct class c_##name; \
55   - static class_ptr _classInit##name##_(void) { \
56   - c_##name.parent = _##_parent; \
57   - c_##name.init = NULL; \
58   - return &c_##name; \
59   - } \
60   - static struct class c_##name = { \
61   - CLASS_MAGIC, \
62   - NULL, \
63   - sizeof(struct c_##name), \
64   - _classInit##name##_, \
65   - INIT_IFACE_IMPL(__VA_ARGS__) \
66   - }; struct class * const _##name = &c_##name; \
67   - struct c_##name##_object { void * class; struct c_##name data; }
68   -
69   -
70   -/**
71   - * create a static instance of a class.
72   - * \todo
73   - * this macro requires to close the initializer
74   - * with an extra curly brancket. This is not nice...find a
75   - * way to prevent this.
76   - */
77   -#define INSTANCE(class, name) \
78   - struct c_##class##_object _##name; \
79   - class name = &(_##name.data); \
80   - struct c_##class##_object _##name = { \
81   - &c_##class,
82   -
83   -#define INIT_CLASS(class) ((class)->init? (class)->init() : (class))
84   -#define GET_CLASS(object) (INIT_CLASS(*(class_ptr *)((void*)(object) - sizeof(void*))))
85   -#define IFACE_GET(class,iface) (interfaceGet(&((class)->impl),(iface)))
86   -#define HAS_PARENT(class) (NULL != ((class)->parent) && INIT_CLASS((class)->parent))
87   -
88   -#define IS_OBJECT(obj) ((GET_CLASS((obj)))->magic == CLASS_MAGIC)
89   -#define INSTANCE_OF(class,obj) ((GET_CLASS((obj))) == _##class)
90   -
91   -/**
92   - * \todo actually i use gcc feature ## for variadoc... think about
93   - * a way to make this standard.
94   - */
95   -#define _CALL(_class,_iface,method,...) \
96   - do { \
97   - class_ptr class = _class; \
98   - iface = (struct i_##_iface *)IFACE_GET(class, &i_##_iface); \
99   - while ((NULL == iface || NULL == iface->method) && HAS_PARENT(class)) { \
100   - class = class->parent; \
101   - iface = (struct i_##_iface *)IFACE_GET(class, &i_##_iface); \
102   - } \
103   - assert(NULL != iface->method); \
104   - } while(0)
105   -
106   -#define CALL(object,_iface,method,...) \
107   - do { \
108   - struct i_##_iface * iface; \
109   - _CALL(GET_CLASS(object), _iface, method, ##__VA_ARGS__); \
110   - iface->method(object, ##__VA_ARGS__); \
111   - } while(0)
112   -
113   -#define RETCALL(object,_iface,method,ret,...) \
114   - do { \
115   - struct i_##_iface * iface; \
116   - _CALL(GET_CLASS(object), _iface, method, ##__VA_ARGS__); \
117   - ret = iface->method(object, ##__VA_ARGS__); \
118   - } while(0)
119   -
120   -#define PARENTCALL(object,_iface,method,...) \
121   - do { \
122   - struct i_##_iface * iface; \
123   - class_ptr pc_class = GET_CLASS((object)); \
124   - assert(HAS_PARENT(pc_class)); \
125   - _CALL(pc_class->parent, _iface, method, ##__VA_ARGS__); \
126   - iface->method(object, ##__VA_ARGS__); \
127   - } while(0)
128   -
129   -
130   -struct class;
131   -typedef struct class * class_ptr;
132   -typedef class_ptr (* fptr_classInit)(void);
133   -struct class {
134   - const int magic;
135   - class_ptr parent;
136   - size_t object_size;
137   - fptr_classInit init;
138   - struct iface_impl impl;
139   -};
140   -
141   -#endif // __CLASS_CLASS_H__
142   -
143   -// vim: set ts=4 sw=4:
1   -/**
2   - * \file
3   - * Interface definition code. Each interface is a set of selector functions
4   - * as well as a data structure where the concrete implementation will be stored.
5   - * This structure is the intergrated in the class that implements the
6   - * interface.
7   - *
8   - * \author Georg Hopp
9   - *
10   - * \copyright
11   - * Copyright © 2012 Georg Hopp
12   - *
13   - * This program is free software: you can redistribute it and/or modify
14   - * it under the terms of the GNU General Public License as published by
15   - * the Free Software Foundation, either version 3 of the License, or
16   - * (at your option) any later version.
17   - *
18   - * This program is distributed in the hope that it will be useful,
19   - * but WITHOUT ANY WARRANTY; without even the implied warranty of
20   - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21   - * GNU General Public License for more details.
22   - *
23   - * You should have received a copy of the GNU General Public License
24   - * along with this program. If not, see <http://www.gnu.org/licenses/>.
25   - */
26   -
27   -#ifndef __CLASS_INTERFACE_H__
28   -#define __CLASS_INTERFACE_H__
29   -
30   -#include <sys/types.h>
31   -
32   -#define MAX_IFACE 32 // ATTENTION: every iface_impl will use MAX_IFACE * sizeof(void*)
33   -
34   -#define IFACE(name) ((const struct i_##name const*)&i_##name##_impl)
35   -#define INIT_IFACE(name,...) \
36   - static const struct i_##name i_##name##_impl = {&i_##name,__VA_ARGS__}
37   -
38   -#define NUMARGS(...) (sizeof((const void*[]){__VA_ARGS__})/sizeof(void*))
39   -#define INIT_IFACE_IMPL(...) {NUMARGS(__VA_ARGS__), 0, {__VA_ARGS__}}
40   -
41   -
42   -struct interface {
43   - const char * name;
44   - const size_t nmethods;
45   -};
46   -typedef const struct interface * iface_ptr;
47   -
48   -struct iface_impl {
49   - const size_t nimpl; // number of interface implementations
50   - char simpl; // implementations sorted??
51   - const void * impl[MAX_IFACE]; // implementations
52   -};
53   -typedef struct iface_impl * iface_impl_ptr;
54   -
55   -extern iface_ptr interfaceGet(iface_impl_ptr, const iface_ptr);
56   -
57   -#endif // __CLASS_INTERFACE_H__
58   -
59   -// vim: set ts=4 sw=4:
1   -/**
2   - * \file
3   - * Interface for class handling. Defines new, delete and clone selectors
4   - * which in turn use the ctor, dtor and clone implementation from the
5   - * class implementation.
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 __CLASS_INTERFACE_CLASS_H__
27   -#define __CLASS_INTERFACE_CLASS_H__
28   -
29   -#include <stdarg.h>
30   -
31   -#include "class/class.h"
32   -#include "class/interface.h"
33   -
34   -typedef int (* fptr_ctor)(void *, va_list *);
35   -typedef void (* fptr_dtor)(void *);
36   -typedef void (* fptr_clone)(void *, void * const);
37   -
38   -extern const struct interface i_Class;
39   -
40   -struct i_Class {
41   - const struct interface * const _;
42   - fptr_ctor ctor;
43   - fptr_dtor dtor;
44   - fptr_clone clone;
45   -};
46   -
47   -extern void * classNew(class_ptr, ...);
48   -extern void classDelete(void **);
49   -extern void * classClone(void *);
50   -
51   -#define new(class,...) classNew(_##class, ##__VA_ARGS__)
52   -#define delete(object) classDelete((void **)&(object))
53   -#define clone(object) classClone((void *)(object))
54   -
55   -/**
56   - * With this one we can create a new instance via a
57   - * intermidiary that gets the arguments.
58   - */
59   -extern void * classNewParams(class_ptr, va_list *);
60   -#define newParams(class,args) classNewParams(_##class, args)
61   -
62   -#endif // __CLASS_INTERFACE_CLASS_H__
63   -
64   -// 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 __COMMONS_H__
24   -#define __COMMONS_H__
25   -
26   -#define Bool char
27   -#define TRUE 1
28   -#define FALSE 0
29   -
30   -#ifndef MAX
31   -# define MAX(a,b) ((a)>(b)? (a) : (b))
32   -#endif
33   -
34   -#ifndef MIN
35   -# define MIN(a,b) ((a)<(b)? (a) : (b))
36   -#endif
37   -
38   -#define SWAP_FUN(a, b) ((a)^=(b),(b)^=(a),(a)^=(b))
39   -
40   -#define SWAP(type, a, b) do { \
41   - type tmp = (a); \
42   - (a) = (b); \
43   - (b) = tmp; \
44   -} while(0);
45   -
46   -#endif // __COMMONS_H__
47   -
48   -// vim: set ts=4 sw=4:
... ... @@ -23,14 +23,14 @@
23 23 #ifndef __CONFIG_H__
24 24 #define __CONFIG_H__
25 25
  26 +#include "trbase.h"
26 27 #include "hash.h"
27   -#include "class.h"
28 28 #include "config/value.h"
29 29
30 30 #define MAX_CONFIG_LINE 256
31 31
32 32
33   -CLASS(Config) {
  33 +TR_CLASS(Config) {
34 34 char * cnf_file;
35 35 Hash config;
36 36 };
... ...
... ... @@ -25,8 +25,8 @@
25 25
26 26 #include <sys/types.h>
27 27
  28 +#include "trbase.h"
28 29 #include "hash.h"
29   -#include "class.h"
30 30
31 31 #define MAX_CONFIG_LINE 256
32 32
... ... @@ -38,7 +38,7 @@ typedef enum e_ConfigValueType {
38 38 CONFIG_VALUE_STRING = 1
39 39 } ConfigValueType;
40 40
41   -CLASS(ConfigValue) {
  41 +TR_CLASS(ConfigValue) {
42 42 union {
43 43 char * string;
44 44 long long number;
... ...
... ... @@ -25,12 +25,12 @@
25 25
26 26 #include <sys/types.h>
27 27
28   -#include "class.h"
  28 +#include "trbase.h"
29 29 #include "tree.h"
30 30
31 31 #define HASH_IS_EMPTY(h) ((h)->root)
32 32
33   -CLASS(Hash) {
  33 +TR_CLASS(Hash) {
34 34 Tree root;
35 35 };
36 36
... ...
... ... @@ -24,17 +24,15 @@
24 24 #ifndef __HASH_INTERFACE_HASHABLE_H__
25 25 #define __HASH_INTERFACE_HASHABLE_H__
26 26
27   -#include "class.h"
  27 +#include "trbase.h"
28 28
29 29 typedef unsigned long (* fptr_hashableGetHash)(void *);
30 30 typedef void (* fptr_hashableHandleDouble)(void *, void *);
31 31
32   -extern const struct interface i_Hashable;
33   -
34   -struct i_Hashable {
35   - const struct interface * const _;
36   - fptr_hashableGetHash getHash;
37   - fptr_hashableHandleDouble handleDouble;
  32 +TR_INTERFACE(Hashable) {
  33 + TR_IFID;
  34 + fptr_hashableGetHash getHash;
  35 + fptr_hashableHandleDouble handleDouble;
38 36 };
39 37
40 38 extern unsigned long hashableGetHash(void *);
... ...
... ... @@ -25,9 +25,9 @@
25 25
26 26 #include <sys/types.h>
27 27
28   -#include "class.h"
  28 +#include "trbase.h"
29 29
30   -CLASS(HashValue) {
  30 +TR_CLASS(HashValue) {
31 31 unsigned long hash;
32 32
33 33 char * key;
... ...
... ... @@ -26,9 +26,9 @@
26 26 #include <time.h>
27 27 #include <sys/types.h>
28 28
29   -#include "class.h"
  29 +#include "trbase.h"
30 30
31   -CLASS(HttpCookie) {
  31 +TR_CLASS(HttpCookie) {
32 32 unsigned long hash;
33 33
34 34 char * key;
... ...
... ... @@ -27,11 +27,11 @@
27 27
28 28 #include <sys/types.h>
29 29
30   -#include "class.h"
  30 +#include "trbase.h"
31 31
32 32 #define N_VALUES 128
33 33
34   -CLASS(HttpHeader) {
  34 +TR_CLASS(HttpHeader) {
35 35 unsigned long hash;
36 36 char * name;
37 37 char * value[N_VALUES];
... ...
... ... @@ -28,15 +28,15 @@
28 28
29 29 #include <sys/types.h>
30 30
  31 +#include "trbase.h"
  32 +
31 33 typedef size_t (* fptr_httpIntroSizeGet)(void *);
32 34 typedef char * (* fptr_httpIntroToString)(void *, char *);
33 35
34   -extern const struct interface i_HttpIntro;
35   -
36   -struct i_HttpIntro {
37   - const struct interface * const _;
38   - fptr_httpIntroSizeGet sizeGet;
39   - fptr_httpIntroToString toString;
  36 +TR_INTERFACE(HttpIntro) {
  37 + TR_IFID;
  38 + fptr_httpIntroSizeGet sizeGet;
  39 + fptr_httpIntroToString toString;
40 40 };
41 41
42 42 extern size_t httpIntroSizeGet(void *);
... ...
... ... @@ -24,12 +24,12 @@
24 24 #ifndef __HTTP_MESSAGE__
25 25 #define __HTTP_MESSAGE__
26 26
27   -#include "class.h"
  27 +#include "trbase.h"
28 28 #include "hash.h"
29 29 #include "stream.h"
30 30 #include "asset.h"
31 31
32   -CLASS(HttpMessage) {
  32 +TR_CLASS(HttpMessage) {
33 33 char * version;
34 34
35 35 Hash header;
... ...
... ... @@ -24,13 +24,12 @@
24 24 #ifndef __HTTP_PARSER_H__
25 25 #define __HTTP_PARSER_H__
26 26
27   -#include "class.h"
  27 +#include "trbase.h"
28 28 #include "http/message.h"
29 29 #include "queue.h"
30 30 #include "cbuf.h"
31 31 #include "stream.h"
32 32
33   -#include "commons.h"
34 33
35 34 #define PARSER_MAX_BUF 131072
36 35
... ... @@ -44,7 +43,7 @@ typedef enum e_HttpMessageState {
44 43 } HttpMessageState;
45 44
46 45
47   -CLASS(HttpParser) {
  46 +TR_CLASS(HttpParser) {
48 47 Cbuf buffer;
49 48 Bool ourLock;
50 49
... ...
... ... @@ -24,7 +24,7 @@
24 24 #ifndef __HTTP_REQUEST_H__
25 25 #define __HTTP_REQUEST_H__
26 26
27   -#include "class.h"
  27 +#include "trbase.h"
28 28 #include "http/message.h"
29 29 #include "hash.h"
30 30
... ... @@ -43,8 +43,8 @@ typedef enum e_HttpMethod {
43 43 HTTP_CONNECT
44 44 } HttpMethod;
45 45
46   -CLASS(HttpRequest) {
47   - EXTENDS(HttpMessage);
  46 +TR_CLASS(HttpRequest) {
  47 + TR_EXTENDS(HttpMessage);
48 48
49 49 char * method;
50 50 char * uri;
... ...
... ... @@ -27,15 +27,15 @@
27 27 #include <time.h>
28 28 #include <sys/types.h>
29 29
30   -#include "class.h"
  30 +#include "trbase.h"
31 31 #include "http/message.h"
32 32 #include "session.h"
33 33 #include "user.h"
34 34 #include "asset.h"
35 35
36 36
37   -CLASS(HttpResponse) {
38   - EXTENDS(HttpMessage);
  37 +TR_CLASS(HttpResponse) {
  38 + TR_EXTENDS(HttpMessage);
39 39
40 40 unsigned int status;
41 41 char * reason;
... ...
... ... @@ -27,7 +27,7 @@
27 27 #include <sys/types.h>
28 28 #include <time.h>
29 29
30   -#include "class.h"
  30 +#include "trbase.h"
31 31 #include "hash.h"
32 32 #include "http/parser.h"
33 33 #include "http/writer.h"
... ... @@ -37,10 +37,9 @@
37 37 #include "http/request.h"
38 38 #include "http/response.h"
39 39 #include "queue.h"
40   -#include "commons.h"
41 40
42 41
43   -CLASS(HttpWorker) {
  42 +TR_CLASS(HttpWorker) {
44 43 char * id;
45 44
46 45 Cbuf pbuf;
... ...
... ... @@ -26,13 +26,11 @@
26 26
27 27 #include <sys/types.h>
28 28
29   -#include "class.h"
  29 +#include "trbase.h"
30 30 #include "http/message.h"
31 31 #include "queue.h"
32 32 #include "stream.h"
33 33
34   -#include "commons.h"
35   -
36 34
37 35 /*
38 36 * the buffer that will be written back to an http client.
... ... @@ -78,7 +76,7 @@ typedef enum e_HttpWriterState {
78 76 HTTP_WRITER_DONE
79 77 } HttpWriterState;
80 78
81   -CLASS(HttpWriter) {
  79 +TR_CLASS(HttpWriter) {
82 80 char * buffer;
83 81
84 82 Queue queue;
... ...
1   -/**
2   - * \file
3   - * This interface provides only one function at all.
4   - * indexUuid will generate a uuid to the current object.
5   - *
6   - * \todo
7   - * Maybe merge hashable and indexable. Thus we might get an
8   - * easy way to exchange the hashing mechanism used for my
9   - * associative arrays.
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 __INDEXABLE_H__
31   -#define __INDEXABLE_H__
32   -
33   -#include "uuid.h"
34   -
35   -
36   -typedef Uuid (* fptr_indexUuid)(void *, Uuid);
37   -
38   -extern const struct interface i_Indexable;
39   -
40   -struct i_Indexable {
41   - const struct interface * const _;
42   - fptr_indexUuid uuid;
43   -};
44   -
45   -extern Uuid indexUuid(void *, Uuid);
46   -
47   -#endif // __INDEXABLE_H__
48   -
49   -// vim: set ts=4 sw=4:
1   -/**
2   - * \file
3   - * Definition of the observer pattern implementation.
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 __OBSERVER_H__
25   -#define __OBSERVER_H__
26   -
27   -typedef void (* fptr_observerUpdate)(void *, void*);
28   -
29   -extern const struct interface i_Observer;
30   -
31   -struct i_Observer {
32   - const struct interface * const _;
33   - fptr_observerUpdate update;
34   -};
35   -
36   -extern void observerUpdate(void *, void *);
37   -
38   -#endif // __OBSERVER_H__
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   -#ifndef __SERIALIZABLE_H__
24   -#define __SERIALIZABLE_H__
25   -
26   -typedef void (* fptr_serialize)(void *, unsigned char **, size_t *);
27   -typedef void (* fptr_unserialize)(void *, const unsigned char *, size_t);
28   -
29   -extern const struct interface i_Serializable;
30   -
31   -struct i_Serializable {
32   - const struct interface * const _;
33   - fptr_serialize serialize;
34   - fptr_unserialize unserialize;
35   -};
36   -
37   -extern void serialize(void *, unsigned char **, size_t *);
38   -extern void unserialize(void *, const unsigned char *, size_t);
39   -
40   -#endif // __SERIALIZABLE_H__
41   -
42   -// vim: set ts=4 sw=4:
1   -/**
2   - * \file
3   - * Definition of the subject pattern implementation.
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 __SUBJECT_H__
25   -#define __SUBJECT_H__
26   -
27   -typedef void (* fptr_subjectAttach)(void *, void *);
28   -typedef void (* fptr_subjectDetach)(void *, void *);
29   -typedef void (* fptr_subjectNotify)(void *);
30   -
31   -extern const struct interface i_Subject;
32   -
33   -struct i_Subject {
34   - const struct interface * const _;
35   - fptr_subjectAttach attach;
36   - fptr_subjectDetach detach;
37   - fptr_subjectNotify notify;
38   -};
39   -
40   -extern void subjectAttach(void *, void *);
41   -extern void subjectDetach(void *, void *);
42   -extern void subjectNotify(void *);
43   -
44   -#endif // __SUBJECT_H__
45   -
46   -// vim: set ts=4 sw=4:
... ... @@ -26,16 +26,14 @@
26 26
27 27 #include <stdarg.h>
28 28
29   -#include "class.h"
  29 +#include "trbase.h"
30 30 #include "logger.h"
31 31
32 32 typedef void (* fptr_log)(void *, logger_level, const char * const);
33 33
34   -extern const struct interface i_Logger;
35   -
36   -struct i_Logger {
37   - const struct interface * const _;
38   - fptr_log log;
  34 +TR_INTERFACE(Logger) {
  35 + TR_IFID;
  36 + fptr_log log;
39 37 };
40 38
41 39 extern void loggerLog(void *, logger_level, const char * const, ...);
... ...
... ... @@ -25,7 +25,7 @@
25 25 #ifndef __LOGGER_LOGGER_H__
26 26 #define __LOGGER_LOGGER_H__
27 27
28   -#include "class.h"
  28 +#include "trbase.h"
29 29
30 30 typedef enum logger_level {
31 31 LOGGER_DEBUG=0,
... ... @@ -40,16 +40,16 @@ typedef enum logger_level {
40 40
41 41 extern const char * const logger_level_str[];
42 42
43   -CLASS(Logger) {
  43 +TR_CLASS(Logger) {
44 44 logger_level min_level;
45 45 };
46 46
47   -CLASS(LoggerStderr) {
48   - EXTENDS(Logger);
  47 +TR_CLASS(LoggerStderr) {
  48 + TR_EXTENDS(Logger);
49 49 };
50 50
51   -CLASS(LoggerSyslog) {
52   - EXTENDS(Logger);
  51 +TR_CLASS(LoggerSyslog) {
  52 + TR_EXTENDS(Logger);
53 53 };
54 54
55 55 #endif // __LOGGER_LOGGER_H__
... ...
... ... @@ -25,7 +25,7 @@
25 25
26 26 #include <sys/types.h>
27 27
28   -#include "class.h"
  28 +#include "trbase.h"
29 29 #include "storage/storage.h"
30 30
31 31 /**
... ... @@ -45,7 +45,7 @@ typedef enum e_ResourceActions {
45 45 } ResourceAction;
46 46
47 47
48   -CLASS(Permission) {
  48 +TR_CLASS(Permission) {
49 49 char id[37];
50 50 unsigned long hash;
51 51
... ...
... ... @@ -28,11 +28,10 @@
28 28
29 29 #include <sys/types.h>
30 30
31   -#include "class.h"
32   -#include "commons.h"
  31 +#include "trbase.h"
33 32
34 33
35   -CLASS(Queue) {
  34 +TR_CLASS(Queue) {
36 35 void * msg;
37 36 Queue next;
38 37
... ...
... ... @@ -25,11 +25,11 @@
25 25
26 26 #include <sys/types.h>
27 27
28   -#include "class.h"
  28 +#include "trbase.h"
29 29 #include "storage/storage.h"
30 30
31 31
32   -CLASS(RbacObject) {
  32 +TR_CLASS(RbacObject) {
33 33 char * name;
34 34 size_t nname;
35 35 };
... ...
... ... @@ -25,10 +25,10 @@
25 25
26 26 #include <sys/types.h>
27 27
28   -#include "class.h"
  28 +#include "trbase.h"
29 29
30 30
31   -CLASS(RbacOperation) {
  31 +TR_CLASS(RbacOperation) {
32 32 char * name;
33 33 size_t nname;
34 34 };
... ...
... ... @@ -25,7 +25,7 @@
25 25
26 26 #include <sys/types.h>
27 27
28   -#include "class.h"
  28 +#include "trbase.h"
29 29
30 30
31 31 /**
... ... @@ -37,7 +37,7 @@
37 37 * tricky to find the correct interface when we want to
38 38 * be flexible in future.
39 39 */
40   -CLASS(RbacUser) {
  40 +TR_CLASS(RbacUser) {
41 41 char * name;
42 42 size_t nname;
43 43 };
... ...
... ... @@ -25,12 +25,12 @@
25 25
26 26 #include <sys/types.h>
27 27
28   -#include "class.h"
  28 +#include "trbase.h"
29 29 #include "ebac/permission.h"
30 30 #include "storage/storage.h"
31 31
32 32
33   -CLASS(Role) {
  33 +TR_CLASS(Role) {
34 34 char id[37];
35 35 unsigned long hash;
36 36
... ...
... ... @@ -33,7 +33,7 @@
33 33
34 34 #include <dlfcn.h>
35 35
36   -#include "class.h"
  36 +#include "trbase.h"
37 37 #include "hash.h"
38 38 #include "session.h"
39 39 #include "http/request.h"
... ... @@ -42,7 +42,7 @@
42 42
43 43 typedef char * (* fptr_routable)(Application, Session, Hash);
44 44
45   -CLASS(Router) {
  45 +TR_CLASS(Router) {
46 46 Hash functions;
47 47 Application application;
48 48
... ...
... ... @@ -31,7 +31,7 @@
31 31
32 32 #include <openssl/ssl.h>
33 33
34   -#include "class.h"
  34 +#include "trbase.h"
35 35 #include "socket.h"
36 36 #include "logger.h"
37 37 #include "stream.h"
... ... @@ -42,7 +42,7 @@ struct conns {
42 42 void * worker;
43 43 };
44 44
45   -CLASS(Server) {
  45 +TR_CLASS(Server) {
46 46 Logger logger;
47 47 Sock sock;
48 48 Sock sockSSL;
... ...
... ... @@ -27,13 +27,13 @@
27 27 #include <sys/types.h>
28 28 #include <user.h>
29 29
30   -#include "class.h"
  30 +#include "trbase.h"
31 31
32 32 // livetime of a session in seconds
33 33 #define SESSION_LIVETIME 300 // 5 minutes
34 34
35 35
36   -CLASS(Session) {
  36 +TR_CLASS(Session) {
37 37 char id[37];
38 38 unsigned long hash;
39 39
... ...
... ... @@ -27,10 +27,10 @@
27 27
28 28 #include <arpa/inet.h> // for in_port_t
29 29
30   -#include "class.h"
  30 +#include "trbase.h"
31 31 #include "logger.h"
32 32
33   -CLASS(Sock) {
  33 +TR_CLASS(Sock) {
34 34 Logger log;
35 35 in_port_t port;
36 36 struct sockaddr_in addr;
... ...
... ... @@ -26,7 +26,7 @@
26 26 #include <gdbm.h>
27 27 #include <sys/types.h>
28 28
29   -#include "class.h"
  29 +#include "trbase.h"
30 30
31 31
32 32 typedef enum e_StoragePutResults {
... ... @@ -37,7 +37,7 @@ typedef enum e_StoragePutResults {
37 37 } StoragePutResult;
38 38
39 39
40   -CLASS(Storage) {
  40 +TR_CLASS(Storage) {
41 41 GDBM_FILE gdbm;
42 42 char * db_name;
43 43 };
... ...
... ... @@ -27,15 +27,14 @@
27 27
28 28 #include <sys/types.h>
29 29
  30 +#include "trbase.h"
30 31 #include "stream/stream.h"
31 32
32 33 typedef ssize_t (* fptr_streamReaderRead)(void *, Stream);
33 34
34   -extern const struct interface i_StreamReader;
35   -
36   -struct i_StreamReader {
37   - const struct interface * const _;
38   - fptr_streamReaderRead read;
  35 +TR_INTERFACE(StreamReader) {
  36 + TR_IFID;
  37 + fptr_streamReaderRead read;
39 38 };
40 39
41 40 extern ssize_t streamReaderRead(void *, Stream);
... ...
... ... @@ -27,15 +27,14 @@
27 27
28 28 #include <sys/types.h>
29 29
  30 +#include "trbase.h"
30 31 #include "stream/stream.h"
31 32
32 33 typedef ssize_t (* fptr_streamWriterWrite)(void *, Stream);
33 34
34   -extern const struct interface i_StreamWriter;
35   -
36   -struct i_StreamWriter {
37   - const struct interface * const _;
38   - fptr_streamWriterWrite write;
  35 +TR_INTERFACE(StreamWriter) {
  36 + TR_IFID;
  37 + fptr_streamWriterWrite write;
39 38 };
40 39
41 40 extern ssize_t streamWriterWrite(void *, Stream);
... ...
... ... @@ -26,14 +26,14 @@
26 26 #include <sys/types.h>
27 27 #include <openssl/ssl.h>
28 28
29   -#include "class.h"
  29 +#include "trbase.h"
30 30
31 31 typedef enum e_StreamHandleType {
32 32 STREAM_FD = 0,
33 33 STREAM_SSL
34 34 } StreamHandleType;
35 35
36   -CLASS(Stream) {
  36 +TR_CLASS(Stream) {
37 37 StreamHandleType type;
38 38 union {
39 39 int fd;
... ...
... ... @@ -23,7 +23,7 @@
23 23 #ifndef __TREE_H__
24 24 #define __TREE_H__
25 25
26   -#include "class.h"
  26 +#include "trbase.h"
27 27
28 28 #define TREE_RIGHT(node) (NULL!=(node)?(node)->right:NULL)
29 29 #define TREE_LEFT(node) (NULL!=(node)?(node)->left:NULL)
... ... @@ -114,7 +114,7 @@
114 114
115 115 enum rbColor {rbBlack=1, rbRed=2};
116 116
117   -CLASS(Tree) {
  117 +TR_CLASS(Tree) {
118 118 void * data;
119 119
120 120 enum rbColor color;
... ...
... ... @@ -25,12 +25,11 @@
25 25
26 26 #include <sys/types.h>
27 27
28   -#include "class.h"
  28 +#include "trbase.h"
29 29 #include "uuid.h"
30 30 #include "auth.h"
31   -#include "storage/storage.h"
32 31
33   -CLASS(User) {
  32 +TR_CLASS(User) {
34 33 unsigned long hash;
35 34 AuthModule auth_type;
36 35
... ...
1   -/**
2   - * \file
3   - *
4   - * \author Georg Hopp
5   - *
6   - * \copyright
7   - * Copyright © 2012 Georg Hopp
8   - *
9   - * This program is free software: you can redistribute it and/or modify
10   - * it under the terms of the GNU General Public License as published by
11   - * the Free Software Foundation, either version 3 of the License, or
12   - * (at your option) any later version.
13   - *
14   - * This program is distributed in the hope that it will be useful,
15   - * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17   - * GNU General Public License for more details.
18   - *
19   - * You should have received a copy of the GNU General Public License
20   - * along with this program. If not, see <http://www.gnu.org/licenses/>.
21   - */
22   -
23   -#ifndef __UTILS_MEMORY_H__
24   -#define __UTILS_MEMORY_H__
25   -
26   -#define CSTRA(val) val, sizeof(val)-1 //!< Const STRing Argument
27   -
28   -#define MEM_FREE(seg) (memFree((void **)&(seg)))
29   -
30   -#include <sys/types.h>
31   -
32   -void * memMalloc(size_t);
33   -void * memCalloc(size_t, size_t);
34   -void memFree(void **);
35   -size_t memGetSize(void *);
36   -void memCleanup();
37   -
38   -#endif // __UTILS_MEMORY_H__
39   -
40   -// vim: set ts=4 sw=4:
... ... @@ -33,13 +33,12 @@
33 33 #include <sys/types.h>
34 34 #include <uuid/uuid.h>
35 35
36   -#include "class.h"
37   -#include "commons.h"
  36 +#include "trbase.h"
38 37
39 38
40 39 typedef char UuidString[37];
41 40
42   -CLASS(Uuid) {
  41 +TR_CLASS(Uuid) {
43 42 union {
44 43 uuid_t value;
45 44 struct {
... ...
... ... @@ -3,25 +3,18 @@ AUTOMAKE_OPTIONS = subdir-objects
3 3
4 4
5 5 TRUTILS = utils/hash.c \
6   - utils/memory.c \
7 6 utils/http.c \
8 7 utils/daemonize.c \
9 8 utils/signalHandling.c \
10 9 utils/mime_type.c
11 10
12   -TRBASESRC = interface/subject.c \
13   - interface/observer.c \
14   - interface/serializable.c \
15   - interface/indexable.c
16   -
17   -TRBASELIBS = class/libclass.la \
18   - cbuf/libcbuf.la \
19   - hash/libhash.la \
20   - queue/libqueue.la \
21   - logger/liblogger.la \
22   - tree/libtree.la \
23   - stream/libstream.la \
24   - uuid/libuuid.la
  11 +TRCOMMONLIBS = cbuf/libcbuf.la \
  12 + hash/libhash.la \
  13 + queue/libqueue.la \
  14 + logger/liblogger.la \
  15 + tree/libtree.la \
  16 + stream/libstream.la \
  17 + uuid/libuuid.la
25 18
26 19 TRHTTPSERVER = http/libhttp.la \
27 20 asset/libasset.la \
... ... @@ -36,21 +29,21 @@ TR = ./application/.libs/libapplication.a \
36 29 ./config/.libs/libconfig.a \
37 30 ./router/.libs/librouter.a
38 31
39   -TRLIBS = -ltrutils -ltrhttpserver -ltrbase
  32 +TRLIBS = -ltrutils -ltrhttpserver -ltrcommon
40 33 USEDLIBS = -lrt -lssl -lcrypto -lldap -lgdbm -luuid -ldl
41 34
42 35 AM_CFLAGS += -I../include/
43 36
44 37 bin_PROGRAMS = taskrambler
45   -lib_LTLIBRARIES = libtrutils.la libtrbase.la libtrhttpserver.la
  38 +lib_LTLIBRARIES = libtrutils.la libtrcommon.la libtrhttpserver.la
46 39
47 40 libtrutils_la_SOURCES = $(TRUTILS)
48 41 libtrutils_la_CFLAGS = $(AM_CFLAGS)
49 42 libtrutils_la_LIBADD =
50 43
51   -libtrbase_la_SOURCES = $(TRBASESRC)
52   -libtrbase_la_CFLAGS = $(AM_CFLAGS)
53   -libtrbase_la_LIBADD = $(TRBASELIBS)
  44 +libtrcommon_la_SOURCES =
  45 +libtrcommon_la_CFLAGS = $(AM_CFLAGS)
  46 +libtrcommon_la_LIBADD = $(TRCOMMONLIBS)
54 47
55 48 libtrhttpserver_la_SOURCES =
56 49 libtrhttpserver_la_CFLAGS = $(AM_CFLAGS)
... ... @@ -62,6 +55,6 @@ taskrambler_LDADD = $(TRLIBS) $(TR) $(USEDLIBS)
62 55 taskrambler_LDFLAGS = -Wl,--export-dynamic \
63 56 -Wl,--whole-archive,./application/.libs/libapplication.a,--no-whole-archive
64 57
65   -SUBDIRS = asset auth cbuf class hash queue http \
  58 +SUBDIRS = asset auth cbuf hash queue http \
66 59 logger server session socket stream tree application \
67 60 storage user config router uuid
... ...
... ... @@ -24,13 +24,11 @@
24 24
25 25 #include <stdarg.h>
26 26
27   -#include "class.h"
  27 +#include "trbase.h"
28 28 #include "router.h"
29 29 #include "application/application.h"
30 30 #include "application/adapter/http.h"
31 31
32   -#include "utils/memory.h"
33   -#include "interface/observer.h"
34 32
35 33 static
36 34 int
... ... @@ -54,16 +52,16 @@ applicationAdapterHttpDtor(void * _this)
54 52 void applicationAdapterHttpUpdate(void *, void *);
55 53
56 54
57   -INIT_IFACE(
58   - Class,
  55 +TR_INIT_IFACE(
  56 + TR_Class,
59 57 applicationAdapterHttpCtor,
60 58 applicationAdapterHttpDtor,
61 59 NULL);
62   -INIT_IFACE(Observer, applicationAdapterHttpUpdate);
63   -CREATE_CLASS(
  60 +TR_INIT_IFACE(TR_Observer, applicationAdapterHttpUpdate);
  61 +TR_CREATE_CLASS(
64 62 ApplicationAdapterHttp,
65 63 NULL,
66   - IFACE(Class),
67   - IFACE(Observer));
  64 + TR_IF(TR_Class),
  65 + TR_IF(TR_Observer));
68 66
69 67 // vim: set ts=4 sw=4:
... ...
... ... @@ -25,6 +25,7 @@
25 25 #include <stdio.h>
26 26 #include <sys/types.h>
27 27
  28 +#include "trbase.h"
28 29 #include "application/application.h"
29 30 #include "application/adapter/http.h"
30 31 #include "hash.h"
... ... @@ -74,7 +75,7 @@ applicationAdapterHttpUpdate(void * _this, void * subject)
74 75 nbuf = sprintf(buf, "sid=%s;Path=/", session->id);
75 76 queuePut(
76 77 worker->additional_headers,
77   - new(HttpHeader, CSTRA("Set-Cookie"), buf, nbuf));
  78 + TR_new(HttpHeader, CSTRA("Set-Cookie"), buf, nbuf));
78 79
79 80 worker->current_response = (HttpMessage)routerRoute(
80 81 this->router,
... ...
... ... @@ -24,13 +24,12 @@
24 24
25 25 #include <stdarg.h>
26 26
27   -#include "class.h"
  27 +#include "trbase.h"
28 28 #include "hash.h"
29 29 #include "uuid.h"
30 30 #include "application/application.h"
31 31 #include "storage/storage.h"
32 32
33   -#include "utils/memory.h"
34 33 #include "config.h"
35 34
36 35 static
... ... @@ -57,9 +56,9 @@ applicationCtor(void * _this, va_list * params)
57 56
58 57 this->auth = va_arg(*params, void *);
59 58
60   - this->active_sessions = memCalloc(SESSION_LIVETIME, sizeof(Hash));
  59 + this->active_sessions = TR_calloc(SESSION_LIVETIME, sizeof(Hash));
61 60 for (i=0; i<SESSION_LIVETIME; i++) {
62   - this->active_sessions[i] = new(Hash);
  61 + this->active_sessions[i] = TR_new(Hash);
63 62 }
64 63
65 64 this->version = VERSION;
... ... @@ -75,18 +74,18 @@ applicationDtor(void * _this)
75 74 Application this = _this;
76 75 size_t i;
77 76
78   - delete(this->user_namespace);
  77 + TR_delete(this->user_namespace);
79 78
80 79 for (i=0; i<SESSION_LIVETIME; i++) {
81   - delete(this->active_sessions[i]);
  80 + TR_delete(this->active_sessions[i]);
82 81 }
83 82
84   - MEM_FREE(this->active_sessions);
85   - MEM_FREE(this->auth);
  83 + TR_MEM_FREE(this->active_sessions);
  84 + TR_MEM_FREE(this->auth);
86 85 }
87 86
88 87
89   -INIT_IFACE(Class, applicationCtor, applicationDtor, NULL);
90   -CREATE_CLASS(Application, NULL, IFACE(Class));
  88 +TR_INIT_IFACE(TR_Class, applicationCtor, applicationDtor, NULL);
  89 +TR_CREATE_CLASS(Application, NULL, TR_IF(TR_Class));
91 90
92 91 // vim: set ts=4 sw=4:
... ...
... ... @@ -22,11 +22,10 @@
22 22
23 23 #define _GNU_SOURCE
24 24
  25 +#include "trbase.h"
25 26 #include "hash.h"
26 27 #include "auth/credential.h"
27 28
28   -#include "utils/memory.h"
29   -#include "commons.h"
30 29
31 30 int _controllerValidatePasswordRepeat(char *, size_t, char *, size_t);
32 31
... ... @@ -54,7 +53,7 @@ _controllerGetCredentialFromArgs(Hash args)
54 53 return FALSE;
55 54 }
56 55
57   - return new(Credential,
  56 + return TR_new(Credential,
58 57 CRED_PASSWORD,
59 58 (char *)(email->value), email->nvalue,
60 59 (char *)(password->value), password->nvalue);
... ...
... ... @@ -22,12 +22,10 @@
22 22
23 23 #define _GNU_SOURCE
24 24
  25 +#include "trbase.h"
25 26 #include "hash.h"
26 27 #include "user.h"
27 28
28   -#include "utils/memory.h"
29   -#include "commons.h"
30   -
31 29
32 30 User
33 31 _controllerGetUserFromArgs(Hash args)
... ... @@ -44,7 +42,7 @@ _controllerGetUserFromArgs(Hash args)
44 42 return FALSE;
45 43 }
46 44
47   - return new(User,
  45 + return TR_new(User,
48 46 (char *)(email->value), email->nvalue,
49 47 (char *)(email->value), email->nvalue,
50 48 (char *)(firstname->value), firstname->nvalue,
... ...
... ... @@ -22,12 +22,11 @@
22 22
23 23 #define _GNU_SOURCE
24 24
  25 +#include "trbase.h"
25 26 #include "hash.h"
26 27 #include "user.h"
27 28 #include "auth/credential.h"
28 29
29   -#include "utils/memory.h"
30   -#include "commons.h"
31 30
32 31 User _controllerGetUserFromArgs(Hash args);
33 32 Credential _controllerGetCredentialFromArgs(Hash args);
... ... @@ -39,8 +38,8 @@ _controllerProcessUserCreateArgs(Hash args, User * user, Credential * cred)
39 38 *cred = _controllerGetCredentialFromArgs(args);
40 39
41 40 if (NULL == *user || NULL == *cred) {
42   - delete(*user);
43   - delete(*cred);
  41 + TR_delete(*user);
  42 + TR_delete(*cred);
44 43
45 44 return FALSE;
46 45 }
... ...
... ... @@ -22,12 +22,10 @@
22 22
23 23 #define _GNU_SOURCE
24 24
  25 +#include "trbase.h"
25 26 #include "hash.h"
26 27 #include "user.h"
27 28
28   -#include "utils/memory.h"
29   -#include "commons.h"
30   -
31 29
32 30 int
33 31 _controllerUpdateUserFromArgs(Hash args, User * user)
... ... @@ -45,13 +43,13 @@ _controllerUpdateUserFromArgs(Hash args, User * user)
45 43 return FALSE;
46 44 }
47 45
48   - new_user = new(User,
  46 + new_user = TR_new(User,
49 47 (char *)((*user)->username), *(*user)->nusername,
50 48 (char *)(email->value), email->nvalue,
51 49 (char *)(firstname->value), firstname->nvalue,
52 50 (char *)(surname->value), surname->nvalue);
53 51
54   - delete(*user);
  52 + TR_delete(*user);
55 53 *user = new_user;
56 54
57 55 return TRUE;
... ...
... ... @@ -22,13 +22,13 @@
22 22
23 23 #define _GNU_SOURCE
24 24
  25 +#include "trbase.h"
25 26 #include "application/application.h"
26 27 #include "session.h"
27 28 #include "hash.h"
28 29 #include "auth/credential.h"
29 30 #include "user.h"
30 31
31   -#include "utils/memory.h"
32 32
33 33 User
34 34 _controllerCreateUserFromArgs(Hash args)
... ... @@ -49,7 +49,7 @@ _controllerCreateUserFromArgs(Hash args)
49 49 return NULL;
50 50 }
51 51
52   - return new(User,
  52 + return TR_new(User,
53 53 (char *)(email->value), email->nvalue,
54 54 (char *)(firstname->value), firstname->nvalue,
55 55 (char *)(surname->value), surname->nvalue);
... ...
... ... @@ -20,11 +20,10 @@
20 20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 21 */
22 22
  23 +#include "trbase.h"
23 24 #include "hash.h"
24 25 #include "auth/credential.h"
25 26
26   -#include "utils/memory.h"
27   -#include "commons.h"
28 27
29 28 int
30 29 _controllerValidatePassword(
... ...
... ... @@ -20,12 +20,10 @@
20 20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 21 */
22 22
  23 +#include "trbase.h"
23 24 #include "hash.h"
24 25 #include "auth/credential.h"
25 26
26   -#include "utils/memory.h"
27   -#include "commons.h"
28   -
29 27 int
30 28 _controllerValidatePasswordRepeat(
31 29 char * password,
... ...
... ... @@ -22,14 +22,13 @@
22 22
23 23 #define _GNU_SOURCE
24 24
25   -#include "class.h"
  25 +#include "trbase.h"
26 26 #include "application/application.h"
27 27 #include "session.h"
28 28 #include "hash.h"
29 29 #include "auth/credential.h"
30 30 #include "user.h"
31 31
32   -#include "utils/memory.h"
33 32
34 33 char * controllerCurrentuserRead(Application, Session, Hash);
35 34
... ... @@ -56,7 +55,7 @@ controllerAuthenticateCreate(
56 55 return NULL;
57 56 }
58 57
59   - credential = new(Credential,
  58 + credential = TR_new(Credential,
60 59 CRED_PASSWORD,
61 60 (char *)(username->value), username->nvalue,
62 61 (char *)(password->value), password->nvalue);
... ... @@ -67,7 +66,7 @@ controllerAuthenticateCreate(
67 66 response_data = controllerCurrentuserRead(application, session, NULL);
68 67 }
69 68
70   - delete(credential);
  69 + TR_delete(credential);
71 70
72 71 return response_data;
73 72 }
... ...
... ... @@ -22,12 +22,10 @@
22 22
23 23 #define _GNU_SOURCE
24 24
25   -#include "class.h"
26 25 #include "application/application.h"
27 26 #include "session.h"
28 27 #include "hash.h"
29 28
30   -#include "utils/memory.h"
31 29
32 30 char * controllerCurrentuserRead(Application, Session, Hash);
33 31
... ...
... ... @@ -25,13 +25,11 @@
25 25 #include <sys/types.h>
26 26 #include <stdio.h>
27 27
28   -#include "class.h"
  28 +#include "trbase.h"
29 29 #include "application/application.h"
30 30 #include "session.h"
31 31 #include "hash.h"
32 32
33   -#include "utils/memory.h"
34   -
35 33
36 34 #define USER_JSON \
37 35 "{\"username\":\"%s\",\"email\":\"%s\",\"firstname\":\"%s\",\"surname\":\"%s\"}"
... ... @@ -47,7 +45,7 @@ controllerCurrentuserRead(Application app, Session sess, Hash args)
47 45 (NULL != sess->user)? sess->user->email : "",
48 46 (NULL != sess->user)? sess->user->firstname : "",
49 47 (NULL != sess->user)? sess->user->surname : "");
50   - buffer = memMalloc(nbuffer);
  48 + buffer = TR_malloc(nbuffer);
51 49 nbuffer = sprintf(buffer, USER_JSON,
52 50 (NULL != sess->user)? sess->user->username : "",
53 51 (NULL != sess->user)? sess->user->email : "",
... ...
... ... @@ -25,12 +25,11 @@
25 25 #include <sys/types.h>
26 26 #include <stdio.h>
27 27
  28 +#include "trbase.h"
28 29 #include "application/application.h"
29 30 #include "hash.h"
30 31 #include "session.h"
31 32
32   -#include "utils/memory.h"
33   -
34 33 #define LOC_JSON "{\"loc\":\"%s\"}"
35 34
36 35 char *
... ... @@ -40,7 +39,7 @@ controllerLocRead(Application app, Session sess, Hash args)
40 39 size_t nbuffer;
41 40
42 41 nbuffer = snprintf(NULL, 0, LOC_JSON, app->loc? app->loc : "");
43   - buffer = memMalloc(nbuffer);
  42 + buffer = TR_malloc(nbuffer);
44 43 sprintf(buffer, LOC_JSON, app->loc? app->loc : "");
45 44
46 45 return buffer;
... ...
... ... @@ -25,14 +25,14 @@
25 25 #include <sys/types.h>
26 26 #include <stdio.h>
27 27
  28 +#include "trbase.h"
28 29 #include "application/application.h"
29 30 #include "session.h"
30 31 #include "hash.h"
31 32
32   -#include "utils/memory.h"
33   -
34 33 #define RANDVAL_JSON "{\"ctime\":%ld,\"vnext\":%ld,\"value\":\"%02d\"}"
35 34
  35 +
36 36 char *
37 37 controllerRandvalRead(Application app, Session sess, Hash args)
38 38 {
... ... @@ -49,7 +49,7 @@ controllerRandvalRead(Application app, Session sess, Hash args)
49 49 app->val->timestamp,
50 50 remaining,
51 51 app->val->value);
52   - buffer = memMalloc(nbuffer);
  52 + buffer = TR_malloc(nbuffer);
53 53 sprintf(
54 54 buffer,
55 55 RANDVAL_JSON,
... ...
... ... @@ -25,12 +25,11 @@
25 25 #include <stdio.h>
26 26 #include <sys/types.h>
27 27
  28 +#include "trbase.h"
28 29 #include "application/application.h"
29 30 #include "session.h"
30 31 #include "hash.h"
31 32
32   -#include "utils/memory.h"
33   -
34 33 #define SESSION_JSON "{\"id\":\"%s\",\"timeout\":%d,\"timeleft\":%ld}"
35 34
36 35
... ... @@ -47,7 +46,7 @@ controllerSessinfoRead(
47 46 (NULL != session)? session->id : "",
48 47 (NULL != session)? SESSION_LIVETIME : 0,
49 48 (NULL != session)? session->livetime - time(NULL) : 0);
50   - buffer = memMalloc(nbuffer);
  49 + buffer = TR_malloc(nbuffer);
51 50 sprintf(buffer, SESSION_JSON,
52 51 (NULL != session)? session->id : "",
53 52 (NULL != session)? SESSION_LIVETIME : 0,
... ...
... ... @@ -22,13 +22,13 @@
22 22
23 23 #define _GNU_SOURCE
24 24
  25 +#include "trbase.h"
25 26 #include "application/application.h"
26 27 #include "session.h"
27 28 #include "hash.h"
28 29 #include "auth/credential.h"
29 30 #include "user.h"
30 31
31   -#include "utils/memory.h"
32 32
33 33 char * controllerCurrentuserRead(Application, Session, Hash);
34 34 int _controllerProcessUserCreateArgs(Hash, User *, Credential *);
... ... @@ -55,9 +55,9 @@ controllerSignupCreate(
55 55 response_data = controllerCurrentuserRead(application, session, NULL);
56 56 }
57 57
58   - delete(credential);
59   - delete(user);
60   - delete(user_id);
  58 + TR_delete(credential);
  59 + TR_delete(user);
  60 + TR_delete(user_id);
61 61
62 62 return response_data;
63 63
... ...
... ... @@ -22,13 +22,13 @@
22 22
23 23 #define _GNU_SOURCE
24 24
  25 +#include "trbase.h"
25 26 #include "application/application.h"
26 27 #include "session.h"
27 28 #include "hash.h"
28 29 #include "auth/credential.h"
29 30 #include "user.h"
30 31
31   -#include "utils/memory.h"
32 32
33 33 char * controllerCurrentuserRead(Application, Session, Hash);
34 34 int _controllerProcessUserCreateArgs(Hash, User *, Credential *);
... ... @@ -53,9 +53,9 @@ controllerUserCreate(
53 53 response_data = controllerCurrentuserRead(application, session, NULL);
54 54 }
55 55
56   - delete(credential);
57   - delete(user);
58   - delete(user_id);
  56 + TR_delete(credential);
  57 + TR_delete(user);
  58 + TR_delete(user_id);
59 59
60 60 return response_data;
61 61 }
... ...
... ... @@ -25,13 +25,11 @@
25 25 #include <sys/types.h>
26 26 #include <stdio.h>
27 27
28   -#include "class.h"
  28 +#include "trbase.h"
29 29 #include "application/application.h"
30 30 #include "session.h"
31 31 #include "hash.h"
32 32
33   -#include "utils/memory.h"
34   -
35 33
36 34 #define USER_JSON \
37 35 "{\"email\":\"%s\",\"firstname\":\"%s\",\"surname\":\"%s\"}"
... ... @@ -49,7 +47,7 @@ controllerUserRead(Application app, Session sess, Hash args)
49 47 user->email,
50 48 user->firstname,
51 49 user->surname);
52   - buffer = memMalloc(nbuffer);
  50 + buffer = TR_malloc(nbuffer);
53 51 nbuffer = sprintf(buffer, USER_JSON,
54 52 user->email,
55 53 user->firstname,
... ...
... ... @@ -22,13 +22,12 @@
22 22
23 23 #define _GNU_SOURCE
24 24
  25 +#include "trbase.h"
25 26 #include "application/application.h"
26 27 #include "session.h"
27 28 #include "hash.h"
28 29 #include "user.h"
29 30
30   -#include "utils/memory.h"
31   -#include "commons.h"
32 31
33 32 char * controllerCurrentuserRead(Application, Session, Hash);
34 33 int _controllerUpdateUserFromArgs(Hash, User *);
... ... @@ -49,7 +48,7 @@ controllerUserUpdate(
49 48 if (0 == uuidCompare(uuidZero, user_id)) {
50 49 return NULL;
51 50 }
52   - delete(user_id);
  51 + TR_delete(user_id);
53 52
54 53 return controllerCurrentuserRead(application, session, NULL);
55 54 }
... ...
... ... @@ -25,12 +25,11 @@
25 25 #include <sys/types.h>
26 26 #include <stdio.h>
27 27
  28 +#include "trbase.h"
28 29 #include "application/application.h"
29 30 #include "hash.h"
30 31 #include "session.h"
31 32
32   -#include "utils/memory.h"
33   -
34 33 #define VERSION_JSON "{\"version\":\"%s\"}"
35 34
36 35 char *
... ... @@ -40,7 +39,7 @@ controllerVersionRead(Application app, Session sess, Hash args)
40 39 size_t nbuffer;
41 40
42 41 nbuffer = snprintf(NULL, 0, VERSION_JSON, app->version? app->version : "");
43   - buffer = memMalloc(nbuffer);
  42 + buffer = TR_malloc(nbuffer);
44 43 sprintf(buffer, VERSION_JSON, app->version? app->version : "");
45 44
46 45 return buffer;
... ...
... ... @@ -26,19 +26,13 @@
26 26 #include <stdlib.h>
27 27 #include <sys/types.h>
28 28
29   -#include "class.h"
  29 +#include "trbase.h"
30 30 #include "auth.h"
31 31 #include "user.h"
32 32 #include "uuid.h"
33 33 #include "storage/storage.h"
34 34 #include "application/application.h"
35 35
36   -#include "interface/serializable.h"
37   -#include "interface/indexable.h"
38   -
39   -#include "utils/memory.h"
40   -#include "commons.h"
41   -
42 36 Uuid
43 37 applicationCreateUser(
44 38 Application this,
... ... @@ -49,8 +43,8 @@ applicationCreateUser(
49 43 size_t nuser_serialized;
50 44 Uuid index;
51 45
52   - index = indexUuid(user, this->user_namespace);
53   - serialize(user, (unsigned char **)&user_serialized, &nuser_serialized);
  46 + index = TR_indexUuid(user, this->user_namespace);
  47 + TR_serialize(user, (unsigned char **)&user_serialized, &nuser_serialized);
54 48
55 49 if (SPR_OK != storagePut(
56 50 this->users,
... ... @@ -62,7 +56,7 @@ applicationCreateUser(
62 56 return uuidZero;
63 57 }
64 58
65   - MEM_FREE(user_serialized);
  59 + TR_MEM_FREE(user_serialized);
66 60
67 61 if (! applicationUpdatePassword(this, cred, user)) {
68 62 /**
... ...
... ... @@ -24,19 +24,13 @@
24 24 #include <stdlib.h>
25 25 #include <sys/types.h>
26 26
27   -#include "class.h"
  27 +#include "trbase.h"
28 28 #include "auth.h"
29 29 #include "user.h"
30 30 #include "uuid.h"
31 31 #include "storage/storage.h"
32 32 #include "application/application.h"
33 33
34   -#include "interface/serializable.h"
35   -#include "interface/indexable.h"
36   -
37   -#include "utils/memory.h"
38   -#include "commons.h"
39   -
40 34 User
41 35 applicationGetUser(Application this, Uuid uuid)
42 36 {
... ... @@ -52,11 +46,11 @@ applicationGetUser(Application this, Uuid uuid)
52 46 &nuser_serialized);
53 47
54 48 if (NULL != user_serialized) {
55   - unserialize(
  49 + TR_unserialize(
56 50 user,
57 51 (unsigned char *)user_serialized,
58 52 nuser_serialized);
59   - MEM_FREE(user_serialized);
  53 + TR_MEM_FREE(user_serialized);
60 54 }
61 55
62 56 return user;
... ...
... ... @@ -26,15 +26,10 @@
26 26 #include <stdlib.h>
27 27 #include <sys/types.h>
28 28
29   -#include "class.h"
  29 +#include "trbase.h"
30 30 #include "auth.h"
31 31 #include "uuid.h"
32 32 #include "storage/storage.h"
33   -
34   -#include "interface/serializable.h"
35   -#include "interface/indexable.h"
36   -
37   -#include "utils/memory.h"
38 33 #include "application/application.h"
39 34
40 35
... ... @@ -47,11 +42,11 @@ applicationLogin(
47 42 Uuid search;
48 43 AuthModule auth_module;
49 44
50   - User user = new(User, NULL);
  45 + User user = TR_new(User, NULL);
51 46
52 47 user->username = CRED_PWD(credential).user;
53 48 user->nusername = &CRED_PWD(credential).nuser;
54   - search = indexUuid(user, this->user_namespace);
  49 + search = TR_indexUuid(user, this->user_namespace);
55 50
56 51 auth_module = authenticate(this->auth, credential, search);
57 52
... ... @@ -71,11 +66,11 @@ applicationLogin(
71 66 &nuser_serialized);
72 67
73 68 if (NULL != user_serialized) {
74   - unserialize(
  69 + TR_unserialize(
75 70 session->user,
76 71 (unsigned char *)user_serialized,
77 72 nuser_serialized);
78   - MEM_FREE(user_serialized);
  73 + TR_MEM_FREE(user_serialized);
79 74 } else {
80 75 /**
81 76 * this is a user authenticated via another method
... ... @@ -87,15 +82,15 @@ applicationLogin(
87 82 * the delete will not free it.
88 83 */
89 84 session->user->username = NULL;
90   - delete(session->user);
91   - session->user = new(User,
  85 + TR_delete(session->user);
  86 + session->user = TR_new(User,
92 87 CRED_PWD(credential).user,
93 88 CRED_PWD(credential).nuser,
94 89 CSTRA(""),
95 90 CSTRA(""),
96 91 CSTRA(""));
97 92
98   - serialize(
  93 + TR_serialize(
99 94 session->user,
100 95 (unsigned char **)&user_serialized,
101 96 &nuser_serialized);
... ... @@ -110,7 +105,7 @@ applicationLogin(
110 105 sizeof((search->uuid).value),
111 106 user_serialized,
112 107 nuser_serialized);
113   - MEM_FREE(user_serialized);
  108 + TR_MEM_FREE(user_serialized);
114 109 }
115 110
116 111 session->user->auth_type = auth_module;
... ... @@ -120,11 +115,11 @@ applicationLogin(
120 115 break;
121 116 }
122 117
123   - delete(search);
  118 + TR_delete(search);
124 119 return TRUE;
125 120 }
126 121
127   - delete(search);
  122 + TR_delete(search);
128 123
129 124 return FALSE;
130 125 }
... ...
... ... @@ -22,17 +22,16 @@
22 22
23 23 #define _GNU_SOURCE
24 24
25   -#include "class.h"
  25 +#include "trbase.h"
26 26 #include "auth.h"
27 27
28   -#include "utils/memory.h"
29 28 #include "application/application.h"
30 29
31 30
32 31 void
33 32 applicationLogout(Application this, Session session)
34 33 {
35   - delete(session->user);
  34 + TR_delete(session->user);
36 35 }
37 36
38 37 // vim: set ts=4 sw=4:
... ...
... ... @@ -25,12 +25,11 @@
25 25 #include <stdlib.h>
26 26 #include <sys/types.h>
27 27
28   -#include "class.h"
  28 +#include "trbase.h"
29 29 #include "session.h"
30 30 #include "hash.h"
31 31 #include "application/application.h"
32 32
33   -#include "utils/memory.h"
34 33
35 34 void
36 35 applicationSessionCleanup(Application this, time_t now)
... ... @@ -43,7 +42,7 @@ applicationSessionCleanup(Application this, time_t now)
43 42 }
44 43
45 44 if (0 < expired && SESSION_LIVETIME > expired) {
46   - Hash * tmp_buf = memCalloc(SESSION_LIVETIME, sizeof(Hash));
  45 + Hash * tmp_buf = TR_calloc(SESSION_LIVETIME, sizeof(Hash));
47 46
48 47 memcpy(
49 48 &(tmp_buf[expired]),
... ... @@ -54,7 +53,7 @@ applicationSessionCleanup(Application this, time_t now)
54 53 &(this->active_sessions[SESSION_LIVETIME - expired]),
55 54 expired * sizeof(Hash));
56 55
57   - MEM_FREE(this->active_sessions);
  56 + TR_MEM_FREE(this->active_sessions);
58 57 this->active_sessions = tmp_buf;
59 58 }
60 59
... ...
... ... @@ -24,13 +24,10 @@
24 24
25 25 #include <sys/types.h>
26 26
27   -#include "class.h"
28 27 #include "session.h"
29 28 #include "hash.h"
30 29 #include "application/application.h"
31 30
32   -#include "utils/memory.h"
33   -
34 31
35 32 Session
36 33 applicationSessionGet(Application this, const char * sid)
... ...
... ... @@ -25,17 +25,16 @@
25 25 #include <stdlib.h>
26 26 #include <sys/types.h>
27 27
28   -#include "class.h"
  28 +#include "trbase.h"
29 29 #include "session.h"
30 30 #include "hash.h"
31 31 #include "application/application.h"
32 32
33   -#include "utils/memory.h"
34 33
35 34 Session
36 35 applicationSessionStart(Application this)
37 36 {
38   - Session sess = new(Session);
  37 + Session sess = TR_new(Session);
39 38
40 39 hashAdd((this->active_sessions)[0], sess);
41 40
... ...
... ... @@ -24,12 +24,9 @@
24 24
25 25 #include <sys/types.h>
26 26
27   -#include "class.h"
28 27 #include "session.h"
29 28 #include "application/application.h"
30 29
31   -#include "utils/memory.h"
32   -
33 30
34 31 void
35 32 applicationSessionStop(Application this, Session session)
... ...
... ... @@ -26,16 +26,12 @@
26 26 #include <stdlib.h>
27 27 #include <sys/types.h>
28 28
29   -#include "class.h"
  29 +#include "trbase.h"
30 30 #include "auth.h"
31 31 #include "user.h"
32 32 #include "storage/storage.h"
33 33 #include "application/application.h"
34 34
35   -#include "interface/indexable.h"
36   -
37   -#include "utils/memory.h"
38   -#include "commons.h"
39 35
40 36 int
41 37 applicationUpdatePassword(
... ... @@ -57,16 +53,16 @@ applicationUpdatePassword(
57 53 }
58 54
59 55 memcpy(hash_data, salt, SALT_SIZE);
60   - MEM_FREE(salt);
  56 + TR_MEM_FREE(salt);
61 57
62   - index = indexUuid(user, this->user_namespace);
  58 + index = TR_indexUuid(user, this->user_namespace);
63 59 storageUpdate(
64 60 this->passwords,
65 61 (char *)(index->uuid).value,
66 62 sizeof((index->uuid).value),
67 63 (char *)hash_data,
68 64 SALT_SIZE + HASH_SIZE);
69   - delete(index);
  65 + TR_delete(index);
70 66
71 67 return TRUE;
72 68 }
... ...
... ... @@ -26,18 +26,13 @@
26 26 #include <stdlib.h>
27 27 #include <sys/types.h>
28 28
29   -#include "class.h"
  29 +#include "trbase.h"
30 30 #include "auth.h"
31 31 #include "user.h"
32 32 #include "uuid.h"
33 33 #include "storage/storage.h"
34 34 #include "application/application.h"
35 35
36   -#include "interface/serializable.h"
37   -#include "interface/indexable.h"
38   -
39   -#include "utils/memory.h"
40   -#include "commons.h"
41 36
42 37 Uuid
43 38 applicationUpdateUser(
... ... @@ -48,8 +43,8 @@ applicationUpdateUser(
48 43 size_t nuser_serialized;
49 44 Uuid index;
50 45
51   - index = indexUuid(user, this->user_namespace);
52   - serialize(user, (unsigned char **)&user_serialized, &nuser_serialized);
  46 + index = TR_indexUuid(user, this->user_namespace);
  47 + TR_serialize(user, (unsigned char **)&user_serialized, &nuser_serialized);
53 48
54 49 if (SPR_OK != storageUpdate(
55 50 this->users,
... ... @@ -61,7 +56,7 @@ applicationUpdateUser(
61 56 return uuidZero;
62 57 }
63 58
64   - MEM_FREE(user_serialized);
  59 + TR_MEM_FREE(user_serialized);
65 60
66 61 return index;
67 62 }
... ...
... ... @@ -37,7 +37,7 @@
37 37 #include <time.h>
38 38
39 39
40   -#include "class.h"
  40 +#include "trbase.h"
41 41 #include "asset.h"
42 42 #include "hash.h"
43 43
... ... @@ -138,8 +138,8 @@ assetHandleDouble(void * _this, void * _doub)
138 138 {
139 139 }
140 140
141   -INIT_IFACE(Class, assetCtor, assetDtor, NULL);
142   -INIT_IFACE(Hashable, assetGetHash, assetHandleDouble);
143   -CREATE_CLASS(Asset, NULL, IFACE(Class), IFACE(Hashable));
  141 +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));
144 144
145 145 // vim: set ts=4 sw=4:
... ...
... ... @@ -25,7 +25,7 @@
25 25
26 26 // for strlen
27 27
28   -#include "class.h"
  28 +#include "trbase.h"
29 29 #include "asset.h"
30 30 #include "hash.h"
31 31
... ... @@ -36,7 +36,7 @@ inline
36 36 void
37 37 freeAsset(const void * _node)
38 38 {
39   - delete(_node);
  39 + TR_delete(_node);
40 40 }
41 41
42 42 Asset
... ... @@ -45,13 +45,13 @@ assetPoolGet(const char * path, size_t npath)
45 45 Asset asset = NULL;
46 46
47 47 if (NULL == asset_pool) {
48   - asset_pool = new(Hash);
  48 + asset_pool = TR_new(Hash);
49 49 } else {
50 50 asset = hashGet(asset_pool, path, npath);
51 51 }
52 52
53 53 if (NULL == asset) {
54   - asset = new(Asset, path, npath);
  54 + asset = TR_new(Asset, path, npath);
55 55 if (NULL != asset) {
56 56 hashAdd(asset_pool, asset);
57 57 }
... ... @@ -75,9 +75,11 @@ assetPoolRelease(Asset asset)
75 75 asset_pool, asset->fname, asset->nfname);
76 76
77 77 if (found == asset) {
78   - delete(found);
  78 + TR_delete(found);
79 79 } else {
80   - // this should never happen....error log...
  80 + /**
  81 + * \todo this should never happen....error log...
  82 + */
81 83 }
82 84 }
83 85
... ... @@ -89,7 +91,7 @@ assetPoolCleanup(void)
89 91 {
90 92 if (NULL != asset_pool) {
91 93 hashEach(asset_pool, freeAsset);
92   - delete(asset_pool);
  94 + TR_delete(asset_pool);
93 95 }
94 96 }
95 97
... ...
... ... @@ -26,10 +26,8 @@
26 26 #include <stdio.h>
27 27 #include <ldap.h>
28 28
29   -#include "class.h"
  29 +#include "trbase.h"
30 30 #include "uuid.h"
31   -#include "utils/memory.h"
32   -#include "commons.h"
33 31
34 32 #include "auth.h"
35 33 #include "auth/credential.h"
... ... @@ -57,7 +55,7 @@ authDtor(void * _this)
57 55 int i;
58 56
59 57 for (i=1; i<=MAX_AUTH; i++) {
60   - delete(this->auth[i]);
  58 + TR_delete(this->auth[i]);
61 59 }
62 60 }
63 61
... ... @@ -77,8 +75,8 @@ authAuthenticate(void * _this, Credential cred, Uuid user_index)
77 75 return FALSE;
78 76 }
79 77
80   -INIT_IFACE(Class, authCtor, authDtor, NULL);
81   -INIT_IFACE(Auth, authAuthenticate);
82   -CREATE_CLASS(Auth, NULL, IFACE(Class), IFACE(Auth));
  78 +TR_INIT_IFACE(TR_Class, authCtor, authDtor, NULL);
  79 +TR_INIT_IFACE(Auth, authAuthenticate);
  80 +TR_CREATE_CLASS(Auth, NULL, TR_IF(TR_Class), TR_IF(Auth));
83 81
84 82 // vim: set ts=4 sw=4:
... ...
... ... @@ -23,11 +23,10 @@
23 23 #include <stdarg.h>
24 24 #include <sys/types.h>
25 25
26   -#include "class.h"
  26 +#include "trbase.h"
27 27 #include "auth.h"
28 28 #include "auth/ldap.h"
29 29 #include "auth/storage.h"
30   -#include "commons.h"
31 30
32 31 int
33 32 authCreate(Auth this, AuthModule module, ...)
... ... @@ -35,18 +34,18 @@ authCreate(Auth this, AuthModule module, ...)
35 34 va_list params;
36 35
37 36 if (NULL != this->auth[module]) {
38   - delete(this->auth[module]);
  37 + TR_delete(this->auth[module]);
39 38 }
40 39
41 40 va_start(params, module);
42 41
43 42 switch (module) {
44 43 case AUTH_LDAP:
45   - this->auth[module] = newParams(AuthLdap, &params);
  44 + this->auth[module] = TR_newv(AuthLdap, &params);
46 45 break;
47 46
48 47 case AUTH_STORAGE:
49   - this->auth[module] = newParams(AuthStorage, &params);
  48 + this->auth[module] = TR_newv(AuthStorage, &params);
50 49 break;
51 50 }
52 51
... ...
... ... @@ -25,9 +25,7 @@
25 25 #include <stdlib.h>
26 26 #include <string.h>
27 27
28   -#include "class.h"
29   -#include "utils/memory.h"
30   -
  28 +#include "trbase.h"
31 29 #include "auth/credential.h"
32 30
33 31 static
... ... @@ -48,11 +46,11 @@ credentialCtor(void * _this, va_list * params)
48 46 pass = va_arg(* params, char*);
49 47 CRED_PWD(this).npass = va_arg(* params, size_t);
50 48
51   - CRED_PWD(this).user = memMalloc(CRED_PWD(this).nuser + 1);
  49 + CRED_PWD(this).user = TR_malloc(CRED_PWD(this).nuser + 1);
52 50 CRED_PWD(this).user[CRED_PWD(this).nuser] = 0;
53 51 memcpy(CRED_PWD(this).user, user, CRED_PWD(this).nuser);
54 52
55   - CRED_PWD(this).pass = memMalloc(CRED_PWD(this).npass + 1);
  53 + CRED_PWD(this).pass = TR_malloc(CRED_PWD(this).npass + 1);
56 54 CRED_PWD(this).pass[CRED_PWD(this).npass] = 0;
57 55 memcpy(CRED_PWD(this).pass, pass, CRED_PWD(this).npass);
58 56 }
... ... @@ -73,13 +71,13 @@ credentialDtor(void * _this)
73 71
74 72 switch(this->type) {
75 73 case CRED_PASSWORD:
76   - MEM_FREE(CRED_PWD(this).user);
77   - MEM_FREE(CRED_PWD(this).pass);
  74 + TR_MEM_FREE(CRED_PWD(this).user);
  75 + TR_MEM_FREE(CRED_PWD(this).pass);
78 76 break;
79 77 }
80 78 }
81 79
82   -INIT_IFACE(Class, credentialCtor, credentialDtor, NULL);
83   -CREATE_CLASS(Credential, NULL, IFACE(Class));
  80 +TR_INIT_IFACE(TR_Class, credentialCtor, credentialDtor, NULL);
  81 +TR_CREATE_CLASS(Credential, NULL, TR_IF(TR_Class));
84 82
85 83 // vim: set ts=4 sw=4:
... ...
... ... @@ -25,17 +25,14 @@
25 25 #include "auth/credential.h"
26 26 #include "auth/interface/auth.h"
27 27
28   -const struct interface i_Auth = {
29   - "auth",
30   - 1
31   -};
  28 +TR_CREATE_INTERFACE(Auth, 1);
32 29
33 30 int
34 31 authenticate(void * auth, Credential cred, Uuid user_index)
35 32 {
36 33 int ret;
37 34
38   - RETCALL(auth, Auth, authenticate, ret, cred, user_index);
  35 + TR_RETCALL(auth, Auth, authenticate, ret, cred, user_index);
39 36
40 37 return ret;
41 38 }
... ...
... ... @@ -26,10 +26,8 @@
26 26 #include <stdio.h>
27 27 #include <ldap.h>
28 28
29   -#include "class.h"
  29 +#include "trbase.h"
30 30 #include "uuid.h"
31   -#include "utils/memory.h"
32   -#include "commons.h"
33 31
34 32 #include "auth/ldap.h"
35 33 #include "auth/credential.h"
... ... @@ -43,7 +41,7 @@ authLdapCtor(void * _this, va_list * params)
43 41 char * url = va_arg(*params, char*);
44 42 char * base_dn;
45 43
46   - this->url = memMalloc(strlen(url) + 1);
  44 + this->url = TR_malloc(strlen(url) + 1);
47 45 strcpy(this->url, url);
48 46
49 47 this->version = 3;
... ... @@ -51,7 +49,7 @@ authLdapCtor(void * _this, va_list * params)
51 49 base_dn = va_arg(* params, char *);
52 50 this->nbase_dn = va_arg(* params, size_t);
53 51
54   - this->base_dn = memMalloc(this->nbase_dn + 1);
  52 + this->base_dn = TR_malloc(this->nbase_dn + 1);
55 53 this->base_dn[this->nbase_dn] = 0;
56 54 memcpy(this->base_dn, base_dn, this->nbase_dn);
57 55
... ... @@ -64,8 +62,8 @@ authLdapDtor(void * _this)
64 62 {
65 63 AuthLdap this = _this;
66 64
67   - MEM_FREE(this->base_dn);
68   - MEM_FREE(this->url);
  65 + TR_MEM_FREE(this->base_dn);
  66 + TR_MEM_FREE(this->url);
69 67 }
70 68
71 69 static
... ... @@ -118,8 +116,8 @@ authLdapAuthenticate(void * _this, Credential cred, Uuid user_index)
118 116 return FALSE;
119 117 }
120 118
121   -INIT_IFACE(Class, authLdapCtor, authLdapDtor, NULL);
122   -INIT_IFACE(Auth, authLdapAuthenticate);
123   -CREATE_CLASS(AuthLdap, NULL, IFACE(Class), IFACE(Auth));
  119 +TR_INIT_IFACE(TR_Class, authLdapCtor, authLdapDtor, NULL);
  120 +TR_INIT_IFACE(Auth, authLdapAuthenticate);
  121 +TR_CREATE_CLASS(AuthLdap, NULL, TR_IF(TR_Class), TR_IF(Auth));
124 122
125 123 // vim: set ts=4 sw=4:
... ...
... ... @@ -25,10 +25,8 @@
25 25 #include <openssl/evp.h>
26 26 #include <openssl/rand.h>
27 27
28   -#include "class.h"
  28 +#include "trbase.h"
29 29 #include "auth/storage.h"
30   -#include "utils/memory.h"
31   -#include "commons.h"
32 30
33 31 /*
34 32 * I have to hash the passwords, maybe this will move in
... ... @@ -78,9 +76,9 @@ hash_pw(
78 76 unsigned char ** salt)
79 77 {
80 78 if (NULL == *salt) {
81   - *salt = memCalloc(SALT_SIZE, sizeof(unsigned char));
  79 + *salt = TR_calloc(SALT_SIZE, sizeof(unsigned char));
82 80 if (0 > RAND_pseudo_bytes(*salt, SALT_SIZE)) {
83   - MEM_FREE(*salt);
  81 + TR_MEM_FREE(*salt);
84 82 return FALSE;
85 83 }
86 84 }
... ... @@ -94,7 +92,7 @@ hash_pw(
94 92 EVP_sha512(),
95 93 HASH_SIZE,
96 94 hash)) {
97   - MEM_FREE(*salt);
  95 + TR_MEM_FREE(*salt);
98 96 return FALSE;
99 97 }
100 98
... ...
... ... @@ -20,13 +20,11 @@
20 20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 21 */
22 22
23   -#include "class.h"
  23 +#include "trbase.h"
24 24 #include "storage/storage.h"
25 25 #include "auth.h"
26 26 #include "uuid.h"
27 27 #include "user.h"
28   -#include "commons.h"
29   -#include "utils/memory.h"
30 28
31 29 static
32 30 int
... ... @@ -77,21 +75,21 @@ authStorageAuthenticate(void * _this, Credential cred, Uuid user_index)
77 75 CRED_PWD(cred).npass,
78 76 current_hash,
79 77 &found_hash)) {
80   - MEM_FREE(found_hash);
  78 + TR_MEM_FREE(found_hash);
81 79 return FALSE;
82 80 }
83 81
84 82 if (0 != memcmp(current_hash, found_hash+SALT_SIZE, HASH_SIZE)) {
85   - MEM_FREE(found_hash);
  83 + TR_MEM_FREE(found_hash);
86 84 return FALSE;
87 85 }
88 86
89   - MEM_FREE(found_hash);
  87 + TR_MEM_FREE(found_hash);
90 88 return TRUE;
91 89 }
92 90
93   -INIT_IFACE(Class, authStorageCtor, authStorageDtor, NULL);
94   -INIT_IFACE(Auth, authStorageAuthenticate);
95   -CREATE_CLASS(AuthStorage, NULL, IFACE(Class), IFACE(Auth));
  91 +TR_INIT_IFACE(TR_Class, authStorageCtor, authStorageDtor, NULL);
  92 +TR_INIT_IFACE(Auth, authStorageAuthenticate);
  93 +TR_CREATE_CLASS(AuthStorage, NULL, TR_IF(TR_Class), TR_IF(Auth));
96 94
97 95 // vim: set ts=4 sw=4:
... ...
... ... @@ -33,9 +33,7 @@
33 33 #include <unistd.h>
34 34 #include <fcntl.h>
35 35
36   -#include "class.h"
37   -#include "utils/memory.h"
38   -
  36 +#include "trbase.h"
39 37 #include "cbuf.h"
40 38
41 39
... ... @@ -53,15 +51,15 @@ cbufCtor(void * _this, va_list * params)
53 51 int shm;
54 52 char * data;
55 53
56   - this->shm_name = memMalloc(strlen(shm_name) + 7 + 2);
  54 + this->shm_name = TR_malloc(strlen(shm_name) + 7 + 2);
57 55 sprintf(this->shm_name, "/%06d_%s", getpid(), shm_name);
58 56
59 57 /**
60 58 * align size at page boundary.
61 59 * increase as neccessary
62 60 */
63   - size = va_arg(*params, size_t);
64   - size = (0 >= size)? 1 : (0 != size%psize)? (size/psize)+1 : size/psize;
  61 + size = va_arg(*params, size_t);
  62 + size = (0 >= size)? 1 : (0 != size%psize)? (size/psize)+1 : size/psize;
65 63 this->bsize = psize * size;
66 64
67 65 while (-1 == state) {
... ... @@ -110,7 +108,7 @@ cbufDtor(void * _this)
110 108 {
111 109 Cbuf this = _this;
112 110
113   - MEM_FREE(this->shm_name);
  111 + TR_MEM_FREE(this->shm_name);
114 112
115 113 if (NULL != this->data && MAP_FAILED != this->data) {
116 114 munmap(this->data, this->bsize << 1);
... ... @@ -119,7 +117,7 @@ cbufDtor(void * _this)
119 117 this->data = NULL;
120 118 }
121 119
122   -INIT_IFACE(Class, cbufCtor, cbufDtor, NULL);
123   -CREATE_CLASS(Cbuf, NULL, IFACE(Class));
  120 +TR_INIT_IFACE(TR_Class, cbufCtor, cbufDtor, NULL);
  121 +TR_CREATE_CLASS(Cbuf, NULL, TR_IF(TR_Class));
124 122
125 123 // vim: set ts=4 sw=4:
... ...
... ... @@ -22,8 +22,6 @@
22 22
23 23 #include "cbuf.h"
24 24
25   -#include "commons.h"
26   -
27 25 Bool
28 26 cbufIsLocked(Cbuf this)
29 27 {
... ...
1   -ACLOCAL_AMFLAGS = -I m4
2   -AUTOMAKE_OPTIONS = subdir-objects
3   -
4   -AM_CFLAGS += -I../../include/
5   -
6   -noinst_LTLIBRARIES = libclass.la
7   -
8   -libclass_la_SOURCES = interface.c interface/i_class.c
9   -libclass_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   -#include <stdlib.h>
25   -
26   -#include "class/interface.h"
27   -#include "commons.h"
28   -
29   -static
30   -inline
31   -int
32   -comp(const void * _a, const void * _b)
33   -{
34   - const struct interface * a = **(const struct interface ***)_a;
35   - const struct interface * b = **(const struct interface ***)_b;
36   - return ((a)<(b))? -1 : ((a)>(b))? 1 : 0;
37   -}
38   -
39   -/**
40   - * this one is important in selector functions to get the correct interface
41   - * implementation of a class.
42   - */
43   -iface_ptr
44   -interfaceGet(iface_impl_ptr iface_impl, const iface_ptr _iface)
45   -{
46   - const iface_ptr * iface = &_iface;
47   - iface_ptr * found;
48   -
49   - if (! iface_impl->simpl) {
50   - qsort((void**)(iface_impl->impl), iface_impl->nimpl, sizeof(iface_ptr), comp);
51   - iface_impl->simpl=TRUE;
52   - }
53   -
54   - found = bsearch(
55   - &iface,
56   - iface_impl->impl,
57   - iface_impl->nimpl,
58   - sizeof(iface_ptr),
59   - comp);
60   -
61   - return found? *found : (iface_ptr)NULL;
62   -}
63   -
64   -// 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 <assert.h>
26   -
27   -#include "class/class.h"
28   -#include "class/interface/class.h"
29   -
30   -#include "utils/memory.h"
31   -
32   -
33   -const
34   -struct interface i_Class = {
35   - "class",
36   - 3
37   -};
38   -
39   -void *
40   -classNewParams(class_ptr class, va_list * params)
41   -{
42   - void * object = memCalloc(1, class->object_size + sizeof(void*));
43   - int ret;
44   -
45   - * (class_ptr *)object = class;
46   - object += sizeof(void*);
47   -
48   - RETCALL(object, Class, ctor, ret, params);
49   -
50   - if (-1 == ret) {
51   - classDelete(&object);
52   - }
53   -
54   - return object;
55   -}
56   -
57   -void *
58   -classNew(class_ptr class, ...)
59   -{
60   - va_list params;
61   - void * object;
62   -
63   - va_start(params, class);
64   - object = classNewParams(class, &params);
65   - va_end(params);
66   -
67   - return object;
68   -}
69   -
70   -void
71   -classDelete(void ** object)
72   -{
73   - if (NULL != *object) {
74   - void * mem;
75   -
76   - CALL(*object, Class, dtor);
77   -
78   - mem = *object - sizeof(void*);
79   - MEM_FREE(mem);
80   - *object = NULL;
81   - }
82   -}
83   -
84   -void *
85   -classClone(void * _object)
86   -{
87   - class_ptr class = GET_CLASS(_object);
88   - void * object = memCalloc(1, class->object_size + sizeof(void*));
89   -
90   - * (class_ptr *)object = class;
91   - object += sizeof(void*);
92   -
93   -#undef clone
94   - CALL(object, Class, clone, _object);
95   -
96   - return object;
97   -}
98   -
99   -// vim: set ts=4 sw=4:
... ... @@ -26,10 +26,9 @@
26 26 #include <ctype.h>
27 27 #include <sys/types.h>
28 28
29   -#include "class.h"
  29 +#include "trbase.h"
30 30 #include "config/config.h"
31 31 #include "config/value.h"
32   -#include "utils/memory.h"
33 32
34 33 static
35 34 int
... ... @@ -42,17 +41,17 @@ configCtor(void * _this, va_list * params)
42 41 char * cnf_file = va_arg(*params, char *);
43 42 size_t ncnf_file = strlen(cnf_file);
44 43
45   - this->cnf_file = memMalloc(ncnf_file + 1);
  44 + this->cnf_file = TR_malloc(ncnf_file + 1);
46 45 memcpy(this->cnf_file, cnf_file, ncnf_file);
47 46 this->cnf_file[ncnf_file] = '\0';
48 47
49 48 handle = fopen(this->cnf_file, "r");
50 49 if (NULL == handle) {
51   - MEM_FREE(this->cnf_file);
  50 + TR_MEM_FREE(this->cnf_file);
52 51 return -1;
53 52 }
54 53
55   - this->config = new(Hash);
  54 + this->config = TR_new(Hash);
56 55
57 56 line[MAX_CONFIG_LINE] = '\0';
58 57
... ... @@ -99,7 +98,7 @@ configCtor(void * _this, va_list * params)
99 98 if (0 != nkey && 0 != nvalue) {
100 99 hashAdd(
101 100 this->config,
102   - new(ConfigValue, key, nkey, value, nvalue));
  101 + TR_new(ConfigValue, key, nkey, value, nvalue));
103 102 }
104 103 }
105 104
... ... @@ -108,15 +107,16 @@ configCtor(void * _this, va_list * params)
108 107 return 0;
109 108 }
110 109
111   -static void configDtor(void * _this)
  110 +static
  111 +void configDtor(void * _this)
112 112 {
113 113 Config this = _this;
114 114
115   - MEM_FREE(this->cnf_file);
116   - delete(this->config);
  115 + TR_MEM_FREE(this->cnf_file);
  116 + TR_delete(this->config);
117 117 }
118 118
119   -INIT_IFACE(Class, configCtor, configDtor, NULL);
120   -CREATE_CLASS(Config, NULL, IFACE(Class));
  119 +TR_INIT_IFACE(TR_Class, configCtor, configDtor, NULL);
  120 +TR_CREATE_CLASS(Config, NULL, TR_IF(TR_Class));
121 121
122 122 // vim: set ts=4 sw=4:
... ...
Please register or login to post a comment