00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_TApplicationServer
00013 #define ROOT_TApplicationServer
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef ROOT_TApplication
00025 #include "TApplication.h"
00026 #endif
00027 #ifndef ROOT_TString
00028 #include "TString.h"
00029 #endif
00030 #ifndef ROOT_TSysEvtHandler
00031 #include "TSysEvtHandler.h"
00032 #endif
00033 #ifndef ROOT_TUrl
00034 #include "TUrl.h"
00035 #endif
00036
00037 class TList;
00038 class TMessage;
00039 class TSocket;
00040 class TRemoteObject;
00041
00042 class TApplicationServer : public TApplication {
00043
00044 private:
00045 Int_t fProtocol;
00046 TUrl fUrl;
00047 TSocket *fSocket;
00048 Bool_t fIsValid;
00049 Bool_t fInterrupt;
00050
00051 TString fLogFilePath;
00052 FILE *fLogFile;
00053 Int_t fLogFileDes;
00054 Bool_t fRealTimeLog;
00055
00056 TString fSessId;
00057
00058 TString fWorkDir;
00059
00060 TList *fSentCanvases;
00061 TRemoteObject *fWorkingDir;
00062
00063 void ExecLogon();
00064 Int_t Setup();
00065 Int_t SendCanvases();
00066
00067 protected:
00068 void HandleCheckFile(TMessage *mess);
00069
00070 static void ErrorHandler(Int_t level, Bool_t abort, const char *location,
00071 const char *msg);
00072
00073 public:
00074 TApplicationServer(Int_t *argc, char **argv, FILE *flog, const char *logfile);
00075 virtual ~TApplicationServer();
00076
00077 void GetOptions(Int_t *argc, char **argv);
00078 Int_t GetProtocol() const { return fProtocol; }
00079 Int_t GetPort() const { return fUrl.GetPort(); }
00080 const char *GetUser() const { return fUrl.GetUser(); }
00081 const char *GetHost() const { return fUrl.GetHost(); }
00082 TSocket *GetSocket() const { return fSocket; }
00083
00084 void HandleSocketInput();
00085 void HandleUrgentData();
00086 void HandleSigPipe();
00087 void Interrupt() { fInterrupt = kTRUE; }
00088 Bool_t IsValid() const { return fIsValid; }
00089
00090 Long_t ProcessLine(const char *line, Bool_t = kFALSE, Int_t *err = 0);
00091
00092 void Reset(const char *dir);
00093 Int_t ReceiveFile(const char *file, Bool_t bin, Long64_t size);
00094 void Run(Bool_t retrn = kFALSE);
00095 void SendLogFile(Int_t status = 0, Int_t start = -1, Int_t end = -1);
00096 Int_t BrowseDirectory(const char *dirname);
00097 Int_t BrowseFile(const char *fname);
00098 Int_t BrowseKey(const char *keyname);
00099
00100 void Terminate(Int_t status);
00101
00102 ClassDef(TApplicationServer,0)
00103 };
00104
00105
00106
00107
00108
00109 class TASLogHandler : public TFileHandler {
00110 private:
00111 TSocket *fSocket;
00112 FILE *fFile;
00113 TString fPfx;
00114
00115 static TString fgPfx;
00116 public:
00117 enum EStatusBits { kFileIsPipe = BIT(23) };
00118 TASLogHandler(const char *cmd, TSocket *s, const char *pfx = "");
00119 TASLogHandler(FILE *f, TSocket *s, const char *pfx = "");
00120 virtual ~TASLogHandler();
00121
00122 Bool_t IsValid() { return ((fFile && fSocket) ? kTRUE : kFALSE); }
00123
00124 Bool_t Notify();
00125 Bool_t ReadNotify() { return Notify(); }
00126
00127 static void SetDefaultPrefix(const char *pfx);
00128 };
00129
00130
00131
00132 class TASLogHandlerGuard {
00133
00134 private:
00135 TASLogHandler *fExecHandler;
00136
00137 public:
00138 TASLogHandlerGuard(const char *cmd, TSocket *s,
00139 const char *pfx = "", Bool_t on = kTRUE);
00140 TASLogHandlerGuard(FILE *f, TSocket *s,
00141 const char *pfx = "", Bool_t on = kTRUE);
00142 virtual ~TASLogHandlerGuard();
00143 };
00144
00145 #endif