diff options
Diffstat (limited to 'netsvcs/clients/Naming/Dump_Restore')
-rw-r--r-- | netsvcs/clients/Naming/Dump_Restore/Dump_Restore.cpp | 467 | ||||
-rw-r--r-- | netsvcs/clients/Naming/Dump_Restore/Dump_Restore.h | 86 | ||||
-rw-r--r-- | netsvcs/clients/Naming/Dump_Restore/Dump_Restore.mpc | 21 | ||||
-rw-r--r-- | netsvcs/clients/Naming/Dump_Restore/Makefile.am | 51 | ||||
-rw-r--r-- | netsvcs/clients/Naming/Dump_Restore/README | 66 | ||||
-rw-r--r-- | netsvcs/clients/Naming/Dump_Restore/createfile.cpp | 34 | ||||
-rw-r--r-- | netsvcs/clients/Naming/Dump_Restore/main.cpp | 26 |
7 files changed, 0 insertions, 751 deletions
diff --git a/netsvcs/clients/Naming/Dump_Restore/Dump_Restore.cpp b/netsvcs/clients/Naming/Dump_Restore/Dump_Restore.cpp deleted file mode 100644 index bfda59cd09f..00000000000 --- a/netsvcs/clients/Naming/Dump_Restore/Dump_Restore.cpp +++ /dev/null @@ -1,467 +0,0 @@ -// $Id$ - -#include "ace/Malloc_Base.h" -#include "ace/Service_Config.h" -#include "ace/Read_Buffer.h" -#include "ace/Thread_Manager.h" - -// FUZZ: disable check_for_streams_include -#include "ace/streams.h" /* Because dump () uses ofstream. */ - -#include "Dump_Restore.h" -#include "ace/OS_NS_signal.h" -#include "ace/OS_NS_stdio.h" -#include "ace/OS_NS_string.h" -#include "ace/OS_NS_unistd.h" - -ACE_RCSID(Dump_Restore, Dump_Restore, "$Id$") - -Dump_Restore::Dump_Restore (int argc, ACE_TCHAR *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 (), - ACE_TEXT ("localhost")) == 0) - { - if (ns_context_->open (ACE_Naming_Context::PROC_LOCAL) == -1) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("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, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ns_context_->open"))); - } - - this->display_menu (); - - if (ACE_Event_Handler::register_stdin_handler (this, - ACE_Reactor::instance (), - ACE_Thread_Manager::instance ()) == -1) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("register_stdin_handler"))); -} - -Dump_Restore::~Dump_Restore (void) -{ - // Deregister this handler with the ACE_Reactor. - ACE_Reactor::instance ()->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]; - u_short port; - - if (::scanf ("%s", option) <= 0) - { - ACE_DEBUG ((LM_ERROR, - ACE_TEXT ("try again\n"))); - return 0; - } - - switch (option[0]) - { - case 'P' : - case 'p' : - set_proc_local (); - break; - case 'N' : - case 'n' : - set_node_local (); - break; - case 'H' : - case 'h' : - if (::scanf ("%s %hu", buf1, &port) <= 0) - break; - set_host (ACE_TEXT_CHAR_TO_TCHAR (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' : - populate (Dump_Restore::BIND); - break; - case 'U' : - case 'u' : - populate (Dump_Restore::UNBIND); - break; - case 'R' : - case 'r' : - populate (Dump_Restore::REBIND); - break; - case 'D': - case 'd': - if (::scanf ("%s", dump_filename_) <= 0) - break; - this->dump (); - break; - case 'Q' : - case 'q' : - quit (); - break; - default : - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Unrecognized command.\n"))); - } - - display_menu (); - return 0; -} - -void -Dump_Restore::display_menu (void) -{ - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("\n"))); - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("Name Service Main Menu\n"))); - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("----------------------\n"))); - - // Check if using local name space or remote name space - if (ACE_OS::strcmp (this->name_options_->nameserver_host (), - ACE_TEXT ("localhost")) == 0) - { - if (this->ns_scope_ == ACE_Naming_Context::PROC_LOCAL) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT (" *** Using Process Local Database ***\n\n"))); - else - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT (" *** Using Node Local Database ***\n\n"))); - } - else - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT (" Hostname: %s\n"), - this->hostname_)); - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT (" Port Number: %d\n"), - this->port_)); - } - - if (this->infile_) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("Input File: %C\n"), - this->filename_)); - else - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("** No Input File Specified **\n"))); - - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("<P> Use Process Local Database\n"))); - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("<N> Use Node Local Database\n"))); - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("<H> Set Remote Name server <host> and <port>\n"))); - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("<F> Set Input File <file name>\n"))); - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("<B> Bind\n"))); - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("<U> Unbind\n"))); - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("<R> Rebind\n"))); - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("<D> Dump <file name>\n"))); - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("<Q> or ^C (exit) \n"))); -} - - -int -Dump_Restore::set_proc_local (void) -{ - // Set Name Options - this->name_options_->nameserver_host (ACE_TEXT ("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, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ns_context_->open")), - -1); - - return 0; -} - -int -Dump_Restore::set_node_local (void) -{ - // Set Name Options - this->name_options_->nameserver_host (ACE_TEXT ("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, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ns_context_->open")), - -1); - return 0; -} - -int -Dump_Restore::set_host (const ACE_TCHAR *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, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ns_context_->open")), - -1); - return 0; -} - -int -Dump_Restore::doit (Dump_Restore::Operation_Type op, - const char *name, - const char *value, - const 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_Allocator::instance (); - ACE_Read_Buffer read_buffer (this->infile_, - 0, - allocator); - - for (char *temp; - (temp = read_buffer.read ('\n')) != 0; - ) - { - char *name = 0; - const char *actual_name = 0; - char *value = 0; - const char *actual_value = 0; - char *type = 0; - const 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, - ACE_TEXT ("%p\n"), - ACE_TEXT ("populate")), - -1); - /* NOTREACHED */ - } - } - - return result; - } - else - return -1; -} - -int -Dump_Restore::bind (const char *key, - const char *value, - const char *type) -{ - int result = ns_context_->bind (key, - value, - type); - if (result == -1) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ns_context_->bind")), - -1); - else if (result == 1) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("%s%s%s\n"), - ACE_TEXT ("key <"), - key, - ACE_TEXT ("> already bound")), - 1); - return 0; -} - -int -Dump_Restore::unbind (const char *key) -{ - int result = ns_context_->unbind (key); - - if (result == -1) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("ns_context_->unbind")), - -1); - return 0; -} - -int -Dump_Restore::rebind (const char *key, - const char *value, - const char *type) -{ - if (ns_context_->rebind (key, - value, - type) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("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 deleted file mode 100644 index 1cdd2113f8e..00000000000 --- a/netsvcs/clients/Naming/Dump_Restore/Dump_Restore.h +++ /dev/null @@ -1,86 +0,0 @@ -// -*- C++ -*- -// -// $Id$ - -#include "ace/Event_Handler.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Reactor.h" -#include "ace/Naming_Context.h" -#include "ace/svc_export.h" - -class ACE_Svc_Export Dump_Restore : public ACE_Event_Handler -{ -public: - enum Operation_Type - { - BIND, - UNBIND, - REBIND - }; - Dump_Restore (int argc, ACE_TCHAR *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: - ACE_TCHAR 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 (const ACE_TCHAR *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, - const char *name, - const char *value, - const char *type = ""); - int bind (const char *key, - const char *value, - const char *type = ""); - int unbind (const char *key); - int rebind (const char *key, - const char *value, - const char *type = ""); - - char filename_[MAXPATHLEN + 1]; - char dump_filename_[MAXPATHLEN + 1]; - - 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/Dump_Restore.mpc b/netsvcs/clients/Naming/Dump_Restore/Dump_Restore.mpc deleted file mode 100644 index c88bb05e2e2..00000000000 --- a/netsvcs/clients/Naming/Dump_Restore/Dump_Restore.mpc +++ /dev/null @@ -1,21 +0,0 @@ -// -*- MPC -*- -// $Id$ - -project(Netsvcs_Dump_Restore_Lib): acelib { - avoids += ace_for_tao - sharedname = Dump_Restore - dynamicflags += ACE_BUILD_SVC_DLL - Source_Files { - Dump_Restore.cpp - } -} - -project(Netsvcs_Dump_Restore) : aceexe { - avoids += ace_for_tao - exename = main - libs += Dump_Restore - after += Netsvcs_Dump_Restore_Lib - Source_Files { - main.cpp - } -} diff --git a/netsvcs/clients/Naming/Dump_Restore/Makefile.am b/netsvcs/clients/Naming/Dump_Restore/Makefile.am deleted file mode 100644 index 51e678fdac5..00000000000 --- a/netsvcs/clients/Naming/Dump_Restore/Makefile.am +++ /dev/null @@ -1,51 +0,0 @@ -## Process this file with automake to create Makefile.in -## -## $Id$ -## -## This file was generated by MPC. Any changes made directly to -## this file will be lost the next time it is generated. -## -## MPC Command: -## /acebuilds/ACE_wrappers-repository/bin/mwc.pl -include /acebuilds/MPC/config -include /acebuilds/MPC/templates -feature_file /acebuilds/ACE_wrappers-repository/local.features -noreldefs -type automake -exclude build,Kokyu - -ACE_BUILDDIR = $(top_builddir) -ACE_ROOT = $(top_srcdir) - -## Makefile.Netsvcs_Dump_Restore_Lib.am -noinst_LTLIBRARIES = libDump_Restore.la - -libDump_Restore_la_CPPFLAGS = \ - -I$(ACE_ROOT) \ - -I$(ACE_BUILDDIR) \ - -DACE_BUILD_SVC_DLL - -libDump_Restore_la_SOURCES = \ - Dump_Restore.cpp - -libDump_Restore_la_LIBADD = \ - $(top_builddir)/ace/libACE.la - -noinst_HEADERS = \ - Dump_Restore.h - -## Makefile.Netsvcs_Dump_Restore.am -noinst_PROGRAMS = main - -main_CPPFLAGS = \ - -I$(ACE_ROOT) \ - -I$(ACE_BUILDDIR) - -main_SOURCES = \ - main.cpp \ - Dump_Restore.h - -main_LDADD = \ - libDump_Restore.la $(top_builddir)/ace/libACE.la - -## Clean up template repositories, etc. -clean-local: - -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.* - -rm -f gcctemp.c gcctemp so_locations *.ics - -rm -rf cxx_repository ptrepository ti_files - -rm -rf templateregistry ir.out - -rm -rf ptrepository SunWS_cache Templates.DB diff --git a/netsvcs/clients/Naming/Dump_Restore/README b/netsvcs/clients/Naming/Dump_Restore/README deleted file mode 100644 index 25b1243d03f..00000000000 --- a/netsvcs/clients/Naming/Dump_Restore/README +++ /dev/null @@ -1,66 +0,0 @@ -This file describes the usage of the Dump-Restore utility for the ACE -Name Server. - -Similar to the test application provided in the ../Client/ 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 deleted file mode 100644 index 25bf2fb803c..00000000000 --- a/netsvcs/clients/Naming/Dump_Restore/createfile.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// $Id$ - -#include <stdio.h> -#include <string.h> -#include "ace/ACE.h" - -ACE_RCSID(Dump_Restore, createfile, "$Id$") - -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 deleted file mode 100644 index 46d298357bc..00000000000 --- a/netsvcs/clients/Naming/Dump_Restore/main.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// $Id$ - -// Test the client-side of the ACE Name Server... - -#include "ace/Service_Config.h" -#include "ace/Log_Msg.h" -#include "Dump_Restore.h" - -ACE_RCSID(Dump_Restore, main, "$Id$") - -int -ACE_TMAIN (int argc, ACE_TCHAR *argv[]) -{ - ACE_Service_Config daemon (argv[0]); - - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("entering main\n"))); - - // Get a handler - Dump_Restore client_handler (argc, argv); - - ACE_Reactor::run_event_loop (); - - /* NOTREACHED */ - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("leaving main\n"))); - return 0; -} |