request_parser.c 968 Bytes
#include <stdlib.h>

#include "cclass.h"
#include "http/request.h"
#include "http/request_parser.h"


INIT_CLASS(HTTP_REQUEST_PARSER);


__construct(LOGGER)
{
	this->request_queue = va_arg(*params, HTTP_REQUEST_QUEUE);

	this->buffer = malloc(HTTP_REQUEST_PARSER_READ_CHUNK);
}

__destruct(LOGGER)
{
	free(this->buffer);
} 

__jsonConst(LOGGER) {}
__toJson(LOGGER) {}
__clear(LOGGER) {}


static void
get_data(HTTP_REQUEST_PARSER this, const char * data, size_t size)
{
	size_t remaining, chunks;

	remaining = this->buffer_used % HTTP_REQUEST_PARSER_READ_CHUNK;
	chunks    = this->buffer_used / HTTP_REQUEST_PARSER_READ_CHUNK;

	chunks = (0 == remaining) ? chunks++ : chunks;

	if (size > remaining) {
		this->buffer =
			realloc(this->buffer, chunks * HTTP_REQUEST_PARSER_READ_CHUNK);
	}

	memcpy(this->buffer + this->buffer_used, data, size);
	this->buffer_used += size;
}

void http_request_parser_parse(const char * data, size_t size)
{
}

// vim: set ts=4 sw=4: