Server 0.0.1
HTTP/REST server implementation

src/http/message.c

Go to the documentation of this file.
00001 
00023 #ifndef _GNU_SOURCE
00024 #define _GNU_SOURCE
00025 #endif
00026 
00027 #include <search.h>
00028 #include <stdlib.h>
00029 #include <string.h>
00030 #include <stdarg.h>
00031 #include <unistd.h>
00032 
00033 #include "class.h"
00034 #include "hash.h"
00035 #include "http/message.h"
00036 #include "utils/memory.h"
00037 
00038 
00039 static
00040 int
00041 httpMessageCtor(void * _this, va_list * params)
00042 {
00043         HttpMessage this    = _this;
00044         char *      version = va_arg(* params, char *);
00045 
00046         this->version = calloc(1, strlen(version)+1);
00047         strcpy(this->version, version);
00048 
00049         this->header = new(Hash);
00050 
00051         return 0;
00052 }
00053 
00054 static
00055 void
00056 httpMessageDtor(void * _this)
00057 {
00058         HttpMessage this = _this;
00059 
00060         delete(this->header);
00061 
00062         FREE(this->version);
00063 
00064         switch (this->type) {
00065                 case HTTP_MESSAGE_BUFFERED:
00066                         FREE(this->body);
00067                         break;
00068 
00069                 case HTTP_MESSAGE_PIPED:
00070                         if (2 < (this->handle->handle).fd) {
00071                                 close((this->handle->handle).fd);
00072                         }
00073                         delete(this->handle);
00074                         break;
00075 
00076                 default:
00077                         break;
00078         }
00079 } 
00080 
00081 INIT_IFACE(Class, httpMessageCtor, httpMessageDtor, NULL);
00082 CREATE_CLASS(HttpMessage, NULL, IFACE(Class));
00083 
00084 // vim: set ts=4 sw=4:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines