taskrambler  0.1.9
Web server and task management solution.
message.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 #ifndef _GNU_SOURCE
24 #define _GNU_SOURCE
25 #endif
26 
27 #include <search.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #include <stdarg.h>
31 #include <unistd.h>
32 
33 #include "class.h"
34 #include "hash.h"
35 #include "http/message.h"
36 #include "utils/memory.h"
37 
38 
39 static
40 int
41 httpMessageCtor(void * _this, va_list * params)
42 {
43  HttpMessage this = _this;
44  char * version = va_arg(* params, char *);
45 
46  this->version = memCalloc(1, strlen(version)+1);
47  strcpy(this->version, version);
48 
49  this->header = new(Hash);
50 
51  return 0;
52 }
53 
54 static
55 void
56 httpMessageDtor(void * _this)
57 {
58  HttpMessage this = _this;
59 
60  delete(this->header);
61 
62  MEM_FREE(this->version);
63 
64  if (NULL == this->asset) {
65  MEM_FREE(this->body);
66  } else {
67  assetPoolRelease(this->asset);
68  this->asset = NULL;
69  this->body = NULL;
70  }
71 }
72 
74 CREATE_CLASS(HttpMessage, NULL, IFACE(Class));
75 
76 // vim: set ts=4 sw=4:
size_t assetPoolRelease(Asset)
Definition: pool.c:66
#define MEM_FREE(seg)
Definition: memory.h:28
CREATE_CLASS(HttpMessage, NULL, IFACE(Class))
#define IFACE(name)
Definition: interface.h:34
static int httpMessageCtor(void *_this, va_list *params)
Definition: message.c:41
void * memCalloc(size_t, size_t)
Definition: memory.c:818
static void httpMessageDtor(void *_this)
Definition: message.c:56
INIT_IFACE(Class, httpMessageCtor, httpMessageDtor, NULL)