From 8bec3ea459fe2369a1e7d4d08f1ac598eb877247 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Mon, 12 Mar 2012 02:13:51 +0100 Subject: [PATCH] Create method_strings array with HTTP_METHOD_MAP macro. --- http_parser.c | 30 +++-------------------- http_parser.h | 68 +++++++++++++++++++++++++-------------------------- 2 files changed, 38 insertions(+), 60 deletions(-) diff --git a/http_parser.c b/http_parser.c index ac41fed..acd4130 100644 --- a/http_parser.c +++ b/http_parser.c @@ -123,32 +123,10 @@ do { \ static const char *method_strings[] = - { "DELETE" - , "GET" - , "HEAD" - , "POST" - , "PUT" - , "CONNECT" - , "OPTIONS" - , "TRACE" - , "COPY" - , "LOCK" - , "MKCOL" - , "MOVE" - , "PROPFIND" - , "PROPPATCH" - , "SEARCH" - , "UNLOCK" - , "REPORT" - , "MKACTIVITY" - , "CHECKOUT" - , "MERGE" - , "M-SEARCH" - , "NOTIFY" - , "SUBSCRIBE" - , "UNSUBSCRIBE" - , "PATCH" - , "PURGE" + { +#define XX(num, name, string) #string, + HTTP_METHOD_MAP(XX) +#undef XX }; diff --git a/http_parser.h b/http_parser.h index b833acb..8ed4180 100644 --- a/http_parser.h +++ b/http_parser.h @@ -85,44 +85,44 @@ typedef int (*http_cb) (http_parser*); /* Request Methods */ -#define HTTP_METHOD_MAP(XX) \ - XX(0, DELETE) \ - XX(1, GET) \ - XX(2, HEAD) \ - XX(3, POST) \ - XX(4, PUT) \ - /* pathological */ \ - XX(5, CONNECT) \ - XX(6, OPTIONS) \ - XX(7, TRACE) \ - /* webdav */ \ - XX(8, COPY) \ - XX(9, LOCK) \ - XX(10, MKCOL) \ - XX(11, MOVE) \ - XX(12, PROPFIND) \ - XX(13, PROPPATCH) \ - XX(14, SEARCH) \ - XX(15, UNLOCK) \ - /* subversion */ \ - XX(16, REPORT) \ - XX(17, MKACTIVITY) \ - XX(18, CHECKOUT) \ - XX(19, MERGE) \ - /* upnp */ \ - XX(20, MSEARCH) \ - XX(21, NOTIFY) \ - XX(22, SUBSCRIBE) \ - XX(23, UNSUBSCRIBE) \ - /* RFC-5789 */ \ - XX(24, PATCH) \ - XX(25, PURGE) \ +#define HTTP_METHOD_MAP(XX) \ + XX(0, DELETE, DELETE) \ + XX(1, GET, GET) \ + XX(2, HEAD, HEAD) \ + XX(3, POST, POST) \ + XX(4, PUT, PUT) \ + /* pathological */ \ + XX(5, CONNECT, CONNECT) \ + XX(6, OPTIONS, OPTIONS) \ + XX(7, TRACE, TRACE) \ + /* webdav */ \ + XX(8, COPY, COPY) \ + XX(9, LOCK, LOCK) \ + XX(10, MKCOL, MKCOL) \ + XX(11, MOVE, MOVE) \ + XX(12, PROPFIND, PROPFIND) \ + XX(13, PROPPATCH, PROPPATCH) \ + XX(14, SEARCH, SEARCH) \ + XX(15, UNLOCK, UNLOCK) \ + /* subversion */ \ + XX(16, REPORT, REPORT) \ + XX(17, MKACTIVITY, MKACTIVITY) \ + XX(18, CHECKOUT, CHECKOUT) \ + XX(19, MERGE, MERGE) \ + /* upnp */ \ + XX(20, MSEARCH, M-SEARCH) \ + XX(21, NOTIFY, NOTIFY) \ + XX(22, SUBSCRIBE, SUBSCRIBE) \ + XX(23, UNSUBSCRIBE, UNSUBSCRIBE) \ + /* RFC-5789 */ \ + XX(24, PATCH, PATCH) \ + XX(25, PURGE, PURGE) \ enum http_method { -#define XX(num, name) HTTP_##name = num, +#define XX(num, name, string) HTTP_##name = num, HTTP_METHOD_MAP(XX) -#undef X +#undef XX };