Author: aschnell
Date: Thu Feb 26 12:27:26 2009
New Revision: 55787
URL: http://svn.opensuse.org/viewcvs/yast?rev=55787&view=rev
Log:
- some SystemCmd cleanup:
- use enum instead of int in interface
- make function return string instead of pointer/reference to string
- other minor issues
Modified:
trunk/storage/libstorage/src/AppUtil.cc
trunk/storage/libstorage/src/Dasd.cc
trunk/storage/libstorage/src/Disk.cc
trunk/storage/libstorage/src/Dm.cc
trunk/storage/libstorage/src/DmCo.cc
trunk/storage/libstorage/src/DmmultipathCo.cc
trunk/storage/libstorage/src/DmraidCo.cc
trunk/storage/libstorage/src/LvmLv.cc
trunk/storage/libstorage/src/LvmVg.cc
trunk/storage/libstorage/src/Md.cc
trunk/storage/libstorage/src/ProcMounts.cc
trunk/storage/libstorage/src/Storage.cc
trunk/storage/libstorage/src/SystemCmd.cc
trunk/storage/libstorage/src/SystemCmd.h
trunk/storage/libstorage/src/Volume.cc
Modified: trunk/storage/libstorage/src/AppUtil.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/AppUtil.cc?rev=55787&r1=55786&r2=55787&view=diff
==============================================================================
--- trunk/storage/libstorage/src/AppUtil.cc (original)
+++ trunk/storage/libstorage/src/AppUtil.cc Thu Feb 26 12:27:26 2009
@@ -508,7 +508,7 @@
SystemCmd c( cmd );
if( c.numLines()>0 )
{
- extractNthWord( 0, *c.getLine(0)) >> ret;
+ extractNthWord( 0, c.getLine(0)) >> ret;
}
y2mil( "driver:" << driver << " ret:" << ret );
return( ret );
Modified: trunk/storage/libstorage/src/Dasd.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Dasd.cc?rev=55787&r1=55786&r2=55787&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Dasd.cc (original)
+++ trunk/storage/libstorage/src/Dasd.cc Thu Feb 26 12:27:26 2009
@@ -61,7 +61,7 @@
{
if( Cmd.select( "^format" )>0 )
{
- string tmp = *Cmd.getLine(0, true);
+ string tmp = Cmd.getLine(0, true);
y2milestone( "Format line:%s", tmp.c_str() );
tmp = tmp.erase( 0, tmp.find( ':' ) + 1 );
tmp = boost::to_lower_copy(extractNthWord(4, tmp), locale::classic());
@@ -171,7 +171,7 @@
unsigned long c_start;
unsigned long c_size;
- line = *cmd.getLine(i);
+ line = cmd.getLine(i);
tmp = extractNthWord( 0, line );
if( part.match(tmp) )
{
@@ -234,7 +234,7 @@
if( cmd.select( "cylinders" )>0 )
{
val = 0;
- tmp = *cmd.getLine(0, true);
+ tmp = cmd.getLine(0, true);
y2milestone( "Cylinder line:%s", tmp.c_str() );
tmp = tmp.erase( 0, tmp.find( ':' ) + 1 );
tmp = extractNthWord( 3, tmp );
@@ -245,7 +245,7 @@
if( cmd.select( "tracks per" )>0 )
{
val = 0;
- tmp = *cmd.getLine(0, true);
+ tmp = cmd.getLine(0, true);
y2milestone( "Tracks line:%s", tmp.c_str() );
tmp = tmp.erase( 0, tmp.find( ':' ) + 1 );
tmp = extractNthWord( 3, tmp );
@@ -256,7 +256,7 @@
if( cmd.select( "blocks per" )>0 )
{
val = 0;
- tmp = *cmd.getLine(0, true);
+ tmp = cmd.getLine(0, true);
y2milestone( "Blocks line:%s", tmp.c_str() );
tmp = tmp.erase( 0, tmp.find( ':' ) + 1 );
tmp = extractNthWord( 3, tmp );
@@ -267,7 +267,7 @@
if( cmd.select( "blocksize" )>0 )
{
val = 0;
- tmp = *cmd.getLine(0, true);
+ tmp = cmd.getLine(0, true);
y2milestone( "Bytes line:%s", tmp.c_str() );
tmp = tmp.erase( 0, tmp.find( ':' ) + 1 );
tmp = extractNthWord( 3, tmp );
Modified: trunk/storage/libstorage/src/Disk.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Disk.cc?rev=55787&r1=55786&r2=55787&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Disk.cc (original)
+++ trunk/storage/libstorage/src/Disk.cc Thu Feb 26 12:27:26 2009
@@ -381,13 +381,13 @@
checkSystemError( cmd_line, Cmd );
if( Cmd.select( "Partition Table:" )>0 )
{
- string tmp = *Cmd.getLine(0, true);
+ string tmp = Cmd.getLine(0, true);
y2mil("Label line:" << tmp);
dlabel = extractNthWord( 2, tmp );
}
if( Cmd.select( "BIOS cylinder" )>0 )
{
- string tmp = *Cmd.getLine(0, true);
+ string tmp = Cmd.getLine(0, true);
getGeometry( tmp, cyl, head, sector );
new_cyl = cyl;
new_head = head;
@@ -791,7 +791,7 @@
unsigned id;
bool boot;
- line = *Cmd.getLine(i);
+ line = Cmd.getLine(i);
tmp = extractNthWord( 0, line );
if( tmp.length()>0 && isdigit(tmp[0]) )
{
@@ -1946,7 +1946,7 @@
unsigned long c;
unsigned h;
unsigned s;
- string tmp = *Cmd.getLine(0, true);
+ string tmp = Cmd.getLine(0, true);
getGeometry( tmp, c, h, s );
if( c!=0 && c!=cyl )
{
@@ -2065,8 +2065,7 @@
PartitionType type;
bool boot;
if( cmd.numLines()>0 &&
- scanPartedLine( *cmd.getLine(0), nr, start, csize, type,
- id, boot ))
+ scanPartedLine( cmd.getLine(0), nr, start, csize, type, id, boot ))
{
y2milestone( "really created at cyl:%ld csize:%ld", start, csize );
p->changeRegion( start, csize, cylinderToKb(csize) );
@@ -2110,7 +2109,7 @@
if( cmd.numLines()>0 )
{
string dummy, s1, s2;
- std::istringstream data( *cmd.getLine(0) );
+ std::istringstream data( cmd.getLine(0) );
classic(data);
data >> dummy >> s1 >> s2;
y2milestone( "dummy:\"%s\" s1:\"%s\" s2:\"%s\"", dummy.c_str(),
Modified: trunk/storage/libstorage/src/Dm.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Dm.cc?rev=55787&r1=55786&r2=55787&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Dm.cc (original)
+++ trunk/storage/libstorage/src/Dm.cc Thu Feb 26 12:27:26 2009
@@ -63,7 +63,7 @@
" inactive:" << inactiv);
if( c.numLines()>0 )
{
- string line = *c.getLine(0);
+ string line = c.getLine(0);
target = extractNthWord( 2, line );
if( target=="striped" )
extractNthWord( 3, line ) >> stripe;
@@ -77,7 +77,7 @@
unsigned long le;
string dev;
string majmin;
- string line = *c.getLine(i);
+ string line = c.getLine(i);
if( target=="linear" )
{
extractNthWord( 1, line ) >> le;
@@ -209,17 +209,17 @@
" -m " + *(++ls.begin()) + " | sed -e \"s/:.*//\"" );
if( c.retcode()==0 && c.numLines()>0 )
{
- string tmp = "/dev/"+*c.getLine(0);
+ string tmp = "/dev/" + c.getLine(0);
if( cont->getStorage()->knownDevice( tmp, true ) )
{
ret = tmp;
}
else
{
- c.execute(DMSETUPBIN " table " + quote(*c.getLine(0)));
+ c.execute(DMSETUPBIN " table " + quote(c.getLine(0)));
if( c.retcode()==0 && c.numLines()>0 )
{
- pair = extractNthWord( 3, *c.getLine(0) );
+ pair = extractNthWord( 3, c.getLine(0) );
ret = cont->getStorage()->deviceByNumber( pair );
}
}
@@ -494,7 +494,7 @@
SystemCmd c(DMSETUPBIN " -c --noheadings info " + quote(table));
if( c.retcode()==0 && c.numLines()>0 )
{
- list<string> sl = splitString( *c.getLine(0), ":" );
+ list<string> sl = splitString( c.getLine(0), ":" );
if( sl.size()>=3 )
{
list<string>::const_iterator ci = sl.begin();
Modified: trunk/storage/libstorage/src/DmCo.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/DmCo.cc?rev=55787&r1=55786&r2=55787&view=diff
==============================================================================
--- trunk/storage/libstorage/src/DmCo.cc (original)
+++ trunk/storage/libstorage/src/DmCo.cc Thu Feb 26 12:27:26 2009
@@ -83,7 +83,7 @@
string cipher, keysize;
for( unsigned int i = 0; i < c.numLines(); i++)
{
- string line = *c.getLine(i);
+ string line = c.getLine(i);
string key = extractNthWord( 0, line );
if( key == "cipher:" )
cipher = extractNthWord( 1, line );
@@ -118,7 +118,7 @@
SystemCmd c(DMSETUPBIN " ls | grep \"(.*)\"" );
for( unsigned i=0; ihttp://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/DmmultipathCo.cc?rev=55787&r1=55786&r2=55787&view=diff
==============================================================================
--- trunk/storage/libstorage/src/DmmultipathCo.cc (original)
+++ trunk/storage/libstorage/src/DmmultipathCo.cc Thu Feb 26 12:27:26 2009
@@ -41,7 +41,7 @@
if (c.numLines() > 0)
{
- string line = *c.getLine(0);
+ string line = c.getLine(0);
y2mil("mp line:" << line);
string unit = extractNthWord(0, line);
@@ -63,7 +63,7 @@
list<string> devs;
for (unsigned int i = 1; i < c.numLines(); i++)
{
- string line = *c.getLine(i);
+ string line = c.getLine(i);
if (boost::starts_with(line, " \\_"))
{
y2mil("mp element:" << line);
@@ -168,12 +168,12 @@
unsigned i=0;
if( i= 1)
Modified: trunk/storage/libstorage/src/DmraidCo.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/DmraidCo.cc?rev=55787&r1=55786&r2=55787&view=diff
==============================================================================
--- trunk/storage/libstorage/src/DmraidCo.cc (original)
+++ trunk/storage/libstorage/src/DmraidCo.cc Thu Feb 26 12:27:26 2009
@@ -38,7 +38,7 @@
list<string>::const_iterator ci;
list<string> sl;
if( c.numLines()>0 )
- sl = splitString( *c.getLine(0), ":" );
+ sl = splitString( c.getLine(0), ":" );
Pv *pve = new Pv;
if( sl.size()>=4 )
{
@@ -49,7 +49,7 @@
unsigned num = 1;
while( num=3 )
{
@@ -133,7 +133,7 @@
SystemCmd c(DMRAIDBIN " -s -c -c -c");
for( unsigned i=0; i=3 )
{
list<string>::const_iterator ci = sl.begin();
Modified: trunk/storage/libstorage/src/LvmLv.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/LvmLv.cc?rev=55787&r1=55786&r2=55787&view=diff
==============================================================================
--- trunk/storage/libstorage/src/LvmLv.cc (original)
+++ trunk/storage/libstorage/src/LvmLv.cc Thu Feb 26 12:27:26 2009
@@ -114,7 +114,7 @@
{
for (unsigned int l = 1; l < cmd.numLines(); l++)
{
- string line = *cmd.getLine(l);
+ string line = cmd.getLine(l);
if (extractNthWord(0, line) == name())
{
Modified: trunk/storage/libstorage/src/LvmVg.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/LvmVg.cc?rev=55787&r1=55786&r2=55787&view=diff
==============================================================================
--- trunk/storage/libstorage/src/LvmVg.cc (original)
+++ trunk/storage/libstorage/src/LvmVg.cc Thu Feb 26 12:27:26 2009
@@ -641,10 +641,10 @@
string::size_type pos;
while( i> p->num_pe;
extractNthWord( 7, line ) >> p->free_pe;
}
- line = *c.getLine( i++ );
+ line = c.getLine( i++ );
}
if( !p->device.empty() )
{
@@ -1124,7 +1124,7 @@
for( unsigned i=0; i0 )
vgname.erase( 0, pos );
@@ -1537,7 +1537,7 @@
c.execute( "devmap_name "+dm+":"+i->device.substr( 8 ) );
if( c.retcode()==0 )
{
- string dev = "/dev/" + *c.getLine( 0 );
+ string dev = "/dev/" + c.getLine( 0 );
y2mil( "dev:" << i->device << " normal dev:" << dev );
if( getStorage()->knownDevice( dev ) )
{
Modified: trunk/storage/libstorage/src/Md.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Md.cc?rev=55787&r1=55786&r2=55787&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Md.cc (original)
+++ trunk/storage/libstorage/src/Md.cc Thu Feb 26 12:27:26 2009
@@ -49,21 +49,21 @@
string::size_type pos;
if( c.retcode()==0 && c.numLines(true)>0 )
{
- md_uuid = *c.getLine(0,true);
+ md_uuid = c.getLine(0,true);
if( (pos=md_uuid.find( "UUID : " ))!=string::npos )
md_uuid.erase( 0, pos+7 );
md_uuid = extractNthWord( 0, md_uuid );
}
c.select( "Version : " );
if( c.retcode()==0 && c.numLines(true)>0 )
- sb_ver = extractNthWord( 2, *c.getLine(0,true) );
+ sb_ver = extractNthWord( 2, c.getLine(0,true) );
if (c.retcode()==0 && c.numLines(true)>0 )
{
- y2mil( "line:\"" << *c.getLine(0,true) << "\"" );
+ y2mil( "line:\"" << c.getLine(0,true) << "\"" );
y2mil( "sb_ver:\"" << sb_ver << "\"" );
- y2mil( "word0:\"" << extractNthWord( 0, *c.getLine(0,true)) << "\"" );
- y2mil( "word1:\"" << extractNthWord( 1, *c.getLine(0,true)) << "\"" );
- y2mil( "word2:\"" << extractNthWord( 2, *c.getLine(0,true)) << "\"" );
+ y2mil( "word0:\"" << extractNthWord( 0, c.getLine(0,true)) << "\"" );
+ y2mil( "word1:\"" << extractNthWord( 1, c.getLine(0,true)) << "\"" );
+ y2mil( "word2:\"" << extractNthWord( 2, c.getLine(0,true)) << "\"" );
}
string tmp;
string line = line1;
@@ -260,7 +260,7 @@
c.select("State : ");
if( c.retcode()==0 && c.numLines(true)>0 )
{
- string state = *c.getLine(0,true);
+ string state = c.getLine(0,true);
string::size_type pos;
if( (pos=state.find( "State : " ))!=string::npos )
state.erase( 0, pos+8 );
Modified: trunk/storage/libstorage/src/ProcMounts.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/ProcMounts.cc?rev=55787&r1=55786&r2=55787&view=diff
==============================================================================
--- trunk/storage/libstorage/src/ProcMounts.cc (original)
+++ trunk/storage/libstorage/src/ProcMounts.cc Thu Feb 26 12:27:26 2009
@@ -56,7 +56,7 @@
mt.select( (string)" on "+dir+' ' );
if( mt.numLines(true)>0 )
{
- list<string> sl = splitString( *mt.getLine(0,true) );
+ list<string> sl = splitString( mt.getLine(0,true) );
y2mil( "sl:" << sl );
if( sl.size()>=6 )
{
@@ -93,8 +93,8 @@
mt.select( " / " );
if( mt.numLines()>0 )
{
- y2mil( "root mount:" << *mt.getLine(0,true) );
- string dev = extractNthWord( 0, *mt.getLine(0,true));
+ y2mil( "root mount:" << mt.getLine(0,true) );
+ string dev = extractNthWord( 0, mt.getLine(0,true));
if( !dev.empty() && dev[0]!='/' )
{
dev = sto->findNormalDevice( dev );
Modified: trunk/storage/libstorage/src/Storage.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Storage.cc?rev=55787&r1=55786&r2=55787&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Storage.cc (original)
+++ trunk/storage/libstorage/src/Storage.cc Thu Feb 26 12:27:26 2009
@@ -225,7 +225,7 @@
if( testmode )
{
- SystemCmd::testmode = true;
+ SystemCmd::setTestmode();
rootprefix = testdir;
fstab = new EtcFstab( rootprefix );
string t = testdir+"/volume_info";
@@ -250,7 +250,7 @@
SystemCmd rm;
for( unsigned i=0; i=2 )
{
- ret = extractNthWord( 0, *c.getLine(0) )==
- extractNthWord( 0, *c.getLine(1) );
+ ret = extractNthWord( 0, c.getLine(0) ) == extractNthWord( 0, c.getLine(1) );
}
}
y2mil("ret:" << ret << "n1:" << n1 << " n2:" << n2);
@@ -3725,7 +3724,7 @@
SystemCmd c( "ps ax | grep -w /usr/sbin/hald | grep -v grep" );
if( c.numLines()>0 )
{
- extractNthWord( 0, *c.getLine(0) ) >> hald_pid;
+ extractNthWord( 0, c.getLine(0) ) >> hald_pid;
y2mil( "hald_pid:" << hald_pid );
}
if( hald_pid>0 )
@@ -4575,7 +4574,7 @@
unsigned line=0;
while( line> t;
Modified: trunk/storage/libstorage/src/SystemCmd.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/SystemCmd.cc?rev=55787&r1=55786&r2=55787&view=diff
==============================================================================
--- trunk/storage/libstorage/src/SystemCmd.cc (original)
+++ trunk/storage/libstorage/src/SystemCmd.cc Thu Feb 26 12:27:26 2009
@@ -29,6 +29,7 @@
execute( Command );
}
+
SystemCmd::SystemCmd( const string& Command_Cv )
{
y2mil("constructor SystemCmd:\"" << Command_Cv << "\"");
@@ -36,12 +37,14 @@
execute( Command_Cv );
}
+
SystemCmd::SystemCmd()
{
y2mil("constructor SystemCmd");
init();
}
+
void SystemCmd::init()
{
Combine_b = false;
@@ -52,6 +55,7 @@
pfds[0].events = pfds[1].events = POLLIN;
}
+
SystemCmd::~SystemCmd()
{
if( File_aC[IDX_STDOUT] )
@@ -60,14 +64,15 @@
fclose( File_aC[IDX_STDERR] );
}
+
void
-SystemCmd::setOutputHandler( void (*Handle_f)( void *, string, bool ),
- void * Par_p )
+SystemCmd::setOutputHandler( void (*Handle_f)( void *, string, bool ), void * Par_p )
{
OutputHandler_f = Handle_f;
HandlerPar_p = Par_p;
}
+
void
SystemCmd::closeOpenFds()
{
@@ -99,8 +104,7 @@
int
SystemCmd::executeRestricted( const string& Command_Cv,
- long unsigned MaxTimeSec,
- long unsigned MaxLineOut,
+ long unsigned MaxTimeSec, long unsigned MaxLineOut,
bool& ExceedTime, bool& ExceedLines )
{
y2mil("cmd:" << Command_Cv << " MaxTime:" << MaxTimeSec << " MaxLines:" << MaxLineOut);
@@ -349,29 +353,34 @@
return Wait_ii != 0;
}
+
void
-SystemCmd::setCombine( const bool Comb_bv )
- {
- Combine_b = Comb_bv;
- }
+SystemCmd::setCombine(bool val)
+{
+ Combine_b = val;
+}
-const string *
-SystemCmd::getString( unsigned Idx_iv ) const
+
+void
+SystemCmd::setTestmode(bool val)
+{
+ testmode = val;
+}
+
+
+string
+SystemCmd::getString( OutputStream Idx_iv ) const
{
if( Idx_iv > 1 )
{
y2err("invalid index " << Idx_iv);
}
- if( !Valid_ab[Idx_iv] )
- {
- Text_aC[Idx_iv] = boost::join(Lines_aC[Idx_iv], "\n");
- Valid_ab[Idx_iv] = true;
- }
- return &Text_aC[Idx_iv];
+ return boost::join(Lines_aC[Idx_iv], "\n");
}
+
unsigned
-SystemCmd::numLines( bool Sel_bv, unsigned Idx_iv ) const
+SystemCmd::numLines( bool Sel_bv, OutputStream Idx_iv ) const
{
unsigned Ret_ii;
@@ -391,10 +400,11 @@
return Ret_ii;
}
-const string *
-SystemCmd::getLine( unsigned Nr_iv, bool Sel_bv, unsigned Idx_iv ) const
+
+string
+SystemCmd::getLine( unsigned Nr_iv, bool Sel_bv, OutputStream Idx_iv ) const
{
- const string * Ret_pCi = NULL;
+ string ret;
if( Idx_iv > 1 )
{
@@ -404,21 +414,22 @@
{
if( Nr_iv < SelLines_aC[Idx_iv].capacity() )
{
- Ret_pCi = SelLines_aC[Idx_iv][Nr_iv];
+ ret = *SelLines_aC[Idx_iv][Nr_iv];
}
}
else
{
if( Nr_iv < Lines_aC[Idx_iv].size() )
{
- Ret_pCi = &Lines_aC[Idx_iv][Nr_iv];
+ ret = Lines_aC[Idx_iv][Nr_iv];
}
}
- return Ret_pCi;
+ return ret;
}
+
int
-SystemCmd::select( string Pat_Cv, bool Invert_bv, unsigned Idx_iv )
+SystemCmd::select( string Pat_Cv, bool Invert_bv, OutputStream Idx_iv )
{
int I_ii;
int End_ii;
@@ -460,14 +471,12 @@
return Size_ii;
}
+
void
SystemCmd::invalidate()
{
- int Idx_ii;
-
- for( Idx_ii=0; Idx_ii<2; Idx_ii++ )
+ for (int Idx_ii = 0; Idx_ii < 2; Idx_ii++)
{
- Valid_ab[Idx_ii] = false;
SelLines_aC[Idx_ii].resize(0);
Lines_aC[Idx_ii].clear();
NewLineSeen_ab[Idx_ii] = true;
@@ -559,6 +568,7 @@
}
}
+
void
SystemCmd::extractNewline( const char* Buf_ti, int Cnt_iv, bool& NewLine_br,
string& Text_Cr, vector<string>& Lines_Cr )
@@ -603,9 +613,9 @@
SystemCmd::logOutput() const
{
for (unsigned i = 0; i < numLines(false, IDX_STDERR); ++i)
- y2mil("stderr:" << *getLine(i, false, IDX_STDERR));
+ y2mil("stderr:" << getLine(i, false, IDX_STDERR));
for (unsigned i = 0; i < numLines(false, IDX_STDOUT); ++i)
- y2mil("stdout:" << *getLine(i, false, IDX_STDOUT));
+ y2mil("stdout:" << getLine(i, false, IDX_STDOUT));
}
Modified: trunk/storage/libstorage/src/SystemCmd.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/SystemCmd.h?rev=55787&r1=55786&r2=55787&view=diff
==============================================================================
--- trunk/storage/libstorage/src/SystemCmd.h (original)
+++ trunk/storage/libstorage/src/SystemCmd.h Thu Feb 26 12:27:26 2009
@@ -18,33 +18,38 @@
class SystemCmd
{
public:
+
enum OutputStream { IDX_STDOUT, IDX_STDERR };
+
SystemCmd( const char* Command_Cv );
SystemCmd( const string& Command_Cv );
SystemCmd();
+
virtual ~SystemCmd();
+
int execute( const string& Command_Cv );
int executeBackground( const string& Command_Cv );
int executeRestricted( const string& Command_Cv,
- unsigned long MaxTimeSec,
- unsigned long MaxLineOut,
+ unsigned long MaxTimeSec, unsigned long MaxLineOut,
bool& ExceedTime, bool& ExceedLines);
- void setOutputHandler( void (*Handle_f)( void *, string, bool ),
- void * Par_p );
+
+ void setOutputHandler( void (*Handle_f)( void *, string, bool ), void * Par_p );
+ void setOutputProcessor( OutputProcessor * proc ) { output_proc = proc; }
void logOutput() const;
- void setOutputProcessor( OutputProcessor * proc )
- { output_proc = proc; }
- int select( string Reg_Cv, bool Invert_bv=false,
- unsigned Idx_ii=IDX_STDOUT );
- const string& stderr() const { return( *getString(IDX_STDERR)); }
- const string& stdout() const { return( *getString(IDX_STDOUT)); }
- const string& cmd() const { return( lastCmd ); }
- const string* getLine( unsigned Num_iv, bool Selected_bv=false,
- unsigned Idx_ii=IDX_STDOUT ) const;
- unsigned numLines( bool Selected_bv=false, unsigned Idx_ii=IDX_STDOUT ) const;
- void setCombine( const bool Combine_b=true );
+
+ string stderr() const { return getString(IDX_STDERR); }
+ string stdout() const { return getString(IDX_STDOUT); }
+ string cmd() const { return lastCmd; }
int retcode() const { return Ret_i; }
+ int select(string Reg_Cv, bool Invert_bv = false, OutputStream Idx_ii = IDX_STDOUT);
+ unsigned numLines(bool Selected_bv = false, OutputStream Idx_ii = IDX_STDOUT) const;
+ string getLine(unsigned Num_iv, bool Selected_bv = false, OutputStream Idx_ii = IDX_STDOUT) const;
+
+ void setCombine(bool combine = true);
+
+ static void setTestmode(bool testmode = true);
+
/**
* Quotes and protects a single string for shell execution.
*/
@@ -55,8 +60,6 @@
*/
static string quote(const std::list<string>& strs);
- static bool testmode;
-
protected:
void invalidate();
@@ -71,10 +74,8 @@
void addLine( string Text_Cv, std::vector<string>& Lines_Cr );
void init();
- const string* getString( unsigned Idx_ii=IDX_STDOUT ) const;
+ string getString(OutputStream Idx_ii = IDX_STDOUT) const;
- mutable string Text_aC[2];
- mutable bool Valid_ab[2];
FILE* File_aC[2];
std::vector<string> Lines_aC[2];
std::vector SelLines_aC[2];
@@ -89,6 +90,8 @@
OutputProcessor* output_proc;
struct pollfd pfds[2];
+ static bool testmode;
+
};
Modified: trunk/storage/libstorage/src/Volume.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Volume.cc?rev=55787&r1=55786&r2=55787&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Volume.cc (original)
+++ trunk/storage/libstorage/src/Volume.cc Thu Feb 26 12:27:26 2009
@@ -347,7 +347,7 @@
}
if( found )
{
- list<string> l = splitString( *loopData.getLine( 0, true ));
+ list<string> l = splitString( loopData.getLine( 0, true ));
std::ostringstream b;
classic(b);
b << "line[" << device() << "]=" << l;
@@ -400,7 +400,7 @@
}
if( found )
{
- list<string> l = splitString( *blkidData.getLine( 0, true ), " \t\n",
+ list<string> l = splitString( blkidData.getLine( 0, true ), " \t\n",
true, true, "\"" );
std::ostringstream b;
classic(b);
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org