PTLib  Version 2.10.10
PHTTPServiceProcess Class Referenceabstract

#include <httpsvc.h>

Inheritance diagram for PHTTPServiceProcess:
PServiceProcess PProcess PThread PObject PSecureHTTPServiceProcess

Classes

struct  Info
 

Public Types

enum  { MaxSecuredKeys = 10 }
 
- Public Types inherited from PProcess
enum  CodeStatus { AlphaCode, BetaCode, ReleaseCode, NumCodeStatuses }
 Release status for the program. More...
 
- Public Types inherited from PThread
enum  Priority {
  LowestPriority, LowPriority, NormalPriority, HighPriority,
  HighestPriority, NumPriorities
}
 Codes for thread priorities. More...
 
enum  AutoDeleteFlag { AutoDeleteThread, NoAutoDeleteThread }
 Codes for thread autodelete flag. More...
 
- Public Types inherited from PObject
enum  Comparison { LessThan = -1, EqualTo = 0, GreaterThan = 1 }
 Result of the comparison operation performed by the Compare() function. More...
 

Public Member Functions

 PHTTPServiceProcess (const Info &inf)
 
 ~PHTTPServiceProcess ()
 
PBoolean OnStart ()
 Called when the service is started. More...
 
void OnStop ()
 Called by the system when the service is stopped. More...
 
PBoolean OnPause ()
 Called by the system when the service is to be paused. More...
 
void OnContinue ()
 Resume after the service was paused. More...
 
const char * GetServiceDependencies () const
 
virtual void OnConfigChanged ()=0
 
virtual PBoolean Initialise (const char *initMsg)=0
 
PBoolean ListenForHTTP (WORD port, PSocket::Reusability reuse=PSocket::CanReuseAddress, PINDEX stackSize=0x4000)
 
PBoolean ListenForHTTP (PSocket *listener, PSocket::Reusability reuse=PSocket::CanReuseAddress, PINDEX stackSize=0x4000)
 
virtual PString GetPageGraphic ()
 
void GetPageHeader (PHTML &)
 
void GetPageHeader (PHTML &, const PString &title)
 
virtual PString GetCopyrightText ()
 
const PStringGetMacroKeyword () const
 
const PTimeGetCompilationDate () const
 
const PStringGetHomePage () const
 
const PStringGetEMailAddress () const
 
const PStringGetProductName () const
 
const PTEACypher::KeyGetProductKey () const
 
const PStringArrayGetSecuredKeys () const
 
const PTEACypher::KeyGetSignatureKey () const
 
PBoolean ShouldIgnoreSignatures () const
 
void SetIgnoreSignatures (PBoolean ig)
 
virtual void AddRegisteredText (PHTML &html)
 
virtual void AddUnregisteredText (PHTML &html)
 
virtual PBoolean SubstituteEquivalSequence (PHTTPRequest &request, const PString &, PString &)
 
virtual PHTTPServerCreateHTTPServer (PTCPSocket &socket)
 
virtual PHTTPServerOnCreateHTTPServer (const PHTTPSpace &urlSpace)
 
PTCPSocketAcceptHTTP ()
 
PBoolean ProcessHTTP (PTCPSocket &socket)
 
- Public Member Functions inherited from PServiceProcess
virtual int InternalMain (void *arg=NULL)
 Main function for process, called from real main after initialisation. More...
 
 ~PServiceProcess ()
 
virtual void Terminate ()
 Terminate the process. More...
 
 PServiceProcess (const char *manuf, const char *name, WORD majorVersion, WORD minorVersion, CodeStatus status, WORD buildNumber)
 Create a new service process. More...
 
virtual void OnControl ()=0
 The Control menu option was used in the SysTray menu. More...
 
void SetLogLevel (PSystemLog::Level level)
 Set the level at which errors are logged. More...
 
PSystemLog::Level GetLogLevel () const
 Get the current level for logging. More...
 
- Public Member Functions inherited from PProcess
PTimerListGetTimerList ()
 Get the list of timers handled by the application. More...
 
void PreInitialise (int argc, char **argv, char **envp)
 Internal initialisation function called directly from InternalMain(). More...
 
 ~PProcess ()
 
PDirectory PXGetHomeDir ()
 
void PXCheckSignals ()
 
void PXAbortIOBlock (int fd)
 
Comparison Compare (const PObject &obj) const
 Compare two process instances. More...
 
virtual PString GetThreadName () const
 Get the name of the thread. More...
 
virtual void SetThreadName (const PString &name)
 Change the name of the thread. More...
 
 PProcess (const char *manuf="", const char *name="", WORD majorVersion=1, WORD minorVersion=0, CodeStatus status=ReleaseCode, WORD buildNumber=1, bool library=false)
 Create a new process instance. More...
 
virtual void OnThreadStart (PThread &thread)
 Callback for when a thread is started by the PTLib system. More...
 
virtual void OnThreadEnded (PThread &thread)
 Callback for when a thread is ended if wqas started in the PTLib system. More...
 
virtual bool OnInterrupt (bool terminating)
 Callback for when a ^C (SIGINT) or termination request (SIGTERM) is received by process. More...
 
void SetTerminationValue (int value)
 Set the termination value for the process. More...
 
int GetTerminationValue () const
 Get the termination value for the process. More...
 
PArgListGetArguments ()
 Get the programme arguments. More...
 
virtual const PStringGetManufacturer () const
 Get the name of the manufacturer of the software. More...
 
virtual const PStringGetName () const
 Get the name of the process. More...
 
virtual PString GetVersion (PBoolean full=true) const
 Get the version of the software. More...
 
const PFilePathGetFile () const
 Get the processes executable image file path. More...
 
PProcessIdentifier GetProcessID () const
 Get the platform dependent process identifier for the process. More...
 
PTime GetStartTime () const
 Return the time at which the program was started. More...
 
PString GetUserName () const
 Get the effective user name of the owner of the process, eg "root" etc. More...
 
PBoolean SetUserName (const PString &username, PBoolean permanent=false)
 Set the effective owner of the process. More...
 
PString GetGroupName () const
 Get the effective group name of the owner of the process, eg "root" etc. More...
 
PBoolean SetGroupName (const PString &groupname, PBoolean permanent=false)
 Set the effective group of the process. More...
 
int GetMaxHandles () const
 Get the maximum file handle value for the process. More...
 
PBoolean SetMaxHandles (int newLimit)
 Set the maximum number of file handles for the process. More...
 
virtual PString GetConfigurationFile ()
 Get the default file to use in PConfig instances. More...
 
void SetConfigurationPath (const PString &path)
 Set the default file or set of directories to search for use in PConfig. More...
 
- Public Member Functions inherited from PThread
bool IsAutoDelete () const
 
int PXBlockOnChildTerminate (int pid, const PTimeInterval &timeout)
 
int PXBlockOnIO (int handle, int type, const PTimeInterval &timeout)
 
void PXAbortBlock () const
 
void PrintOn (ostream &strm) const
 Standard stream print function. More...
 
 PThread (PINDEX, AutoDeleteFlag deletion=AutoDeleteThread, Priority priorityLevel=NormalPriority, const PString &threadName=PString::Empty())
 Create a new thread instance. More...
 
 ~PThread ()
 Destroy the thread, this simply calls the Terminate() function with all its restrictions and penalties. More...
 
virtual void Restart ()
 Restart a terminated thread using the same stack priority etc that was current when the thread terminated. More...
 
virtual PBoolean IsTerminated () const
 Determine if the thread has been terminated or ran to completion. More...
 
void WaitForTermination () const
 Block and wait for the thread to terminate. More...
 
PBoolean WaitForTermination (const PTimeInterval &maxWait) const
 Block and wait for the thread to terminate. More...
 
virtual void Suspend (PBoolean susp=true)
 Suspend or resume the thread. More...
 
virtual void Resume ()
 Resume thread execution, this is identical to Suspend(false). More...
 
virtual PBoolean IsSuspended () const
 Determine if the thread is currently suspended. More...
 
virtual void SetPriority (Priority priorityLevel)
 Set the priority of the thread relative to other threads in the current process. More...
 
virtual Priority GetPriority () const
 Get the current priority of the thread in the current process. More...
 
virtual void SetAutoDelete (AutoDeleteFlag deletion=AutoDeleteThread)
 Set the flag indicating thread object is to be automatically deleted when the thread ends. More...
 
void SetNoAutoDelete ()
 Reet the flag indicating thread object is to be automatically deleted when the thread ends. More...
 
virtual PThreadIdentifier GetThreadId () const
 Get operating system specific thread identifier for this thread. More...
 
bool GetTimes (Times &times)
 Get the thread execution times. More...
 
virtual void Main ()=0
 User override function for the main execution routine of the thread. More...
 
- Public Member Functions inherited from PObject
virtual ~PObject ()
 
virtual PObjectClone () const
 Create a copy of the class on the heap. More...
 
virtual PINDEX HashFunction () const
 This function yields a hash value required by the PDictionary class. More...
 
virtual Comparison CompareObjectMemoryDirect (const PObject &obj) const
 Determine the byte wise comparison of two objects. More...
 
bool operator== (const PObject &obj) const
 Compare the two objects. More...
 
bool operator!= (const PObject &obj) const
 Compare the two objects. More...
 
bool operator< (const PObject &obj) const
 Compare the two objects. More...
 
bool operator> (const PObject &obj) const
 Compare the two objects. More...
 
bool operator<= (const PObject &obj) const
 Compare the two objects. More...
 
bool operator>= (const PObject &obj) const
 Compare the two objects. More...
 
virtual const char * GetClass (unsigned ancestor=0) const
 Get the current dynamic type of the object instance. More...
 
PBoolean IsClass (const char *cls) const
 
virtual PBoolean InternalIsDescendant (const char *clsName) const
 Determine if the dynamic type of the current instance is a descendent of the specified class. More...
 
virtual void ReadFrom (istream &strm)
 Input the contents of the object from the stream. More...
 

Static Public Member Functions

static PHTTPServiceProcessCurrent ()
 
- Static Public Member Functions inherited from PServiceProcess
static PServiceProcessCurrent ()
 Get the current service process object. More...
 
- Static Public Member Functions inherited from PProcess
static void PreShutdown ()
 Internal shutdown function called directly from the ~PProcess InternalMain(). More...
 
static void PostShutdown ()
 
static void PXShowSystemWarning (PINDEX code)
 
static void PXShowSystemWarning (PINDEX code, const PString &str)
 
static PString GetOSClass ()
 Get the class of the operating system the process is running on, eg "unix". More...
 
static PString GetOSName ()
 Get the name of the operating system the process is running on, eg "Linux". More...
 
static PString GetOSHardware ()
 Get the hardware the process is running on, eg "sparc". More...
 
static PString GetOSVersion ()
 Get the version of the operating system the process is running on, eg "2.0.33". More...
 
static bool IsOSVersion (unsigned major, unsigned minor=0, unsigned build=0)
 See if operating system is later than the version specified. More...
 
static PDirectory GetOSConfigDir ()
 Get the configuration directory of the operating system the process is running on, eg "/etc" for Unix, "c:\windows" for Win95 or "c:\winnt\system32\drivers\etc" for NT. More...
 
static PString GetLibVersion ()
 Get the version of the PTLib library the process is running on, eg "2.5beta3". More...
 
static PProcessCurrent ()
 Get the current processes object instance. More...
 
static PBoolean IsInitialised ()
 Determine if the current processes object instance has been initialised. More...
 
static PProcessIdentifier GetCurrentProcessID ()
 Get the platform dependent process identifier for the currentprocess. More...
 
- Static Public Member Functions inherited from PThread
static void Sleep (const PTimeInterval &delay)
 Suspend the current thread for the specified amount of time. More...
 
static PThreadIdentifier GetCurrentThreadId ()
 
static PThreadCurrent ()
 Get the currently running thread object instance. More...
 
static void Yield ()
 Yield to another thread without blocking. More...
 
static PThreadCreate (const PNotifier &notifier, INT parameter=0, AutoDeleteFlag deletion=AutoDeleteThread, Priority priorityLevel=NormalPriority, const PString &threadName=PString::Empty(), PINDEX stackSize=65536)
 Create a simple thread executing the specified notifier. More...
 
static PThreadCreate (const PNotifier &notifier, const PString &threadName)
 
- Static Public Member Functions inherited from PObject
static Comparison InternalCompareObjectMemoryDirect (const PObject *obj1, const PObject *obj2, PINDEX size)
 Internal function caled from CompareObjectMemoryDirect() More...
 
static const char * Class ()
 Get the name of the class as a C string. More...
 

Protected Member Functions

void ShutdownListener ()
 
void BeginRestartSystem ()
 
void CompleteRestartSystem ()
 
 PLIST (ThreadList, PHTTPServiceThread)
 
- Protected Member Functions inherited from PServiceProcess
int InitialiseService ()
 
void _PXShowSystemWarning (PINDEX num, const PString &str)
 
void PXOnSignal (int)
 
void PXOnAsyncSignal (int)
 
- Protected Member Functions inherited from PProcess
void Construct ()
 
 PDICTIONARY (PXFdDict, POrdinalKey, PThread)
 
void CommonConstruct ()
 
void CommonDestruct ()
 
void CreateConfigFilesDictionary ()
 
- Protected Member Functions inherited from PObject
 PObject ()
 Constructor for PObject, made protected so cannot ever create one on its own. More...
 

Protected Attributes

PSockethttpListeningSocket
 
PHTTPSpace httpNameSpace
 
PString macroKeyword
 
PTEACypher::Key productKey
 
PStringArray securedKeys
 
PTEACypher::Key signatureKey
 
PBoolean ignoreSignatures
 
PTime compilationDate
 
PString manufacturersHomePage
 
PString manufacturersEmail
 
PString productNameHTML
 
PString gifHTML
 
PString copyrightHolder
 
PString copyrightHomePage
 
PString copyrightEmail
 
PThreadrestartThread
 
ThreadList httpThreads
 
PMutex httpThreadsMutex
 
- Protected Attributes inherited from PServiceProcess
PBoolean debugMode
 Flag to indicate service is run in simulation mode. More...
 
PString pidFileToRemove
 
PBoolean isTerminating
 
- Protected Attributes inherited from PProcess
bool m_library
 
int terminationValue
 
PString manufacturer
 
PString productName
 
WORD majorVersion
 
WORD minorVersion
 
CodeStatus status
 
WORD buildNumber
 
PFilePath executableFile
 
PStringArray configurationPaths
 
PArgList arguments
 
int maxHandles
 
PTime programStartTime
 
bool m_shuttingDown
 
ThreadMap m_activeThreads
 
PMutex m_activeThreadMutex
 
PTimerList timers
 
PProcessIdentifier m_processID
 
int pxSignals
 
PAbstractDictionaryconfigFiles
 
PXFdDict ioBlocks [3]
 
- Protected Attributes inherited from PThread
bool m_isProcess
 
bool m_autoDelete
 
PINDEX m_originalStackSize
 
PString m_threadName
 
PMutex m_threadNameMutex
 
PThreadIdentifier m_threadId
 

Additional Inherited Members

- Protected Types inherited from PProcess
typedef std::map< PThreadIdentifier, PThread * > ThreadMap
 

Member Enumeration Documentation

anonymous enum
Enumerator
MaxSecuredKeys 

Constructor & Destructor Documentation

PHTTPServiceProcess::PHTTPServiceProcess ( const Info inf)
PHTTPServiceProcess::~PHTTPServiceProcess ( )

Member Function Documentation

PTCPSocket* PHTTPServiceProcess::AcceptHTTP ( )
virtual void PHTTPServiceProcess::AddRegisteredText ( PHTML html)
virtual
virtual void PHTTPServiceProcess::AddUnregisteredText ( PHTML html)
virtual
void PHTTPServiceProcess::BeginRestartSystem ( )
protected
void PHTTPServiceProcess::CompleteRestartSystem ( )
protected
virtual PHTTPServer* PHTTPServiceProcess::CreateHTTPServer ( PTCPSocket socket)
virtual

Reimplemented in PSecureHTTPServiceProcess.

static PHTTPServiceProcess& PHTTPServiceProcess::Current ( )
static
const PTime& PHTTPServiceProcess::GetCompilationDate ( ) const
inline

References compilationDate.

virtual PString PHTTPServiceProcess::GetCopyrightText ( )
virtual
const PString& PHTTPServiceProcess::GetEMailAddress ( ) const
inline

References manufacturersEmail.

const PString& PHTTPServiceProcess::GetHomePage ( ) const
inline

References manufacturersHomePage.

const PString& PHTTPServiceProcess::GetMacroKeyword ( ) const
inline

References macroKeyword.

virtual PString PHTTPServiceProcess::GetPageGraphic ( )
virtual
void PHTTPServiceProcess::GetPageHeader ( PHTML )
void PHTTPServiceProcess::GetPageHeader ( PHTML ,
const PString title 
)
const PTEACypher::Key& PHTTPServiceProcess::GetProductKey ( ) const
inline

References productKey.

const PString& PHTTPServiceProcess::GetProductName ( ) const
inline

References productNameHTML.

const PStringArray& PHTTPServiceProcess::GetSecuredKeys ( ) const
inline

References securedKeys.

const char* PHTTPServiceProcess::GetServiceDependencies ( ) const
const PTEACypher::Key& PHTTPServiceProcess::GetSignatureKey ( ) const
inline

References signatureKey.

virtual PBoolean PHTTPServiceProcess::Initialise ( const char *  initMsg)
pure virtual
PBoolean PHTTPServiceProcess::ListenForHTTP ( WORD  port,
PSocket::Reusability  reuse = PSocket::CanReuseAddress,
PINDEX  stackSize = 0x4000 
)
PBoolean PHTTPServiceProcess::ListenForHTTP ( PSocket listener,
PSocket::Reusability  reuse = PSocket::CanReuseAddress,
PINDEX  stackSize = 0x4000 
)
virtual void PHTTPServiceProcess::OnConfigChanged ( )
pure virtual
void PHTTPServiceProcess::OnContinue ( )
virtual

Resume after the service was paused.

Reimplemented from PServiceProcess.

virtual PHTTPServer* PHTTPServiceProcess::OnCreateHTTPServer ( const PHTTPSpace urlSpace)
virtual
PBoolean PHTTPServiceProcess::OnPause ( )
virtual

Called by the system when the service is to be paused.

This will suspend any actions that the service may be executing. Usually this is less expensive in resource allocation etc than stopping and starting the service.

Returns
true if the service was successfully paused.

Reimplemented from PServiceProcess.

PBoolean PHTTPServiceProcess::OnStart ( )
virtual

Called when the service is started.

This typically initialises the service and returns true if the service is ready to run. The Main() function is then executed.

Returns
true if service may start, false if an initialisation failure occurred.

Implements PServiceProcess.

void PHTTPServiceProcess::OnStop ( )
virtual

Called by the system when the service is stopped.

One return from this function there is no guarentee that any more user code will be executed. Any cleaning up or closing of resource must be done in here.

Reimplemented from PServiceProcess.

PHTTPServiceProcess::PLIST ( ThreadList  ,
PHTTPServiceThread   
)
protected
PBoolean PHTTPServiceProcess::ProcessHTTP ( PTCPSocket socket)
void PHTTPServiceProcess::SetIgnoreSignatures ( PBoolean  ig)
inline

References ignoreSignatures.

PBoolean PHTTPServiceProcess::ShouldIgnoreSignatures ( ) const
inline

References ignoreSignatures.

void PHTTPServiceProcess::ShutdownListener ( )
protected
virtual PBoolean PHTTPServiceProcess::SubstituteEquivalSequence ( PHTTPRequest request,
const PString ,
PString  
)
virtual

Member Data Documentation

PTime PHTTPServiceProcess::compilationDate
protected

Referenced by GetCompilationDate().

PString PHTTPServiceProcess::copyrightEmail
protected
PString PHTTPServiceProcess::copyrightHolder
protected
PString PHTTPServiceProcess::copyrightHomePage
protected
PString PHTTPServiceProcess::gifHTML
protected
PSocket* PHTTPServiceProcess::httpListeningSocket
protected
PHTTPSpace PHTTPServiceProcess::httpNameSpace
protected
ThreadList PHTTPServiceProcess::httpThreads
protected
PMutex PHTTPServiceProcess::httpThreadsMutex
protected
PBoolean PHTTPServiceProcess::ignoreSignatures
protected
PString PHTTPServiceProcess::macroKeyword
protected

Referenced by GetMacroKeyword().

PString PHTTPServiceProcess::manufacturersEmail
protected

Referenced by GetEMailAddress().

PString PHTTPServiceProcess::manufacturersHomePage
protected

Referenced by GetHomePage().

PTEACypher::Key PHTTPServiceProcess::productKey
protected

Referenced by GetProductKey().

PString PHTTPServiceProcess::productNameHTML
protected

Referenced by GetProductName().

PThread* PHTTPServiceProcess::restartThread
protected
PStringArray PHTTPServiceProcess::securedKeys
protected

Referenced by GetSecuredKeys().

PTEACypher::Key PHTTPServiceProcess::signatureKey
protected

Referenced by GetSignatureKey().


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