-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproj2_proxy.h
60 lines (53 loc) · 1.23 KB
/
proj2_proxy.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
https://powcoder.com
代写代考加微信 powcoder
Assignment Project Exam Help
Add WeChat powcoder
// Modified from CSE422 FS09
// Modified from CSE422 FS12
#include <iostream>
#include <string>
#include <pthread.h>
#include <unistd.h>
#include "HTTP_Request.h"
#include "HTTP_Response.h"
#include "URL.h"
#include "TCP_Socket.h"
#include "Proxy_Worker.h"
using namespace std;
int port = 80;
hostent *server = NULL;
/**
* Prints the help message and exits.
*
* @param exe The name of the eecutalble.
*/
void help_message(char *exe)
{
cout << "Usage " << exe << " [options]" << endl;
cout << "The following option is available:" << endl;
cout << " -h Display help message" << endl;
}
/**
* Parse the parameters
*
* @param argc The number of args.
* @param argv The array of cmd line arguments.
*/
void parse_args(int argc, char *argv[])
{
char *endptr; // for strtol
for(int i = 1; i < argc; i++)
{
if((!strncmp(argv[i], "-h", 2)) ||
(!strncmp(argv[i], "-H", 2)))
{
help_message(argv[0]);
exit(1);
}
else{
cerr << "Invalid parameter:" << argv[i] << endl;
help_message(argv[0]);
exit(1);
}
}
}