Add RSS CGI, also quite a lot of refactoring
[blerg.git] / cgi / canned_responses.c
1 #include <stdio.h>
2 #include <string.h>
3 #include "canned_responses.h"
4 #include "app.h"
5
6 void respond_simple_data(unsigned const char *data, int len) {
7         printf("Content-length: %d\r\n\r\n", len);
8         fwrite(data, len, 1, stdout);
9 }
10
11 void respond_404() {
12         printf("Status: 404 Not Found\r\n");
13         printf("Content-type: text/html\r\n");
14         printf("Content-length: %d\r\n\r\n", strlen(CONTENT_404));
15
16         printf(CONTENT_404);
17 }
18
19 void respond_405() {
20         printf("Status: 405 Method Not Allowed\r\n");
21         printf("Content-type: text/html\r\n");
22         printf("Content-length: %d\r\n\r\n", strlen(CONTENT_405));
23
24         printf(CONTENT_405);
25 }
26
27 void respond_JSON_Failure() {
28         respond_simple_data(JSON_FAILURE, strlen(JSON_FAILURE));
29 }
30
31 void respond_JSON_Success() {
32         respond_simple_data(JSON_SUCCESS, strlen(JSON_SUCCESS));
33 }