diff --git a/include/http/response.h b/include/http/response.h index 2a638af..1eb2d8d 100644 --- a/include/http/response.h +++ b/include/http/response.h @@ -34,24 +34,24 @@ #include "asset.h" -TR_CLASS(HttpResponse) { +TR_CLASS(TR_HttpResponse) { TR_EXTENDS(HttpMessage); unsigned int status; char * reason; }; -TR_INSTANCE_INIT(HttpResponse); -TR_CLASSVARS_DECL(HttpResponse) {}; +TR_INSTANCE_INIT(TR_HttpResponse); +TR_CLASSVARS_DECL(TR_HttpResponse) {}; -HttpResponse httpResponse304( +TR_HttpResponse httpResponse304( const char *, size_t, const char *, size_t, const char *, size_t); -HttpResponse httpResponse403(); -HttpResponse httpResponse404(); -HttpResponse httpResponse500(); -HttpResponse httpResponseJson(const char *, size_t); -HttpResponse httpResponseAsset(const char *, size_t, time_t); +TR_HttpResponse httpResponse403(); +TR_HttpResponse httpResponse404(); +TR_HttpResponse httpResponse500(); +TR_HttpResponse httpResponseJson(const char *, size_t); +TR_HttpResponse httpResponseAsset(const char *, size_t, time_t); #endif // __HTTP_RESPONSE_H__ diff --git a/include/router.h b/include/router.h index 638e3a5..e082243 100644 --- a/include/router.h +++ b/include/router.h @@ -54,7 +54,7 @@ TR_CLASS(Router) { TR_INSTANCE_INIT(Router); TR_CLASSVARS_DECL(Router) {}; -HttpResponse routerRoute(Router, HttpRequest, Session); +TR_HttpResponse routerRoute(Router, HttpRequest, Session); #endif // __ROUTER_H__ diff --git a/src/Makefile.am b/src/Makefile.am index 6dfc2bf..3a465d9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -19,7 +19,7 @@ TR = ./application/.libs/libapplication.a \ ./config/.libs/libconfig.a \ ./router/.libs/librouter.a -TRLIBS = -ltrbase -ltrhashing -ltrio -ltrdata -ltrutils -ltrhttpserver +TRLIBS = -ltrbase -ltrhash -ltrio -ltrdata -ltrutils -ltrhttpserver USEDLIBS = -lrt -lssl -lcrypto -lldap -lgdbm -luuid AM_CFLAGS += -I../include/ diff --git a/src/application/adapter/http/http.c b/src/application/adapter/http/http.c index 5b77515..5db30b3 100644 --- a/src/application/adapter/http/http.c +++ b/src/application/adapter/http/http.c @@ -60,7 +60,7 @@ TR_INIT_IFACE( TR_INIT_IFACE(TR_Observer, applicationAdapterHttpUpdate); TR_CREATE_CLASS( ApplicationAdapterHttp, - NULL, + NULL, NULL, TR_IF(TR_Class), TR_IF(TR_Observer)); diff --git a/src/application/session_cleanup.c b/src/application/session_cleanup.c index 1313e51..84cd333 100644 --- a/src/application/session_cleanup.c +++ b/src/application/session_cleanup.c @@ -56,13 +56,13 @@ applicationSessionCleanup(Application this, time_t now) tmp_buf, &(this->active_sessions[SESSION_LIVETIME - expired]), expired * sizeof(struct sessinfo)); - + TR_MEM_FREE(this->active_sessions); this->active_sessions = tmp_buf; } for (i=0; iactive_sessions[i].ip_index), NULL); + TR_treeDestroy(this->active_sessions[i].ip_index, NULL); TR_hashCleanup(this->active_sessions[i].sessions); } diff --git a/src/application/session_get.c b/src/application/session_get.c index 3521e48..ae271d5 100644 --- a/src/application/session_get.c +++ b/src/application/session_get.c @@ -73,17 +73,17 @@ applicationSessionGet(Application this, const char * sid, uint32_t ip) */ sess->livetime = this->session_time_ofs + SESSION_LIVETIME; sess = (Session)TR_treeDelete( - &((this->active_sessions)[index].ip_index), + (this->active_sessions)[index].ip_index, &ip, sessionIpIndexComp); TR_hashAdd((this->active_sessions)[0].sessions, sess); TR_treeInsert( - &((this->active_sessions)[0].ip_index), + (this->active_sessions)[0].ip_index, sess, sessionIpIndexComp); break; } else { sess = (Session)TR_treeDelete( - &((this->active_sessions)[index].ip_index), + (this->active_sessions)[index].ip_index, &ip, sessionIpIndexComp); if (NULL != sess) { // we have a previous session from this ip, remove it. diff --git a/src/application/session_start.c b/src/application/session_start.c index 21eda31..ca39333 100644 --- a/src/application/session_start.c +++ b/src/application/session_start.c @@ -59,7 +59,7 @@ applicationSessionStart(Application this, uint32_t ip) TR_hashAdd((this->active_sessions)[0].sessions, sess); TR_treeInsert( - &((this->active_sessions)[0].ip_index), + (this->active_sessions)[0].ip_index, sess, sessionIpIndexComp); diff --git a/src/application/session_stop.c b/src/application/session_stop.c index d7d5380..3dd342e 100644 --- a/src/application/session_stop.c +++ b/src/application/session_stop.c @@ -51,7 +51,7 @@ sessionIpIndexComp(const void * a, const void * b) void applicationSessionStop(Application this, Session session) { - int index = SESSION_LIVETIME - + int index = SESSION_LIVETIME - (session->livetime - this->session_time_ofs); if (SESSION_LIVETIME > index) { @@ -59,7 +59,7 @@ applicationSessionStop(Application this, Session session) (this->active_sessions)[index].sessions, session->hash); TR_treeDelete( - &((this->active_sessions)[index].ip_index), + (this->active_sessions)[index].ip_index, session, sessionIpIndexComp); } } diff --git a/src/http/parser/parse.c b/src/http/parser/parse.c index 4bec4d7..7552b7e 100644 --- a/src/http/parser/parse.c +++ b/src/http/parser/parse.c @@ -88,7 +88,7 @@ httpParserParse(void * _this, TR_Stream st) cont = 0; break; } - + httpParserNewMessage(this, line, line_end); if (NULL == this->current) { TR_cbufRelease(this->buffer); @@ -178,7 +178,7 @@ httpParserParse(void * _this, TR_Stream st) } } - return this->queue->nmsg; + return TR_queueSize(this->queue); } // vim: set ts=4 sw=4: diff --git a/src/http/response.c b/src/http/response.c index e4bad03..06a6f0c 100644 --- a/src/http/response.c +++ b/src/http/response.c @@ -35,10 +35,10 @@ static int httpResponseCtor(void * _this, va_list * params) { - HttpResponse this = _this; + TR_HttpResponse this = _this; char * reason; - TR_PARENTCALL(TR_Response, _this, TR_Class, ctor, params); + TR_PARENTCALL(TR_HttpResponse, _this, TR_Class, ctor, params); this->status = va_arg(* params, unsigned int); reason = va_arg(* params, char *); @@ -53,18 +53,18 @@ static void httpResponseDtor(void * _this) { - HttpResponse this = _this; + TR_HttpResponse this = _this; TR_MEM_FREE(this->reason); - TR_PARENTCALL(TR_Response, _this, TR_Class, dtor); + TR_PARENTCALL(TR_HttpResponse, _this, TR_Class, dtor); } static size_t sizeGet(void * _this) { - HttpResponse this = _this; + TR_HttpResponse this = _this; size_t size = 0; size += strlen(((HttpMessage)this)->version) + 1; @@ -78,7 +78,7 @@ static char * toString(void * _this, char * string) { - HttpResponse this = _this; + TR_HttpResponse this = _this; strcpy(string, ((HttpMessage)this)->version); string += strlen(string); @@ -99,7 +99,7 @@ toString(void * _this, char * string) TR_INIT_IFACE(TR_Class, httpResponseCtor, httpResponseDtor, NULL); TR_INIT_IFACE(HttpIntro, sizeGet, toString); TR_CREATE_CLASS( - HttpResponse, + TR_HttpResponse, HttpMessage, NULL, TR_IF(TR_Class), diff --git a/src/http/response/304.c b/src/http/response/304.c index 3a8ce80..8df7aae 100644 --- a/src/http/response/304.c +++ b/src/http/response/304.c @@ -28,16 +28,16 @@ #include "http/message.h" #include "http/header.h" -HttpResponse +TR_HttpResponse httpResponse304( const char * mime, size_t nmime, const char * etag, size_t netag, const char * mtime, size_t nmtime) { - HttpResponse response; + TR_HttpResponse response; HttpMessage message; - response = TR_new(HttpResponse, "HTTP/1.1", 304, "Not Modified"); + response = TR_new(TR_HttpResponse, "HTTP/1.1", 304, "Not Modified"); message = (HttpMessage)response; message->nbody = 0; diff --git a/src/http/response/403.c b/src/http/response/403.c index 86224c8..8967894 100644 --- a/src/http/response/403.c +++ b/src/http/response/403.c @@ -31,13 +31,13 @@ #include "http/header.h" -HttpResponse +TR_HttpResponse httpResponse403() { - HttpResponse response; + TR_HttpResponse response; HttpMessage message; - response = TR_new(HttpResponse, "HTTP/1.1", 403, "Forbidden"); + response = TR_new(TR_HttpResponse, "HTTP/1.1", 403, "Forbidden"); message = (HttpMessage)response; message->nbody = 0; diff --git a/src/http/response/404.c b/src/http/response/404.c index 2cfe647..1506c65 100644 --- a/src/http/response/404.c +++ b/src/http/response/404.c @@ -40,13 +40,13 @@ "" -HttpResponse +TR_HttpResponse httpResponse404() { - HttpResponse response; + TR_HttpResponse response; HttpMessage message; - response = TR_new(HttpResponse, "HTTP/1.1", 404, "Not Found"); + response = TR_new(TR_HttpResponse, "HTTP/1.1", 404, "Not Found"); message = (HttpMessage)response; TR_hashAdd(message->header, diff --git a/src/http/response/500.c b/src/http/response/500.c index d9884c3..2776418 100644 --- a/src/http/response/500.c +++ b/src/http/response/500.c @@ -40,13 +40,13 @@ "" -HttpResponse +TR_HttpResponse httpResponse500() { - HttpResponse response; + TR_HttpResponse response; HttpMessage message; - response = TR_new(HttpResponse, "HTTP/1.1", 500, "Internal Server Error"); + response = TR_new(TR_HttpResponse, "HTTP/1.1", 500, "Internal Server Error"); message = (HttpMessage)response; TR_hashAdd(message->header, diff --git a/src/http/response/asset.c b/src/http/response/asset.c index 4983f3c..ea583aa 100644 --- a/src/http/response/asset.c +++ b/src/http/response/asset.c @@ -52,10 +52,10 @@ #include "asset.h" -HttpResponse +TR_HttpResponse httpResponseAsset(const char * fname, size_t nfname, time_t exptime) { - HttpResponse response; + TR_HttpResponse response; HttpMessage message; Asset asset = assetPoolGet(fname, nfname); char expires[200]; @@ -65,7 +65,7 @@ httpResponseAsset(const char * fname, size_t nfname, time_t exptime) return NULL; } - response = TR_new(HttpResponse, "HTTP/1.1", 200, "OK"); + response = TR_new(TR_HttpResponse, "HTTP/1.1", 200, "OK"); message = (HttpMessage)response; message->asset = asset; diff --git a/src/http/response/json.c b/src/http/response/json.c index c54920d..03fb61b 100644 --- a/src/http/response/json.c +++ b/src/http/response/json.c @@ -33,13 +33,13 @@ #include "http/header.h" #include "session.h" -HttpResponse +TR_HttpResponse httpResponseJson(const char * body, size_t nbody) { - HttpResponse response; + TR_HttpResponse response; HttpMessage message; - response = TR_new(HttpResponse, "HTTP/1.1", 200, "OK"); + response = TR_new(TR_HttpResponse, "HTTP/1.1", 200, "OK"); message = (HttpMessage)response; TR_hashAdd(message->header, diff --git a/src/http/worker/add_common_header.c b/src/http/worker/add_common_header.c index aa53a29..6f5cf6c 100644 --- a/src/http/worker/add_common_header.c +++ b/src/http/worker/add_common_header.c @@ -49,7 +49,7 @@ httpWorkerAddCommonHeader(HttpWorker this) TR_hashAdd(this->current_response->header, TR_new(HttpHeader, CSTRA("Server"), CSTRA(PACKAGE_STRING))); - switch(((HttpResponse)this->current_response)->status) { + switch(((TR_HttpResponse)this->current_response)->status) { case 304: break; diff --git a/src/http/worker/process.c b/src/http/worker/process.c index 863f6bb..e41c5d4 100644 --- a/src/http/worker/process.c +++ b/src/http/worker/process.c @@ -129,7 +129,7 @@ httpWorkerProcess(HttpWorker this, TR_Stream st) } } - return this->writer->queue->nmsg; + return TR_queueSize(this->writer->queue); } // vim: set ts=4 sw=4: diff --git a/src/http/writer/write.c b/src/http/writer/write.c index 71d3e6c..73f6a68 100644 --- a/src/http/writer/write.c +++ b/src/http/writer/write.c @@ -145,8 +145,8 @@ httpWriterWrite(void * _this, TR_Stream st) } return NULL == this->current ? - this->queue->nmsg : - this->queue->nmsg + 1; + TR_queueSize(this->queue) : + TR_queueSize(this->queue) + 1; } // vim: set ts=4 sw=4: diff --git a/src/router/route.c b/src/router/route.c index 1745757..4fc7ca0 100644 --- a/src/router/route.c +++ b/src/router/route.c @@ -48,7 +48,7 @@ #define COMMAND_LEN 128 -HttpResponse +TR_HttpResponse routerRoute( Router this, HttpRequest request, @@ -62,14 +62,14 @@ routerRoute( char * command; size_t ncommand; char * response_data; - HttpResponse response; + TR_HttpResponse response; if ('/' != request->uri[0]) { /* * we only support absolute paths within our * application */ - return NULL; + return (void *)NULL; } command = &(request->uri[1]); @@ -121,7 +121,7 @@ routerRoute( default: /* other methods are not subject of REST */ - return NULL; + return (void *)NULL; } /* @@ -243,7 +243,7 @@ routerRoute( */ } - return NULL; + return (void *)NULL; } /* diff --git a/src/utils/http.c b/src/utils/http.c index f75cddf..ce4d549 100644 --- a/src/utils/http.c +++ b/src/utils/http.c @@ -128,7 +128,7 @@ httpGetMessage( const char * part3, size_t len3) { if (isHttpVersion(part1, len1)) { - return TR_new(HttpResponse, + return TR_new(TR_HttpResponse, part1, len1, strtoul(part2, NULL, 10), part3, len3);