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[] = {
34  NULL
35 };
36 
37 static const char *const one_hundred[] = {
38  "Continue",
39  "Switching Protocols",
40  "Processing"
41 };
42 
43 static const char *const two_hundred[] = {
44  "OK",
45  "Created",
46  "Accepted",
47  "Non-Authoritative Information",
48  "No Content",
49  "Reset Content",
50  "Partial Content",
51  "Multi Status"
52 };
53 
54 static const char *const three_hundred[] = {
55  "Multiple Choices",
56  "Moved Permanently",
57  "Moved Temporarily",
58  "See Other",
59  "Not Modified",
60  "Use Proxy",
61  "Switch Proxy",
62  "Temporary Redirect",
63  "Permanent Redirect"
64 };
65 
66 static const char *const four_hundred[] = {
67  "Bad Request",
68  "Unauthorized",
69  "Payment Required",
70  "Forbidden",
71  "Not Found",
72  "Method Not Allowed",
73  "Not Acceptable",
74  "Proxy Authentication Required",
75  "Request Time-out",
76  "Conflict",
77  "Gone",
78  "Length Required",
79  "Precondition Failed",
80  "Request Entity Too Large",
81  "Request-URI Too Large",
82  "Unsupported Media Type",
83  "Requested Range Not Satisfiable",
84  "Expectation Failed",
85  "Unknown",
86  "Unknown",
87  "Unknown", /* 420 */
88  "Unknown",
89  "Unprocessable Entity",
90  "Locked",
91  "Failed Dependency",
92  "Unordered Collection",
93  "Upgrade Required",
94  "Unknown",
95  "Unknown",
96  "Unknown",
97  "Unknown", /* 430 */
98  "Unknown",
99  "Unknown",
100  "Unknown",
101  "Unknown",
102  "Unknown", /* 435 */
103  "Unknown",
104  "Unknown",
105  "Unknown",
106  "Unknown",
107  "Unknown", /* 440 */
108  "Unknown",
109  "Unknown",
110  "Unknown",
111  "No Response",
112  "Unknown", /* 445 */
113  "Unknown",
114  "Unknown",
115  "Unknown",
116  "Retry With",
117  "Blocked by Windows Parental Controls", /* 450 */
118  "Unavailable For Legal Reasons"
119 };
120 
121 static const char *const five_hundred[] = {
122  "Internal Server Error",
123  "Not Implemented",
124  "Bad Gateway",
125  "Service Unavailable",
126  "Gateway Time-out",
127  "HTTP Version not supported",
128  "Variant Also Negotiates",
129  "Insufficient Storage",
130  "Unknown",
131  "Bandwidth Limit Exceeded",
132  "Not Extended"
133 };
134 
135 
136 struct MHD_Reason_Block
137 {
138  unsigned int max;
139  const char *const*data;
140 };
141 
142 #define BLOCK(m) { (sizeof(m) / sizeof(char*)), m }
143 
144 static const struct MHD_Reason_Block reasons[] = {
146  BLOCK (one_hundred),
147  BLOCK (two_hundred),
151 };
152 
153 
154 const char *
155 MHD_get_reason_phrase_for (unsigned int code)
156 {
157  if ( (code >= 100) &&
158  (code < 600) &&
159  (reasons[code / 100].max > (code % 100)) )
160  return reasons[code / 100].data[code % 100];
161  return "Unknown";
162 }
void * data
Definition: microhttpd.h:2108
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:54
platform-specific includes for libmicrohttpd
static const char *const two_hundred[]
Definition: reason_phrase.c:43
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:66
#define BLOCK(m)
static const char *const one_hundred[]
Definition: reason_phrase.c:37