reason_phrase.c

Go to the documentation of this file.
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 static const char *invalid_hundred[] = { };
00031 
00032 static const char *one_hundred[] = {
00033   "Continue",
00034   "Switching Protocols",
00035   "Processing"
00036 };
00037 
00038 static const char *two_hundred[] = {
00039   "OK",
00040   "Created",
00041   "Accepted",
00042   "Non-Authoritative Information",
00043   "No Content",
00044   "Reset Content",
00045   "Partial Content",
00046   "Multi Status"
00047 };
00048 
00049 static const char *three_hundred[] = {
00050   "Multiple Choices",
00051   "Moved Permanently",
00052   "Moved Temporarily",
00053   "See Other",
00054   "Not Modified",
00055   "Use Proxy",
00056   "Switch Proxy",
00057   "Temporary Redirect"
00058 };
00059 
00060 static const char *four_hundred[] = {
00061   "Bad Request",
00062   "Unauthorized",
00063   "Payment Required",
00064   "Forbidden",
00065   "Not Found",
00066   "Method Not Allowed",
00067   "Not Acceptable",
00068   "Proxy Authentication Required",
00069   "Request Time-out",
00070   "Conflict",
00071   "Gone",
00072   "Length Required",
00073   "Precondition Failed",
00074   "Request Entity Too Large",
00075   "Request-URI Too Large",
00076   "Unsupported Media Type",
00077   "Requested Range Not Satisfiable",
00078   "Expectation Failed",
00079   "Unprocessable Entity",
00080   "Locked",
00081   "Failed Dependency",
00082   "Unordered Collection",
00083   "Upgrade Required",
00084   "Retry With"
00085 };
00086 
00087 static const char *five_hundred[] = {
00088   "Internal Server Error",
00089   "Not Implemented",
00090   "Bad Gateway",
00091   "Service Unavailable",
00092   "Gateway Time-out",
00093   "HTTP Version not supported",
00094   "Variant Also Negotiates",
00095   "Insufficient Storage",
00096   "Bandwidth Limit Exceeded",
00097   "Not Extended"
00098 };
00099 
00100 
00101 struct MHD_Reason_Block
00102 {
00103   unsigned int max;
00104   const char **data;
00105 };
00106 
00107 #define BLOCK(m) { (sizeof(m) / sizeof(char*)), m }
00108 
00109 static const struct MHD_Reason_Block reasons[] = {
00110   BLOCK (invalid_hundred),
00111   BLOCK (one_hundred),
00112   BLOCK (two_hundred),
00113   BLOCK (three_hundred),
00114   BLOCK (four_hundred),
00115   BLOCK (five_hundred),
00116 };
00117 
00118 const char *
00119 MHD_get_reason_phrase_for (unsigned int code)
00120 {
00121   if ((code >= 100 && code < 600) && (reasons[code / 100].max > code % 100))
00122     return reasons[code / 100].data[code % 100];
00123   return "Unknown";
00124 }

Generated on Fri Feb 27 18:32:19 2009 for GNU libmicrohttpd by  doxygen 1.5.7.1