Browse Source

utilize libtrdata

next
Georg Hopp 12 years ago
parent
commit
5849bb7274
  1. 4
      configure.ac
  2. 26
      include/application/application.h
  3. 1
      include/asset.h
  4. 79
      include/cbuf.h
  5. 6
      include/config/config.h
  6. 1
      include/config/value.h
  7. 10
      include/hash.h
  8. 48
      include/hash/hash.h
  9. 43
      include/hash/interface/hashable.h
  10. 42
      include/hash/value.h
  11. 15
      include/http/message.h
  12. 7
      include/http/parser.h
  13. 8
      include/http/request.h
  14. 22
      include/http/worker.h
  15. 4
      include/http/writer.h
  16. 58
      include/queue.h
  17. 8
      include/router.h
  18. 138
      include/tree.h
  19. 17
      src/Makefile.am
  20. 9
      src/application/adapter/http/update.c
  21. 9
      src/application/application.c
  22. 10
      src/application/controller/_get_credential_from_args.c
  23. 10
      src/application/controller/_get_user_from_args.c
  24. 8
      src/application/controller/_process_user_create_args.c
  25. 10
      src/application/controller/_update_user_from_args.c
  26. 1
      src/application/controller/_validate_password.c
  27. 1
      src/application/controller/_validate_password_repeat.c
  28. 21
      src/application/controller/authenticate/create.c
  29. 8
      src/application/controller/authenticate/delete.c
  30. 4
      src/application/controller/currentuser/read.c
  31. 5
      src/application/controller/loc/read.c
  32. 5
      src/application/controller/randval/read.c
  33. 5
      src/application/controller/sessinfo/read.c
  34. 8
      src/application/controller/signup/create.c
  35. 8
      src/application/controller/user/create.c
  36. 14
      src/application/controller/user/read.c
  37. 8
      src/application/controller/user/update.c
  38. 4
      src/application/controller/version/read.c
  39. 11
      src/application/session_cleanup.c
  40. 7
      src/application/session_get.c
  41. 5
      src/application/session_start.c
  42. 4
      src/application/session_stop.c
  43. 5
      src/asset/asset.c
  44. 14
      src/asset/pool.c
  45. 16
      src/cbuf/Makefile.am
  46. 33
      src/cbuf/addr_index.c
  47. 123
      src/cbuf/cbuf.c
  48. 32
      src/cbuf/empty.c
  49. 41
      src/cbuf/get_data.c
  50. 33
      src/cbuf/get_free.c
  51. 49
      src/cbuf/get_line.c
  52. 31
      src/cbuf/get_read.c
  53. 31
      src/cbuf/get_write.c
  54. 36
      src/cbuf/inc_read.c
  55. 36
      src/cbuf/inc_write.c
  56. 31
      src/cbuf/is_empty.c
  57. 31
      src/cbuf/is_locked.c
  58. 31
      src/cbuf/lock.c
  59. 33
      src/cbuf/memchr.c
  60. 51
      src/cbuf/read.c
  61. 31
      src/cbuf/release.c
  62. 45
      src/cbuf/set_data.c
  63. 34
      src/cbuf/skip_non_alpha.c
  64. 6
      src/config/config.c
  65. 5
      src/config/get.c
  66. 5
      src/config/value.c
  67. 12
      src/hash/Makefile.am
  68. 63
      src/hash/add.c
  69. 40
      src/hash/cleanup.c
  70. 67
      src/hash/delete.c
  71. 45
      src/hash/each.c
  72. 67
      src/hash/get.c
  73. 39
      src/hash/get_first.c
  74. 58
      src/hash/hash.c
  75. 48
      src/hash/interface/hashable.c
  76. 108
      src/hash/value.c
  77. 10
      src/http/header.c
  78. 4
      src/http/message.c
  79. 4
      src/http/message/has_keep_alive.c
  80. 4
      src/http/message/header_size_get.c
  81. 4
      src/http/message/header_to_string.c
  82. 9
      src/http/parser.c
  83. 5
      src/http/parser/p_body.c
  84. 8
      src/http/parser/p_header.c
  85. 8
      src/http/parser/p_post_vars.c
  86. 6
      src/http/parser/p_request_vars.c
  87. 49
      src/http/parser/parse.c
  88. 8
      src/http/request.c
  89. 8
      src/http/response/304.c
  90. 4
      src/http/response/404.c
  91. 4
      src/http/response/500.c
  92. 10
      src/http/response/asset.c
  93. 4
      src/http/response/json.c
  94. 10
      src/http/worker.c
  95. 12
      src/http/worker/add_common_header.c
  96. 8
      src/http/worker/add_computed_header.c
  97. 4
      src/http/worker/get_asset.c
  98. 8
      src/http/worker/process.c
  99. 4
      src/http/writer.c
  100. 6
      src/http/writer/write.c

4
configure.ac

@ -92,13 +92,9 @@ AC_CONFIG_FILES([Makefile
src/Makefile
src/asset/Makefile
src/auth/Makefile
src/cbuf/Makefile
src/hash/Makefile
src/queue/Makefile
src/http/Makefile
src/server/Makefile
src/session/Makefile
src/tree/Makefile
src/application/Makefile
src/storage/Makefile
src/user/Makefile

26
include/application/application.h

@ -25,11 +25,11 @@
#include <sys/types.h>
#include <trbase.h>
#include <trhash.h>
#include "trbase.h"
#include "trhash.h"
#include "trdata.h"
#include "session.h"
#include "hash.h"
#include "auth.h"
#include "auth/credential.h"
#include "storage/storage.h"
@ -43,24 +43,24 @@ struct randval {
};
TR_CLASS(Application) {
Hash * active_sessions;
TR_Hash * active_sessions;
time_t session_time_ofs;
Auth auth;
struct randval * val;
struct randval * val;
Storage users;
Storage passwords;
Storage roles;
Storage users;
Storage passwords;
Storage roles;
TR_Uuid user_namespace;
TR_Uuid user_namespace;
Hash roles_user_index;
Hash roles_resource_index;
TR_Hash roles_user_index;
TR_Hash roles_resource_index;
const char * version;
const char * loc;
const char * version;
const char * loc;
};
int applicationLogin(Application, Credential, Session);

1
include/asset.h

@ -27,7 +27,6 @@
#include <sys/types.h>
#include "trbase.h"
#include "hash.h"
TR_CLASS(Asset) {

79
include/cbuf.h

@ -1,79 +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 "trbase.h"
#include "trio.h"
#define ECBUFOVFL 100
TR_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, TR_Stream);
ssize_t cbufWrite(Cbuf, TR_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:

6
include/config/config.h

@ -24,15 +24,15 @@
#define __CONFIG_H__
#include "trbase.h"
#include "hash.h"
#include "trdata.h"
#include "config/value.h"
#define MAX_CONFIG_LINE 256
TR_CLASS(Config) {
char * cnf_file;
Hash config;
char * cnf_file;
TR_Hash config;
};
ConfigValue configGet(Config, const char *, size_t);

1
include/config/value.h

@ -26,7 +26,6 @@
#include <sys/types.h>
#include "trbase.h"
#include "hash.h"
#define MAX_CONFIG_LINE 256

10
include/hash.h

@ -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:

48
include/hash/hash.h

@ -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 "trbase.h"
#include "tree.h"
#define HASH_IS_EMPTY(h) ((h)->root)
TR_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:

43
include/hash/interface/hashable.h

@ -1,43 +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 "trbase.h"
typedef unsigned long (* fptr_hashableGetHash)(void *);
typedef void (* fptr_hashableHandleDouble)(void *, void *);
TR_INTERFACE(Hashable) {
TR_IFID;
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:

42
include/hash/value.h

@ -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 "trbase.h"
TR_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:

15
include/http/message.h

@ -25,20 +25,19 @@
#define __HTTP_MESSAGE__
#include "trbase.h"
#include "trio.h"
#include "hash.h"
#include "trdata.h"
#include "asset.h"
TR_CLASS(HttpMessage) {
char * version;
char * version;
Hash header;
TR_Hash header;
Asset asset;
char * body;
Asset asset;
char * body;
int nbody;
int dbody;
int nbody;
int dbody;
};
char httpMessageHasKeepAlive(HttpMessage);

7
include/http/parser.h

@ -26,9 +26,8 @@
#include "trbase.h"
#include "trio.h"
#include "trdata.h"
#include "http/message.h"
#include "queue.h"
#include "cbuf.h"
#define PARSER_MAX_BUF 131072
@ -44,13 +43,13 @@ typedef enum e_HttpMessageState {
TR_CLASS(HttpParser) {
Cbuf buffer;
TR_Cbuf buffer;
Bool ourLock;
char * incomplete;
size_t isize;
Queue queue;
TR_Queue queue;
HttpMessage current;
HttpMessageState state;

8
include/http/request.h

@ -25,8 +25,8 @@
#define __HTTP_REQUEST_H__
#include "trbase.h"
#include "trdata.h"
#include "http/message.h"
#include "hash.h"
#define N_HTTP_METHOD 8
@ -52,9 +52,9 @@ TR_CLASS(HttpRequest) {
HttpMethod method_id;
Hash get;
Hash post;
Hash cookies;
TR_Hash get;
TR_Hash post;
TR_Hash cookies;
};
HttpMethod httpRequestGetMethodId(HttpRequest);

22
include/http/worker.h

@ -28,32 +28,30 @@
#include <time.h>
#include "trbase.h"
#include "hash.h"
#include "trdata.h"
#include "http/parser.h"
#include "http/writer.h"
#include "cbuf.h"
#include "session.h"
#include "http/request.h"
#include "http/response.h"
#include "queue.h"
TR_CLASS(HttpWorker) {
char * id;
char * id;
Cbuf pbuf;
Hash asset_pool;
TR_Cbuf pbuf;
TR_Hash asset_pool;
void * application_adapter;
void * application_adapter;
HttpRequest current_request;
HttpMessage current_response;
HttpRequest current_request;
HttpMessage current_response;
Queue additional_headers;
TR_Queue additional_headers;
HttpParser parser;
HttpWriter writer;
HttpParser parser;
HttpWriter writer;
};
#endif // __HTTP_WORKER_H__

4
include/http/writer.h

@ -28,8 +28,8 @@
#include "trbase.h"
#include "trio.h"
#include "trdata.h"
#include "http/message.h"
#include "queue.h"
/*
@ -79,7 +79,7 @@ typedef enum e_HttpWriterState {
TR_CLASS(HttpWriter) {
char * buffer;
Queue queue;
TR_Queue queue;
HttpMessage current;
size_t nbuffer; // size of buffer

58
include/queue.h

@ -1,58 +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 "trbase.h"
TR_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:

8
include/router.h

@ -34,22 +34,22 @@
#include <dlfcn.h>
#include "trbase.h"
#include "hash.h"
#include "trdata.h"
#include "session.h"
#include "http/request.h"
#include "http/response.h"
#include "application/application.h"
typedef char * (* fptr_routable)(Application, Session, Hash);
typedef char * (* fptr_routable)(Application, Session, TR_Hash);
TR_CLASS(Router) {
Hash functions;
TR_Hash functions;
Application application;
void * handle;
char * prefix;
size_t nprefix;
};
HttpResponse routerRoute(Router, HttpRequest, Session);

138
include/tree.h

@ -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 "trbase.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};
TR_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:

17
src/Makefile.am

@ -7,11 +7,6 @@ TRUTILS = utils/http.c \
utils/signalHandling.c \
utils/mime_type.c
TRCOMMONLIBS = cbuf/libcbuf.la \
hash/libhash.la \
queue/libqueue.la \
tree/libtree.la
TRHTTPSERVER = http/libhttp.la \
asset/libasset.la \
server/libserver.la
@ -24,22 +19,18 @@ TR = ./application/.libs/libapplication.a \
./config/.libs/libconfig.a \
./router/.libs/librouter.a
TRLIBS = -ltrbase -ltrhashing -ltrio -ltrutils -ltrhttpserver -ltrcommon
TRLIBS = -ltrbase -ltrhashing -ltrio -ltrdata -ltrutils -ltrhttpserver
USEDLIBS = -lrt -lssl -lcrypto -lldap -lgdbm -luuid
AM_CFLAGS += -I../include/
bin_PROGRAMS = taskrambler
lib_LTLIBRARIES = libtrutils.la libtrcommon.la libtrhttpserver.la
lib_LTLIBRARIES = libtrutils.la libtrhttpserver.la
libtrutils_la_SOURCES = $(TRUTILS)
libtrutils_la_CFLAGS = $(AM_CFLAGS)
libtrutils_la_LIBADD =
libtrcommon_la_SOURCES =
libtrcommon_la_CFLAGS = $(AM_CFLAGS)
libtrcommon_la_LIBADD = $(TRCOMMONLIBS)
libtrhttpserver_la_SOURCES =
libtrhttpserver_la_CFLAGS = $(AM_CFLAGS)
libtrhttpserver_la_LIBADD = $(TRHTTPSERVER)
@ -50,6 +41,6 @@ taskrambler_LDADD = $(TRLIBS) $(TR) $(USEDLIBS)
taskrambler_LDFLAGS = -Wl,--export-dynamic \
-Wl,--whole-archive,./application/.libs/libapplication.a,--no-whole-archive
SUBDIRS = asset auth cbuf hash queue http \
server session tree application \
SUBDIRS = asset auth http \
server session application \
storage user config router

9
src/application/adapter/http/update.c

@ -26,9 +26,10 @@
#include <sys/types.h>
#include "trbase.h"
#include "trdata.h"
#include "application/application.h"
#include "application/adapter/http.h"
#include "hash.h"
#include "http/worker.h"
#include "http/header.h"
#include "http/message.h"
@ -39,9 +40,9 @@
static
inline
char *
getSessionId(Hash cookies)
getSessionId(TR_Hash cookies)
{
HashValue sidstr = hashGet(cookies, CSTRA("sid"));
TR_HashValue sidstr = TR_hashGet(cookies, CSTRA("sid"));
if (NULL != sidstr) {
return (char*)sidstr->value;
@ -73,7 +74,7 @@ applicationAdapterHttpUpdate(void * _this, void * subject)
// send session cookie
nbuf = sprintf(buf, "sid=%s;Path=/", session->id);
queuePut(
TR_queuePut(
worker->additional_headers,
TR_new(HttpHeader, CSTRA("Set-Cookie"), buf, nbuf));

9
src/application/application.c

@ -24,8 +24,9 @@
#include <stdarg.h>
#include <trbase.h>
#include <trhash.h>
#include "trbase.h"
#include "trhash.h"
#include "trdata.h"
#include "application/application.h"
#include "storage/storage.h"
@ -56,9 +57,9 @@ applicationCtor(void * _this, va_list * params)
this->auth = va_arg(*params, void *);
this->active_sessions = TR_calloc(SESSION_LIVETIME, sizeof(Hash));
this->active_sessions = TR_calloc(SESSION_LIVETIME, sizeof(TR_Hash));
for (i=0; i<SESSION_LIVETIME; i++) {
this->active_sessions[i] = TR_new(Hash);
this->active_sessions[i] = TR_new(TR_Hash);
}
this->version = VERSION;

10
src/application/controller/_get_credential_from_args.c

@ -23,18 +23,18 @@
#define _GNU_SOURCE
#include "trbase.h"
#include "hash.h"
#include "trdata.h"
#include "auth/credential.h"
int _controllerValidatePasswordRepeat(char *, size_t, char *, size_t);
Credential
_controllerGetCredentialFromArgs(Hash args)
_controllerGetCredentialFromArgs(TR_Hash args)
{
HashValue email = hashGet(args, CSTRA("email"));
HashValue password = hashGet(args, CSTRA("password"));
HashValue pwrepeat = hashGet(args, CSTRA("pwrepeat"));
TR_HashValue email = TR_hashGet(args, CSTRA("email"));
TR_HashValue password = TR_hashGet(args, CSTRA("password"));
TR_HashValue pwrepeat = TR_hashGet(args, CSTRA("pwrepeat"));
if (
NULL == email ||

10
src/application/controller/_get_user_from_args.c

@ -25,16 +25,16 @@
#include <trbase.h>
#include <trhash.h>
#include "hash.h"
#include "trdata.h"
#include "user.h"
User
_controllerGetUserFromArgs(Hash args)
_controllerGetUserFromArgs(TR_Hash args)
{
HashValue email = hashGet(args, CSTRA("email"));
HashValue firstname = hashGet(args, CSTRA("firstname"));
HashValue surname = hashGet(args, CSTRA("surname"));
TR_HashValue email = TR_hashGet(args, CSTRA("email"));
TR_HashValue firstname = TR_hashGet(args, CSTRA("firstname"));
TR_HashValue surname = TR_hashGet(args, CSTRA("surname"));
if (
NULL == email ||

8
src/application/controller/_process_user_create_args.c

@ -23,16 +23,16 @@
#define _GNU_SOURCE
#include "trbase.h"
#include "hash.h"
#include "trdata.h"
#include "user.h"
#include "auth/credential.h"
User _controllerGetUserFromArgs(Hash args);
Credential _controllerGetCredentialFromArgs(Hash args);
User _controllerGetUserFromArgs(TR_Hash args);
Credential _controllerGetCredentialFromArgs(TR_Hash args);
int
_controllerProcessUserCreateArgs(Hash args, User * user, Credential * cred)
_controllerProcessUserCreateArgs(TR_Hash args, User * user, Credential * cred)
{
*user = _controllerGetUserFromArgs(args);
*cred = _controllerGetCredentialFromArgs(args);

10
src/application/controller/_update_user_from_args.c

@ -24,17 +24,17 @@
#include <trbase.h>
#include <trhash.h>
#include <trdata.h>
#include "hash.h"
#include "user.h"
int
_controllerUpdateUserFromArgs(Hash args, User * user)
_controllerUpdateUserFromArgs(TR_Hash args, User * user)
{
HashValue email = hashGet(args, CSTRA("email"));
HashValue firstname = hashGet(args, CSTRA("firstname"));
HashValue surname = hashGet(args, CSTRA("surname"));
TR_HashValue email = TR_hashGet(args, CSTRA("email"));
TR_HashValue firstname = TR_hashGet(args, CSTRA("firstname"));
TR_HashValue surname = TR_hashGet(args, CSTRA("surname"));
User new_user;
if (

1
src/application/controller/_validate_password.c

@ -21,7 +21,6 @@
*/
#include "trbase.h"
#include "hash.h"
#include "auth/credential.h"

1
src/application/controller/_validate_password_repeat.c

@ -21,7 +21,6 @@
*/
#include "trbase.h"
#include "hash.h"
#include "auth/credential.h"
int

21
src/application/controller/authenticate/create.c

@ -23,32 +23,33 @@
#define _GNU_SOURCE
#include "trbase.h"
#include "trdata.h"
#include "application/application.h"
#include "session.h"
#include "hash.h"
#include "auth/credential.h"
#include "user.h"
char * controllerCurrentuserRead(Application, Session, Hash);
char * controllerCurrentuserRead(Application, Session, TR_Hash);
char *
controllerAuthenticateCreate(
Application application,
Session session,
Hash args)
TR_Hash args)
{
HashValue username;
HashValue password;
Credential credential;
TR_HashValue username;
TR_HashValue password;
Credential credential;
char * response_data;
char * response_data;
username = hashGet(args, CSTRA("username"));
password = hashGet(args, CSTRA("password"));
username = TR_hashGet(args, CSTRA("username"));
password = TR_hashGet(args, CSTRA("password"));
if (NULL == username) {
username = hashGet(args, CSTRA("email"));
username = TR_hashGet(args, CSTRA("email"));
}
if (NULL == username || NULL == password) {

8
src/application/controller/authenticate/delete.c

@ -22,18 +22,18 @@
#define _GNU_SOURCE
#include "trdata.h"
#include "application/application.h"
#include "session.h"
#include "hash.h"
char * controllerCurrentuserRead(Application, Session, Hash);
char * controllerCurrentuserRead(Application, Session, TR_Hash);
char *
controllerAuthenticateDelete(
Application application,
Session session,
Hash args)
TR_Hash args)
{
applicationLogout(application, session);
return controllerCurrentuserRead(application, session, NULL);

4
src/application/controller/currentuser/read.c

@ -26,16 +26,16 @@
#include <stdio.h>
#include "trbase.h"
#include "trdata.h"
#include "application/application.h"
#include "session.h"
#include "hash.h"
#define USER_JSON \
"{\"username\":\"%s\",\"email\":\"%s\",\"firstname\":\"%s\",\"surname\":\"%s\"}"
char *
controllerCurrentuserRead(Application app, Session sess, Hash args)
controllerCurrentuserRead(Application app, Session sess, TR_Hash args)
{
char * buffer;
size_t nbuffer;

5
src/application/controller/loc/read.c

@ -26,14 +26,15 @@
#include <stdio.h>
#include "trbase.h"
#include "trdata.h"
#include "application/application.h"
#include "hash.h"
#include "session.h"
#define LOC_JSON "{\"loc\":\"%s\"}"
char *
controllerLocRead(Application app, Session sess, Hash args)
controllerLocRead(Application app, Session sess, TR_Hash args)
{
char * buffer;
size_t nbuffer;

5
src/application/controller/randval/read.c

@ -26,15 +26,16 @@
#include <stdio.h>
#include "trbase.h"
#include "trdata.h"
#include "application/application.h"
#include "session.h"
#include "hash.h"
#define RANDVAL_JSON "{\"ctime\":%ld,\"vnext\":%ld,\"value\":\"%02d\"}"
char *
controllerRandvalRead(Application app, Session sess, Hash args)
controllerRandvalRead(Application app, Session sess, TR_Hash args)
{
char * buffer;
size_t nbuffer;

5
src/application/controller/sessinfo/read.c

@ -26,9 +26,10 @@
#include <sys/types.h>
#include "trbase.h"
#include "trdata.h"
#include "application/application.h"
#include "session.h"
#include "hash.h"
#define SESSION_JSON "{\"id\":\"%s\",\"timeout\":%d,\"timeleft\":%ld}"
@ -37,7 +38,7 @@ char *
controllerSessinfoRead(
Application application,
Session session,
Hash args)
TR_Hash args)
{
char * buffer;
size_t nbuffer;

8
src/application/controller/signup/create.c

@ -24,23 +24,23 @@
#include <trbase.h>
#include <trhash.h>
#include <trdata.h>
#include "application/application.h"
#include "session.h"
#include "hash.h"
#include "auth/credential.h"
#include "user.h"
char * controllerCurrentuserRead(Application, Session, Hash);
int _controllerProcessUserCreateArgs(Hash, User *, Credential *);
char * controllerCurrentuserRead(Application, Session, TR_Hash);
int _controllerProcessUserCreateArgs(TR_Hash, User *, Credential *);
char *
controllerSignupCreate(
Application application,
Session session,
Hash args)
TR_Hash args)
{
Credential credential;
User user;

8
src/application/controller/user/create.c

@ -24,22 +24,22 @@
#include <trbase.h>
#include <trhash.h>
#include <trdata.h>
#include "application/application.h"
#include "session.h"
#include "hash.h"
#include "auth/credential.h"
#include "user.h"
char * controllerCurrentuserRead(Application, Session, Hash);
int _controllerProcessUserCreateArgs(Hash, User *, Credential *);
char * controllerCurrentuserRead(Application, Session, TR_Hash);
int _controllerProcessUserCreateArgs(TR_Hash, User *, Credential *);
char *
controllerUserCreate(
Application application,
Session session,
Hash args)
TR_Hash args)
{
Credential credential;
User user;

14
src/application/controller/user/read.c

@ -27,23 +27,23 @@
#include <trbase.h>
#include <trhash.h>
#include <trdata.h>
#include "application/application.h"
#include "session.h"
#include "hash.h"
#define USER_JSON \
"{\"email\":\"%s\",\"firstname\":\"%s\",\"surname\":\"%s\"}"
char *
controllerUserRead(Application app, Session sess, Hash args)
controllerUserRead(Application app, Session sess, TR_Hash args)
{
char * buffer;
size_t nbuffer;
HashValue id = hashGet(args, CSTRA("id"));
TR_Uuid search = TR_uuidParse(id->value);
User user = applicationGetUser(app, search);
char * buffer;
size_t nbuffer;
TR_HashValue id = TR_hashGet(args, CSTRA("id"));
TR_Uuid search = TR_uuidParse(id->value);
User user = applicationGetUser(app, search);
nbuffer = snprintf(NULL, 0, USER_JSON,
user->email,

8
src/application/controller/user/update.c

@ -24,21 +24,21 @@
#include <trbase.h>
#include <trhash.h>
#include <trdata.h>
#include "application/application.h"
#include "session.h"
#include "hash.h"
#include "user.h"
char * controllerCurrentuserRead(Application, Session, Hash);
int _controllerUpdateUserFromArgs(Hash, User *);
char * controllerCurrentuserRead(Application, Session, TR_Hash);
int _controllerUpdateUserFromArgs(TR_Hash, User *);
char *
controllerUserUpdate(
Application application,
Session session,
Hash args)
TR_Hash args)
{
TR_Uuid user_id;

4
src/application/controller/version/read.c

@ -26,14 +26,14 @@
#include <stdio.h>
#include "trbase.h"
#include "trdata.h"
#include "application/application.h"
#include "hash.h"
#include "session.h"
#define VERSION_JSON "{\"version\":\"%s\"}"
char *
controllerVersionRead(Application app, Session sess, Hash args)
controllerVersionRead(Application app, Session sess, TR_Hash args)
{
char * buffer;
size_t nbuffer;

11
src/application/session_cleanup.c

@ -25,9 +25,10 @@
#include <stdlib.h>
#include <sys/types.h>
#include "trdata.h"
#include "trbase.h"
#include "session.h"
#include "hash.h"
#include "application/application.h"
@ -42,23 +43,23 @@ applicationSessionCleanup(Application this, time_t now)
}
if (0 < expired && SESSION_LIVETIME > expired) {
Hash * tmp_buf = TR_calloc(SESSION_LIVETIME, sizeof(Hash));
TR_Hash * tmp_buf = TR_calloc(SESSION_LIVETIME, sizeof(TR_Hash));
memcpy(
&(tmp_buf[expired]),
this->active_sessions,
(SESSION_LIVETIME - expired) * sizeof(Hash));
(SESSION_LIVETIME - expired) * sizeof(TR_Hash));
memcpy(
tmp_buf,
&(this->active_sessions[SESSION_LIVETIME - expired]),
expired * sizeof(Hash));
expired * sizeof(TR_Hash));
TR_MEM_FREE(this->active_sessions);
this->active_sessions = tmp_buf;
}
for (i=0; i<expired; i++) {
hashCleanup(this->active_sessions[i]);
TR_hashCleanup(this->active_sessions[i]);
}
this->session_time_ofs = now;

7
src/application/session_get.c

@ -24,8 +24,9 @@
#include <sys/types.h>
#include "trdata.h"
#include "session.h"
#include "hash.h"
#include "application/application.h"
@ -40,7 +41,7 @@ applicationSessionGet(Application this, const char * sid)
* now get the session if not expired
*/
for (index=0; index<SESSION_LIVETIME; index++) {
sess = (Session)hashDelete(
sess = (Session)TR_hashDelete(
(this->active_sessions)[index], sid, 36);
if (NULL != sess) {
break;
@ -52,7 +53,7 @@ applicationSessionGet(Application this, const char * sid)
*/
if (NULL != sess) {
sess->livetime = this->session_time_ofs + SESSION_LIVETIME;
hashAdd((this->active_sessions)[0], sess);
TR_hashAdd((this->active_sessions)[0], sess);
}
}

5
src/application/session_start.c

@ -26,8 +26,9 @@
#include <sys/types.h>
#include "trbase.h"
#include "trdata.h"
#include "session.h"
#include "hash.h"
#include "application/application.h"
@ -36,7 +37,7 @@ applicationSessionStart(Application this)
{
Session sess = TR_new(Session);
hashAdd((this->active_sessions)[0], sess);
TR_hashAdd((this->active_sessions)[0], sess);
return sess;
}

4
src/application/session_stop.c

@ -24,6 +24,8 @@
#include <sys/types.h>
#include "trdata.h"
#include "session.h"
#include "application/application.h"
@ -35,7 +37,7 @@ applicationSessionStop(Application this, Session session)
(session->livetime - this->session_time_ofs);
if (SESSION_LIVETIME > index) {
hashDeleteByVal((this->active_sessions)[index], session->hash);
TR_hashDeleteByVal((this->active_sessions)[index], session->hash);
}
}

5
src/asset/asset.c

@ -40,7 +40,6 @@
#include <trhash.h>
#include "asset.h"
#include "hash.h"
#include "utils/mime_type.h"
#include "utils/http.h"
@ -139,7 +138,7 @@ assetHandleDouble(void * _this, void * _doub)
}
TR_INIT_IFACE(TR_Class, assetCtor, assetDtor, NULL);
TR_INIT_IFACE(Hashable, assetGetHash, assetHandleDouble);
TR_CREATE_CLASS(Asset, NULL, TR_IF(TR_Class), TR_IF(Hashable));
TR_INIT_IFACE(TR_Hashable, assetGetHash, assetHandleDouble);
TR_CREATE_CLASS(Asset, NULL, TR_IF(TR_Class), TR_IF(TR_Hashable));
// vim: set ts=4 sw=4:

14
src/asset/pool.c

@ -26,10 +26,10 @@
// for strlen
#include "trbase.h"
#include "trdata.h"
#include "asset.h"
#include "hash.h"
Hash asset_pool = NULL;
TR_Hash asset_pool = NULL;
static
inline
@ -45,15 +45,15 @@ assetPoolGet(const char * path, size_t npath)
Asset asset = NULL;
if (NULL == asset_pool) {
asset_pool = TR_new(Hash);
asset_pool = TR_new(TR_Hash);
} else {
asset = hashGet(asset_pool, path, npath);
asset = TR_hashGet(asset_pool, path, npath);
}
if (NULL == asset) {
asset = TR_new(Asset, path, npath);
if (NULL != asset) {
hashAdd(asset_pool, asset);
TR_hashAdd(asset_pool, asset);
}
} else {
asset->ref_count++;
@ -71,7 +71,7 @@ assetPoolRelease(Asset asset)
}
if (NULL != asset) {
Asset found = (Asset)hashDelete(
Asset found = (Asset)TR_hashDelete(
asset_pool, asset->fname, asset->nfname);
if (found == asset) {
@ -90,7 +90,7 @@ void
assetPoolCleanup(void)
{
if (NULL != asset_pool) {
hashEach(asset_pool, freeAsset);
TR_hashEach(asset_pool, freeAsset);
TR_delete(asset_pool);
}
}

16
src/cbuf/Makefile.am

@ -1,16 +0,0 @@
ACLOCAL_AMFLAGS = -I m4
AUTOMAKE_OPTIONS = subdir-objects
CB = cbuf.c read.c \
get_line.c set_data.c get_data.c \
addr_index.c get_free.c get_read.c get_write.c \
inc_read.c inc_write.c is_empty.c memchr.c \
skip_non_alpha.c is_locked.c lock.c release.c \
empty.c
AM_CFLAGS += -I../../include/
noinst_LTLIBRARIES = libcbuf.la
libcbuf_la_SOURCES = $(CB)
libcbuf_la_CFLAGS = $(AM_CFLAGS)

33
src/cbuf/addr_index.c

@ -1,33 +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/>.
*/
#include <sys/types.h>
#include "cbuf.h"
size_t
cbufAddrIndex(Cbuf this, const void * c)
{
return c - (const void *)cbufGetRead(this);
}
// vim: set ts=4 sw=4:

123
src/cbuf/cbuf.c

@ -1,123 +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/>.
*/
#define _POSIX_SOURCE
#define _POSIX_C_SOURCE 200112L
#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include "trbase.h"
#include "cbuf.h"
static void cbufDtor(void*);
static
int
cbufCtor(void * _this, va_list * params)
{
Cbuf this = _this;
char state = -1;
char * shm_name = va_arg(*params, char*);
long psize = sysconf(_SC_PAGESIZE);
size_t size;
int shm;
char * data;
this->shm_name = TR_malloc(strlen(shm_name) + 7 + 2);
sprintf(this->shm_name, "/%06d_%s", getpid(), shm_name);
/**
* align size at page boundary.
* increase as neccessary
*/
size = va_arg(*params, size_t);
size = (0 >= size)? 1 : (0 != size%psize)? (size/psize)+1 : size/psize;
this->bsize = psize * size;
while (-1 == state) {
shm = shm_open(this->shm_name, O_RDWR|O_CREAT|O_EXCL, S_IRWXU);
if (-1 == shm) {
break;
}
if (-1 == ftruncate(shm, this->bsize)) {
break;
}
this->data = mmap (0, this->bsize << 1,
PROT_NONE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
if (this->data == MAP_FAILED) {
this->data = NULL;
break;
}
data = mmap (this->data, this->bsize,
PROT_READ|PROT_WRITE, MAP_FIXED|MAP_SHARED, shm, 0);
if (data != this->data) {
break;
}
data = mmap (this->data + this->bsize, this->bsize,
PROT_READ|PROT_WRITE, MAP_FIXED|MAP_SHARED, shm, 0);
if (data != this->data + this->bsize) {
break;
}
state = 0;
}
if (-1 != shm) {
shm_unlink(this->shm_name);
close(shm);
}
return state;
}
static
void
cbufDtor(void * _this)
{
Cbuf this = _this;
TR_MEM_FREE(this->shm_name);
if (NULL != this->data && MAP_FAILED != this->data) {
munmap(this->data, this->bsize << 1);
}
this->data = NULL;
}
TR_INIT_IFACE(TR_Class, cbufCtor, cbufDtor, NULL);
TR_CREATE_CLASS(Cbuf, NULL, TR_IF(TR_Class));
// vim: set ts=4 sw=4:

32
src/cbuf/empty.c

@ -1,32 +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/>.
*/
#include "cbuf.h"
void
cbufEmpty(Cbuf this)
{
this->bused = 0;
this->read = this->write;
}
// vim: set ts=4 sw=4:

41
src/cbuf/get_data.c

@ -1,41 +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/>.
*/
#include <sys/types.h>
#include <string.h>
#include "cbuf.h"
char *
cbufGetData(Cbuf this, size_t n)
{
char * ret = cbufGetRead(this);
if (n > this->bused) {
return (char *)-1;
}
cbufIncRead(this, n);
return ret;
}
// vim: set ts=4 sw=4:

33
src/cbuf/get_free.c

@ -1,33 +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/>.
*/
#include <sys/types.h>
#include "cbuf.h"
size_t
cbufGetFree(Cbuf this)
{
return this->bsize - this->bused;
}
// vim: set ts=4 sw=4:

49
src/cbuf/get_line.c

@ -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/>.
*/
#include <sys/types.h>
#include <string.h>
#include "cbuf.h"
char *
cbufGetLine(Cbuf this, char ** line_end)
{
char * nl = cbufMemchr(this, '\n');
char * ret = NULL;
if (NULL != nl) {
size_t len = cbufAddrIndex(this, nl) + 1;
*line_end = nl - 1;
*nl = 0;
*(nl-1) = ('\r' == *(nl-1))? 0 : *(nl-1);
ret = cbufGetRead(this);
cbufIncRead(this, len);
}
return ret;
}
// vim: set ts=4 sw=4:

31
src/cbuf/get_read.c

@ -1,31 +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/>.
*/
#include "cbuf.h"
char *
cbufGetRead(Cbuf this)
{
return this->data + this->read;
}
// vim: set ts=4 sw=4:

31
src/cbuf/get_write.c

@ -1,31 +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/>.
*/
#include "cbuf.h"
char *
cbufGetWrite(Cbuf this)
{
return this->data + this->write;
}
// vim: set ts=4 sw=4:

36
src/cbuf/inc_read.c

@ -1,36 +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/>.
*/
#include <sys/types.h>
#include "cbuf.h"
void
cbufIncRead(Cbuf this, size_t n)
{
this->read += n;
this->read = (this->read >= this->bsize)?
this->read - this->bsize : this->read;
this->bused -= n;
}
// vim: set ts=4 sw=4:

36
src/cbuf/inc_write.c

@ -1,36 +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/>.
*/
#include <sys/types.h>
#include "cbuf.h"
void
cbufIncWrite(Cbuf this, size_t n)
{
this->write += n;
this->write = (this->write >= this->bsize)?
this->write - this->bsize : this->write;
this->bused += n;
}
// vim: set ts=4 sw=4:

31
src/cbuf/is_empty.c

@ -1,31 +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/>.
*/
#include "cbuf.h"
char
cbufIsEmpty(Cbuf this)
{
return (0 == this->bused);
}
// vim: set ts=4 sw=4:

31
src/cbuf/is_locked.c

@ -1,31 +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/>.
*/
#include "cbuf.h"
Bool
cbufIsLocked(Cbuf this)
{
return this->lock;
}
// vim: set ts=4 sw=4:

31
src/cbuf/lock.c

@ -1,31 +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/>.
*/
#include "cbuf.h"
void
cbufLock(Cbuf this)
{
this->lock = TRUE;
}
// vim: set ts=4 sw=4:

33
src/cbuf/memchr.c

@ -1,33 +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/>.
*/
#include <string.h>
#include "cbuf.h"
char *
cbufMemchr(Cbuf this, int c)
{
return memchr(cbufGetRead(this), c, this->bused);
}
// vim: set ts=4 sw=4:

51
src/cbuf/read.c

@ -1,51 +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/>.
*/
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include "trio.h"
#include "cbuf.h"
ssize_t
cbufRead(Cbuf this, TR_Stream st)
{
size_t rsize = cbufGetFree(this);
ssize_t rrsize;
if (0 == rsize) {
errno = ECBUFOVFL;
return -1;
}
rrsize = TR_streamRead(st, cbufGetWrite(this), rsize);
if (0 < rrsize) {
cbufIncWrite(this, rrsize);
}
return rrsize;
}
// vim: set ts=4 sw=4:

31
src/cbuf/release.c

@ -1,31 +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/>.
*/
#include "cbuf.h"
void
cbufRelease(Cbuf this)
{
this->lock = FALSE;
}
// vim: set ts=4 sw=4:

45
src/cbuf/set_data.c

@ -1,45 +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/>.
*/
#include <sys/types.h>
#include <string.h>
#include <errno.h>
#include "cbuf.h"
char *
cbufSetData(Cbuf this, const void * src, size_t n)
{
char * addr;
if (n > cbufGetFree(this)) {
errno = ECBUFOVFL;
return (char *)-1;
}
addr = memcpy(cbufGetWrite(this), src, n);
cbufIncWrite(this, n);
return addr;
}
// vim: set ts=4 sw=4:

34
src/cbuf/skip_non_alpha.c

@ -1,34 +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/>.
*/
#include <ctype.h>
#include "cbuf.h"
void
cbufSkipNonAlpha(Cbuf this)
{
while(0 < this->bused && !isalpha(*cbufGetRead(this)))
cbufIncRead(this, 1);
}
// vim: set ts=4 sw=4:

6
src/config/config.c

@ -27,6 +27,8 @@
#include <sys/types.h>
#include "trbase.h"
#include "trdata.h"
#include "config/config.h"
#include "config/value.h"
@ -51,7 +53,7 @@ configCtor(void * _this, va_list * params)
return -1;
}
this->config = TR_new(Hash);
this->config = TR_new(TR_Hash);
line[MAX_CONFIG_LINE] = '\0';
@ -96,7 +98,7 @@ configCtor(void * _this, va_list * params)
value[nvalue] = '\0';
if (0 != nkey && 0 != nvalue) {
hashAdd(
TR_hashAdd(
this->config,
TR_new(ConfigValue, key, nkey, value, nvalue));
}

5
src/config/get.c

@ -22,7 +22,8 @@
#include <sys/types.h>
#include "hash/hash.h"
#include "trdata.h"
#include "config/config.h"
#include "config/value.h"
@ -33,7 +34,7 @@ configGet(Config this, const char * key, size_t nkey)
return NULL;
}
return hashGet(this->config, key, nkey);
return TR_hashGet(this->config, key, nkey);
}
// vim: set ts=4 sw=4:

5
src/config/value.c

@ -27,6 +27,7 @@
#include <trbase.h>
#include <trhash.h>
#include <trdata.h>
#include "config/value.h"
@ -94,7 +95,7 @@ configValueHandleDouble(void * _this, void * _double)
}
TR_INIT_IFACE(TR_Class, configValueCtor, configValueDtor, NULL);
TR_INIT_IFACE(Hashable, configValueGetHash, configValueHandleDouble);
TR_CREATE_CLASS(ConfigValue, NULL, TR_IF(TR_Class), TR_IF(Hashable));
TR_INIT_IFACE(TR_Hashable, configValueGetHash, configValueHandleDouble);
TR_CREATE_CLASS(ConfigValue, NULL, TR_IF(TR_Class), TR_IF(TR_Hashable));
// vim: set ts=4 sw=4:

12
src/hash/Makefile.am

@ -1,12 +0,0 @@
ACLOCAL_AMFLAGS = -I m4
AUTOMAKE_OPTIONS = subdir-objects
HASH = hash.c add.c get.c get_first.c delete.c each.c value.c \
cleanup.c interface/hashable.c
AM_CFLAGS += -I../../include/
noinst_LTLIBRARIES = libhash.la
libhash_la_SOURCES = $(HASH)
libhash_la_CFLAGS = $(AM_CFLAGS)

63
src/hash/add.c

@ -1,63 +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/>.
*/
#include <search.h>
#include "hash.h"
static
inline
int
hashAddComp(const void * a, const void * b)
{
unsigned long hash_a = hashableGetHash((void*)a);
unsigned long hash_b = hashableGetHash((void*)b);
if (hash_a < hash_b) {
return -1;
}
if (hash_a > hash_b) {
return 1;
}
return 0;
}
void *
hashAdd(Hash this, void * operand)
{
void * found = treeInsert(&this->root, operand, hashAddComp);
if (NULL == found) {
return NULL;
}
if (operand != found) {
hashableHandleDouble(found, operand);
TR_delete(operand);
}
return found;
}
// vim: set ts=4 sw=4:

40
src/hash/cleanup.c

@ -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/>.
*/
#include "hash/hash.h"
#include "trbase.h"
static
inline
void
tDelete(const void * node, const int depth)
{
TR_delete(node);
}
void
hashCleanup(Hash this)
{
treeDestroy(&(this->root), tDelete);
}
// vim: set ts=4 sw=4:

67
src/hash/delete.c

@ -1,67 +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/>.
*/
#include <sys/types.h>
#include <trhash.h>
#include "asset.h"
#include "hash.h"
static
inline
int
hashDeleteComp(const void * a, const void * b)
{
unsigned long hash_a = hashableGetHash((void*)a);
if (hash_a < *(const unsigned long*)b) {
return -1;
}
if (hash_a > *(const unsigned long*)b) {
return 1;
}
return 0;
}
void *
hashDelete(Hash this, const char * search, size_t nsearch)
{
unsigned long hash = TR_sdbm((const unsigned char *)search, nsearch);
void * found = NULL;
found = treeDelete(&(this->root), &hash, hashDeleteComp);
return found;
}
void *
hashDeleteByVal(Hash this, unsigned long hash)
{
void * found = treeDelete(&(this->root), &hash, hashDeleteComp);
return found;
}
// vim: set ts=4 sw=4:

45
src/hash/each.c

@ -1,45 +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/>.
*/
#include <search.h>
#include "hash.h"
static void (*cb)(const void*);
static
inline
void
walk(const void * node, const int depth)
{
cb(node);
}
void
hashEach(Hash this, void (*callback)(const void*))
{
cb = callback;
treeWalk(this->root, walk);
}
// vim: set ts=4 sw=4:

67
src/hash/get.c

@ -1,67 +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/>.
*/
#include <stdio.h>
#include <search.h>
#include <sys/types.h>
#include <trhash.h>
#include "hash.h"
#include "tree.h"
static
inline
int
hashGetComp(const void * a, const void * b)
{
unsigned long hash_a = hashableGetHash((void*)a);
if (hash_a < *(const unsigned long*)b) {
return -1;
}
if (hash_a > *(const unsigned long*)b) {
return 1;
}
return 0;
}
void *
hashGet(Hash this, const char * search, size_t nsearch)
{
unsigned long hash = TR_sdbm((const unsigned char *)search, nsearch);
void * found = treeFind(this->root, &hash, hashGetComp);
return found;
}
void *
hashGetByVal(Hash this, unsigned long hash)
{
void * found = treeFind(this->root, &hash, hashGetComp);
return found;
}
// vim: set ts=4 sw=4:

39
src/hash/get_first.c

@ -1,39 +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/>.
*/
#include <stdio.h>
#include <search.h>
#include <sys/types.h>
#include <trhash.h>
#include "hash.h"
#include "tree.h"
void *
hashGetFirst(Hash this)
{
return this->root;
}
// vim: set ts=4 sw=4:

58
src/hash/hash.c

@ -1,58 +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/>.
*/
#define _GNU_SOURCE
#include <search.h>
#include <stdarg.h>
#include "hash/hash.h"
#include "trbase.h"
static
int
hashCtor(void * _this, va_list * params)
{
return 0;
}
static
inline
void
tDelete(const void * node, const int depth)
{
TR_delete(node);
}
static
void
hashDtor(void * _this)
{
Hash this = _this;
hashCleanup(this);
}
TR_INIT_IFACE(TR_Class, hashCtor, hashDtor, NULL);
TR_CREATE_CLASS(Hash, NULL, TR_IF(TR_Class));
// vim: set ts=4 sw=4:

48
src/hash/interface/hashable.c

@ -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/>.
*/
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include "trbase.h"
#include "hash/interface/hashable.h"
TR_CREATE_INTERFACE(Hashable, 2);
unsigned long
hashableGetHash(void * hashable)
{
unsigned long ret;
TR_RETCALL(hashable, Hashable, getHash, ret);
return ret;
}
void
hashableHandleDouble(void * hashable, void * new_hashable)
{
TR_CALL(hashable, Hashable, handleDouble, new_hashable);
}
// vim: set ts=4 sw=4:

108
src/hash/value.c

@ -1,108 +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/>.
*/
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <trbase.h>
#include <trhash.h>
#include "hash/value.h"
#include "hash/interface/hashable.h"
static
int
hashValueCtor(void * _this, va_list * params)
{
HashValue this = _this;
char * key = va_arg(* params, char*);
void * value;
this->nkey = va_arg(* params, size_t);
value = va_arg(* params, void*);
this->nvalue = va_arg(* params, size_t);
this->key = TR_malloc(this->nkey + 1);
this->key[this->nkey] = 0;
memcpy(this->key, key, this->nkey);
this->hash = TR_sdbm((unsigned char *)this->key, this->nkey);
if (NULL != value) {
this->value = TR_malloc(this->nvalue + 1);
((char*)this->value)[this->nvalue] = 0;
memcpy(this->value, value, this->nvalue);
}
return 0;
}
static
void
hashValueDtor(void * _this)
{
HashValue this = _this;
TR_MEM_FREE(this->key);
TR_MEM_FREE(this->value);
}
static
unsigned long
hashValueGetHash(void * _this)
{
HashValue this = _this;
return this->hash;
}
static
void
hashValueHandleDouble(void * _this, void * _double)
{
HashValue this = _this;
HashValue doub = _double;
void * tmp_value;
size_t tmp_nvalue;
/**
* here we swap the internal data of both objects,
* effectively overwriting the old entry. We need not
* to free anything here as _double will be deleted
* afterwards anyway (\see hash/add.c).
*/
tmp_value = this->value;
this->value = doub->value;
doub->value = tmp_value;
tmp_nvalue = this->nvalue;
this->nvalue = doub->nvalue;
doub->nvalue = tmp_nvalue;
}
TR_INIT_IFACE(TR_Class, hashValueCtor, hashValueDtor, NULL);
TR_INIT_IFACE(Hashable, hashValueGetHash, hashValueHandleDouble);
TR_CREATE_CLASS(HashValue, NULL, TR_IF(TR_Class), TR_IF(Hashable));
// vim: set ts=4 sw=4:

10
src/http/header.c

@ -24,10 +24,10 @@
#include <stdlib.h>
#include <string.h>
#include <trbase.h>
#include <trhash.h>
#include "trbase.h"
#include "trhash.h"
#include "trdata.h"
#include "hash.h"
#include "http/header.h"
static
@ -99,7 +99,7 @@ httpHeaderHandleDouble(void * _this, void * _double)
}
TR_INIT_IFACE(TR_Class, httpHeaderCtor, httpHeaderDtor, NULL);
TR_INIT_IFACE(Hashable, httpHeaderGetHash, httpHeaderHandleDouble);
TR_CREATE_CLASS(HttpHeader, NULL, TR_IF(TR_Class), TR_IF(Hashable));
TR_INIT_IFACE(TR_Hashable, httpHeaderGetHash, httpHeaderHandleDouble);
TR_CREATE_CLASS(HttpHeader, NULL, TR_IF(TR_Class), TR_IF(TR_Hashable));
// vim: set ts=4 sw=4:

4
src/http/message.c

@ -31,7 +31,7 @@
#include <unistd.h>
#include "trbase.h"
#include "hash.h"
#include "trdata.h"
#include "http/message.h"
@ -45,7 +45,7 @@ httpMessageCtor(void * _this, va_list * params)
this->version = TR_calloc(1, strlen(version)+1);
strcpy(this->version, version);
this->header = TR_new(Hash);
this->header = TR_new(TR_Hash);
return 0;
}

4
src/http/message/has_keep_alive.c

@ -29,7 +29,7 @@
#include "http/header.h"
#include "trbase.h"
#include "hash.h"
#include "trdata.h"
char
httpMessageHasKeepAlive(HttpMessage message)
@ -38,7 +38,7 @@ httpMessageHasKeepAlive(HttpMessage message)
size_t size;
char * value;
header = hashGet(message->header, CSTRA("connection"));
header = TR_hashGet(message->header, CSTRA("connection"));
if (NULL == header) {
return 0;

4
src/http/message/header_size_get.c

@ -24,11 +24,11 @@
#include <string.h>
#include <sys/types.h>
#include "trdata.h"
#include "http/message.h"
#include "http/response.h"
#include "http/header.h"
#include "http/interface/http_intro.h"
#include "hash.h"
static size_t size;
@ -45,7 +45,7 @@ httpMessageHeaderSizeGet(HttpMessage message)
{
size = httpIntroSizeGet(message);
hashEach(message->header, addHeaderSize);
TR_hashEach(message->header, addHeaderSize);
size += 2;
return size;

4
src/http/message/header_to_string.c

@ -24,10 +24,10 @@
#include <string.h>
#include <stdio.h>
#include "trdata.h"
#include "http/response.h"
#include "http/header.h"
#include "http/interface/http_intro.h"
#include "hash.h"
static char * string;
@ -46,7 +46,7 @@ httpMessageHeaderToString(HttpMessage response, char * _string)
string = httpIntroToString(response, _string);
hashEach(message->header, addHeaderString);
TR_hashEach(message->header, addHeaderString);
*string++ = '\r';
*string++ = '\n';

9
src/http/parser.c

@ -26,11 +26,10 @@
#include "trbase.h"
#include "trio.h"
#include "trdata.h"
#include "http/parser.h"
#include "queue.h"
#include "http/request.h"
#include "http/response.h"
#include "cbuf.h"
static
@ -39,13 +38,13 @@ httpParserCtor(void * _this, va_list * params)
{
HttpParser this = _this;
this->buffer = va_arg(* params, Cbuf);
this->buffer = va_arg(* params, TR_Cbuf);
if (NULL == this->buffer) {
return -1;
}
this->queue = TR_new(Queue);
this->queue = TR_new(TR_Queue);
return 0;
}
@ -59,7 +58,7 @@ httpParserDtor(void * _this)
TR_delete(this->queue);
if (TRUE == this->ourLock)
cbufRelease(this->buffer);
TR_cbufRelease(this->buffer);
TR_MEM_FREE(this->incomplete);
TR_delete(this->current);

5
src/http/parser/p_body.c

@ -23,12 +23,11 @@
#include <stdlib.h>
#include <sys/types.h>
#include "trbase.h"
#include "http/header.h"
#include "http/message.h"
#include "http/parser.h"
#include "cbuf.h"
#include "trbase.h"
size_t
httpParserBody(HttpParser this, const char * buf, size_t nbuf)

8
src/http/parser/p_header.c

@ -25,11 +25,11 @@
#include <sys/types.h>
#include "trbase.h"
#include "trdata.h"
#include "http/header.h"
#include "http/parser.h"
#include "http/message.h"
#include "http/request.h"
#include "hash.h"
void
httpParserHeader(
@ -88,15 +88,15 @@ httpParserHeader(
nval = pair-eqsign-1;
val = (0 != nval)? eqsign+1 : NULL;
hashAdd(request->cookies,
TR_new(HashValue, key, eqsign-key, val, nval));
TR_hashAdd(request->cookies,
TR_new(TR_HashValue, key, eqsign-key, val, nval));
pair++;
togo -= (pair - eqsign);
}
}
hashAdd(current->header,
TR_hashAdd(current->header,
TR_new(HttpHeader, name, nname, value, lend - value));
}

8
src/http/parser/p_post_vars.c

@ -23,10 +23,10 @@
#include <string.h>
#include <sys/types.h>
#include "trbase.h"
#include "trdata.h"
#include "http/parser.h"
#include "http/request.h"
#include "hash.h"
#include "trbase.h"
#include "utils/http.h"
@ -63,8 +63,8 @@ httpParserPostVars(HttpParser this)
value = (0 != nvalue)? eqsign+1 : NULL;
nvalue = urldecode(value, nvalue);
hashAdd(request->post,
TR_new(HashValue, key, eqsign-key, value, nvalue));
TR_hashAdd(request->post,
TR_new(TR_HashValue, key, eqsign-key, value, nvalue));
pair++;
togo -= (pair - eqsign);

6
src/http/parser/p_request_vars.c

@ -25,9 +25,9 @@
#include <sys/types.h>
#include "trbase.h"
#include "trdata.h"
#include "http/parser.h"
#include "http/request.h"
#include "hash.h"
void
httpParserRequestVars(HttpParser this)
@ -62,8 +62,8 @@ httpParserRequestVars(HttpParser this)
nvalue = delim-eqsign-1;
value = (0 != nvalue)? eqsign+1 : NULL;
hashAdd(request->get,
TR_new(HashValue, key, eqsign-key, value, nvalue));
TR_hashAdd(request->get,
TR_new(TR_HashValue, key, eqsign-key, value, nvalue));
}
}

49
src/http/parser/parse.c

@ -24,8 +24,7 @@
#include "trbase.h"
#include "trio.h"
#include "cbuf.h"
#include "queue.h"
#include "trdata.h"
#include "http/parser.h"
#include "http/header.h"
@ -41,22 +40,22 @@ httpParserParse(void * _this, TR_Stream st)
char * line;
char * line_end;
if (cbufIsLocked(this->buffer)) {
if (TR_cbufIsLocked(this->buffer)) {
if (FALSE == this->ourLock)
return 0;
}
else {
cbufLock(this->buffer);
TR_cbufLock(this->buffer);
this->ourLock = TRUE;
}
if (NULL != this->incomplete) {
cbufSetData(this->buffer, this->incomplete, this->isize);
TR_cbufSetData(this->buffer, this->incomplete, this->isize);
TR_MEM_FREE(this->incomplete);
}
if (0 > (read = cbufRead(this->buffer, st))) {
cbufRelease(this->buffer);
if (0 > (read = TR_cbufRead(this->buffer, st))) {
TR_cbufRelease(this->buffer);
this->ourLock = FALSE;
return read;
}
@ -64,27 +63,27 @@ httpParserParse(void * _this, TR_Stream st)
while (cont) {
switch(this->state) {
case HTTP_MESSAGE_GARBAGE:
cbufSkipNonAlpha(this->buffer);
if (! cbufIsEmpty(this->buffer)) {
TR_cbufSkipNonAlpha(this->buffer);
if (! TR_cbufIsEmpty(this->buffer)) {
this->state = HTTP_MESSAGE_START;
}
else {
cbufRelease(this->buffer);
TR_cbufRelease(this->buffer);
this->ourLock = FALSE;
cont = 0;
break;
}
case HTTP_MESSAGE_START:
if (NULL == (line = cbufGetLine(this->buffer, &line_end))) {
if (! cbufIsEmpty(this->buffer)) {
if (NULL == (line = TR_cbufGetLine(this->buffer, &line_end))) {
if (! TR_cbufIsEmpty(this->buffer)) {
this->isize = this->buffer->bused;
this->incomplete = TR_malloc(this->isize);
memcpy(this->incomplete,
cbufGetData(this->buffer, this->isize),
TR_cbufGetData(this->buffer, this->isize),
this->isize);
}
cbufRelease(this->buffer);
TR_cbufRelease(this->buffer);
this->ourLock = FALSE;
cont = 0;
break;
@ -92,7 +91,7 @@ httpParserParse(void * _this, TR_Stream st)
httpParserNewMessage(this, line, line_end);
if (NULL == this->current) {
cbufRelease(this->buffer);
TR_cbufRelease(this->buffer);
this->ourLock = FALSE;
return -2; // a server error occured can't process...
}
@ -101,15 +100,15 @@ httpParserParse(void * _this, TR_Stream st)
this->state = HTTP_MESSAGE_INTRO_DONE;
case HTTP_MESSAGE_INTRO_DONE:
if (NULL == (line = cbufGetLine(this->buffer, &line_end))) {
if (! cbufIsEmpty(this->buffer)) {
if (NULL == (line = TR_cbufGetLine(this->buffer, &line_end))) {
if (! TR_cbufIsEmpty(this->buffer)) {
this->isize = this->buffer->bused;
this->incomplete = TR_malloc(this->isize);
memcpy(this->incomplete,
cbufGetData(this->buffer, this->isize),
TR_cbufGetData(this->buffer, this->isize),
this->isize);
}
cbufRelease(this->buffer);
TR_cbufRelease(this->buffer);
this->ourLock = FALSE;
cont = 0;
break;
@ -126,18 +125,18 @@ httpParserParse(void * _this, TR_Stream st)
if (this->current->dbody == this->current->nbody) {
this->state = HTTP_MESSAGE_DONE;
} else {
if (cbufIsEmpty(this->buffer)) {
cbufRelease(this->buffer);
if (TR_cbufIsEmpty(this->buffer)) {
TR_cbufRelease(this->buffer);
this->ourLock = FALSE;
cont = 0;
break;
}
cbufIncRead(
TR_cbufIncRead(
this->buffer,
httpParserBody(
this,
cbufGetRead(this->buffer),
TR_cbufGetRead(this->buffer),
this->buffer->bused));
break;
@ -145,7 +144,7 @@ httpParserParse(void * _this, TR_Stream st)
case HTTP_MESSAGE_DONE:
{
HttpHeader enc = hashGet(
HttpHeader enc = TR_hashGet(
this->current->header,
CSTRA("content-type"));
@ -164,7 +163,7 @@ httpParserParse(void * _this, TR_Stream st)
/**
* enqueue current request
*/
queuePut(this->queue, this->current);
TR_queuePut(this->queue, this->current);
this->current = NULL;
/**

8
src/http/request.c

@ -26,7 +26,7 @@
#include <sys/types.h>
#include "trbase.h"
#include "hash.h"
#include "trdata.h"
#include "http/interface/http_intro.h"
#include "http/request.h"
@ -66,9 +66,9 @@ httpRequestCtor(void * _this, va_list * params)
return -1;
}
this->get = TR_new(Hash);
this->post = TR_new(Hash);
this->cookies = TR_new(Hash);
this->get = TR_new(TR_Hash);
this->post = TR_new(TR_Hash);
this->cookies = TR_new(TR_Hash);
return 0;
}

8
src/http/response/304.c

@ -23,10 +23,10 @@
#include <sys/types.h>
#include "trbase.h"
#include "trdata.h"
#include "http/response.h"
#include "http/message.h"
#include "http/header.h"
#include "hash.h"
HttpResponse
httpResponse304(
@ -43,11 +43,11 @@ httpResponse304(
message->nbody = 0;
message->body = NULL;
hashAdd(message->header,
TR_hashAdd(message->header,
TR_new(HttpHeader, CSTRA("Content-Type"), mime, nmime));
hashAdd(message->header,
TR_hashAdd(message->header,
TR_new(HttpHeader, CSTRA("ETag"), etag, netag));
hashAdd(message->header,
TR_hashAdd(message->header,
TR_new(HttpHeader, CSTRA("Last-Modified"), mtime, nmtime));
return response;

4
src/http/response/404.c

@ -26,10 +26,10 @@
#include <sys/types.h>
#include "trbase.h"
#include "trdata.h"
#include "http/response.h"
#include "http/message.h"
#include "http/header.h"
#include "hash.h"
#define RESP_DATA "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n" \
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n" \
@ -49,7 +49,7 @@ httpResponse404()
response = TR_new(HttpResponse, "HTTP/1.1", 404, "Not Found");
message = (HttpMessage)response;
hashAdd(message->header,
TR_hashAdd(message->header,
TR_new(HttpHeader, CSTRA("Content-Type"), CSTRA("text/html")));
message->nbody = sizeof(RESP_DATA) - 1;

4
src/http/response/500.c

@ -26,10 +26,10 @@
#include <sys/types.h>
#include "trbase.h"
#include "trdata.h"
#include "http/response.h"
#include "http/message.h"
#include "http/header.h"
#include "hash.h"
#define RESP_DATA "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n" \
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n" \
@ -49,7 +49,7 @@ httpResponse500()
response = TR_new(HttpResponse, "HTTP/1.1", 500, "Internal Server Error");
message = (HttpMessage)response;
hashAdd(message->header,
TR_hashAdd(message->header,
TR_new(HttpHeader, CSTRA("Content-Type"), CSTRA("text/html")));
message->nbody = sizeof(RESP_DATA) - 1;

10
src/http/response/asset.c

@ -43,11 +43,11 @@
#include "trbase.h"
#include "trio.h"
#include "trdata.h"
#include "http/response.h"
#include "http/message.h"
#include "http/header.h"
#include "utils/http.h"
#include "hash.h"
#include "asset.h"
@ -74,14 +74,14 @@ httpResponseAsset(const char * fname, size_t nfname, time_t exptime)
nexpires = rfc1123Gmt(expires, sizeof(expires), &exptime);
hashAdd(message->header,
TR_hashAdd(message->header,
TR_new(HttpHeader, CSTRA("Content-Type"),
asset->mime_type, asset->nmime_type));
hashAdd(message->header,
TR_hashAdd(message->header,
TR_new(HttpHeader, CSTRA("ETag"), asset->etag, asset->netag));
hashAdd(message->header,
TR_hashAdd(message->header,
TR_new(HttpHeader, CSTRA("Expires"), expires, nexpires));
hashAdd(message->header,
TR_hashAdd(message->header,
TR_new(HttpHeader, CSTRA("Last-Modified"),
asset->mtime, asset->nmtime));

4
src/http/response/json.c

@ -27,11 +27,11 @@
#include <sys/types.h>
#include "trbase.h"
#include "trdata.h"
#include "http/response.h"
#include "http/message.h"
#include "http/header.h"
#include "session.h"
#include "hash.h"
HttpResponse
httpResponseJson(const char * body, size_t nbody)
@ -42,7 +42,7 @@ httpResponseJson(const char * body, size_t nbody)
response = TR_new(HttpResponse, "HTTP/1.1", 200, "OK");
message = (HttpMessage)response;
hashAdd(message->header,
TR_hashAdd(message->header,
TR_new(
HttpHeader,
CSTRA("Content-Type"),

10
src/http/worker.c

@ -32,8 +32,6 @@
#include "trbase.h"
#include "trio.h"
#include "hash.h"
#include "queue.h"
#include "http/worker.h"
#include "http/parser.h"
#include "http/writer.h"
@ -49,12 +47,12 @@ httpWorkerCtor(void * _this, va_list * params)
this->id = TR_malloc(strlen(id) + 1);
strcpy(this->id, id);
this->asset_pool = TR_new(Hash);
this->asset_pool = TR_new(TR_Hash);
sprintf(cbuf_id, "%s_%s", "parser", id);
this->pbuf = TR_new(Cbuf, cbuf_id, PARSER_MAX_BUF);
this->pbuf = TR_new(TR_Cbuf, cbuf_id, PARSER_MAX_BUF);
this->additional_headers = TR_new(Queue);
this->additional_headers = TR_new(TR_Queue);
this->parser = TR_new(HttpParser, this->pbuf);
this->writer = TR_new(HttpWriter);
@ -91,7 +89,7 @@ httpWorkerClone(void * _this, void * _base)
this->asset_pool = base->asset_pool;
this->application_adapter = base->application_adapter;
this->additional_headers = TR_new(Queue);
this->additional_headers = TR_new(TR_Queue);
this->parser = TR_new(HttpParser, base->pbuf);
/*

12
src/http/worker/add_common_header.c

@ -23,10 +23,10 @@
#include <sys/types.h>
#include "trbase.h"
#include "trdata.h"
#include "http/message.h"
#include "http/header.h"
#include "http/worker.h"
#include "hash.h"
#include "utils/http.h"
#include "config.h"
@ -38,15 +38,15 @@ httpWorkerAddCommonHeader(HttpWorker this)
size_t nbuf;
if (httpMessageHasKeepAlive((HttpMessage)this->current_request)) {
hashAdd(this->current_response->header,
TR_hashAdd(this->current_response->header,
TR_new(HttpHeader, CSTRA("Connection"), CSTRA("Keep-Alive")));
}
else {
hashAdd(this->current_response->header,
TR_hashAdd(this->current_response->header,
TR_new(HttpHeader, CSTRA("Connection"), CSTRA("Close")));
}
hashAdd(this->current_response->header,
TR_hashAdd(this->current_response->header,
TR_new(HttpHeader, CSTRA("Server"), CSTRA(PACKAGE_STRING)));
switch(((HttpResponse)this->current_response)->status) {
@ -55,12 +55,12 @@ httpWorkerAddCommonHeader(HttpWorker this)
default:
nbuf = sprintf(buffer, "%d", this->current_response->nbody);
hashAdd(this->current_response->header,
TR_hashAdd(this->current_response->header,
TR_new(HttpHeader, CSTRA("Content-Length"), buffer, nbuf));
}
nbuf = rfc1123GmtNow(buffer, sizeof(buffer));
hashAdd(this->current_response->header,
TR_hashAdd(this->current_response->header,
TR_new(HttpHeader, CSTRA("Date"), buffer, nbuf));
}

8
src/http/worker/add_computed_header.c

@ -22,20 +22,20 @@
#include <sys/types.h>
#include "trdata.h"
#include "http/message.h"
#include "http/header.h"
#include "http/worker.h"
#include "queue.h"
void
httpWorkerAddComputedHeader(HttpWorker this)
{
HttpHeader header = (HttpHeader)queueGet(this->additional_headers);
HttpHeader header = (HttpHeader)TR_queueGet(this->additional_headers);
while(NULL != header) {
hashAdd(this->current_response->header, header);
header = (HttpHeader)queueGet(this->additional_headers);
TR_hashAdd(this->current_response->header, header);
header = (HttpHeader)TR_queueGet(this->additional_headers);
}
}

4
src/http/worker/get_asset.c

@ -24,12 +24,12 @@
#include <time.h>
#include "trbase.h"
#include "trdata.h"
#include "http/header.h"
#include "http/message.h"
#include "http/request.h"
#include "http/response.h"
#include "http/worker.h"
#include "hash.h"
HttpMessage
httpWorkerGetAsset(HttpWorker this, const char * fname)
@ -41,7 +41,7 @@ httpWorkerGetAsset(HttpWorker this, const char * fname)
size_t nfname = strlen(fname);
header = hashGet(
header = TR_hashGet(
((HttpMessage)this->current_request)->header,
CSTRA("If-None-Match"));

8
src/http/worker/process.c

@ -28,7 +28,7 @@
#include <sys/time.h>
#include "trbase.h"
#include "queue.h"
#include "trdata.h"
#include "http/worker.h"
#include "http/header.h"
@ -57,8 +57,8 @@ httpWorkerProcess(HttpWorker this, TR_Stream st)
}
if (0 < requests) {
while (! queueEmpty(this->parser->queue)) {
this->current_request = queueGet(this->parser->queue);
while (! TR_queueEmpty(this->parser->queue)) {
this->current_request = TR_queueGet(this->parser->queue);
this->current_response = NULL;
/*
@ -124,7 +124,7 @@ httpWorkerProcess(HttpWorker this, TR_Stream st)
httpWorkerAddCommonHeader(this);
httpWorkerAddComputedHeader(this);
TR_delete(this->current_request);
queuePut(this->writer->queue, this->current_response);
TR_queuePut(this->writer->queue, this->current_response);
this->current_response = NULL;
}
}

4
src/http/writer.c

@ -24,7 +24,7 @@
#include "trbase.h"
#include "trio.h"
#include "queue.h"
#include "trdata.h"
#include "http/writer.h"
static
@ -33,7 +33,7 @@ httpWriterCtor(void * _this, va_list * params)
{
HttpWriter this = _this;
this->queue = TR_new(Queue);
this->queue = TR_new(TR_Queue);
return 0;
}

6
src/http/writer/write.c

@ -27,7 +27,7 @@
#include "http/message.h"
#include "trio.h"
#include "queue.h"
#include "trdata.h"
#include "http/writer.h"
@ -43,8 +43,8 @@ httpWriterWrite(void * _this, TR_Stream st)
case HTTP_WRITER_GET:
if (! queueEmpty(this->queue)) {
this->current = queueGet(this->queue);
if (! TR_queueEmpty(this->queue)) {
this->current = TR_queueGet(this->queue);
this->written = 0;
this->nheader = httpMessageHeaderSizeGet(this->current);

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save