reason_phrase.c

Go to the documentation of this file.
00001 /*
00002      This file is part of libmicrohttpd
00003      (C) 2007, 2011 Christian Grothoff
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
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   "Unknown",
00084   "Unknown",
00085   "Unknown", /* 420 */
00086   "Unknown",
00087   "Unprocessable Entity",
00088   "Locked",
00089   "Failed Dependency",
00090   "Unordered Collection",
00091   "Upgrade Required",
00092   "Unknown",
00093   "Unknown",
00094   "Unknown",
00095   "Unknown", /* 430 */
00096   "Unknown",
00097   "Unknown",
00098   "Unknown",
00099   "Unknown",
00100   "Unknown", /* 435 */
00101   "Unknown",
00102   "Unknown",
00103   "Unknown",
00104   "Unknown",
00105   "Unknown", /* 440 */
00106   "Unknown",
00107   "Unknown",
00108   "Unknown",
00109   "No Response",
00110   "Unknown", /* 445 */
00111   "Unknown",
00112   "Unknown",
00113   "Unknown",
00114   "Retry With",
00115   "Blocked by Windows Parental Controls", /* 450 */
00116   "Unavailable For Legal Reasons"
00117 };
00118 
00119 static const char *five_hundred[] = {
00120   "Internal Server Error",
00121   "Not Implemented",
00122   "Bad Gateway",
00123   "Service Unavailable",
00124   "Gateway Time-out",
00125   "HTTP Version not supported",
00126   "Variant Also Negotiates",
00127   "Insufficient Storage",
00128   "Unknown",
00129   "Bandwidth Limit Exceeded",
00130   "Not Extended"
00131 };
00132 
00133 
00134 struct MHD_Reason_Block
00135 {
00136   unsigned int max;
00137   const char **data;
00138 };
00139 
00140 #define BLOCK(m) { (sizeof(m) / sizeof(char*)), m }
00141 
00142 static const struct MHD_Reason_Block reasons[] = {
00143   BLOCK (invalid_hundred),
00144   BLOCK (one_hundred),
00145   BLOCK (two_hundred),
00146   BLOCK (three_hundred),
00147   BLOCK (four_hundred),
00148   BLOCK (five_hundred),
00149 };
00150 
00151 const char *
00152 MHD_get_reason_phrase_for (unsigned int code)
00153 {
00154   if ( (code >= 100) && 
00155        (code < 600) && 
00156        (reasons[code / 100].max > (code % 100)) )
00157     return reasons[code / 100].data[code % 100];
00158   return "Unknown";
00159 }

Generated on 27 Sep 2012 for GNU libmicrohttpd by  doxygen 1.6.1