Add new account center and account recovery frontends
[blerg.git] / cgi / canned_responses.c
1 /* Blerg is (C) 2011 The Dominion of Awesome, and is distributed under a
2  * BSD-style license.  Please see the COPYING file for details.
3  */
4 #include <stdio.h>
5 #include <string.h>
6 #include "canned_responses.h"
7 #include "app.h"
8
9 void respond_simple_data(const char *data, int len) {
10         printf("Content-length: %d\r\n\r\n", len);
11         fwrite(data, len, 1, stdout);
12 }
13
14 void respond_403() {
15         printf("Status: 403 Forbidden\r\n");
16         printf("Content-type: text/html\r\n");
17         printf("Content-length: %d\r\n\r\n", strlen(CONTENT_403));
18
19         printf(CONTENT_403);
20 }
21
22 void respond_404() {
23         printf("Status: 404 Not Found\r\n");
24         printf("Content-type: text/html\r\n");
25         printf("Content-length: %d\r\n\r\n", strlen(CONTENT_404));
26
27         printf(CONTENT_404);
28 }
29
30 void respond_405() {
31         printf("Status: 405 Method Not Allowed\r\n");
32         printf("Content-type: text/html\r\n");
33         printf("Content-length: %d\r\n\r\n", strlen(CONTENT_405));
34
35         printf(CONTENT_405);
36 }
37
38 void respond_JSON_Failure() {
39         printf("Content-type: application/json\r\n");
40         respond_simple_data(JSON_FAILURE, strlen(JSON_FAILURE));
41 }
42
43 void respond_JSON_Success() {
44         printf("Content-type: application/json\r\n");
45         respond_simple_data(JSON_SUCCESS, strlen(JSON_SUCCESS));
46 }