diff options
author | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-02-06 04:14:55 +0000 |
---|---|---|
committer | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-02-06 04:14:55 +0000 |
commit | ecdf2ad0d66c74d10d1d0a720d64fc1342522922 (patch) | |
tree | e95756e717ed8938f094271313936f8d15969abd /netsvcs | |
parent | 39ce91395546b30fdd2ccb73b84be2862b26e094 (diff) | |
download | ATCD-ecdf2ad0d66c74d10d1d0a720d64fc1342522922.tar.gz |
replaced use of ACE_OS::gets with ACE_OS::fgets
Diffstat (limited to 'netsvcs')
-rw-r--r-- | netsvcs/clients/Naming/Client/Client_Test.cpp | 226 |
1 files changed, 113 insertions, 113 deletions
diff --git a/netsvcs/clients/Naming/Client/Client_Test.cpp b/netsvcs/clients/Naming/Client/Client_Test.cpp index 4ec748b7d5a..fbc027bcdc3 100644 --- a/netsvcs/clients/Naming/Client/Client_Test.cpp +++ b/netsvcs/clients/Naming/Client/Client_Test.cpp @@ -1,6 +1,7 @@ -#define ACE_BUILD_SVC_DLL // $Id$ +#define ACE_BUILD_SVC_DLL + #include "ace/Service_Config.h" #include "ace/Naming_Context.h" #include "ace/Dynamic_Service.h" @@ -120,8 +121,8 @@ Client_Test::open (void) this->display_menu (); if (ACE::register_stdin_handler (this, - ACE_Reactor::instance (), - ACE_Thread_Manager::instance ()) == -1) + ACE_Reactor::instance (), + ACE_Thread_Manager::instance ()) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "register_stdin_handler"), -1); return 0; } @@ -152,12 +153,12 @@ Client_Test::handle_input (ACE_HANDLE) char buf3[BUFSIZ]; char *temp_buf; int port; - char input[256]; + char input[1024]; if (::scanf ("%s", option) <= 0) { ACE_ERROR_RETURN ((LM_ERROR, "%p Try again!\n", - "Client_Test::handle_input"), 0); + "Client_Test::handle_input"), 0); } int result = -1; @@ -172,112 +173,112 @@ Client_Test::handle_input (ACE_HANDLE) break; case 'h' : if (::scanf ("%s %d", buf1, &port) <= 0) - break; + break; result = this->set_host (buf1, port); break; case 'b' : // get the input from stdin - ACE_OS::gets (input); + ACE_OS::fgets (input, sizeof input, ACE_STDIN); // get the key if ((temp_buf = ACE_OS::strtok (input, " "))) - { - ACE_OS::strcpy (buf1, temp_buf); - - // get the value - if ((temp_buf = ACE_OS::strtok (0, " "))) - { - ACE_OS::strcpy (buf2, temp_buf); - - // get the type (if entered) - if ((temp_buf = ACE_OS::strtok (0, " "))) - { - ACE_OS::strcpy (buf3, temp_buf); - result = this->bind (buf1, buf2, buf3); - } - else - result = this->bind (buf1, buf2); - } - else - ACE_ERROR ((LM_ERROR, "Bind Failed! Value not entered.\n")); - } + { + ACE_OS::strcpy (buf1, temp_buf); + + // get the value + if ((temp_buf = ACE_OS::strtok (0, " "))) + { + ACE_OS::strcpy (buf2, temp_buf); + + // get the type (if entered) + if ((temp_buf = ACE_OS::strtok (0, " "))) + { + ACE_OS::strcpy (buf3, temp_buf); + result = this->bind (buf1, buf2, buf3); + } + else + result = this->bind (buf1, buf2); + } + else + ACE_ERROR ((LM_ERROR, "Bind Failed! Value not entered.\n")); + } else - ACE_ERROR ((LM_ERROR, "Bind Failed! Key and Value not entered.\n")); + ACE_ERROR ((LM_ERROR, "Bind Failed! Key and Value not entered.\n")); break; case 'u' : if (::scanf ("%s", buf1) <= 0) - break; + break; result = this->unbind (buf1); break; case 'r' : // get the input from stdin - ACE_OS::gets (input); + ACE_OS::fgets (input, sizeof input, ACE_STDIN); // get the key if ((temp_buf = ACE_OS::strtok (input, " "))) - { - ACE_OS::strcpy (buf1, temp_buf); - - // get the value - if ((temp_buf = ACE_OS::strtok (0, " "))) - { - ACE_OS::strcpy (buf2, temp_buf); - - // get the type (if entered) - if ((temp_buf = ACE_OS::strtok (0, " "))) - { - ACE_OS::strcpy (buf3, temp_buf); - result = this->rebind (buf1, buf2, buf3); - } - else - result = this->rebind (buf1, buf2); - } - else - ACE_ERROR ((LM_ERROR, "Rebind Failed! Value not entered.\n")); - } + { + ACE_OS::strcpy (buf1, temp_buf); + + // get the value + if ((temp_buf = ACE_OS::strtok (0, " "))) + { + ACE_OS::strcpy (buf2, temp_buf); + + // get the type (if entered) + if ((temp_buf = ACE_OS::strtok (0, " "))) + { + ACE_OS::strcpy (buf3, temp_buf); + result = this->rebind (buf1, buf2, buf3); + } + else + result = this->rebind (buf1, buf2); + } + else + ACE_ERROR ((LM_ERROR, "Rebind Failed! Value not entered.\n")); + } else - ACE_ERROR ((LM_ERROR, "Reind Failed! Key and value not entered.\n")); + ACE_ERROR ((LM_ERROR, "Reind Failed! Key and value not entered.\n")); break; case 'f' : if (::scanf ("%s", buf1) <= 0) - break; + break; result = this->find (buf1); break; case 'j' : if (::scanf ("%s", buf1) <= 0) - break; + break; else - result = this->list_names (buf1); + result = this->list_names (buf1); break; case 'k' : if (::scanf ("%s", buf1) <= 0) - break; + break; else - result = this->list_values (buf1); + result = this->list_values (buf1); break; case 'l' : if (::scanf ("%s", buf1) <= 0) - break; + break; else - result = this->list_types (buf1); + result = this->list_types (buf1); break; case 'c' : if (::scanf ("%s", buf1) <= 0) - break; + break; else - result = this->list_name_entries (buf1); + result = this->list_name_entries (buf1); break; case 'd' : if (::scanf ("%s", buf1) <= 0) - break; + break; else - result = this->list_value_entries (buf1); + result = this->list_value_entries (buf1); break; case 'e' : if (::scanf ("%s", buf1) <= 0) - break; + break; else - result = this->list_type_entries (buf1); + result = this->list_type_entries (buf1); break; case 'q' : result = this->quit (); @@ -318,7 +319,7 @@ void Client_Test::list_options (void) { // ACE_DEBUG ((LM_DEBUG, " *** Process Name is %s ***\n", -// this->name_options_->process_name ())); +// this->name_options_->process_name ())); switch (this->name_options_->context ()) { case ACE_Naming_Context::PROC_LOCAL: @@ -329,16 +330,16 @@ Client_Test::list_options (void) break; case ACE_Naming_Context::NET_LOCAL: ACE_DEBUG ((LM_DEBUG, " *** Hostname: %s\n", - this->name_options_->nameserver_host ())); + this->name_options_->nameserver_host ())); ACE_DEBUG ((LM_DEBUG, " *** Port Number: %d\n", - this->name_options_->nameserver_port ())); + this->name_options_->nameserver_port ())); break; default: assert (!"shouldn't occur!\n"); /* NOTREACHED */ } ACE_DEBUG ((LM_DEBUG, " *** Namespace directory is %s ***\n", - this->name_options_->namespace_dir ())); + this->name_options_->namespace_dir ())); } int @@ -387,7 +388,7 @@ Client_Test::bind (char* key, char* value, char* type) { if (NAMING_CONTEXT ()->bind (key, value, type) != 0) ACE_ERROR_RETURN ((LM_ERROR, "%p Bind failed! Key %s exists\n", - "Client_Test::bind", key), 0); + "Client_Test::bind", key), 0); return 0; } @@ -396,7 +397,7 @@ Client_Test::unbind (char* key) { if (NAMING_CONTEXT ()->unbind (key) != 0) ACE_ERROR_RETURN ((LM_ERROR, "%p Unbind failed! Key %s not found\n", - "Client_Test::unbind", key), 0); + "Client_Test::unbind", key), 0); return 0; } @@ -414,15 +415,15 @@ Client_Test::list_names (char *pattern) if (NAMING_CONTEXT ()->list_names (set, pattern) != 0) ACE_ERROR_RETURN ((LM_ERROR, "%p Pattern matching failed!\n", - "Client_Test::list_names"), 0); + "Client_Test::list_names"), 0); else { ACE_PWSTRING_ITERATOR set_iterator (set); for (ACE_WString *name = 0; - set_iterator.next (name) !=0; - set_iterator.advance()) - ACE_DEBUG ((LM_DEBUG, "%s\n", name->char_rep ())); + set_iterator.next (name) !=0; + set_iterator.advance()) + ACE_DEBUG ((LM_DEBUG, "%s\n", name->char_rep ())); } return 0; } @@ -434,15 +435,15 @@ Client_Test::list_values (char *pattern) if (NAMING_CONTEXT ()->list_values (set, pattern) != 0) ACE_ERROR_RETURN ((LM_ERROR, "%p Pattern matching failed!\n", - "Client_Test::list_values"), 0); + "Client_Test::list_values"), 0); else { ACE_PWSTRING_ITERATOR set_iterator (set); for (ACE_WString *value = 0; - set_iterator.next (value) !=0; - set_iterator.advance()) - ACE_DEBUG ((LM_DEBUG, "%s\n", value->char_rep ())); + set_iterator.next (value) !=0; + set_iterator.advance()) + ACE_DEBUG ((LM_DEBUG, "%s\n", value->char_rep ())); } return 0; } @@ -454,15 +455,15 @@ Client_Test::list_types (char *pattern) if (NAMING_CONTEXT ()->list_types (set, pattern) != 0) ACE_ERROR_RETURN ((LM_ERROR, "%p Pattern matching failed!\n", - "Client_Test::list_types"), 0); + "Client_Test::list_types"), 0); else { ACE_PWSTRING_ITERATOR set_iterator (set); for (ACE_WString *type = 0; - set_iterator.next (type) !=0; - set_iterator.advance()) - ACE_DEBUG ((LM_DEBUG, "%s\n", type->char_rep ())); + set_iterator.next (type) !=0; + set_iterator.advance()) + ACE_DEBUG ((LM_DEBUG, "%s\n", type->char_rep ())); } return 0; } @@ -474,20 +475,20 @@ Client_Test::list_name_entries (char *pattern) if (NAMING_CONTEXT ()->list_name_entries (set, pattern) != 0) ACE_ERROR_RETURN ((LM_ERROR, "%p Pattern matching failed!\n", - "Client_Test::list_names"), 0); + "Client_Test::list_names"), 0); else { ACE_BINDING_ITERATOR set_iterator (set); for (ACE_Name_Binding *entry = 0; - set_iterator.next (entry) !=0; - set_iterator.advance()) - { - ACE_DEBUG ((LM_DEBUG, "%s\t", entry->name_.char_rep ())); - ACE_DEBUG ((LM_DEBUG, "%s\t", entry->value_.char_rep ())); - if (entry->type_) - ACE_DEBUG ((LM_DEBUG, "%s\n", entry->type_)); - } + set_iterator.next (entry) !=0; + set_iterator.advance()) + { + ACE_DEBUG ((LM_DEBUG, "%s\t", entry->name_.char_rep ())); + ACE_DEBUG ((LM_DEBUG, "%s\t", entry->value_.char_rep ())); + if (entry->type_) + ACE_DEBUG ((LM_DEBUG, "%s\n", entry->type_)); + } } return 0; } @@ -499,19 +500,19 @@ Client_Test::list_value_entries (char *pattern) if (NAMING_CONTEXT ()->list_value_entries (set, pattern) != 0) ACE_ERROR_RETURN ((LM_ERROR, "%p Pattern matching failed!\n", - "Client_Test::list_values"), 0); + "Client_Test::list_values"), 0); else { ACE_BINDING_ITERATOR set_iterator (set); for (ACE_Name_Binding *entry = 0; - set_iterator.next (entry) !=0; - set_iterator.advance()) - { - ACE_DEBUG ((LM_DEBUG, "%s\t", entry->name_.char_rep ())); - ACE_DEBUG ((LM_DEBUG, "%s\t", entry->value_.char_rep ())); - if (entry->type_) - ACE_DEBUG ((LM_DEBUG, "%s\n", entry->type_)); - } + set_iterator.next (entry) !=0; + set_iterator.advance()) + { + ACE_DEBUG ((LM_DEBUG, "%s\t", entry->name_.char_rep ())); + ACE_DEBUG ((LM_DEBUG, "%s\t", entry->value_.char_rep ())); + if (entry->type_) + ACE_DEBUG ((LM_DEBUG, "%s\n", entry->type_)); + } } return 0; } @@ -523,19 +524,19 @@ Client_Test::list_type_entries (char *pattern) if (NAMING_CONTEXT ()->list_type_entries (set, pattern) != 0) ACE_ERROR_RETURN ((LM_ERROR, "%p Pattern matching failed!\n", - "Client_Test::list_types"), 0); + "Client_Test::list_types"), 0); else { ACE_BINDING_ITERATOR set_iterator (set); for (ACE_Name_Binding *entry = 0; - set_iterator.next (entry) !=0; - set_iterator.advance()) - { - ACE_DEBUG ((LM_DEBUG, "%s\t", entry->name_.char_rep ())); - ACE_DEBUG ((LM_DEBUG, "%s\t", entry->value_.char_rep ())); - ACE_DEBUG ((LM_DEBUG, "%s\n", entry->type_)); - } + set_iterator.next (entry) !=0; + set_iterator.advance()) + { + ACE_DEBUG ((LM_DEBUG, "%s\t", entry->name_.char_rep ())); + ACE_DEBUG ((LM_DEBUG, "%s\t", entry->value_.char_rep ())); + ACE_DEBUG ((LM_DEBUG, "%s\n", entry->type_)); + } } return 0; } @@ -549,14 +550,14 @@ Client_Test::find (char *key) if (NAMING_CONTEXT ()->resolve (key, value, type) != 0) ACE_ERROR_RETURN ((LM_ERROR, "%p Find failed! Key %s not found\n", - "Client_Test::list_find", key), 0); + "Client_Test::list_find", key), 0); else { ACE_DEBUG ((LM_DEBUG, - "Binding for %s : value = %s\ttype = %s\n", - key, value, type)); + "Binding for %s : value = %s\ttype = %s\n", + key, value, type)); if (type) - delete [] type; + delete [] type; return 0; } } @@ -567,4 +568,3 @@ template class ACE_Dynamic_Service<ACE_Naming_Context>; #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) #pragma instantiate ACE_Dynamic_Service<ACE_Naming_Context> #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ - |