GNU libmicrohttpd  0.9.29
reason_phrase.c
Go to the documentation of this file.
1 /*
2  This file is part of libmicrohttpd
3  Copyright (C) 2007, 2011 Christian Grothoff
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 
19 */
26 #include "platform.h"
27 #include "microhttpd.h"
28 
29 #ifndef NULL
30 #define NULL (void*)0
31 #endif
32 
33 static const char *invalid_hundred[] = { NULL };
34 
35 static const char *const one_hundred[] = {
36  "Continue",
37  "Switching Protocols",
38  "Processing"
39 };
40 
41 static const char *const two_hundred[] = {
42  "OK",
43  "Created",
44  "Accepted",
45  "Non-Authoritative Information",
46  "No Content",
47  "Reset Content",
48  "Partial Content",
49  "Multi Status"
50 };
51 
52 static const char *const three_hundred[] = {
53  "Multiple Choices",
54  "Moved Permanently",
55  "Moved Temporarily",
56  "See Other",
57  "Not Modified",
58  "Use Proxy",
59  "Switch Proxy",
60  "Temporary Redirect"
61 };
62 
63 static const char *const four_hundred[] = {
64  "Bad Request",
65  "Unauthorized",
66  "Payment Required",
67  "Forbidden",
68  "Not Found",
69  "Method Not Allowed",
70  "Not Acceptable",
71  "Proxy Authentication Required",
72  "Request Time-out",
73  "Conflict",
74  "Gone",
75  "Length Required",
76  "Precondition Failed",
77  "Request Entity Too Large",
78  "Request-URI Too Large",
79  "Unsupported Media Type",
80  "Requested Range Not Satisfiable",
81  "Expectation Failed",
82  "Unknown",
83  "Unknown",
84  "Unknown", /* 420 */
85  "Unknown",
86  "Unprocessable Entity",
87  "Locked",
88  "Failed Dependency",
89  "Unordered Collection",
90  "Upgrade Required",
91  "Unknown",
92  "Unknown",
93  "Unknown",
94  "Unknown", /* 430 */
95  "Unknown",
96  "Unknown",
97  "Unknown",
98  "Unknown",
99  "Unknown", /* 435 */
100  "Unknown",
101  "Unknown",
102  "Unknown",
103  "Unknown",
104  "Unknown", /* 440 */
105  "Unknown",
106  "Unknown",
107  "Unknown",
108  "No Response",
109  "Unknown", /* 445 */
110  "Unknown",
111  "Unknown",
112  "Unknown",
113  "Retry With",
114  "Blocked by Windows Parental Controls", /* 450 */
115  "Unavailable For Legal Reasons"
116 };
117 
118 static const char *const five_hundred[] = {
119  "Internal Server Error",
120  "Not Implemented",
121  "Bad Gateway",
122  "Service Unavailable",
123  "Gateway Time-out",
124  "HTTP Version not supported",
125  "Variant Also Negotiates",
126  "Insufficient Storage",
127  "Unknown",
128  "Bandwidth Limit Exceeded",
129  "Not Extended"
130 };
131 
132 
133 struct MHD_Reason_Block
134 {
135  unsigned int max;
136  const char *const*data;
137 };
138 
139 #define BLOCK(m) { (sizeof(m) / sizeof(char*)), m }
140 
141 static const struct MHD_Reason_Block reasons[] = {
143  BLOCK (one_hundred),
144  BLOCK (two_hundred),
148 };
149 
150 
151 const char *
152 MHD_get_reason_phrase_for (unsigned int code)
153 {
154  if ( (code >= 100) &&
155  (code < 600) &&
156  (reasons[code / 100].max > (code % 100)) )
157  return reasons[code / 100].data[code % 100];
158  return "Unknown";
159 }
void * data
Definition: microhttpd.h:2035
public interface to libmicrohttpd
#define NULL
Definition: reason_phrase.c:30
static const char *const five_hundred[]
static const char *const three_hundred[]
Definition: reason_phrase.c:52
platform-specific includes for libmicrohttpd
static const char *const two_hundred[]
Definition: reason_phrase.c:41
static const struct MHD_Reason_Block reasons[]
static const char * invalid_hundred[]
Definition: reason_phrase.c:33
const char * MHD_get_reason_phrase_for(unsigned int code)
static const char *const four_hundred[]
Definition: reason_phrase.c:63
#define BLOCK(m)
static const char *const one_hundred[]
Definition: reason_phrase.c:35