diff options
author | 2016-02-21 11:35:58 +0100 | |
---|---|---|
committer | 2016-02-21 11:35:58 +0100 | |
commit | b5daabda5495dea5c50e17961ecfed2ea8619d76 (patch) | |
tree | f192bedcd7939c68d40a75a1901239be7f52de07 /3rdparty/http-parser/contrib/url_parser.c | |
parent | e57c90084c5d1dd9f6cdb0bbbf8782dc4f369cda (diff) | |
parent | c24b31a077c2103b27e4df67d3be825c0c7d379d (diff) |
Merge remote-tracking branch 'refs/remotes/mamedev/master'
Resolved Conflicts:
- src/osd/modules/render/d3d/d3dhlsl.cpp
Diffstat (limited to '3rdparty/http-parser/contrib/url_parser.c')
-rw-r--r-- | 3rdparty/http-parser/contrib/url_parser.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/3rdparty/http-parser/contrib/url_parser.c b/3rdparty/http-parser/contrib/url_parser.c new file mode 100644 index 00000000000..6650b414af9 --- /dev/null +++ b/3rdparty/http-parser/contrib/url_parser.c @@ -0,0 +1,46 @@ +#include "http_parser.h" +#include <stdio.h> +#include <string.h> + +void +dump_url (const char *url, const struct http_parser_url *u) +{ + unsigned int i; + + printf("\tfield_set: 0x%x, port: %u\n", u->field_set, u->port); + for (i = 0; i < UF_MAX; i++) { + if ((u->field_set & (1 << i)) == 0) { + printf("\tfield_data[%u]: unset\n", i); + continue; + } + + printf("\tfield_data[%u]: off: %u, len: %u, part: %.*s\n", + i, + u->field_data[i].off, + u->field_data[i].len, + u->field_data[i].len, + url + u->field_data[i].off); + } +} + +int main(int argc, char ** argv) { + struct http_parser_url u; + int len, connect, result; + + if (argc != 3) { + printf("Syntax : %s connect|get url\n", argv[0]); + return 1; + } + len = strlen(argv[2]); + connect = strcmp("connect", argv[1]) == 0 ? 1 : 0; + printf("Parsing %s, connect %d\n", argv[2], connect); + + result = http_parser_parse_url(argv[2], len, connect, &u); + if (result != 0) { + printf("Parse error : %d\n", result); + return result; + } + printf("Parse ok, result : \n"); + dump_url(argv[2], &u); + return 0; +}
\ No newline at end of file |