home *** CD-ROM | disk | FTP | other *** search
/ PC World 2000 January / PCWorld_2000-01_cd.bin / Software / Servis / Devc / _SETUP.4 / Group3 / io.h < prev    next >
C/C++ Source or Header  |  1998-12-24  |  4KB  |  145 lines

  1. /* 
  2.  * io.h
  3.  *
  4.  * System level I/O functions and types.
  5.  *
  6.  * This file is part of the Mingw32 package.
  7.  *
  8.  * Contributors:
  9.  *  Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
  10.  *
  11.  *  THIS SOFTWARE IS NOT COPYRIGHTED
  12.  *
  13.  *  This source code is offered for use in the public domain. You may
  14.  *  use, modify or distribute it freely.
  15.  *
  16.  *  This code is distributed in the hope that it will be useful but
  17.  *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
  18.  *  DISCLAMED. This includes but is not limited to warranties of
  19.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  20.  *
  21.  * $Revision: 2.5 $
  22.  * $Author: colin $
  23.  * $Date: 1998/05/12 22:24:04 $
  24.  *
  25.  */
  26.  
  27. #ifndef    __STRICT_ANSI__
  28.  
  29. #ifndef    _IO_H_
  30. #define    _IO_H_
  31.  
  32. /* We need the definition of FILE anyway... */
  33. #include <stdio.h>
  34.  
  35. /* MSVC's io.h contains the stuff from dir.h, so I will too.
  36.  * NOTE: This also defines off_t, the file offset type, through
  37.  *       an inclusion of sys/types.h */
  38. #include <dir.h>
  39.  
  40. /* TODO: Maximum number of open handles has not been tested, I just set
  41.  * it the same as FOPEN_MAX. */
  42. #define    HANDLE_MAX    FOPEN_MAX
  43.  
  44.  
  45. /* Some defines for _access nAccessMode (MS doesn't define them, but
  46.  * it doesn't seem to hurt to add them). */
  47. #define    F_OK    0    /* Check for file existence */
  48. #define    W_OK    2    /* Check for write permission */
  49. #define    R_OK    4    /* Check for read permission */
  50. /* TODO: Is this safe? X_OK not supported directly... */
  51. #define X_OK    R_OK    /* Check for execute permission */
  52.  
  53. #ifndef RC_INVOKED
  54.  
  55. #ifdef    __cplusplus
  56. extern "C" {
  57. #endif
  58.  
  59. int        _access (const char* szFileName, int nAccessMode);
  60. int        _chsize (int nHandle, long lnNewSize);
  61. int        _close (int nHandle);
  62.  
  63. /* NOTE: The only significant bit in unPermissions appears to be bit 7 (0x80),
  64.  *       the "owner write permission" bit (on FAT). */
  65. int        _creat (const char* szFileName, unsigned unPermissions);
  66.  
  67. int        _dup (int nHandle);
  68. int        _dup2 (int nOldHandle, int nNewHandle);
  69. long        _filelength (int nHandle);
  70. int        _fileno (FILE* fileGetHandle);
  71. long        _get_osfhandle (int nHandle);
  72. int        _isatty (int nHandle);
  73.  
  74. /* In a very odd turn of events this function is excluded from those
  75.  * files which define _STREAM_COMPAT. This is required in order to
  76.  * build GNU libio because of a conflict with _eof in streambuf.h
  77.  * line 107. Actually I might just be able to change the name of
  78.  * the enum member in streambuf.h... we'll see. TODO */
  79. #ifndef    _STREAM_COMPAT
  80. int        _eof (int nHandle);
  81. #endif
  82.  
  83. /* LK_... locking commands defined in sys/locking.h. */
  84. int        _locking (int nHandle, int nCmd, long lnLockRegionLength);
  85.  
  86. long        _lseek (int nHandle, long lnOffset, int nOrigin);
  87.  
  88. /* Optional third argument is unsigned unPermissions. */
  89. int        _open (const char* szFileName, int nFlags, ...);
  90.  
  91. int        _open_osfhandle (long lnOSHandle, int nFlags);
  92. int        _pipe (int *naHandles, unsigned int unSize, int nMode);
  93. int        _read (int nHandle, void* caBuffer, unsigned int nToRead);
  94.  
  95. /* SH_... flags for nShFlags defined in share.h
  96.  * Optional fourth argument is unsigned unPermissions */
  97. int        _sopen (char* szFileName, int nFlags, int nShFlags, ...);
  98.  
  99. long        _tell (int nHandle);
  100. /* Should umask be in sys/stat.h and/or sys/types.h instead? */
  101. int        _umask (int nMode);
  102. int        _unlink (const char* szFileName);
  103. int        _write (int nHandle, const void* caBuffer,
  104.                 unsigned int unToWrite);
  105.  
  106.  
  107. #ifndef    _NO_OLDNAMES
  108. /*
  109.  * Non-underscored versions of non-ANSI functions to improve portability.
  110.  * These functions live in libmoldname.a.
  111.  */
  112.  
  113. int        access (const char* szFileName, int nAccessMode);
  114. int        chsize (int nHandle, long lnNewSize);
  115. int        close (int nHandle);
  116. int        creat (const char* szFileName, int nAccessMode);
  117. int        dup (int nHandle);
  118. int        dup2 (int nOldHandle, int nNewHandle);
  119. int        eof (int nHandle);
  120. long        filelength (int nHandle);
  121. int        fileno (FILE* fileGetHandle);
  122. int        isatty (int nHandle);
  123. long        lseek (int nHandle, long lnOffset, int nOrigin);
  124. int        open (const char* szFileName, int nFlags, ...);
  125. int        read (int nHandle, void* caBuffer, unsigned int nToRead);
  126. int        sopen (char* szFileName, int nAccess, int nFlag, ...);
  127. long        tell (int nHandle);
  128. int        umask (int nMode);
  129. int        unlink (const char* szFileName);
  130. int        write (int nHandle, const void* caBuffer,
  131.                unsigned int nToWrite);
  132.  
  133. #endif    /* Not _NO_OLDNAMES */
  134.  
  135. #ifdef    __cplusplus
  136. }
  137. #endif
  138.  
  139. #endif    /* Not RC_INVOKED */
  140.  
  141. #endif    /* _IO_H_ not defined */
  142.  
  143. #endif    /* Not strict ANSI */
  144.  
  145.