mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-17 16:29:28 -04:00
VC has no getopt(), so do without in bench_http.
This commit is contained in:
parent
4ac38a5c38
commit
1273d2f519
@ -29,19 +29,19 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/time.h>
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <windows.h>
|
#include <winsock2.h>
|
||||||
#else
|
#else
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <event.h>
|
#include <event.h>
|
||||||
@ -88,8 +88,10 @@ main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
struct event_base *base;
|
struct event_base *base;
|
||||||
struct evhttp *http;
|
struct evhttp *http;
|
||||||
|
int i;
|
||||||
int c;
|
int c;
|
||||||
int use_iocp = 0;
|
int use_iocp = 0;
|
||||||
|
unsigned short port = 8080;
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
WSADATA WSAData;
|
WSADATA WSAData;
|
||||||
@ -100,15 +102,25 @@ main(int argc, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
base = event_base_new();
|
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) {
|
switch (c) {
|
||||||
case 'p':
|
case 'p':
|
||||||
port = atoi(optarg);
|
port = atoi(argv[i+1]);
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
content_len = atol(optarg);
|
content_len = atol(argv[i+1]);
|
||||||
if (content_len == 0) {
|
if (content_len == 0) {
|
||||||
fprintf(stderr, "Bad content length\n");
|
fprintf(stderr, "Bad content length\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user