home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c221 / 6.ddi / MWHC.006 / 20 < prev    next >
Encoding:
Text File  |  1992-12-09  |  20.9 KB  |  774 lines

  1. /*
  2.  *   stdio.h -- ANSI 
  3.  *
  4.  *   Standard input/output facilities.
  5.  *
  6.  *           Copyright (c) 1990, 1991, 1992 MetaWare Incorporated
  7.  */
  8.  
  9. #ifndef _STDIO_H
  10. #define _STDIO_H
  11. #pragma push_align_members(64);
  12.  
  13.  
  14. #ifdef __CPLUSPLUS__
  15. extern "C" {
  16. #endif
  17.  
  18. #if (_I286 || _VMS)
  19.     #define BUFSIZ      (512)
  20. #elif _R3000    
  21.     #define BUFSIZ      (4096)
  22. #elif _IBMESA
  23.     #define BUFSIZ      (8192)
  24. #elif _IBM370 || (_AIX && _I386)
  25.     #define BUFSIZ      (4096)
  26. #else
  27.     #define BUFSIZ      (1024)
  28. #endif
  29.  
  30. #define EOF (-1)
  31.  
  32. #ifndef NULL
  33.     #define NULL ((void    *)0)
  34. #endif
  35.  
  36. #ifndef _SIZET_H
  37. #include <sizet.h>
  38. #endif
  39.  
  40. typedef long fpos_t;
  41.  
  42. /* maximum number of open files */
  43. #ifdef _IBMESA
  44.     #define FOPEN_MAX    (64)
  45. #elif _IBM370 || (_AIX && _I386)
  46.     #define FOPEN_MAX    (200)
  47. #elif ((_ATT || _ATT4)    && _I386 || _SUN || _MC68)
  48.     #define FOPEN_MAX    (60)
  49. #elif _VMS
  50.     #define FOPEN_MAX    (20)
  51. #elif _NEXT
  52.     #define FOPEN_MAX    (256)
  53. #elif _HOBBIT
  54.     #define FOPEN_MAX    (130)
  55. #elif _SOL
  56.     /* solaris begins with an initial allocation of 20
  57.      * entries in the IOB, and then mallocs 40 more if
  58.      * this value is exceeded
  59.      */
  60.     #define FOPEN_MAX    (60)
  61.     #define _FOPEN_MAX1 (20)
  62. #else
  63.     #define FOPEN_MAX    (50)
  64. #endif
  65. #define _NFILE FOPEN_MAX
  66.  
  67.  
  68. /* only _iob.c need be recompiled if FOPEN_MAX is changed */
  69. extern int _fopen_max;
  70.  
  71. #if _NEXT
  72.     #define FILENAME_MAX (1024)
  73. #else
  74.     #define FILENAME_MAX (255)  /* max name len guaranteed */
  75. #endif
  76.  
  77. /*
  78.  * the FILE table (_IOB) is structured in one of three ways:
  79.  *   _IOB_FIXED
  80.  *       a fixed-size array, with size FOPEN_MAX
  81.  *   _IOB_EXTENSION
  82.  *       a fixed-size array, but may also contain a second array,
  83.  *       not contiguous to the first, for expansion if required.
  84.  *       0verall size is still FOPEN_MAX, but the size of the first
  85.  *       table is _FOPEN_MAX1.
  86.  *   _IOB_LIST
  87.  *       the _IOB is implemented as a linked list, with the first three
  88.  *       entries static, but all remaining entries allocated with malloc,
  89.  *       and linked together with link fields
  90.  */
  91.  
  92. #define        _IOB_FIXED    1
  93. #define        _IOB_EXTENSION    2
  94. #define        _IOB_LIST    3
  95.  
  96. #if _SOL
  97. #    define _IOB_FORMAT     _IOB_EXTENSION
  98. #elif _HOBBIT && defined(_REENTRANT)
  99. #    define _IOB_FORMAT     _IOB_LIST
  100. #else
  101. #    define _IOB_FORMAT     _IOB_FIXED
  102. #endif
  103.  
  104. /*  _IOB semantics:
  105.  *
  106.  *  _flag semantics:
  107.  *    _IOFBF, _IONBF, _IOLBF:
  108.  *        specify buffering.  Note that _IOFBF is 0, and thus,
  109.  *        no flag implies full buffering.
  110.  *
  111.  *    _IOREAD, _IOWRT, _IORW:
  112.  *        set at open time as follows:
  113.  *            _IOREAD        open "r"
  114.  *            _IOWRT        open "w"
  115.  *          _IORW        open "r+", "w+", "a+"
  116.  *        open update (the "+" guys): 
  117.  *            _IOREAD and _IOWRT are or'd in for read/write 
  118.  *            operations.  At seek time, the buffer is flushed,
  119.  *            if necessary, and the _IOREAD/_IOWRT flags are
  120.  *            cleared.  Note that the user must issue an
  121.  *            intervening seek before switching between read/
  122.  *            write operations.  Thus, at seek time, the buffer
  123.  *            is cleared, and the only remaining flag is _IORW.
  124.  *            _IORW is set at open time, and remains set until
  125.  *            the file is closed.
  126.  *        open append:
  127.  *            The append requirement is passed to the system
  128.  *            open routine.  Thus, all writes are automatically
  129.  *            appended, and no record of the append status is
  130.  *            kept in the _IOB.  Note that DOS does not have
  131.  *            an open append system call, and thus we track
  132.  *            file position in the _FIOSEEKEOF flag.
  133.  *        open read/write:
  134.  *            _IOREAD/_IOWRITE are set at open time, and remain
  135.  *            set until the file is closed.
  136.  *
  137.  *     _IOMYBUF
  138.  *        if set, then the buffer allocated at open time
  139.  *        belongs to the i/o system (as opposed to the user), 
  140.  *        and it's the i/o system's responsibility to free
  141.  *        the buffer at close time.
  142.  *
  143.  *  _cnt semantics:
  144.  *    if _IOREAD
  145.  *        _cnt specifies the number of characters remaining
  146.  *        to be read in the buffer.
  147.  *    else if _IOWRT
  148.  *        _cnt specifies the number of unused bytes remaining
  149.  *        in the buffer.
  150.  *    endif
  151.  *
  152.  *  _base semantics:
  153.  *    pointer to beginning of buffer.  This value remains
  154.  *    constant after open.
  155.  *
  156.  *  _ptr semantics:
  157.  *    if _IOREAD
  158.  *       _ptr specifies the location of the next byte to be read.
  159.  *    else if _IOWRT
  160.  *       _ptr specifies the location of the next unused byte.
  161.  *    endif
  162.  *
  163.  *  _file semantics:
  164.  *    contains the low-level system file handle.
  165.  *
  166.  *  miscellaneous:
  167.  *    to determine buffer size, one of the following must 
  168.  *    be present:
  169.  *      _bufsiz       size of buffer (_IOB_BUFSIZ)
  170.  *      _bufendp    pointer to byte following buffer (_IOB_BUFENDP)
  171.  *      _bufendtab[]    a table of bufendp pointers (_IOB_BUFENDTAB)
  172.  *      _bufsiz & _bufendp both of the first two (_IOB_BUFSIZ_ENDP)
  173.  *
  174.  */
  175.  
  176.  
  177. #if _MSDOS || _MSNT || (_I860 && _ATT) || _AM29K
  178.     #define _TEXTFILES 1
  179. #else
  180.     #define _TEXTFILES 0
  181. #endif
  182.  
  183. #if _MSDOS || _MSNT || (_I860 && _ATT)
  184.     #define _NEWLINE_XLATE 1
  185. #else
  186.     #define _NEWLINE_XLATE 0
  187. #endif
  188.  
  189. #if _AM29K
  190.     #define _SYSTEM_NEWLINE_XLATE 1
  191. #else
  192.     #define _SYSTEM_NEWLINE_XLATE 0
  193. #endif
  194.  
  195. /* specify _WRITEAPPEND if we must supply our own APPEND on WRITE */
  196. /* This is required on MSDOS, as there is no OPEN APPEND */
  197. #if _MSDOS || _MSNT
  198.     #define _WRITEAPPEND 1
  199. #else
  200.     #define _WRITEAPPEND 0
  201. #endif
  202.  
  203. #if _MSDOS || _MSNT
  204.     #define _FLUSH_SYSCALL_REQUIRED 1
  205. #else
  206.     #define _FLUSH_SYSCALL_REQUIRED 0
  207. #endif
  208.  
  209.  
  210. /* minimum file descriptor for user stream */
  211. #if _MSDOS
  212.     #define _MIN_USER_STREAM 5
  213. #else
  214.     #define _MIN_USER_STREAM 3
  215. #endif
  216.  
  217. /*
  218.  *  extra information provided as follows:
  219.  *    _FIOAPPEND    required by WRITE so SEEK END may be done
  220.  *                      if required.
  221.  *    _FIOTEXT        required by READ/WRITE so CR/LF translation
  222.  *                      may be done if required.
  223.  *    _FIOSEEKEOF    not required, but improves response for
  224.  *                      DOS (saves a SEEK END on every WRITE APPEND)
  225.  */
  226.  
  227. typedef enum {
  228.     _FIOAPPEND =       0x0001,         /* open append */
  229.     #if _TEXTFILES
  230.     _FIOTEXT =         0x0002,         /* text file */
  231.     #endif
  232.     #if _WRITEAPPEND
  233.     _FIOSEEKEOF =   0x0004,         /* last SEEK was to EOF */
  234.     #endif
  235.     __ansi_cant_end_enums_in_comma    /* Must be here else isn't -Hansi. */
  236.     } _iob_fioflag_t;
  237.  
  238. /* support for ungetc */
  239. typedef struct {
  240.     int _iob_cnt;            /* _cnt, copied from _iob  */
  241.     int _bufsiz;            /* ungetc buffer size */
  242.     unsigned char *_base;    /* ungetc pointer to buffer */
  243.     unsigned char *_ptr;    /* ungetc pointer to current byte */
  244.     } _iob_unget_t;
  245.  
  246.  
  247. #define _IOB_BUFSIZ     1
  248. #define _IOB_BUFENDP    2
  249. #define _IOB_BUFENDTAB  3
  250. #define _IOB_BUFSIZ_ENDP 4
  251.  
  252. #if _BSD || _SUN || _EPI || _ISIS || _NEXT || _NEWS 
  253.  
  254.     #define _IOB_BUFTYP _IOB_BUFSIZ
  255.  
  256.     #define _IOB_CHAR_FLAG 0
  257.  
  258.     typedef int _iob_cnt_t;
  259.     typedef char _iob_ptr_t;
  260.     typedef int _bufsiz_t;
  261.     typedef short _iob_flag_t;
  262.     typedef char _iob_file_t;
  263.  
  264.     typedef struct {
  265.     _iob_cnt_t _cnt;
  266.     _iob_ptr_t *_ptr;
  267.     _iob_ptr_t *_base;
  268.     _bufsiz_t _bufsiz;
  269.     _iob_flag_t _flag;
  270.     _iob_file_t _file;
  271.     char _unused[1];    /* in case align_members is off */
  272.     } FILE;
  273.  
  274. #elif _IBMESA    /* AIX and ESA have ptr/cnt switched. */
  275.  
  276.     #define _IOB_BUFTYP _IOB_BUFSIZ_ENDP
  277.  
  278.     #define _IOB_CHAR_FLAG 0
  279.  
  280.     typedef int _iob_cnt_t;
  281.     typedef unsigned char _iob_ptr_t;
  282.     typedef short _iob_flag_t;
  283.     typedef short _iob_file_t;
  284.     typedef int _bufsiz_t;
  285.  
  286.     /* Both bufsiz and bufendp are included in the iob. */
  287.     typedef struct {
  288.     _iob_cnt_t _cnt;
  289.     _iob_ptr_t *_ptr;
  290.     _iob_ptr_t *_base;
  291.     _bufsiz_t _bufsiz;
  292.     _iob_flag_t _flag;
  293.     _iob_file_t _file;
  294. #if defined(_REENTRANT) || defined(_THREAD_SAFE)    /* IBM's names here. */
  295.     int _unused[2];
  296.     void *_lock;            /* lock for thread safe library */
  297. #else
  298.     int _unused[3];  /* in case align_members is off */
  299. #endif
  300.     _iob_ptr_t *_bufendp;
  301.     } FILE;
  302.  
  303. #elif _AIX
  304.  
  305.     #define _IOB_BUFTYP _IOB_BUFENDP
  306.  
  307.     #define _IOB_CHAR_FLAG 0
  308.  
  309.     typedef int _iob_cnt_t;
  310.     typedef unsigned char _iob_ptr_t;
  311.     typedef short _iob_flag_t;
  312.     typedef short _iob_file_t;
  313.  
  314.     typedef struct {
  315.     _iob_ptr_t *_ptr;
  316.     _iob_cnt_t _cnt;
  317.     _iob_ptr_t *_base;
  318.     _iob_ptr_t *_bufendp;
  319.     _iob_flag_t _flag;
  320.     _iob_file_t _file;
  321.     int _unused[3];  /* in case align_members is off */
  322.     } FILE;
  323.  
  324. #elif _R3000  /* MIPS R2000/R3000 */
  325.  
  326.     #define _IOB_BUFTYP _IOB_BUFENDTAB
  327.  
  328.     #define _IOB_CHAR_FLAG 1
  329.  
  330.     typedef int _iob_cnt_t;
  331.     typedef unsigned char _iob_ptr_t;
  332.     typedef char _iob_flag_t;
  333.     typedef char _iob_file_t;
  334.  
  335.     extern _iob_ptr_t *_bufendtab[];
  336.  
  337.     typedef struct {
  338.     _iob_cnt_t _cnt;
  339.     _iob_ptr_t *_ptr;
  340.     _iob_ptr_t *_base;
  341.     _iob_flag_t _flag;
  342.     _iob_file_t _file;
  343.     char _unused[2];    /* in case align_members is off */
  344.     } FILE;
  345.  
  346. #elif _I860
  347.  
  348.     #if _ATT
  349.  
  350.     #define _IOB_BUFTYP _IOB_BUFENDTAB
  351.  
  352.     #define _IOB_CHAR_FLAG 0
  353.  
  354.     typedef int _iob_cnt_t;
  355.     typedef char _iob_ptr_t;
  356.     typedef short _iob_flag_t;
  357.     typedef char _iob_file_t;
  358.  
  359.     extern _iob_ptr_t *_bufendtab[];
  360.  
  361.     typedef struct {
  362.         _iob_cnt_t _cnt;
  363.         _iob_ptr_t *_ptr;
  364.         _iob_ptr_t *_base;
  365.         _iob_flag_t _flag;
  366.         _iob_file_t _file;
  367.         char _unused[1];    /* in case align_members is off */
  368.         } FILE;
  369.  
  370.     #elif _ATT4 
  371.  
  372.     #define _IOB_BUFTYP _IOB_BUFENDTAB
  373.  
  374.     #define _IOB_CHAR_FLAG 1
  375.  
  376.     typedef int _iob_cnt_t;
  377.     typedef unsigned char _iob_ptr_t;
  378.     typedef unsigned char _iob_flag_t;
  379.     typedef unsigned char _iob_file_t;
  380.  
  381.     extern _iob_ptr_t *_bufendtab[];
  382.  
  383.         /* _STDIO_REVERSE appears in AT&Ts stdio.h.  We have it here
  384.            in case they have some other include file that activates it */
  385.     typedef struct {
  386.         #if _STDIO_REVERSE
  387.         _iob_ptr_t *_ptr;
  388.         _iob_cnt_t _cnt;
  389.         #else
  390.         _iob_cnt_t _cnt;
  391.         _iob_ptr_t *_ptr;
  392.         #endif
  393.         _iob_ptr_t *_base;
  394.         _iob_flag_t _flag;
  395.         _iob_file_t _file;
  396.         char _unused[2];    /* in case align_members is off */
  397.         } FILE;
  398.     #endif
  399.  
  400. #elif _HP9000
  401.  
  402.     #define _IOB_BUFTYP _IOB_BUFENDTAB
  403.  
  404.     #define _IOB_CHAR_FLAG 1
  405.  
  406.     typedef int _iob_cnt_t;
  407.     typedef char _iob_ptr_t;
  408.     typedef short int _iob_flag_t;
  409.     typedef char _iob_file_t;
  410.  
  411.     extern _iob_ptr_t *_bufendtab[];
  412.  
  413.     typedef struct {
  414.     _iob_cnt_t _cnt;
  415.     _iob_ptr_t *_ptr;
  416.     _iob_ptr_t *_base;
  417.     _iob_flag_t _flag;
  418.     _iob_file_t _file;
  419.     char _unused[1];    /* in case align_members is off */
  420.     } FILE;
  421.  
  422. #elif _HOBBIT
  423.     #define _IOB_BUFTYP _IOB_BUFSIZ
  424.  
  425.     #define _IOB_CHAR_FLAG 0
  426.  
  427.     typedef int _iob_cnt_t;
  428.     typedef char _iob_ptr_t;
  429.     typedef int _bufsiz_t;
  430.     typedef int _iob_flag_t;
  431.     typedef int  _iob_file_t;
  432.  
  433.     #if (_IOB_FORMAT == _IOB_LIST)
  434.  
  435.     /* for reentrant hobbit, the _iob is a linked list.  Because the 
  436.        _iob-parallel table concept doesn't work, we include the fields
  437.        that would normally be in the parallel tables directly into
  438.        the _iob entry definition.
  439.     */
  440.     typedef struct _iob_ent_type {
  441.         _iob_cnt_t _cnt;
  442.         _iob_ptr_t *_ptr;
  443.         _iob_ptr_t *_base;
  444.         _bufsiz_t _bufsiz;
  445.         _iob_flag_t _flag;
  446.         _iob_file_t _file;
  447.         _iob_unget_t _iob_unget;
  448.         _iob_fioflag_t _iob_fioflag;
  449.         struct _iob_ent_type *_link;  /* link to next FILE structure */
  450.         } FILE;
  451.     #else
  452.     typedef struct {
  453.         _iob_cnt_t _cnt;
  454.         _iob_ptr_t *_ptr;
  455.         _iob_ptr_t *_base;
  456.         _bufsiz_t _bufsiz;
  457.         _iob_flag_t _flag;
  458.         _iob_file_t _file;
  459.         } FILE;
  460.     #endif
  461.  
  462. #elif _ATT || _ATT4 || _SOL
  463.  
  464.     #define _IOB_BUFTYP _IOB_BUFENDTAB
  465.  
  466.     #define _IOB_CHAR_FLAG 1
  467.  
  468.     typedef int _iob_cnt_t;
  469.     typedef char _iob_ptr_t;
  470.     typedef unsigned char _iob_flag_t;
  471.     typedef unsigned char _iob_file_t;
  472.  
  473.     extern _iob_ptr_t *_bufendtab[];
  474.  
  475.         /* _STDIO_REVERSE appears in AT&Ts stdio.h.  We have it here
  476.            in case they have some other include file that activates it */
  477.     typedef struct {
  478.     #if _STDIO_REVERSE
  479.         _iob_ptr_t *_ptr;
  480.         _iob_cnt_t _cnt;
  481.     #else
  482.         _iob_cnt_t _cnt;
  483.         _iob_ptr_t *_ptr;
  484.     #endif
  485.     _iob_ptr_t *_base;
  486.     _iob_flag_t _flag;
  487.     _iob_file_t _file;
  488.     char _unused[2];    /* in case align_members is off */
  489.     } FILE;
  490.  
  491.     #if _SOL
  492.     /* an extra 60 entries of iob and bufendtab, if needed */
  493.     extern FILE *_iob_more;
  494.     extern _iob_ptr_t **_bufendtab_more;
  495.     #endif
  496.  
  497. #elif _MSDOS
  498.  
  499.     #define _IOB_BUFTYP _IOB_BUFENDTAB
  500.  
  501.     #define _IOB_CHAR_FLAG 0
  502.  
  503.     typedef int _iob_cnt_t;
  504.     typedef char _iob_ptr_t;
  505.     typedef short int _iob_flag_t;
  506.     typedef char _iob_file_t;
  507.  
  508.     extern _iob_ptr_t *_bufendtab[];
  509.  
  510.     typedef struct {
  511.         _iob_ptr_t *_ptr;
  512.         _iob_cnt_t _cnt;
  513.         _iob_ptr_t *_base;
  514.         _iob_flag_t _flag;
  515.         _iob_file_t _file;
  516.         char _unused[5];    /* in case align_members is off */
  517.         } FILE;
  518.  
  519. #elif _MSNT
  520.     #define _IOB_BUFTYP _IOB_BUFENDTAB
  521.     #define _IOB_CHAR_FLAG 1
  522.     typedef int _iob_cnt_t;
  523.     typedef char _iob_ptr_t;
  524.     extern _iob_ptr_t *_bufendtab[];
  525.     typedef struct {
  526.       _iob_ptr_t *_ptr;
  527.       _iob_cnt_t   _cnt;
  528.       _iob_ptr_t *_base;
  529.       int   _flag;
  530.       int   _file;
  531.       int   _charbuf;        /* not used */
  532.       int   _bufsiz;        /* not used */
  533.       int   _tmpnum;        /* not used */
  534.       } FILE;
  535. #else
  536.     #error Error in compilation:  OS not specified: __FILE__, line __LINE__.
  537. #endif
  538.  
  539. /* ordinal for _flag */
  540. enum {
  541.     _IOFBF =        0x0000,        /* full    bufferring */
  542.     _IOREAD =        0x0001,        /* reading */
  543.     _IOWRT =        0x0002,        /* writing */
  544.     _IONBF =        0x0004,        /* no buffering    */
  545.     _IOMYBUF =        0x0008,        /* free    buffer on close */
  546.     _IOEOF =        0x0010,        /* eof reached */
  547.     _IOERR =        0x0020,        /* error occurred */
  548.     #if _IOB_CHAR_FLAG
  549.     _IOSTRG =       0x0040,         /* string buffering */
  550.     _IOLBF =    0x0040,        /* line buffering */
  551.     _IORW =        0x0080,        /* read/write enabled */
  552.     #else
  553.     _IOSTRG =         0x0040,         /* string buffering */
  554.     _IOLBF =    0x0080,        /* line    buffering */
  555.     _IORW =        0x0100,        /* read/write enabled */
  556.     #endif
  557.     _IOSHRMEM =        0x0200        /* entry and buffer in shared mem? */
  558.     };
  559.  
  560. /* ANSI requires these to be macros: */
  561. #define _IOFBF    _IOFBF
  562. #define _IOLBF    _IOLBF
  563. #define _IONBF    _IONBF
  564. #if _ATT
  565.     #define L_tmpnam (25)    /* length of file tmpnam string: system V */
  566. #elif _IBMESA
  567.     #define L_tmpnam (sizeof(_P_tmpdir)+15)    
  568. #else
  569.     #define L_tmpnam (18)    /* length of file tmpnam string */
  570. #endif
  571.  
  572. #ifdef _REENTRANT
  573.     #ifndef _STATIC_H
  574.     #include <static.h>
  575.     #endif
  576. #else
  577.     /* associated IOB tables */
  578.     extern char *_iob_tmpnam[];        /* ptr to tmp filename */
  579.     extern _iob_fioflag_t _iob_fioflag[];    /* _FIO... flags */
  580.     extern _iob_unget_t _iob_unget[];    /* support for ungetc */
  581.     #if _SYSTEM_NEWLINE_XLATE
  582.     /* file position for start of buffer for READ */
  583.     extern long _iob_bufpos[];
  584.     #endif
  585.     #if (_IOB_FORMAT == _IOB_LIST)
  586.     extern FILE *_iob_head;
  587.     #endif
  588.     #if _ATT4 || __ATTSTDC    /* UNIX 5v4 uses __iob */
  589.         #define _IOB __iob
  590.     #else
  591.         #define _IOB _iob
  592.     #endif
  593.     extern FILE _IOB [];
  594. #endif
  595.  
  596. #define stdin    (&_IOB[0])
  597. #define stdout    (&_IOB[1])
  598. #define stderr    (&_IOB[2])
  599.  
  600. #if _MSDOS && __HIGHC__
  601. #    define stdaux (&_IOB[3])
  602. #    define stdprn (&_IOB[4])
  603. #endif
  604.  
  605. #if _MSDOS || _MSNT
  606. #    define _P_tmpdir "\\"
  607. #else
  608. #    define _P_tmpdir "/tmp/"
  609. #endif
  610.  
  611. #if __HIGHC__
  612.     #define P_tmpdir _P_tmpdir
  613. #endif
  614.  
  615. #define TMP_MAX  (1000)  /* min number    of unique tmpnames */
  616.  
  617. #define SEEK_SET (0)      /*From_beginning*/
  618. #define SEEK_CUR (1)      /*From_current*/
  619. #define SEEK_END (2)      /*From_end*/
  620.  
  621. extern    int remove(const char *__pathname);
  622. extern    int rename(const char *__old, const char *__new);
  623. extern    FILE *tmpfile(void);
  624. extern    char *tmpnam(char *__s);
  625. extern    int fclose(FILE    *__stream);
  626. extern    int fflush(FILE    *__stream);
  627. extern    FILE *fopen(const char *__pathname, const char *__type);
  628. #if  !(_MSDOS || _VMS)
  629.     extern FILE *fdopen(int __fd, const char *__type);
  630. #endif
  631. extern    FILE *freopen(const char *__pathname, const char *__type, FILE *__stream);
  632. extern    void setbuf(FILE *__stream, char *__buf);
  633. extern    int setvbuf(FILE *__stream, char *__buf, int __type, size_t __size);
  634. extern    size_t fread
  635.      (void *__ptr, size_t __size, size_t __nelem, FILE *__stream);
  636. extern    size_t fwrite
  637.      (const    void *__ptr, size_t __size, size_t __nelem, FILE *__stream);
  638. extern    int fgetc(FILE *__stream);
  639.  
  640. #undef    getc
  641. extern    int getc(FILE *__stream);
  642. #define getc(p)     (--(p)->_cnt>=0? *(p)->_ptr++&0377:fgetc(p))
  643.  
  644. #undef    getchar
  645. extern    int getchar(void);
  646. #define getchar() (getc(stdin))
  647.  
  648. extern    char *gets(char    *__s);
  649. extern    char *fgets(char *__s, int __N,    FILE *__stream);
  650. extern    int fputs(const    char *__s, FILE    *__stream);
  651. extern    int fputc(int __c, FILE    *__stream);
  652.  
  653. extern long _filelength(int );
  654. extern long _tell(int );
  655. extern int _fcloseall(void);
  656. extern int _flushall(void);
  657. extern int _fputchar(int __c);
  658. extern int _fgetchar(void);
  659. #if __HIGHC__
  660.     extern long filelength(int );
  661.     extern long tell(int );
  662.     extern int fcloseall(void);
  663.     extern int flushall(void);
  664.     extern int fputchar(int __c);
  665.     extern int fgetchar(void);
  666. #endif
  667.  
  668. #if _MSDOS
  669.     extern FILE *_fdopen(int __fd, const char *__type);
  670.     extern int _getw(FILE *_stream);
  671.     extern int _putw(int _int1, FILE * _stream);
  672.     extern void _stkdmp(int __filehandle);
  673.     extern char *_tempnam(char *dir,char *prefix);
  674.     extern int _unlink(const char *__pathname);
  675.  
  676.     #if __HIGHC__
  677.     extern FILE *fdopen(int __fd, const char *__type);
  678.     extern int getw(FILE *_stream);
  679.     extern int putw(int _int1, FILE * _stream);
  680.     extern int unlink(const char *__pathname);
  681.     #endif
  682. #endif
  683.  
  684. #if _MSDOS || (_ATT && !_I860) || _ATT4 || _SUN || _SOL
  685.     extern char *tempnam(char *dir,char *prefix);
  686. #endif
  687.  
  688. #undef    putc
  689. extern    int putc(int __c, FILE *__stream);
  690.  
  691. #undef    putchar
  692. extern int putchar(int    __c);
  693. #define putchar(c) (putc((c), stdout))
  694. extern int puts(const char *__s);
  695. extern int ungetc(int __c, FILE *__stream);
  696. extern int fseek(FILE *__stream, long __offset, int __ptrname);
  697. extern long ftell(FILE    *__stream);
  698. extern void rewind(FILE *__stream);
  699. extern int fsetpos(FILE *__stream, const fpos_t *__pos);
  700. extern int fgetpos(FILE *__stream, fpos_t *__pos);
  701.  
  702. #undef    clearerr
  703. extern void clearerr(FILE *__stream);
  704. /* clear _IOERR and _IOEOF */
  705. #define clearerr(__stream) ((__stream)->_flag &= ~(_IOERR | _IOEOF))
  706.  
  707. #undef feof
  708. extern int feof(FILE *__stream);
  709. #define feof(__stream)    ((__stream)->_flag & _IOEOF)
  710.  
  711. #undef ferror
  712. extern int ferror(FILE    *__stream);
  713. #define ferror(__stream) ((__stream)->_flag & _IOERR)
  714.  
  715. extern void perror(const char *__s);
  716.  
  717. #include <stdarg.h>
  718. extern int vprintf(const char *__format, va_list __arg);
  719. extern int vfprintf(FILE *__stream, const char    *__format, va_list __arg);
  720. extern int vsprintf(char *__s,    const char *__format, va_list __arg);
  721. extern int printf(const char *__format, ...);
  722. extern int fprintf(FILE *__stream, const char *__format, ...);
  723. extern int sprintf(char *__s, const char *__format, ...);
  724. extern int fscanf(FILE    *__stream, const char *__format, ...);
  725. extern int scanf(const    char *__format,    ...);
  726. extern int sscanf(const char *__s, const char *__format, ...);
  727. extern int _vfscanf( FILE *f, const char *format, va_list args );
  728. extern int _vscanf( const char *format, va_list args);
  729. extern int _vsscanf( const char *s, const char *format, va_list args );
  730. extern int _vbprintf( char *buf, unsigned int bufsize, const char *format,
  731.     va_list args );
  732. extern int _bprintf(char *buf, unsigned int bufsize, const char *format, ...);
  733. #if __HIGHC__
  734.     extern int vfscanf( FILE *f, const char *format, va_list args );
  735.     extern int vscanf( const char *format, va_list args );
  736.     extern int vsscanf( const char *s, const char *format, va_list args );
  737. #endif
  738.  
  739. extern int _fileno (FILE *__stream);
  740. #define __fileno(__stream) ((__stream)->_file)
  741. #if __HIGHC__
  742.     #define fileno(__stream)  ((__stream)->_file)
  743. #endif
  744.  
  745. #if _TEXTFILES
  746.     #define _O_TEXT          0x4000
  747.     #ifdef _AM29K
  748.     #define _O_BINARY    0x0000
  749.     #else
  750.         #define _O_BINARY     0x8000
  751.     #endif
  752.  
  753.     #define _TEXT            (0)
  754.     #define _BINARY          (1)
  755.     extern int _setmode(FILE *__stream, int __mode);
  756.  
  757.     /* used to set _fmode */
  758.     #define _USER_FILES_BINARY          (1)
  759.     #define _STDIN_AND_STDOUT_BINARY     (2)
  760.     #define _STDERR_BINARY        (4)
  761.     #define _ALL_FILES_BINARY      \
  762.       (_USER_FILES_BINARY|_STDIN_AND_STDOUT_BINARY|_STDERR_BINARY)
  763.     #define _ALL_FILES_TEXT      (0xff    & ~_ALL_FILES_BINARY)
  764.     #define _USER_FILES_TEXT      (_fmode & ~_USER_FILES_BINARY)
  765.     #define _STDIN_AND_STDOUT_TEXT    (_fmode & ~_STDIN_AND_STDOUT_BINARY)
  766.     #define _STDERR_TEXT        (_fmode & ~_STDERR_BINARY)
  767. #endif
  768.  
  769. #ifdef __CPLUSPLUS__
  770. }
  771. #endif
  772. #pragma pop_align_members();
  773. #endif /*_STDIO_H*/
  774.