taskrambler  0.1.9
Web server and task management solution.
json.c File Reference
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <time.h>
#include <sys/types.h>
#include "class.h"
#include "http/response.h"
#include "http/message.h"
#include "http/header.h"
#include "session.h"
#include "utils/memory.h"
#include "hash.h"
+ Include dependency graph for json.c:

Go to the source code of this file.

Functions

HttpResponse httpResponseJson (const char *body, size_t nbody)
 

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

Function Documentation

HttpResponse httpResponseJson ( const char *  body,
size_t  nbody 
)

Definition at line 40 of file json.c.

References CSTRA, hashAdd(), and memMalloc().

Referenced by routerRoute().

41 {
42  HttpResponse response;
43  HttpMessage message;
44 
45  response = new(HttpResponse, "HTTP/1.1", 200, "OK");
46  message = (HttpMessage)response;
47 
48  hashAdd(message->header,
49  new(HttpHeader, CSTRA("Content-Type"), CSTRA("application/json")));
50 
51  message->nbody = nbody;
52  message->body = memMalloc(nbody);
53  memcpy(message->body, body, nbody);
54 
55  return response;
56 }
void * memMalloc(size_t)
Definition: memory.c:783
#define CSTRA(val)
Const STRing Argument.
Definition: memory.h:26
void * hashAdd(Hash, void *)
Definition: add.c:48

+ Here is the call graph for this function:

+ Here is the caller graph for this function: