#include <mcs.hh>
This is the basic class for all threaded objects inside MCS. It offers a log facility as well as a static access to a Env object.
Definition at line 6112 of file mcs.hh.
Public Member Functions | |
BaseThread (Thread *parent, const char *ltID) | |
Constructor invoked from other objects. | |
BaseThread (Thread *parent, int lID) | |
Constructor invoked from ClienThread objects. | |
BaseThread (const BaseThread &) | |
Declared to avoid using of default copy constructor. | |
int | chkExt (string &s) |
Check if an external program or script is registered in the configuration file. | |
BaseThread & | operator= (const BaseThread &) |
Declared to avoid using of default assignment operator. | |
const char * | tid () |
Return the thread identifier. | |
~BaseThread () | |
Destructor. | |
Static Public Member Functions | |
static int | fileType (string fn) |
Determine the file type of an external program or script. | |
static int | spawn (string fn, string pars, string wpath=".", string thrID="x", string user="x", string pass="x", string dbname="x", string fout="out", string ferr="err") |
Execute an external program or script in a dedicated environment. | |
Protected Member Functions | |
RetValue | Log (Event e) |
Logging facility. | |
Static Protected Attributes | |
static Env * | env |
Pointer to the actual Env object, this can be seen in all threaded object. | |
Private Attributes | |
MCS_DEBUG_ALLOC | |
char | tID [4] |
Thread identifier stored as a null terminated string. |
mcs::BaseThread::BaseThread | ( | const BaseThread & | ) |
Declared to avoid using of default copy constructor.
mcs::BaseThread::BaseThread | ( | Thread * | parent, | |
int | lID | |||
) |
Constructor invoked from ClienThread objects.
ClienThread objects are identified by a numeric identifier.
parent | Parent thread; | |
lID | Numeric identifier. |
Definition at line 75 of file BaseThread.cc.
mcs::BaseThread::BaseThread | ( | Thread * | parent, | |
const char * | ltID | |||
) |
Constructor invoked from other objects.
The other objects are identified by a mnemonic string identifier.
parent | Parent thread; | |
ltID | String identifier. |
Definition at line 81 of file BaseThread.cc.
mcs::BaseThread::~BaseThread | ( | ) |
int mcs::BaseThread::chkExt | ( | string & | s | ) |
Check if an external program or script is registered in the configuration file.
The name (as registered in the configuration file) must be given as parameter. Upon return the parameter will contain the complete path to the real file.
An exception will be thrown if the external program or script is not registered in the configuration file or if the file type (as returned by ()) is fileType MCS_FT_UNKNOWN.
Definition at line 140 of file BaseThread.cc.
int mcs::BaseThread::fileType | ( | string | fn | ) | [static] |
Determine the file type of an external program or script.
This method is used when a user issue a MCS_CMD_EXEC command, to execute an external program or script, to determine the file type. Return value can be one of the following:
fn | Path to file. |
ERROR | MSG_CANT_OPEN_FILE. |
Definition at line 112 of file BaseThread.cc.
Logging facility.
e | Event object containing information about an event. |
Definition at line 29 of file BaseThread.cc.
BaseThread& mcs::BaseThread::operator= | ( | const BaseThread & | ) |
Declared to avoid using of default assignment operator.
int mcs::BaseThread::spawn | ( | string | fn, | |
string | pars, | |||
string | wpath = "." , |
|||
string | thrID = "x" , |
|||
string | user = "x" , |
|||
string | pass = "x" , |
|||
string | dbname = "x" , |
|||
string | fout = "out" , |
|||
string | ferr = "err" | |||
) | [static] |
Execute an external program or script in a dedicated environment.
This routine will create an environment with the following variables, the content of which can be specified via this method's parameters:
Then the external program or script will be executed in the directory specified in the "wpath" parameter, and its standard output and error will be captured in the files specified in the "fout" and "ferr" parameters.
Scripts will be executed under the "sh" shell. The "wpath", "fout", "ferr" parameters can be either absolute paths or path relative to the current working dir, that is what is returned by mcs::Pwd().
fn | Complete path to the program or script; | |
pars | Arguments to the program or script; | |
wpath | Directory where the program or script will be executed, also content of the PWD environment variable; | |
thrID | Content of the MCS_CID environment variable; | |
user | Content of the MCS_USER environment variable; | |
pass | Content of the MCS_PASS environment variable; | |
dbname | Content of the MCS_DBNAME environment variable; | |
fout | Path to the file that will contain the standard output result; | |
ferr | Path to the file that will contain the standard error result; |
Definition at line 159 of file BaseThread.cc.
const char * mcs::BaseThread::tid | ( | ) |
Env * mcs::BaseThread::env [static, protected] |
char mcs::BaseThread::tID[4] [private] |
![]() |
MCS (My Customizable Server) ver. 0.3.3-alpha3
|