Compare commits
merge into: ghopp:master
ghopp:0.1.7
ghopp:master
ghopp:next
ghopp:release0.1.5
ghopp:release0.1.6
ghopp:release0.1.7
ghopp:v0.1.8
ghopp:v0.1.9
pull from: ghopp:next
ghopp:0.1.7
ghopp:master
ghopp:next
ghopp:release0.1.5
ghopp:release0.1.6
ghopp:release0.1.7
ghopp:v0.1.8
ghopp:v0.1.9
39 Commits
248 changed files with 1433 additions and 7551 deletions
-
3Makefile.am
-
19configure.ac
-
8include/application/adapter/http.h
-
49include/application/application.h
-
10include/asset.h
-
2include/auth.h
-
10include/auth/auth.h
-
8include/auth/credential.h
-
19include/auth/interface/auth.h
-
8include/auth/ldap.h
-
8include/auth/storage.h
-
82include/cbuf.h
-
10include/class.h
-
143include/class/class.h
-
59include/class/interface.h
-
64include/class/interface/class.h
-
48include/commons.h
-
14include/config/config.h
-
9include/config/value.h
-
10include/hash.h
-
48include/hash/hash.h
-
45include/hash/interface/hashable.h
-
42include/hash/value.h
-
21include/http.h
-
8include/http/cookie.h
-
8include/http/header.h
-
14include/http/interface/http_intro.h
-
23include/http/message.h
-
20include/http/parser.h
-
18include/http/request.h
-
22include/http/response.h
-
33include/http/worker.h
-
18include/http/writer.h
-
49include/interface/indexable.h
-
40include/interface/observer.h
-
42include/interface/serializable.h
-
46include/interface/subject.h
-
9include/logger.h
-
45include/logger/interface/logger.h
-
57include/logger/logger.h
-
8include/permission.h
-
59include/queue.h
-
8include/rbac/object.h
-
8include/rbac/operation.h
-
8include/rbac/user.h
-
9include/role.h
-
18include/router.h
-
28include/server.h
-
38include/session.h
-
48include/socket.h
-
8include/storage/storage.h
-
10include/stream.h
-
45include/stream/interface/reader.h
-
45include/stream/interface/writer.h
-
49include/stream/stream.h
-
138include/tree.h
-
13include/user.h
-
33include/utils/hash.h
-
2include/utils/http.h
-
40include/utils/memory.h
-
2include/utils/mime_type.h
-
2include/utils/signalHandling.h
-
73include/uuid.h
-
24m4/trlibs.m4
-
47src/Makefile.am
-
21src/application/adapter/http/http.c
-
31src/application/adapter/http/update.c
-
31src/application/application.c
-
17src/application/controller/_get_credential_from_args.c
-
29src/application/controller/_get_user_from_args.c
-
17src/application/controller/_process_user_create_args.c
-
23src/application/controller/_update_user_from_args.c
-
9src/application/controller/_validate_email.c
-
6src/application/controller/_validate_password.c
-
7src/application/controller/_validate_password_repeat.c
-
28src/application/controller/authenticate/create.c
-
10src/application/controller/authenticate/delete.c
-
10src/application/controller/currentuser/read.c
-
10src/application/controller/loc/read.c
-
11src/application/controller/randval/read.c
-
10src/application/controller/sessinfo/read.c
-
22src/application/controller/signup/create.c
-
22src/application/controller/user/create.c
-
22src/application/controller/user/read.c
-
19src/application/controller/user/update.c
-
9src/application/controller/version/read.c
-
27src/application/create_user.c
-
19src/application/get_user.c
-
35src/application/login.c
-
7src/application/logout.c
-
24src/application/session_cleanup.c
-
75src/application/session_get.c
-
38src/application/session_start.c
-
32src/application/session_stop.c
-
18src/application/update_password.c
-
24src/application/update_user.c
-
15src/asset/asset.c
-
32src/asset/pool.c
-
18src/auth/auth.c
-
12src/auth/create.c
@ -1,82 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* My implementation of a ringbuffer. |
|||
* It maps a shared memory object twice directly following |
|||
* thus make it possible to read and write from any |
|||
* position within the buffer without the nasty wrap |
|||
* calculations. |
|||
* This is achived because the same memory region is mapped |
|||
* at the two addresses. |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2012 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef __CBUF_H__ |
|||
#define __CBUF_H__ |
|||
|
|||
#include <ctype.h> |
|||
#include <string.h> |
|||
#include <sys/types.h> |
|||
|
|||
#include "class.h" |
|||
#include "stream.h" |
|||
|
|||
#include "commons.h" |
|||
#include "utils/memory.h" |
|||
|
|||
#define ECBUFOVFL 100 |
|||
|
|||
|
|||
CLASS(Cbuf) { |
|||
char * shm_name; // shared memory identifier |
|||
|
|||
char * data; |
|||
Bool lock; |
|||
|
|||
size_t bsize; |
|||
size_t bused; |
|||
|
|||
size_t write; |
|||
size_t read; |
|||
}; |
|||
|
|||
ssize_t cbufRead(Cbuf, Stream); |
|||
ssize_t cbufWrite(Cbuf, Stream); |
|||
|
|||
char * cbufGetLine(Cbuf, char **); |
|||
char * cbufGetData(Cbuf, size_t); |
|||
char * cbufSetData(Cbuf, const void *, size_t); |
|||
void cbufEmpty(Cbuf); |
|||
|
|||
char * cbufGetRead(Cbuf this); |
|||
char * cbufGetWrite(Cbuf this); |
|||
char * cbufMemchr(Cbuf this, int c); |
|||
size_t cbufAddrIndex(Cbuf this, const void * c); |
|||
void cbufIncRead(Cbuf this, size_t n); |
|||
void cbufIncWrite(Cbuf this, size_t n); |
|||
size_t cbufGetFree(Cbuf this); |
|||
char cbufIsEmpty(Cbuf this); |
|||
void cbufSkipNonAlpha(Cbuf this); |
|||
Bool cbufIsLocked(Cbuf this); |
|||
void cbufLock(Cbuf this); |
|||
void cbufRelease(Cbuf this); |
|||
|
|||
#endif // __CBUF_H__ |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,10 +0,0 @@ |
|||
#ifndef __CLASS_H__ |
|||
#define __CLASS_H__ |
|||
|
|||
#include "class/class.h" |
|||
#include "class/interface.h" |
|||
#include "class/interface/class.h" |
|||
|
|||
#endif // __CLASS_H__ |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,143 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* My own class implementation for C. It combines a data structure |
|||
* with a set of dynamically linked methods defined by an interface. A |
|||
* dynamically linked method will be called via a selector method which in |
|||
* turn gets the implementation stored in the class. |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2012 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef __CLASS_CLASS_H__ |
|||
#define __CLASS_CLASS_H__ |
|||
|
|||
#include <stdarg.h> |
|||
#include <sys/types.h> |
|||
#include <string.h> |
|||
#include <assert.h> |
|||
|
|||
#include "class/interface.h" |
|||
|
|||
#ifndef _ISOC99_SOURCE |
|||
#define _ISOC99_SOURCE |
|||
#endif |
|||
|
|||
#define CLASS_MAGIC 0xFEFE |
|||
|
|||
#define CLASS(name) \ |
|||
struct c_##name; \ |
|||
typedef struct c_##name * name; \ |
|||
extern struct class * const _##name; \ |
|||
struct c_##name |
|||
|
|||
#define EXTENDS(parent) \ |
|||
const char _[sizeof(struct c_##parent)] |
|||
|
|||
#define _NULL NULL |
|||
#define CREATE_CLASS(name,_parent,...) \ |
|||
static struct class c_##name; \ |
|||
static class_ptr _classInit##name##_(void) { \ |
|||
c_##name.parent = _##_parent; \ |
|||
c_##name.init = NULL; \ |
|||
return &c_##name; \ |
|||
} \ |
|||
static struct class c_##name = { \ |
|||
CLASS_MAGIC, \ |
|||
NULL, \ |
|||
sizeof(struct c_##name), \ |
|||
_classInit##name##_, \ |
|||
INIT_IFACE_IMPL(__VA_ARGS__) \ |
|||
}; struct class * const _##name = &c_##name; \ |
|||
struct c_##name##_object { void * class; struct c_##name data; } |
|||
|
|||
|
|||
/** |
|||
* create a static instance of a class. |
|||
* \todo |
|||
* this macro requires to close the initializer |
|||
* with an extra curly brancket. This is not nice...find a |
|||
* way to prevent this. |
|||
*/ |
|||
#define INSTANCE(class, name) \ |
|||
struct c_##class##_object _##name; \ |
|||
class name = &(_##name.data); \ |
|||
struct c_##class##_object _##name = { \ |
|||
&c_##class, |
|||
|
|||
#define INIT_CLASS(class) ((class)->init? (class)->init() : (class)) |
|||
#define GET_CLASS(object) (INIT_CLASS(*(class_ptr *)((void*)(object) - sizeof(void*)))) |
|||
#define IFACE_GET(class,iface) (interfaceGet(&((class)->impl),(iface))) |
|||
#define HAS_PARENT(class) (NULL != ((class)->parent) && INIT_CLASS((class)->parent)) |
|||
|
|||
#define IS_OBJECT(obj) ((GET_CLASS((obj)))->magic == CLASS_MAGIC) |
|||
#define INSTANCE_OF(class,obj) ((GET_CLASS((obj))) == _##class) |
|||
|
|||
/** |
|||
* \todo actually i use gcc feature ## for variadoc... think about |
|||
* a way to make this standard. |
|||
*/ |
|||
#define _CALL(_class,_iface,method,...) \ |
|||
do { \ |
|||
class_ptr class = _class; \ |
|||
iface = (struct i_##_iface *)IFACE_GET(class, &i_##_iface); \ |
|||
while ((NULL == iface || NULL == iface->method) && HAS_PARENT(class)) { \ |
|||
class = class->parent; \ |
|||
iface = (struct i_##_iface *)IFACE_GET(class, &i_##_iface); \ |
|||
} \ |
|||
assert(NULL != iface->method); \ |
|||
} while(0) |
|||
|
|||
#define CALL(object,_iface,method,...) \ |
|||
do { \ |
|||
struct i_##_iface * iface; \ |
|||
_CALL(GET_CLASS(object), _iface, method, ##__VA_ARGS__); \ |
|||
iface->method(object, ##__VA_ARGS__); \ |
|||
} while(0) |
|||
|
|||
#define RETCALL(object,_iface,method,ret,...) \ |
|||
do { \ |
|||
struct i_##_iface * iface; \ |
|||
_CALL(GET_CLASS(object), _iface, method, ##__VA_ARGS__); \ |
|||
ret = iface->method(object, ##__VA_ARGS__); \ |
|||
} while(0) |
|||
|
|||
#define PARENTCALL(object,_iface,method,...) \ |
|||
do { \ |
|||
struct i_##_iface * iface; \ |
|||
class_ptr pc_class = GET_CLASS((object)); \ |
|||
assert(HAS_PARENT(pc_class)); \ |
|||
_CALL(pc_class->parent, _iface, method, ##__VA_ARGS__); \ |
|||
iface->method(object, ##__VA_ARGS__); \ |
|||
} while(0) |
|||
|
|||
|
|||
struct class; |
|||
typedef struct class * class_ptr; |
|||
typedef class_ptr (* fptr_classInit)(void); |
|||
struct class { |
|||
const int magic; |
|||
class_ptr parent; |
|||
size_t object_size; |
|||
fptr_classInit init; |
|||
struct iface_impl impl; |
|||
}; |
|||
|
|||
#endif // __CLASS_CLASS_H__ |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,59 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* Interface definition code. Each interface is a set of selector functions |
|||
* as well as a data structure where the concrete implementation will be stored. |
|||
* This structure is the intergrated in the class that implements the |
|||
* interface. |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2012 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef __CLASS_INTERFACE_H__ |
|||
#define __CLASS_INTERFACE_H__ |
|||
|
|||
#include <sys/types.h> |
|||
|
|||
#define MAX_IFACE 32 // ATTENTION: every iface_impl will use MAX_IFACE * sizeof(void*) |
|||
|
|||
#define IFACE(name) ((const struct i_##name const*)&i_##name##_impl) |
|||
#define INIT_IFACE(name,...) \ |
|||
static const struct i_##name i_##name##_impl = {&i_##name,__VA_ARGS__} |
|||
|
|||
#define NUMARGS(...) (sizeof((const void*[]){__VA_ARGS__})/sizeof(void*)) |
|||
#define INIT_IFACE_IMPL(...) {NUMARGS(__VA_ARGS__), 0, {__VA_ARGS__}} |
|||
|
|||
|
|||
struct interface { |
|||
const char * name; |
|||
const size_t nmethods; |
|||
}; |
|||
typedef const struct interface * iface_ptr; |
|||
|
|||
struct iface_impl { |
|||
const size_t nimpl; // number of interface implementations |
|||
char simpl; // implementations sorted?? |
|||
const void * impl[MAX_IFACE]; // implementations |
|||
}; |
|||
typedef struct iface_impl * iface_impl_ptr; |
|||
|
|||
extern iface_ptr interfaceGet(iface_impl_ptr, const iface_ptr); |
|||
|
|||
#endif // __CLASS_INTERFACE_H__ |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,64 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* Interface for class handling. Defines new, delete and clone selectors |
|||
* which in turn use the ctor, dtor and clone implementation from the |
|||
* class implementation. |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2012 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef __CLASS_INTERFACE_CLASS_H__ |
|||
#define __CLASS_INTERFACE_CLASS_H__ |
|||
|
|||
#include <stdarg.h> |
|||
|
|||
#include "class/class.h" |
|||
#include "class/interface.h" |
|||
|
|||
typedef int (* fptr_ctor)(void *, va_list *); |
|||
typedef void (* fptr_dtor)(void *); |
|||
typedef void (* fptr_clone)(void *, void * const); |
|||
|
|||
extern const struct interface i_Class; |
|||
|
|||
struct i_Class { |
|||
const struct interface * const _; |
|||
fptr_ctor ctor; |
|||
fptr_dtor dtor; |
|||
fptr_clone clone; |
|||
}; |
|||
|
|||
extern void * classNew(class_ptr, ...); |
|||
extern void classDelete(void **); |
|||
extern void * classClone(void *); |
|||
|
|||
#define new(class,...) classNew(_##class, ##__VA_ARGS__) |
|||
#define delete(object) classDelete((void **)&(object)) |
|||
#define clone(object) classClone((void *)(object)) |
|||
|
|||
/** |
|||
* With this one we can create a new instance via a |
|||
* intermidiary that gets the arguments. |
|||
*/ |
|||
extern void * classNewParams(class_ptr, va_list *); |
|||
#define newParams(class,args) classNewParams(_##class, args) |
|||
|
|||
#endif // __CLASS_INTERFACE_CLASS_H__ |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,48 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2012 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef __COMMONS_H__ |
|||
#define __COMMONS_H__ |
|||
|
|||
#define Bool char |
|||
#define TRUE 1 |
|||
#define FALSE 0 |
|||
|
|||
#ifndef MAX |
|||
# define MAX(a,b) ((a)>(b)? (a) : (b)) |
|||
#endif |
|||
|
|||
#ifndef MIN |
|||
# define MIN(a,b) ((a)<(b)? (a) : (b)) |
|||
#endif |
|||
|
|||
#define SWAP_FUN(a, b) ((a)^=(b),(b)^=(a),(a)^=(b)) |
|||
|
|||
#define SWAP(type, a, b) do { \ |
|||
type tmp = (a); \ |
|||
(a) = (b); \ |
|||
(b) = tmp; \ |
|||
} while(0); |
|||
|
|||
#endif // __COMMONS_H__ |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,10 +0,0 @@ |
|||
#ifndef __HASH_H__ |
|||
#define __HASH_H__ |
|||
|
|||
#include "hash/hash.h" |
|||
#include "hash/value.h" |
|||
#include "hash/interface/hashable.h" |
|||
|
|||
#endif // __HASH_H__ |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,48 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2012 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef __HASH_HASH_H__ |
|||
#define __HASH_HASH_H__ |
|||
|
|||
#include <sys/types.h> |
|||
|
|||
#include "class.h" |
|||
#include "tree.h" |
|||
|
|||
#define HASH_IS_EMPTY(h) ((h)->root) |
|||
|
|||
CLASS(Hash) { |
|||
Tree root; |
|||
}; |
|||
|
|||
void * hashAdd(Hash, void *); |
|||
void * hashDelete(Hash, const char *, size_t); |
|||
void * hashGet(Hash, const char *, size_t); |
|||
void * hashGetFirst(Hash); |
|||
void * hashDeleteByVal(Hash, unsigned long); |
|||
void * hashGetByVal(Hash, unsigned long); |
|||
void hashEach(Hash, void (*)(const void*)); |
|||
void hashCleanup(Hash); |
|||
|
|||
#endif // __HASH_HASH_H__ |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,45 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* The logger interface. |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2012 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef __HASH_INTERFACE_HASHABLE_H__ |
|||
#define __HASH_INTERFACE_HASHABLE_H__ |
|||
|
|||
#include "class.h" |
|||
|
|||
typedef unsigned long (* fptr_hashableGetHash)(void *); |
|||
typedef void (* fptr_hashableHandleDouble)(void *, void *); |
|||
|
|||
extern const struct interface i_Hashable; |
|||
|
|||
struct i_Hashable { |
|||
const struct interface * const _; |
|||
fptr_hashableGetHash getHash; |
|||
fptr_hashableHandleDouble handleDouble; |
|||
}; |
|||
|
|||
extern unsigned long hashableGetHash(void *); |
|||
extern void hashableHandleDouble(void *, void *); |
|||
|
|||
#endif // __HASH_INTERFACE_HASHABLE_H__ |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,42 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2012 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef __HASH_VALUE_H__ |
|||
#define __HASH_VALUE_H__ |
|||
|
|||
#include <sys/types.h> |
|||
|
|||
#include "class.h" |
|||
|
|||
CLASS(HashValue) { |
|||
unsigned long hash; |
|||
|
|||
char * key; |
|||
void * value; |
|||
|
|||
size_t nkey; |
|||
size_t nvalue; |
|||
}; |
|||
|
|||
#endif // __HASH_VALUE_H__ |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,49 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* This interface provides only one function at all. |
|||
* indexUuid will generate a uuid to the current object. |
|||
* |
|||
* \todo |
|||
* Maybe merge hashable and indexable. Thus we might get an |
|||
* easy way to exchange the hashing mechanism used for my |
|||
* associative arrays. |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2012 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef __INDEXABLE_H__ |
|||
#define __INDEXABLE_H__ |
|||
|
|||
#include "uuid.h" |
|||
|
|||
|
|||
typedef Uuid (* fptr_indexUuid)(void *, Uuid); |
|||
|
|||
extern const struct interface i_Indexable; |
|||
|
|||
struct i_Indexable { |
|||
const struct interface * const _; |
|||
fptr_indexUuid uuid; |
|||
}; |
|||
|
|||
extern Uuid indexUuid(void *, Uuid); |
|||
|
|||
#endif // __INDEXABLE_H__ |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,40 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* Definition of the observer pattern implementation. |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2012 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef __OBSERVER_H__ |
|||
#define __OBSERVER_H__ |
|||
|
|||
typedef void (* fptr_observerUpdate)(void *, void*); |
|||
|
|||
extern const struct interface i_Observer; |
|||
|
|||
struct i_Observer { |
|||
const struct interface * const _; |
|||
fptr_observerUpdate update; |
|||
}; |
|||
|
|||
extern void observerUpdate(void *, void *); |
|||
|
|||
#endif // __OBSERVER_H__ |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,42 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2012 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef __SERIALIZABLE_H__ |
|||
#define __SERIALIZABLE_H__ |
|||
|
|||
typedef void (* fptr_serialize)(void *, unsigned char **, size_t *); |
|||
typedef void (* fptr_unserialize)(void *, const unsigned char *, size_t); |
|||
|
|||
extern const struct interface i_Serializable; |
|||
|
|||
struct i_Serializable { |
|||
const struct interface * const _; |
|||
fptr_serialize serialize; |
|||
fptr_unserialize unserialize; |
|||
}; |
|||
|
|||
extern void serialize(void *, unsigned char **, size_t *); |
|||
extern void unserialize(void *, const unsigned char *, size_t); |
|||
|
|||
#endif // __SERIALIZABLE_H__ |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,46 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* Definition of the subject pattern implementation. |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2012 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef __SUBJECT_H__ |
|||
#define __SUBJECT_H__ |
|||
|
|||
typedef void (* fptr_subjectAttach)(void *, void *); |
|||
typedef void (* fptr_subjectDetach)(void *, void *); |
|||
typedef void (* fptr_subjectNotify)(void *); |
|||
|
|||
extern const struct interface i_Subject; |
|||
|
|||
struct i_Subject { |
|||
const struct interface * const _; |
|||
fptr_subjectAttach attach; |
|||
fptr_subjectDetach detach; |
|||
fptr_subjectNotify notify; |
|||
}; |
|||
|
|||
extern void subjectAttach(void *, void *); |
|||
extern void subjectDetach(void *, void *); |
|||
extern void subjectNotify(void *); |
|||
|
|||
#endif // __SUBJECT_H__ |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,9 +0,0 @@ |
|||
#ifndef __LOGGER_H__ |
|||
#define __LOGGER_H__ |
|||
|
|||
#include "logger/logger.h" |
|||
#include "logger/interface/logger.h" |
|||
|
|||
#endif // __LOGGER_H__ |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,45 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* The logger interface. |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2012 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef __LOGGER_INTERFACE_LOGGER_H__ |
|||
#define __LOGGER_INTERFACE_LOGGER_H__ |
|||
|
|||
#include <stdarg.h> |
|||
|
|||
#include "class.h" |
|||
#include "logger.h" |
|||
|
|||
typedef void (* fptr_log)(void *, logger_level, const char * const); |
|||
|
|||
extern const struct interface i_Logger; |
|||
|
|||
struct i_Logger { |
|||
const struct interface * const _; |
|||
fptr_log log; |
|||
}; |
|||
|
|||
extern void loggerLog(void *, logger_level, const char * const, ...); |
|||
|
|||
#endif // __LOGGER_INTERFACE_LOGGER_H__ |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,57 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* A generic logger class and two extended classes, One that logs to |
|||
* stderr and one that logs to the system syslog. |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2012 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef __LOGGER_LOGGER_H__ |
|||
#define __LOGGER_LOGGER_H__ |
|||
|
|||
#include "class.h" |
|||
|
|||
typedef enum logger_level { |
|||
LOGGER_DEBUG=0, |
|||
LOGGER_INFO, |
|||
LOGGER_NOTICE, |
|||
LOGGER_WARNING, |
|||
LOGGER_ERR, |
|||
LOGGER_CRIT, |
|||
LOGGER_ALERT, |
|||
LOGGER_EMERG |
|||
} logger_level; |
|||
|
|||
extern const char * const logger_level_str[]; |
|||
|
|||
CLASS(Logger) { |
|||
logger_level min_level; |
|||
}; |
|||
|
|||
CLASS(LoggerStderr) { |
|||
EXTENDS(Logger); |
|||
}; |
|||
|
|||
CLASS(LoggerSyslog) { |
|||
EXTENDS(Logger); |
|||
}; |
|||
|
|||
#endif // __LOGGER_LOGGER_H__ |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,59 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* Holds requests ready for processing. |
|||
* |
|||
* \todo change this to a real queue. |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2012 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef __QUEUE_H__ |
|||
#define __QUEUE_H__ |
|||
|
|||
#include <sys/types.h> |
|||
|
|||
#include "class.h" |
|||
#include "commons.h" |
|||
|
|||
|
|||
CLASS(Queue) { |
|||
void * msg; |
|||
Queue next; |
|||
|
|||
/** |
|||
* first and last are only available in the initial queue |
|||
* element (the root). This elelment does not contain any message |
|||
* and exists only for organizational purpose. |
|||
* |
|||
* \todo next and first always have to be the same...so get rid |
|||
* of first. |
|||
*/ |
|||
Queue first; |
|||
Queue last; |
|||
size_t nmsg; |
|||
}; |
|||
|
|||
void queuePut(Queue, void *); |
|||
void * queueGet(Queue); |
|||
|
|||
#define queueEmpty(this) (0 >= (this)->nmsg) |
|||
|
|||
#endif // __QUEUE_H__ |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,48 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* Abstraction layer above BSD sockets. Capsules and simplifies connect |
|||
* accept and listen. |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2012 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef __SOCKET_H__ |
|||
#define __SOCKET_H__ |
|||
|
|||
#include <arpa/inet.h> // for in_port_t |
|||
|
|||
#include "class.h" |
|||
#include "logger.h" |
|||
|
|||
CLASS(Sock) { |
|||
Logger log; |
|||
in_port_t port; |
|||
struct sockaddr_in addr; |
|||
int handle; |
|||
}; |
|||
|
|||
void socketConnect(Sock this, const char * addr, char (*)[16]); |
|||
void socketListen(Sock this, int backlog); |
|||
Sock socketAccept(Sock this, char (*remoteAddr)[16]); |
|||
void socketNonblock(Sock this); |
|||
|
|||
#endif // __SOCKET_H__ |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
|
|||
@ -1,10 +0,0 @@ |
|||
#ifndef __STREAM_H__ |
|||
#define __STREAM_H__ |
|||
|
|||
#include "stream/stream.h" |
|||
#include "stream/interface/reader.h" |
|||
#include "stream/interface/writer.h" |
|||
|
|||
#endif // __STREAM_H__ |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,45 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* Interface whose implementations can read from a stream given as |
|||
* a handle. |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2012 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef __STREAM_INTERFACE_READER_H__ |
|||
#define __STREAM_INTERFACE_READER_H__ |
|||
|
|||
#include <sys/types.h> |
|||
|
|||
#include "stream/stream.h" |
|||
|
|||
typedef ssize_t (* fptr_streamReaderRead)(void *, Stream); |
|||
|
|||
extern const struct interface i_StreamReader; |
|||
|
|||
struct i_StreamReader { |
|||
const struct interface * const _; |
|||
fptr_streamReaderRead read; |
|||
}; |
|||
|
|||
extern ssize_t streamReaderRead(void *, Stream); |
|||
|
|||
#endif // __STREAM_INTERFACE_READER_H__ |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,45 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* Interface whose implementations can write from a stream given as |
|||
* a handle. |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2012 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef __STREAM_INTERFACE_WRITER_H__ |
|||
#define __STREAM_INTERFACE_WRITER_H__ |
|||
|
|||
#include <sys/types.h> |
|||
|
|||
#include "stream/stream.h" |
|||
|
|||
typedef ssize_t (* fptr_streamWriterWrite)(void *, Stream); |
|||
|
|||
extern const struct interface i_StreamWriter; |
|||
|
|||
struct i_StreamWriter { |
|||
const struct interface * const _; |
|||
fptr_streamWriterWrite write; |
|||
}; |
|||
|
|||
extern ssize_t streamWriterWrite(void *, Stream); |
|||
|
|||
#endif // __STREAM_INTERFACE_WRITER_H__ |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,49 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2012 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef __STREAM_STREAM_H__ |
|||
#define __STREAM_STREAM_H__ |
|||
|
|||
#include <sys/types.h> |
|||
#include <openssl/ssl.h> |
|||
|
|||
#include "class.h" |
|||
|
|||
typedef enum e_StreamHandleType { |
|||
STREAM_FD = 0, |
|||
STREAM_SSL |
|||
} StreamHandleType; |
|||
|
|||
CLASS(Stream) { |
|||
StreamHandleType type; |
|||
union { |
|||
int fd; |
|||
SSL * ssl; |
|||
} handle; |
|||
}; |
|||
|
|||
ssize_t streamRead(Stream, void *, size_t); |
|||
ssize_t streamWrite(Stream, void *, size_t); |
|||
|
|||
#endif // __STREAM_STREAM_H__ |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,138 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2012 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef __TREE_H__ |
|||
#define __TREE_H__ |
|||
|
|||
#include "class.h" |
|||
|
|||
#define TREE_RIGHT(node) (NULL!=(node)?(node)->right:NULL) |
|||
#define TREE_LEFT(node) (NULL!=(node)?(node)->left:NULL) |
|||
#define TREE_PARENT(node) (NULL!=(node)?(node)->parent:NULL) |
|||
|
|||
#define TREE_CHILD(node) \ |
|||
(NULL==TREE_RIGHT((node))?TREE_LEFT((node)):TREE_RIGHT((node))) |
|||
|
|||
#define TREE_RIGHT_LEFT(node) \ |
|||
(NULL!=TREE_RIGHT((node))?TREE_LEFT(TREE_RIGHT((node))):NULL) |
|||
|
|||
#define TREE_LEFT_RIGHT(node) \ |
|||
(NULL!=TREE_LEFT((node))?TREE_RIGHT(TREE_LEFT((node))):NULL) |
|||
|
|||
#define TREE_SIBLING(node) \ |
|||
(NULL!=TREE_PARENT((node))? \ |
|||
((node)==TREE_PARENT((node))->left? \ |
|||
TREE_PARENT((node))->right: \ |
|||
TREE_PARENT((node))->left): \ |
|||
NULL) |
|||
|
|||
#define TREE_GRANDPARENT(node) \ |
|||
(NULL!=TREE_PARENT((node))?TREE_PARENT((node))->parent:NULL) |
|||
|
|||
#define TREE_UNCLE(node) \ |
|||
(NULL!=TREE_GRANDPARENT((node))? \ |
|||
(TREE_PARENT((node))==TREE_GRANDPARENT((node))->left? \ |
|||
TREE_GRANDPARENT((node))->right: \ |
|||
TREE_GRANDPARENT((node))->left): \ |
|||
NULL) |
|||
|
|||
#define TREE_ROTATE_LEFT(root, node) \ |
|||
do { \ |
|||
if (NULL != TREE_RIGHT_LEFT((node))) { \ |
|||
TREE_RIGHT_LEFT((node))->parent = (node); \ |
|||
} \ |
|||
TREE_RIGHT((node))->left = (node); \ |
|||
if (NULL != TREE_PARENT((node))) { \ |
|||
if (TREE_PARENT((node))->left==(node)) { \ |
|||
TREE_PARENT((node))->left = (node)->right; \ |
|||
} else { \ |
|||
TREE_PARENT((node))->right = (node)->right; \ |
|||
} \ |
|||
} else { \ |
|||
*(root) = (node)->right; \ |
|||
} \ |
|||
(node)->right = TREE_RIGHT_LEFT((node)); \ |
|||
(node)->parent = (node)->right; \ |
|||
TREE_RIGHT((node))->parent = (node)->parent; \ |
|||
} while(0) |
|||
|
|||
#define TREE_ROTATE_RIGHT(root, node) \ |
|||
do { \ |
|||
if (NULL != TREE_LEFT_RIGHT((node))) { \ |
|||
TREE_LEFT_RIGHT((node))->parent = (node); \ |
|||
} \ |
|||
TREE_LEFT((node))->right = (node); \ |
|||
if (NULL != TREE_PARENT((node))) { \ |
|||
if (TREE_PARENT((node))->left==(node)) { \ |
|||
TREE_PARENT((node))->left = (node)->left; \ |
|||
} else { \ |
|||
TREE_PARENT((node))->right = (node)->left; \ |
|||
} \ |
|||
} else { \ |
|||
*(root) = (node)->left; \ |
|||
} \ |
|||
TREE_LEFT((node))->parent = (node)->parent; \ |
|||
(node)->left = TREE_LEFT_RIGHT((node)); \ |
|||
(node)->parent = (node)->right; \ |
|||
} while(0) |
|||
|
|||
#define TREE_REPLACE_NODE(root, node1, node2) \ |
|||
do { \ |
|||
if (NULL != TREE_PARENT((node1))) { \ |
|||
if ((node1) == TREE_PARENT((node1))->left) { \ |
|||
TREE_PARENT((node1))->left = (node2); \ |
|||
} else { \ |
|||
TREE_PARENT((node1))->right = (node2); \ |
|||
} \ |
|||
} else { \ |
|||
*(root) = (node2); \ |
|||
} \ |
|||
if (NULL != (node2)) { \ |
|||
(node2)->parent = (node1)->parent; \ |
|||
} \ |
|||
} while(0) |
|||
|
|||
|
|||
enum rbColor {rbBlack=1, rbRed=2}; |
|||
|
|||
CLASS(Tree) { |
|||
void * data; |
|||
|
|||
enum rbColor color; |
|||
|
|||
Tree parent; |
|||
Tree left; |
|||
Tree right; |
|||
}; |
|||
|
|||
typedef int (*TreeComp)(const void *, const void *); |
|||
typedef void (*TreeAction)(const void *, const int); |
|||
|
|||
void * treeFind(Tree, const void *, TreeComp); |
|||
void * treeInsert(Tree *, const void *, TreeComp); |
|||
void * treeDelete(Tree *, const void *, TreeComp); |
|||
void treeWalk(Tree, TreeAction); |
|||
void treeDestroy(Tree *, TreeAction); |
|||
|
|||
#endif // __TREE_H__ |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,33 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* Functions to handle varios signals send to the application. |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2012 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef __UTILS_HASH_H__ |
|||
#define __UTILS_HASH_H__ |
|||
|
|||
#include <sys/types.h> |
|||
|
|||
unsigned long sdbm(const unsigned char *, size_t); |
|||
|
|||
#endif // __UTILS_HASH_H__ |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,40 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2012 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef __UTILS_MEMORY_H__ |
|||
#define __UTILS_MEMORY_H__ |
|||
|
|||
#define CSTRA(val) val, sizeof(val)-1 //!< Const STRing Argument |
|||
|
|||
#define MEM_FREE(seg) (memFree((void **)&(seg))) |
|||
|
|||
#include <sys/types.h> |
|||
|
|||
void * memMalloc(size_t); |
|||
void * memCalloc(size_t, size_t); |
|||
void memFree(void **); |
|||
size_t memGetSize(void *); |
|||
void memCleanup(); |
|||
|
|||
#endif // __UTILS_MEMORY_H__ |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -1,73 +0,0 @@ |
|||
/** |
|||
* \file |
|||
* ways to create uuid variant 5. For uuid of variant 1 I use |
|||
* the implementation delivered with the core utils. |
|||
* But this is wrapped in here, so that the rest of the code |
|||
* can use only this implementation...this additionally has the |
|||
* advantage that we can implement version 1 here too for systems |
|||
* where the coreutils implementation is not available. |
|||
* |
|||
* \author Georg Hopp |
|||
* |
|||
* \copyright |
|||
* Copyright © 2012 Georg Hopp |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef __UUID_H__ |
|||
#define __UUID_H__ |
|||
|
|||
#include <stdint.h> |
|||
#include <sys/types.h> |
|||
#include <uuid/uuid.h> |
|||
|
|||
#include "class.h" |
|||
#include "commons.h" |
|||
|
|||
|
|||
typedef char UuidString[37]; |
|||
|
|||
CLASS(Uuid) { |
|||
union { |
|||
uuid_t value; |
|||
struct { |
|||
uint32_t time_low; |
|||
uint16_t time_mid; |
|||
uint16_t time_hi_version; |
|||
uint8_t clk_seq_hi_res; |
|||
uint8_t clk_seq_low; |
|||
unsigned char node[6]; |
|||
} elements; |
|||
} uuid; |
|||
}; |
|||
|
|||
extern Uuid uuidZero; |
|||
|
|||
/* |
|||
* generator functions...these are not really part of the object |
|||
* but generate a uuid object. |
|||
*/ |
|||
Uuid uuidVersion1(); |
|||
Uuid uuidVersion3(const unsigned char *, size_t, Uuid); |
|||
Uuid uuidVersion5(const unsigned char *, size_t, Uuid); |
|||
|
|||
void uuidUnparse(Uuid, UuidString); |
|||
Uuid uuidParse(const UuidString); |
|||
|
|||
int uuidCompare(Uuid, Uuid); |
|||
|
|||
#endif // __UUID_H__ |
|||
|
|||
// vim: set ts=4 sw=4: |
|||
@ -0,0 +1,24 @@ |
|||
AC_DEFUN([AC_TRLIBS_ROOT], |
|||
[ |
|||
AC_ARG_VAR([TRLIBS_ROOT], |
|||
[ |
|||
The installation root of the taskrambler libraries |
|||
]) |
|||
|
|||
AS_IF([test "$TRLIBS_ROOT"], |
|||
[ |
|||
AC_MSG_NOTICE("Using ${TRLIBS_ROOT} as installation root for libtrbase") |
|||
CFLAGS="${CFLAGS} -I${TRLIBS_ROOT}/include" |
|||
LDFLAGS="${LDFLAGS} -L${TRLIBS_ROOT}/lib -lgdbm -luuid" |
|||
]) |
|||
]) |
|||
|
|||
AC_DEFUN([AC_NEED_TRBASE], |
|||
[ |
|||
AC_CHECK_LIB([trbase], [TR_classNew], [], |
|||
[ |
|||
AC_MSG_ERROR([Needed trbase library not found may try to set TRLIBS_ROOT]) |
|||
]) |
|||
]) |
|||
|
|||
# vim: set ft=m4 ts=2 sw=2: |
|||
Some files were not shown because too many files changed in this diff
Write
Preview
Loading…
Cancel
Save
Reference in new issue