Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / examples / Web_Crawler / Options.cpp
blob824b4b784dbad106d98c8b8fd3ec105cdd601edf
1 #include "ace/Get_Opt.h"
2 #include "ace/Log_Msg.h"
3 #include "URL_Addr.h"
4 #include "Options.h"
5 #include "ace/OS_NS_string.h"
8 int
9 Options::parse_args (int argc, ACE_TCHAR *argv[])
11 //FUZZ: disable check_for_lack_ACE_OS
12 ACE_Get_Opt getopt (argc, argv, ACE_TEXT ("df:h:i:l:rt:u:vo:p:"));
13 //FUZZ: enable check_for_lack_ACE_OS
15 ACE_LOG_MSG->open (argv[0]);
17 this->hostname_ = ACE_TEXT ("www.cs.wustl.edu");
18 this->uri_ = ACE_TEXT ("index.html");
19 this->recurse_ = 0;
20 this->debug_ = 0;
21 this->timeout_.sec (ACE_DEFAULT_TIMEOUT);
22 this->url_filter_ = 0;
23 this->verbose_ = 0;
24 this->order_ = ACE_TEXT ("FIFO");
25 this->port_no_ = ACE_DEFAULT_HTTP_PORT;
27 // The default is to make this limit as large as possible.
28 this->handle_limit_ = -1;
30 //FUZZ: disable check_for_lack_ACE_OS
31 for (int c;
32 (c = getopt ()) != EOF;
34 //FUZZ: enable check_for_lack_ACE_OS
35 switch (c)
37 case ACE_TEXT ('d'):
38 this->debug_ = 1;
39 break;
40 case ACE_TEXT ('f'):
41 this->url_filter_ = getopt.opt_arg ();
42 break;
43 case ACE_TEXT ('h'):
44 this->hostname_ = getopt.opt_arg ();
45 break;
46 case ACE_TEXT ('i'):
47 this->uri_ = getopt.opt_arg ();
48 break;
49 case ACE_TEXT ('l'):
50 this->handle_limit_ = ACE_OS::atoi (getopt.opt_arg ());
51 break;
52 case ACE_TEXT ('r'):
53 this->recurse_ = 1;
54 break;
55 case ACE_TEXT ('t'):
56 this->timeout_.sec (ACE_OS::atoi (getopt.opt_arg ()));
57 break;
58 case ACE_TEXT ('u'):
60 this->hostname_ = getopt.opt_arg ();
61 ACE_TCHAR *s = ACE_OS::strchr (getopt.opt_arg (), ACE_TEXT ('/'));
62 if (s != 0)
64 this->uri_ = s + 1;
65 *s = ACE_TEXT ('\0');
67 else
68 ACE_ERROR ((LM_ERROR,
69 ACE_TEXT ("invalid URL %s\n"),
70 getopt.opt_arg ()));
72 break;
73 case ACE_TEXT ('v'):
74 this->verbose_ = 1;
75 break;
76 case ACE_TEXT ('o'):
78 this->order_ = getopt.opt_arg ();
80 break;
81 case ACE_TEXT ('p'):
82 this->port_no_ = ACE_OS::atoi (getopt.opt_arg ());
83 break;
84 default:
85 ACE_ERROR ((LM_ERROR,
86 ACE_TEXT ("usage: %n [-d] [-f filter] [-h hostname]")
87 ACE_TEXT (" [-l handle-limit] [-r] [-t timeout] [-u URI]")
88 ACE_TEXT (" [-v]\n%a"),
89 1));
91 /* NOTREACHED */
94 return 0;
97 int
98 Options::port_no () const
100 return this->port_no_;
104 Options::recurse () const
106 return this->recurse_;
109 const ACE_Time_Value *
110 Options::timeout () const
112 return &this->timeout_;
116 Options::debug () const
118 return this->debug_;
122 Options::verbose () const
124 return this->verbose_;
127 const ACE_TCHAR *
128 Options::order () const
130 return this->order_;
132 const ACE_TCHAR *
133 Options::hostname () const
135 return this->hostname_;
138 const ACE_TCHAR *
139 Options::path_name () const
141 return this->uri_;
144 const ACE_TCHAR *
145 Options::url_filter () const
147 return this->url_filter_;
150 Command_Processor *
151 Options::command_processor () const
153 return this->command_processor_;
156 void
157 Options::command_processor (Command_Processor *cp)
159 this->command_processor_ = cp;
162 URL_Visitor *
163 Options::visitor () const
165 return this->visitor_;
168 void
169 Options::visitor (URL_Visitor *v)
171 this->visitor_ = v;
175 Options::handle_limit ()
177 return this->handle_limit_;