Synesis Software

include/unistd.h

Go to the documentation of this file.
00001 /* /////////////////////////////////////////////////////////////////////////////
00002  * File:    unistd.h
00003  *
00004  * Purpose: Declaration of various UNIX standard functions.
00005  *
00006  * Created: 1st November 2003
00007  * Updated: 16th February 2008
00008  *
00009  * Home:    http://synesis.com.au/software/
00010  *
00011  * Copyright (c) 2003-2008, Matthew Wilson and Synesis Software
00012  * All rights reserved.
00013  *
00014  * Redistribution and use in source and binary forms, with or without
00015  * modification, are permitted provided that the following conditions are met:
00016  *
00017  * - Redistributions of source code must retain the above copyright notice, this
00018  *   list of conditions and the following disclaimer.
00019  * - Redistributions in binary form must reproduce the above copyright notice,
00020  *   this list of conditions and the following disclaimer in the documentation
00021  *   and/or other materials provided with the distribution.
00022  * - Neither the names of Matthew Wilson and Synesis Software nor the names of
00023  *   any contributors may be used to endorse or promote products derived from
00024  *   this software without specific prior written permission.
00025  *
00026  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00027  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00029  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00030  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00031  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00032  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00033  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00034  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00035  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00036  * POSSIBILITY OF SUCH DAMAGE.
00037  *
00038  * ////////////////////////////////////////////////////////////////////////// */
00039 
00040 
00046 #ifndef SYNSOFT_UNIXEM_INCL_H_UNISTD
00047 #define SYNSOFT_UNIXEM_INCL_H_UNISTD
00048 
00049 #ifndef UNIXEM_DOCUMENTATION_SKIP_SECTION
00050 # define SYNSOFT_UNIXEM_VER_H_UNISTD_MAJOR      2
00051 # define SYNSOFT_UNIXEM_VER_H_UNISTD_MINOR      4
00052 # define SYNSOFT_UNIXEM_VER_H_UNISTD_REVISION   1
00053 # define SYNSOFT_UNIXEM_VER_H_UNISTD_EDIT       29
00054 #endif /* !UNIXEM_DOCUMENTATION_SKIP_SECTION */
00055 
00056 /* /////////////////////////////////////////////////////////////////////////////
00057  * Includes
00058  */
00059 
00060 #include <stddef.h>     /* for size_t */
00061 #include <sys/types.h>  /* for mode_t */
00062 
00063 /* Some of the functions declared here (and defined in unistd.c) may be
00064  * provided by some Win32 compilers. So we discriminate for support here,
00065  * and exclude definitions as appropriate.
00066  */
00067 
00068 #if defined(__BORLANDC__)
00069 # include <dir.h>
00070 # define UNIXEM_chdir_PROVIDED_BY_COMPILER
00071 # define UNIXEM_getcwd_PROVIDED_BY_COMPILER
00072 # define UNIXEM_mkdir_PROVIDED_BY_COMPILER
00073 # define UNIXEM_rmdir_PROVIDED_BY_COMPILER
00074 #elif defined(__DMC__)
00075 # include <direct.h>
00076 # define UNIXEM_chdir_PROVIDED_BY_COMPILER
00077 # define UNIXEM_close_PROVIDED_BY_COMPILER
00078 # define UNIXEM_getcwd_PROVIDED_BY_COMPILER
00079 #elif defined(__GNUC__)
00080 # include <io.h>
00081 # define UNIXEM_chdir_PROVIDED_BY_COMPILER
00082 # define UNIXEM_chmod_PROVIDED_BY_COMPILER
00083 # define UNIXEM_getcwd_PROVIDED_BY_COMPILER
00084 # define UNIXEM_mkdir_PROVIDED_BY_COMPILER
00085 # define UNIXEM_rmdir_PROVIDED_BY_COMPILER
00086 #elif defined(__INTEL_COMPILER)
00087 # if defined(_WIN32) && \
00088      !defined(__STDC__)
00089 #  include <direct.h>
00090 #  define UNIXEM_chdir_PROVIDED_BY_COMPILER
00091 #  define UNIXEM_getcwd_PROVIDED_BY_COMPILER
00092 #  define UNIXEM_mkdir_PROVIDED_BY_COMPILER
00093 #  define UNIXEM_rmdir_PROVIDED_BY_COMPILER
00094 # endif /* !__STDC__ */
00095 #elif defined(__MWERKS__)
00096 # define UNIXEM_mkdir_PROVIDED_BY_COMPILER
00097 #elif defined(__WATCOMC__)
00098 # define UNIXEM_chdir_PROVIDED_BY_COMPILER
00099 # define UNIXEM_getcwd_PROVIDED_BY_COMPILER
00100 # define UNIXEM_mkdir_PROVIDED_BY_COMPILER
00101 # define UNIXEM_rmdir_PROVIDED_BY_COMPILER
00102 #elif defined(_MSC_VER)
00103 # if !defined(__STDC__)
00104 #  include <direct.h>
00105 #  define UNIXEM_chdir_PROVIDED_BY_COMPILER
00106 #  define UNIXEM_getcwd_PROVIDED_BY_COMPILER
00107 #  define UNIXEM_mkdir_PROVIDED_BY_COMPILER
00108 #  define UNIXEM_rmdir_PROVIDED_BY_COMPILER
00109 # endif /* !__STDC__ */
00110 #else
00111 # error Compiler not discriminated
00112 #endif /* compiler */
00113 
00114 
00115 #if defined(_MSC_VER) && \
00116     !defined(__STDC__)
00117 # define UNIXEM_UNISTD_INCLUDING_MS_DIRECT_H
00118 #endif /* compiler */
00119 
00120 /* ////////////////////////////////////////////////////////////////////////// */
00121 
00132 /* ////////////////////////////////////////////////////////////////////////// */
00133 
00134 #ifndef _WIN32
00135 # error This file is only currently defined for compilation on Win32 systems
00136 #endif /* _WIN32 */
00137 
00138 /* /////////////////////////////////////////////////////////////////////////////
00139  * Constants and definitions
00140  */
00141 
00142 //#ifndef PATH_MAX
00143 //# define PATH_MAX   (260)   /*!< \brief The maximum number of characters (including null terminator) in a directory entry name */
00144 //#endif /* !PATH_MAX */
00145 
00146 enum
00147 {
00148         _PC_LINK_MAX                    
00149 #define _PC_LINK_MAX            _PC_LINK_MAX
00150     ,   _PC_MAX_CANON                   
00151 #define _PC_MAX_CANON           _PC_MAX_CANON
00152     ,   _PC_MAX_INPUT                   
00153 #define _PC_MAX_INPUT           _PC_MAX_INPUT
00154     ,   _PC_NAME_MAX                    
00155 #define _PC_NAME_MAX            _PC_NAME_MAX
00156     ,   _PC_PATH_MAX                    
00157 #define _PC_PATH_MAX            _PC_PATH_MAX
00158  
00159     ,   _PC_PIPE_BUF                    
00160 #define _PC_PIPE_BUF            _PC_PIPE_BUF
00161     ,   _PC_CHOWN_RESTRICTED            
00162 #define _PC_CHOWN_RESTRICTED    _PC_CHOWN_RESTRICTED
00163     ,   _PC_NO_TRUNC                    
00164 #define _PC_NO_TRUNC            _PC_NO_TRUNC
00165     ,   _PC_VDISABLE                    
00166 #define _PC_VDISABLE            _PC_VDISABLE
00167     ,   _PC_AIX_DISK_PARTITION          
00170 #define _PC_AIX_DISK_PARTITION    _PC_AIX_DISK_PARTITION
00171     ,   _PC_AIX_DISK_SIZE               
00176 #define _PC_AIX_DISK_SIZE           _PC_AIX_DISK_SIZE
00177     ,   _PC_FILESIZEBITS                
00178 #define _PC_FILESIZEBITS            _PC_FILESIZEBITS
00179     ,   _PC_SYNC_IO                     
00180 #define _PC_SYNC_IO                 _PC_SYNC_IO
00181 };
00182 
00183 /* /////////////////////////////////////////////////////////////////////////////
00184  * API functions
00185  */
00186 
00187 #ifdef __cplusplus
00188 extern "C" {
00189 #endif /* __cplusplus */
00190 
00203 int link(const char *originalFile, const char *linkName);
00204 
00211 int unlink(const char *path);
00212 
00213 
00222 #ifndef UNIXEM_chdir_PROVIDED_BY_COMPILER
00223 int chdir(const char *dirName);
00224 #endif /* !UNIXEM_chdir_PROVIDED_BY_COMPILER */
00225 
00226 
00236 #ifndef UNIXEM_getcwd_PROVIDED_BY_COMPILER
00237 char *getcwd(char *buffer, size_t max_len);
00238 #endif /* !UNIXEM_getcwd_PROVIDED_BY_COMPILER */
00239 
00240 
00250 #ifndef UNIXEM_mkdir_PROVIDED_BY_COMPILER
00251 int mkdir(const char *dirName, unsigned mode);
00252 #endif /* !UNIXEM_mkdir_PROVIDED_BY_COMPILER */
00253 
00254 
00262 #ifndef UNIXEM_rmdir_PROVIDED_BY_COMPILER
00263 int rmdir(const char *dirName);
00264 #endif /* !UNIXEM_rmdir_PROVIDED_BY_COMPILER */
00265 
00271 #ifndef UNIXEM_close_PROVIDED_BY_COMPILER
00272 int close(int handle);
00273 #endif /* !UNIXEM_close_PROVIDED_BY_COMPILER */
00274 
00275 /* * \brief Creates a pipe
00276  *
00277  * \param handles An array of two handles. handles[0] will be set to the
00278  * read stream. handels[1] will be set to the write stream
00279  * \return 0 on success, or -1 if there is an error
00280  */
00281 /* int pipe(int handles[2]); */
00282 
00285 int getpagesize(void);
00286 
00289 long pathconf(char const *path, int name);
00290 
00291 
00299 char *realpath(char const *path, char resolvedPath[]);
00300 
00305 int usleep(unsigned long microSeconds);
00306 
00307 #ifdef __cplusplus
00308 } /* extern "C" */
00309 #endif /* __cplusplus */
00310 
00311 /* ////////////////////////////////////////////////////////////////////////// */
00312 
00315 /* ////////////////////////////////////////////////////////////////////////// */
00316 
00317 #endif /* SYNSOFT_UNIXEM_INCL_H_UNISTD */
00318 
00319 /* ////////////////////////////////////////////////////////////////////////// */

UNIX Emulation for Win32 Libraries documentation © Synesis Software Pty Ltd, 2002-2007