mcs.hh File Reference


Detailed Description

Main include file for all MCS based applications.

Definition in file mcs.hh.

#include <netinet/in.h>
#include <string>
#include <iostream>
#include <vector>
#include <cstdlib>
#include "mcs_config.h"
#include <mysql.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <mcsmsg.hh>
#include "mcstypes.hh"

Include dependency graph for mcs.hh:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  mcs
namespace  std

Classes

class  mcs::B64_Codec
 A Base 64 encoder/decoder. More...
class  mcs::BaseThread
 Base class for MCS threaded objects. More...
class  mcs::Buffer
 High level buffer. More...
class  mcs::Client
 Connect to a MCS server as a client. More...
class  mcs::ClientInfo
 Class holding information about a client connection. More...
class  mcs::CommandParser
 Parse command lines. More...
class  mcs::Conf
 Read and write configuration files. More...
class  mcs::Data
 A general purpose data type. More...
class  mcs::DateTime
 A class to hold date time information. More...
class  mcs::DBConn
 Handle database connection. More...
class  mcs::Dynamic_Array< BASE >
 A thread safe, template class to handle an array of objects. More...
class  mcs::Env
 Hold all environment variables. More...
class  mcs::Event
 Hold informations about an event. More...
class  mcs::FITSReader
 Read a FITS file. More...
class  mcs::FITSWriter
 Write a fits file. More...
class  mcs::HostInfo
 Retrieve informations about a network host. More...
class  mcs::LocalThread
 Server side administrative thread. More...
class  mcs::NetInterface
 Retrieve informations about network interfaces. More...
class  mcs::Pipe
 A high level class to use system pipes. More...
class  mcs::Query
 Execute queries on the database. More...
class  mcs::Record
 A dynamic array of Data objects. More...
class  mcs::RecordSet
 The base class that implement the data abstraction layer. More...
class  mcs::Serializable
 Serialize memory buffers or files into chunks. More...
class  mcs::Server
 Main server class for a MCS-based application. More...
class  mcs::ServerSocket
 Manage TCP server sockets. More...
class  mcs::Socket
 Manage TCP sockets. More...
class  mcs::Synchro
 A simple class to implement "critical sections". More...
class  mcs::Table
 A class to directly set and retrieve value from a database table. More...
class  mcs::Thread
 A class to create separate threads. More...
class  mcs::ThreadFunc
class  mcs::ThreadSpecificData< BASE >
class  mcs::URLReader
 A class that provide a uniform access to file retrieving. More...
class  mcs::UserThread
 The server side client thread. More...

Defines

#define csz   c_str()
 Macro to extract a C-style, null terminated string from a string object.
#define DYNAMIC_ARRAY_DEFAULT_STEP   10
 Size of allocation block for the Dynamic_Array class.
#define MCS_(TYPE, rest...)   mcs::Event(__FILE__, __LINE__, TYPE , ## rest)
 Facility to easily pass all necessary parameter to an Event constructor.
#define MCS_B64_DECODE   1
#define MCS_B64_DECODEINPLACE   2
#define MCS_B64_DEF_LINE   72
#define MCS_B64_ENCODE   0
#define MCS_B64_MIN_LINE   4
#define MCS_BANNER   "\nMy Customizable Server (MCS) ver. " PACKAGE_VERSION "\n"
 MCS banner.
#define MCS_CLIENT_DATA   2
#define MCS_CLIENT_DISCONNECT   4
#define MCS_CLIENT_ERROR   1
#define MCS_CLIENT_FILE   3
#define MCS_CMD_CID   "CID"
 Command: Retrieve the Client identifier.
#define MCS_CMD_CID_HELP
#define MCS_CMD_CLIENT_INFO   "CLINFO"
 Command: Return server status information.
#define MCS_CMD_CLIENT_INFO_HELP   "Return all client informations."
#define MCS_CMD_CLOSECLIENT   "BYE"
 Command: Close the session.
#define MCS_CMD_CLOSECLIENT_HELP
#define MCS_CMD_DBCONNECT   "CON"
 Command: Finalize the authentication process and log in.
#define MCS_CMD_DBCONNECT_HELP
#define MCS_CMD_DBNAME   "DBN"
 Command: Provide the application (database) name.
#define MCS_CMD_DBNAME_HELP
#define MCS_CMD_EXEC   "EXEC"
 Command: Execute an external program, script, SQL or batch file.
#define MCS_CMD_EXEC_HELP
#define MCS_CMD_GET   "GET"
 Command: Download a file from the work directory.
#define MCS_CMD_GET_HELP
#define MCS_CMD_GETDATA   "GDATA"
 Command: Download Data objects.
#define MCS_CMD_GETDATA_HELP
#define MCS_CMD_MAX_TOKENS   100
 Max number of tokens for a command line.
#define MCS_CMD_NOP   "NOP"
 Command: No operation (dummy) command.
#define MCS_CMD_NOP_HELP   "No operation (dummy) command."
#define MCS_CMD_PASSWORD   "PWD"
 Command: Provide password.
#define MCS_CMD_PASSWORD_HELP
#define MCS_CMD_PUT   "PUT"
 Command: Upload a file to the work directory.
#define MCS_CMD_PUT_HELP
#define MCS_CMD_PUTDATA   "PDATA"
 Command: Upload Data objects.
#define MCS_CMD_PUTDATA_HELP
#define MCS_CMD_QUERY   "QRY"
 Command: Execute queries on the database.
#define MCS_CMD_QUERY_HELP
#define MCS_CMD_RECORD   "FETCH"
#define MCS_CMD_RECORD_HELP
#define MCS_CMD_SENDQUERYRES   "QRES"
 Command: Retrieve a file with an ASCII dump of the entire set of records returned by the last query.
#define MCS_CMD_SENDQUERYRES_HELP
#define MCS_CMD_TABLEINFO   "TINFO"
 Command: Retrieve information about a table.
#define MCS_CMD_TABLEINFO_HELP
#define MCS_CMD_TABLELIST   "TLIST"
 Command: Retrieve the list of tables actually present in the database.
#define MCS_CMD_TABLELIST_HELP
#define MCS_CMD_USERNAME   "USR"
 Command: Provide user name.
#define MCS_CMD_USERNAME_HELP
#define MCS_COMMBUFSIZE   1024
 Max length of a message being sent between client and server.
#define MCS_CRITICAL_SECTION(BLOCK...)
 Execute a list of commands inside a critical section.
#define MCS_CRITICAL_SECTION_BEGIN   enter(); try {
 Start a critical section, there must be no "return" or "goto" instruction inside the section.
#define MCS_CRITICAL_SECTION_END   } catch(Event e) { leave(); throw e; } leave();
 End a critical section, there must be no "return" or "goto" instruction inside the section.
#define MCS_CRITICAL_SECTION_END_RETURN(What...)
#define MCS_CUSTOM_LOCAL(CLASS)
#define MCS_CUSTOM_LOCAL_END(CLASS)   };
#define MCS_CUSTOM_SERVER(CLIENT, LOCAL)
 Macro to define a Server derived class, that works with UserThread and LocalThread derived objects.
#define MCS_CUSTOM_USER(CLASS)
 Wait for a MCS server termination.
#define MCS_CUSTOM_USER_END(CLASS)   };
#define MCS_DATA_NDIM   15
#define MCS_DEFAULT_CLIENT_TIMEOUT   10 * 60 * 1000
 Default client connection timeout, in milliseconds: 10 minutes.
#define MCS_DEFAULT_MAX_USERS   100
 Default max number of clients connected.
#define MCS_DEFAULT_PORT   6523
 Default port on which the server is listening.
#define MCS_DEFAULTCHUNKSIZE   16384
 File chunk size.
#define MCS_ERROR(A, rest...)   mcs::Event(__FILE__, __LINE__, mcs::ERROR, A, ## rest)
 Facility to easily pass all necessary parameter to an Event constructor.
#define MCS_FATAL(A, rest...)   mcs::Event(__FILE__, __LINE__, mcs::FATAL, A, ## rest)
 Facility to easily pass all necessary parameter to an Event constructor.
#define MCS_FT_BATCH   1
 Return value for BaseThread.fileType(), batch file.
#define MCS_FT_BIN   4
 Return value for BaseThread.fileType(), binary file.
#define MCS_FT_SCRIPT   3
 Return value for BaseThread.fileType(), script file.
#define MCS_FT_SQL   2
 Return value for BaseThread.fileType(), SQL file.
#define MCS_FT_UNKNOWN   0
 Return value for BaseThread.fileType(), unknown type.
#define MCS_GRANT_ADMIN   256
#define MCS_GRANT_ALL   511
#define MCS_GRANT_BATCH   16
#define MCS_GRANT_GET   32
#define MCS_GRANT_LOGIN   1
#define MCS_GRANT_NO_GRANTS   0
#define MCS_GRANT_PUT   64
#define MCS_GRANT_QUERY   8
#define MCS_GRANT_SCRIPTS   4
#define MCS_GRANT_SQL_SCRIPTS   2
#define MCS_GRANT_SYS   128
#define MCS_ID_CLIENT   -3
#define MCS_ID_LOCAL   -2
#define MCS_ID_UNKNOWN   -1
#define MCS_MISSING_ASSIGNMENT_OPERATOR(CLASS)   CLASS& operator=(const CLASS&);
#define MCS_MISSING_COPY_CONSTRUCTOR(CLASS)   CLASS(const CLASS&);
#define MCS_MKDIR_PROTECT   S_IRUSR | S_IWUSR | S_IXUSR
#define MCS_MKDIR_UMASK   0
#define MCS_OK(A, rest...)   mcs::Event(__FILE__, __LINE__, mcs::OK, A, ## rest)
 Facility to easily pass all necessary parameter to an Event constructor.
#define MCS_OPT_ALL_ERRORS   "werr"
 Option: Turns all warning into errors, so that a warning can stop the execution.
#define MCS_OPT_ALL_ERRORS_HELP
#define MCS_OPT_FORCE   "force"
 Option: Continue execution of commands even if an error occur.
#define MCS_OPT_FORCE_HELP
#define MCS_OPT_HELP   "help"
 Option: Return a quick help for a command or an option.
#define MCS_OPT_LOOP   "loop"
 Option: Put a copy of thr recevied Data object in the "send" vector.
#define MCS_OPT_LOOP_HELP
#define MCS_OPT_SAVEQUERYASCII   "sqascii"
 Option: Save query result in ASCII format.
#define MCS_OPT_SAVEQUERYASCII_HELP
#define MCS_OPT_SAVEQUERYFITS   "sqfits"
 Option: Save query result in FITS format.
#define MCS_OPT_SAVEQUERYFITS_HELP
#define MCS_PAB_INSERT   1
#define MCS_PAB_REPLACE   3
#define MCS_PAB_UPDATE   2
#define MCS_PRE   "#"
 Prefix of a message for the client, this is the first character.
#define MCS_PROMPT_ERROR   MCS_PRE "0E-"
 Prompt sent after a command raised one error.
#define MCS_PROMPT_OK   MCS_PRE "0--"
 Prompt sent after a command has been executed correctly.
#define MCS_PROMPT_WARN   MCS_PRE "0W-"
 Prompt sent after a command raised one or more warnings.
#define MCS_RS_ACCUM   1
 Flag for RecordSet::init().
#define MCS_RS_INSERT   16
 Flag for RecordSet::init().
#define MCS_RS_KNOW_NROWS   4
 Flag for RecordSet::init().
#define MCS_RS_RANDOM   8
 Flag for RecordSet::init().
#define MCS_RS_USEMETAREC   2
 Flag for RecordSet::init().
#define MCS_SELECT_READ   0
#define MCS_SELECT_WRITE   1
#define MCS_SEP   "|"
 This character is used to split a message into "fields".
#define MCS_SERIAL_BUFFER   1
#define MCS_SERIAL_FILENAME   2
#define MCS_SERIAL_UNKNOWN   0
#define MCS_SSLCERT   "mcscert.pem"
#define MCS_SSLPRIV   "mcspkey.pem"
#define MCS_STATE_CREATED   1
 Thread state: the object has been created ut the separate thread has not been started.
#define MCS_STATE_END   4
 Thread state: the separate thread had terminated its execution.
#define MCS_STATE_RUNNING   2
 Thread state: the separate thread is executing the run() method.
#define MCS_STATE_TERMINATING   3
 Thread state: the exit() method is executing, the separate thread is going to execute the final() method.
#define MCS_SUBST_LEADING   4
 To be used with subst(), substitute only if "what" is at the beginning. See subst().
#define MCS_SUBST_QUOTE_WITH   1
 To be used with subst(), doubles each backslash in "with". See subst().
#define MCS_SUBST_TRAILING   8
 To be used with subst(), substitute only if "what" is at the end. See subst().
#define MCS_SYNCHRO_LOCK   1
 To be used with Synchro.enter(): enter a critical section.
#define MCS_SYNCHRO_TRY_LOCK   2
 To be used with Synchro.enter(): try to enter a critical section.
#define MCS_SYNCHRO_TRY_TIMED   3
 To be used with Synchro.enter(): try to enter a critical section with timeout facility.
#define MCS_VMSG_SIZE   1000
 Size of the Event.vmsg static array.
#define MCS_WARN(A, rest...)   mcs::Event(__FILE__, __LINE__, mcs::WARN, A, ## rest)
 Facility to easily pass all necessary parameter to an Event constructor.
#define my_mempcpy(D, S, N)   ((void *) ((char *) memcpy (D, S, N) + (N)))
 Some systems doesn't have mempcpy, so we provide it here.
#define MYSQL_SOCK   NULL

Typedefs

typedef enum Types mcs::Types

Enumerations

enum  mcs::BufferFreeOnDestroy { mcs::AUTO_FREE, mcs::DONT_FREE }
 Values to be used in Buffer class constructor. More...
enum  mcs::RetValue { mcs::OK, mcs::WARN, mcs::ERROR, mcs::FATAL }
 Return value for MCS routines. More...
enum  mcs::ThrowExceptions { mcs::DONT_THROW, mcs::THROW }
 Values to be used with throwexc parameters. More...
enum  mcs::TimeMode { mcs::UTC, mcs::LOCAL }
 Enumerate operational mode for a DateTime object. More...
enum  mcs::Types {
  mcs::TINY, mcs::SMALL, mcs::MEDIUM, mcs::INT,
  mcs::BIGINT, mcs::FLOAT, mcs::DOUBLE, mcs::STRING,
  mcs::TIME, mcs::TINY_BLOB, mcs::BLOB, mcs::POINTER
}
 Enumeration of base type for Data. More...

Functions

string mcs::btos (bool b)
 Convert a boolean to a string containing "true" or "false".
string mcs::chomp (string s)
 Remove any trailing newlines.
int mcs::copy (char *OLDNAME, char *NEWNAME)
 Copy a file from OLDNAME to NEWNAME.
string mcs::dtos (double f)
 Convert an floating point number to a string.
int mcs::extractCode (const char *msg)
 Extract the numeric code from a server reply.
bool mcs::File_Dir_Exist (string fn, unsigned int &size)
 Check if a file or directory exists.
bool mcs::FITS2Types (int fits, Types &dbt, bool &isunsigned)
 Convert a FITSIO type into a MCS type.
string mcs::fitsError (int status)
 Return a description of a FITS error.
bool mcs::FloatType (Types type)
 Tell if "type" is a float type.
string mcs::hexDump (const void *buf, unsigned int size)
 Return a string with an hex dump of the buffer pointed by "buf", with a length of "size".
bool mcs::IntType (Types type)
 Tell if "type" is an integer type.
string mcs::itos (int i)
 Convert an integer to a string.
void mcs::ls2Record (string fn, Record &v)
 Fill a vector with a list of file.
Envmcs::mcsStart (string appname, string inipath="", Server *(*cb_newServer)(Env *)=NULL)
 Start a MCS server.
bool mcs::mkDir (string path, mode_t perm=0, enum ThrowExceptions throwexc=THROW)
 Create a directory.
int mcs::move (char *OLDNAME, char *NEWNAME)
 Move a file from OLDNAME to NEWNAME.
time_t mcs::my_timelocal (struct tm *tm)
string mcs::MYSQL2Str (enum_field_types type)
 Return the name of the MySQL type given in "type".
bool mcs::MYSQL2Types (enum_field_types mtype, Types &type)
 Convert a MySQL type into a MCS type.
string mcs::Pwd ()
 Return the current working dir.
mode_t mcs::read_umask ()
 Read the file creation mask of the current process.
string mcs::remLeading (string &s, const char *p)
 Remove any leading character "p".
string mcs::remTabs (string s)
 Remove any tab.
string mcs::remTrailing (string &s, const char *p)
 Remove any trailing character "p".
bool mcs::rmDir (string path, enum ThrowExceptions throwexc=THROW)
 Removes a directory.
int mcs::Select (int fd[], int nfd, unsigned int sec_timeout, unsigned int usec_timeout, int op)
int mcs::Select (int fd, unsigned int sec_timeout, unsigned int usec_timeout, int op)
void mcs::sleep_ms (unsigned int millisec)
 A millisecond resolution sleep function.
vector< string > mcs::split (string s, string sep=" ")
 Split a string into tokens.
int mcs::stoi (string s, int errval)
 Convert a string to an integer.
int mcs::stoi (string s)
 Convert a string to an integer.
string mcs::subst (string s, string what, string with, int op=0)
 Perform substitutions on a string.
string mcs::trim (string s)
 Remove any leading or trailing blanks.
bool mcs::Types2FITS (Types dbt, bool isunsigned, int &fits)
 Convert a MCS type into a FITSIO type.
bool mcs::Types2MYSQL (Types &type, enum_field_types &mtype)
 Convert a MCS type into a MySQL type.
string mcs::Types2MYSQLStr (Types &type, bool isunsigned)
 Convert a MCS type into a MySQL type.
bool mcs::Types2S_FITS (Types dbt, int len, bool isunsigned, string &fits)
 Convert a MCS type into a FITSIO type code.
string mcs::Types2Str (Types type, bool isunsigned)
 Return the name of the type given in "type" and "isunsigned".
bool mcs::VarLenType (Types type)
 Tell if "type" is a variable length type.
string mcs::vtos (vector< string > vec)
 Join a vector of strings in a single string using newlines.


Define Documentation

#define csz   c_str()

Macro to extract a C-style, null terminated string from a string object.

Definition at line 527 of file mcs.hh.

#define DYNAMIC_ARRAY_DEFAULT_STEP   10

Size of allocation block for the Dynamic_Array class.

Definition at line 3815 of file mcs.hh.

#define MCS_ ( TYPE,
rest...   )     mcs::Event(__FILE__, __LINE__, TYPE , ## rest)

Facility to easily pass all necessary parameter to an Event constructor.

Definition at line 1011 of file mcs.hh.

#define MCS_BANNER   "\nMy Customizable Server (MCS) ver. " PACKAGE_VERSION "\n"

MCS banner.

Definition at line 204 of file mcs.hh.

#define MCS_CMD_CID   "CID"

Command: Retrieve the Client identifier.

Definition at line 299 of file mcs.hh.

#define MCS_CMD_CID_HELP

Value:

"Retrieve the Client identifier.\n" \
                                        "CID"

Definition at line 300 of file mcs.hh.

#define MCS_CMD_CLIENT_INFO   "CLINFO"

Command: Return server status information.

Definition at line 268 of file mcs.hh.

#define MCS_CMD_CLOSECLIENT   "BYE"

Command: Close the session.

Definition at line 294 of file mcs.hh.

#define MCS_CMD_CLOSECLIENT_HELP

Value:

"Close the session.\n" \
                                        "BYE"

Definition at line 295 of file mcs.hh.

#define MCS_CMD_DBCONNECT   "CON"

Command: Finalize the authentication process and log in.

Definition at line 289 of file mcs.hh.

#define MCS_CMD_DBCONNECT_HELP

Value:

"Finalize the authentication process and log in.\n" \
                                        "CON"

Definition at line 290 of file mcs.hh.

#define MCS_CMD_DBNAME   "DBN"

Command: Provide the application (database) name.

Definition at line 283 of file mcs.hh.

#define MCS_CMD_DBNAME_HELP

Value:

"Supply application (database) name.\n" \
                                        "DBN <application_name>"

Definition at line 284 of file mcs.hh.

#define MCS_CMD_EXEC   "EXEC"

Command: Execute an external program, script, SQL or batch file.

Definition at line 383 of file mcs.hh.

#define MCS_CMD_EXEC_HELP

Value:

"Execute an external program, SQL or batch file.\n" \
                                        "EXEC <alias> [[PAR1] [PAR2] ...]"

Definition at line 384 of file mcs.hh.

#define MCS_CMD_GET   "GET"

Command: Download a file from the work directory.

Definition at line 388 of file mcs.hh.

#define MCS_CMD_GET_HELP

Value:

"Download a file from the work directory.\n" \
                                        "GET <filename>"

Definition at line 389 of file mcs.hh.

#define MCS_CMD_GETDATA   "GDATA"

Command: Download Data objects.

Definition at line 398 of file mcs.hh.

#define MCS_CMD_GETDATA_HELP

Value:

"Download Data objects.\n" \
                                        "GDATA <position>"

Definition at line 399 of file mcs.hh.

#define MCS_CMD_MAX_TOKENS   100

Max number of tokens for a command line.

Definition at line 5132 of file mcs.hh.

#define MCS_CMD_NOP   "NOP"

Command: No operation (dummy) command.

Definition at line 263 of file mcs.hh.

#define MCS_CMD_PASSWORD   "PWD"

Command: Provide password.

Definition at line 278 of file mcs.hh.

#define MCS_CMD_PASSWORD_HELP

Value:

"Supply password.\n"  \
                                        "PWD <password>"

Definition at line 279 of file mcs.hh.

#define MCS_CMD_PUT   "PUT"

Command: Upload a file to the work directory.

Definition at line 393 of file mcs.hh.

#define MCS_CMD_PUT_HELP

Value:

"Upload a file to the work directory.\n" \
                                        "PUT <filename> <size>"

Definition at line 394 of file mcs.hh.

#define MCS_CMD_PUTDATA   "PDATA"

Command: Upload Data objects.

Definition at line 403 of file mcs.hh.

#define MCS_CMD_PUTDATA_HELP

Value:

"Upload Data objects.\n" \
                                        "PDATA <size>"

Definition at line 404 of file mcs.hh.

#define MCS_CMD_QUERY   "QRY"

Command: Execute queries on the database.

Definition at line 320 of file mcs.hh.

#define MCS_CMD_QUERY_HELP

Value:

"Execute queries on the database.\n" \
                                        "QRY <SQL query>"

Definition at line 321 of file mcs.hh.

#define MCS_CMD_RECORD   "FETCH"

Command: Retrieve the record at a specified position, or at current position (if none is specified) of the last query executed.

Definition at line 309 of file mcs.hh.

#define MCS_CMD_RECORD_HELP

Value:

"Retrieve the record at a specified position, or at\n" \
                                        "current position (if none is specified) of the last\n" \
                                        "query executed.\n" \
                                        "FETCH [position]"

Definition at line 310 of file mcs.hh.

#define MCS_CMD_SENDQUERYRES   "QRES"

Command: Retrieve a file with an ASCII dump of the entire set of records returned by the last query.

Definition at line 325 of file mcs.hh.

#define MCS_CMD_SENDQUERYRES_HELP

Value:

"Retrieve a file with an ASCII dump of the entire set\n" \
                                        "of records returned by the last query." \
                                        "QRES"

Definition at line 326 of file mcs.hh.

#define MCS_CMD_TABLEINFO   "TINFO"

Command: Retrieve information about a table.

Definition at line 338 of file mcs.hh.

#define MCS_CMD_TABLEINFO_HELP

Value:

"Retrieve information about a table.\n" \
                                        "TINFO"

Definition at line 339 of file mcs.hh.

#define MCS_CMD_TABLELIST   "TLIST"

Command: Retrieve the list of tables actually present in the database.

Definition at line 332 of file mcs.hh.

#define MCS_CMD_TABLELIST_HELP

Value:

"Retrieve the list of tables actually present in the\n" \
                                        "database.\n" \
                                        "TLIST"

Definition at line 333 of file mcs.hh.

#define MCS_CMD_USERNAME   "USR"

Command: Provide user name.

Definition at line 273 of file mcs.hh.

#define MCS_CMD_USERNAME_HELP

Value:

"Supply user name.\n" \
                                        "USR <user_name>"

Definition at line 274 of file mcs.hh.

#define MCS_COMMBUFSIZE   1024

Max length of a message being sent between client and server.

Definition at line 182 of file mcs.hh.

#define MCS_CRITICAL_SECTION ( BLOCK...   ) 

Value:

Execute a list of commands inside a critical section.

There must be no "return" or "goto" instruction inside the section.

Definition at line 2420 of file mcs.hh.

#define MCS_CRITICAL_SECTION_BEGIN   enter(); try {

Start a critical section, there must be no "return" or "goto" instruction inside the section.

Definition at line 2403 of file mcs.hh.

#define MCS_CRITICAL_SECTION_END   } catch(Event e) { leave(); throw e; } leave();

End a critical section, there must be no "return" or "goto" instruction inside the section.

Definition at line 2407 of file mcs.hh.

#define MCS_CRITICAL_SECTION_END_RETURN ( What...   ) 

Value:

leave(); return What; }                           \
catch(Event e) { leave(); throw e; }

Definition at line 2409 of file mcs.hh.

#define MCS_CUSTOM_LOCAL ( CLASS   ) 

Value:

class CLASS : public mcs::LocalThread                     \
{                                     \
public:                                   \
    CLASS(mcs::Thread* p) :                                           \
    LocalThread(p) {}                             \
    ~CLASS() {}

Definition at line 7446 of file mcs.hh.

#define MCS_CUSTOM_SERVER ( CLIENT,
LOCAL   ) 

Value:

mcs::Server* newCustomServer(mcs::Env* env);                          \
                                      \
class mcsCustomServer : public mcs::Server                            \
{                                                     \
private:                                                              \
    mcs::UserThread* newUserThread(int id, int sock) {                \
    return new CLIENT(this, id, sock);                \
    }                                     \
                                      \
    mcs::LocalThread* newLocalThread() {                              \
    return new LOCAL(this);                           \
    }                                     \
                                      \
public:                                   \
    mcsCustomServer(mcs::Env* lenv): Server(lenv) {}              \
                                      \
    ~mcsCustomServer() {}                                             \
};                                                                    \
                                                                      \
mcs::Server* newCustomServer(Env* env)                                \
{  return new mcsCustomServer(env); }                                 \
                                                                      \
mcs::Env* mcsCustomStart(string appname, string inipath = "")         \
{ return mcsStart(appname, inipath, &newCustomServer); }
Macro to define a Server derived class, that works with UserThread and LocalThread derived objects.

The UserThread and LocalThread derived classes must have the same constructors as the parents classes. Remember that this class simply defines a new class, it doesn't istantiate any object.

Parameters:
CLASS The newly defined class name;
CLIENT The UserThread derived class name;
LOCAL The LocalThread derived class name.
EXTRA Extra code added inside the server class definition.

Definition at line 7469 of file mcs.hh.

#define MCS_CUSTOM_USER ( CLASS   ) 

Value:

class CLASS : public mcs::UserThread                          \
{                                     \
public:                                   \
    CLASS(mcs::Thread* p, int id, int sock) :                     \
    UserThread(p, id, sock) {}                        \
    ~CLASS() {}
Wait for a MCS server termination.

The Server termination will occur if the object terminate spontaneously (see Sever class documentation). This function install a signal handler for the SIGINT, SIGQUIT and SIGTERM signals, so termination will occur also if one of these signals is received by the application.

This function simply waits for the server termination, once this occurr it destroy the Env object and then returns. A typical use of this function is in the main program, toghether with the mcsStart() function:

  #include <mcs.hh>
  using namespace mcs;

  int main(int argc, char* argv[])
  {
    mcsStart("myApp");  //...or mcsCustomStart()
  }

Parameters:
env Address of a valid Env object.
Note:
If you run the example shown above in a terminal, and you press CTRL-C the application will receive a SIGINT signal, so it will terminate the server, then exit.

Definition at line 7436 of file mcs.hh.

#define MCS_DEFAULT_CLIENT_TIMEOUT   10 * 60 * 1000

Default client connection timeout, in milliseconds: 10 minutes.

Definition at line 178 of file mcs.hh.

#define MCS_DEFAULT_MAX_USERS   100

Default max number of clients connected.

Definition at line 174 of file mcs.hh.

#define MCS_DEFAULT_PORT   6523

Default port on which the server is listening.

Definition at line 161 of file mcs.hh.

#define MCS_DEFAULTCHUNKSIZE   16384

File chunk size.

When a file is going to be sent or received it will be splitted in chunks of this size.

Definition at line 170 of file mcs.hh.

#define MCS_ERROR ( A,
rest...   )     mcs::Event(__FILE__, __LINE__, mcs::ERROR, A, ## rest)

Facility to easily pass all necessary parameter to an Event constructor.

Definition at line 1005 of file mcs.hh.

#define MCS_FATAL ( A,
rest...   )     mcs::Event(__FILE__, __LINE__, mcs::FATAL, A, ## rest)

Facility to easily pass all necessary parameter to an Event constructor.

Definition at line 1008 of file mcs.hh.

#define MCS_FT_BATCH   1

Return value for BaseThread.fileType(), batch file.

Definition at line 6269 of file mcs.hh.

#define MCS_FT_BIN   4

Return value for BaseThread.fileType(), binary file.

Definition at line 6278 of file mcs.hh.

#define MCS_FT_SCRIPT   3

Return value for BaseThread.fileType(), script file.

Definition at line 6275 of file mcs.hh.

#define MCS_FT_SQL   2

Return value for BaseThread.fileType(), SQL file.

Definition at line 6272 of file mcs.hh.

#define MCS_FT_UNKNOWN   0

Return value for BaseThread.fileType(), unknown type.

Definition at line 6266 of file mcs.hh.

#define MCS_OK ( A,
rest...   )     mcs::Event(__FILE__, __LINE__, mcs::OK, A, ## rest)

Facility to easily pass all necessary parameter to an Event constructor.

Definition at line 999 of file mcs.hh.

#define MCS_OPT_ALL_ERRORS   "werr"

Option: Turns all warning into errors, so that a warning can stop the execution.

Definition at line 367 of file mcs.hh.

#define MCS_OPT_ALL_ERRORS_HELP

Value:

"Turns all warning into errors, so that a warning can\n" \
                    "stop the execution.\n" \
                                        "-werr"

Definition at line 368 of file mcs.hh.

#define MCS_OPT_FORCE   "force"

Option: Continue execution of commands even if an error occur.

Definition at line 361 of file mcs.hh.

#define MCS_OPT_FORCE_HELP

Value:

"Continue execution of commands even if an error\n" \
                                        "occurred.\n" \
                                        "-force"

Definition at line 362 of file mcs.hh.

#define MCS_OPT_HELP   "help"

Option: Return a quick help for a command or an option.

Definition at line 379 of file mcs.hh.

#define MCS_OPT_LOOP   "loop"

Option: Put a copy of thr recevied Data object in the "send" vector.

Definition at line 373 of file mcs.hh.

#define MCS_OPT_LOOP_HELP

Value:

"Put a copy of thr recevied Data object in the \n" \
                                        "\"send\" vector.\n" \
                                        "-loop"

Definition at line 374 of file mcs.hh.

#define MCS_OPT_SAVEQUERYASCII   "sqascii"

Option: Save query result in ASCII format.

Definition at line 355 of file mcs.hh.

#define MCS_OPT_SAVEQUERYASCII_HELP

Value:

"Save query result in ASCII format.\n"  \
                                        "-sqascii"

Definition at line 356 of file mcs.hh.

#define MCS_OPT_SAVEQUERYFITS   "sqfits"

Option: Save query result in FITS format.

Definition at line 350 of file mcs.hh.

#define MCS_OPT_SAVEQUERYFITS_HELP

Value:

"Save query result in FITS format.\n " \
                                        "-sqfits"

Definition at line 351 of file mcs.hh.

#define MCS_PRE   "#"

Prefix of a message for the client, this is the first character.

Definition at line 242 of file mcs.hh.

#define MCS_PROMPT_ERROR   MCS_PRE "0E-"

Prompt sent after a command raised one error.

Definition at line 254 of file mcs.hh.

#define MCS_PROMPT_OK   MCS_PRE "0--"

Prompt sent after a command has been executed correctly.

Definition at line 248 of file mcs.hh.

#define MCS_PROMPT_WARN   MCS_PRE "0W-"

Prompt sent after a command raised one or more warnings.

Definition at line 251 of file mcs.hh.

#define MCS_RS_ACCUM   1

Flag for RecordSet::init().

If this flag is set then all records will be fetched when the startFetch() method is called.

Setting this flag implies that the MCS_RS_RANDOM and MCS_RS_KNOW_NROWS flags are also set.

Definition at line 4452 of file mcs.hh.

#define MCS_RS_INSERT   16

Flag for RecordSet::init().

If this flag is set then the RecordSet object will work in "insert" mode, that is all records will be inserted in the set using the insert() method.

Setting this flag implies that the MCS_RS_ACCUM, MCS_RS_RANDOM and MCS_RS_KNOW_NROWS flags are also set.

Definition at line 4495 of file mcs.hh.

#define MCS_RS_KNOW_NROWS   4

Flag for RecordSet::init().

If this flag is set then the number of records in the set is known and can be retrieved through the nRows() method.

Definition at line 4472 of file mcs.hh.

#define MCS_RS_RANDOM   8

Flag for RecordSet::init().

If this flag is set then the object provide a random access to the set, that is the methods setFirst, setLast, setPos, etc... can be used to locte a particular record.

Definition at line 4481 of file mcs.hh.

#define MCS_RS_USEMETAREC   2

Flag for RecordSet::init().

If this flag is set then all records in the set will have the same structure based on the metarec object. When a call to the overrided fetch() method is performed the internal Record object (accessible throught the rec() method) will already contain an empty structure which is a copy of the metarec object.

Definition at line 4464 of file mcs.hh.

#define MCS_SEP   "|"

This character is used to split a message into "fields".

Definition at line 245 of file mcs.hh.

#define MCS_STATE_CREATED   1

Thread state: the object has been created ut the separate thread has not been started.

Definition at line 2433 of file mcs.hh.

#define MCS_STATE_END   4

Thread state: the separate thread had terminated its execution.

Definition at line 2442 of file mcs.hh.

#define MCS_STATE_RUNNING   2

Thread state: the separate thread is executing the run() method.

Definition at line 2436 of file mcs.hh.

#define MCS_STATE_TERMINATING   3

Thread state: the exit() method is executing, the separate thread is going to execute the final() method.

Definition at line 2439 of file mcs.hh.

#define MCS_SUBST_LEADING   4

To be used with subst(), substitute only if "what" is at the beginning. See subst().

Definition at line 543 of file mcs.hh.

#define MCS_SUBST_QUOTE_WITH   1

To be used with subst(), doubles each backslash in "with". See subst().

Definition at line 540 of file mcs.hh.

#define MCS_SUBST_TRAILING   8

To be used with subst(), substitute only if "what" is at the end. See subst().

Definition at line 546 of file mcs.hh.

#define MCS_SYNCHRO_LOCK   1

To be used with Synchro.enter(): enter a critical section.

Definition at line 2288 of file mcs.hh.

#define MCS_SYNCHRO_TRY_LOCK   2

To be used with Synchro.enter(): try to enter a critical section.

Definition at line 2291 of file mcs.hh.

#define MCS_SYNCHRO_TRY_TIMED   3

To be used with Synchro.enter(): try to enter a critical section with timeout facility.

Definition at line 2294 of file mcs.hh.

#define MCS_VMSG_SIZE   1000

Size of the Event.vmsg static array.

Definition at line 771 of file mcs.hh.

#define MCS_WARN ( A,
rest...   )     mcs::Event(__FILE__, __LINE__, mcs::WARN, A, ## rest)

Facility to easily pass all necessary parameter to an Event constructor.

Definition at line 1002 of file mcs.hh.

#define my_mempcpy ( D,
S,
 )     ((void *) ((char *) memcpy (D, S, N) + (N)))

Some systems doesn't have mempcpy, so we provide it here.

Definition at line 531 of file mcs.hh.


mcslogo

MCS (My Customizable Server) ver. 0.3.3-alpha3
Documentation generated on Thu Mar 22 13:22:23 UTC 2012