yast2-storage
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes

storage::SystemCmd Class Reference

#include <SystemCmd.h>

Inheritance diagram for storage::SystemCmd:
noncopyable

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

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::checkOutput ( ) [protected]
void storage::SystemCmd::closeOpenFds ( ) const [protected]

Referenced by doExecute().

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

References lastCmd.

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

int storage::SystemCmd::doExecute ( const string &  Cmd_Cv) [protected]
bool storage::SystemCmd::doWait ( bool  Hang_bv,
int &  Ret_ir 
) [protected]
int storage::SystemCmd::execute ( const string &  Command_Cv)
int storage::SystemCmd::executeBackground ( const string &  Command_Cv)

References Background_b, doExecute(), and y2mil.

Referenced by executeRestricted().

int storage::SystemCmd::executeRestricted ( const string &  Command_Cv,
unsigned long  MaxTimeSec,
unsigned long  MaxLineOut,
bool &  ExceedTime,
bool &  ExceedLines 
)
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().

string storage::SystemCmd::getLine ( unsigned  Num_iv,
bool  Selected_bv = false,
OutputStream  Idx_ii = IDX_STDOUT 
) const
void storage::SystemCmd::getUntilEOF ( FILE *  File_Cr,
std::vector< string > &  Lines_Cr,
bool &  NewLineSeen_br,
bool  Stderr_bv 
) [protected]
void storage::SystemCmd::init ( ) [protected]

References File_aC, and pfds.

Referenced by SystemCmd().

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

References Lines_aC, NewLineSeen_ab, and SelLines_aC.

Referenced by doExecute().

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

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

Referenced by doExecute().

unsigned storage::SystemCmd::numLines ( bool  Selected_bv = false,
OutputStream  Idx_ii = IDX_STDOUT 
) const
string storage::SystemCmd::quote ( const std::list< string > &  strs) [static]

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

References quote().

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

Quotes and protects a single string for shell execution.

Referenced by storage::quote(), and quote().

int storage::SystemCmd::retcode ( ) const [inline]
int storage::SystemCmd::select ( const string &  Reg_Cv,
OutputStream  Idx_ii = IDX_STDOUT 
)
void storage::SystemCmd::setCombine ( bool  combine = true)

References Combine_b.

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

void storage::SystemCmd::setOutputProcessor ( OutputProcessor proc) [inline]
void storage::SystemCmd::setTestmode ( bool  testmode = true) [static]

References testmode.

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

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

References IDX_STDERR, and Lines_aC.

Referenced by storage::Container::setExtError().

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

Member Data Documentation

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

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

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

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

Referenced by addLine(), and logOutput().

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

Referenced by checkOutput(), and invalidate().

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

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

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

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

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

Referenced by doExecute(), and setTestmode().


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