1
0
mirror of https://gitlab.xiph.org/xiph/icecast-common.git synced 2024-12-04 14:46:31 -05:00

Fix: Added missing namespace for HTTPP_NS_* and httpp_req_*

This commit is contained in:
Philipp Schafft 2018-10-31 11:29:07 +00:00
parent 6404c9a156
commit 7674b277d6
3 changed files with 71 additions and 71 deletions

View File

@ -71,45 +71,45 @@ igloo_httpp_request_info_t igloo_httpp_request_info(igloo_httpp_request_type_e r
#endif #endif
switch (req) { switch (req) {
/* offical methods */ /* offical methods */
case httpp_req_get: case igloo_httpp_req_get:
return igloo_HTTPP_REQUEST_IS_SAFE|igloo_HTTPP_REQUEST_IS_IDEMPOTENT|igloo_HTTPP_REQUEST_IS_CACHEABLE|igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY|igloo_HTTPP_REQUEST_HAS_OPTIONAL_REQUEST_BODY; return igloo_HTTPP_REQUEST_IS_SAFE|igloo_HTTPP_REQUEST_IS_IDEMPOTENT|igloo_HTTPP_REQUEST_IS_CACHEABLE|igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY|igloo_HTTPP_REQUEST_HAS_OPTIONAL_REQUEST_BODY;
break; break;
case httpp_req_post: case igloo_httpp_req_post:
return igloo_HTTPP_REQUEST_IS_CACHEABLE|igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY|igloo_HTTPP_REQUEST_HAS_REQUEST_BODY; return igloo_HTTPP_REQUEST_IS_CACHEABLE|igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY|igloo_HTTPP_REQUEST_HAS_REQUEST_BODY;
break; break;
case httpp_req_put: case igloo_httpp_req_put:
return igloo_HTTPP_REQUEST_IS_IDEMPOTENT|igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY|igloo_HTTPP_REQUEST_HAS_REQUEST_BODY; return igloo_HTTPP_REQUEST_IS_IDEMPOTENT|igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY|igloo_HTTPP_REQUEST_HAS_REQUEST_BODY;
break; break;
case httpp_req_head: case igloo_httpp_req_head:
return igloo_HTTPP_REQUEST_IS_SAFE|igloo_HTTPP_REQUEST_IS_IDEMPOTENT|igloo_HTTPP_REQUEST_IS_CACHEABLE; return igloo_HTTPP_REQUEST_IS_SAFE|igloo_HTTPP_REQUEST_IS_IDEMPOTENT|igloo_HTTPP_REQUEST_IS_CACHEABLE;
break; break;
case httpp_req_options: case igloo_httpp_req_options:
return igloo_HTTPP_REQUEST_IS_SAFE|igloo_HTTPP_REQUEST_IS_IDEMPOTENT|igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY|igloo_HTTPP_REQUEST_HAS_OPTIONAL_REQUEST_BODY; return igloo_HTTPP_REQUEST_IS_SAFE|igloo_HTTPP_REQUEST_IS_IDEMPOTENT|igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY|igloo_HTTPP_REQUEST_HAS_OPTIONAL_REQUEST_BODY;
break; break;
case httpp_req_delete: case igloo_httpp_req_delete:
return igloo_HTTPP_REQUEST_IS_IDEMPOTENT|igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY; return igloo_HTTPP_REQUEST_IS_IDEMPOTENT|igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY;
break; break;
case httpp_req_trace: case igloo_httpp_req_trace:
return igloo_HTTPP_REQUEST_IS_SAFE|igloo_HTTPP_REQUEST_IS_IDEMPOTENT|igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY; return igloo_HTTPP_REQUEST_IS_SAFE|igloo_HTTPP_REQUEST_IS_IDEMPOTENT|igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY;
break; break;
case httpp_req_connect: case igloo_httpp_req_connect:
return igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY|igloo_HTTPP_REQUEST_HAS_REQUEST_BODY; return igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY|igloo_HTTPP_REQUEST_HAS_REQUEST_BODY;
break; break;
/* Icecast specific methods */ /* Icecast specific methods */
case httpp_req_source: case igloo_httpp_req_source:
return igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY|igloo_HTTPP_REQUEST_HAS_REQUEST_BODY; return igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY|igloo_HTTPP_REQUEST_HAS_REQUEST_BODY;
break; break;
case httpp_req_play: case igloo_httpp_req_play:
return igloo_HTTPP_REQUEST_IS_SAFE|igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY|igloo_HTTPP_REQUEST_HAS_OPTIONAL_REQUEST_BODY; return igloo_HTTPP_REQUEST_IS_SAFE|igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY|igloo_HTTPP_REQUEST_HAS_OPTIONAL_REQUEST_BODY;
break; break;
case httpp_req_stats: case igloo_httpp_req_stats:
return igloo_HTTPP_REQUEST_IS_SAFE|igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY|igloo_HTTPP_REQUEST_HAS_OPTIONAL_REQUEST_BODY; return igloo_HTTPP_REQUEST_IS_SAFE|igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY|igloo_HTTPP_REQUEST_HAS_OPTIONAL_REQUEST_BODY;
break; break;
/* Virtual and other methods */ /* Virtual and other methods */
case httpp_req_none: case igloo_httpp_req_none:
case httpp_req_unknown: case igloo_httpp_req_unknown:
default: default:
return igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY|igloo_HTTPP_REQUEST_HAS_OPTIONAL_REQUEST_BODY; return igloo_HTTPP_REQUEST_HAS_RESPONSE_BODY|igloo_HTTPP_REQUEST_HAS_OPTIONAL_REQUEST_BODY;
break; break;
@ -121,7 +121,7 @@ igloo_http_parser_t *igloo_httpp_create_parser(void)
igloo_http_parser_t *parser = calloc(1, sizeof(igloo_http_parser_t)); igloo_http_parser_t *parser = calloc(1, sizeof(igloo_http_parser_t));
parser->refc = 1; parser->refc = 1;
parser->req_type = httpp_req_none; parser->req_type = igloo_httpp_req_none;
parser->uri = NULL; parser->uri = NULL;
parser->vars = igloo_avl_tree_new(igloo__compare_vars, NULL); parser->vars = igloo_avl_tree_new(igloo__compare_vars, NULL);
parser->queryvars = igloo_avl_tree_new(igloo__compare_vars, NULL); parser->queryvars = igloo_avl_tree_new(igloo__compare_vars, NULL);
@ -494,39 +494,39 @@ int igloo_httpp_parse(igloo_http_parser_t *parser, const char *http_data, unsign
return 0; return 0;
} }
if (parser->req_type != httpp_req_none && parser->req_type != httpp_req_unknown) { if (parser->req_type != igloo_httpp_req_none && parser->req_type != igloo_httpp_req_unknown) {
switch (parser->req_type) { switch (parser->req_type) {
case httpp_req_get: case igloo_httpp_req_get:
igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "GET"); igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "GET");
break; break;
case httpp_req_post: case igloo_httpp_req_post:
igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "POST"); igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "POST");
break; break;
case httpp_req_put: case igloo_httpp_req_put:
igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "PUT"); igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "PUT");
break; break;
case httpp_req_head: case igloo_httpp_req_head:
igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "HEAD"); igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "HEAD");
break; break;
case httpp_req_options: case igloo_httpp_req_options:
igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "OPTIONS"); igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "OPTIONS");
break; break;
case httpp_req_delete: case igloo_httpp_req_delete:
igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "DELETE"); igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "DELETE");
break; break;
case httpp_req_trace: case igloo_httpp_req_trace:
igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "TRACE"); igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "TRACE");
break; break;
case httpp_req_connect: case igloo_httpp_req_connect:
igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "CONNECT"); igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "CONNECT");
break; break;
case httpp_req_source: case igloo_httpp_req_source:
igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "SOURCE"); igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "SOURCE");
break; break;
case httpp_req_play: case igloo_httpp_req_play:
igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "PLAY"); igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "PLAY");
break; break;
case httpp_req_stats: case igloo_httpp_req_stats:
igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "STATS"); igloo_httpp_setvar(parser, igloo_HTTPP_VAR_REQ_TYPE, "STATS");
break; break;
default: default:
@ -733,20 +733,20 @@ const igloo_http_var_t *igloo_httpp_get_any_var(igloo_http_parser_t *parser, igl
return NULL; return NULL;
switch (ns) { switch (ns) {
case HTTPP_NS_VAR: case igloo_HTTPP_NS_VAR:
if (name[0] != '_' || name[1] != '_') if (name[0] != '_' || name[1] != '_')
return NULL; return NULL;
tree = parser->vars; tree = parser->vars;
break; break;
case HTTPP_NS_HEADER: case igloo_HTTPP_NS_HEADER:
if (name[0] == '_' && name[1] == '_') if (name[0] == '_' && name[1] == '_')
return NULL; return NULL;
tree = parser->vars; tree = parser->vars;
break; break;
case HTTPP_NS_QUERY_STRING: case igloo_HTTPP_NS_QUERY_STRING:
tree = parser->queryvars; tree = parser->queryvars;
break; break;
case HTTPP_NS_POST_BODY: case igloo_HTTPP_NS_POST_BODY:
tree = parser->postvars; tree = parser->postvars;
break; break;
} }
@ -769,14 +769,14 @@ char ** igloo_httpp_get_any_key(igloo_http_parser_t *parser, igloo_httpp_ns_t ns
return NULL; return NULL;
switch (ns) { switch (ns) {
case HTTPP_NS_VAR: case igloo_HTTPP_NS_VAR:
case HTTPP_NS_HEADER: case igloo_HTTPP_NS_HEADER:
tree = parser->vars; tree = parser->vars;
break; break;
case HTTPP_NS_QUERY_STRING: case igloo_HTTPP_NS_QUERY_STRING:
tree = parser->queryvars; tree = parser->queryvars;
break; break;
case HTTPP_NS_POST_BODY: case igloo_HTTPP_NS_POST_BODY:
tree = parser->postvars; tree = parser->postvars;
break; break;
} }
@ -793,11 +793,11 @@ char ** igloo_httpp_get_any_key(igloo_http_parser_t *parser, igloo_httpp_ns_t ns
for (avlnode = igloo_avl_get_first(tree); avlnode; avlnode = igloo_avl_get_next(avlnode)) { for (avlnode = igloo_avl_get_first(tree); avlnode; avlnode = igloo_avl_get_next(avlnode)) {
igloo_http_var_t *var = avlnode->key; igloo_http_var_t *var = avlnode->key;
if (ns == HTTPP_NS_VAR) { if (ns == igloo_HTTPP_NS_VAR) {
if (var->name[0] != '_' || var->name[1] != '_') { if (var->name[0] != '_' || var->name[1] != '_') {
continue; continue;
} }
} else if (ns == HTTPP_NS_HEADER) { } else if (ns == igloo_HTTPP_NS_HEADER) {
if (var->name[0] == '_' && var->name[1] == '_') { if (var->name[0] == '_' && var->name[1] == '_') {
continue; continue;
} }
@ -851,7 +851,7 @@ const char *igloo_httpp_get_param(igloo_http_parser_t *parser, const char *name)
static void httpp_clear(igloo_http_parser_t *parser) static void httpp_clear(igloo_http_parser_t *parser)
{ {
parser->req_type = httpp_req_none; parser->req_type = igloo_httpp_req_none;
if (parser->uri) if (parser->uri)
free(parser->uri); free(parser->uri);
parser->uri = NULL; parser->uri = NULL;
@ -923,29 +923,29 @@ static int igloo__free_vars(void *key)
igloo_httpp_request_type_e igloo_httpp_str_to_method(const char * method) { igloo_httpp_request_type_e igloo_httpp_str_to_method(const char * method) {
if (strcasecmp("GET", method) == 0) { if (strcasecmp("GET", method) == 0) {
return httpp_req_get; return igloo_httpp_req_get;
} else if (strcasecmp("POST", method) == 0) { } else if (strcasecmp("POST", method) == 0) {
return httpp_req_post; return igloo_httpp_req_post;
} else if (strcasecmp("PUT", method) == 0) { } else if (strcasecmp("PUT", method) == 0) {
return httpp_req_put; return igloo_httpp_req_put;
} else if (strcasecmp("HEAD", method) == 0) { } else if (strcasecmp("HEAD", method) == 0) {
return httpp_req_head; return igloo_httpp_req_head;
} else if (strcasecmp("OPTIONS", method) == 0) { } else if (strcasecmp("OPTIONS", method) == 0) {
return httpp_req_options; return igloo_httpp_req_options;
} else if (strcasecmp("DELETE", method) == 0) { } else if (strcasecmp("DELETE", method) == 0) {
return httpp_req_delete; return igloo_httpp_req_delete;
} else if (strcasecmp("TRACE", method) == 0) { } else if (strcasecmp("TRACE", method) == 0) {
return httpp_req_trace; return igloo_httpp_req_trace;
} else if (strcasecmp("CONNECT", method) == 0) { } else if (strcasecmp("CONNECT", method) == 0) {
return httpp_req_connect; return igloo_httpp_req_connect;
} else if (strcasecmp("SOURCE", method) == 0) { } else if (strcasecmp("SOURCE", method) == 0) {
return httpp_req_source; return igloo_httpp_req_source;
} else if (strcasecmp("PLAY", method) == 0) { } else if (strcasecmp("PLAY", method) == 0) {
return httpp_req_play; return igloo_httpp_req_play;
} else if (strcasecmp("STATS", method) == 0) { } else if (strcasecmp("STATS", method) == 0) {
return httpp_req_stats; return igloo_httpp_req_stats;
} else { } else {
return httpp_req_unknown; return igloo_httpp_req_unknown;
} }
} }

View File

@ -19,19 +19,19 @@ int main(int argc, char **argv)
printf("Parse succeeded...\n\n"); printf("Parse succeeded...\n\n");
printf("Request was "); printf("Request was ");
switch (parser.req_type) { switch (parser.req_type) {
case httpp_req_none: case igloo_httpp_req_none:
printf(" none\n"); printf(" none\n");
break; break;
case httpp_req_unknown: case igloo_httpp_req_unknown:
printf(" unknown\n"); printf(" unknown\n");
break; break;
case httpp_req_get: case igloo_httpp_req_get:
printf(" get\n"); printf(" get\n");
break; break;
case httpp_req_post: case igloo_httpp_req_post:
printf(" post\n"); printf(" post\n");
break; break;
case httpp_req_head: case igloo_httpp_req_head:
printf(" head\n"); printf(" head\n");
break; break;
} }

View File

@ -40,32 +40,32 @@
#define igloo_HTTPP_VAR_ICYPASSWORD "__icy_password" #define igloo_HTTPP_VAR_ICYPASSWORD "__icy_password"
typedef enum { typedef enum {
HTTPP_NS_VAR, igloo_HTTPP_NS_VAR,
HTTPP_NS_HEADER, igloo_HTTPP_NS_HEADER,
HTTPP_NS_QUERY_STRING, igloo_HTTPP_NS_QUERY_STRING,
HTTPP_NS_POST_BODY igloo_HTTPP_NS_POST_BODY
} igloo_httpp_ns_t; } igloo_httpp_ns_t;
typedef enum httpp_request_type_tag { typedef enum httpp_request_type_tag {
/* Initial and internally used state of the engine */ /* Initial and internally used state of the engine */
httpp_req_none = 0, igloo_httpp_req_none = 0,
/* Part of HTTP standard: GET, POST, PUT and HEAD */ /* Part of HTTP standard: GET, POST, PUT and HEAD */
httpp_req_get, igloo_httpp_req_get,
httpp_req_post, igloo_httpp_req_post,
httpp_req_put, igloo_httpp_req_put,
httpp_req_head, igloo_httpp_req_head,
httpp_req_options, igloo_httpp_req_options,
httpp_req_delete, igloo_httpp_req_delete,
httpp_req_trace, igloo_httpp_req_trace,
httpp_req_connect, igloo_httpp_req_connect,
/* Icecast SOURCE, to be replaced with PUT some day */ /* Icecast SOURCE, to be replaced with PUT some day */
httpp_req_source, igloo_httpp_req_source,
/* XXX: ??? */ /* XXX: ??? */
httpp_req_play, igloo_httpp_req_play,
/* Icecast 2.x STATS, to request a live stream of stats events */ /* Icecast 2.x STATS, to request a live stream of stats events */
httpp_req_stats, igloo_httpp_req_stats,
/* Used if request method is unknown. MUST BE LAST ONE IN LIST. */ /* Used if request method is unknown. MUST BE LAST ONE IN LIST. */
httpp_req_unknown igloo_httpp_req_unknown
} igloo_httpp_request_type_e; } igloo_httpp_request_type_e;
typedef unsigned int igloo_httpp_request_info_t; typedef unsigned int igloo_httpp_request_info_t;