]> granicus.if.org Git - libevent/commitdiff
VC has no getopt(), so do without in bench_http.
authorChristopher Davis <chrisd@torproject.org>
Tue, 2 Mar 2010 23:16:28 +0000 (15:16 -0800)
committerChristopher Davis <chrisd@mangrin.org>
Tue, 2 Mar 2010 23:31:50 +0000 (15:31 -0800)
test/bench_http.c

index e8d1f276a9a103bb8d1e2d1aca37a4e0a5e483e3..f507414260f7f747e2e32725bee480f478b66695 100644 (file)
 
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/time.h>
 #ifdef WIN32
-#include <windows.h>
+#include <winsock2.h>
 #else
 #include <sys/socket.h>
 #include <sys/resource.h>
+#include <sys/time.h>
+#include <unistd.h>
 #endif
 #include <fcntl.h>
 #include <signal.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include <unistd.h>
 #include <errno.h>
 
 #include <event.h>
@@ -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);