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 78509 2007-05-28 19:36:42Z johnnyw $
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 (ACE_TCHAR **argv,
00068                       ACE_TCHAR *&buf,
00069                       bool substitute_env_args = true,
00070                       bool quote_args = false);
00071 
00072 #if !defined (ACE_LACKS_CHDIR)
00073   ACE_NAMESPACE_INLINE_FUNCTION
00074   int chdir (const char *path);
00075 
00076 #if defined (ACE_HAS_WCHAR)
00077   ACE_NAMESPACE_INLINE_FUNCTION
00078   int chdir (const wchar_t *path);
00079 #endif /* ACE_HAS_WCHAR */
00080 #endif /* ACE_LACKS_CHDIR */
00081 
00082   ACE_NAMESPACE_INLINE_FUNCTION
00083   int rmdir (const char *path);
00084 
00085 #if defined (ACE_HAS_WCHAR)
00086   ACE_NAMESPACE_INLINE_FUNCTION
00087   int rmdir (const wchar_t *path);
00088 #endif /* ACE_HAS_WCHAR */
00089 
00090   ACE_NAMESPACE_INLINE_FUNCTION
00091   int close (ACE_HANDLE handle);
00092 
00093   ACE_NAMESPACE_INLINE_FUNCTION
00094   ACE_HANDLE dup (ACE_HANDLE handle);
00095 
00096   ACE_NAMESPACE_INLINE_FUNCTION
00097   int dup2 (ACE_HANDLE oldfd,
00098             ACE_HANDLE newfd);
00099 
00100   extern ACE_Export
00101   int execl (const char *path,
00102              const char *arg0, ...);
00103 
00104   extern ACE_Export
00105   int execle (const char *path,
00106               const char *arg0, ...);
00107 
00108   extern ACE_Export
00109   int execlp (const char *file,
00110               const char *arg0, ...);
00111 
00112   ACE_NAMESPACE_INLINE_FUNCTION
00113   int execv (const char *path,
00114              char *const argv[]);
00115 
00116   ACE_NAMESPACE_INLINE_FUNCTION
00117   int execve (const char *path,
00118               char *const argv[],
00119               char *const envp[]);
00120 
00121   ACE_NAMESPACE_INLINE_FUNCTION
00122   int execvp (const char *file,
00123               char *const argv[]);
00124 
00125   //@{
00126   /// Forks and exec's a process in a manner that works on Solaris and
00127   /// NT.  argv[0] must be the full path name to the executable.
00128   ACE_NAMESPACE_INLINE_FUNCTION
00129   pid_t fork (void);
00130 
00131   // not in susv3
00132   extern ACE_Export
00133   pid_t fork (const ACE_TCHAR *program_name);
00134 
00135   extern ACE_Export
00136   pid_t fork_exec (ACE_TCHAR *argv[]);
00137 
00138   //@}
00139 
00140   ACE_NAMESPACE_INLINE_FUNCTION
00141   int fsync (ACE_HANDLE handle);
00142 
00143   ACE_NAMESPACE_INLINE_FUNCTION
00144   int ftruncate (ACE_HANDLE handle, ACE_OFF_T offset);
00145 
00146   ACE_NAMESPACE_INLINE_FUNCTION
00147   char *getcwd (char *, size_t);
00148 
00149 #if defined (ACE_HAS_WCHAR)
00150   ACE_NAMESPACE_INLINE_FUNCTION
00151   wchar_t *getcwd (wchar_t *, size_t);
00152 #endif /* ACE_HAS_WCHAR */
00153 
00154   ACE_NAMESPACE_INLINE_FUNCTION
00155   gid_t getgid (void);
00156 
00157   ACE_NAMESPACE_INLINE_FUNCTION
00158   gid_t getegid (void);
00159 
00160   ACE_NAMESPACE_INLINE_FUNCTION
00161   int getopt (int argc,
00162               char *const *argv,
00163               const char *optstring);
00164 
00165   ACE_NAMESPACE_INLINE_FUNCTION
00166   long getpagesize (void);
00167 
00168   ACE_NAMESPACE_INLINE_FUNCTION
00169   pid_t getpgid (pid_t pid);
00170 
00171   ACE_NAMESPACE_INLINE_FUNCTION
00172   pid_t getpid (void);
00173 
00174   ACE_NAMESPACE_INLINE_FUNCTION
00175   pid_t getppid (void);
00176 
00177   ACE_NAMESPACE_INLINE_FUNCTION
00178   uid_t getuid (void);
00179 
00180   ACE_NAMESPACE_INLINE_FUNCTION
00181   uid_t geteuid (void);
00182 
00183   // should call gethostname()
00184   ACE_NAMESPACE_INLINE_FUNCTION
00185   int hostname (char *name,
00186                 size_t maxnamelen);
00187 
00188 #if defined (ACE_HAS_WCHAR)
00189   ACE_NAMESPACE_INLINE_FUNCTION
00190   int hostname (wchar_t *name,
00191                 size_t maxnamelen);
00192 #endif /* ACE_HAS_WCHAR */
00193 
00194   ACE_NAMESPACE_INLINE_FUNCTION
00195   int isatty (int handle);
00196 
00197 #if defined (ACE_WIN32)
00198   ACE_NAMESPACE_INLINE_FUNCTION
00199   int isatty (ACE_HANDLE handle);
00200 #endif /* ACE_WIN32 */
00201 
00202   ACE_NAMESPACE_INLINE_FUNCTION
00203   ACE_OFF_T lseek (ACE_HANDLE handle,
00204                    ACE_OFF_T offset,
00205                    int whence);
00206 
00207 #if defined (ACE_HAS_LLSEEK) || defined (ACE_HAS_LSEEK64)
00208   ACE_NAMESPACE_INLINE_FUNCTION
00209   ACE_LOFF_T llseek (ACE_HANDLE handle,
00210                      ACE_LOFF_T offset,
00211                      int whence);
00212 #endif /* ACE_HAS_LLSEEK */
00213 
00214   /// Get the number of CPUs configured in the machine.
00215   extern ACE_Export
00216   long num_processors (void);
00217 
00218   /// Get the number of CPUs currently online.
00219   extern ACE_Export
00220   long num_processors_online (void);
00221 
00222   ACE_NAMESPACE_INLINE_FUNCTION
00223   int pipe (ACE_HANDLE handles[]);
00224 
00225   extern ACE_Export
00226   ssize_t pread (ACE_HANDLE handle,
00227                  void *buf,
00228                  size_t nbyte,
00229                  ACE_OFF_T offset);
00230 
00231   extern ACE_Export
00232   ssize_t pwrite (ACE_HANDLE handle,
00233                   const void *buf,
00234                   size_t nbyte,
00235                   ACE_OFF_T offset);
00236 
00237   ACE_NAMESPACE_INLINE_FUNCTION
00238   ssize_t read (ACE_HANDLE handle,
00239                 void *buf,
00240                 size_t len);
00241 
00242   ACE_NAMESPACE_INLINE_FUNCTION
00243   ssize_t read (ACE_HANDLE handle,
00244                 void *buf,
00245                 size_t len,
00246                 ACE_OVERLAPPED *);
00247 
00248   /**
00249    * Receive @a len bytes into @a buf from <handle> (uses the
00250    * <ACE_OS::read> call, which uses the <read> system call on UNIX
00251    * and the <ReadFile> call on Win32). If errors occur, -1 is
00252    * returned.  If EOF occurs, 0 is returned.  Whatever data has been
00253    * read will be returned to the caller through<bytes_transferred>.
00254    *
00255    */
00256   extern ACE_Export
00257   ssize_t read_n (ACE_HANDLE handle,
00258                   void *buf,
00259                   size_t len,
00260                   size_t *bytes_transferred = 0);
00261 
00262   ACE_NAMESPACE_INLINE_FUNCTION
00263   ssize_t readlink (const char *path,
00264                     char *buf,
00265                     size_t bufsiz);
00266 
00267   ACE_NAMESPACE_INLINE_FUNCTION
00268   void *sbrk (intptr_t brk);
00269 
00270   ACE_NAMESPACE_INLINE_FUNCTION
00271   int setgid (gid_t);
00272 
00273   ACE_NAMESPACE_INLINE_FUNCTION
00274   int setegid (gid_t);
00275 
00276   ACE_NAMESPACE_INLINE_FUNCTION
00277   int setpgid (pid_t pid, pid_t pgid);
00278 
00279   ACE_NAMESPACE_INLINE_FUNCTION
00280   int setregid (gid_t rgid, gid_t egid);
00281 
00282   ACE_NAMESPACE_INLINE_FUNCTION
00283   int setreuid (uid_t ruid, uid_t euid);
00284 
00285   ACE_NAMESPACE_INLINE_FUNCTION
00286   pid_t setsid (void);
00287 
00288   ACE_NAMESPACE_INLINE_FUNCTION
00289   int setuid (uid_t);
00290 
00291   ACE_NAMESPACE_INLINE_FUNCTION
00292   int seteuid (uid_t);
00293 
00294   ACE_NAMESPACE_INLINE_FUNCTION
00295   int sleep (u_int seconds);
00296 
00297   ACE_NAMESPACE_INLINE_FUNCTION
00298   int sleep (const ACE_Time_Value &tv);
00299 
00300   // used by ARGV::string_to_argv
00301   extern ACE_Export
00302   int string_to_argv (ACE_TCHAR *buf,
00303                       int &argc,
00304                       ACE_TCHAR **&argv,
00305                       bool substitute_env_args = true);
00306 
00307   ACE_NAMESPACE_INLINE_FUNCTION
00308   void swab (const void *src, void *dest, ssize_t n);
00309 
00310   ACE_NAMESPACE_INLINE_FUNCTION
00311   long sysconf (int);
00312 
00313   // not in susv3
00314   ACE_NAMESPACE_INLINE_FUNCTION
00315   long sysinfo (int cmd,
00316                 char *buf,
00317                 long count);
00318 
00319   ACE_NAMESPACE_INLINE_FUNCTION
00320   int truncate (const ACE_TCHAR *filename, ACE_OFF_T length);
00321 
00322   ACE_NAMESPACE_INLINE_FUNCTION
00323   useconds_t ualarm (useconds_t usecs,
00324                      useconds_t interval = 0);
00325 
00326   ACE_NAMESPACE_INLINE_FUNCTION
00327   useconds_t ualarm (const ACE_Time_Value &tv,
00328                      const ACE_Time_Value &tv_interval = ACE_Time_Value::zero);
00329 
00330   ACE_NAMESPACE_INLINE_FUNCTION
00331   int unlink (const char *path);
00332 
00333 #if defined (ACE_HAS_WCHAR)
00334   ACE_NAMESPACE_INLINE_FUNCTION
00335   int unlink (const wchar_t *path);
00336 #endif /* ACE_HAS_WCHAR */
00337 
00338   ACE_NAMESPACE_INLINE_FUNCTION
00339   ssize_t write (ACE_HANDLE handle,
00340                  const void *buf,
00341                  size_t nbyte);
00342 
00343   ACE_NAMESPACE_INLINE_FUNCTION
00344   ssize_t write (ACE_HANDLE handle,
00345                  const void *buf,
00346                  size_t nbyte,
00347                  ACE_OVERLAPPED *);
00348 
00349   /**
00350    * Send @a len bytes from @a buf to <handle> (uses the <ACE_OS::write>
00351    * calls, which is uses the <write> system call on UNIX and the
00352    * <WriteFile> call on Win32).  If errors occur, -1 is returned.  If
00353    * EOF occurs, 0 is returned.  Whatever data has been transmitted
00354    * will be returned to the caller through <bytes_transferred>.
00355    */
00356   extern ACE_Export
00357   ssize_t write_n (ACE_HANDLE handle,
00358                    const void *buf,
00359                    size_t len,
00360                    size_t *bytes_transferred = 0);
00361 
00362 } /* namespace ACE_OS */
00363 
00364 ACE_END_VERSIONED_NAMESPACE_DECL
00365 
00366 # if defined (ACE_HAS_INLINED_OSCALLS)
00367 #   if defined (ACE_INLINE)
00368 #     undef ACE_INLINE
00369 #   endif /* ACE_INLINE */
00370 #   define ACE_INLINE inline
00371 #   include "ace/OS_NS_unistd.inl"
00372 # endif /* ACE_HAS_INLINED_OSCALLS */
00373 
00374 # include /**/ "ace/post.h"
00375 #endif /* ACE_OS_NS_UNISTD_H */

Generated on Sun Jan 27 12:05:34 2008 for ACE by doxygen 1.3.6