home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 14 / hacker14.iso / programacao / cwin / c.exe / $INSTDIR / include / io.h < prev    next >
Encoding:
C/C++ Source or Header  |  2003-12-15  |  7.6 KB  |  301 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.  *  DISCLAIMED. This includes but is not limited to warranties of
  19.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  20.  *
  21.  * $Revision: 1.6 $
  22.  * $Author: earnie $
  23.  * $Date: 2002/11/12 15:29:38 $
  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. int _chmod (const char*, int);
  129.  
  130.  
  131. #ifdef __MSVCRT__
  132. __int64  _filelengthi64(int);
  133. long _findfirsti64(const char*, struct _finddatai64_t*);
  134. int _findnexti64(long, struct _finddatai64_t*);
  135. __int64  _lseeki64(int, __int64, int);
  136. __int64  _telli64(int);
  137. #endif /* __MSVCRT__ */
  138.  
  139.  
  140. #ifndef _NO_OLDNAMES
  141.  
  142. #ifndef _UWIN
  143. int    chdir (const char*);
  144. char*    getcwd (char*, int);
  145. int    mkdir (const char*);
  146. char*    mktemp (char*);
  147. int    rmdir (const char*);
  148. int chmod (const char*, int);
  149. #endif /* _UWIN */
  150.  
  151. #endif /* Not _NO_OLDNAMES */
  152.  
  153. #ifdef    __cplusplus
  154. }
  155. #endif
  156.  
  157. #endif    /* Not RC_INVOKED */
  158.  
  159. #endif    /* Not __STRICT_ANSI__ */
  160.  
  161. /* TODO: Maximum number of open handles has not been tested, I just set
  162.  * it the same as FOPEN_MAX. */
  163. #define    HANDLE_MAX    FOPEN_MAX
  164.  
  165.  
  166. /* Some defines for _access nAccessMode (MS doesn't define them, but
  167.  * it doesn't seem to hurt to add them). */
  168. #define    F_OK    0    /* Check for file existence */
  169. #define    X_OK    1    /* Check for execute permission. */
  170. #define    W_OK    2    /* Check for write permission */
  171. #define    R_OK    4    /* Check for read permission */
  172.  
  173. #ifndef RC_INVOKED
  174.  
  175. #ifdef    __cplusplus
  176. extern "C" {
  177. #endif
  178.  
  179. int        _access (const char*, int);
  180. int        _chsize (int, long);
  181. int        _close (int);
  182. int        _commit(int);
  183.  
  184. /* NOTE: The only significant bit in unPermissions appears to be bit 7 (0x80),
  185.  *       the "owner write permission" bit (on FAT). */
  186. int        _creat (const char*, int);
  187.  
  188. int        _dup (int);
  189. int        _dup2 (int, int);
  190. long        _filelength (int);
  191. int        _fileno (FILE*);
  192. long        _get_osfhandle (int);
  193. int        _isatty (int);
  194.  
  195. /* In a very odd turn of events this function is excluded from those
  196.  * files which define _STREAM_COMPAT. This is required in order to
  197.  * build GNU libio because of a conflict with _eof in streambuf.h
  198.  * line 107. Actually I might just be able to change the name of
  199.  * the enum member in streambuf.h... we'll see. TODO */
  200. #ifndef    _STREAM_COMPAT
  201. int        _eof (int);
  202. #endif
  203.  
  204. /* LK_... locking commands defined in sys/locking.h. */
  205. int        _locking (int, int, long);
  206.  
  207. long        _lseek (int, long, int);
  208.  
  209. /* Optional third argument is unsigned unPermissions. */
  210. int        _open (const char*, int, ...);
  211.  
  212. int        _open_osfhandle (long, int);
  213. int        _pipe (int *, unsigned int, int);
  214. int        _read (int, void*, unsigned int);
  215. int        _setmode (int, int);
  216.  
  217. /* SH_... flags for nShFlags defined in share.h
  218.  * Optional fourth argument is unsigned unPermissions */
  219. int        _sopen (const char*, int, int, ...);
  220.  
  221. long        _tell (int);
  222. /* Should umask be in sys/stat.h and/or sys/types.h instead? */
  223. int        _umask (int);
  224. int        _unlink (const char*);
  225. int        _write (int, const void*, unsigned int);
  226.  
  227. /* Wide character versions. Also declared in wchar.h. */
  228. /* Not in crtdll.dll */
  229. #if !defined (_WIO_DEFINED)
  230. #if defined (__MSVCRT__)
  231. int         _waccess(const wchar_t*, int);
  232. int         _wchmod(const wchar_t*, int);
  233. int         _wcreat(const wchar_t*, int);
  234. long         _wfindfirst(const wchar_t*, struct _wfinddata_t*);
  235. int         _wfindnext(long, struct _wfinddata_t *);
  236. int         _wunlink(const wchar_t*);
  237. int         _wopen(const wchar_t*, int, ...);
  238. int         _wsopen(const wchar_t*, int, int, ...);
  239. wchar_t *     _wmktemp(wchar_t*);
  240. long  _wfindfirsti64(const wchar_t*, struct _wfinddatai64_t*);
  241. int  _wfindnexti64(long, struct _wfinddatai64_t*);
  242. #endif /* defined (__MSVCRT__) */
  243. #define _WIO_DEFINED
  244. #endif /* _WIO_DEFINED */
  245.  
  246. #ifndef    _NO_OLDNAMES
  247. /*
  248.  * Non-underscored versions of non-ANSI functions to improve portability.
  249.  * These functions live in libmoldname.a.
  250.  */
  251.  
  252. #ifndef _UWIN
  253. int        access (const char*, int);
  254. int        chsize (int, long );
  255. int        close (int);
  256. int        creat (const char*, int);
  257. int        dup (int);
  258. int        dup2 (int, int);
  259. int        eof (int);
  260. long        filelength (int);
  261. int        fileno (FILE*);
  262. int        isatty (int);
  263. long        lseek (int, long, int);
  264. int        open (const char*, int, ...);
  265. int        read (int, void*, unsigned int);
  266. int        setmode (int, int);
  267. int        sopen (const char*, int, int, ...);
  268. long        tell (int);
  269. int        umask (int);
  270. int        unlink (const char*);
  271. int        write (int, const void*, unsigned int);
  272. #endif /* _UWIN */
  273.  
  274. /* Wide character versions. Also declared in wchar.h. */
  275. /* Where do these live? Not in libmoldname.a nor in libmsvcrt.a */
  276. #if 0
  277. int         waccess(const wchar_t *, int);
  278. int         wchmod(const wchar_t *, int);
  279. int         wcreat(const wchar_t *, int);
  280. long         wfindfirst(wchar_t *, struct _wfinddata_t *);
  281. int         wfindnext(long, struct _wfinddata_t *);
  282. int         wunlink(const wchar_t *);
  283. int         wrename(const wchar_t *, const wchar_t *);
  284. int         wopen(const wchar_t *, int, ...);
  285. int         wsopen(const wchar_t *, int, int, ...);
  286. wchar_t *     wmktemp(wchar_t *);
  287. #endif
  288.  
  289. #endif    /* Not _NO_OLDNAMES */
  290.  
  291. #ifdef    __cplusplus
  292. }
  293. #endif
  294.  
  295. #endif    /* Not RC_INVOKED */
  296.  
  297. #endif    /* _IO_H_ not defined */
  298.  
  299. #endif    /* Not strict ANSI */
  300.  
  301.