MCS  0.3.3-alpha7
mcs.hh File Reference

Main include file for all MCS based applications. More...

#include <netinet/in.h>
#include <string>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include "mcs_config.h"
#include <mysql.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.

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::UserThread
 The server side client thread. More...
 

Namespaces

 mcs
 Namespace for MCS library.
 

Macros

#define BEEP   "\x7"
 
#define BGBLUE   "\x1B[44m"
 
#define BLUE   "\x1B[34m"
 
#define CLEANS   "\x1B[2J"
 
#define csz   c_str()
 Macro to extract a C-style, null terminated string from a string object. More...
 
#define CYAN   "\x1B[36m"
 
#define DYNAMIC_ARRAY_DEFAULT_STEP   10
 Size of allocation block for the Dynamic_Array class. More...
 
#define GREEN   "\x1B[32m"
 
#define MAGENTA   "\x1B[35m"
 
#define MCS_(TYPE, rest...)   mcs::Event(__FILE__, __LINE__, TYPE , ## rest)
 Facility to easily pass all necessary parameter to an Event constructor. More...
 
#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. More...
 
#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. More...
 
#define MCS_CMD_CID_HELP
 
#define MCS_CMD_CLIENT_INFO   "CLINFO"
 Command: Return server status information. More...
 
#define MCS_CMD_CLIENT_INFO_HELP   "Return all client informations."
 
#define MCS_CMD_CLOSECLIENT   "BYE"
 Command: Close the session. More...
 
#define MCS_CMD_CLOSECLIENT_HELP
 
#define MCS_CMD_DBCONNECT   "CON"
 Command: Finalize the authentication process and log in. More...
 
#define MCS_CMD_DBCONNECT_HELP
 
#define MCS_CMD_DBNAME   "DBN"
 Command: Provide the application (database) name. More...
 
#define MCS_CMD_DBNAME_HELP
 
#define MCS_CMD_EXEC   "EXEC"
 Command: Execute an external program, script, SQL or batch file. More...
 
#define MCS_CMD_EXEC_HELP
 
#define MCS_CMD_GET   "GET"
 Command: Download a file from the work directory. More...
 
#define MCS_CMD_GET_HELP
 
#define MCS_CMD_GETDATA   "GDATA"
 Command: Download Data objects. More...
 
#define MCS_CMD_GETDATA_HELP
 
#define MCS_CMD_MAX_TOKENS   100
 Max number of tokens for a command line. More...
 
#define MCS_CMD_NOP   "NOP"
 Command: No operation (dummy) command. More...
 
#define MCS_CMD_NOP_HELP   "No operation (dummy) command."
 
#define MCS_CMD_PASSWORD   "PWD"
 Command: Provide password. More...
 
#define MCS_CMD_PASSWORD_HELP
 
#define MCS_CMD_PUT   "PUT"
 Command: Upload a file to the work directory. More...
 
#define MCS_CMD_PUT_HELP
 
#define MCS_CMD_PUTDATA   "PDATA"
 Command: Upload Data objects. More...
 
#define MCS_CMD_PUTDATA_HELP
 
#define MCS_CMD_QUERY   "QRY"
 Command: Execute queries on the database. More...
 
#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. More...
 
#define MCS_CMD_SENDQUERYRES_HELP
 
#define MCS_CMD_TABLEINFO   "TINFO"
 Command: Retrieve information about a table. More...
 
#define MCS_CMD_TABLEINFO_HELP
 
#define MCS_CMD_TABLELIST   "TLIST"
 Command: Retrieve the list of tables actually present in the database. More...
 
#define MCS_CMD_TABLELIST_HELP
 
#define MCS_CMD_USERNAME   "USR"
 Command: Provide user name. More...
 
#define MCS_CMD_USERNAME_HELP
 
#define MCS_COMMBUFSIZE   1024
 Max length of a message being sent between client and server. More...
 
#define MCS_CRITICAL_SECTION(BLOCK...)
 Execute a list of commands inside a critical section. More...
 
#define MCS_CRITICAL_SECTION_BEGIN   enter(); try {
 Start a critical section, there must be no "return" or "goto" instruction inside the section. More...
 
#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. More...
 
#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. More...
 
#define MCS_CUSTOM_USER(CLASS)
 Wait for a MCS server termination. More...
 
#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. More...
 
#define MCS_DEFAULT_MAX_USERS   100
 Default max number of clients connected. More...
 
#define MCS_DEFAULT_PORT   6523
 Default port on which the server is listening. More...
 
#define MCS_DEFAULTCHUNKSIZE   16384
 File chunk size. More...
 
#define MCS_ERROR(A, rest...)   mcs::Event(__FILE__, __LINE__, mcs::ERROR, A, ## rest)
 Facility to easily pass all necessary parameter to an Event constructor. More...
 
#define MCS_FATAL(A, rest...)   mcs::Event(__FILE__, __LINE__, mcs::FATAL, A, ## rest)
 Facility to easily pass all necessary parameter to an Event constructor. More...
 
#define MCS_FT_BATCH   1
 Return value for BaseThread.fileType(), batch file. More...
 
#define MCS_FT_BIN   4
 Return value for BaseThread.fileType(), binary file. More...
 
#define MCS_FT_SCRIPT   3
 Return value for BaseThread.fileType(), script file. More...
 
#define MCS_FT_SQL   2
 Return value for BaseThread.fileType(), SQL file. More...
 
#define MCS_FT_UNKNOWN   0
 Return value for BaseThread.fileType(), unknown type. More...
 
#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. More...
 
#define MCS_OPT_ALL_ERRORS   "werr"
 Option: Turns all warning into errors, so that a warning can stop the execution. More...
 
#define MCS_OPT_ALL_ERRORS_HELP
 
#define MCS_OPT_FORCE   "force"
 Option: Continue execution of commands even if an error occur. More...
 
#define MCS_OPT_FORCE_HELP
 
#define MCS_OPT_HELP   "help"
 Option: Return a quick help for a command or an option. More...
 
#define MCS_OPT_LOOP   "loop"
 Option: Put a copy of thr recevied Data object in the "send" vector. More...
 
#define MCS_OPT_LOOP_HELP
 
#define MCS_OPT_SAVEQUERYASCII   "sqascii"
 Option: Save query result in ASCII format. More...
 
#define MCS_OPT_SAVEQUERYASCII_HELP
 
#define MCS_OPT_SAVEQUERYFITS   "sqfits"
 Option: Save query result in FITS format. More...
 
#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. More...
 
#define MCS_PROMPT_ERROR   MCS_PRE "0E-"
 Prompt sent after a command raised one error. More...
 
#define MCS_PROMPT_OK   MCS_PRE "0--"
 Prompt sent after a command has been executed correctly. More...
 
#define MCS_PROMPT_WARN   MCS_PRE "0W-"
 Prompt sent after a command raised one or more warnings. More...
 
#define MCS_RS_ACCUM   1
 Flag for RecordSet::init(). More...
 
#define MCS_RS_INSERT   16
 Flag for RecordSet::init(). More...
 
#define MCS_RS_KNOW_NROWS   4
 Flag for RecordSet::init(). More...
 
#define MCS_RS_RANDOM   8
 Flag for RecordSet::init(). More...
 
#define MCS_RS_USEMETAREC   2
 Flag for RecordSet::init(). More...
 
#define MCS_SELECT_READ   0
 
#define MCS_SELECT_WRITE   1
 
#define MCS_SEP   "|"
 This character is used to split a message into "fields". More...
 
#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. More...
 
#define MCS_STATE_END   4
 Thread state: the separate thread had terminated its execution. More...
 
#define MCS_STATE_RUNNING   2
 Thread state: the separate thread is executing the run() method. More...
 
#define MCS_STATE_TERMINATING   3
 Thread state: the exit() method is executing, the separate thread is going to execute the final() method. More...
 
#define MCS_SUBST_LEADING   4
 To be used with subst(), substitute only if "what" is at the beginning. See subst(). More...
 
#define MCS_SUBST_QUOTE_WITH   1
 To be used with subst(), doubles each backslash in "with". See subst(). More...
 
#define MCS_SUBST_TRAILING   8
 To be used with subst(), substitute only if "what" is at the end. See subst(). More...
 
#define MCS_SYNCHRO_LOCK   1
 To be used with Synchro.enter(): enter a critical section. More...
 
#define MCS_SYNCHRO_TRY_LOCK   2
 To be used with Synchro.enter(): try to enter a critical section. More...
 
#define MCS_SYNCHRO_TRY_TIMED   3
 To be used with Synchro.enter(): try to enter a critical section with timeout facility. More...
 
#define MCS_VMSG_SIZE   1000
 Size of the Event.vmsg static array. More...
 
#define MCS_WARN(A, rest...)   mcs::Event(__FILE__, __LINE__, mcs::WARN, A, ## rest)
 Facility to easily pass all necessary parameter to an Event constructor. More...
 
#define MERROR   std::cerr << RED << "\r(E)\t"<< GREEN << __FILE__ << "," << __LINE__ << NORMAL << "\t" <<TBOLD<<__FUNCTION__<<NORMAL << "\t"
 
#define MINFO   std::cout << BLUE << "\r(I)\t"<< GREEN << __FILE__ << "," << __LINE__ << NORMAL << "\t" <<TBOLD<<__FUNCTION__<<NORMAL << "\t"
 
#define MWARN   std::cout << YELLOW << "\r(W)\t"<< GREEN << __FILE__ << "," << __LINE__ << NORMAL << "\t" <<TBOLD<<__FUNCTION__<<NORMAL << "\t"
 
#define my_mempcpy(D, S, N)   ((void *) ((char *) memcpy (D, S, N) + (N)))
 Some systems doesn't have mempcpy, so we provide it here. More...
 
#define MYSQL_SOCK   NULL
 
#define NORMAL   "\x1B[0m"
 
#define RED   "\x1B[31m"
 
#define REV   "\x1B[7m"
 
#define TBOLD   "\x1B[1m"
 
#define YELLOW   "\x1B[33m"
 

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 { UTC, 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, POINTER
}
 Enumeration of base type for Data. More...
 

Functions

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

Detailed Description

Main include file for all MCS based applications.

Definition in file mcs.hh.

Macro Definition Documentation

◆ csz

#define csz   c_str()

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

Definition at line 486 of file mcs.hh.

◆ DYNAMIC_ARRAY_DEFAULT_STEP

#define DYNAMIC_ARRAY_DEFAULT_STEP   10

Size of allocation block for the Dynamic_Array class.

Definition at line 3800 of file mcs.hh.

◆ MCS_

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

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

Definition at line 970 of file mcs.hh.

◆ MCS_BANNER

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

MCS banner.

Definition at line 232 of file mcs.hh.

◆ MCS_CMD_CID

#define MCS_CMD_CID   "CID"

Command: Retrieve the Client identifier.

Definition at line 327 of file mcs.hh.

◆ MCS_CMD_CID_HELP

#define MCS_CMD_CID_HELP
Value:
"Retrieve the Client identifier.\n" \
"CID"

Definition at line 328 of file mcs.hh.

◆ MCS_CMD_CLIENT_INFO

#define MCS_CMD_CLIENT_INFO   "CLINFO"

Command: Return server status information.

Definition at line 296 of file mcs.hh.

◆ MCS_CMD_CLOSECLIENT

#define MCS_CMD_CLOSECLIENT   "BYE"

Command: Close the session.

Definition at line 322 of file mcs.hh.

◆ MCS_CMD_CLOSECLIENT_HELP

#define MCS_CMD_CLOSECLIENT_HELP
Value:
"Close the session.\n" \
"BYE"

Definition at line 323 of file mcs.hh.

◆ MCS_CMD_DBCONNECT

#define MCS_CMD_DBCONNECT   "CON"

Command: Finalize the authentication process and log in.

Definition at line 317 of file mcs.hh.

◆ MCS_CMD_DBCONNECT_HELP

#define MCS_CMD_DBCONNECT_HELP
Value:
"Finalize the authentication process and log in.\n" \
"CON"

Definition at line 318 of file mcs.hh.

◆ MCS_CMD_DBNAME

#define MCS_CMD_DBNAME   "DBN"

Command: Provide the application (database) name.

Definition at line 311 of file mcs.hh.

◆ MCS_CMD_DBNAME_HELP

#define MCS_CMD_DBNAME_HELP
Value:
"Supply application (database) name.\n" \
"DBN <application_name>"

Definition at line 312 of file mcs.hh.

◆ MCS_CMD_EXEC

#define MCS_CMD_EXEC   "EXEC"

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

Definition at line 411 of file mcs.hh.

◆ MCS_CMD_EXEC_HELP

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

Definition at line 412 of file mcs.hh.

◆ MCS_CMD_GET

#define MCS_CMD_GET   "GET"

Command: Download a file from the work directory.

Definition at line 416 of file mcs.hh.

◆ MCS_CMD_GET_HELP

#define MCS_CMD_GET_HELP
Value:
"Download a file from the work directory.\n" \
"GET <filename>"

Definition at line 417 of file mcs.hh.

◆ MCS_CMD_GETDATA

#define MCS_CMD_GETDATA   "GDATA"

Command: Download Data objects.

Definition at line 426 of file mcs.hh.

◆ MCS_CMD_GETDATA_HELP

#define MCS_CMD_GETDATA_HELP
Value:
"Download Data objects.\n" \
"GDATA <position>"

Definition at line 427 of file mcs.hh.

◆ MCS_CMD_MAX_TOKENS

#define MCS_CMD_MAX_TOKENS   100

Max number of tokens for a command line.

Definition at line 5117 of file mcs.hh.

◆ MCS_CMD_NOP

#define MCS_CMD_NOP   "NOP"

Command: No operation (dummy) command.

Definition at line 291 of file mcs.hh.

◆ MCS_CMD_PASSWORD

#define MCS_CMD_PASSWORD   "PWD"

Command: Provide password.

Definition at line 306 of file mcs.hh.

◆ MCS_CMD_PASSWORD_HELP

#define MCS_CMD_PASSWORD_HELP
Value:
"Supply password.\n" \
"PWD <password>"

Definition at line 307 of file mcs.hh.

◆ MCS_CMD_PUT

#define MCS_CMD_PUT   "PUT"

Command: Upload a file to the work directory.

Definition at line 421 of file mcs.hh.

◆ MCS_CMD_PUT_HELP

#define MCS_CMD_PUT_HELP
Value:
"Upload a file to the work directory.\n" \
"PUT <filename> <size>"

Definition at line 422 of file mcs.hh.

◆ MCS_CMD_PUTDATA

#define MCS_CMD_PUTDATA   "PDATA"

Command: Upload Data objects.

Definition at line 431 of file mcs.hh.

◆ MCS_CMD_PUTDATA_HELP

#define MCS_CMD_PUTDATA_HELP
Value:
"Upload Data objects.\n" \
"PDATA <size>"

Definition at line 432 of file mcs.hh.

◆ MCS_CMD_QUERY

#define MCS_CMD_QUERY   "QRY"

Command: Execute queries on the database.

Definition at line 348 of file mcs.hh.

◆ MCS_CMD_QUERY_HELP

#define MCS_CMD_QUERY_HELP
Value:
"Execute queries on the database.\n" \
"QRY <SQL query>"

Definition at line 349 of file mcs.hh.

◆ MCS_CMD_RECORD

#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 337 of file mcs.hh.

◆ MCS_CMD_RECORD_HELP

#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 338 of file mcs.hh.

◆ MCS_CMD_SENDQUERYRES

#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 353 of file mcs.hh.

◆ MCS_CMD_SENDQUERYRES_HELP

#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 354 of file mcs.hh.

◆ MCS_CMD_TABLEINFO

#define MCS_CMD_TABLEINFO   "TINFO"

Command: Retrieve information about a table.

Definition at line 366 of file mcs.hh.

◆ MCS_CMD_TABLEINFO_HELP

#define MCS_CMD_TABLEINFO_HELP
Value:
"Retrieve information about a table.\n" \
"TINFO"

Definition at line 367 of file mcs.hh.

◆ MCS_CMD_TABLELIST

#define MCS_CMD_TABLELIST   "TLIST"

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

Definition at line 360 of file mcs.hh.

◆ MCS_CMD_TABLELIST_HELP

#define MCS_CMD_TABLELIST_HELP
Value:
"Retrieve the list of tables actually present in the\n" \
"database.\n" \
"TLIST"

Definition at line 361 of file mcs.hh.

◆ MCS_CMD_USERNAME

#define MCS_CMD_USERNAME   "USR"

Command: Provide user name.

Definition at line 301 of file mcs.hh.

◆ MCS_CMD_USERNAME_HELP

#define MCS_CMD_USERNAME_HELP
Value:
"Supply user name.\n" \
"USR <user_name>"

Definition at line 302 of file mcs.hh.

◆ MCS_COMMBUFSIZE

#define MCS_COMMBUFSIZE   1024

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

Definition at line 210 of file mcs.hh.

◆ MCS_CRITICAL_SECTION

#define MCS_CRITICAL_SECTION (   BLOCK...)
Value:
MCS_CRITICAL_SECTION_BEGIN \
BLOCK; \
MCS_CRITICAL_SECTION_END

Execute a list of commands inside a critical section.

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

Definition at line 2393 of file mcs.hh.

◆ MCS_CRITICAL_SECTION_BEGIN

#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 2375 of file mcs.hh.

◆ MCS_CRITICAL_SECTION_END

#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 2380 of file mcs.hh.

◆ MCS_CRITICAL_SECTION_END_RETURN

#define MCS_CRITICAL_SECTION_END_RETURN (   What...)
Value:
leave(); return What; } \
catch(Event e) { leave(); throw e; }

Definition at line 2382 of file mcs.hh.

◆ MCS_CUSTOM_LOCAL

#define MCS_CUSTOM_LOCAL (   CLASS)
Value:
class CLASS : public mcs::LocalThread \
{ \
public: \
CLASS(mcs::Thread* p) : \
LocalThread(p) {} \
~CLASS() {}
Server side administrative thread.
Definition: mcs.hh:6741
A class to create separate threads.
Definition: mcs.hh:2487

Definition at line 7423 of file mcs.hh.

◆ MCS_CUSTOM_SERVER

#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); }
Main server class for a MCS-based application.
Definition: mcs.hh:7166
Env * mcsStart(string appname, string inipath="", Server *(*cb_newServer)(Env *)=NULL)
Start a MCS server.
Definition: Main.cc:113
Hold all environment variables.
Definition: mcs.hh:6867

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
CLASSThe newly defined class name;
CLIENTThe UserThread derived class name;
LOCALThe LocalThread derived class name.
EXTRAExtra code added inside the server class definition.

Definition at line 7446 of file mcs.hh.

◆ MCS_CUSTOM_USER

#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() {}
The server side client thread.
Definition: mcs.hh:6365
A class to create separate threads.
Definition: mcs.hh:2487

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
envAddress 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 7413 of file mcs.hh.

◆ MCS_DEFAULT_CLIENT_TIMEOUT

#define MCS_DEFAULT_CLIENT_TIMEOUT   10 * 60 * 1000

Default client connection timeout, in milliseconds: 10 minutes.

Definition at line 206 of file mcs.hh.

◆ MCS_DEFAULT_MAX_USERS

#define MCS_DEFAULT_MAX_USERS   100

Default max number of clients connected.

Definition at line 202 of file mcs.hh.

◆ MCS_DEFAULT_PORT

#define MCS_DEFAULT_PORT   6523

Default port on which the server is listening.

Definition at line 189 of file mcs.hh.

◆ MCS_DEFAULTCHUNKSIZE

#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 198 of file mcs.hh.

◆ MCS_ERROR

#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 964 of file mcs.hh.

◆ MCS_FATAL

#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 967 of file mcs.hh.

◆ MCS_FT_BATCH

#define MCS_FT_BATCH   1

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

Definition at line 6254 of file mcs.hh.

◆ MCS_FT_BIN

#define MCS_FT_BIN   4

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

Definition at line 6263 of file mcs.hh.

◆ MCS_FT_SCRIPT

#define MCS_FT_SCRIPT   3

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

Definition at line 6260 of file mcs.hh.

◆ MCS_FT_SQL

#define MCS_FT_SQL   2

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

Definition at line 6257 of file mcs.hh.

◆ MCS_FT_UNKNOWN

#define MCS_FT_UNKNOWN   0

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

Definition at line 6251 of file mcs.hh.

◆ MCS_OK

#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 958 of file mcs.hh.

◆ MCS_OPT_ALL_ERRORS

#define MCS_OPT_ALL_ERRORS   "werr"

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

Definition at line 395 of file mcs.hh.

◆ MCS_OPT_ALL_ERRORS_HELP

#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 396 of file mcs.hh.

◆ MCS_OPT_FORCE

#define MCS_OPT_FORCE   "force"

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

Definition at line 389 of file mcs.hh.

◆ MCS_OPT_FORCE_HELP

#define MCS_OPT_FORCE_HELP
Value:
"Continue execution of commands even if an error\n" \
"occurred.\n" \
"-force"

Definition at line 390 of file mcs.hh.

◆ MCS_OPT_HELP

#define MCS_OPT_HELP   "help"

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

Definition at line 407 of file mcs.hh.

◆ MCS_OPT_LOOP

#define MCS_OPT_LOOP   "loop"

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

Definition at line 401 of file mcs.hh.

◆ MCS_OPT_LOOP_HELP

#define MCS_OPT_LOOP_HELP
Value:
"Put a copy of thr received Data object in the \n" \
"\"send\" vector.\n" \
"-loop"

Definition at line 402 of file mcs.hh.

◆ MCS_OPT_SAVEQUERYASCII

#define MCS_OPT_SAVEQUERYASCII   "sqascii"

Option: Save query result in ASCII format.

Definition at line 383 of file mcs.hh.

◆ MCS_OPT_SAVEQUERYASCII_HELP

#define MCS_OPT_SAVEQUERYASCII_HELP
Value:
"Save query result in ASCII format.\n" \
"-sqascii"

Definition at line 384 of file mcs.hh.

◆ MCS_OPT_SAVEQUERYFITS

#define MCS_OPT_SAVEQUERYFITS   "sqfits"

Option: Save query result in FITS format.

Definition at line 378 of file mcs.hh.

◆ MCS_OPT_SAVEQUERYFITS_HELP

#define MCS_OPT_SAVEQUERYFITS_HELP
Value:
"Save query result in FITS format.\n " \
"-sqfits"

Definition at line 379 of file mcs.hh.

◆ MCS_PRE

#define MCS_PRE   "#"

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

Definition at line 270 of file mcs.hh.

◆ MCS_PROMPT_ERROR

#define MCS_PROMPT_ERROR   MCS_PRE "0E-"

Prompt sent after a command raised one error.

Definition at line 282 of file mcs.hh.

◆ MCS_PROMPT_OK

#define MCS_PROMPT_OK   MCS_PRE "0--"

Prompt sent after a command has been executed correctly.

Definition at line 276 of file mcs.hh.

◆ MCS_PROMPT_WARN

#define MCS_PROMPT_WARN   MCS_PRE "0W-"

Prompt sent after a command raised one or more warnings.

Definition at line 279 of file mcs.hh.

◆ MCS_RS_ACCUM

#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 4437 of file mcs.hh.

◆ MCS_RS_INSERT

#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 4480 of file mcs.hh.

◆ MCS_RS_KNOW_NROWS

#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 4457 of file mcs.hh.

◆ MCS_RS_RANDOM

#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 4466 of file mcs.hh.

◆ MCS_RS_USEMETAREC

#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 4449 of file mcs.hh.

◆ MCS_SEP

#define MCS_SEP   "|"

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

Definition at line 273 of file mcs.hh.

◆ MCS_STATE_CREATED

#define MCS_STATE_CREATED   1

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

Definition at line 2406 of file mcs.hh.

◆ MCS_STATE_END

#define MCS_STATE_END   4

Thread state: the separate thread had terminated its execution.

Definition at line 2416 of file mcs.hh.

◆ MCS_STATE_RUNNING

#define MCS_STATE_RUNNING   2

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

Definition at line 2409 of file mcs.hh.

◆ MCS_STATE_TERMINATING

#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 2413 of file mcs.hh.

◆ MCS_SUBST_LEADING

#define MCS_SUBST_LEADING   4

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

Definition at line 502 of file mcs.hh.

◆ MCS_SUBST_QUOTE_WITH

#define MCS_SUBST_QUOTE_WITH   1

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

Definition at line 499 of file mcs.hh.

◆ MCS_SUBST_TRAILING

#define MCS_SUBST_TRAILING   8

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

Definition at line 505 of file mcs.hh.

◆ MCS_SYNCHRO_LOCK

#define MCS_SYNCHRO_LOCK   1

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

Definition at line 2259 of file mcs.hh.

◆ MCS_SYNCHRO_TRY_LOCK

#define MCS_SYNCHRO_TRY_LOCK   2

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

Definition at line 2262 of file mcs.hh.

◆ MCS_SYNCHRO_TRY_TIMED

#define MCS_SYNCHRO_TRY_TIMED   3

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

Definition at line 2266 of file mcs.hh.

◆ MCS_VMSG_SIZE

#define MCS_VMSG_SIZE   1000

Size of the Event.vmsg static array.

Definition at line 730 of file mcs.hh.

◆ MCS_WARN

#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 961 of file mcs.hh.

◆ my_mempcpy

#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 490 of file mcs.hh.


mcslogo

MCS (My Customizable Server) ver. 0.3.3-alpha7
Documentation generated on Mon May 28 07:39:41 UTC 2018