TUnixSystem


class description - source file - inheritance tree

class TUnixSystem : public TSystem


    protected:
virtual char* DynamicPathName(const char* lib, Bool_t quiet = kFALSE) static void* FindDynLib(const char* lib) static const char* GetDynamicPath() const static int ReadUtmpFile() static void* SearchUtmpEntry(int nentries, const char* tty) static Func_t UnixDynFindSymbol(const char* lib, const char* entry) static void UnixDynListLibs(const char* lib) static void UnixDynListSymbols(const char* lib, const char* re) static int UnixDynLoad(const char* lib) static void UnixDynUnload(const char* lib) static int UnixFilestat(const char* path, Long_t* id, Long_t* size, Long_t* flags, Long_t* modtime) static int UnixFSstat(const char* path, Long_t* id, Long_t* bsize, Long_t* blocks, Long_t* bfree) static const char* UnixGetdirentry(void* dir) const static const char* UnixHomedirectory(const char* user = "0") const static void UnixIgnoreSignal(ESignals sig, Bool_t ignore) static int UnixMakedir(const char* name) static Long_t UnixNow() static void* UnixOpendir(const char* name) static int UnixRecv(int sock, void* buf, int len, int flag) static void UnixResetSignal(ESignals sig) static void UnixResetSignals() static int UnixSelect(UInt_t nfds, TFdSet* readready, TFdSet* writeready, Long_t timeout) static int UnixSend(int sock, const void* buf, int len, int flag) static int UnixSetitimer(Long_t ms) static void UnixSignal(ESignals sig, void* h) static const char* UnixSigname(ESignals sig) const static int UnixTcpConnect(const char* hostname, int port, int tcpwindowsize) static int UnixTcpService(int port, Bool_t reuse, int backlog, int tcpwindowsize) static int UnixUnixConnect(int port) static int UnixUnixService(int port, int backlog) static int UnixWaitchild() public:
TUnixSystem TUnixSystem() TUnixSystem TUnixSystem(const TUnixSystem&) virtual void ~TUnixSystem() virtual void Abort(int code = 0) virtual int AcceptConnection(int sock) virtual Bool_t AccessPathName(const char* path, EAccessMode mode = kFileExists) virtual void AddFileHandler(TFileHandler* fh) virtual void AddSignalHandler(TSignalHandler* sh) virtual void AddTimer(TTimer* ti) virtual int AnnounceTcpService(int port, Bool_t reuse, int backlog, int tcpwindowsize = -1) virtual int AnnounceUnixService(int port, int backlog) virtual Bool_t ChangeDirectory(const char* path) void CheckChilds() Bool_t CheckDescriptors() Bool_t CheckSignals(Bool_t sync) static TClass* Class() virtual void CloseConnection(int sock, Bool_t force = kFALSE) virtual void Closelog() virtual int ClosePipe(FILE* pipe) virtual char* ConcatFileName(const char* dir, const char* name) int ConnectService(const char* server, int port, int tcpwindowsize) virtual int CopyFile(const char* from, const char* to, Bool_t overwrite = kFALSE) virtual void DispatchOneEvent(Bool_t pendingOnly = kFALSE) void DispatchSignals(ESignals sig) Bool_t DispatchTimers(Bool_t mode) virtual Func_t DynFindSymbol(const char* module, const char* entry) virtual int Exec(const char* shellcmd) virtual void Exit(int code, Bool_t mode = kTRUE) virtual Bool_t ExpandPathName(TString& patbuf) virtual char* ExpandPathName(const char* path) virtual void FreeDirectory(void* dirp) virtual const char* GetDirEntry(void* dirp) const virtual const char* Getenv(const char* name) const virtual const char* GetError() const virtual int GetFsInfo(const char* path, Long_t* id, Long_t* bsize, Long_t* blocks, Long_t* bfree) virtual TInetAddress GetHostByName(const char* server) virtual int GetPathInfo(const char* path, Long_t* id, Long_t* size, Long_t* flags, Long_t* modtime) virtual TInetAddress GetPeerName(int sock) virtual int GetPid() virtual int GetServiceByName(const char* service) virtual char* GetServiceByPort(int port) virtual TInetAddress GetSockName(int sock) virtual int GetSockOpt(int sock, int option, int* val) virtual const char* HomeDirectory(const char* userName = "0") const virtual const char* HostName() const virtual void IgnoreSignal(ESignals sig, Bool_t ignore = kTRUE) virtual Bool_t Init() virtual TClass* IsA() const virtual int Link(const char* from, const char* to) virtual void ListLibraries(const char* regexp) virtual void ListSymbols(const char* module, const char* re) virtual int Load(const char* module, const char* entry, Bool_t system = kFALSE) virtual int MakeDirectory(const char* name) virtual TTime Now() virtual int OpenConnection(const char* server, int port, int tcpwindowsize = -1) virtual void* OpenDirectory(const char* name) virtual void Openlog(const char* name, Int_t options, ELogFacility facility) virtual FILE* OpenPipe(const char* shellcmd, const char* mode) virtual int RecvBuf(int sock, void* buffer, int length) virtual int RecvRaw(int sock, void* buffer, int length, int flag) virtual TFileHandler* RemoveFileHandler(TFileHandler* fh) virtual TSignalHandler* RemoveSignalHandler(TSignalHandler* sh) virtual TTimer* RemoveTimer(TTimer* ti) virtual int Rename(const char* from, const char* to) virtual void ResetSignal(ESignals sig, Bool_t reset = kTRUE) virtual void ResetTimer(TTimer* ti) virtual int SendBuf(int sock, const void* buffer, int length) virtual int SendRaw(int sock, const void* buffer, int length, int flag) virtual void SetDisplay() virtual void Setenv(const char* name, const char* value) virtual void SetProgname(const char* name) virtual int SetSockOpt(int sock, int option, int val) virtual void ShowMembers(TMemberInspector& insp, char* parent) virtual void Sleep(UInt_t milliSec) virtual void StackTrace() virtual void Streamer(TBuffer& b) void StreamerNVirtual(TBuffer& b) virtual int Symlink(const char* from, const char* to) virtual void Syslog(ELogLevel level, const char* mess) virtual int Umask(Int_t mask) virtual int Unlink(const char* name) virtual void Unload(const char* module) virtual int Utime(const char* file, Long_t modtime, Long_t actime) virtual char* Which(const char* search, const char* file, EAccessMode mode = kFileExists) virtual const char* WorkingDirectory() const

Data Members




Class Description

                                                                      
 TUnixSystem                                                          
                                                                      
 Class providing an interface to the UNIX Operating System.           
                                                                      


TUnixSystem() : TSystem("Unix", "Unix System")

~TUnixSystem()
 Reset to original state.

Bool_t Init()
 Initialize Unix system interface.

void SetProgname(const char *name)
 Set the application name (from command line, argv[0]) and copy it in
 gProgName. Copy the application pathname in gProgPath.

void SetDisplay()
 Set DISPLAY environment variable based on utmp entry. Only for UNIX.

const char* GetError()
 Return system error string.

const char* HostName()
 Return the system's host name.

void AddFileHandler(TFileHandler *h)
 Add a file handler to the list of system file handlers.

TFileHandler* RemoveFileHandler(TFileHandler *h)
 Remove a file handler from the list of file handlers.

void AddSignalHandler(TSignalHandler *h)
 Add a signal handler to list of system signal handlers.

TSignalHandler* RemoveSignalHandler(TSignalHandler *h)
 Remove a signal handler from list of signal handlers.

void ResetSignal(ESignals sig, Bool_t reset)
 If reset is true reset the signal handler for the specified signal
 to the default handler, else restore previous behaviour.

void IgnoreSignal(ESignals sig, Bool_t ignore)
 If ignore is true ignore the specified signal, else restore previous
 behaviour.

void DispatchOneEvent(Bool_t pendingOnly)
 Dispatch a single event.

void Sleep(UInt_t milliSec)
 Sleep milliSec milliseconds.

void DispatchSignals(ESignals sig)
 Handle and dispatch signals.

Bool_t CheckSignals(Bool_t sync)
 Check if some signals were raised and call their Notify() member.

void CheckChilds()
 Check if childs have finished.

Bool_t CheckDescriptors()
 Check if there is activity on some file descriptors and call their
 Notify() member.

int MakeDirectory(const char *name)
 Make a Unix file system directory. Returns 0 in case of success and
 -1 if the directory could not be created.

void* OpenDirectory(const char *name)
 Open a Unix file system directory. Returns 0 if directory does not exist.

void FreeDirectory(void *dirp)
 Close a Unix file system directory.

const char* GetDirEntry(void *dirp)
 Get next Unix file system directory entry. Returns 0 if no more entries.

Bool_t ChangeDirectory(const char *path)
 Change directory. Returns kTRUE in case of success, kFALSE otherwise.

const char* WorkingDirectory()
 Return working directory.

const char* HomeDirectory(const char *userName)
 Return the user's home directory.

char* ConcatFileName(const char *dir, const char *name)
 Concatenate a directory and a file name. Returned string must be
 deleted by user.

Bool_t AccessPathName(const char *path, EAccessMode mode)
 Returns FALSE if one can access a file using the specified access mode.
 Mode is the same as for the Unix access(2) function.
 Attention, bizarre convention of return value!!

int CopyFile(const char *f, const char *t, Bool_t overwrite)
 Copy a file. If overwrite is true and file already exists the
 file will be overwritten. Returns 0 when successful, -1 in case
 of failure, -2 in case the file already exists and overwrite was false.

int Rename(const char *f, const char *t)
 Rename a file. Returns 0 when successful, -1 in case of failure.

int GetPathInfo(const char *path, Long_t *id, Long_t *size, Long_t *flags, Long_t *modtime)
 Get info about a file: id, size, flags, modification time.
 Id      is (statbuf.st_dev << 24) + statbuf.st_ino
 Size    is the file size
 Flags   is file type: 0 is regular file, bit 0 set executable,
                       bit 1 set directory, bit 2 set special file
                       (socket, fifo, pipe, etc.)
 Modtime is modification time.
 The function returns 0 in case of success and 1 if the file could
 not be stat'ed.

int GetFsInfo(const char *path, Long_t *id, Long_t *bsize, Long_t *blocks, Long_t *bfree)
 Get info about a file system: id, bsize, bfree, blocks.
 Id      is file system type (machine dependend, see statfs())
 Bsize   is block size of file system
 Blocks  is total number of blocks in file system
 Bfree   is number of free blocks in file system
 The function returns 0 in case of success and 1 if the file system could
 not be stat'ed.

int Link(const char *from, const char *to)
 Create a link from file1 to file2. Returns 0 when successful,
 -1 in case of failure.

int Symlink(const char *from, const char *to)
 Create a symlink from file1 to file2. Returns 0 when succesfull,
 -1 in case of failure.

int Unlink(const char *name)
 Unlink, i.e. remove, a file or directory. Returns 0 when succesfull,
 -1 in case of failure.

Bool_t ExpandPathName(TString &path)
 Expand a pathname getting rid of special shell characters like ~.$, etc.
 For Unix/Win32 compatibility use $(XXX) instead of $XXX when using
 environment variables in a pathname. If compatibility is not an issue
 you can use on Unix directly $XXX.

Bool_t ExpandPathName(TString &patbuf0)
 Expand a pathname getting rid of special shell characters like ~.$, etc.
 For Unix/Win32 compatibility use $(XXX) instead of $XXX when using
 environment variables in a pathname. If compatibility is not an issue
 you can use on Unix directly $XXX.

char* ExpandPathName(const char *path)
 Expand a pathname getting rid of special shell characaters like ~.$, etc.
 For Unix/Win32 compatibility use $(XXX) instead of $XXX when using
 environment variables in a pathname. If compatibility is not an issue
 you can use on Unix directly $XXX. The user must delete returned string.

int Umask(Int_t mask)
 Set the process file creation mode mask.

int Utime(const char *file, Long_t modtime, Long_t actime)
 Set a files modification and access times. If actime = 0 it will be
 set to the modtime. Returns 0 on success and -1 in case of error.

char* Which(const char *search, const char *wfil, EAccessMode mode)
 Find location of file "wfil" in a search path.
 The search path is specified as a : separated list of directories.
 User must delete returned string. Returns 0 in case file is not found.

void Setenv(const char *name, const char *value)
 Set environment variable. The string passed will be owned by
 the environment and can not be reused till a "name" is set
 again. The solution below will lose the space for the string
 in that case, but if this functions is not called thousands
 of times that should not be a problem.

const char* Getenv(const char *name)
 Get environment variable.

int Exec(const char *shellcmd)
 Execute a command.

FILE* OpenPipe(const char *command, const char *mode)
 Open a pipe.

int ClosePipe(FILE *pipe)
 Close the pipe.

int GetPid()
 Get process id.

void Exit(int code, Bool_t mode)
 Exit the application.

void Abort(int)
 Abort the application.

void StackTrace()
 Print a stack trace.

void Openlog(const char *name, Int_t options, ELogFacility facility)
 Open connection to system log daemon. For the use of the options and
 facility see the Unix openlog man page.

void Syslog(ELogLevel level, const char *mess)
 Send mess to syslog daemon. Level is the logging level and mess the
 message that will be written on the log.

void Closelog()
 Close connection to system log daemon.

Func_t DynFindSymbol(const char *module, const char *entry)

int Load(const char *module, const char *entry, Bool_t system)
 Load a shared library. Returns 0 on successful loading, 1 in
 case lib was already loaded and -1 in case lib does not exist
 or in case of error.

void Unload(const char *module)
 Unload a shared library.

void ListSymbols(const char *module, const char *regexp)
 List symbols in a shared library.

void ListLibraries(const char *regexp)
 List all loaded shared libraries.

TTime Now()
 Return current time.

Bool_t DispatchTimers(Bool_t mode)
 Handle and dispatch timers. If mode = kTRUE dispatch synchronous
 timers else a-synchronous timers.

void AddTimer(TTimer *ti)
 Add timer to list of system timers.

TTimer* RemoveTimer(TTimer *ti)
 Remove timer from list of system timers.

void ResetTimer(TTimer *ti)
 Reset a-sync timer.

TInetAddress GetHostByName(const char *hostname)
 Get Internet Protocol (IP) address of host. Returns an TInetAddress
 object. To see if the hostname lookup was successfull call
 TInetAddress::IsValid().

TInetAddress GetSockName(int sock)
 Get Internet Protocol (IP) address of host and port #.

TInetAddress GetPeerName(int sock)
 Get Internet Protocol (IP) address of remote host and port #.

int GetServiceByName(const char *servicename)
 Get port # of internet service.

char* GetServiceByPort(int port)
 Get name of internet service.

int ConnectService(const char *servername, int port, int tcpwindowsize)
 Connect to service servicename on server servername.

int OpenConnection(const char *server, int port, int tcpwindowsize)
 Open a connection to a service on a server. Returns -1 in case
 connection cannot be opened.
 Use tcpwindowsize to specify the size of the receive buffer, it has
 to be specified here to make sure the window scale option is set (for
 tcpwindowsize > 65KB and for platforms supporting window scaling).
 Is called via the TSocket constructor.

int AnnounceTcpService(int port, Bool_t reuse, int backlog, int tcpwindowsize)
 Announce TCP/IP service.
 Open a socket, bind to it and start listening for TCP/IP connections
 on the port. If reuse is true reuse the address, backlog specifies
 how many sockets can be waiting to be accepted.
 Use tcpwindowsize to specify the size of the receive buffer, it has
 to be specified here to make sure the window scale option is set (for
 tcpwindowsize > 65KB and for platforms supporting window scaling).
 Returns socket fd or -1 if socket() failed, -2 if bind() failed
 or -3 if listen() failed.

int AnnounceUnixService(int port, int backlog)
 Announce unix domain service.

int AcceptConnection(int sock)
 Accept a connection. In case of an error return -1. In case
 non-blocking I/O is enabled and no connections are available
 return -2.

void CloseConnection(int sock, Bool_t force)
 Close socket.

int RecvBuf(int sock, void *buf, int length)
 Receive a buffer headed by a length indicator. Lenght is the size of
 the buffer. Returns the number of bytes received in buf or -1 in
 case of error.

int SendBuf(int sock, const void *buf, int length)
 Send a buffer headed by a length indicator. Returns length of sent buffer
 or -1 in case of error.

int RecvRaw(int sock, void *buf, int length, int opt)
 Receive exactly length bytes into buffer. Use opt to receive out-of-band
 data or to have a peek at what is in the buffer (see TSocket). Buffer
 must be able to store at least length bytes. Returns the number of
 bytes received (can be 0 if other side of connection was closed) or -1
 in case of error, -2 in case of MSG_OOB and errno == EWOULDBLOCK, -3
 in case of MSG_OOB and errno == EINVAL and -4 in case of kNoBlock and
 errno == EWOULDBLOCK.

int SendRaw(int sock, const void *buf, int length, int opt)
 Send exactly length bytes from buffer. Use opt to send out-of-band
 data (see TSocket). Returns the number of bytes sent or -1 in case of
 error. Returns -4 in case of kNoBlock and errno == EWOULDBLOCK.

int SetSockOpt(int sock, int opt, int val)
 Set socket option.

int GetSockOpt(int sock, int opt, int *val)
 Get socket option.

void UnixSignal(ESignals sig, SigHandler_t handler)
 Set a signal handler for a signal.

void UnixIgnoreSignal(ESignals sig, Bool_t ignore)
 If ignore is true ignore the specified signal, else restore previous
 behaviour.

const char* UnixSigname(ESignals sig)
 Return the signal name associated with a signal.

void UnixResetSignal(ESignals sig)
 Restore old signal handler for specified signal.

void UnixResetSignals()
 Restore old signal handlers.

Long_t UnixNow()
 Get current time in milliseconds since 0:00 Jan 1 1995.

int UnixSetitimer(Long_t ms)
 Set interval timer to time-out in ms milliseconds.

int UnixSelect(UInt_t nfds, TFdSet *readready, TFdSet *writeready, Long_t timeout)
 Wait for events on the file descriptors specified in the readready and
 writeready masks or for timeout (in milliseconds) to occur.

const char* UnixHomedirectory(const char *name)
 Returns the user's home directory.

int UnixMakedir(const char *dir)
 Make a Unix file system directory. Returns 0 in case of success and
 -1 if the directory could not be created.

void* UnixOpendir(const char *dir)
 Open a directory.

const char* UnixGetdirentry(void *dirp1)
 Returns the next directory entry.

int UnixFilestat(const char *path, Long_t *id, Long_t *size, Long_t *flags, Long_t *modtime)
 Get info about a file: id, size, flags, modification time.
 Id      is (statbuf.st_dev << 24) + statbuf.st_ino
 Size    is the file size
 Flags   is file type: 0 is regular file, bit 0 set executable,
                       bit 1 set directory, bit 2 set special file
                       (socket, fifo, pipe, etc.)
 Modtime is modification time.
 The function returns 0 in case of success and 1 if the file could
 not be stat'ed.

int UnixFSstat(const char *path, Long_t *id, Long_t *bsize, Long_t *blocks, Long_t *bfree)
 Get info about a file system: id, bsize, bfree, blocks.
 Id      is file system type (machine dependend, see statfs())
 Bsize   is block size of file system
 Blocks  is total number of blocks in file system
 Bfree   is number of free blocks in file system
 The function returns 0 in case of success and 1 if the file system could
 not be stat'ed.

int UnixWaitchild()
 Wait till child is finished.

int UnixTcpConnect(const char *hostname, int port, int tcpwindowsize)
 Open a TCP/IP connection to server and connect to a service (i.e. port).
 Use tcpwindowsize to specify the size of the receive buffer, it has
 to be specified here to make sure the window scale option is set (for
 tcpwindowsize > 65KB and for platforms supporting window scaling).
 Is called via the TSocket constructor.

int UnixUnixConnect(int port)
 Connect to a Unix domain socket.

int UnixTcpService(int port, Bool_t reuse, int backlog, int tcpwindowsize)
 Open a socket, bind to it and start listening for TCP/IP connections
 on the port. If reuse is true reuse the address, backlog specifies
 how many sockets can be waiting to be accepted. If port is 0 a port
 scan will be done to find a free port. This option is mutual exlusive
 with the reuse option.
 Use tcpwindowsize to specify the size of the receive buffer, it has
 to be specified here to make sure the window scale option is set (for
 tcpwindowsize > 65KB and for platforms supporting window scaling).
 Returns socket fd or -1 if socket() failed, -2 if bind() failed
 or -3 if listen() failed.

int UnixUnixService(int port, int backlog)
 Open a socket, bind to it and start listening for Unix domain connections
 to it. Returns socket fd or -1.

int UnixRecv(int sock, void *buffer, int length, int flag)
 Receive exactly length bytes into buffer. Returns number of bytes
 received. Returns -1 in case of error, -2 in case of MSG_OOB
 and errno == EWOULDBLOCK, -3 in case of MSG_OOB and errno == EINVAL
 and -4 in case of kNoBlock and errno == EWOULDBLOCK.

int UnixSend(int sock, const void *buffer, int length, int flag)
 Send exactly length bytes from buffer. Returns -1 in case of error,
 otherwise number of sent bytes. Returns -4 in case of kNoBlock and
 errno == EWOULDBLOCK.

const char* GetDynamicPath()
 Get shared library search path. Static utility function.

char* DynamicPathName(const char *lib, Bool_t quiet)
 Returns the path of a shared library (searches for library in the
 shared library search path). If no file name extension is provided
 it first tries .so, .sl, .dl and then .a (for AIX). The returned string
 must be deleted.

void* FindDynLib(const char *lib)
 Returns the handle to a loaded shared library. Returns 0 when library
 not loaded.

int UnixDynLoad(const char *lib)
 Load a shared library. Returns 0 on successful loading, 1 in
 case lib was already loaded and -1 in case lib does not exist
 or in case of error.

Func_t UnixDynFindSymbol(const char *lib, const char *entry)
 Finds and returns a function pointer to a symbol in the shared library.
 Returns 0 when symbol not found.

void UnixDynListSymbols(const char *lib, const char *regexp)
 List symbols in a shared library. One can use wildcards to list only
 the intresting symbols.

void UnixDynListLibs(const char *lib)
 List all loaded shared libraries.

void UnixDynUnload(const char *lib)
 Unload a shared library.

int ReadUtmpFile()
 Read utmp file. Returns number of entries in utmp file.

void* SearchUtmpEntry(int n, const char *tty)
 Look for utmp entry which is connected to terminal tty.



Inline Functions


            TClass* Class()
            TClass* IsA() const
               void ShowMembers(TMemberInspector& insp, char* parent)
               void Streamer(TBuffer& b)
               void StreamerNVirtual(TBuffer& b)
        TUnixSystem TUnixSystem(const TUnixSystem&)


Author: Fons Rademakers 15/09/95
Last update: root/unix:$Name: $:$Id: TUnixSystem.cxx,v 1.58 2003/04/06 21:30:13 rdm Exp $
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *


ROOT page - Class index - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.