taskrambler  0.1.9
Web server and task management solution.
404.c
Go to the documentation of this file.
1 /**
2  * \file
3  *
4  * \author Georg Hopp
5  *
6  * \copyright
7  * Copyright © 2012 Georg Hopp
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #include <stdlib.h>
24 #include <string.h>
25 #include <stdio.h>
26 #include <sys/types.h>
27 
28 #include "class.h"
29 
30 #include "http/response.h"
31 #include "http/message.h"
32 #include "http/header.h"
33 
34 #include "utils/memory.h"
35 #include "hash.h"
36 
37 #define RESP_DATA "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n" \
38  "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n" \
39  " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" \
40  "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n" \
41  "<head><title>404 - Not Found</title></head>" \
42  "<body><h1>404 - Not Found</h1></body>" \
43  "</html>"
44 
45 
46 HttpResponse
48 {
49  HttpResponse response;
50  HttpMessage message;
51 
52  response = new(HttpResponse, "HTTP/1.1", 404, "Not Found");
53  message = (HttpMessage)response;
54 
55  hashAdd(message->header,
56  new(HttpHeader, CSTRA("Content-Type"), CSTRA("text/html")));
57 
58  message->nbody = sizeof(RESP_DATA) - 1;
59  message->body = memMalloc(sizeof(RESP_DATA));
60  memcpy(message->body, RESP_DATA, sizeof(RESP_DATA));
61 
62  return response;
63 }
64 
65 // vim: set ts=4 sw=4:
HttpResponse httpResponse404()
Definition: 404.c:47
void * memMalloc(size_t)
Definition: memory.c:783
#define CSTRA(val)
Const STRing Argument.
Definition: memory.h:26
#define RESP_DATA
Definition: 404.c:37
void * hashAdd(Hash, void *)
Definition: add.c:48