request_parser.c
968 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#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: