ASSA Namespace Reference

CommonUtils.h. More...


Classes

class  Acceptor
class  Address
class  AutoPtrRef
 A wrapper class to provide AutoPtr with reference semantics. More...
class  AutoPtr
 AutoPtr is based on SGI implementation of a auto_ptr template that makes memory handling a little bit easier. More...
class  AutoPtrArrayRef
 A wrapper class to provide AutoPtr with reference semantics. More...
class  AutoPtrArray
 AutoPtrArray handles memory management of an array of objects. More...
class  CharInBuffer
 CharInBuffer is a bucket for the character-based streams/messages. More...
class  Option
 Option class. More...
class  CmdLineOpts
 Class CmdLineOpts. More...
class  Connector
 Connector is a template class for initialization of communication services. More...
class  ConUDPSocket
class  Destroyer
class  EventHandler
 EventHandler class. More...
class  FdSet
 Class FdSet. More...
class  FileLogger
class  ChildStatusHandler
 A helper class of Fork. More...
class  Fork
 Fork class is a simple wrapper around C library function fork(). More...
class  fnode_t
 forknode_t class. More...
class  ForkList
 ForkList is a singleton class that keeps a list of all forked children. More...
class  GenServer
class  SIGINTHandler
 SIGINTHandler handles SIGINT signal. More...
class  SIGUSR1Handler
 Class SIGUSR1Handler. More...
class  SIGUSR2Handler
 Class SIGUSR2Handler handles SIGUSR2 signal. More...
class  SIGCHLDHandler
 Class SIGCHLDHandler handles SIGCHLD signal. More...
class  SIGALRMHandler
 Class SIGALRMHandler handles SIGALRM signal. More...
class  SIGPOLLHandler
 Class SIGPOLLHandler handles SIGPOLL signal. More...
class  IdSet
class  INETAddress
class  IniFile
class  IPv4Socket
class  Logger
class  DiagnosticContext
 Class DiagnosticContext tracks who deep a function is in the calling stack. More...
class  Logger_Impl
class  MaskSet
class  MemDump
class  PidFileLock
class  Pipe
class  PriorityQueue
class  PriorityQueue_Heap
struct  Bfunc
 Bfunc is used by PriorityQueue_impl. More...
struct  Less
 Less is borrowed from STL implementation. More...
class  PriorityQueue_Impl
 Class PriorityQueue_Impl. More...
class  PriorityQueue_STLPQ
class  Reactor
class  Regexp
 Regexp class. More...
class  RemoteLogger
class  Repository
class  Semaphore
class  ServiceHandler
class  SigAction
class  SigHandler
class  SigHandlers
class  CFUNC_Handler
 CFUNC_Handler class. More...
class  SigHandlersList
 SigHandlersList class. More...
class  SigSet
class  Singleton
class  Socket
class  Socketbuf
class  StdOutLogger
class  io_ptrs
 io_ptrs structure. More...
class  Streambuf
 Streambuf class. More...
class  Timer
struct  TimerCompare
 TimerCompare class compares two Timers base on their expiration timestamp. More...
class  TimerCountdown
class  TimerQueue
class  TimeVal
class  UDPSocket
class  UnConUDPSocket
class  UNIXAddress
class  xdrIOBuffer

Namespaces

namespace  Log
namespace  Utils

Typedefs

typedef sockaddr SA
typedef sockaddr_in SA_IN
typedef sockaddr_un SA_UN
typedef unsigned long TimerId
 Timer Id is used in handle_timeout() calls.
typedef int(EventHandler::* EH_IO_Callback )(int)
 A type for the pointer to I/O-related callback member function of class EventHandler.
typedef unsigned long TimerId

Enumerations

enum  ConnectMode { sync, async }
enum  EventType {
  READ_EVENT = 0x01, WRITE_EVENT = 0x02, EXCEPT_EVENT = 0x04, TIMEOUT_EVENT = 0x10,
  SIGNAL_EVENT = 0x20, RWE_EVENTS = 0x07, ALL_EVENTS = 0x37
}
 EventType defines events types that Reactor understands. More...
enum  Group {
  TRACE = 0x00000001, APP = 0x00000002, USR1 = 0x00000004, USR2 = 0x00000008,
  USR3 = 0x00000010, ALL_APPS = 0x0000001F, ERROR = 0x00000020, PIDFLOCK = 0x00000040,
  CMDLINEOPTS = 0x00000080, SEM = 0x00000100, SIGHAND = 0x00000200, REACT = 0x00000400,
  REACTTRACE = 0x00000800, SOCK = 0x00001000, SOCKTRACE = 0x00002000, XDRBUF = 0x00004000,
  XDRBUFTRACE = 0x00008000, STRMBUF = 0x00010000, STRMBUFTRACE = 0x00020000, FORK = 0x00040000,
  SIGACT = 0x00080000, PIPE = 0x00100000, CHARINBUF = 0x00200000, ADDRESS = 0x00400000,
  INIFILE = 0x00800000, REGEXP = 0x01000000, RES5 = 0x02000000, RES6 = 0x04000000,
  RES7 = 0x08000000, RES8 = 0x10000000, RES9 = 0x20000000, RES10 = 0x40000000,
  ALL_LIB = 0x7FFFFFE0, ALL = 0x7FFFFFFF, NONE = 0x00000000
}
 Bit mask used to mask out log messages. More...
enum  marker_t { FUNC_MSG, FUNC_ENTRY, FUNC_EXIT }

Functions

Socketoperator>> (Socket &s_, CharInBuffer &b_)
bool isReadEvent (EventType e_)
bool isWriteEvent (EventType e_)
bool isExceptEvent (EventType e_)
bool isTimeoutEvent (EventType e_)
bool isSignalEvent (EventType e_)
bool isRWEEvents (EventType e_)
bool isAllEvents (EventType e_)
Socketflush (Socket &os_)
 flush manipulator.
Socketendl (Socket &os_)
 endl manipulator.
Socketends (Socket &os_)
 ends manipulator.
TimeVal operator+ (const TimeVal &lhs_, const TimeVal &rhs_)
TimeVal operator- (const TimeVal &lhs_, const TimeVal &rhs_)
bool operator> (const TimeVal &lhs_, const TimeVal &rhs_)
bool operator!= (const TimeVal &lhs_, const TimeVal &rhs_)
bool operator<= (const TimeVal &lhs_, const TimeVal &rhs_)
bool operator>= (const TimeVal &lhs_, const TimeVal &rhs_)
Socketoperator>> (Socket &s_, xdrIOBuffer &b_)


Detailed Description

CommonUtils.h.

A random collection of unrelated static functions.


Typedef Documentation

int(EventHandler::* ASSA::EH_IO_Callback)(int)
 

A type for the pointer to I/O-related callback member function of class EventHandler.

These are:

  • handle_read ()
  • handle_write ()
  • handle_except ()

See also:
EventHandler

Definition at line 236 of file EventHandler.h.

typedef struct sockaddr ASSA::SA
 

Definition at line 30 of file Address.h.

typedef struct sockaddr_in ASSA::SA_IN
 

Definition at line 31 of file Address.h.

typedef struct sockaddr_un ASSA::SA_UN
 

Definition at line 32 of file Address.h.

typedef unsigned long ASSA::TimerId
 

Definition at line 28 of file TimerQueue.h.

unsigned long ASSA::TimerId
 

Timer Id is used in handle_timeout() calls.

Definition at line 27 of file EventHandler.h.


Enumeration Type Documentation

enum ASSA::ConnectMode
 

Enumerator:
sync  Synchronous connection mode.
async  Asynchronous connection mode.

Definition at line 37 of file Connector.h.

00037                  { 
00038     sync,                   
00039     async                   
00040 };

enum ASSA::EventType
 

EventType defines events types that Reactor understands.

Enumerator:
READ_EVENT  Notify when there will be at least 1 byte available for reading from IO channel without blocking .
WRITE_EVENT  Notify when there will be room for at least 1 byte to be written to IO channel without blocking.
EXCEPT_EVENT  Notify when there is an exception condition detected in TCP layer.
TIMEOUT_EVENT  Notify about expired timer.
SIGNAL_EVENT  Notify when UNIX signal is delivered by OS.
RWE_EVENTS  READ_EVENT | WRITE_EVENT | EXCEPT_EVENT.
ALL_EVENTS  Mask that includes all events.

Definition at line 34 of file EventHandler.h.

00035 {   
00036     READ_EVENT    = 0x01,   
00039     WRITE_EVENT   = 0x02,   
00042     EXCEPT_EVENT  = 0x04,   
00044     TIMEOUT_EVENT = 0x10,   
00045     SIGNAL_EVENT  = 0x20,   
00046     RWE_EVENTS    = 0x07,   
00047     ALL_EVENTS    = 0x37    
00048 };

enum ASSA::Group
 

Bit mask used to mask out log messages.

Enumerator:
TRACE  Function call trace.
APP  Application-level messages.
USR1  Additional application-level messages.
USR2  Additional application-level messages.
USR3  Additional application-level messages.
ALL_APPS  All application-level messages.
ERROR  ASSA and system errors.
PIDFLOCK  Class PidFileLock messages.
CMDLINEOPTS  Class CmdLineOpts messages.
SEM  Class Semaphore messages.
SIGHAND  Class SigHandler(s) messages.
REACT  Class Reactor/PrioriyQueue messages.
REACTTRACE  Extended Reactor/PrioriyQueue messages.
SOCK  Class Socket & friends messages.
SOCKTRACE  Extended Socket & friends messages.
XDRBUF  Class xdrIOBuffer messages.
XDRBUFTRACE  Extended xdrIOBuffer messages.
STRMBUF  Class Streambuf & friends messages.
STRMBUFTRACE  Extended Streambuf & friends messages.
FORK  Class Fork messages.
SIGACT  Class SigACtion messages.
PIPE  Class Pipe messages.
CHARINBUF  Class CharInBuffer messages.
ADDRESS  Class Address & friends messages.
INIFILE  Class IniFile messages.
REGEXP  Class RegExp messages.
RES5  Reserved for future use.
RES6  Reserved for future use.
RES7  Reserved for future use.
RES8  Reserved for future use.
RES9  Reserved for future use.
RES10  Reserved for future use.
ALL_LIB  All library messages.
ALL  All messages: library + application.
NONE  Total silence.

Definition at line 25 of file LogMask.h.

00025            {
00026     TRACE        = 0x00000001, 
00027     APP          = 0x00000002, 
00028     USR1         = 0x00000004, 
00029     USR2         = 0x00000008, 
00030     USR3         = 0x00000010, 
00031     /*-----------------------------------------------------------------------*/
00032     ALL_APPS     = 0x0000001F, 
00033     /*-----------------------------------------------------------------------*/
00034     ERROR        = 0x00000020, 
00035     PIDFLOCK     = 0x00000040, 
00036     CMDLINEOPTS  = 0x00000080, 
00037     SEM          = 0x00000100, 
00038     SIGHAND      = 0x00000200, 
00039     REACT        = 0x00000400, 
00040     REACTTRACE   = 0x00000800, 
00041     SOCK         = 0x00001000, 
00042     SOCKTRACE    = 0x00002000, 
00043     XDRBUF       = 0x00004000, 
00044     XDRBUFTRACE  = 0x00008000, 
00045     STRMBUF      = 0x00010000, 
00046     STRMBUFTRACE = 0x00020000, 
00047     FORK         = 0x00040000, 
00048     SIGACT       = 0x00080000, 
00049     PIPE         = 0x00100000, 
00050     CHARINBUF    = 0x00200000, 
00051     ADDRESS      = 0x00400000, 
00052     INIFILE      = 0x00800000, 
00053     REGEXP       = 0x01000000, 
00054     RES5         = 0x02000000, 
00055     RES6         = 0x04000000, 
00056     RES7         = 0x08000000, 
00057     RES8         = 0x10000000, 
00058     RES9         = 0x20000000, 
00059     RES10        = 0x40000000, 
00060     /*-----------------------------------------------------------------------*/
00061     ALL_LIB      = 0x7FFFFFE0, 
00062     ALL          = 0x7FFFFFFF, 
00063     NONE         = 0x00000000  
00064 };

enum ASSA::marker_t
 

Enumerator:
FUNC_MSG 
FUNC_ENTRY 
FUNC_EXIT 

Definition at line 67 of file LogMask.h.

00067               { 
00068     FUNC_MSG,
00069     FUNC_ENTRY, 
00070     FUNC_EXIT 
00071 };


Function Documentation

Socket& ASSA::endl Socket &  os_  )  [inline]
 

endl manipulator.

If you want to insert a newline character ('
') to terminate a text line, you should favor the manipulator endl. This manipulator inserts a newline character and also flushes the stream buffer.

Author:
Vladislav Grinchenko

Definition at line 559 of file Socket.h.

References ASSA::Socket::flush(), and ASSA::Socket::write().

Referenced by ASSA::GenServer::display_help(), ASSA::FileLogger::dump(), ASSA::FileLogger::handle_rollover(), ASSA::GenServer::init(), and ASSA::Logger::log_open().

00560 {
00561     char c = '\n';
00562     os_.write (&c, 1);
00563     os_.flush ();
00564     return (os_);
00565 }

Socket& ASSA::ends Socket &  os_  )  [inline]
 

ends manipulator.

You can insert a null character (without flushing the output stream) with the manipulator ends. A common use for a Socket object is to mediate output to a stream buffer that constructs an in-memory character sequence. Such a sequence wants a terminating null character. The manipulator ends provides highly visible evidence that the null character is indeed being supplied.

Author:
Vladislav Grinchenko

Definition at line 579 of file Socket.h.

References ASSA::Socket::write().

Referenced by ASSA::Semaphore::dump(), ASSA::Socket::dumpState(), ASSA::GenServer::get_version(), ASSA::GenServer::handle_signal(), and ASSA::PidFileLock::write_pid().

00580 {
00581     char c = '\0';
00582     os_.write (&c, 1);
00583     return (os_);
00584 }

Socket& ASSA::flush Socket &  os_  )  [inline]
 

flush manipulator.

Flush a stream buffer.

Definition at line 544 of file Socket.h.

References ASSA::Socket::flush().

Referenced by ASSA::RemoteLogger::log_close(), ASSA::FileLogger::log_close(), ASSA::RemoteLogger::log_func(), ASSA::FileLogger::log_func(), ASSA::RemoteLogger::log_msg(), ASSA::FileLogger::log_msg(), ASSA::RemoteLogger::log_open(), ASSA::FileLogger::log_raw_msg(), ASSA::StdOutLogger::log_resync(), ASSA::RemoteLogger::log_resync(), and ASSA::FileLogger::log_resync().

00545 {
00546     os_.flush ();
00547     return (os_);
00548 }

bool ASSA::isAllEvents EventType  e_  )  [inline]
 

Definition at line 87 of file EventHandler.h.

References isExceptEvent(), isReadEvent(), isSignalEvent(), isTimeoutEvent(), and isWriteEvent().

00088 {
00089     return isReadEvent (e_) && isWriteEvent (e_) && isExceptEvent (e_) &&
00090         isSignalEvent (e_) && isTimeoutEvent (e_) ;
00091 }

bool ASSA::isExceptEvent EventType  e_  )  [inline]
 

Definition at line 63 of file EventHandler.h.

References EXCEPT_EVENT.

Referenced by isAllEvents(), isRWEEvents(), and ASSA::Reactor::removeHandler().

00064 {
00065     return (e_ & EXCEPT_EVENT) == EXCEPT_EVENT;
00066 }

bool ASSA::isReadEvent EventType  e_  )  [inline]
 

Definition at line 51 of file EventHandler.h.

References READ_EVENT.

Referenced by isAllEvents(), isRWEEvents(), ASSA::Reactor::registerIOHandler(), and ASSA::Reactor::removeHandler().

00052 {     
00053     return (e_ & READ_EVENT) == READ_EVENT;
00054 }

bool ASSA::isRWEEvents EventType  e_  )  [inline]
 

Definition at line 81 of file EventHandler.h.

References isExceptEvent(), isReadEvent(), and isWriteEvent().

00082 {
00083     return isReadEvent (e_) && isWriteEvent (e_) && isExceptEvent (e_);
00084 }

bool ASSA::isSignalEvent EventType  e_  )  [inline]
 

Definition at line 75 of file EventHandler.h.

References SIGNAL_EVENT.

Referenced by isAllEvents(), and ASSA::Reactor::registerIOHandler().

00076 {
00077     return (e_ & SIGNAL_EVENT) == SIGNAL_EVENT;
00078 }

bool ASSA::isTimeoutEvent EventType  e_  )  [inline]
 

Definition at line 69 of file EventHandler.h.

References TIMEOUT_EVENT.

Referenced by isAllEvents(), ASSA::Reactor::registerIOHandler(), and ASSA::Reactor::removeHandler().

00070 {
00071     return (e_ & TIMEOUT_EVENT) == TIMEOUT_EVENT;
00072 }

bool ASSA::isWriteEvent EventType  e_  )  [inline]
 

Definition at line 57 of file EventHandler.h.

References WRITE_EVENT.

Referenced by isAllEvents(), isRWEEvents(), and ASSA::Reactor::removeHandler().

00058 {
00059     return (e_ & WRITE_EVENT) == WRITE_EVENT;
00060 }

bool ASSA::operator!= const TimeVal &  lhs_,
const TimeVal &  rhs_
[inline]
 

Definition at line 321 of file TimeVal.h.

00322 {
00323     return !( lhs_ == rhs_ );
00324 }

TimeVal ASSA::operator+ const TimeVal &  lhs_,
const TimeVal &  rhs_
[inline]
 

Definition at line 282 of file TimeVal.h.

References ASSA::TimeVal::normalize().

00283 {
00284     TimeVal temp(lhs_);
00285     temp += rhs_;
00286     temp.normalize ();
00287     return temp;
00288 }

TimeVal ASSA::operator- const TimeVal &  lhs_,
const TimeVal &  rhs_
[inline]
 

Definition at line 291 of file TimeVal.h.

References ASSA::TimeVal::normalize().

00292 {
00293     TimeVal temp(lhs_);
00294     temp -= rhs_;
00295     temp.normalize ();
00296     return temp;
00297 }

bool ASSA::operator<= const TimeVal &  lhs_,
const TimeVal &  rhs_
[inline]
 

Definition at line 327 of file TimeVal.h.

00328 {
00329     return !(rhs_ < lhs_);
00330 }

bool ASSA::operator> const TimeVal &  lhs_,
const TimeVal &  rhs_
[inline]
 

Definition at line 315 of file TimeVal.h.

00316 {
00317     return rhs_ < lhs_;
00318 }

bool ASSA::operator>= const TimeVal &  lhs_,
const TimeVal &  rhs_
[inline]
 

Definition at line 333 of file TimeVal.h.

00334 {
00335     return !(lhs_ < rhs_);
00336 }

Socket& ASSA::operator>> Socket s_,
xdrIOBuffer b_
 

Definition at line 25 of file xdrIOBuffer.cpp.

References DL, ASSA::xdrIOBuffer::dump(), EL, ASSA::xdrIOBuffer::error, ERROR, ASSA::xdrIOBuffer::get_state(), ASSA::Socket::getBytesAvail(), ASSA::xdrIOBuffer::m_buf, ASSA::xdrIOBuffer::m_ptr, ASSA::xdrIOBuffer::m_state, ASSA::xdrIOBuffer::m_sz, ASSA::Socket::read(), ASSA::xdrIOBuffer::size(), trace_with_mask, ASSA::xdrIOBuffer::waiting, XDRBUFTRACE, and ASSA::xdrIOBuffer::xmitted.

00026 {
00027     trace_with_mask("Socket >> xdrIOBuffer", XDRBUFTRACE);
00028 
00029     DL((XDRBUFTRACE,"Buffer Initially:\n"));
00030     b_.dump ();
00031 
00032     if (b_.m_state != xdrIOBuffer::waiting) {
00033         EL((ERROR,"Wrong state: %s\n", b_.get_state ().c_str ()));
00034         return s_;
00035     }
00036     int expected = b_.m_sz - b_.size ();
00037 
00038     DL((XDRBUFTRACE,"Bytes expected: %d\n",expected));
00039     DL((XDRBUFTRACE,"Bytes in Socket buffer(s): %d\n", s_.getBytesAvail ()));
00040     int ret;
00041 
00042     if ((ret = s_.read (b_.m_ptr, expected)) <= 0) {
00043         if (errno != EWOULDBLOCK) { 
00044             EL((ERROR,"Socket::read() error!\n"));
00045             b_.m_state = xdrIOBuffer::error;
00046         }
00047         else {
00048             EL((ERROR,"Socket::read() error! \n"));
00049         }
00050         return s_;
00051     }
00052     b_.m_ptr += ret;
00053 
00054     DL((XDRBUFTRACE,"Received %d bytes\n", ret));
00055     b_.dump ();
00056 
00057     if (b_.m_sz == b_.size ()) { // at the end
00058         DL((XDRBUFTRACE,"Complete message is in the buffer!\n"));
00059         b_.m_state = xdrIOBuffer::xmitted;
00060         b_.m_ptr = b_.m_buf;    // rewind m_ptr for parsing stage
00061         b_.dump ();
00062     }
00063     return s_;
00064 }

Socket& ASSA::operator>> ASSA::Socket s_,
ASSA::CharInBuffer b_
 

Regardless of the delimeter size, which can be >1, add the character received to the buffer and compare the end of the buffer with the delimeter.

If match, bite off delimiter and set the state to complete. If not, continue reading till either there is no more characters to read, or Socket error (fail || eof), or buffer overflow. If overflow occurs, set the state to 'error' and terminate.

Definition at line 68 of file CharInBuffer.cpp.

References CHARINBUF, DL, ASSA::CharInBuffer::state(), ASSA::CharInBuffer::state_name(), trace_with_mask, and ASSA::CharInBuffer::waiting.

00069 {
00070     trace_with_mask ("Socket >> CharInBuffer", CHARINBUF);
00071     register char c;
00072 
00073     if (b_.state () != CharInBuffer::waiting) {
00074         DL((CHARINBUF,"Wrong state %s\n", b_.state_name (b_.state ())));
00075         return s_;
00076     }
00088     while (s_.read (&c, 1) == 1) {
00089         b_.m_buffer += c;
00090 
00091         if (b_.m_buffer.size() < b_.m_delimiter.size()) { // Bug # 1252926
00092             continue;
00093         }
00094 
00095         if (b_.m_buffer.substr (
00096                 b_.m_buffer.size ()-b_.m_delimiter.size ()) == b_.m_delimiter) 
00097         {
00098             b_.chop ();
00099             b_.m_state = CharInBuffer::complete;
00100             return s_;
00101         }
00102 
00103         if (b_.m_buffer.length () >= b_.m_max_size) {
00104             b_.m_state = CharInBuffer::error;
00105             break;
00106         }
00107     }
00108 
00109     if (!s_) {                  // eof or error
00110         b_.state (CharInBuffer::error);
00111     }
00112     
00113     return s_;
00114 }


Generated on Wed Jun 21 01:42:51 2006 for libassa by  doxygen 1.4.6