1
0
mirror of https://gitlab.xiph.org/xiph/icecast-common.git synced 2024-06-23 06:25:25 +00:00

Added support for shoutcast login protocol (ewww...)

svn path=/trunk/httpp/; revision=4444
This commit is contained in:
Michael Smith 2003-03-08 04:57:02 +00:00
parent f5c688d43b
commit 8dec7ae9d5
2 changed files with 42 additions and 2 deletions

View File

@ -270,6 +270,42 @@ static void parse_query(http_parser_t *parser, char *query)
}
}
/* The old shoutcast procotol. Don't look at this, it's really nasty */
int httpp_parse_icy(http_parser_t *parser, char *http_data, unsigned long len)
{
char *data;
char *line[MAX_HEADERS];
int lines;
if(http_data == NULL)
return 0;
data = malloc(len + 1);
memcpy(data, http_data, len);
data[len] = 0;
lines = split_headers(data, len, line);
/* Now, this protocol looks like:
* sourcepassword\n
* headers: as normal\n"
* \n
*/
parser->req_type = httpp_req_source;
httpp_setvar(parser, HTTPP_VAR_URI, "/");
httpp_setvar(parser, HTTPP_VAR_ICYPASSWORD, line[0]);
httpp_setvar(parser, HTTPP_VAR_PROTOCOL, "ICY");
/* This protocol is evil */
httpp_setvar(parser, HTTPP_VAR_VERSION, "666");
parse_headers(parser, line, lines);
free(data);
return 1;
}
int httpp_parse(http_parser_t *parser, char *http_data, unsigned long len)
{
char *data, *tmp;
@ -348,8 +384,10 @@ int httpp_parse(http_parser_t *parser, char *http_data, unsigned long len)
}
parser->uri = strdup(uri);
} else
parser->uri = NULL;
} else {
free(data);
return 0;
}
if ((version != NULL) && ((tmp = strchr(version, '/')) != NULL)) {
tmp[0] = '\0';

View File

@ -14,6 +14,7 @@
#define HTTPP_VAR_REQ_TYPE "__req_type"
#define HTTPP_VAR_ERROR_MESSAGE "__errormessage"
#define HTTPP_VAR_ERROR_CODE "__errorcode"
#define HTTPP_VAR_ICYPASSWORD "__icy_password"
typedef enum httpp_request_type_tag {
httpp_req_none, httpp_req_get, httpp_req_post, httpp_req_head,
@ -40,6 +41,7 @@ typedef struct http_parser_tag {
http_parser_t *httpp_create_parser(void);
void httpp_initialize(http_parser_t *parser, http_varlist_t *defaults);
int httpp_parse(http_parser_t *parser, char *http_data, unsigned long len);
int httpp_parse_icy(http_parser_t *parser, char *http_data, unsigned long len);
int httpp_parse_response(http_parser_t *parser, char *http_data, unsigned long len, char *uri);
void httpp_setvar(http_parser_t *parser, char *name, char *value);
char *httpp_getvar(http_parser_t *parser, char *name);