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

Go to the source code of this file.

Functions

static int httpResponseCtor (void *_this, va_list *params)
 
static void httpResponseDtor (void *_this)
 
static size_t sizeGet (void *_this)
 
static char * toString (void *_this, char *string)
 
 INIT_IFACE (Class, httpResponseCtor, httpResponseDtor, NULL)
 
 INIT_IFACE (HttpIntro, sizeGet, toString)
 
 CREATE_CLASS (HttpResponse, 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 response.c.

Function Documentation

CREATE_CLASS ( HttpResponse  ,
HttpMessage  ,
IFACE(Class)  ,
IFACE(HttpIntro)   
)
static int httpResponseCtor ( void *  _this,
va_list *  params 
)
static

Definition at line 38 of file response.c.

References memCalloc(), and PARENTCALL.

39 {
40  HttpResponse this = _this;
41  char * reason;
42 
43  PARENTCALL(_this, Class, ctor, params);
44 
45  this->status = va_arg(* params, unsigned int);
46  reason = va_arg(* params, char *);
47 
48  this->reason = memCalloc(1, strlen(reason)+1);
49  strcpy(this->reason, reason);
50 
51  return 0;
52 }
void * memCalloc(size_t, size_t)
Definition: memory.c:818
#define PARENTCALL(object, _iface, method,...)
Definition: class/class.h:120

+ Here is the call graph for this function:

static void httpResponseDtor ( void *  _this)
static

Definition at line 56 of file response.c.

References MEM_FREE, and PARENTCALL.

57 {
58  HttpResponse this = _this;
59 
60  MEM_FREE(this->reason);
61 
62  PARENTCALL(_this, Class, dtor);
63 }
#define MEM_FREE(seg)
Definition: memory.h:28
#define PARENTCALL(object, _iface, method,...)
Definition: class/class.h:120
INIT_IFACE ( Class  ,
httpResponseCtor  ,
httpResponseDtor  ,
NULL   
)
INIT_IFACE ( HttpIntro  ,
sizeGet  ,
toString   
)
static size_t sizeGet ( void *  _this)
static

Definition at line 67 of file response.c.

References size.

68 {
69  HttpResponse this = _this;
70  size_t size = 0;
71 
72  size += strlen(((HttpMessage)this)->version) + 1;
73  size += 3 + 1; // for status
74  size += strlen(this->reason) + 2;
75 
76  return size;
77 }
static size_t size
static char* toString ( void *  _this,
char *  string 
)
static

Definition at line 81 of file response.c.

References string.

82 {
83  HttpResponse this = _this;
84 
85  strcpy(string, ((HttpMessage)this)->version);
86  string += strlen(string);
87  *string++ = ' ';
88 
89  snprintf(string, 4, "%d", this->status);
90  string += strlen(string);
91  *string++ = ' ';
92 
93  strcpy(string, this->reason);
94  string += strlen(string);
95  *string++ = '\r';
96  *string++ = '\n';
97 
98  return string;
99 }
static char * string