diff options
author | brunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-04-21 23:51:43 +0000 |
---|---|---|
committer | brunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-04-21 23:51:43 +0000 |
commit | 409b839bc14361b8b5cad747de7f046a1982b0ee (patch) | |
tree | 05973aca29c5211f30d4c2d5fb6cbe2840b2edb6 | |
parent | 3c3906b7716107183e0e6d3c599989f63e3c6378 (diff) | |
download | ATCD-409b839bc14361b8b5cad747de7f046a1982b0ee.tar.gz |
Added help information to tao_ir and removed the environment.
-rw-r--r-- | TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.cpp | 6 | ||||
-rw-r--r-- | TAO/orbsvcs/ImplRepo_Service/Options.cpp | 2 | ||||
-rw-r--r-- | TAO/orbsvcs/ImplRepo_Service/Repository.cpp | 23 | ||||
-rw-r--r-- | TAO/orbsvcs/ImplRepo_Service/Repository.h | 3 | ||||
-rw-r--r-- | TAO/orbsvcs/ImplRepo_Service/tao_ir_i.cpp | 126 | ||||
-rw-r--r-- | TAO/orbsvcs/ImplRepo_Service/tao_ir_i.h | 8 |
6 files changed, 121 insertions, 47 deletions
diff --git a/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.cpp b/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.cpp index ac2f643d464..cab9384de6c 100644 --- a/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.cpp @@ -228,7 +228,6 @@ ImplRepo_i::register_server (const char *server, options.working_directory_.in ())); Repository_Record rec (options.command_line_, - options.environment_, options.working_directory_, "", 0, @@ -252,11 +251,9 @@ ImplRepo_i::register_server (const char *server, if (OPTIONS::instance()->debug () >= 2) ACE_DEBUG ((LM_DEBUG, "Server: %s\n" "Command Line: %s\n" - "Environment: %s\n" "Working Directory: %s\n\n", server, rec.comm_line, - rec.env, rec.wdir)); } } @@ -271,7 +268,6 @@ ImplRepo_i::reregister_server (const char *server, { ACE_UNUSED_ARG (ACE_TRY_ENV); Repository_Record rec (options.command_line_, - options.environment_, options.working_directory_, "", 0, @@ -286,11 +282,9 @@ ImplRepo_i::reregister_server (const char *server, if (OPTIONS::instance()->debug () >= 2) ACE_DEBUG ((LM_DEBUG, "Server: %s\n" "Command Line: %s\n" - "Environment: %s\n" "Working Directory: %s\n\n", server, rec.comm_line, - rec.env, rec.wdir)); } diff --git a/TAO/orbsvcs/ImplRepo_Service/Options.cpp b/TAO/orbsvcs/ImplRepo_Service/Options.cpp index 146f6cff0ed..ad0cb268112 100644 --- a/TAO/orbsvcs/ImplRepo_Service/Options.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/Options.cpp @@ -29,7 +29,7 @@ Options::parse_args (int argc, ASYS_TCHAR *argv[]) "Error: Unable to open %s for writing: %p\n", get_opts.optarg), -1); break; - case '?': // display help for use of the server.*/ + case '?': // display help for use of the server. default: ACE_ERROR_RETURN ((LM_ERROR, "Usage: %s" diff --git a/TAO/orbsvcs/ImplRepo_Service/Repository.cpp b/TAO/orbsvcs/ImplRepo_Service/Repository.cpp index 4f6d2303a82..25fa333406a 100644 --- a/TAO/orbsvcs/ImplRepo_Service/Repository.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/Repository.cpp @@ -8,7 +8,6 @@ ACE_RCSID(ImplRepo_Service, Repository, "$Id$") Repository_Record::Repository_Record () : comm_line (ACE::strnew ("")), - env (ACE::strnew ("")), wdir (ACE::strnew ("")), host (ACE::strnew ("")), port (0), @@ -19,7 +18,6 @@ Repository_Record::Repository_Record () Repository_Record::Repository_Record (const Repository_Record &r) : comm_line (ACE::strnew (r.comm_line)), - env (ACE::strnew (r.env)), wdir (ACE::strnew (r.wdir)), host (ACE::strnew (r.host)), port (r.port), @@ -29,13 +27,11 @@ Repository_Record::Repository_Record (const Repository_Record &r) } Repository_Record::Repository_Record (const ASYS_TCHAR *c, - const ASYS_TCHAR *e, const ASYS_TCHAR *w, const ASYS_TCHAR *h, const unsigned short p, const ASYS_TCHAR *pi) : comm_line (ACE::strnew (c)), - env (ACE::strnew (e)), wdir (ACE::strnew (w)), host (ACE::strnew (h)), port (p), @@ -46,7 +42,6 @@ Repository_Record::Repository_Record (const ASYS_TCHAR *c, Repository_Record::~Repository_Record () { delete [] this->comm_line; - delete [] this->env; delete [] this->wdir; delete [] this->host; delete [] this->ping_ior; @@ -59,13 +54,11 @@ Repository_Record::operator= (Repository_Record &r) return *this; delete [] this->comm_line; - delete [] this->env; delete [] this->wdir; delete [] this->host; delete [] this->ping_ior; this->comm_line = ACE::strnew (r.comm_line); - this->env = ACE::strnew (r.env); this->wdir = ACE::strnew (r.wdir); this->host = ACE::strnew (r.host); this->port = r.port; @@ -153,22 +146,6 @@ Repository::get_comm_line (ACE_TString key, ASYS_TCHAR *&comm_line) return retval; } - -int -Repository::get_env (ACE_TString key, ASYS_TCHAR *&env) -{ - Repository_Record *rec; - int retval = this->repository_.find (key, rec); - - if (retval == 0) - { - ACE_NEW_RETURN (env, ASYS_TCHAR [ACE_OS::strlen (rec->env) + 1], -1); - ACE_OS::strcpy (env, rec->env); - } - - return retval; -} - int Repository::get_wdir (ACE_TString key, ASYS_TCHAR *&wdir) { diff --git a/TAO/orbsvcs/ImplRepo_Service/Repository.h b/TAO/orbsvcs/ImplRepo_Service/Repository.h index a1c4a23798f..8c68b7d8e46 100644 --- a/TAO/orbsvcs/ImplRepo_Service/Repository.h +++ b/TAO/orbsvcs/ImplRepo_Service/Repository.h @@ -35,7 +35,6 @@ struct Repository_Record Repository_Record (); Repository_Record (const Repository_Record &); Repository_Record (const ASYS_TCHAR *c, - const ASYS_TCHAR *e, const ASYS_TCHAR *w, const ASYS_TCHAR *h, const unsigned short p, @@ -50,7 +49,6 @@ struct Repository_Record // Fields ASYS_TCHAR *comm_line; - ASYS_TCHAR *env; ASYS_TCHAR *wdir; ASYS_TCHAR *host; unsigned short port; @@ -92,7 +90,6 @@ public: // = Accessor methods int get_comm_line (ACE_TString key, ASYS_TCHAR *&comm_line); - int get_env (ACE_TString key, ASYS_TCHAR *&env); int get_wdir (ACE_TString key, ASYS_TCHAR *&wdir); int get_ping_ior (ACE_TString key, ASYS_TCHAR *&ping_ior); int get_hostport (ACE_TString key, ASYS_TCHAR *&host, unsigned short &port); diff --git a/TAO/orbsvcs/ImplRepo_Service/tao_ir_i.cpp b/TAO/orbsvcs/ImplRepo_Service/tao_ir_i.cpp index f606ca7ffbf..26de6f13104 100644 --- a/TAO/orbsvcs/ImplRepo_Service/tao_ir_i.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/tao_ir_i.cpp @@ -58,38 +58,136 @@ TAO_IR_i::init (int argc, char **argv) return 0; } + +// Go through and figure out which operation we should do. + int TAO_IR_i::parse_args (void) { if (this->argc_ < 2) { - ACE_ERROR ((LM_ERROR, - "Usage: %s [options] command [command-arguments]\n", - this->argv[0])); - ACE_ERROR ((LM_ERROR, " where [options] are ORB options\n")); - ACE_ERROR ((LM_ERROR, " where command is:\n")); - ACE_ERROR ((LM_ERROR, " add - Add an entry to the IR\n")); - ACE_ERROR ((LM_ERROR, " remove - Remove an entry from the IR\n")); - ACE_ERROR ((LM_ERROR, " update - Update an entry in the IR\n")); - ACE_ERROR ((LM_ERROR, " list - List the entries in the IR\n")); - ACE_ERROR ((LM_ERROR, " where [command-arguments] depend on the command\n")); + this->print_usage (ALL); return -1; } - if (ACE_OS::stricmp (this->argv[1], ASYS_TEXT ("add"))) + if (ACE_OS::strcasecmp (this->argv_[1], ASYS_TEXT ("add")) == 0) { + if (this->argc_ < 3) + { + this->print_usage (ADD); + return -1; + } + + return this->parse_add_args (); } - else if (ACE_OS::stricmp (this->argv[1], ASYS_TEXT ("remove"))) + else if (ACE_OS::strcasecmp (this->argv_[1], ASYS_TEXT ("remove")) == 0) { + if (this->argc_ < 3) + { + this->print_usage (REMOVE); + return -1; + } } - else if (ACE_OS::stricmp (this->argv[1], ASYS_TEXT ("update"))) + else if (ACE_OS::strcasecmp (this->argv_[1], ASYS_TEXT ("update")) == 0) { + if (this->argc_ < 3) + { + this->print_usage (UPDATE); + return -1; + } } - else if (ACE_OS::stricmp (this->argv[1], ASYS_TEXT ("list"))) + else if (ACE_OS::strcasecmp (this->argv_[1], ASYS_TEXT ("list")) == 0) { + if (this->argc_ > 2) + { + ACE_ERROR ((LM_ERROR, "Unrecognized options\n")); + this->print_usage (LIST); + return -1; + } } // Indicates successful parsing of command line. return 0; } + +// Look at the arguments assuming that it is an add command. +int +TAO_IR_i::parse_add_args () +{ + // Skip both the program name and the "add" command + ACE_Get_Opt get_opts (this->argc_ - 2, this->argv_ + 2, "hc:w:"); + + ACE_DEBUG ((LM_DEBUG, "Server name: %s\n", this->argv_[2])); + + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'c': // Command line arguments + ACE_DEBUG ((LM_DEBUG, "Command line argument: %s\n", get_opts.optarg)); + break; + case 'w': // Working Directory + ACE_DEBUG ((LM_DEBUG, "Working directory: %s\n", get_opts.optarg)); + break; + case 'h': // display help + default: + this->print_usage (ADD); + return -1; + } + + // Success + return 0; +} + +// Print out information about an operation. + +void +TAO_IR_i::print_usage (Operation op) +{ + switch (op) + { + case ADD: + ACE_ERROR ((LM_ERROR, "Usage: tao_ir [options] add <name> [command-arguments]\n")); + ACE_ERROR ((LM_ERROR, " where [options] are ORB options\n")); + ACE_ERROR ((LM_ERROR, " where <name> is the POA name used by the server object\n")); + ACE_ERROR ((LM_ERROR, " where [command-arguments] can be\n")); + ACE_ERROR ((LM_ERROR, " -h Displays this\n")); + ACE_ERROR ((LM_ERROR, " -c command Startup command\n")); + ACE_ERROR ((LM_ERROR, " -w dir Working directory\n")); + break; + case REMOVE: + ACE_ERROR ((LM_ERROR, "Usage: tao_ir [options] remove <name> [command-arguments]\n")); + ACE_ERROR ((LM_ERROR, " where [options] are ORB options\n")); + ACE_ERROR ((LM_ERROR, " where <name> is the POA name used by the server object\n")); + ACE_ERROR ((LM_ERROR, " where [command-arguments] can be\n")); + ACE_ERROR ((LM_ERROR, " -h Displays this\n")); + break; + case UPDATE: + ACE_ERROR ((LM_ERROR, "Usage: tao_ir [options] update <name> [command-arguments]\n")); + ACE_ERROR ((LM_ERROR, " where [options] are ORB options\n")); + ACE_ERROR ((LM_ERROR, " where <name> is the POA name used by the server object\n")); + ACE_ERROR ((LM_ERROR, " where [command-arguments] can be\n")); + ACE_ERROR ((LM_ERROR, " -h Displays this\n")); + ACE_ERROR ((LM_ERROR, " -c command Startup command\n")); + ACE_ERROR ((LM_ERROR, " -w dir Working directory\n")); + break; + case LIST: + ACE_ERROR ((LM_ERROR, "Usage: tao_ir [options] list [command-arguments]\n")); + ACE_ERROR ((LM_ERROR, " where [options] are ORB options\n")); + ACE_ERROR ((LM_ERROR, " where [command-arguments] can be\n")); + ACE_ERROR ((LM_ERROR, " -h Displays this\n")); + break; + default: + ACE_ERROR ((LM_ERROR, "Usage: tao_ir [options] command [command-arguments]\n")); + ACE_ERROR ((LM_ERROR, " where [options] are ORB options\n")); + ACE_ERROR ((LM_ERROR, " where command is one of the following:\n")); + ACE_ERROR ((LM_ERROR, " add Add an entry to the IR\n")); + ACE_ERROR ((LM_ERROR, " remove Remove an entry from the IR\n")); + ACE_ERROR ((LM_ERROR, " update Update an entry in the IR\n")); + ACE_ERROR ((LM_ERROR, " list List the entries in the IR\n")); + ACE_ERROR ((LM_ERROR, " where [command-arguments] depend on the command\n")); + break; + } +} diff --git a/TAO/orbsvcs/ImplRepo_Service/tao_ir_i.h b/TAO/orbsvcs/ImplRepo_Service/tao_ir_i.h index bca219b2ed7..eb90ca5e06a 100644 --- a/TAO/orbsvcs/ImplRepo_Service/tao_ir_i.h +++ b/TAO/orbsvcs/ImplRepo_Service/tao_ir_i.h @@ -42,12 +42,20 @@ public: // Initialize the client communication endpoint with server. private: + enum Operation {ALL, ADD, REMOVE, UPDATE, LIST}; + + void print_usage (Operation op); + // Print out information about an operation. + int read_ior (char *filename); // Function to read the server ior from a file. int parse_args (void); // Parses the arguments passed on the command line. + int parse_add_args (void); + // Parses arguments specific to the ADD command. + int argc_; // # of arguments on the command line. |