From: Christopher Davis Date: Tue, 2 Mar 2010 23:16:28 +0000 (-0800) Subject: VC has no getopt(), so do without in bench_http. X-Git-Tag: release-2.0.5-beta~107 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1273d2f519a386c30149143a85e5175e100cb980;p=libevent VC has no getopt(), so do without in bench_http. --- diff --git a/test/bench_http.c b/test/bench_http.c index e8d1f276..f5074142 100644 --- a/test/bench_http.c +++ b/test/bench_http.c @@ -29,19 +29,19 @@ #include #include -#include #ifdef WIN32 -#include +#include #else #include #include +#include +#include #endif #include #include #include #include #include -#include #include #include @@ -88,8 +88,10 @@ main(int argc, char **argv) { struct event_base *base; struct evhttp *http; + int i; int c; int use_iocp = 0; + unsigned short port = 8080; #ifdef WIN32 WSADATA WSAData; @@ -100,15 +102,25 @@ main(int argc, char **argv) #endif base = event_base_new(); - unsigned short port = 8080; - while ((c = getopt(argc, argv, "p:l:i")) != -1) { + for (i = 1; i < argc; ++i) { + if (*argv[i] != '-') + continue; + + c = argv[i][1]; + + if ((c == 'p' || c == 'l') && i + 1 >= argc) { + fprintf(stderr, "-%c requires argument.\n", c); + exit(1); + } + + switch (c) { case 'p': - port = atoi(optarg); + port = atoi(argv[i+1]); break; case 'l': - content_len = atol(optarg); + content_len = atol(argv[i+1]); if (content_len == 0) { fprintf(stderr, "Bad content length\n"); exit(1);