OS_NS_unistd.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   OS_NS_unistd.h
00006  *
00007  *  $Id: OS_NS_unistd.h 81156 2008-03-30 20:56:47Z iliyan $
00008  *
00009  *  @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
00010  *  @author Jesper S. M|ller<stophph@diku.dk>
00011  *  @author and a cast of thousands...
00012  *
00013  *  Originally in OS.h.
00014  */
00015 //=============================================================================
00016 
00017 #ifndef ACE_OS_NS_UNISTD_H
00018 # define ACE_OS_NS_UNISTD_H
00019 
00020 # include /**/ "ace/pre.h"
00021 
00022 # include "ace/config-all.h"
00023 
00024 # if !defined (ACE_LACKS_PRAGMA_ONCE)
00025 #  pragma once
00026 # endif /* ACE_LACKS_PRAGMA_ONCE */
00027 
00028 #include /**/ "ace/ACE_export.h"
00029 #include "ace/Time_Value.h"
00030 #include "ace/Basic_Types.h"
00031 #include "ace/os_include/os_unistd.h"
00032 #include "ace/os_include/os_stdio.h"
00033 
00034 
00035 #if defined (ACE_EXPORT_MACRO)
00036 #  undef ACE_EXPORT_MACRO
00037 #endif
00038 #define ACE_EXPORT_MACRO ACE_Export
00039 
00040 // This should go in os_unistd.h, but since we don't yet implement any code
00041 // at that level, we put it here.  It used to be in OS.i.
00042 #if defined (ACE_NEEDS_FTRUNCATE)
00043 extern "C" ACE_Export int ftruncate (ACE_HANDLE handle, long len);
00044 #endif /* ACE_NEEDS_FTRUNCATE */
00045 
00046 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00047 
00048 namespace ACE_OS
00049 {
00050 
00051   ACE_NAMESPACE_INLINE_FUNCTION
00052   int access (const char *path, int amode);
00053 
00054 #if defined (ACE_HAS_WCHAR)
00055   ACE_NAMESPACE_INLINE_FUNCTION
00056   int access (const wchar_t *path, int amode);
00057 #endif /* ACE_HAS_WCHAR */
00058 
00059   ACE_NAMESPACE_INLINE_FUNCTION
00060   unsigned int alarm (u_int secs);
00061 
00062   ACE_NAMESPACE_INLINE_FUNCTION
00063   long allocation_granularity (void);
00064 
00065   // used by ARGV::argv_to_string() and ACE_OS::fork_exec()
00066   extern ACE_Export
00067   int argv_to_string (int argc,
00068                       ACE_TCHAR **argv,
00069                       ACE_TCHAR *&buf,
00070                       bool substitute_env_args = true,
00071                       bool quote_args = false);
00072 
00073   extern ACE_Export
00074   int argv_to_string (ACE_TCHAR **argv,
00075                       ACE_TCHAR *&buf,
00076                       bool substitute_env_args = true,
00077                       bool quote_args = false);
00078 
00079 #if !defined (ACE_LACKS_CHDIR)
00080   ACE_NAMESPACE_INLINE_FUNCTION
00081   int chdir (const char *path);
00082 
00083 #if defined (ACE_HAS_WCHAR)
00084   ACE_NAMESPACE_INLINE_FUNCTION
00085   int chdir (const wchar_t *path);
00086 #endif /* ACE_HAS_WCHAR */
00087 #endif /* ACE_LACKS_CHDIR */
00088 
00089   ACE_NAMESPACE_INLINE_FUNCTION
00090   int rmdir (const char *path);
00091 
00092 #if defined (ACE_HAS_WCHAR)
00093   ACE_NAMESPACE_INLINE_FUNCTION
00094   int rmdir (const wchar_t *path);
00095 #endif /* ACE_HAS_WCHAR */
00096 
00097   ACE_NAMESPACE_INLINE_FUNCTION
00098   int close (ACE_HANDLE handle);
00099 
00100   ACE_NAMESPACE_INLINE_FUNCTION
00101   ACE_HANDLE dup (ACE_HANDLE handle);
00102 
00103   ACE_NAMESPACE_INLINE_FUNCTION
00104   int dup2 (ACE_HANDLE oldfd,
00105             ACE_HANDLE newfd);
00106 
00107   extern ACE_Export
00108   int execl (const char *path,
00109              const char *arg0, ...);
00110 
00111   extern ACE_Export
00112   int execle (const char *path,
00113               const char *arg0, ...);
00114 
00115   extern ACE_Export
00116   int execlp (const char *file,
00117               const char *arg0, ...);
00118 
00119   ACE_NAMESPACE_INLINE_FUNCTION
00120   int execv (const char *path,
00121              char *const argv[]);
00122 
00123   ACE_NAMESPACE_INLINE_FUNCTION
00124   int execve (const char *path,
00125               char *const argv[],
00126               char *const envp[]);
00127 
00128   ACE_NAMESPACE_INLINE_FUNCTION
00129   int execvp (const char *file,
00130               char *const argv[]);
00131 
00132   //@{
00133   /// Forks and exec's a process in a manner that works on Solaris and
00134   /// NT.  argv[0] must be the full path name to the executable.
00135   ACE_NAMESPACE_INLINE_FUNCTION
00136   pid_t fork (void);
00137 
00138   // not in susv3
00139   extern ACE_Export
00140   pid_t fork (const ACE_TCHAR *program_name);
00141 
00142   extern ACE_Export
00143   pid_t fork_exec (ACE_TCHAR *argv[]);
00144 
00145   //@}
00146 
00147   ACE_NAMESPACE_INLINE_FUNCTION
00148   int fsync (ACE_HANDLE handle);
00149 
00150   ACE_NAMESPACE_INLINE_FUNCTION
00151   int ftruncate (ACE_HANDLE handle, ACE_OFF_T offset);
00152 
00153   ACE_NAMESPACE_INLINE_FUNCTION
00154   char *getcwd (char *, size_t);
00155 
00156 #if defined (ACE_HAS_WCHAR)
00157   ACE_NAMESPACE_INLINE_FUNCTION
00158   wchar_t *getcwd (wchar_t *, size_t);
00159 #endif /* ACE_HAS_WCHAR */
00160 
00161   ACE_NAMESPACE_INLINE_FUNCTION
00162   gid_t getgid (void);
00163 
00164   ACE_NAMESPACE_INLINE_FUNCTION
00165   gid_t getegid (void);
00166 
00167   ACE_NAMESPACE_INLINE_FUNCTION
00168   int getopt (int argc,
00169               char *const *argv,
00170               const char *optstring);
00171 
00172   ACE_NAMESPACE_INLINE_FUNCTION
00173   long getpagesize (void);
00174 
00175   ACE_NAMESPACE_INLINE_FUNCTION
00176   pid_t getpgid (pid_t pid);
00177 
00178   ACE_NAMESPACE_INLINE_FUNCTION
00179   pid_t getpid (void);
00180 
00181   ACE_NAMESPACE_INLINE_FUNCTION
00182   pid_t getppid (void);
00183 
00184   ACE_NAMESPACE_INLINE_FUNCTION
00185   uid_t getuid (void);
00186 
00187   ACE_NAMESPACE_INLINE_FUNCTION
00188   uid_t geteuid (void);
00189 
00190   // should call gethostname()
00191   ACE_NAMESPACE_INLINE_FUNCTION
00192   int hostname (char *name,
00193                 size_t maxnamelen);
00194 
00195 #if defined (ACE_HAS_WCHAR)
00196   ACE_NAMESPACE_INLINE_FUNCTION
00197   int hostname (wchar_t *name,
00198                 size_t maxnamelen);
00199 #endif /* ACE_HAS_WCHAR */
00200 
00201   ACE_NAMESPACE_INLINE_FUNCTION
00202   int isatty (int handle);
00203 
00204 #if defined (ACE_WIN32)
00205   ACE_NAMESPACE_INLINE_FUNCTION
00206   int isatty (ACE_HANDLE handle);
00207 #endif /* ACE_WIN32 */
00208 
00209   ACE_NAMESPACE_INLINE_FUNCTION
00210   ACE_OFF_T lseek (ACE_HANDLE handle,
00211                    ACE_OFF_T offset,
00212                    int whence);
00213 
00214 #if defined (ACE_HAS_LLSEEK) || defined (ACE_HAS_LSEEK64)
00215   ACE_NAMESPACE_INLINE_FUNCTION
00216   ACE_LOFF_T llseek (ACE_HANDLE handle,
00217                      ACE_LOFF_T offset,
00218                      int whence);
00219 #endif /* ACE_HAS_LLSEEK */
00220 
00221   /// Get the number of CPUs configured in the machine.
00222   extern ACE_Export
00223   long num_processors (void);
00224 
00225   /// Get the number of CPUs currently online.
00226   extern ACE_Export
00227   long num_processors_online (void);
00228 
00229   ACE_NAMESPACE_INLINE_FUNCTION
00230   int pipe (ACE_HANDLE handles[]);
00231 
00232   extern ACE_Export
00233   ssize_t pread (ACE_HANDLE handle,
00234                  void *buf,
00235                  size_t nbyte,
00236                  ACE_OFF_T offset);
00237 
00238   extern ACE_Export
00239   ssize_t pwrite (ACE_HANDLE handle,
00240                   const void *buf,
00241                   size_t nbyte,
00242                   ACE_OFF_T offset);
00243 
00244   ACE_NAMESPACE_INLINE_FUNCTION
00245   ssize_t read (ACE_HANDLE handle,
00246                 void *buf,
00247                 size_t len);
00248 
00249   ACE_NAMESPACE_INLINE_FUNCTION
00250   ssize_t read (ACE_HANDLE handle,
00251                 void *buf,
00252                 size_t len,
00253                 ACE_OVERLAPPED *);
00254 
00255   /**
00256    * Receive @a len bytes into @a buf from <handle> (uses the
00257    * <ACE_OS::read> call, which uses the <read> system call on UNIX
00258    * and the <ReadFile> call on Win32). If errors occur, -1 is
00259    * returned.  If EOF occurs, 0 is returned.  Whatever data has been
00260    * read will be returned to the caller through<bytes_transferred>.
00261    *
00262    */
00263   extern ACE_Export
00264   ssize_t read_n (ACE_HANDLE handle,
00265                   void *buf,
00266                   size_t len,
00267                   size_t *bytes_transferred = 0);
00268 
00269   ACE_NAMESPACE_INLINE_FUNCTION
00270   ssize_t readlink (const char *path,
00271                     char *buf,
00272                     size_t bufsiz);
00273 
00274   ACE_NAMESPACE_INLINE_FUNCTION
00275   void *sbrk (intptr_t brk);
00276 
00277   ACE_NAMESPACE_INLINE_FUNCTION
00278   int setgid (gid_t);
00279 
00280   ACE_NAMESPACE_INLINE_FUNCTION
00281   int setegid (gid_t);
00282 
00283   ACE_NAMESPACE_INLINE_FUNCTION
00284   int setpgid (pid_t pid, pid_t pgid);
00285 
00286   ACE_NAMESPACE_INLINE_FUNCTION
00287   int setregid (gid_t rgid, gid_t egid);
00288 
00289   ACE_NAMESPACE_INLINE_FUNCTION
00290   int setreuid (uid_t ruid, uid_t euid);
00291 
00292   ACE_NAMESPACE_INLINE_FUNCTION
00293   pid_t setsid (void);
00294 
00295   ACE_NAMESPACE_INLINE_FUNCTION
00296   int setuid (uid_t);
00297 
00298   ACE_NAMESPACE_INLINE_FUNCTION
00299   int seteuid (uid_t);
00300 
00301   ACE_NAMESPACE_INLINE_FUNCTION
00302   int sleep (u_int seconds);
00303 
00304   ACE_NAMESPACE_INLINE_FUNCTION
00305   int sleep (const ACE_Time_Value &tv);
00306 
00307   // used by ARGV::string_to_argv
00308   extern ACE_Export
00309   int string_to_argv (ACE_TCHAR *buf,
00310                       int &argc,
00311                       ACE_TCHAR **&argv,
00312                       bool substitute_env_args = true);
00313 
00314   ACE_NAMESPACE_INLINE_FUNCTION
00315   void swab (const void *src, void *dest, ssize_t n);
00316 
00317   ACE_NAMESPACE_INLINE_FUNCTION
00318   long sysconf (int);
00319 
00320   // not in susv3
00321   ACE_NAMESPACE_INLINE_FUNCTION
00322   long sysinfo (int cmd,
00323                 char *buf,
00324                 long count);
00325 
00326   ACE_NAMESPACE_INLINE_FUNCTION
00327   int truncate (const ACE_TCHAR *filename, ACE_OFF_T length);
00328 
00329   ACE_NAMESPACE_INLINE_FUNCTION
00330   useconds_t ualarm (useconds_t usecs,
00331                      useconds_t interval = 0);
00332 
00333   ACE_NAMESPACE_INLINE_FUNCTION
00334   useconds_t ualarm (const ACE_Time_Value &tv,
00335                      const ACE_Time_Value &tv_interval = ACE_Time_Value::zero);
00336 
00337   ACE_NAMESPACE_INLINE_FUNCTION
00338   int unlink (const char *path);
00339 
00340 #if defined (ACE_HAS_WCHAR)
00341   ACE_NAMESPACE_INLINE_FUNCTION
00342   int unlink (const wchar_t *path);
00343 #endif /* ACE_HAS_WCHAR */
00344 
00345   ACE_NAMESPACE_INLINE_FUNCTION
00346   ssize_t write (ACE_HANDLE handle,
00347                  const void *buf,
00348                  size_t nbyte);
00349 
00350   ACE_NAMESPACE_INLINE_FUNCTION
00351   ssize_t write (ACE_HANDLE handle,
00352                  const void *buf,
00353                  size_t nbyte,
00354                  ACE_OVERLAPPED *);
00355 
00356   /**
00357    * Send @a len bytes from @a buf to @a handle (uses the <ACE_OS::write>
00358    * calls, which is uses the <write> system call on UNIX and the
00359    * <WriteFile> call on Win32).  If errors occur, -1 is returned.  If
00360    * EOF occurs, 0 is returned.  Whatever data has been transmitted
00361    * will be returned to the caller through <bytes_transferred>.
00362    */
00363   extern ACE_Export
00364   ssize_t write_n (ACE_HANDLE handle,
00365                    const void *buf,
00366                    size_t len,
00367                    size_t *bytes_transferred = 0);
00368 
00369 } /* namespace ACE_OS */
00370 
00371 ACE_END_VERSIONED_NAMESPACE_DECL
00372 
00373 # if defined (ACE_HAS_INLINED_OSCALLS)
00374 #   if defined (ACE_INLINE)
00375 #     undef ACE_INLINE
00376 #   endif /* ACE_INLINE */
00377 #   define ACE_INLINE inline
00378 #   include "ace/OS_NS_unistd.inl"
00379 # endif /* ACE_HAS_INLINED_OSCALLS */
00380 
00381 # include /**/ "ace/post.h"
00382 #endif /* ACE_OS_NS_UNISTD_H */

Generated on Tue Feb 2 17:18:41 2010 for ACE by  doxygen 1.4.7