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

Go to the source code of this file.

Functions

static int httpRequestCtor (void *_this, va_list *params)
 
static void httpRequestDtor (void *_this)
 
static size_t sizeGet (void *_this)
 
static char * toString (void *_this, char *string)
 
 INIT_IFACE (Class, httpRequestCtor, httpRequestDtor, NULL)
 
 INIT_IFACE (HttpIntro, sizeGet, toString)
 
 CREATE_CLASS (HttpRequest, HttpMessage, IFACE(Class), IFACE(HttpIntro))
 

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

Function Documentation

CREATE_CLASS ( HttpRequest  ,
HttpMessage  ,
IFACE(Class)  ,
IFACE(HttpIntro)   
)
static int httpRequestCtor ( void *  _this,
va_list *  params 
)
static
Todo:
looks like path is not used at all

Definition at line 38 of file request.c.

References httpRequestGetMethodId(), MEM_FREE, memMalloc(), PARENTCALL, and post().

39 {
40  HttpRequest this = _this;
41  char * method, * uri;
42  size_t mlen, ulen;
43 
44  method = va_arg(* params, char *);
45  mlen = va_arg(* params, size_t);
46  uri = va_arg(* params, char *);
47  ulen = va_arg(* params, size_t);
48 
49  PARENTCALL(_this, Class, ctor, params);
50 
51  this->method = memMalloc(mlen + 1);
52  this->method[mlen] = 0;
53  memcpy(this->method, method, mlen);
54 
55  this->uri = memMalloc(ulen + 1);
56  this->uri[ulen] = 0;
57  memcpy(this->uri, uri, ulen);
58 
59  this->method_id = httpRequestGetMethodId(this);
60 
61  if (-1 == this->method_id) {
62  MEM_FREE(this->uri);
63  MEM_FREE(this->method);
64  MEM_FREE(this->path); /** \todo looks like path is not used at all */
65 
66  PARENTCALL(_this, Class, dtor);
67 
68  return -1;
69  }
70 
71  this->get = new(Hash);
72  this->post = new(Hash);
73  this->cookies = new(Hash);
74 
75  return 0;
76 }
void post(struct element *tree, void(*cb)(struct element *, int))
Definition: rbtree.c:618
#define MEM_FREE(seg)
Definition: memory.h:28
HttpMethod httpRequestGetMethodId(HttpRequest)
Definition: get_method_id.c:39
void * memMalloc(size_t)
Definition: memory.c:783
#define PARENTCALL(object, _iface, method,...)
Definition: class/class.h:120

+ Here is the call graph for this function:

static void httpRequestDtor ( void *  _this)
static

Definition at line 80 of file request.c.

References MEM_FREE, PARENTCALL, and post().

81 {
82  HttpRequest this = _this;
83 
84  delete(this->get);
85  delete(this->post);
86  delete(this->cookies);
87 
88  MEM_FREE(this->uri);
89  MEM_FREE(this->method);
90  MEM_FREE(this->path);
91 
92  PARENTCALL(_this, Class, dtor);
93 }
void post(struct element *tree, void(*cb)(struct element *, int))
Definition: rbtree.c:618
#define MEM_FREE(seg)
Definition: memory.h:28
#define PARENTCALL(object, _iface, method,...)
Definition: class/class.h:120

+ Here is the call graph for this function:

INIT_IFACE ( Class  ,
httpRequestCtor  ,
httpRequestDtor  ,
NULL   
)
INIT_IFACE ( HttpIntro  ,
sizeGet  ,
toString   
)
static size_t sizeGet ( void *  _this)
static

Definition at line 97 of file request.c.

References size.

Referenced by httpIntroSizeGet().

98 {
99  HttpRequest this = _this;
100  size_t size = 0;
101 
102  size += strlen(this->method) + 1;
103  size += strlen(this->uri) + 1;
104  size += strlen(((HttpMessage)this)->version) + 2;
105 
106  return size;
107 }
static size_t size

+ Here is the caller graph for this function:

static char* toString ( void *  _this,
char *  string 
)
static

Definition at line 111 of file request.c.

References string.

Referenced by httpIntroToString().

112 {
113  HttpRequest this = _this;
114 
115  strcpy(string, this->method);
116  string += strlen(string);
117  *string++ = ' ';
118 
119  strcpy(string, this->uri);
120  string += strlen(string);
121  *string++ = ' ';
122 
123  strcpy(string, ((HttpMessage)this)->version);
124  string += strlen(string);
125  *string++ = '\r';
126  *string++ = '\n';
127 
128  return string;
129 }
static char * string

+ Here is the caller graph for this function: