storage::SystemCmd Class Reference

#include <SystemCmd.h>

List of all members.

Public Types

enum  OutputStream { IDX_STDOUT, IDX_STDERR }

Public Member Functions

 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, bool &ExceedTime, bool &ExceedLines)
void setOutputProcessor (OutputProcessor *proc)
const vector< string > & stdout () const
const vector< string > & stderr () const
string cmd () const
int retcode () const
int select (const string &Reg_Cv, 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 Public Member Functions

static void setTestmode (bool testmode=true)
static string quote (const string &str)
static string quote (const std::list< string > &strs)

Protected Member Functions

void invalidate ()
void closeOpenFds () const
int doExecute (const string &Cmd_Cv)
bool doWait (bool Hang_bv, int &Ret_ir)
void checkOutput ()
void getUntilEOF (FILE *File_Cr, std::vector< string > &Lines_Cr, bool &NewLineSeen_br, bool Stderr_bv)
void extractNewline (const string &Buf_ti, int Cnt_ii, bool &NewLineSeen_br, string &Text_Cr, std::vector< string > &Lines_Cr)
void addLine (const string &Text_Cv, std::vector< string > &Lines_Cr)
void init ()
void logOutput () const

Protected Attributes

FILE * File_aC [2]
std::vector< string > Lines_aC [2]
std::vector< string * > SelLines_aC [2]
bool NewLineSeen_ab [2]
bool Combine_b
bool Background_b
string lastCmd
int Ret_i
int Pid_i
OutputProcessoroutput_proc
struct pollfd pfds [2]

Static Protected Attributes

static bool testmode = false
static const unsigned line_limit = 50


Member Enumeration Documentation

Enumerator:
IDX_STDOUT 
IDX_STDERR 


Constructor & Destructor Documentation

storage::SystemCmd::SystemCmd ( const string &  Command_Cv  ) 

References execute(), init(), and y2mil.

storage::SystemCmd::SystemCmd (  ) 

References init(), and y2mil.

storage::SystemCmd::~SystemCmd (  )  [virtual]

References File_aC, IDX_STDERR, and IDX_STDOUT.


Member Function Documentation

int storage::SystemCmd::execute ( const string &  Command_Cv  ) 

int storage::SystemCmd::executeBackground ( const string &  Command_Cv  ) 

References Background_b, doExecute(), and y2mil.

int storage::SystemCmd::executeRestricted ( const string &  Command_Cv,
unsigned long  MaxTimeSec,
unsigned long  MaxLineOut,
bool &  ExceedTime,
bool &  ExceedLines 
)

void storage::SystemCmd::setOutputProcessor ( OutputProcessor proc  )  [inline]

const vector<string>& storage::SystemCmd::stdout (  )  const [inline]

const vector<string>& storage::SystemCmd::stderr (  )  const [inline]

string storage::SystemCmd::cmd (  )  const [inline]

References lastCmd.

Referenced by doExecute(), and storage::Container::setExtError().

int storage::SystemCmd::retcode (  )  const [inline]

int storage::SystemCmd::select ( const string &  Reg_Cv,
OutputStream  Idx_ii = IDX_STDOUT 
)

unsigned storage::SystemCmd::numLines ( bool  Selected_bv = false,
OutputStream  Idx_ii = IDX_STDOUT 
) const

string storage::SystemCmd::getLine ( unsigned  Num_iv,
bool  Selected_bv = false,
OutputStream  Idx_ii = IDX_STDOUT 
) const

void storage::SystemCmd::setCombine ( bool  combine = true  ) 

References Combine_b.

Referenced by storage::Volume::resizeFs().

void storage::SystemCmd::setTestmode ( bool  testmode = true  )  [static]

References testmode.

Referenced by storage::Storage::Storage().

string storage::SystemCmd::quote ( const string &  str  )  [static]

Quotes and protects a single string for shell execution.

Referenced by quote().

string storage::SystemCmd::quote ( const std::list< string > &  strs  )  [static]

Quotes and protects every single string in the list for shell execution.

References quote().

void storage::SystemCmd::invalidate (  )  [protected]

References Lines_aC, NewLineSeen_ab, and SelLines_aC.

Referenced by doExecute().

void storage::SystemCmd::closeOpenFds (  )  const [protected]

Referenced by doExecute().

int storage::SystemCmd::doExecute ( const string &  Cmd_Cv  )  [protected]

bool storage::SystemCmd::doWait ( bool  Hang_bv,
int &  Ret_ir 
) [protected]

void storage::SystemCmd::checkOutput (  )  [protected]

void storage::SystemCmd::getUntilEOF ( FILE *  File_Cr,
std::vector< string > &  Lines_Cr,
bool &  NewLineSeen_br,
bool  Stderr_bv 
) [protected]

void storage::SystemCmd::extractNewline ( const string &  Buf_ti,
int  Cnt_ii,
bool &  NewLineSeen_br,
string &  Text_Cr,
std::vector< string > &  Lines_Cr 
) [protected]

References addLine(), and y2deb.

Referenced by getUntilEOF().

void storage::SystemCmd::addLine ( const string &  Text_Cv,
std::vector< string > &  Lines_Cr 
) [protected]

References line_limit, y2deb, and y2mil.

Referenced by extractNewline(), and getUntilEOF().

void storage::SystemCmd::init (  )  [protected]

References File_aC, and pfds.

Referenced by SystemCmd().

void storage::SystemCmd::logOutput (  )  const [protected]

References getLine(), IDX_STDERR, IDX_STDOUT, line_limit, numLines(), and y2mil.

Referenced by doExecute().


Member Data Documentation

FILE* storage::SystemCmd::File_aC[2] [protected]

std::vector<string> storage::SystemCmd::Lines_aC[2] [protected]

std::vector<string*> storage::SystemCmd::SelLines_aC[2] [protected]

Referenced by getLine(), invalidate(), numLines(), and select().

Referenced by checkOutput(), and invalidate().

Referenced by doExecute(), doWait(), and setCombine().

string storage::SystemCmd::lastCmd [protected]

Referenced by cmd(), doExecute(), and doWait().

int storage::SystemCmd::Ret_i [protected]

Referenced by doExecute(), and retcode().

int storage::SystemCmd::Pid_i [protected]

Referenced by doExecute(), doWait(), getUntilEOF(), and select().

struct pollfd storage::SystemCmd::pfds[2] [read, protected]

Referenced by doExecute(), doWait(), and init().

bool storage::SystemCmd::testmode = false [static, protected]

Referenced by doExecute(), and setTestmode().

const unsigned storage::SystemCmd::line_limit = 50 [static, protected]

Referenced by addLine(), and logOutput().


The documentation for this class was generated from the following files:

Generated on Mon Feb 6 10:42:58 2012 for yast2-storage by  doxygen 1.5.6