reason_phrase.c

Go to the documentation of this file.
00001 /*
00002      This file is part of libmicrohttpd
00003      (C) 2007 Lymba
00004 
00005 
00006      This library is free software; you can redistribute it and/or
00007      modify it under the terms of the GNU Lesser General Public
00008      License as published by the Free Software Foundation; either
00009      version 2.1 of the License, or (at your option) any later version.
00010 
00011      This library is distributed in the hope that it will be useful,
00012      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014      Lesser General Public License for more details.
00015 
00016      You should have received a copy of the GNU Lesser General Public
00017      License along with this library; if not, write to the Free Software
00018      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00019 
00020 */
00021 
00029 #include "reason_phrase.h"
00030 
00031 static const char *invalid_hundred[] = { };
00032 
00033 static const char *one_hundred[] = {
00034   "Continue",
00035   "Switching Protocols",
00036   "Processing"
00037 };
00038 
00039 static const char *two_hundred[] = {
00040   "OK",
00041   "Created",
00042   "Accepted",
00043   "Non-Authoritative Information",
00044   "No Content",
00045   "Reset Content",
00046   "Partial Content"
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 };
00057 
00058 static const char *four_hundred[] = {
00059   "Bad Request",
00060   "Unauthorized",
00061   "Payment Required",
00062   "Forbidden",
00063   "Not Found",
00064   "Method Not Allowed",
00065   "Not Acceptable",
00066   "Proxy Authentication Required",
00067   "Request Time-out",
00068   "Conflict",
00069   "Gone",
00070   "Length Required",
00071   "Precondition Failed",
00072   "Request Entity Too Large",
00073   "Request-URI Too Large",
00074   "Unsupported Media Type"
00075 };
00076 
00077 static const char *five_hundred[] = {
00078   "Internal Server Error",
00079   "Bad Gateway",
00080   "Service Unavailable",
00081   "Gateway Time-out",
00082   "HTTP Version not supported"
00083 };
00084 
00085 
00086 struct MHD_Reason_Block
00087 {
00088   unsigned int max;
00089   const char **data;
00090 };
00091 
00092 #define BLOCK(m) { (sizeof(m) / sizeof(char*)), m }
00093 
00094 static const struct MHD_Reason_Block reasons[] = {
00095   BLOCK (invalid_hundred),
00096   BLOCK (one_hundred),
00097   BLOCK (two_hundred),
00098   BLOCK (three_hundred),
00099   BLOCK (four_hundred),
00100   BLOCK (five_hundred),
00101 };
00102 
00103 const char *
00104 MHD_get_reason_phrase_for (unsigned int code)
00105 {
00106   if ((code >= 100 && code < 600) && (reasons[code / 100].max > code % 100))
00107     return reasons[code / 100].data[code % 100];
00108   return "Unknown";
00109 }

Generated on Fri Oct 3 15:57:31 2008 for GNU libmicrohttpd by  doxygen 1.5.6