00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef ROOT_TWinNTSystem
00014 #define ROOT_TWinNTSystem
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef ROOT_TSystem
00025 #include "TSystem.h"
00026 #endif
00027
00028
00029 #if !defined(__CINT__)
00030 #include "Windows4Root.h"
00031 #include <commctrl.h>
00032 #else
00033 typedef void* HANDLE;
00034 struct WIN32_FIND_DATA;
00035 typedef void* HIMAGELIST;
00036 typedef void* HICON;
00037 typedef UChar_t BOOL;
00038 struct FILE;
00039 #endif
00040
00041 #ifndef MAX_SID_SIZE
00042 #define MAX_SID_SIZE 1024
00043 #endif
00044 #define MAX_NAME_STRING 1024
00045
00046 #define SID_GROUP 0
00047 #define SID_MEMBER 1
00048
00049 struct passwd {
00050 char *pw_name;
00051 char *pw_passwd;
00052 int pw_uid;
00053 int pw_gid;
00054 int pw_quota;
00055 char *pw_gecos;
00056 char *pw_dir;
00057 char *pw_shell;
00058 char *pw_group;
00059 };
00060
00061 struct group {
00062 char *gr_name;
00063 char *gr_passwd;
00064 int gr_gid;
00065 char **gr_mem;
00066 };
00067
00068
00069 class TWinNTSystem : public TSystem {
00070 public:
00071
00072 typedef Bool_t (*ThreadMsgFunc_t)(MSG*);
00073
00074 private:
00075 struct group *fGroups;
00076 struct passwd *fPasswords;
00077 int fNbUsers;
00078 int fNbGroups;
00079 int fActUser;
00080 Bool_t fGroupsInitDone;
00081 Bool_t fFirstFile;
00082
00083 HANDLE fhProcess;
00084 void *fGUIThreadHandle;
00085 ULong_t fGUIThreadId;
00086 char *fDirNameBuffer;
00087 WIN32_FIND_DATA fFindFileData;
00088
00089 Bool_t DispatchTimers(Bool_t mode);
00090 Bool_t CheckDescriptors();
00091 Bool_t CheckSignals(Bool_t sync);
00092 Bool_t CountMembers(const char *lpszGroupName);
00093 const char *GetLinkedLibraries();
00094 Bool_t GetNbGroups();
00095 Long_t LookupSID (const char *lpszAccountName, int what, int &groupIdx, int &memberIdx);
00096 Bool_t CollectMembers(const char *lpszGroupName, int &groupIdx, int &memberIdx);
00097 Bool_t CollectGroups();
00098 Bool_t InitUsersGroups();
00099 void DoBeep(Int_t freq=-1, Int_t duration=-1) const;
00100
00101 static void ThreadStub(void *Parameter) {((TWinNTSystem *)Parameter)->TimerThread();}
00102 void TimerThread();
00103
00104 public:
00105 TWinNTSystem();
00106 virtual ~TWinNTSystem();
00107
00108
00109 HANDLE GetProcess();
00110 Bool_t HandleConsoleEvent();
00111
00112
00113 Bool_t Init();
00114 const char *BaseName(const char *name);
00115 void SetProgname(const char *name);
00116 const char *GetError();
00117 const char *HostName();
00118 void *GetGUIThreadHandle() const {return fGUIThreadHandle;}
00119 ULong_t GetGUIThreadId() const {return fGUIThreadId;}
00120 void SetGUIThreadMsgHandler(ThreadMsgFunc_t func);
00121 void NotifyApplicationCreated();
00122
00123
00124
00125 Bool_t ProcessEvents();
00126 void DispatchOneEvent(Bool_t pendingOnly = kFALSE);
00127 void ExitLoop();
00128 Int_t Select(TList *active, Long_t timeout);
00129 Int_t Select(TFileHandler *fh, Long_t timeout);
00130
00131
00132 void AddSignalHandler(TSignalHandler *sh);
00133 TSignalHandler *RemoveSignalHandler(TSignalHandler *sh);
00134 void ResetSignal(ESignals sig, Bool_t reset = kTRUE);
00135 void IgnoreSignal(ESignals sig, Bool_t ignore = kTRUE);
00136 void AddFileHandler(TFileHandler *fh);
00137 TFileHandler *RemoveFileHandler(TFileHandler *fh);
00138 void StackTrace();
00139
00140
00141 Int_t GetFPEMask();
00142 Int_t SetFPEMask(Int_t mask = kDefaultMask);
00143
00144
00145 int Exec(const char *shellcmd);
00146 FILE *OpenPipe(const char *shellcmd, const char *mode);
00147 int ClosePipe(FILE *pipe);
00148 void Exit(int code, Bool_t mode = kTRUE);
00149 void Abort(int code = 0);
00150 int GetPid();
00151
00152
00153 const char *Getenv(const char *name);
00154 void Setenv(const char *name, const char *value);
00155
00156
00157 int mkdir(const char *name, Bool_t recursive = kFALSE);
00158 int MakeDirectory(const char *name);
00159 Bool_t ChangeDirectory(const char *path);
00160 const char *GetDirEntry(void *dirp);
00161 const char *DirName(const char *pathname);
00162 void FreeDirectory(void *dirp);
00163 void *OpenDirectory(const char *name);
00164 const char *WorkingDirectory(char driveletter);
00165 const char *WorkingDirectory();
00166 const char *HomeDirectory(const char *userName=0);
00167 const char *TempDirectory() const;
00168 FILE *TempFileName(TString &base, const char *dir = 0);
00169
00170
00171 Int_t GetUid(const char *user = 0);
00172 Int_t GetGid(const char *group = 0);
00173 Int_t GetEffectiveUid();
00174 Int_t GetEffectiveGid();
00175 UserGroup_t *GetUserInfo(Int_t uid);
00176 UserGroup_t *GetUserInfo(const char *user = 0);
00177 UserGroup_t *GetGroupInfo(Int_t gid);
00178 UserGroup_t *GetGroupInfo(const char *group = 0);
00179
00180
00181 const char DriveName(const char *pathname="/");
00182 const char *PrependPathName(const char *dir, TString& name);
00183 Bool_t ExpandPathName(TString &patbuf);
00184 char *ExpandPathName(const char *path);
00185 Bool_t AccessPathName(const char *path, EAccessMode mode = kFileExists);
00186 Bool_t IsPathLocal(const char *path);
00187 Bool_t IsAbsoluteFileName(const char *dir);
00188 int CopyFile(const char *from, const char *to, Bool_t overwrite = kFALSE);
00189 int Rename(const char *from, const char *to);
00190 int Link(const char *from, const char *to);
00191 int Symlink(const char *from, const char *to);
00192 int Unlink(const char *name);
00193 int SetNonBlock(int fd);
00194 int GetPathInfo(const char *path, FileStat_t &buf);
00195 int GetFsInfo(const char *path, Long_t *id, Long_t *bsize,
00196 Long_t *blocks, Long_t *bfree);
00197 int Chmod(const char *file, UInt_t mode);
00198 int Umask(Int_t mask);
00199 int Utime(const char *file, Long_t modtime, Long_t actime);
00200 const char *UnixPathName(const char *unixpathname);
00201 const char *FindFile(const char *search, TString& file, EAccessMode mode = kFileExists);
00202 TList *GetVolumes(Option_t *opt = "") const;
00203
00204
00205 Int_t RedirectOutput(const char *name, const char *mode = "a", RedirectHandle_t *h = 0);
00206
00207
00208 void AddDynamicPath(const char *dir);
00209 const char *GetDynamicPath();
00210 void SetDynamicPath(const char *path);
00211 char *DynamicPathName(const char *lib, Bool_t quiet = kFALSE);
00212 int Load(const char *module, const char *entry = "", Bool_t system = kFALSE);
00213 const char *GetLibraries(const char *regexp = "",
00214 const char *option = "",
00215 Bool_t isRegexp = kTRUE);
00216
00217
00218 TTime Now();
00219 void AddTimer(TTimer *ti);
00220 TTimer *RemoveTimer(TTimer *ti);
00221 void Sleep(UInt_t milliSec);
00222 Double_t GetRealTime();
00223 Double_t GetCPUTime();
00224
00225
00226 int ConnectService(const char *servername, int port, int tcpwindowsize);
00227 TInetAddress GetHostByName(const char *server);
00228 TInetAddress GetPeerName(int sock);
00229 TInetAddress GetSockName(int sock);
00230 int GetServiceByName(const char *service);
00231 char *GetServiceByPort(int port);
00232 int OpenConnection(const char *server, int port, int tcpwindowsize = -1);
00233 int AnnounceTcpService(int port, Bool_t reuse, int backlog, int tcpwindowsize = -1);
00234 int AnnounceUnixService(int port, int backlog);
00235 int AnnounceUnixService(const char *sockpath, int backlog);
00236 int AcceptConnection(int sock);
00237 void CloseConnection(int sock, Bool_t force = kFALSE);
00238 int RecvRaw(int sock, void *buffer, int length, int flag);
00239 int SendRaw(int sock, const void *buffer, int length, int flag);
00240 int RecvBuf(int sock, void *buffer, int length);
00241 int SendBuf(int sock, const void *buffer, int length);
00242 int SetSockOpt(int sock, int opt, int val);
00243 int GetSockOpt(int sock, int opt, int *val);
00244
00245 static int WinNTUnixConnect(int port);
00246 static int WinNTUnixConnect(const char *path);
00247
00248
00249 Int_t GetSysInfo(SysInfo_t *info) const;
00250 Int_t GetCpuInfo(CpuInfo_t *info, Int_t sampleTime = 1000) const;
00251 Int_t GetMemInfo(MemInfo_t *info) const;
00252 Int_t GetProcInfo(ProcInfo_t *info) const;
00253
00254 ClassDef(TWinNTSystem, 0)
00255 };
00256
00257 R__EXTERN ULong_t gConsoleWindow;
00258
00259 #endif