From: Ken Coar Date: Mon, 14 Aug 2000 21:33:27 +0000 (+0000) Subject: Make compilable on Windows again. I'm not sure the x = { [1] = 1 } X-Git-Tag: APACHE_2_0_ALPHA_6~26 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fd1c44be0403c722f9d24dadfb05cd96fe90d7e0;p=thirdparty%2Fapache%2Fhttpd.git Make compilable on Windows again. I'm not sure the x = { [1] = 1 } syntax is even ANSI C, but it originally compiled for me. Oh, well. I'd rather have this statically built at compile time, but I don't want to add the dependencies on the method order and its being a contiguous sequence. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86073 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index 87ad70eaf0b..caea143c51a 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -811,26 +811,44 @@ API_EXPORT(int) ap_method_number_of(const char *method) return M_INVALID; } +/* + * Turn a known method number into a name. Doesn't work for + * extension methods, obviously. + */ API_EXPORT(const char *) ap_method_name_of(int methnum) { - static const char *AP_HTTP_METHODS[] = { - [M_GET] = "GET", - [M_PUT] = "PUT", - [M_POST] = "POST", - [M_DELETE] = "DELETE", - [M_CONNECT] = "CONNECT", - [M_OPTIONS] = "OPTIONS", - [M_TRACE] = "TRACE", - [M_PATCH] = "PATCH", - [M_PROPFIND] = "PROPFIND", - [M_PROPPATCH] = "PROPPATCH", - [M_MKCOL] = "MKCOL", - [M_COPY] = "COPY", - [M_MOVE] = "MOVE", - [M_LOCK] = "LOCK", - [M_UNLOCK] = "UNLOCK", - [M_INVALID] = NULL - }; - + static const char *AP_HTTP_METHODS[METHODS] = { NULL }; + + /* + * This is ugly, but the previous incantation made Windows C + * varf. I'm not even sure it was ANSI C. However, ugly as it + * is, this works, and we only have to do it once. + */ + if (AP_HTTP_METHODS[0] == NULL) { + AP_HTTP_METHODS[M_GET] = "GET"; + AP_HTTP_METHODS[M_PUT] = "PUT"; + AP_HTTP_METHODS[M_POST] = "POST"; + AP_HTTP_METHODS[M_DELETE] = "DELETE"; + AP_HTTP_METHODS[M_CONNECT] = "CONNECT"; + AP_HTTP_METHODS[M_OPTIONS] = "OPTIONS"; + AP_HTTP_METHODS[M_TRACE] = "TRACE"; + AP_HTTP_METHODS[M_PATCH] = "PATCH"; + AP_HTTP_METHODS[M_PROPFIND] = "PROPFIND"; + AP_HTTP_METHODS[M_PROPPATCH] = "PROPPATCH"; + AP_HTTP_METHODS[M_MKCOL] = "MKCOL"; + AP_HTTP_METHODS[M_COPY] = "COPY"; + AP_HTTP_METHODS[M_MOVE] = "MOVE"; + AP_HTTP_METHODS[M_LOCK] = "LOCK"; + AP_HTTP_METHODS[M_UNLOCK] = "UNLOCK"; + AP_HTTP_METHODS[M_INVALID] = NULL; + /* + * Since we're using symbolic names, make sure we only do + * this once by forcing a value into the first slot IFF it's + * still NULL. + */ + if (AP_HTTP_METHODS[0] == NULL) { + AP_HTTP_METHODS[0] = "INVALID"; + } + } if ((methnum == M_INVALID) || (methnum >= METHODS)) { return NULL;