home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 20.ddi / SOURCE / STARTUP / FILE2.H_ / FILE2.H
Encoding:
C/C++ Source or Header  |  1993-02-08  |  1.9 KB  |  77 lines

  1. /***
  2. *file2.h - auxiliary file structure used internally by file run-time routines
  3. *
  4. *    Copyright (c) 1985-1992, Microsoft Corporation.  All rights reserved.
  5. *
  6. *Purpose:
  7. *    This file defines the auxiliary file structure used internally by
  8. *    the file run time routines.
  9. *    [Internal]
  10. *
  11. ****/
  12.  
  13. #ifndef _INC_FILE2
  14.  
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18.  
  19. #if (_MSC_VER <= 600)
  20. #define __near      _near
  21. #endif
  22.  
  23. /*
  24.    Define the FILE2 structure.
  25.  
  26.    [Note that we depend on the FILE2 structure being the same size as a
  27.    FILE structure (see macro definitions).]
  28. */
  29.  
  30. #define FILE2  struct _iobuf2
  31.  
  32. extern FILE2 {
  33.     char  _flag2;
  34.     char  _charbuf;
  35.     int   _bufsiz;
  36.     int   __tmpnum;
  37. #if (defined(M_I86SM) || defined(M_I86MM))
  38.     char  _padding[2];        /* pad out to size of FILE structure */
  39. #else
  40.     char  _padding[6];        /* pad out to size of FILE structure */
  41. #endif
  42.     } __near _iob2[];
  43.  
  44. #define _IOYOURBUF    0x01
  45. #define _IOFEOF     0x08
  46. #define _IOFLRTN    0x10
  47. #define _IOCTRLZ    0x20
  48. #define _IOCOMMIT    0x40
  49.  
  50. /* Macros for getting _iob[] index and translating (FILE *) to (FILE2 *) */
  51.  
  52. #define _iob2_(s)  (*((FILE2 near *) ((char near *)_iob2 + ((char *)s - (char *)_iob))))
  53. #define _iob_index(s)    ( (FILE *) s - (FILE *)_iob)
  54.  
  55. /* General use macros */
  56.  
  57. #define inuse(s)    ((s)->_flag & (_IOREAD|_IOWRT|_IORW))
  58. #define mbuf(s)     ((s)->_flag & _IOMYBUF)
  59. #define nbuf(s)     ((s)->_flag & _IONBF)
  60. #define ybuf(s)     (_iob2_(s)._flag2 & _IOYOURBUF)
  61. #define bigbuf(s)    (mbuf(s) || ybuf(s))
  62. #define anybuf(s)    ((s)->_flag & (_IOMYBUF|_IONBF) || ybuf(s))
  63. #define _tmpnum(s)    _iob2_(s).__tmpnum
  64.  
  65. /* Optimized macros for use when the (FILE2 *) pointer is already known */
  66.  
  67. #define ybuf2(s2)    ((s2)->_flag2 & _IOYOURBUF)
  68. #define bigbuf2(s,s2)    (mbuf(s) || ybuf2(s2))
  69. #define anybuf2(s,s2)    ((s)->_flag & (_IOMYBUF|_IONBF) || ybuf2(s2))
  70.  
  71. #ifdef __cplusplus
  72. }
  73. #endif
  74.  
  75. #define _INC_FILE2
  76. #endif
  77.