GNU libmicrohttpd 0.9.5
|
00001 /* 00002 This file is part of libmicrohttpd 00003 (C) 2007 Lymba 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the Free Software 00017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 00019 */ 00020 00028 #include "reason_phrase.h" 00029 00030 #ifndef NULL 00031 #define NULL (void*)0 00032 #endif // !NULL 00033 00034 static const char *invalid_hundred[] = { NULL }; 00035 00036 static const char *one_hundred[] = { 00037 "Continue", 00038 "Switching Protocols", 00039 "Processing" 00040 }; 00041 00042 static const char *two_hundred[] = { 00043 "OK", 00044 "Created", 00045 "Accepted", 00046 "Non-Authoritative Information", 00047 "No Content", 00048 "Reset Content", 00049 "Partial Content", 00050 "Multi Status" 00051 }; 00052 00053 static const char *three_hundred[] = { 00054 "Multiple Choices", 00055 "Moved Permanently", 00056 "Moved Temporarily", 00057 "See Other", 00058 "Not Modified", 00059 "Use Proxy", 00060 "Switch Proxy", 00061 "Temporary Redirect" 00062 }; 00063 00064 static const char *four_hundred[] = { 00065 "Bad Request", 00066 "Unauthorized", 00067 "Payment Required", 00068 "Forbidden", 00069 "Not Found", 00070 "Method Not Allowed", 00071 "Not Acceptable", 00072 "Proxy Authentication Required", 00073 "Request Time-out", 00074 "Conflict", 00075 "Gone", 00076 "Length Required", 00077 "Precondition Failed", 00078 "Request Entity Too Large", 00079 "Request-URI Too Large", 00080 "Unsupported Media Type", 00081 "Requested Range Not Satisfiable", 00082 "Expectation Failed", 00083 "Unprocessable Entity", 00084 "Locked", 00085 "Failed Dependency", 00086 "Unordered Collection", 00087 "Upgrade Required", 00088 "Retry With" 00089 }; 00090 00091 static const char *five_hundred[] = { 00092 "Internal Server Error", 00093 "Not Implemented", 00094 "Bad Gateway", 00095 "Service Unavailable", 00096 "Gateway Time-out", 00097 "HTTP Version not supported", 00098 "Variant Also Negotiates", 00099 "Insufficient Storage", 00100 "Bandwidth Limit Exceeded", 00101 "Not Extended" 00102 }; 00103 00104 00105 struct MHD_Reason_Block 00106 { 00107 unsigned int max; 00108 const char **data; 00109 }; 00110 00111 #define BLOCK(m) { (sizeof(m) / sizeof(char*)), m } 00112 00113 static const struct MHD_Reason_Block reasons[] = { 00114 BLOCK (invalid_hundred), 00115 BLOCK (one_hundred), 00116 BLOCK (two_hundred), 00117 BLOCK (three_hundred), 00118 BLOCK (four_hundred), 00119 BLOCK (five_hundred), 00120 }; 00121 00122 const char * 00123 MHD_get_reason_phrase_for (unsigned int code) 00124 { 00125 if ((code >= 100 && code < 600) && (reasons[code / 100].max > code % 100)) 00126 return reasons[code / 100].data[code % 100]; 00127 return "Unknown"; 00128 }