Commit fee92b77 authored by Vitaly Lipatov's avatar Vitaly Lipatov

fix argv filling and comparing

parent b8e17f1f
...@@ -149,15 +149,10 @@ namespace UniSetTypes ...@@ -149,15 +149,10 @@ namespace UniSetTypes
int _argc, char** _argv, int _argc, char** _argv,
const std::string defval="" ) const std::string defval="" )
{ {
for( int i=1; i<_argc; i++ ) for( int i=1; i < (_argc - 1) ; i++ )
{
if( !strcmp(_argv[i], name.c_str()) )
{ {
int k=i+1; if( name == _argv[i] )
if( k<_argc ) return _argv[i+1];
return _argv[k];
break;
}
} }
return defval; return defval;
} }
...@@ -171,7 +166,7 @@ namespace UniSetTypes ...@@ -171,7 +166,7 @@ namespace UniSetTypes
{ {
for( int i=1; i<_argc; i++ ) for( int i=1; i<_argc; i++ )
{ {
if( !strcmp(_argv[i], name.c_str()) ) if( name == _argv[i] )
return i; return i;
} }
return -1; return -1;
......
...@@ -307,15 +307,12 @@ void Configuration::initConfiguration( int argc, char** argv ) ...@@ -307,15 +307,12 @@ void Configuration::initConfiguration( int argc, char** argv )
_argc = argc+2*lnodes.size()+2; _argc = argc+2*lnodes.size()+2;
_argv = new char*[_argc]; _argv = new char*[_argc];
int i = 0;
// //
int i=0; for( ; i < argc; i++ )
for( ;i<argc; i++ ) _argv[i] = strdup(argv[i]);
{
_argv[i] = new char[strlen(argv[i]) + 1];
strcpy(_argv[i],argv[i]);
}
// // , i
for( UniSetTypes::ListOfNode::iterator it=lnodes.begin(); it!=lnodes.end(); ++it ) for( UniSetTypes::ListOfNode::iterator it=lnodes.begin(); it!=lnodes.end(); ++it )
{ {
_argv[i] = "-ORBInitRef"; _argv[i] = "-ORBInitRef";
...@@ -323,8 +320,7 @@ void Configuration::initConfiguration( int argc, char** argv ) ...@@ -323,8 +320,7 @@ void Configuration::initConfiguration( int argc, char** argv )
string name(oind->getRealNodeName(it->id)); string name(oind->getRealNodeName(it->id));
ostringstream param; ostringstream param;
param << name << "=corbaname::" << it->host << ":" << it->port; param << name << "=corbaname::" << it->host << ":" << it->port;
_argv[i+1] = new char[param.str().size()+1]; // +1 - \0 _argv[i+1] = strdup(param.str().c_str());
strcpy(_argv[i+1],param.str().c_str());
if( unideb.debugging(Debug::INFO) ) if( unideb.debugging(Debug::INFO) )
unideb[Debug::INFO] << "(Configuration): " << param.str() << endl; unideb[Debug::INFO] << "(Configuration): " << param.str() << endl;
...@@ -355,10 +351,7 @@ void Configuration::initConfiguration( int argc, char** argv ) ...@@ -355,10 +351,7 @@ void Configuration::initConfiguration( int argc, char** argv )
ostringstream param; ostringstream param;
param <<"NameService=corbaname::" << getProp(nsnode,"host") << ":" << defPort; param <<"NameService=corbaname::" << getProp(nsnode,"host") << ":" << defPort;
// _argv[i+1] = strdup(param.str().c_str());
_argv[i+1] = new char[param.str().size()+1]; // +1 - \0
//
strcpy(_argv[i+1],param.str().c_str());
if( unideb.debugging(Debug::INFO) ) if( unideb.debugging(Debug::INFO) )
unideb[Debug::INFO] << "(Configuration): " << param.str() << endl; unideb[Debug::INFO] << "(Configuration): " << param.str() << endl;
} }
...@@ -771,28 +764,19 @@ xmlNode* Configuration::initDebug( DebugStream& deb, const string& _debname ) ...@@ -771,28 +764,19 @@ xmlNode* Configuration::initDebug( DebugStream& deb, const string& _debname )
string del_level("--"+debname+"-del-levels"); string del_level("--"+debname+"-del-levels");
// //
for (int i=1; i<_argc; i++) for (int i=1; i < (_argc - 1); i++)
{ {
if( !strcmp(_argv[i],log_in.c_str()) ) // "--debug-log_in_file" if( log_in == _argv[i] ) // "--debug-log_in_file"
{ {
if( i+1 < _argc )
deb.logFile(_argv[i+1]); deb.logFile(_argv[i+1]);
} }
else if( !strcmp(_argv[i],add_level.c_str()) ) // "--debug-add-levels" else if( add_level == _argv[i] ) // "--debug-add-levels"
{
if( i+1 < _argc )
{ {
string val(_argv[i+1]); deb.addLevel(Debug::value(_argv[i+1]));
deb.addLevel(Debug::value(val));
} }
} else if( del_level == _argv[i] ) // "--debug-del-levels"
else if( !strcmp(_argv[i],del_level.c_str()) ) // "--debug-del-levels"
{
if( i+1 < _argc )
{ {
string val(_argv[i+1]); deb.delLevel(Debug::value(_argv[i+1]));
deb.delLevel(Debug::value(val));
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment