taskrambler  0.1.9
Web server and task management solution.
cookie.c File Reference
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <sys/types.h>
#include "class.h"
#include "hash.h"
#include "http/cookie.h"
#include "utils/hash.h"
#include "utils/memory.h"
#include "commons.h"
+ Include dependency graph for cookie.c:

Go to the source code of this file.

Functions

static int httpCookieCtor (void *_this, va_list *params)
 
static void httpCookieDtor (void *_this, va_list *params)
 
static unsigned long httpCookieGetHash (void *_this)
 
static void httpCookieHandleDouble (void *_this, void *_double)
 
 INIT_IFACE (Class, httpCookieCtor, httpCookieDtor, NULL)
 
 INIT_IFACE (Hashable, httpCookieGetHash, httpCookieHandleDouble)
 
 CREATE_CLASS (HttpCookie, NULL, IFACE(Class), IFACE(Hashable))
 

Detailed Description

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 cookie.c.

Function Documentation

CREATE_CLASS ( HttpCookie  ,
NULL  ,
IFACE(Class)  ,
IFACE(Hashable)   
)
static int httpCookieCtor ( void *  _this,
va_list *  params 
)
static

Definition at line 39 of file cookie.c.

References memMalloc(), and sdbm().

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

+ Here is the call graph for this function:

static void httpCookieDtor ( void *  _this,
va_list *  params 
)
static

Definition at line 64 of file cookie.c.

References MEM_FREE.

65 {
66  HttpCookie this = _this;
67 
68  MEM_FREE(this->key);
69  MEM_FREE(this->value);
70  MEM_FREE(this->domain);
71  MEM_FREE(this->path);
72 }
#define MEM_FREE(seg)
Definition: memory.h:28
static unsigned long httpCookieGetHash ( void *  _this)
static

Definition at line 76 of file cookie.c.

77 {
78  HttpCookie this = _this;
79 
80  return this->hash;
81 }
static void httpCookieHandleDouble ( void *  _this,
void *  _double 
)
static

Definition at line 85 of file cookie.c.

References SWAP.

86 {
87  HttpCookie this = _this;
88  HttpCookie doub = _double;
89 
90  SWAP(char*, this->key, doub->key);
91  SWAP(char*, this->value, doub->value);
92  SWAP(char*, this->domain, doub->domain);
93  SWAP(char*, this->path, doub->path);
94 
95  SWAP(char*, this->nkey, doub->nkey);
96  SWAP(char*, this->nvalue, doub->nvalue);
97 }
#define SWAP(type, a, b)
Definition: commons.h:40
INIT_IFACE ( Class  ,
httpCookieCtor  ,
httpCookieDtor  ,
NULL   
)
INIT_IFACE ( Hashable  ,
httpCookieGetHash  ,
httpCookieHandleDouble   
)