summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-06-23 11:42:08 +0000
committerlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-06-23 11:42:08 +0000
commitcf2832b28ef33a8a987d3200167a5cb9370a7310 (patch)
tree4d7ee41d9dd46c2cb5b9ac1046bed35d083bc3f3
parenta1fb45bdb94af573c0ac5f65b5ddead479b4b7dd (diff)
downloadATCD-cf2832b28ef33a8a987d3200167a5cb9370a7310.tar.gz
added #include of ace/streams.h.
-rw-r--r--netsvcs/clients/Naming/Dump_Restore/Dump_Restore.cpp179
1 files changed, 90 insertions, 89 deletions
diff --git a/netsvcs/clients/Naming/Dump_Restore/Dump_Restore.cpp b/netsvcs/clients/Naming/Dump_Restore/Dump_Restore.cpp
index 084ef01ce54..91bcdecc75d 100644
--- a/netsvcs/clients/Naming/Dump_Restore/Dump_Restore.cpp
+++ b/netsvcs/clients/Naming/Dump_Restore/Dump_Restore.cpp
@@ -3,6 +3,7 @@
#include "ace/Service_Config.h"
#include "ace/Read_Buffer.h"
#include "ace/Thread_Manager.h"
+#include "ace/streams.h"
#include "Dump_Restore.h"
Dump_Restore::Dump_Restore (int argc, char *argv[])
@@ -15,39 +16,39 @@ Dump_Restore::Dump_Restore (int argc, char *argv[])
this->name_options_->parse_args (argc, argv);
//determine name context
- if (ACE_OS::strcmp (this->name_options_->nameserver_host (), "localhost") == 0)
+ if (ACE_OS::strcmp (this->name_options_->nameserver_host (), "localhost") == 0)
{
if (ns_context_->open (ACE_Naming_Context::PROC_LOCAL) == -1)
- ACE_ERROR ( (LM_ERROR, "%p\n", "ns_context_->open"));
+ ACE_ERROR ( (LM_ERROR, "%p\n", "ns_context_->open"));
}
else
{
// Don't really need to do this but it's a hack to fix
// the problme of Display () not printing the right hostname
- ACE_OS::strcpy (this->hostname_,
- this->name_options_->nameserver_host ());
+ ACE_OS::strcpy (this->hostname_,
+ this->name_options_->nameserver_host ());
this->port_ = this->name_options_->nameserver_port ();
if (this->ns_context_->open (ACE_Naming_Context::NET_LOCAL) == -1)
- ACE_ERROR ((LM_ERROR, "%p\n", "ns_context_->open"));
+ ACE_ERROR ((LM_ERROR, "%p\n", "ns_context_->open"));
}
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 ((LM_ERROR, "%p\n", "register_stdin_handler"));
}
Dump_Restore::~Dump_Restore (void)
{
// Deregister this handler with the ACE_Reactor.
- ACE_Reactor::instance ()->remove_handler
+ ACE_Reactor::instance ()->remove_handler
(ACE_STDIN,
ACE_Event_Handler::DONT_CALL | ACE_Event_Handler::READ_MASK);
- ACE_OS::fclose (this->infile_);
+ ACE_OS::fclose (this->infile_);
}
int
@@ -59,10 +60,10 @@ Dump_Restore::handle_input (ACE_HANDLE)
if (::scanf ("%s", option) <= 0)
{
- cerr << "try again" << endl;
+ ACE_DEBUG ((LM_ERROR, "try again\n"));
return 0;
}
-
+
switch (option[0])
{
case 'P' :
@@ -76,15 +77,15 @@ Dump_Restore::handle_input (ACE_HANDLE)
case 'H' :
case 'h' :
if (::scanf ("%s %hu", buf1, &port) <= 0)
- break;
+ break;
set_host (buf1, port);
break;
case 'F':
case 'f':
if (::scanf ("%s", filename_) <= 0)
- break;
+ break;
if (this->infile_)
- ACE_OS::fclose (this->infile_);
+ ACE_OS::fclose (this->infile_);
this->infile_ = fopen(filename_,"r");
break;
case 'B' :
@@ -102,7 +103,7 @@ Dump_Restore::handle_input (ACE_HANDLE)
case 'D':
case 'd':
if (::scanf ("%s", dump_filename_) <= 0)
- break;
+ break;
this->dump ();
break;
case 'Q' :
@@ -128,9 +129,9 @@ Dump_Restore::display_menu (void)
if (ACE_OS::strcmp (this->name_options_->nameserver_host (), "localhost") == 0)
{
if (this->ns_scope_ == ACE_Naming_Context::PROC_LOCAL)
- cout << " *** Using Process Local Database ***" << endl << endl;
+ cout << " *** Using Process Local Database ***" << endl << endl;
else
- cout << " *** Using Node Local Database ***" << endl << endl;
+ cout << " *** Using Node Local Database ***" << endl << endl;
}
else
{
@@ -162,10 +163,10 @@ Dump_Restore::set_proc_local (void)
// Set Naming Context scope
this->ns_scope_ = ACE_Naming_Context::PROC_LOCAL;
-
+
// Remove old naming context
delete this->ns_context_;
-
+
// Create new Naming Context
ACE_NEW_RETURN (this->ns_context_, ACE_Naming_Context, -1);
@@ -183,7 +184,7 @@ Dump_Restore::set_node_local (void)
this->name_options_->nameserver_port (0);
// Set Naming Context scope
- this->ns_scope_ = ACE_Naming_Context::NODE_LOCAL;
+ this->ns_scope_ = ACE_Naming_Context::NODE_LOCAL;
// Remove old naming context
delete this->ns_context_;
@@ -196,7 +197,7 @@ Dump_Restore::set_node_local (void)
return 0;
}
-int
+int
Dump_Restore::set_host (char* hostname, int port)
{
// Set Name Options
@@ -207,7 +208,7 @@ Dump_Restore::set_host (char* hostname, int port)
// the problme of Display () not printing the right hostname
ACE_OS::strcpy (this->hostname_, hostname);
this->port_ = port;
- this->ns_scope_ = ACE_Naming_Context::NET_LOCAL;
+ this->ns_scope_ = ACE_Naming_Context::NET_LOCAL;
// remove old naming context
delete this->ns_context_;
@@ -218,15 +219,15 @@ Dump_Restore::set_host (char* hostname, int port)
// assume net_local context
if (ns_context_->open (ACE_Naming_Context::NET_LOCAL) == -1)
ACE_ERROR_RETURN ( (LM_ERROR, "%p\n", "ns_context_->open"), -1);
-
+
return 0;
}
int
Dump_Restore::doit (Dump_Restore::Operation_Type op,
- char *name,
- char* value,
- char* type)
+ char *name,
+ char* value,
+ char* type)
{
int result = -1;
@@ -234,18 +235,18 @@ Dump_Restore::doit (Dump_Restore::Operation_Type op,
{
case Dump_Restore::BIND:
{
- result = this->bind (name, value, type);
- break;
+ result = this->bind (name, value, type);
+ break;
}
case Dump_Restore::UNBIND:
{
- result = this->unbind (name);
- break;
+ result = this->unbind (name);
+ break;
}
case Dump_Restore::REBIND:
{
- result = this->rebind (name, value, type);
- break;
+ result = this->rebind (name, value, type);
+ break;
}
}
@@ -263,68 +264,68 @@ Dump_Restore::populate (Dump_Restore::Operation_Type op)
State state = NAME;
// reset file pointer
ACE_OS::rewind (this->infile_);
-
+
ACE_Allocator *allocator = ACE_Allocator::instance ();
ACE_Read_Buffer read_buffer (this->infile_, 0, allocator);
for (char *temp; (temp = read_buffer.read ('\n')) != 0; )
- {
- char *name = 0;
- char *actual_name = 0;
- char *value = 0;
- char *actual_value = 0;
- char *type = 0;
- char *actual_type = 0;
-
- switch (state)
- {
- case NAME:
- name = temp;
- ACE_OS::strtok (name, "=");
- actual_name = ACE_OS::strtok (0, "=");
- state = VALUE;
- break;
- case VALUE:
- value = temp;
- ACE_OS::strtok (value, "=");
- actual_value = ACE_OS::strtok (0, "=");
- state = TYPE;
- break;
- case TYPE:
- type = temp;
- ACE_OS::strtok (type, "=");
- actual_type = ACE_OS::strtok (0, "=");
-
- if (actual_type)
- result = this->doit (op,
- actual_name,
- actual_value,
- actual_type);
- else
- result = this->doit (op,
- actual_name,
- actual_value);
- if (name)
- allocator->free(name);
- if (value)
- allocator->free(value);
- if (type)
- allocator->free(type);
- state = NAME;
- break;
- default:
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "populate"), -1);
- /* NOTREACHED */
- }
- }
-
- return result;
+ {
+ char *name = 0;
+ char *actual_name = 0;
+ char *value = 0;
+ char *actual_value = 0;
+ char *type = 0;
+ char *actual_type = 0;
+
+ switch (state)
+ {
+ case NAME:
+ name = temp;
+ ACE_OS::strtok (name, "=");
+ actual_name = ACE_OS::strtok (0, "=");
+ state = VALUE;
+ break;
+ case VALUE:
+ value = temp;
+ ACE_OS::strtok (value, "=");
+ actual_value = ACE_OS::strtok (0, "=");
+ state = TYPE;
+ break;
+ case TYPE:
+ type = temp;
+ ACE_OS::strtok (type, "=");
+ actual_type = ACE_OS::strtok (0, "=");
+
+ if (actual_type)
+ result = this->doit (op,
+ actual_name,
+ actual_value,
+ actual_type);
+ else
+ result = this->doit (op,
+ actual_name,
+ actual_value);
+ if (name)
+ allocator->free(name);
+ if (value)
+ allocator->free(value);
+ if (type)
+ allocator->free(type);
+ state = NAME;
+ break;
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "populate"), -1);
+ /* NOTREACHED */
+ }
+ }
+
+ return result;
}
- else
+ else
return -1;
}
-int
+int
Dump_Restore::bind (char* key, char* value, char* type)
{
int result = ns_context_->bind (key, value, type);
@@ -336,7 +337,7 @@ Dump_Restore::bind (char* key, char* value, char* type)
return 0;
}
-int
+int
Dump_Restore::unbind (char* key)
{
int result = ns_context_->unbind (key);
@@ -347,7 +348,7 @@ Dump_Restore::unbind (char* key)
return 0;
}
-int
+int
Dump_Restore::rebind (char* key, char* value, char* type)
{
if (ns_context_->rebind (key, value, type) == -1)
@@ -356,7 +357,7 @@ Dump_Restore::rebind (char* key, char* value, char* type)
return 0;
}
-int
+int
Dump_Restore::quit (void)
{
return ACE_OS::kill (ACE_OS::getpid (), SIGINT);