taskrambler  0.1.8
Web server and task management solution.
header.c File Reference
#include <stdlib.h>
#include <string.h>
#include "class.h"
#include "hash.h"
#include "http/header.h"
#include "utils/hash.h"
#include "utils/memory.h"
+ Include dependency graph for header.c:

Go to the source code of this file.

Functions

static int httpHeaderCtor (void *_this, va_list *params)
 
static void httpHeaderDtor (void *_this)
 
static unsigned long httpHeaderGetHash (void *_this)
 
static void httpHeaderHandleDouble (void *_this, void *_double)
 
 INIT_IFACE (Class, httpHeaderCtor, httpHeaderDtor, NULL)
 
 INIT_IFACE (Hashable, httpHeaderGetHash, httpHeaderHandleDouble)
 
 CREATE_CLASS (HttpHeader, NULL, IFACE(Class), IFACE(Hashable))
 

Detailed Description

Interface implementation for HTTP header class.

Author
Georg Hopp

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file header.c.

Function Documentation

CREATE_CLASS ( HttpHeader  ,
NULL  ,
IFACE(Class)  ,
IFACE(Hashable)   
)
static int httpHeaderCtor ( void *  _this,
va_list *  params 
)
static

Definition at line 36 of file header.c.

References memMalloc(), interface::name, sdbm(), and size.

36  {
37  HttpHeader this = _this;
38  char * name;
39  char * value;
40 
41  name = va_arg(* params, char *);
42  this->nname = va_arg(* params, size_t);
43  value = va_arg(* params, char *);
44  this->nvalue[0] = va_arg(* params, size_t);
45 
46  this->name = memMalloc(this->nname + 1);
47  this->name[this->nname] = 0;
48  memcpy(this->name, name, this->nname);
49 
50  this->hash = sdbm((unsigned char *)name, this->nname);
51 
52  (this->value)[0] = memMalloc((this->nvalue)[0] + 1);
53  (this->value)[0][(this->nvalue)[0]] = 0;
54  memcpy((this->value)[0], value, (this->nvalue)[0]);
55  this->cvalue = 1;
56  this->size = this->nname + 2 + (this->nvalue)[0] + 2;
57 
58  return 0;
59 }
unsigned long sdbm(const unsigned char *, size_t)
Definition: utils/hash.c:45
void * memMalloc(size_t)
Definition: memory.c:783
static size_t size

+ Here is the call graph for this function:

static void httpHeaderDtor ( void *  _this)
static

Definition at line 63 of file header.c.

References MEM_FREE, and interface::name.

64 {
65  HttpHeader this = _this;
66  size_t i;
67 
68  MEM_FREE(this->name);
69 
70  for (i=0; i<this->cvalue; i++) {
71  MEM_FREE(this->value[i]);
72  }
73 }
#define MEM_FREE(seg)
Definition: memory.h:28
static unsigned long httpHeaderGetHash ( void *  _this)
static

Definition at line 77 of file header.c.

78 {
79  HttpHeader this = _this;
80 
81  return this->hash;
82 }
static void httpHeaderHandleDouble ( void *  _this,
void *  _double 
)
static
Todo:
do dome error logging...or change to HEAP

Definition at line 86 of file header.c.

References N_VALUES, and size.

87 {
88  HttpHeader this = _this;
89  HttpHeader doub = _double;
90 
91  if (this->cvalue >= N_VALUES) {
92  //! \todo do dome error logging...or change to HEAP
93  return;
94  }
95 
96  (this->nvalue)[this->cvalue] = (doub->nvalue)[0];
97  (this->value)[(this->cvalue)++] = (doub->value)[0];
98  this->size += doub->size;
99  (doub->value)[0] = NULL;
100 }
static size_t size
#define N_VALUES
Definition: header.h:32
INIT_IFACE ( Class  ,
httpHeaderCtor  ,
httpHeaderDtor  ,
NULL   
)
INIT_IFACE ( Hashable  ,
httpHeaderGetHash  ,
httpHeaderHandleDouble   
)