home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 June / Chip_2002-06_cd1.bin / zkuste / cecko / install / devcpp4920.exe / include / io.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-09-17  |  7.8 KB  |  295 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: 1.4 $
  22.  * $Author: cgf $
  23.  * $Date: 2000/02/05 04:04:54 $
  24.  *
  25.  */
  26.  
  27. #ifndef    __STRICT_ANSI__
  28.  
  29. #ifndef    _IO_H_
  30. #define    _IO_H_
  31.  
  32. /* All the headers include this file. */
  33. #include <_mingw.h>
  34.  
  35. /* We need the definition of FILE anyway... */
  36. #include <stdio.h>
  37.  
  38. /* MSVC's io.h contains the stuff from dir.h, so I will too.
  39.  * NOTE: This also defines off_t, the file offset type, through
  40.  *       an inclusion of sys/types.h */
  41. #ifndef __STRICT_ANSI__
  42.  
  43. #include <sys/types.h>    /* To get time_t. */
  44.  
  45. /*
  46.  * Attributes of files as returned by _findfirst et al.
  47.  */
  48. #define    _A_NORMAL    0x00000000
  49. #define    _A_RDONLY    0x00000001
  50. #define    _A_HIDDEN    0x00000002
  51. #define    _A_SYSTEM    0x00000004
  52. #define    _A_VOLID    0x00000008
  53. #define    _A_SUBDIR    0x00000010
  54. #define    _A_ARCH        0x00000020
  55.  
  56.  
  57. #ifndef RC_INVOKED
  58.  
  59. #ifndef    _FSIZE_T_DEFINED
  60. typedef    unsigned long    _fsize_t;
  61. #define _FSIZE_T_DEFINED
  62. #endif
  63.  
  64. /*
  65.  * The following structure is filled in by _findfirst or _findnext when
  66.  * they succeed in finding a match.
  67.  */
  68. struct _finddata_t
  69. {
  70.     unsigned    attrib;        /* Attributes, see constants above. */
  71.     time_t        time_create;
  72.     time_t        time_access;    /* always midnight local time */
  73.     time_t        time_write;
  74.     _fsize_t    size;
  75.     char        name[FILENAME_MAX];    /* may include spaces. */
  76. };
  77.  
  78. struct _finddatai64_t {
  79.     unsigned    attrib;
  80.     time_t      time_create;
  81.     time_t      time_access;
  82.     time_t      time_write;
  83.     __int64     size;
  84.     char        name[FILENAME_MAX];
  85. };
  86.  
  87.  
  88. #ifndef _WFINDDATA_T_DEFINED
  89. struct _wfinddata_t {
  90.         unsigned    attrib;
  91.         time_t        time_create;    /* -1 for FAT file systems */
  92.         time_t        time_access;    /* -1 for FAT file systems */
  93.         time_t        time_write;
  94.         _fsize_t    size;
  95.         wchar_t        name[FILENAME_MAX];    /* may include spaces. */
  96. };
  97. struct _wfinddatai64_t {
  98.     unsigned    attrib;
  99.     time_t      time_create;
  100.     time_t      time_access;
  101.     time_t      time_write;
  102.     __int64     size;
  103.     wchar_t     name[FILENAME_MAX];
  104. };
  105.  
  106. #define _WFINDDATA_T_DEFINED
  107. #endif
  108.  
  109. #ifdef    __cplusplus
  110. extern "C" {
  111. #endif
  112.  
  113. /*
  114.  * Functions for searching for files. _findfirst returns -1 if no match
  115.  * is found. Otherwise it returns a handle to be used in _findnext and
  116.  * _findclose calls. _findnext also returns -1 if no match could be found,
  117.  * and 0 if a match was found. Call _findclose when you are finished.
  118.  */
  119. int    _findfirst (const char*, struct _finddata_t*);
  120. int    _findnext (int, struct _finddata_t*);
  121. int    _findclose (int);
  122.  
  123. int    _chdir (const char*);
  124. char*    _getcwd (char*, int);
  125. int    _mkdir (const char*);
  126. char*    _mktemp (char*);
  127. int    _rmdir (const char*);
  128.  
  129. #ifdef __MSVCRT__
  130. __int64  _filelengthi64(int);
  131. long _findfirsti64(const char*, struct _finddatai64_t*);
  132. int _findnexti64(long, struct _finddatai64_t*);
  133. __int64  _lseeki64(int, __int64, int);
  134. __int64  _telli64(int);
  135. #endif /* __MSVCRT__ */
  136.  
  137.  
  138. #ifndef _NO_OLDNAMES
  139.  
  140. #ifndef _UWIN
  141. int    chdir (const char*);
  142. char*    getcwd (char*, int);
  143. int    mkdir (const char*);
  144. char*    mktemp (char*);
  145. int    rmdir (const char*);
  146. #endif /* _UWIN */
  147.  
  148. #endif /* Not _NO_OLDNAMES */
  149.  
  150. #ifdef    __cplusplus
  151. }
  152. #endif
  153.  
  154. #endif    /* Not RC_INVOKED */
  155.  
  156. #endif    /* Not __STRICT_ANSI__ */
  157.  
  158. /* TODO: Maximum number of open handles has not been tested, I just set
  159.  * it the same as FOPEN_MAX. */
  160. #define    HANDLE_MAX    FOPEN_MAX
  161.  
  162.  
  163. /* Some defines for _access nAccessMode (MS doesn't define them, but
  164.  * it doesn't seem to hurt to add them). */
  165. #define    F_OK    0    /* Check for file existence */
  166. #define    X_OK    1    /* Check for execute permission. */
  167. #define    W_OK    2    /* Check for write permission */
  168. #define    R_OK    4    /* Check for read permission */
  169.  
  170. #ifndef RC_INVOKED
  171.  
  172. #ifdef    __cplusplus
  173. extern "C" {
  174. #endif
  175.  
  176. int        _access (const char*, int);
  177. int        _chsize (int, long);
  178. int        _close (int);
  179.  
  180. /* NOTE: The only significant bit in unPermissions appears to be bit 7 (0x80),
  181.  *       the "owner write permission" bit (on FAT). */
  182. int        _creat (const char*, unsigned);
  183.  
  184. int        _dup (int);
  185. int        _dup2 (int, int);
  186. long        _filelength (int);
  187. int        _fileno (FILE*);
  188. long        _get_osfhandle (int);
  189. int        _isatty (int);
  190.  
  191. /* In a very odd turn of events this function is excluded from those
  192.  * files which define _STREAM_COMPAT. This is required in order to
  193.  * build GNU libio because of a conflict with _eof in streambuf.h
  194.  * line 107. Actually I might just be able to change the name of
  195.  * the enum member in streambuf.h... we'll see. TODO */
  196. #ifndef    _STREAM_COMPAT
  197. int        _eof (int);
  198. #endif
  199.  
  200. /* LK_... locking commands defined in sys/locking.h. */
  201. int        _locking (int, int, long);
  202.  
  203. long        _lseek (int, long, int);
  204.  
  205. /* Optional third argument is unsigned unPermissions. */
  206. int        _open (const char*, int, ...);
  207.  
  208. int        _open_osfhandle (long, int);
  209. int        _pipe (int *, unsigned int, int);
  210. int        _read (int, void*, unsigned int);
  211.  
  212. /* SH_... flags for nShFlags defined in share.h
  213.  * Optional fourth argument is unsigned unPermissions */
  214. int        _sopen (const char*, int, int, ...);
  215.  
  216. long        _tell (int);
  217. /* Should umask be in sys/stat.h and/or sys/types.h instead? */
  218. int        _umask (int);
  219. int        _unlink (const char*);
  220. int        _write (int, const void*, unsigned int);
  221.  
  222. /* Wide character versions. Also declared in wchar.h. */
  223. /* Not in crtdll.dll */
  224. #if !defined (_WIO_DEFINED)
  225. #if defined (__MSVCRT__)
  226. int         _waccess(const wchar_t*, int);
  227. int         _wchmod(const wchar_t*, int);
  228. int         _wcreat(const wchar_t*, int);
  229. long         _wfindfirst(wchar_t*, struct _wfinddata_t*);
  230. int         _wfindnext(long, struct _wfinddata_t *);
  231. int         _wunlink(const wchar_t*);
  232. int         _wopen(const wchar_t*, int, ...);
  233. int         _wsopen(const wchar_t*, int, int, ...);
  234. wchar_t *     _wmktemp(wchar_t*);
  235. long  _wfindfirsti64(const wchar_t*, struct _wfinddatai64_t*);
  236. int  _wfindnexti64(long, struct _wfinddatai64_t*);
  237. #endif /* defined (__MSVCRT__) */
  238. #define _WIO_DEFINED
  239. #endif /* _WIO_DEFINED */
  240.  
  241. #ifndef    _NO_OLDNAMES
  242. /*
  243.  * Non-underscored versions of non-ANSI functions to improve portability.
  244.  * These functions live in libmoldname.a.
  245.  */
  246.  
  247. #ifndef _UWIN
  248. int        access (const char*, int);
  249. int        chsize (int, long );
  250. int        close (int);
  251. int        creat (const char*, int);
  252. int        dup (int);
  253. int        dup2 (int, int);
  254. int        eof (int);
  255. long        filelength (int);
  256. int        fileno (FILE*);
  257. int        isatty (int);
  258. long        lseek (int, long, int);
  259. int        open (const char*, int, ...);
  260. int        read (int, void*, unsigned int);
  261. int        sopen (const char*, int, int, ...);
  262. long        tell (int);
  263. int        umask (int);
  264. int        unlink (const char*);
  265. int        write (int, const void*, unsigned int);
  266. #endif /* _UWIN */
  267.  
  268. /* Wide character versions. Also declared in wchar.h. */
  269. /* Where do these live? Not in libmoldname.a nor in libmsvcrt.a */
  270. #if 0
  271. int         waccess(const wchar_t *, int);
  272. int         wchmod(const wchar_t *, int);
  273. int         wcreat(const wchar_t *, int);
  274. long         wfindfirst(wchar_t *, struct _wfinddata_t *);
  275. int         wfindnext(long, struct _wfinddata_t *);
  276. int         wunlink(const wchar_t *);
  277. int         wrename(const wchar_t *, const wchar_t *);
  278. int         wopen(const wchar_t *, int, ...);
  279. int         wsopen(const wchar_t *, int, int, ...);
  280. wchar_t *     wmktemp(wchar_t *);
  281. #endif
  282.  
  283. #endif    /* Not _NO_OLDNAMES */
  284.  
  285. #ifdef    __cplusplus
  286. }
  287. #endif
  288.  
  289. #endif    /* Not RC_INVOKED */
  290.  
  291. #endif    /* _IO_H_ not defined */
  292.  
  293. #endif    /* Not strict ANSI */
  294.  
  295.