You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.0 KiB
52 lines
1.0 KiB
#include <stdlib.h>
|
|
#include <stdarg.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include "class.h"
|
|
#include "http/worker.h"
|
|
#include "http/request/parser.h"
|
|
#include "http/response/writer.h"
|
|
|
|
#include "interface/class.h"
|
|
#include "interface/stream_reader.h"
|
|
#include "interface/stream_writer.h"
|
|
|
|
#define SHMN "/worker_"
|
|
static
|
|
void
|
|
ctor(void * _this, va_list * params)
|
|
{
|
|
HttpWorker this = _this;
|
|
char * id = va_arg(*params, char *);
|
|
|
|
this->id = malloc(strlen(id) + 1);
|
|
strcpy(this->id, id);
|
|
|
|
this->parser = new(HttpRequestParser, this->id);
|
|
this->writer = new(HttpResponseWriter, this->id);
|
|
}
|
|
|
|
static
|
|
void
|
|
dtor(void * _this)
|
|
{
|
|
HttpWorker this = _this;
|
|
|
|
free(this->id);
|
|
|
|
delete(&this->parser);
|
|
delete(&this->writer);
|
|
}
|
|
|
|
INIT_IFACE(Class, ctor, dtor, NULL);
|
|
INIT_IFACE(StreamReader, (fptr_streamReaderRead)httpWorkerProcess);
|
|
INIT_IFACE(StreamWriter, (fptr_streamWriterWrite)httpWorkerWrite);
|
|
CREATE_CLASS(
|
|
HttpWorker,
|
|
NULL,
|
|
IFACE(Class),
|
|
IFACE(StreamReader),
|
|
IFACE(StreamWriter));
|
|
|
|
// vim: set ts=4 sw=4:
|