1 #include "ace/OS_NS_stdlib.h"
2 #include "ace/Get_Opt.h"
3 #include "ace/Log_Msg.h"
5 #include "Multicast_Manager.h"
7 // Initialize all the static variables.
9 // Contains bit-mask for options.
10 u_int
Options::option_word
= 0;
12 // Which protocol are we using?
13 Options::Protocol_Types
Options::protocol_type
= Options::PROTO_FLO
;
15 // User name for quick lookups.
16 char *Options::user_name
= 0;
18 // Port number for client/server.
19 short Options::port_number
= PORT_NUMBER
;
21 // Maximum time the client waits for servers to timeout.
22 int Options::max_server_timeout
= 5;
24 // Name of the program.
25 char *Options::program_name
;
27 // Default name of file that stores friend info.
28 const char *Options::friend_file
= FRIEND_FILE
;
31 Options::print_usage_and_die (int long_msg
)
38 "-?\tprints a short usage message\n"
39 "-A\tappend the following hostname to the list of predefined hostnames.\n"
40 "-a\treturn information on *all* users remotely logged in (uses yp passwd).\n"
41 "-b\trun the server in the background (i.e., as a daemon).\n"
42 "-d\tturn on debugging.\n"
43 "-F\tuse the following file contents to initialize the host list.\n"
44 "-f\tuse the following file contents to initialize the friends database.\n"
45 "-H\tuse the following hostname as part of the new list of hostnames.\n"
46 "\t(this option overwrites the existing default names).\n"
47 "-h\tprint a long usage message.\n"
48 "-L\tprint the login name rather than the real name (which is the default).\n"
49 "-l\tprint information in long format (works for all protocols).\n"
50 "-p\tset the port number (server must correspond).\n"
51 "-r\tdo the remote lookups (i.e., local operations are the default).\n"
52 "-R\tprint info using the rusers format.\n"
53 "-s\tsort the output by login name.\n"
54 "-S\tsort the output by real name.\n"
55 "-t\tset the amount of time we wait for servers to timeout.\n"
56 "-w\treturn information on just one user.\n"
57 : "[-?haAbdfFHhLlpRrtw]\n"));
62 Options::set_opt (Option_Types opt
)
64 Options::option_word
|= opt
;
68 Options::get_opt (Option_Types opt
)
70 return (Options::option_word
& opt
) != 0;
74 Options::set_options (int argc
, char *argv
[])
77 int add_default_hosts
= 1;
79 Options::program_name
= argv
[0];
81 //FUZZ: disable check_for_lack_ACE_OS
82 ACE_Get_Opt
getopt (argc
, argv
, ACE_TEXT("?aA:bdF:f:hH:Llp:rRsSt:w:"));
84 while ((c
= getopt ()) != -1)
86 //FUZZ: endable check_for_lack_ACE_OS
90 Options::print_usage_and_die (0);
93 Multicast_Manager::add_host (getopt
.opt_arg ());
96 Options::protocol_type
= PROTO_ALL
;
99 Options::set_opt (Options::BE_A_DAEMON
);
102 Options::set_opt (Options::DEBUGGING
);
105 Options::friend_file
= getopt
.opt_arg ();
108 if (Multicast_Manager::insert_hosts_from_file (getopt
.opt_arg ()) < 0)
109 ACE_DEBUG ((LM_DEBUG
,
111 Options::program_name
,
113 add_default_hosts
= 0;
116 Multicast_Manager::add_host (getopt
.opt_arg ());
117 add_default_hosts
= 0;
120 Options::print_usage_and_die (1);
123 Options::set_opt (Options::PRINT_LOGIN_NAME
);
126 Options::set_opt (Options::USE_VERBOSE_FORMAT
);
129 Options::port_number
= ACE_OS::atoi (getopt
.opt_arg ());
132 Options::protocol_type
= PROTO_RUSER
;
135 Options::set_opt (Options::REMOTE_USAGE
);
138 Options::set_opt (Options::SORT_BY_LOGIN_NAME
);
141 Options::set_opt (Options::SORT_BY_REAL_NAME
);
144 Options::max_server_timeout
= ACE_OS::atoi (getopt
.opt_arg ());
147 Options::user_name
= getopt
.opt_arg ();
148 Options::protocol_type
= PROTO_USR
;
155 if (Options::get_opt (Options::REMOTE_USAGE
) && add_default_hosts
)
156 Multicast_Manager::insert_default_hosts ();