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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
// $Id$
#include "ace/Get_Opt.h"
#include "URL_Addr.h"
#include "Options.h"
ACE_RCSID(Web_Crawler, Options, "$Id$")
int
Options::parse_args (int argc, char *argv[])
{
ACE_Get_Opt getopt (argc, argv, ASYS_TEXT ("df:h:i:l:rt:u:vo:p:"));
ACE_LOG_MSG->open (argv[0]);
this->hostname_ = "www.cs.wustl.edu";
this->uri_ = "~kirthika/auto_purge_client.html";
this->recurse_ = 1; //0;
this->debug_ = 0;
this->timeout_.sec (ACE_DEFAULT_TIMEOUT);
this->url_filter_ = 0;
this->verbose_ = 0;
this->order_ = "FIFO";
this->port_no_ = ACE_DEFAULT_HTTP_PORT;
this->handle_limit_ = 64;
// The default is to make this limit as large as possible.
// int handle_limit = 10;
for (int c;
(c = getopt ()) != EOF;
)
switch (c)
{
case 'd':
this->debug_ = 1;
break;
case 'f':
this->url_filter_ = getopt.optarg;
break;
case 'h':
this->hostname_ = getopt.optarg;
break;
case 'i':
this->uri_ = getopt.optarg;
break;
case 'l':
this->handle_limit_ = ACE_OS::atoi (getopt.optarg);
break;
case 'r':
this->recurse_ = 1;
break;
case 't':
this->timeout_.sec (ACE_OS::atoi (getopt.optarg));
break;
case 'u':
{
this->hostname_ = getopt.optarg;
char *s = ACE_OS::strchr (getopt.optarg, '/');
if (s != 0)
{
this->uri_ = s + 1;
*s = '\0';
}
else
ACE_ERROR ((LM_ERROR,
"invalid URL %s\n",
getopt.optarg));
}
break;
case 'v':
this->verbose_ = 1;
break;
case 'o':
{
this->order_ = getopt.optarg;
}
break;
case 'p':
this->port_no_ = ACE_OS::atoi (getopt.optarg);
break;
default:
ACE_ERROR ((LM_ERROR,
"usage: %n [-d] [-f filter] [-h hostname]"
" [-l handle-limit] [-r] [-t timeout] [-u URI]"
" [-v]\n%a",
1));
/* NOTREACHED */
}
// Don't bother checking the return value since this is just a
// "hint" and isn't portable to all OS platforms.
// ACE::set_handle_limit (handle_limit);
/* ACE_DEBUG ((LM_DEBUG, "Changing rlimit\n"));
struct rlimit rl;
if (getrlimit (RLIMIT_NOFILE, &rl) == -1)
cout << "getrlimit: errno = "<< errno <<endl;
rl.rlim_cur = handle_limit;
if (setrlimit (RLIMIT_NOFILE, &rl) == -1)
cout << "setrlimit: errno = "<< errno <<endl;
ACE_ERROR_RETURN ((LM_ERROR,
"%p \n"),
-1);
if (getrlimit (RLIMIT_NOFILE, &rl) == -1)
cout << "getrlimit: errno = "<< errno <<endl;
else
cout << "limit "<< rl.rlim_cur<<endl;
ACE_DEBUG ((LM_DEBUG, "Changed rlimit\n")); */
return 0;
}
int
Options::port_no (void) const
{
return this->port_no_;
}
int
Options::recurse (void) const
{
return this->recurse_;
}
const ACE_Time_Value *
Options::timeout (void) const
{
return &this->timeout_;
}
int
Options::debug (void) const
{
return this->debug_;
}
int
Options::verbose (void) const
{
return this->verbose_;
}
LPCTSTR
Options::order (void) const
{
return this->order_;
}
LPCTSTR
Options::hostname (void) const
{
return this->hostname_;
}
LPCTSTR
Options::path_name (void) const
{
return this->uri_;
}
LPCTSTR
Options::url_filter (void) const
{
return this->url_filter_;
}
Command_Processor *
Options::command_processor (void) const
{
return this->command_processor_;
}
void
Options::command_processor (Command_Processor *cp)
{
this->command_processor_ = cp;
}
URL_Visitor *
Options::visitor (void) const
{
return this->visitor_;
}
void
Options::visitor (URL_Visitor *v)
{
this->visitor_ = v;
}
int
Options::handle_limit (void)
{
return this->handle_limit_;
}
|