summaryrefslogtreecommitdiff
path: root/netsvcs/clients/Naming/Dump_Restore
diff options
context:
space:
mode:
authorlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1996-10-21 21:41:34 +0000
committerlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1996-10-21 21:41:34 +0000
commita5fdebc5f6375078ec1763850a4ca23ec7fe6458 (patch)
treebcf0a25c3d45a209a6e3ac37b233a4812f29c732 /netsvcs/clients/Naming/Dump_Restore
downloadATCD-a5fdebc5f6375078ec1763850a4ca23ec7fe6458.tar.gz
Initial revision
Diffstat (limited to 'netsvcs/clients/Naming/Dump_Restore')
-rw-r--r--netsvcs/clients/Naming/Dump_Restore/Dump_Restore.cpp388
-rw-r--r--netsvcs/clients/Naming/Dump_Restore/Dump_Restore.h74
-rw-r--r--netsvcs/clients/Naming/Dump_Restore/Makefile176
-rw-r--r--netsvcs/clients/Naming/Dump_Restore/README67
-rw-r--r--netsvcs/clients/Naming/Dump_Restore/createfile.cpp32
-rw-r--r--netsvcs/clients/Naming/Dump_Restore/main.cpp22
-rw-r--r--netsvcs/clients/Naming/Dump_Restore/nametest.cpp112
-rw-r--r--netsvcs/clients/Naming/Dump_Restore/nametest.h15
8 files changed, 886 insertions, 0 deletions
diff --git a/netsvcs/clients/Naming/Dump_Restore/Dump_Restore.cpp b/netsvcs/clients/Naming/Dump_Restore/Dump_Restore.cpp
new file mode 100644
index 00000000000..91617d11662
--- /dev/null
+++ b/netsvcs/clients/Naming/Dump_Restore/Dump_Restore.cpp
@@ -0,0 +1,388 @@
+#include <fstream.h>
+// @(#)Dump_Restore.cpp 1.1 10/18/96
+
+#include "ace/Service_Config.h"
+#include "ace/Read_Buffer.h"
+#include "Dump_Restore.h"
+
+Dump_Restore::Dump_Restore (int argc, char *argv[])
+ : infile_ (0)
+{
+ ACE_NEW (this->ns_context_, ACE_Naming_Context);
+
+ // Cache the name options
+ this->name_options_ = this->ns_context_->name_options ();
+ this->name_options_->parse_args (argc, argv);
+
+ //determine name context
+ 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"));
+ }
+ 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 ());
+ 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"));
+ }
+
+ this->display_menu ();
+
+ if (ACE::register_stdin_handler (this,
+ ACE_Service_Config::reactor (),
+ ACE_Service_Config::thr_mgr ()) == -1)
+ ACE_ERROR ((LM_ERROR, "%p\n", "register_stdin_handler"));
+}
+
+Dump_Restore::~Dump_Restore (void)
+{
+ // Deregister this handler with the ACE_Reactor.
+ ACE_Service_Config::reactor ()->remove_handler
+ (ACE_STDIN,
+ ACE_Event_Handler::DONT_CALL | ACE_Event_Handler::READ_MASK);
+
+ ACE_OS::fclose (this->infile_);
+}
+
+int
+Dump_Restore::handle_input (ACE_HANDLE)
+{
+ char option[BUFSIZ];
+ char buf1[BUFSIZ];
+ char buf2[BUFSIZ];
+ char buf3[BUFSIZ];
+ char *temp_buf;
+ int port;
+ char input[256];
+
+ if (::scanf ("%s", option) <= 0)
+ {
+ cerr << "try again" << endl;
+ return 0;
+ }
+
+ int result = -1;
+ switch (option[0])
+ {
+ case 'P' :
+ case 'p' :
+ result = set_proc_local ();
+ break;
+ case 'N' :
+ case 'n' :
+ result = set_node_local ();
+ break;
+ case 'H' :
+ case 'h' :
+ if (::scanf ("%s %d", buf1, &port) <= 0)
+ break;
+ result = set_host (buf1, port);
+ break;
+ case 'F':
+ case 'f':
+ if (::scanf ("%s", filename_) <= 0)
+ break;
+ if (this->infile_)
+ ACE_OS::fclose (this->infile_);
+ this->infile_ = fopen(filename_,"r");
+ break;
+ case 'B' :
+ case 'b' :
+ result = populate (Dump_Restore::BIND);
+ break;
+ case 'U' :
+ case 'u' :
+ result = populate (Dump_Restore::UNBIND);
+ break;
+ case 'R' :
+ case 'r' :
+ result = populate (Dump_Restore::REBIND);
+ break;
+ case 'D':
+ case 'd':
+ if (::scanf ("%s", dump_filename_) <= 0)
+ break;
+ this->dump ();
+ break;
+ case 'Q' :
+ case 'q' :
+ result = quit ();
+ break;
+ default :
+ cout << "Unrecognized command." << endl;
+ }
+// if (result == 0)
+// cout << "Last operation was successful!" << endl;
+// else
+// cout << "Last operation returned: " << result << endl;
+
+ display_menu ();
+ return 0;
+}
+
+void
+Dump_Restore::display_menu (void)
+{
+ cout << endl;
+ cout << " Name Service Main Menu" << endl;
+ cout << " ----------------------" << endl;
+
+ // Check if using local name space or remote name space
+ 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;
+ else
+ cout << " *** Using Node Local Database ***" << endl << endl;
+ }
+ else
+ {
+ cout << " Hostname: " << this->hostname_;
+ cout << " Port Number: " << this->port_ << endl << endl;
+ }
+ if (this->infile_)
+ cout << "Input File: " << filename_ << endl << endl;
+ else
+ cout << "** No Input File Specified **" << endl;
+ cout << "<P> Use Process Local Database" << endl;
+ cout << "<N> Use Node Local Database" << endl;
+ cout << "<H> Set Remote Name server <host> and <port>" << endl;
+ cout << "<F> Set Input File <file name>" << endl << endl;
+ cout << "<B> Bind" << endl;
+ cout << "<U> Unbind" << endl;
+ cout << "<R> Rebind" << endl;
+ cout << "<D> Dump <file name>" << endl;
+ cout << "<Q> or ^C (exit) " << endl;
+}
+
+
+int
+Dump_Restore::set_proc_local (void)
+{
+ // Set Name Options
+ this->name_options_->nameserver_host ("localhost");
+ this->name_options_->nameserver_port (0);
+
+ // 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);
+
+ if (this->ns_context_->open (ACE_Naming_Context::PROC_LOCAL) == -1)
+ ACE_ERROR_RETURN ( (LM_ERROR, "%p\n", "ns_context_->open"), -1);
+
+ return 0;
+}
+
+int
+Dump_Restore::set_node_local (void)
+{
+ // Set Name Options
+ this->name_options_->nameserver_host ("localhost");
+ this->name_options_->nameserver_port (0);
+
+ // Set Naming Context scope
+ this->ns_scope_ = ACE_Naming_Context::NODE_LOCAL;
+
+ // Remove old naming context
+ delete this->ns_context_;
+
+ // Create new Naming Context
+ ACE_NEW_RETURN (this->ns_context_, ACE_Naming_Context, -1);
+
+ if (ns_context_->open (ACE_Naming_Context::NODE_LOCAL) == -1)
+ ACE_ERROR_RETURN ( (LM_ERROR, "%p\n", "ns_context_->open"), -1);
+ return 0;
+}
+
+int
+Dump_Restore::set_host (char* hostname, int port)
+{
+ // Set Name Options
+ this->name_options_->nameserver_host (hostname);
+ this->name_options_->nameserver_port (port);
+
+ // 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_, hostname);
+ this->port_ = port;
+ this->ns_scope_ = ACE_Naming_Context::NET_LOCAL;
+
+ // remove old naming context
+ delete this->ns_context_;
+
+ // Create new Naming Context
+ ACE_NEW_RETURN (this->ns_context_, ACE_Naming_Context, -1);
+
+ // 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)
+{
+ int result = -1;
+
+ switch (op)
+ {
+ case Dump_Restore::BIND:
+ {
+ result = this->bind (name, value, type);
+ break;
+ }
+ case Dump_Restore::UNBIND:
+ {
+ result = this->unbind (name);
+ break;
+ }
+ case Dump_Restore::REBIND:
+ {
+ result = this->rebind (name, value, type);
+ break;
+ }
+ }
+
+ return result;
+}
+
+int
+Dump_Restore::populate (Dump_Restore::Operation_Type op)
+{
+ if (this->infile_)
+ {
+ int result = -1;
+ enum State { NAME, VALUE, TYPE };
+
+ State state = NAME;
+ // reset file pointer
+ ACE_OS::rewind (this->infile_);
+
+ ACE_Allocator *allocator = ACE_Service_Config::allocator ();
+ 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);
+ break;
+ }
+ }
+
+ return result;
+ }
+ else
+ return -1;
+}
+
+int
+Dump_Restore::bind (char* key, char* value, char* type)
+{
+ int result = ns_context_->bind (key, value, type);
+
+ if (result == -1)
+ ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ns_context_->bind"), -1);
+ else if (result == 1)
+ ACE_ERROR_RETURN ((LM_ERROR, "%s%s%s\n", "key <", key, "> already bound"), 1);
+ return 0;
+}
+
+int
+Dump_Restore::unbind (char* key)
+{
+ int result = ns_context_->unbind (key);
+
+ if (result == -1)
+ ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ns_context_->unbind"), -1);
+
+ return 0;
+}
+
+int
+Dump_Restore::rebind (char* key, char* value, char* type)
+{
+ if (ns_context_->rebind (key, value, type) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ns_context_->rebind"), -1);
+
+ return 0;
+}
+
+int
+Dump_Restore::quit (void)
+{
+ return ACE_OS::kill (ACE_OS::getpid (), SIGINT);
+}
+
+void
+Dump_Restore::dump (void)
+{
+ ofstream output_file (dump_filename_);
+
+ ostream *orig_stream = ACE_Log_Msg::instance ()->msg_ostream ();
+ ACE_Log_Msg::instance ()->msg_ostream (&output_file);
+ ACE_Log_Msg::instance ()->clr_flags (ACE_Log_Msg::STDERR | ACE_Log_Msg::LOGGER );
+ ACE_Log_Msg::instance ()->set_flags (ACE_Log_Msg::OSTREAM);
+
+ ns_context_->dump ();
+
+ ACE_Log_Msg::instance ()->msg_ostream (orig_stream);
+ ACE_Log_Msg::instance ()->clr_flags (ACE_Log_Msg::STDERR);
+}
diff --git a/netsvcs/clients/Naming/Dump_Restore/Dump_Restore.h b/netsvcs/clients/Naming/Dump_Restore/Dump_Restore.h
new file mode 100644
index 00000000000..218e842f2e9
--- /dev/null
+++ b/netsvcs/clients/Naming/Dump_Restore/Dump_Restore.h
@@ -0,0 +1,74 @@
+/* -*- C++ -*- */
+// @(#)Dump_Restore.h 1.1 10/18/96
+
+#include "ace/Event_Handler.h"
+#include "ace/Reactor.h"
+#include "ace/Naming_Context.h"
+
+class Dump_Restore : public ACE_Event_Handler
+{
+public:
+ enum Operation_Type
+ {
+ BIND,
+ UNBIND,
+ REBIND
+ };
+ Dump_Restore (int argc, char *argv[]);
+ // Initialize name options and naming context
+
+ ~Dump_Restore (void);
+
+ virtual int handle_input (ACE_HANDLE handle);
+ // Handle user entered commands
+
+ void dump (void);
+
+private:
+ char hostname_[MAXHOSTNAMELEN + 1];
+ // Cache the hostname and port number for remote case
+
+ void display_menu (void);
+ // Display user menu.
+
+ int set_proc_local (void);
+ // Set options to use PROC_LOCAL naming context.
+
+ int set_node_local (void);
+ // Set options to use NODE_LOCAL naming context.
+
+ int set_host (char* hostname, int port);
+ // Set options to use NET_LOCAL naming context specifying host name
+ // and port number.
+
+ int quit (void);
+ // Gracefully exit.
+
+ int populate (Dump_Restore::Operation_Type op);
+
+ int doit (Dump_Restore::Operation_Type op,
+ char *name,
+ char *value,
+ char *type = "");
+ int bind (char* key, char* value, char* type = "");
+ int unbind (char* key);
+ int rebind (char* key, char* value, char* type = "");
+
+ char filename_[MAXPATHLEN];
+ char dump_filename_[MAXPATHLEN];
+
+ u_short port_;
+ // port server is listening on
+
+ ACE_Naming_Context *ns_context_;
+ // Current naming context
+
+ ACE_Naming_Context::Context_Scope_Type ns_scope_;
+ // Defines the scope of the naming context
+
+ FILE *infile_;
+ // input file
+
+ ACE_Name_Options *name_options_;
+ // Name Options associated with the Naming Context
+};
diff --git a/netsvcs/clients/Naming/Dump_Restore/Makefile b/netsvcs/clients/Naming/Dump_Restore/Makefile
new file mode 100644
index 00000000000..62b517b4e40
--- /dev/null
+++ b/netsvcs/clients/Naming/Dump_Restore/Makefile
@@ -0,0 +1,176 @@
+#----------------------------------------------------------------------------
+# @(#)Makefile 1.1 10/18/96
+#
+# Makefile for the ACE Dump-Restore Name_Server utility
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# Local macros
+#----------------------------------------------------------------------------
+
+BIN = main
+LIB = libDump_Restore.a
+SHLIB = libDump_Restore.so
+
+FILES = Dump_Restore
+
+SRC = $(addsuffix .cpp,$(BIN))
+OBJ = $(SRC:%.cpp=$(VDIR)%.o)
+
+LSRC = $(addsuffix .cpp,$(FILES))
+LOBJ = $(LSRC:%.cpp=$(VDIR)%.o)
+SHOBJ = $(addsuffix .so,$(FILES))
+
+LDLIBS = -lDump_Restore
+LIBS += -lACE
+
+VLDLIBS = $(LDLIBS:%=%$(VAR))
+
+BUILD = $(VLIB) $(VSHLIB) $(SHLIBA) $(VBIN)
+
+#----------------------------------------------------------------------------
+# Include macros and targets
+#----------------------------------------------------------------------------
+
+include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU
+include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU
+include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU
+include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU
+include $(WRAPPER_ROOT)/include/makeinclude/rules.lib.GNU
+include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU
+include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU
+
+#----------------------------------------------------------------------------
+# Local targets
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# Dependencies
+#----------------------------------------------------------------------------
+# DO NOT DELETE THIS LINE -- g++dep uses it.
+# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
+
+.obj/Dump_Restore.o .shobj/Dump_Restore.so: Dump_Restore.cpp \
+ $(WRAPPER_ROOT)/ace/Service_Config.h \
+ $(WRAPPER_ROOT)/ace/Service_Object.h \
+ $(WRAPPER_ROOT)/ace/Shared_Object.h \
+ $(WRAPPER_ROOT)/ace/ACE.h \
+ $(WRAPPER_ROOT)/ace/OS.h \
+ $(WRAPPER_ROOT)/ace/Time_Value.h \
+ $(WRAPPER_ROOT)/ace/config.h \
+ $(WRAPPER_ROOT)/ace/Trace.h \
+ $(WRAPPER_ROOT)/ace/ACE.i \
+ $(WRAPPER_ROOT)/ace/Log_Msg.h \
+ $(WRAPPER_ROOT)/ace/Log_Record.h \
+ $(WRAPPER_ROOT)/ace/Log_Priority.h \
+ $(WRAPPER_ROOT)/ace/Log_Record.i \
+ $(WRAPPER_ROOT)/ace/Event_Handler.h \
+ $(WRAPPER_ROOT)/ace/Thread_Manager.h \
+ $(WRAPPER_ROOT)/ace/Thread.h \
+ $(WRAPPER_ROOT)/ace/Synch.h \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \
+ $(WRAPPER_ROOT)/ace/Synch_T.h \
+ $(WRAPPER_ROOT)/ace/Set.h \
+ $(WRAPPER_ROOT)/ace/Proactor.h \
+ $(WRAPPER_ROOT)/ace/Message_Block.h \
+ $(WRAPPER_ROOT)/ace/Malloc.h \
+ $(WRAPPER_ROOT)/ace/Malloc_T.h \
+ $(WRAPPER_ROOT)/ace/Memory_Pool.h \
+ $(WRAPPER_ROOT)/ace/Signal.h \
+ $(WRAPPER_ROOT)/ace/Mem_Map.h \
+ $(WRAPPER_ROOT)/ace/Timer_Queue.h \
+ $(WRAPPER_ROOT)/ace/Timer_Queue.i \
+ $(WRAPPER_ROOT)/ace/ReactorEx.h \
+ $(WRAPPER_ROOT)/ace/Token.h \
+ $(WRAPPER_ROOT)/ace/Reactor.h \
+ $(WRAPPER_ROOT)/ace/Handle_Set.h \
+ $(WRAPPER_ROOT)/ace/Pipe.h \
+ $(WRAPPER_ROOT)/ace/Pipe.i \
+ $(WRAPPER_ROOT)/ace/SOCK_Stream.h \
+ $(WRAPPER_ROOT)/ace/SOCK_IO.h \
+ $(WRAPPER_ROOT)/ace/SOCK.h \
+ $(WRAPPER_ROOT)/ace/Addr.h \
+ $(WRAPPER_ROOT)/ace/IPC_SAP.h \
+ $(WRAPPER_ROOT)/ace/IPC_SAP.i \
+ $(WRAPPER_ROOT)/ace/SOCK.i \
+ $(WRAPPER_ROOT)/ace/SOCK_IO.i \
+ $(WRAPPER_ROOT)/ace/INET_Addr.h \
+ $(WRAPPER_ROOT)/ace/SOCK_Stream.i \
+ $(WRAPPER_ROOT)/ace/Reactor.i \
+ $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \
+ $(WRAPPER_ROOT)/ace/Read_Buffer.h \
+ $(WRAPPER_ROOT)/ace/Read_Buffer.i \
+ Dump_Restore.h \
+ $(WRAPPER_ROOT)/ace/Naming_Context.h \
+ $(WRAPPER_ROOT)/ace/SString.h \
+ $(WRAPPER_ROOT)/ace/Name_Proxy.h \
+ $(WRAPPER_ROOT)/ace/SOCK_Connector.h \
+ $(WRAPPER_ROOT)/ace/SOCK_Connector.i \
+ $(WRAPPER_ROOT)/ace/Synch_Options.h \
+ $(WRAPPER_ROOT)/ace/Name_Request_Reply.h \
+ $(WRAPPER_ROOT)/ace/Name_Space.h
+.obj/main.o .shobj/main.so: main.cpp \
+ $(WRAPPER_ROOT)/ace/Service_Config.h \
+ $(WRAPPER_ROOT)/ace/Service_Object.h \
+ $(WRAPPER_ROOT)/ace/Shared_Object.h \
+ $(WRAPPER_ROOT)/ace/ACE.h \
+ $(WRAPPER_ROOT)/ace/OS.h \
+ $(WRAPPER_ROOT)/ace/Time_Value.h \
+ $(WRAPPER_ROOT)/ace/config.h \
+ $(WRAPPER_ROOT)/ace/Trace.h \
+ $(WRAPPER_ROOT)/ace/ACE.i \
+ $(WRAPPER_ROOT)/ace/Log_Msg.h \
+ $(WRAPPER_ROOT)/ace/Log_Record.h \
+ $(WRAPPER_ROOT)/ace/Log_Priority.h \
+ $(WRAPPER_ROOT)/ace/Log_Record.i \
+ $(WRAPPER_ROOT)/ace/Event_Handler.h \
+ $(WRAPPER_ROOT)/ace/Thread_Manager.h \
+ $(WRAPPER_ROOT)/ace/Thread.h \
+ $(WRAPPER_ROOT)/ace/Synch.h \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \
+ $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \
+ $(WRAPPER_ROOT)/ace/Synch_T.h \
+ $(WRAPPER_ROOT)/ace/Set.h \
+ $(WRAPPER_ROOT)/ace/Proactor.h \
+ $(WRAPPER_ROOT)/ace/Message_Block.h \
+ $(WRAPPER_ROOT)/ace/Malloc.h \
+ $(WRAPPER_ROOT)/ace/Malloc_T.h \
+ $(WRAPPER_ROOT)/ace/Memory_Pool.h \
+ $(WRAPPER_ROOT)/ace/Signal.h \
+ $(WRAPPER_ROOT)/ace/Mem_Map.h \
+ $(WRAPPER_ROOT)/ace/Timer_Queue.h \
+ $(WRAPPER_ROOT)/ace/Timer_Queue.i \
+ $(WRAPPER_ROOT)/ace/ReactorEx.h \
+ $(WRAPPER_ROOT)/ace/Token.h \
+ $(WRAPPER_ROOT)/ace/Reactor.h \
+ $(WRAPPER_ROOT)/ace/Handle_Set.h \
+ $(WRAPPER_ROOT)/ace/Pipe.h \
+ $(WRAPPER_ROOT)/ace/Pipe.i \
+ $(WRAPPER_ROOT)/ace/SOCK_Stream.h \
+ $(WRAPPER_ROOT)/ace/SOCK_IO.h \
+ $(WRAPPER_ROOT)/ace/SOCK.h \
+ $(WRAPPER_ROOT)/ace/Addr.h \
+ $(WRAPPER_ROOT)/ace/IPC_SAP.h \
+ $(WRAPPER_ROOT)/ace/IPC_SAP.i \
+ $(WRAPPER_ROOT)/ace/SOCK.i \
+ $(WRAPPER_ROOT)/ace/SOCK_IO.i \
+ $(WRAPPER_ROOT)/ace/INET_Addr.h \
+ $(WRAPPER_ROOT)/ace/SOCK_Stream.i \
+ $(WRAPPER_ROOT)/ace/Reactor.i \
+ $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \
+ Dump_Restore.h \
+ $(WRAPPER_ROOT)/ace/Naming_Context.h \
+ $(WRAPPER_ROOT)/ace/SString.h \
+ $(WRAPPER_ROOT)/ace/Name_Proxy.h \
+ $(WRAPPER_ROOT)/ace/SOCK_Connector.h \
+ $(WRAPPER_ROOT)/ace/SOCK_Connector.i \
+ $(WRAPPER_ROOT)/ace/Synch_Options.h \
+ $(WRAPPER_ROOT)/ace/Name_Request_Reply.h \
+ $(WRAPPER_ROOT)/ace/Name_Space.h
+
+# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
diff --git a/netsvcs/clients/Naming/Dump_Restore/README b/netsvcs/clients/Naming/Dump_Restore/README
new file mode 100644
index 00000000000..3bb13935d87
--- /dev/null
+++ b/netsvcs/clients/Naming/Dump_Restore/README
@@ -0,0 +1,67 @@
+This file describes the usage of the Dump-Restore utility for the ACE
+Name Server.
+
+Similar to the test application provided in the Client-Server
+directory, a simple ASCII menu-driven interface is provided to the
+user:
+
+ Name Service Main Menu
+ ----------------------
+ *** Using Process Local Database ***
+
+** No Input File Specified **
+<P> Use Process Local Database
+<N> Use Node Local Database
+<H> Set Remote Name server <host> and <port>
+<F> Set Input File <file name>
+
+<B> Bind
+<U> Unbind
+<R> Rebind
+<D> Dump <file name>
+<Q> or ^C (exit)
+
+Initially, the user can select the type of database from the menu:
+
+<P> uses the process local database (i.e., the
+ database is called the same name as the process
+ and stored in /tmp).
+<N> uses the node local database (which defaults
+ to /tmp/localnames).
+<H> uses the net local database by specifying host and port
+ number (by default this is stored in a file called
+ /tmp/globalnames on the server).
+<F> Sets the name of the input file that will be used by the
+ test application to populate the database. The format of
+ the file should be:
+
+ name=<name1>
+ value=<value1>
+ type=[<type1>]
+ name=<name2>
+ value=<value2>
+ type=[<type2>]
+ .
+ .
+ .
+
+ Note that the type field is optional. However, if no type
+ information is associated with a name binding, a null entry still
+ needs to be present (i.e., type=).
+
+Once the input file has been specified, the user can then do one of
+the following:
+
+<B> Bind -- bind all the bindings in the file to the database.
+ This can be used to "restore" the state of the
+ Name Server.
+<U> Unbind -- unbind all the bindings in the file from the database.
+<R> Rebind -- rebind all the bindings in the file to the database.
+<D> Dump <file name> -- dump the state of the database to <filename>.
+<Q> or ^C (exit) -- exit gracefully, saving the contents of the
+ Name Server in persistent shared memory.
+
+Note that the dump file is stored in ASCII with exactly the same
+format as the input file. Also, one can easily change the test
+application so that a call to Dump results in the state of the
+database dumped to standard output instead of a file.
diff --git a/netsvcs/clients/Naming/Dump_Restore/createfile.cpp b/netsvcs/clients/Naming/Dump_Restore/createfile.cpp
new file mode 100644
index 00000000000..4880cfe7883
--- /dev/null
+++ b/netsvcs/clients/Naming/Dump_Restore/createfile.cpp
@@ -0,0 +1,32 @@
+#include <stdio.h>
+// @(#)createfile.cpp 1.1 10/18/96
+
+#include <string.h>
+#include <math.h>
+
+int
+main (int argc, char **argv)
+{
+ FILE *infile, *outfile;
+ char buf[BUFSIZ];
+
+ if ((infile = fopen (argv[1], "r")) == NULL)
+ return -1;
+
+ if ((outfile = fopen (argv[2], "w")) == NULL)
+ return -1;
+
+ int count = 0;
+ while (::fgets (buf, BUFSIZ, infile))
+ {
+ buf[::strlen(buf) - 1] = '\0';
+ fputs (buf, outfile);
+ if (count % 2 == 0)
+ fputs (" ", outfile);
+ else
+ fputs ("\n", outfile);
+ count++;
+ }
+ fclose (outfile);
+ fclose (infile);
+}
diff --git a/netsvcs/clients/Naming/Dump_Restore/main.cpp b/netsvcs/clients/Naming/Dump_Restore/main.cpp
new file mode 100644
index 00000000000..a30b94c6cd3
--- /dev/null
+++ b/netsvcs/clients/Naming/Dump_Restore/main.cpp
@@ -0,0 +1,22 @@
+// Test the client-side of the ACE Name Server...
+// @(#)main.cpp 1.1 10/18/96
+
+#include "ace/Service_Config.h"
+#include "Dump_Restore.h"
+
+int
+main (int argc, char *argv[])
+{
+ ACE_Service_Config daemon (argv[0]);
+
+ ACE_DEBUG ((LM_DEBUG, "entering main\n"));
+
+ // Get a handler
+ Dump_Restore client_handler (argc, argv);
+
+ for (;;)
+ daemon.run_reactor_event_loop ();
+
+ ACE_DEBUG ((LM_DEBUG, "leaving main\n"));
+ return 0;
+}
diff --git a/netsvcs/clients/Naming/Dump_Restore/nametest.cpp b/netsvcs/clients/Naming/Dump_Restore/nametest.cpp
new file mode 100644
index 00000000000..d5347b7206a
--- /dev/null
+++ b/netsvcs/clients/Naming/Dump_Restore/nametest.cpp
@@ -0,0 +1,112 @@
+#include "ace/Naming_Context.h"
+// @(#)nametest.cpp 1.1 10/18/96
+
+#include "ace/Name_Options.h"
+#include "nametest.h"
+
+void
+Nametest::listopt (void)
+{
+ cout << "serverport is "
+ << ACE_Name_Options::instance ()->nameserver_port()
+ << endl;
+ cout << "serverhost is "
+ << ACE_Name_Options::instance ()->nameserver_host()
+ << endl;
+ cout << "process_name is "
+ << ACE_Name_Options::instance ()->process_name()
+ << endl;
+ cout << "namespace_dir is "
+ << ACE_Name_Options::instance ()->namespace_dir()
+ << endl;
+}
+
+int
+Nametest::init (int argc, char *argv[])
+{
+ ACE_Server_Record *sr;
+ ACE_Service_Config::svc_rep ()->find ("Name_Server_Proxy", &sr);
+ ACE_Service_Type *st = sr->type ();
+ ACE_Server_Object *so = st->object ();
+dynamic_cast<ACE_Name_Server_Proxy *> (so);
+
+ ACE_Name_Server_Proxy *ns_proxy = ACE_Service_Config::name_server_proxy ();
+
+ ns_proxy->bind (...);
+
+ this->listopt ();
+
+ ACE_Naming_Context ns_context;
+
+ if (ns_context.open (ACE_Naming_Context::NET_LOCAL) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "ns_context.open"), -1);
+
+ const char *mykey = argv[0];
+ char *myvalue = argv[1];
+ char *ns_value = 0;
+ char *ns_type = 0;
+
+ if (ns_context.bind (mykey, myvalue, "ottotype") == -1)
+ cout << "bind failed" << endl;
+ else
+ cout << "bind succeeded" << endl;
+
+
+ if (ns_context.resolve (mykey, ns_value, ns_type) == -1)
+ cout << "resolve of " << mykey << " failed" << endl;
+ else
+ cout << "resolve of " << mykey << " succeeded, value = "
+ << ns_value << ", type = " << ns_type << endl;
+
+ delete [] ns_value;
+ delete [] ns_type;
+ ns_value = 0;
+ ns_type = 0;
+
+ if (ns_context.rebind (mykey, myvalue, "newottotype") == -1)
+ cout << "rebind failed" << endl;
+ else
+ cout << "rebind succeeded" << endl;
+
+ if (ns_context.resolve (mykey, ns_value, ns_type) == -1)
+ cout << "resolve of " << mykey << " failed" << endl;
+ else
+ cout << "resolve of " << mykey << " succeeded, value = "
+ << ns_value << ", type = " << ns_type << endl;
+
+ delete [] ns_value;
+ delete [] ns_type;
+ ns_value = 0;
+ ns_type = 0;
+
+ if (ns_context.unbind (mykey) == -1)
+ cout << "unbind failed" << endl;
+ else
+ cout << "unbind succeeded" << endl;
+
+ return 0;
+}
+
+int
+Nametest::fini (void)
+{
+ cout << "Nametest::fini called" << endl;
+ return 0;
+}
+
+int
+Nametest::info (char **, unsigned) const
+{
+ cout << "Nametest::info called" << endl;
+ return 0;
+}
+
+extern "C" ACE_Service_Object *_alloc(void);
+
+// Factory function that is called automatically when the ACE
+// framework dynamically links this shared object file.
+
+ACE_Service_Object *_alloc (void)
+{
+ return new Nametest;
+}
diff --git a/netsvcs/clients/Naming/Dump_Restore/nametest.h b/netsvcs/clients/Naming/Dump_Restore/nametest.h
new file mode 100644
index 00000000000..423f2ea1a5c
--- /dev/null
+++ b/netsvcs/clients/Naming/Dump_Restore/nametest.h
@@ -0,0 +1,15 @@
+/* -*- C++ -*- */
+// @(#)nametest.h 1.1 10/18/96
+
+#include "ace/Service_Object.h"
+
+class Nametest : public ACE_Service_Object
+{
+public:
+ virtual int init (int argc, char *argv[]);
+ virtual int fini (void);
+ virtual int info (char **, size_t) const;
+
+ void listopt (void);
+};
+