summaryrefslogtreecommitdiff
path: root/CIAO/DAnCE/RepositoryManager/repository_manager_admin_exec.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'CIAO/DAnCE/RepositoryManager/repository_manager_admin_exec.cpp')
-rw-r--r--CIAO/DAnCE/RepositoryManager/repository_manager_admin_exec.cpp150
1 files changed, 75 insertions, 75 deletions
diff --git a/CIAO/DAnCE/RepositoryManager/repository_manager_admin_exec.cpp b/CIAO/DAnCE/RepositoryManager/repository_manager_admin_exec.cpp
index 9250fec268d..4a9bc440e4e 100644
--- a/CIAO/DAnCE/RepositoryManager/repository_manager_admin_exec.cpp
+++ b/CIAO/DAnCE/RepositoryManager/repository_manager_admin_exec.cpp
@@ -3,7 +3,7 @@
/**
* @file repository_manager_admin_exec.cpp
* @author William R. Otte <wotte@dre.vanderbilt.edu>
- *
+ *
* Simple administration program for the Repository Manager.
*/
@@ -26,20 +26,20 @@ struct Options
shutdown_ (false)
{
}
-
+
struct Installation
{
Installation (void)
{
}
-
+
bool init (const ACE_TCHAR *inst)
{
ACE_CString tmp (inst);
-
+
size_t begin = 0;
size_t pos = tmp.find (',', begin);
-
+
if (pos != ACE_CString::npos)
path_ = tmp.substring (begin, pos - begin);
else
@@ -49,23 +49,23 @@ struct Options
"must have form path,name,replace\n"));
return false;
}
-
-
+
+
begin = pos + 1;
pos = tmp.find (',', begin);
-
+
if (pos != ACE_CString::npos)
name_ = tmp.substring (begin, pos - begin);
- else
+ else
{
DANCE_ERROR ((LM_ERROR, DLINFO "Options::Installation::init - "
"Installation directive mssing replace parameter, "
"must have form path,name,replace\n"));
return false;
}
-
+
begin = pos + 1;
-
+
if (tmp[begin] == '0') replace_ = false;
else if (tmp[begin] == '1') replace_ = true;
else
@@ -74,34 +74,34 @@ struct Options
"Replace directive muse be 1 or 0.\n"));
return false;
}
-
+
return true;
}
-
+
bool operator== (const Installation &rhs) const
{
return (replace_ == rhs.replace_) &&
(path_ == rhs.path_) &&
(name_ == rhs.name_);
}
-
+
ACE_CString path_, name_;
bool replace_;
};
-
+
struct Creation
{
Creation (void)
{
}
-
+
bool init (const ACE_TCHAR *inst)
{
ACE_CString tmp (inst);
-
+
size_t begin = 0;
size_t pos = tmp.find (',', begin);
-
+
if (pos != ACE_CString::npos)
path_ = tmp.substring (begin, pos - begin);
else
@@ -111,36 +111,36 @@ struct Options
"must have form path,name,base,replace\n"));
return false;
}
-
-
+
+
begin = pos + 1;
pos = tmp.find (',', begin);
-
+
if (pos != ACE_CString::npos)
name_ = tmp.substring (begin, pos - begin);
- else
+ else
{
DANCE_ERROR ((LM_ERROR, DLINFO "Options::Creation::init - "
"Creation directive mssing base location and replace parameter, "
"must have form path,name,base,replace\n"));
return false;
}
-
+
begin = pos + 1;
pos = tmp.find (',', begin);
-
+
if (pos != ACE_CString::npos)
base_location_ = tmp.substring (begin, pos - begin);
- else
+ else
{
DANCE_ERROR ((LM_ERROR, DLINFO "Options::Creation::init - "
"Creation directive mssing replace parameter, "
"must have form path,name,base,replace\n"));
return false;
}
-
+
begin = pos + 1;
-
+
if (tmp[begin] == '0') replace_ = false;
else if (tmp[begin] == '1') replace_ = true;
else
@@ -149,17 +149,17 @@ struct Options
"Replace directive muse be 1 or 0.\n"));
return false;
}
-
+
return true;
}
-
+
bool operator== (const Creation &rhs) const
{
return (replace_ == rhs.replace_) &&
(path_ == rhs.path_) &&
(name_ == rhs.name_);
}
-
+
ACE_CString path_, name_, base_location_;
bool replace_;
};
@@ -171,8 +171,8 @@ struct Options
ACE_Unbounded_Set< ACE_CString > uninstall_;
bool list_;
bool shutdown_;
-
- void usage (void)
+
+ void usage (void)
{
DANCE_ERROR ((LM_EMERGENCY, "usage:\n"
"\t-h,--help\t\t\tThis message.\n"
@@ -185,19 +185,19 @@ struct Options
"\t-l,--list\t\t\tList all packages installed in the RM\n"
"\t-s,--shutdown\t\t\tShutdown the RM.\n"
"\t-d,--domain-nc <ior>\t\tProvide a reference to the domain naming context\n"
-
+
"\n\n\tArguments with a * may be specified multiple times.\n"));
}
-
-
+
+
int parse_args (int argc, ACE_TCHAR *argv[])
{
ACE_Get_Opt get_opt (argc, argv,
ACE_TEXT ("hr:i:c:u:lsd:"),
- 0, 0,
+ 0, 0,
ACE_Get_Opt::RETURN_IN_ORDER,
1);
-
+
get_opt.long_option (ACE_TEXT("help"), 'h', ACE_Get_Opt::NO_ARG);
get_opt.long_option (ACE_TEXT("rm-ior"), 'r', ACE_Get_Opt::ARG_REQUIRED);
get_opt.long_option (ACE_TEXT("install"), 'i', ACE_Get_Opt::ARG_REQUIRED);
@@ -206,11 +206,11 @@ struct Options
get_opt.long_option (ACE_TEXT("list"), 'l', ACE_Get_Opt::NO_ARG);
get_opt.long_option (ACE_TEXT("shutdown"), 's', ACE_Get_Opt::NO_ARG);
get_opt.long_option (ACE_TEXT("domain-nc"), 'd', ACE_Get_Opt::ARG_REQUIRED);
-
- char c;
+
+ int c;
Installation inst;
Creation create;
-
+
while ((c = get_opt ()) != -1)
{
switch (c)
@@ -219,21 +219,21 @@ struct Options
this->usage ();
return 1;
break;
-
+
case 'r':
DANCE_DEBUG ((LM_DEBUG, DLINFO "Options::parse_args - "
"Using provided RM IOR: %C\n",
get_opt.opt_arg ()));
rm_ior_ = get_opt.opt_arg ();
break;
-
+
case 'i':
if (!inst.init (get_opt.opt_arg ()))
{
this->usage ();
return -1;
}
-
+
if (inst.replace_)
DANCE_DEBUG ((LM_DEBUG, DLINFO "Options::parse_args - "
"Replacing installed package from path %C with name %C.\n", inst.path_.c_str (),
@@ -242,7 +242,7 @@ struct Options
DANCE_DEBUG ((LM_DEBUG, DLINFO "Options::parse_args - "
"Installing package from path %C with name %C.\n", inst.path_.c_str (),
inst.name_.c_str ()));
-
+
this->install_.insert (inst);
break;
@@ -252,23 +252,23 @@ struct Options
this->usage ();
return -1;
}
-
+
if (create.replace_)
DANCE_DEBUG ((LM_DEBUG, DLINFO "Options::parse_args - "
- "Replacing installed package from path %C with name %C and base location %C.\n",
+ "Replacing installed package from path %C with name %C and base location %C.\n",
create.path_.c_str (),
create.name_.c_str (),
create.base_location_.c_str ()));
else
DANCE_DEBUG ((LM_DEBUG, DLINFO "Options::parse_args - "
- "Installing new package from path %C with name %C and base location %C.\n",
+ "Installing new package from path %C with name %C and base location %C.\n",
create.path_.c_str (),
create.name_.c_str (),
create.base_location_.c_str ()));
-
+
this->create_.insert (create);
break;
-
+
case 'u':
DANCE_DEBUG ((LM_DEBUG, DLINFO "Options::parse_args - "
"Removing package with UUID %C\n", get_opt.opt_arg ()));
@@ -286,7 +286,7 @@ struct Options
"Shutting down the RM instance.\n"));
this->shutdown_ = true;
break;
-
+
case 'd':
DANCE_DEBUG ((LM_DEBUG, DLINFO "Options::parse_args - "
"Using provided Domain NC: %C\n",
@@ -297,7 +297,7 @@ struct Options
if (ACE_OS::strcmp (get_opt.long_option (), ACE_TEXT ("domain-nc")) == 0)
{
}
- else
+ else
{
DANCE_ERROR ((LM_ERROR, DLINFO "Options::parse_args - "
"Unknown long option: %C\n",
@@ -314,31 +314,31 @@ struct Options
int ACE_TMAIN (int argc, ACE_TCHAR **argv)
{
DANCE_DISABLE_TRACE ();
-
+
auto_ptr<DAnCE::Logger_Service> logger;
-
+
int retval (0);
try
{
DAnCE::Logger_Service
- * dlf = ACE_Dynamic_Service<DAnCE::Logger_Service>::instance ("DAnCE_Logger_Backend_Factory");
-
+ * dlf = ACE_Dynamic_Service<DAnCE::Logger_Service>::instance ("DAnCE_Logger_Backend_Factory");
+
if (!dlf)
{
dlf = new DAnCE::Logger_Service;
logger.reset (dlf);
}
-
+
dlf->init (argc, argv);
DANCE_DEBUG ((LM_TRACE, DLINFO
"Module_main.h - initializing ORB\n"));
-
+
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
-
+
ACE_Log_Msg_Backend * backend = dlf->get_logger_backend(orb);
-
+
if (backend != 0)
{
backend->open(0);
@@ -348,7 +348,7 @@ int ACE_TMAIN (int argc, ACE_TCHAR **argv)
ace->set_flags(ACE_Log_Msg::CUSTOM);
}
- Options options;
+ Options options;
int error = options.parse_args (argc, argv);
if (error == -1)
{
@@ -359,18 +359,18 @@ int ACE_TMAIN (int argc, ACE_TCHAR **argv)
{ //help was issued -> quit
return 0;
}
-
+
if (options.rm_ior_ == 0)
{
DANCE_ERROR ((LM_ERROR, DLINFO "repository_manager_admin_exec::main - "
"No RepositoryManager IOR provided\n"));
return -1;
}
-
+
// Resolve the RepositoryManager reference
CORBA::Object_var obj = orb->string_to_object (options.rm_ior_);
-
- Deployment::RepositoryManager_var rm =
+
+ Deployment::RepositoryManager_var rm =
Deployment::RepositoryManager::_narrow (obj);
if (CORBA::is_nil (obj))
@@ -380,13 +380,13 @@ int ACE_TMAIN (int argc, ACE_TCHAR **argv)
options.rm_ior_));
return -1;
}
-
+
DAnCE::RepositoryManager::Admin admin (rm.in ());
-
+
ACE_Unbounded_Set_Iterator<Options::Installation> inst_it =
options.install_.begin ();
Options::Installation *inst (0);
-
+
while (inst_it.next (inst) == 1)
{
if (!admin.install_package (inst->path_.c_str (),
@@ -398,7 +398,7 @@ int ACE_TMAIN (int argc, ACE_TCHAR **argv)
ACE_Unbounded_Set_Iterator<Options::Creation> creat_it (options.create_);
Options::Creation *creat (0);
-
+
while (creat_it.next (creat) == 1)
{
if (!admin.create_package (creat->path_.c_str (),
@@ -411,14 +411,14 @@ int ACE_TMAIN (int argc, ACE_TCHAR **argv)
ACE_Unbounded_Set_Iterator<ACE_CString> uninst_it (options.uninstall_);
ACE_CString *uninst = 0;
-
+
while (uninst_it.next (uninst) == 1)
{
if (!admin.uninstall_package (uninst->c_str ()))
retval = -1;
uninst_it.advance ();
}
-
+
if (options.list_)
{
::CORBA::StringSeq * packages = admin.list_packages ();
@@ -428,18 +428,18 @@ int ACE_TMAIN (int argc, ACE_TCHAR **argv)
"No packages returned from list_packages\n"));
retval = -1;
}
-
+
DANCE_DEBUG ((LM_EMERGENCY, "Listing %u packages installed on server:\n"));
-
+
for (CORBA::ULong i = 0; i < packages->length (); ++i)
{
DANCE_DEBUG ((LM_EMERGENCY, "\t%s\n",
(*packages)[i].in ()));
}
-
+
delete packages;
}
-
+
if (options.shutdown_)
{
DANCE_DEBUG ((LM_EMERGENCY, "Shutting down the Repository Manager\n"));
@@ -460,7 +460,7 @@ int ACE_TMAIN (int argc, ACE_TCHAR **argv)
"Caught unexpected C++ exception.\n"));
return -1;
}
-
+
return 0;
}