taskrambler  0.1.9
Web server and task management solution.
parser.c
Go to the documentation of this file.
1 /**
2  * \file
3  *
4  * \author Georg Hopp
5  *
6  * \copyright
7  * Copyright © 2012 Georg Hopp
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #include <stdlib.h>
24 #include <sys/types.h>
25 #include <stdarg.h>
26 
27 #include "class.h"
28 #include "stream.h"
29 
30 #include "http/parser.h"
31 #include "queue.h"
32 #include "http/request.h"
33 #include "http/response.h"
34 #include "cbuf.h"
35 
36 #include "utils/memory.h"
37 
38 
39 static
40 int
41 httpParserCtor(void * _this, va_list * params)
42 {
43  HttpParser this = _this;
44 
45  this->buffer = va_arg(* params, Cbuf);
46 
47  if (NULL == this->buffer) {
48  return -1;
49  }
50 
51  this->queue = new(Queue);
52 
53  return 0;
54 }
55 
56 static
57 void
58 httpParserDtor(void * _this)
59 {
60  HttpParser this = _this;
61 
62  delete(this->queue);
63 
64  if (TRUE == this->ourLock)
65  cbufRelease(this->buffer);
66 
67  MEM_FREE(this->incomplete);
68  delete(this->current);
69 }
70 
72 INIT_IFACE(StreamReader, httpParserParse);
73 CREATE_CLASS(HttpParser, NULL, IFACE(Class), IFACE(StreamReader));
74 
75 // vim: set ts=4 sw=4:
#define MEM_FREE(seg)
Definition: memory.h:28
void cbufRelease(Cbuf this)
Definition: release.c:26
static int httpParserCtor(void *_this, va_list *params)
Definition: parser.c:41
#define IFACE(name)
Definition: interface.h:34
ssize_t httpParserParse(void *, Stream)
#define TRUE
Definition: commons.h:27
CREATE_CLASS(HttpParser, NULL, IFACE(Class), IFACE(StreamReader))
INIT_IFACE(Class, httpParserCtor, httpParserDtor, NULL)
static void httpParserDtor(void *_this)
Definition: parser.c:58