ROOT  6.06/04
Reference Guide
TWinNTSystem.h
Go to the documentation of this file.
1 // @(#)root/winnt:$Id$
2 // Author: Fons Rademakers 15/09/95
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 
13 #ifndef ROOT_TWinNTSystem
14 #define ROOT_TWinNTSystem
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TWinNTSystem //
19 // //
20 // Class providing an interface to the Windows NT Operating System. //
21 // //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #ifndef ROOT_TSystem
25 #include "TSystem.h"
26 #endif
27 
28 
29 #if !defined(__CINT__)
30  #include "Windows4Root.h"
31  #include <commctrl.h>
32 #else
33  typedef void* HANDLE;
34  struct WIN32_FIND_DATA;
35  typedef void* HIMAGELIST;
36  typedef void* HICON;
37  typedef UChar_t BOOL;
38  struct FILE;
39 #endif
40 
41 #ifndef MAX_SID_SIZE
42 #define MAX_SID_SIZE 1024
43 #endif
44 #define MAX_NAME_STRING 1024
45 
46 #define SID_GROUP 0
47 #define SID_MEMBER 1
48 
49 struct passwd {
50  char *pw_name; // user name
51  char *pw_passwd; // user password
52  int pw_uid; // user ID
53  int pw_gid; // user's group ID
54  int pw_quota; //
55  char *pw_gecos; // user's real (long) name
56  char *pw_dir; // user home directory
57  char *pw_shell; // shell command
58  char *pw_group; // user's group name
59 };
60 
61 struct group {
62  char *gr_name; // group name
63  char *gr_passwd; // group password
64  int gr_gid; // group id
65  char **gr_mem; // group members
66 };
67 
68 
69 class TWinNTSystem : public TSystem {
70 public:
71  // pointer to message handler func
72  typedef Bool_t (*ThreadMsgFunc_t)(MSG*);
73 
74 private:
75  struct group *fGroups; // Groups on local computer
76  struct passwd *fPasswords; // Users on local computer
77  int fNbUsers; // Number of users on local computer
78  int fNbGroups; // Number of groups on local computer
79  int fActUser; // Index of actual user in User list
80  Bool_t fGroupsInitDone; // Flag used for Users and Groups initialization
81  Bool_t fFirstFile; // Flag used by OpenDirectory/GetDirEntry
82 
83  HANDLE fhProcess; // Handle of the current process
84  void *fGUIThreadHandle; // handle of GUI server (aka command) thread
85  ULong_t fGUIThreadId; // id of GUI server (aka command) thread
86  char *fDirNameBuffer; // The string buffer to hold path name
87  WIN32_FIND_DATA fFindFileData; // Structure to look for files (aka OpenDir under UNIX)
88 
89  Bool_t DispatchTimers(Bool_t mode);
90  Bool_t CheckDescriptors();
91  Bool_t CheckSignals(Bool_t sync);
92  Bool_t CountMembers(const char *lpszGroupName);
93  const char *GetLinkedLibraries();
94  Bool_t GetNbGroups();
95  Long_t LookupSID (const char *lpszAccountName, int what, int &groupIdx, int &memberIdx);
96  Bool_t CollectMembers(const char *lpszGroupName, int &groupIdx, int &memberIdx);
97  Bool_t CollectGroups();
98  Bool_t InitUsersGroups();
99  void DoBeep(Int_t freq=-1, Int_t duration=-1) const;
100 
101  static void ThreadStub(void *Parameter) {((TWinNTSystem *)Parameter)->TimerThread();}
102  void TimerThread();
103 
104 protected:
105  static int WinNTUnixConnect(int port);
106  static int WinNTUnixConnect(const char *path);
107  static int WinNTUdpConnect(const char *hostname, int port);
108 
109 public:
110  TWinNTSystem();
111  virtual ~TWinNTSystem();
112 
113  //---- non-TSystem methods ----------------------------------
114  HANDLE GetProcess();
115  Bool_t HandleConsoleEvent();
116 
117  //---- Misc -------------------------------------------------
118  Bool_t Init();
119  const char *BaseName(const char *name);
120  void SetProgname(const char *name);
121  const char *GetError();
122  const char *HostName();
123  void *GetGUIThreadHandle() const {return fGUIThreadHandle;}
124  ULong_t GetGUIThreadId() const {return fGUIThreadId;}
125  void SetGUIThreadMsgHandler(ThreadMsgFunc_t func);
126  void NotifyApplicationCreated();
127 
128 
129  //---- EventLoop --------------------------------------------
130  Bool_t ProcessEvents();
131  void DispatchOneEvent(Bool_t pendingOnly = kFALSE);
132  void ExitLoop();
133  Int_t Select(TList *active, Long_t timeout);
134  Int_t Select(TFileHandler *fh, Long_t timeout);
135 
136  //---- Handling of system events ----------------------------
137  void DispatchSignals(ESignals sig);
138  void AddSignalHandler(TSignalHandler *sh);
139  TSignalHandler *RemoveSignalHandler(TSignalHandler *sh);
140  void ResetSignal(ESignals sig, Bool_t reset = kTRUE);
141  void ResetSignals();
142  void IgnoreSignal(ESignals sig, Bool_t ignore = kTRUE);
143  void AddFileHandler(TFileHandler *fh);
144  TFileHandler *RemoveFileHandler(TFileHandler *fh);
145  void StackTrace();
146 
147  //---- Floating Point Exceptions Control --------------------
148  Int_t GetFPEMask();
149  Int_t SetFPEMask(Int_t mask = kDefaultMask);
150 
151  //---- Processes --------------------------------------------
152  int Exec(const char *shellcmd);
153  FILE *OpenPipe(const char *shellcmd, const char *mode);
154  int ClosePipe(FILE *pipe);
155  void Exit(int code, Bool_t mode = kTRUE);
156  void Abort(int code = 0);
157  int GetPid();
158 
159  //---- Environment manipulation -----------------------------
160  const char *Getenv(const char *name);
161  void Setenv(const char *name, const char *value);
162 
163  //---- Directories ------------------------------------------
164  int mkdir(const char *name, Bool_t recursive = kFALSE);
165  int MakeDirectory(const char *name);
166  Bool_t ChangeDirectory(const char *path);
167  const char *GetDirEntry(void *dirp);
168  const char *DirName(const char *pathname);
169  void FreeDirectory(void *dirp);
170  void *OpenDirectory(const char *name);
171  const char *WorkingDirectory(char driveletter);
172  const char *WorkingDirectory();
173  const char *HomeDirectory(const char *userName=0);
174  const char *TempDirectory() const;
175  FILE *TempFileName(TString &base, const char *dir = 0);
176 
177  //---- Users & Groups ---------------------------------------
178  Int_t GetUid(const char *user = 0);
179  Int_t GetGid(const char *group = 0);
180  Int_t GetEffectiveUid();
181  Int_t GetEffectiveGid();
182  UserGroup_t *GetUserInfo(Int_t uid);
183  UserGroup_t *GetUserInfo(const char *user = 0);
184  UserGroup_t *GetGroupInfo(Int_t gid);
185  UserGroup_t *GetGroupInfo(const char *group = 0);
186 
187  //---- Paths & Files ----------------------------------------
188  const char DriveName(const char *pathname="/");
189  const char *PrependPathName(const char *dir, TString& name);
190  Bool_t ExpandPathName(TString &patbuf);
191  char *ExpandPathName(const char *path);
192  Bool_t AccessPathName(const char *path, EAccessMode mode = kFileExists);
193  Bool_t IsPathLocal(const char *path);
194  Bool_t IsAbsoluteFileName(const char *dir);
195  int CopyFile(const char *from, const char *to, Bool_t overwrite = kFALSE);
196  int Rename(const char *from, const char *to);
197  int Link(const char *from, const char *to);
198  int Symlink(const char *from, const char *to);
199  int Unlink(const char *name);
200  int SetNonBlock(int fd);
201  int GetPathInfo(const char *path, FileStat_t &buf);
202  int GetFsInfo(const char *path, Long_t *id, Long_t *bsize,
203  Long_t *blocks, Long_t *bfree);
204  int Chmod(const char *file, UInt_t mode);
205  int Umask(Int_t mask);
206  int Utime(const char *file, Long_t modtime, Long_t actime);
207  const char *UnixPathName(const char *unixpathname);
208  const char *FindFile(const char *search, TString& file, EAccessMode mode = kFileExists);
209  TList *GetVolumes(Option_t *opt = "") const;
210 
211  //---- Standard Output redirection --------------------------
212  Int_t RedirectOutput(const char *name, const char *mode = "a", RedirectHandle_t *h = 0);
213 
214  //---- Dynamic Loading --------------------------------------
215  void AddDynamicPath(const char *dir);
216  const char *GetDynamicPath();
217  void SetDynamicPath(const char *path);
218  const char *FindDynamicLibrary(TString &lib, Bool_t quiet = kFALSE);
219  int Load(const char *module, const char *entry = "", Bool_t system = kFALSE);
220  const char *GetLibraries(const char *regexp = "",
221  const char *option = "",
222  Bool_t isRegexp = kTRUE);
223 
224  //---- Time & Date -------------------------------------------
225  TTime Now();
226  void AddTimer(TTimer *ti);
227  TTimer *RemoveTimer(TTimer *ti);
228  void Sleep(UInt_t milliSec);
229  Double_t GetRealTime();
230  Double_t GetCPUTime();
231 
232  //---- RPC --------------------------------------------------
233  int ConnectService(const char *servername, int port, int tcpwindowsize, const char *protocol = "tcp");
234  TInetAddress GetHostByName(const char *server);
235  TInetAddress GetPeerName(int sock);
236  TInetAddress GetSockName(int sock);
237  int GetServiceByName(const char *service);
238  char *GetServiceByPort(int port);
239  int OpenConnection(const char *server, int port, int tcpwindowsize = -1, const char *protocol = "tcp");
240  int AnnounceTcpService(int port, Bool_t reuse, int backlog, int tcpwindowsize = -1);
241  int AnnounceUdpService(int port, int backlog);
242  int AnnounceUnixService(int port, int backlog);
243  int AnnounceUnixService(const char *sockpath, int backlog);
244  int AcceptConnection(int sock);
245  void CloseConnection(int sock, Bool_t force = kFALSE);
246  int RecvRaw(int sock, void *buffer, int length, int flag);
247  int SendRaw(int sock, const void *buffer, int length, int flag);
248  int RecvBuf(int sock, void *buffer, int length);
249  int SendBuf(int sock, const void *buffer, int length);
250  int SetSockOpt(int sock, int opt, int val);
251  int GetSockOpt(int sock, int opt, int *val);
252 
253  //---- System, CPU and Memory info
254  Int_t GetSysInfo(SysInfo_t *info) const;
255  Int_t GetCpuInfo(CpuInfo_t *info, Int_t sampleTime = 1000) const;
256  Int_t GetMemInfo(MemInfo_t *info) const;
257  Int_t GetProcInfo(ProcInfo_t *info) const;
258 
260 };
261 
262 R__EXTERN ULong_t gConsoleWindow; // console window handle
263 
264 #endif
Bool_t fFirstFile
Definition: TWinNTSystem.h:81
int pw_quota
Definition: TWinNTSystem.h:54
int pw_uid
Definition: TWinNTSystem.h:52
WIN32_FIND_DATA fFindFileData
Definition: TWinNTSystem.h:87
struct group * fGroups
Definition: TWinNTSystem.h:75
char * pw_shell
Definition: TWinNTSystem.h:57
void * GetGUIThreadHandle() const
Definition: TWinNTSystem.h:123
int gr_gid
Definition: TWinNTSystem.h:64
const char Option_t
Definition: RtypesCore.h:62
TH1 * h
Definition: legend2.C:5
RooCmdArg Link(const char *state, RooAbsData &data)
char * gr_name
Definition: TWinNTSystem.h:62
This class represents an Internet Protocol (IP) address.
Definition: TInetAddress.h:40
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
char * gr_passwd
Definition: TWinNTSystem.h:63
static void ThreadStub(void *Parameter)
Definition: TWinNTSystem.h:101
Basic time type with millisecond precision.
Definition: TTime.h:29
void * fGUIThreadHandle
Definition: TWinNTSystem.h:84
HANDLE fhProcess
Definition: TWinNTSystem.h:83
#define ClassDef(name, id)
Definition: Rtypes.h:254
Int_t bsize[]
Definition: SparseFit4.cxx:31
void Init(TClassEdit::TInterpreterLookupHelper *helper)
Definition: TClassEdit.cxx:118
R__EXTERN ULong_t gConsoleWindow
Definition: TWinNTSystem.h:262
char * pw_name
Definition: TWinNTSystem.h:50
A doubly linked list.
Definition: TList.h:47
static const char * what
Definition: stlLoader.cc:6
ESignals
char * pw_gecos
Definition: TWinNTSystem.h:55
ULong_t fGUIThreadId
Definition: TWinNTSystem.h:85
Double_t length(const TVector2 &v)
Definition: CsgOps.cxx:347
char * pw_group
Definition: TWinNTSystem.h:58
unsigned int UInt_t
Definition: RtypesCore.h:42
struct passwd * fPasswords
Definition: TWinNTSystem.h:76
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:57
RooCmdArg Rename(const char *suffix)
long Long_t
Definition: RtypesCore.h:50
double Double_t
Definition: RtypesCore.h:55
Bool_t fGroupsInitDone
Definition: TWinNTSystem.h:80
unsigned long ULong_t
Definition: RtypesCore.h:51
double func(double *x, double *p)
Definition: stressTF1.cxx:213
EAccessMode
Definition: TSystem.h:54
#define name(a, b)
Definition: linkTestLib0.cpp:5
int pw_gid
Definition: TWinNTSystem.h:53
#define R__EXTERN
Definition: DllImport.h:27
char * pw_passwd
Definition: TWinNTSystem.h:51
char * pw_dir
Definition: TWinNTSystem.h:56
unsigned char UChar_t
Definition: RtypesCore.h:34
Abstract base class defining a generic interface to the underlying Operating System.
Definition: TSystem.h:258
const Bool_t kTRUE
Definition: Rtypes.h:91
float value
Definition: math.cpp:443
module
Definition: ROOT.py:93
ULong_t GetGUIThreadId() const
Definition: TWinNTSystem.h:124
char * fDirNameBuffer
Definition: TWinNTSystem.h:86
char ** gr_mem
Definition: TWinNTSystem.h:65