diff options
author | pradeep <pradeep@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-11-16 23:59:01 +0000 |
---|---|---|
committer | pradeep <pradeep@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-11-16 23:59:01 +0000 |
commit | a9a5d938a047116bea853380ca597a62b4c87ad1 (patch) | |
tree | a11addd01ff0681f14c422167dcf6ecb3edf3611 /apps | |
parent | 3d48600c5a1ef20ac97cd750dd34f785cb052d42 (diff) | |
download | ATCD-a9a5d938a047116bea853380ca597a62b4c87ad1.tar.gz |
hu Nov 16 17:55:18 2000 Pradeep Gore <pradeep@cs.wustl.edu>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/drwho/Multicast_Manager.cpp | 61 | ||||
-rw-r--r-- | apps/drwho/Multicast_Manager.h | 2 | ||||
-rw-r--r-- | apps/drwho/Options.cpp | 138 | ||||
-rw-r--r-- | apps/drwho/Options.h | 2 | ||||
-rw-r--r-- | apps/drwho/Rwho_DB_Manager.h | 2 |
5 files changed, 102 insertions, 103 deletions
diff --git a/apps/drwho/Multicast_Manager.cpp b/apps/drwho/Multicast_Manager.cpp index bd96e00310a..f213a65846e 100644 --- a/apps/drwho/Multicast_Manager.cpp +++ b/apps/drwho/Multicast_Manager.cpp @@ -9,11 +9,11 @@ int Multicast_Manager::received_host_count = 0; Host_Elem *Multicast_Manager::drwho_list = 0; Host_Elem *Multicast_Manager::current_ptr = 0; -// Names of hosts to query for friend info. -char *Multicast_Manager::host_names[] = +// Names of hosts to query for friend info. +const char *Multicast_Manager::host_names[] = { "tango.cs.wustl.edu", - 0 // The NULL entry... + 0 // The NULL entry... }; void @@ -21,7 +21,7 @@ Multicast_Manager::insert_default_hosts (void) { // Enter the static list of hosts into the dynamic table! - for (char **np = host_names; + for (const char **np = host_names; *np != 0; np++) Multicast_Manager::add_host (*np); @@ -30,7 +30,7 @@ Multicast_Manager::insert_default_hosts (void) // Inserts all the names in FILENAME into the list of hosts to // contact. -int +int Multicast_Manager::insert_hosts_from_file (const char *filename) { ACE_Mem_Map mmap (filename); @@ -43,14 +43,14 @@ Multicast_Manager::insert_hosts_from_file (const char *filename) for (char *end_ptr = host_ptr + mmap.size (); host_ptr < end_ptr; ) - { - Multicast_Manager::add_host (host_ptr); + { + Multicast_Manager::add_host (host_ptr); - while (*host_ptr != '\n') - host_ptr++; + while (*host_ptr != '\n') + host_ptr++; - *host_ptr++ = '\0'; - } + *host_ptr++ = '\0'; + } return 0; } @@ -60,11 +60,11 @@ Multicast_Manager::insert_hosts_from_file (const char *filename) // list. If no more unexamined hosts remain a 0 is returned, else a // 1. -int +int Multicast_Manager::get_next_host_addr (in_addr &host_addr) { for (Multicast_Manager::current_ptr = Multicast_Manager::current_ptr == 0 ? Multicast_Manager::drwho_list : Multicast_Manager::current_ptr->next; - + Multicast_Manager::current_ptr != 0; Multicast_Manager::current_ptr = Multicast_Manager::current_ptr->next) { @@ -73,7 +73,7 @@ Multicast_Manager::get_next_host_addr (in_addr &host_addr) if (hp == 0) { - ACE_ERROR ((LM_ERROR, + ACE_ERROR ((LM_ERROR, "%s: host unknown.\n", host_name)); continue; @@ -101,9 +101,9 @@ Multicast_Manager::get_host_entry (const char *host) { static hostent host_entry; hostent *hp; - + if (isdigit (*host)) // IP address. - { + { u_long ia = ACE_OS::inet_addr (host); if (ia == (u_long) -1) @@ -112,18 +112,18 @@ Multicast_Manager::get_host_entry (const char *host) hp = ACE_OS::gethostbyaddr ((char *) &ia, sizeof ia, AF_INET); - } - else - // Host name. + } + else + // Host name. hp = ACE_OS::gethostbyname (host); return hp == 0 ? 0 : (hostent *) memcpy (&host_entry, hp, sizeof *hp); } -// Adds an additional new host to the list of host machines. +// Adds an additional new host to the list of host machines. -void +void Multicast_Manager::add_host (const char *host_name) { ACE_NEW (Multicast_Manager::drwho_list, @@ -131,7 +131,7 @@ Multicast_Manager::add_host (const char *host_name) Multicast_Manager::drwho_list)); } -void +void Multicast_Manager::checkoff_host (in_addr host_addr) { for (Host_Elem *tmp = Multicast_Manager::drwho_list; @@ -141,13 +141,13 @@ Multicast_Manager::checkoff_host (in_addr host_addr) &host_addr.s_addr, sizeof host_addr.s_addr) == 0) { - tmp->checked_off = 1; - Multicast_Manager::received_host_count--; - return; + tmp->checked_off = 1; + Multicast_Manager::received_host_count--; + return; } } -int +int Multicast_Manager::get_next_non_responding_host (const char *&host_name) { for (Multicast_Manager::current_ptr = Multicast_Manager::current_ptr == 0 ? Multicast_Manager::drwho_list : Multicast_Manager::current_ptr->next; @@ -155,10 +155,10 @@ Multicast_Manager::get_next_non_responding_host (const char *&host_name) Multicast_Manager::current_ptr = Multicast_Manager::current_ptr->next) if (Multicast_Manager::current_ptr->checked_off == 0) { - host_name = Multicast_Manager::current_ptr->host_name; - return 1; + host_name = Multicast_Manager::current_ptr->host_name; + return 1; } - + return 0; } @@ -170,9 +170,8 @@ Host_Elem::Host_Elem (const char *h_name, { } -int +int Multicast_Manager::outstanding_hosts_remain (void) { return Multicast_Manager::received_host_count > 0; } - diff --git a/apps/drwho/Multicast_Manager.h b/apps/drwho/Multicast_Manager.h index 5b5f42eddbc..82f609a6546 100644 --- a/apps/drwho/Multicast_Manager.h +++ b/apps/drwho/Multicast_Manager.h @@ -48,7 +48,7 @@ private: static hostent *get_host_entry (const char *host); static int received_host_count; - static char *host_names[]; + static const char *host_names[]; static Host_Elem *drwho_list; static Host_Elem *current_ptr; }; diff --git a/apps/drwho/Options.cpp b/apps/drwho/Options.cpp index c23cfaf04ab..4b82de0563a 100644 --- a/apps/drwho/Options.cpp +++ b/apps/drwho/Options.cpp @@ -5,9 +5,9 @@ #include "ace/Get_Opt.h" #include "ace/Log_Msg.h" -// Initialize all the static variables. +// Initialize all the static variables. -// Contains bit-mask for options. +// Contains bit-mask for options. u_int Options::option_word = 0; // Which protocol are we using? @@ -19,14 +19,14 @@ char *Options::user_name = 0; // Port number for client/server. short Options::port_number = PORT_NUMBER; -// Maximum time the client waits for servers to timeout. +// Maximum time the client waits for servers to timeout. int Options::max_server_timeout = 5; // Name of the program. char *Options::program_name; -// Default name of file that stores friend info. -char *Options::friend_file = FRIEND_FILE; +// Default name of file that stores friend info. +const char *Options::friend_file = FRIEND_FILE; void Options::print_usage_and_die (int long_msg) @@ -34,7 +34,7 @@ Options::print_usage_and_die (int long_msg) ACE_DEBUG ((LM_DEBUG, "usage: %s %s", program_name, - long_msg + long_msg ? "\n" "-?\tprints a short usage message\n" "-A\tappend the following hostname to the list of predefined hostnames.\n" @@ -59,7 +59,7 @@ Options::print_usage_and_die (int long_msg) ACE_OS::exit (1); } -void +void Options::set_opt (Option_Types opt) { Options::option_word |= opt; @@ -79,75 +79,75 @@ Options::set_options (int argc, char *argv[]) Options::program_name = argv[0]; ACE_Get_Opt getopt (argc, argv, "?aA:bdF:f:hH:Llp:rRsSt:w:"); - + while ((c = getopt ()) != -1) { switch (c) - { - case '?': - Options::print_usage_and_die (0); - /* NOTREACHED */ - case 'A': - Multicast_Manager::add_host (getopt.optarg); - break; - case 'a': - Options::protocol_type = PROTO_ALL; - break; - case 'b': - Options::set_opt (Options::BE_A_DAEMON); - break; - case 'd': - Options::set_opt (Options::DEBUG); - break; - case 'f': - Options::friend_file = getopt.optarg; - break; - case 'F': - if (Multicast_Manager::insert_hosts_from_file (getopt.optarg) < 0) + { + case '?': + Options::print_usage_and_die (0); + /* NOTREACHED */ + case 'A': + Multicast_Manager::add_host (getopt.optarg); + break; + case 'a': + Options::protocol_type = PROTO_ALL; + break; + case 'b': + Options::set_opt (Options::BE_A_DAEMON); + break; + case 'd': + Options::set_opt (Options::DEBUG); + break; + case 'f': + Options::friend_file = getopt.optarg; + break; + case 'F': + if (Multicast_Manager::insert_hosts_from_file (getopt.optarg) < 0) ACE_DEBUG ((LM_DEBUG, "%p%a\n", Options::program_name, 1)); - add_default_hosts = 0; - break; - case 'H': - Multicast_Manager::add_host (getopt.optarg); - add_default_hosts = 0; - break; - case 'h': - Options::print_usage_and_die (1); - /* NOTREACHED */ - case 'L': - Options::set_opt (Options::PRINT_LOGIN_NAME); - break; - case 'l': - Options::set_opt (Options::USE_VERBOSE_FORMAT); - break; - case 'p': - Options::port_number = atoi (getopt.optarg); - break; - case 'R': - Options::protocol_type = PROTO_RUSER; - break; - case 'r': - Options::set_opt (Options::REMOTE_USAGE); - break; - case 's': - Options::set_opt (Options::SORT_BY_LOGIN_NAME); - break; - case 'S': - Options::set_opt (Options::SORT_BY_REAL_NAME); - break; - case 't': - Options::max_server_timeout = atoi (getopt.optarg); - break; - case 'w': - Options::user_name = getopt.optarg; - Options::protocol_type = PROTO_USR; - break; - default: - break; - } + add_default_hosts = 0; + break; + case 'H': + Multicast_Manager::add_host (getopt.optarg); + add_default_hosts = 0; + break; + case 'h': + Options::print_usage_and_die (1); + /* NOTREACHED */ + case 'L': + Options::set_opt (Options::PRINT_LOGIN_NAME); + break; + case 'l': + Options::set_opt (Options::USE_VERBOSE_FORMAT); + break; + case 'p': + Options::port_number = atoi (getopt.optarg); + break; + case 'R': + Options::protocol_type = PROTO_RUSER; + break; + case 'r': + Options::set_opt (Options::REMOTE_USAGE); + break; + case 's': + Options::set_opt (Options::SORT_BY_LOGIN_NAME); + break; + case 'S': + Options::set_opt (Options::SORT_BY_REAL_NAME); + break; + case 't': + Options::max_server_timeout = atoi (getopt.optarg); + break; + case 'w': + Options::user_name = getopt.optarg; + Options::protocol_type = PROTO_USR; + break; + default: + break; + } } if (Options::get_opt (Options::REMOTE_USAGE) && add_default_hosts) diff --git a/apps/drwho/Options.h b/apps/drwho/Options.h index 13cf06777d2..5b904329da3 100644 --- a/apps/drwho/Options.h +++ b/apps/drwho/Options.h @@ -56,7 +56,7 @@ public: static Protocol_Types protocol_type; static int max_server_timeout; static char *program_name; - static char *friend_file; + const static char *friend_file; static char *user_name; static void print_usage_and_die (int long_msg); diff --git a/apps/drwho/Rwho_DB_Manager.h b/apps/drwho/Rwho_DB_Manager.h index b995a172a7d..ff1dde83a65 100644 --- a/apps/drwho/Rwho_DB_Manager.h +++ b/apps/drwho/Rwho_DB_Manager.h @@ -44,7 +44,7 @@ private: int current_user; const int WHOD_HEADER_SIZE; char original_pathname[MAXPATHLEN + 1]; - char *rwho_dir_name; + const char *rwho_dir_name; int get_next_host (void); }; |