#ifndef ROOT_TApplicationServer
#define ROOT_TApplicationServer
#ifndef ROOT_TApplication
#include "TApplication.h"
#endif
#ifndef ROOT_TString
#include "TString.h"
#endif
#ifndef ROOT_TSysEvtHandler
#include "TSysEvtHandler.h"
#endif
#ifndef ROOT_TUrl
#include "TUrl.h"
#endif
class TList;
class TMessage;
class TSocket;
class TRemoteObject;
class TApplicationServer : public TApplication {
private:
Int_t fProtocol;
TUrl fUrl;
TSocket *fSocket;
Bool_t fIsValid;
Bool_t fInterrupt;
TString fLogFilePath;
FILE *fLogFile;
Int_t fLogFileDes;
Bool_t fRealTimeLog;
TString fSessId;
TString fWorkDir;
TList *fSentCanvases;
TRemoteObject *fWorkingDir;
void ExecLogon();
Int_t Setup();
Int_t SendCanvases();
protected:
void HandleCheckFile(TMessage *mess);
static void ErrorHandler(Int_t level, Bool_t abort, const char *location,
const char *msg);
public:
TApplicationServer(Int_t *argc, char **argv, FILE *flog, const char *logfile);
virtual ~TApplicationServer();
void GetOptions(Int_t *argc, char **argv);
Int_t GetProtocol() const { return fProtocol; }
Int_t GetPort() const { return fUrl.GetPort(); }
const char *GetUser() const { return fUrl.GetUser(); }
const char *GetHost() const { return fUrl.GetHost(); }
TSocket *GetSocket() const { return fSocket; }
void HandleSocketInput();
void HandleUrgentData();
void HandleSigPipe();
void Interrupt() { fInterrupt = kTRUE; }
Bool_t IsValid() const { return fIsValid; }
Long_t ProcessLine(const char *line, Bool_t = kFALSE, Int_t *err = 0);
void Reset(const char *dir);
Int_t ReceiveFile(const char *file, Bool_t bin, Long64_t size);
void Run(Bool_t retrn = kFALSE);
void SendLogFile(Int_t status = 0, Int_t start = -1, Int_t end = -1);
Int_t BrowseDirectory(const char *dirname);
Int_t BrowseFile(const char *fname);
Int_t BrowseKey(const char *keyname);
void Terminate(Int_t status);
ClassDef(TApplicationServer,0)
};
class TASLogHandler : public TFileHandler {
private:
TSocket *fSocket;
FILE *fFile;
TString fPfx;
static TString fgPfx;
public:
enum EStatusBits { kFileIsPipe = BIT(23) };
TASLogHandler(const char *cmd, TSocket *s, const char *pfx = "");
TASLogHandler(FILE *f, TSocket *s, const char *pfx = "");
virtual ~TASLogHandler();
Bool_t IsValid() { return ((fFile && fSocket) ? kTRUE : kFALSE); }
Bool_t Notify();
Bool_t ReadNotify() { return Notify(); }
static void SetDefaultPrefix(const char *pfx);
};
class TASLogHandlerGuard {
private:
TASLogHandler *fExecHandler;
public:
TASLogHandlerGuard(const char *cmd, TSocket *s,
const char *pfx = "", Bool_t on = kTRUE);
TASLogHandlerGuard(FILE *f, TSocket *s,
const char *pfx = "", Bool_t on = kTRUE);
virtual ~TASLogHandlerGuard();
};
#endif