Browse Source

Make the whole thing build again, anyway no guarantee that it works

next
Georg Hopp 10 years ago
parent
commit
7a3343c8c8
  1. 18
      include/http/response.h
  2. 2
      include/router.h
  3. 2
      src/Makefile.am
  4. 2
      src/application/adapter/http/http.c
  5. 4
      src/application/session_cleanup.c
  6. 6
      src/application/session_get.c
  7. 2
      src/application/session_start.c
  8. 4
      src/application/session_stop.c
  9. 4
      src/http/parser/parse.c
  10. 14
      src/http/response.c
  11. 6
      src/http/response/304.c
  12. 6
      src/http/response/403.c
  13. 6
      src/http/response/404.c
  14. 6
      src/http/response/500.c
  15. 6
      src/http/response/asset.c
  16. 6
      src/http/response/json.c
  17. 2
      src/http/worker/add_common_header.c
  18. 2
      src/http/worker/process.c
  19. 4
      src/http/writer/write.c
  20. 10
      src/router/route.c
  21. 2
      src/utils/http.c

18
include/http/response.h

@ -34,24 +34,24 @@
#include "asset.h" #include "asset.h"
TR_CLASS(HttpResponse) {
TR_CLASS(TR_HttpResponse) {
TR_EXTENDS(HttpMessage); TR_EXTENDS(HttpMessage);
unsigned int status; unsigned int status;
char * reason; 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, 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__ #endif // __HTTP_RESPONSE_H__

2
include/router.h

@ -54,7 +54,7 @@ TR_CLASS(Router) {
TR_INSTANCE_INIT(Router); TR_INSTANCE_INIT(Router);
TR_CLASSVARS_DECL(Router) {}; TR_CLASSVARS_DECL(Router) {};
HttpResponse routerRoute(Router, HttpRequest, Session);
TR_HttpResponse routerRoute(Router, HttpRequest, Session);
#endif // __ROUTER_H__ #endif // __ROUTER_H__

2
src/Makefile.am

@ -19,7 +19,7 @@ TR = ./application/.libs/libapplication.a \
./config/.libs/libconfig.a \ ./config/.libs/libconfig.a \
./router/.libs/librouter.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 USEDLIBS = -lrt -lssl -lcrypto -lldap -lgdbm -luuid
AM_CFLAGS += -I../include/ AM_CFLAGS += -I../include/

2
src/application/adapter/http/http.c

@ -60,7 +60,7 @@ TR_INIT_IFACE(
TR_INIT_IFACE(TR_Observer, applicationAdapterHttpUpdate); TR_INIT_IFACE(TR_Observer, applicationAdapterHttpUpdate);
TR_CREATE_CLASS( TR_CREATE_CLASS(
ApplicationAdapterHttp, ApplicationAdapterHttp,
NULL,
NULL,
NULL, NULL,
TR_IF(TR_Class), TR_IF(TR_Class),
TR_IF(TR_Observer)); TR_IF(TR_Observer));

4
src/application/session_cleanup.c

@ -56,13 +56,13 @@ applicationSessionCleanup(Application this, time_t now)
tmp_buf, tmp_buf,
&(this->active_sessions[SESSION_LIVETIME - expired]), &(this->active_sessions[SESSION_LIVETIME - expired]),
expired * sizeof(struct sessinfo)); expired * sizeof(struct sessinfo));
TR_MEM_FREE(this->active_sessions); TR_MEM_FREE(this->active_sessions);
this->active_sessions = tmp_buf; this->active_sessions = tmp_buf;
} }
for (i=0; i<expired; i++) { for (i=0; i<expired; i++) {
TR_treeDestroy(&(this->active_sessions[i].ip_index), NULL);
TR_treeDestroy(this->active_sessions[i].ip_index, NULL);
TR_hashCleanup(this->active_sessions[i].sessions); TR_hashCleanup(this->active_sessions[i].sessions);
} }

6
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->livetime = this->session_time_ofs + SESSION_LIVETIME;
sess = (Session)TR_treeDelete( sess = (Session)TR_treeDelete(
&((this->active_sessions)[index].ip_index),
(this->active_sessions)[index].ip_index,
&ip, sessionIpIndexComp); &ip, sessionIpIndexComp);
TR_hashAdd((this->active_sessions)[0].sessions, sess); TR_hashAdd((this->active_sessions)[0].sessions, sess);
TR_treeInsert( TR_treeInsert(
&((this->active_sessions)[0].ip_index),
(this->active_sessions)[0].ip_index,
sess, sess,
sessionIpIndexComp); sessionIpIndexComp);
break; break;
} else { } else {
sess = (Session)TR_treeDelete( sess = (Session)TR_treeDelete(
&((this->active_sessions)[index].ip_index),
(this->active_sessions)[index].ip_index,
&ip, sessionIpIndexComp); &ip, sessionIpIndexComp);
if (NULL != sess) { if (NULL != sess) {
// we have a previous session from this ip, remove it. // we have a previous session from this ip, remove it.

2
src/application/session_start.c

@ -59,7 +59,7 @@ applicationSessionStart(Application this, uint32_t ip)
TR_hashAdd((this->active_sessions)[0].sessions, sess); TR_hashAdd((this->active_sessions)[0].sessions, sess);
TR_treeInsert( TR_treeInsert(
&((this->active_sessions)[0].ip_index),
(this->active_sessions)[0].ip_index,
sess, sess,
sessionIpIndexComp); sessionIpIndexComp);

4
src/application/session_stop.c

@ -51,7 +51,7 @@ sessionIpIndexComp(const void * a, const void * b)
void void
applicationSessionStop(Application this, Session session) applicationSessionStop(Application this, Session session)
{ {
int index = SESSION_LIVETIME -
int index = SESSION_LIVETIME -
(session->livetime - this->session_time_ofs); (session->livetime - this->session_time_ofs);
if (SESSION_LIVETIME > index) { if (SESSION_LIVETIME > index) {
@ -59,7 +59,7 @@ applicationSessionStop(Application this, Session session)
(this->active_sessions)[index].sessions, (this->active_sessions)[index].sessions,
session->hash); session->hash);
TR_treeDelete( TR_treeDelete(
&((this->active_sessions)[index].ip_index),
(this->active_sessions)[index].ip_index,
session, sessionIpIndexComp); session, sessionIpIndexComp);
} }
} }

4
src/http/parser/parse.c

@ -88,7 +88,7 @@ httpParserParse(void * _this, TR_Stream st)
cont = 0; cont = 0;
break; break;
} }
httpParserNewMessage(this, line, line_end); httpParserNewMessage(this, line, line_end);
if (NULL == this->current) { if (NULL == this->current) {
TR_cbufRelease(this->buffer); 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: // vim: set ts=4 sw=4:

14
src/http/response.c

@ -35,10 +35,10 @@ static
int int
httpResponseCtor(void * _this, va_list * params) httpResponseCtor(void * _this, va_list * params)
{ {
HttpResponse this = _this;
TR_HttpResponse this = _this;
char * reason; 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); this->status = va_arg(* params, unsigned int);
reason = va_arg(* params, char *); reason = va_arg(* params, char *);
@ -53,18 +53,18 @@ static
void void
httpResponseDtor(void * _this) httpResponseDtor(void * _this)
{ {
HttpResponse this = _this;
TR_HttpResponse this = _this;
TR_MEM_FREE(this->reason); TR_MEM_FREE(this->reason);
TR_PARENTCALL(TR_Response, _this, TR_Class, dtor);
TR_PARENTCALL(TR_HttpResponse, _this, TR_Class, dtor);
} }
static static
size_t size_t
sizeGet(void * _this) sizeGet(void * _this)
{ {
HttpResponse this = _this;
TR_HttpResponse this = _this;
size_t size = 0; size_t size = 0;
size += strlen(((HttpMessage)this)->version) + 1; size += strlen(((HttpMessage)this)->version) + 1;
@ -78,7 +78,7 @@ static
char * char *
toString(void * _this, char * string) toString(void * _this, char * string)
{ {
HttpResponse this = _this;
TR_HttpResponse this = _this;
strcpy(string, ((HttpMessage)this)->version); strcpy(string, ((HttpMessage)this)->version);
string += strlen(string); string += strlen(string);
@ -99,7 +99,7 @@ toString(void * _this, char * string)
TR_INIT_IFACE(TR_Class, httpResponseCtor, httpResponseDtor, NULL); TR_INIT_IFACE(TR_Class, httpResponseCtor, httpResponseDtor, NULL);
TR_INIT_IFACE(HttpIntro, sizeGet, toString); TR_INIT_IFACE(HttpIntro, sizeGet, toString);
TR_CREATE_CLASS( TR_CREATE_CLASS(
HttpResponse,
TR_HttpResponse,
HttpMessage, HttpMessage,
NULL, NULL,
TR_IF(TR_Class), TR_IF(TR_Class),

6
src/http/response/304.c

@ -28,16 +28,16 @@
#include "http/message.h" #include "http/message.h"
#include "http/header.h" #include "http/header.h"
HttpResponse
TR_HttpResponse
httpResponse304( httpResponse304(
const char * mime, size_t nmime, const char * mime, size_t nmime,
const char * etag, size_t netag, const char * etag, size_t netag,
const char * mtime, size_t nmtime) const char * mtime, size_t nmtime)
{ {
HttpResponse response;
TR_HttpResponse response;
HttpMessage message; 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 = (HttpMessage)response;
message->nbody = 0; message->nbody = 0;

6
src/http/response/403.c

@ -31,13 +31,13 @@
#include "http/header.h" #include "http/header.h"
HttpResponse
TR_HttpResponse
httpResponse403() httpResponse403()
{ {
HttpResponse response;
TR_HttpResponse response;
HttpMessage message; 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 = (HttpMessage)response;
message->nbody = 0; message->nbody = 0;

6
src/http/response/404.c

@ -40,13 +40,13 @@
"</html>" "</html>"
HttpResponse
TR_HttpResponse
httpResponse404() httpResponse404()
{ {
HttpResponse response;
TR_HttpResponse response;
HttpMessage message; 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; message = (HttpMessage)response;
TR_hashAdd(message->header, TR_hashAdd(message->header,

6
src/http/response/500.c

@ -40,13 +40,13 @@
"</html>" "</html>"
HttpResponse
TR_HttpResponse
httpResponse500() httpResponse500()
{ {
HttpResponse response;
TR_HttpResponse response;
HttpMessage message; 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; message = (HttpMessage)response;
TR_hashAdd(message->header, TR_hashAdd(message->header,

6
src/http/response/asset.c

@ -52,10 +52,10 @@
#include "asset.h" #include "asset.h"
HttpResponse
TR_HttpResponse
httpResponseAsset(const char * fname, size_t nfname, time_t exptime) httpResponseAsset(const char * fname, size_t nfname, time_t exptime)
{ {
HttpResponse response;
TR_HttpResponse response;
HttpMessage message; HttpMessage message;
Asset asset = assetPoolGet(fname, nfname); Asset asset = assetPoolGet(fname, nfname);
char expires[200]; char expires[200];
@ -65,7 +65,7 @@ httpResponseAsset(const char * fname, size_t nfname, time_t exptime)
return NULL; 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 = (HttpMessage)response;
message->asset = asset; message->asset = asset;

6
src/http/response/json.c

@ -33,13 +33,13 @@
#include "http/header.h" #include "http/header.h"
#include "session.h" #include "session.h"
HttpResponse
TR_HttpResponse
httpResponseJson(const char * body, size_t nbody) httpResponseJson(const char * body, size_t nbody)
{ {
HttpResponse response;
TR_HttpResponse response;
HttpMessage message; HttpMessage message;
response = TR_new(HttpResponse, "HTTP/1.1", 200, "OK");
response = TR_new(TR_HttpResponse, "HTTP/1.1", 200, "OK");
message = (HttpMessage)response; message = (HttpMessage)response;
TR_hashAdd(message->header, TR_hashAdd(message->header,

2
src/http/worker/add_common_header.c

@ -49,7 +49,7 @@ httpWorkerAddCommonHeader(HttpWorker this)
TR_hashAdd(this->current_response->header, TR_hashAdd(this->current_response->header,
TR_new(HttpHeader, CSTRA("Server"), CSTRA(PACKAGE_STRING))); TR_new(HttpHeader, CSTRA("Server"), CSTRA(PACKAGE_STRING)));
switch(((HttpResponse)this->current_response)->status) {
switch(((TR_HttpResponse)this->current_response)->status) {
case 304: case 304:
break; break;

2
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: // vim: set ts=4 sw=4:

4
src/http/writer/write.c

@ -145,8 +145,8 @@ httpWriterWrite(void * _this, TR_Stream st)
} }
return NULL == this->current ? 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: // vim: set ts=4 sw=4:

10
src/router/route.c

@ -48,7 +48,7 @@
#define COMMAND_LEN 128 #define COMMAND_LEN 128
HttpResponse
TR_HttpResponse
routerRoute( routerRoute(
Router this, Router this,
HttpRequest request, HttpRequest request,
@ -62,14 +62,14 @@ routerRoute(
char * command; char * command;
size_t ncommand; size_t ncommand;
char * response_data; char * response_data;
HttpResponse response;
TR_HttpResponse response;
if ('/' != request->uri[0]) { if ('/' != request->uri[0]) {
/* /*
* we only support absolute paths within our * we only support absolute paths within our
* application * application
*/ */
return NULL;
return (void *)NULL;
} }
command = &(request->uri[1]); command = &(request->uri[1]);
@ -121,7 +121,7 @@ routerRoute(
default: default:
/* other methods are not subject of REST */ /* other methods are not subject of REST */
return NULL;
return (void *)NULL;
} }
/* /*
@ -243,7 +243,7 @@ routerRoute(
*/ */
} }
return NULL;
return (void *)NULL;
} }
/* /*

2
src/utils/http.c

@ -128,7 +128,7 @@ httpGetMessage(
const char * part3, size_t len3) const char * part3, size_t len3)
{ {
if (isHttpVersion(part1, len1)) { if (isHttpVersion(part1, len1)) {
return TR_new(HttpResponse,
return TR_new(TR_HttpResponse,
part1, len1, part1, len1,
strtoul(part2, NULL, 10), strtoul(part2, NULL, 10),
part3, len3); part3, len3);

Loading…
Cancel
Save