home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional Developers Kit 1992 November / Disc01 / Disc01.mdf / cppbeta / incla / stdio.h__ / STDIO.H
Encoding:
C/C++ Source or Header  |  1992-09-30  |  10.8 KB  |  293 lines

  1. #ifndef __stdio_h
  2.    #define __stdio_h
  3.  
  4.    #pragma info( none )
  5.    #ifndef __CHKHDR__
  6.       #pragma info( none )
  7.    #endif
  8.  
  9.    #pragma info( restore )
  10.  
  11.    #ifdef __cplusplus
  12.       extern "C" {
  13.    #endif
  14.  
  15.    /********************************************************************/
  16.    /*  <stdio.h> header file                                           */
  17.    /*                                                                  */
  18.    /*  Licensed Materials - Property of IBM                            */
  19.    /*                                                                  */
  20.    /*  IBM C Set/2 Beta Version                                        */
  21.    /*  Copyright (C) International Business Machines Corp., 1991,1992  */
  22.    /*  All rights reserved                                             */
  23.    /*                                                                  */
  24.    /*  US Government Users Restricted Rights -                         */
  25.    /*  Use, duplication, or disclosure restricted                      */
  26.    /*  by GSA ADP Schedule Contract with IBM Corp.                     */
  27.    /*                                                                  */
  28.    /********************************************************************/
  29.  
  30.    #ifndef __size_t
  31.       #define __size_t
  32.       typedef unsigned int size_t;
  33.    #endif
  34.  
  35.    enum _OPERATIONS { _IOINIT, _IOREAD, _IOWRITE, _IOREPOSITION,
  36.                       _IOFLUSH, _IOUNDEFOP };
  37.  
  38.    #define _MAX_UNGET 2
  39.  
  40.    #pragma pack( 1 )
  41.    typedef struct __file       /* visible portion of the FILE struct */
  42.       {
  43.       unsigned char     *bufPtr;
  44.       unsigned long int  count;
  45.       unsigned long int  userFlags;
  46.       unsigned long int  bufLen;
  47.       unsigned long int  ungetCount;
  48.       int                tempStore;
  49.       unsigned char      ungetBuf[_MAX_UNGET];
  50.       enum _OPERATIONS   lastOp;
  51.       char               filler;
  52.       } FILE;
  53.    #pragma pack( )
  54.  
  55.    typedef struct __fpos_t      /* Definition of file positioning structure */
  56.       {
  57.       long int __fpos_elem[2];
  58.       } fpos_t;
  59.  
  60.    #ifndef NULL
  61.       #if (defined(__EXTENDED__)  || defined( __cplusplus ))
  62.          #define NULL 0
  63.       #else
  64.          #define NULL ((void *)0)
  65.       #endif
  66.    #endif
  67.  
  68.    #define _IOFBF              1   /* Buffer modes */
  69.    #define _IOLBF              2
  70.    #define _IONBF              3
  71.    #define BUFSIZ           4096   /* Default buffer size */
  72.    #define EOF              (-1)
  73.    #define L_tmpnam          260   /* Maximum length of temporary names */
  74.    #define FOPEN_MAX          20   /* Minimum number of open files guaranteed */
  75.    #define FILENAME_MAX      260   /* Maximum file name length */
  76.    #define SEEK_SET            0   /* fseek constants */
  77.    #define SEEK_CUR            1
  78.    #define SEEK_END            2
  79.    #define TMP_MAX        100000   /* Maximum guaranteed unique file names */
  80.  
  81.    #define _IOEOF         0x0001   /* EOF flag mask */
  82.    #define _IOERR         0x0002   /* ERR flag mask */
  83.  
  84.    typedef char *__va_list;
  85.  
  86.    /* Standard stream pointers. */
  87.  
  88.    extern FILE * const stdin;
  89.    extern FILE * const stdout;
  90.    extern FILE * const stderr;
  91.  
  92.    /* Function declarations. */
  93.  
  94.    int      _Optlink _fprintf_ansi( FILE *, const char *, ... );
  95.    int      _Optlink _fscanf_ansi( FILE *, const char *, ... );
  96.    int      _Optlink _printf_ansi( const char *, ... );
  97.    int      _Optlink _scanf_ansi( const char *, ... );
  98.    int      _Optlink _sprintf_ansi( char *, const char *, ... );
  99.    int      _Optlink _sscanf_ansi( const char *, const char *, ... );
  100.    void     _Optlink clearerr( FILE * );
  101.    int      _Optlink fclose( FILE * );
  102.    int      _Optlink feof( FILE * );
  103.    int      _Optlink ferror( FILE * );
  104.    int      _Optlink fflush( FILE * );
  105.    int      _Optlink fgetc( FILE * );
  106.    int      _Optlink fgetpos( FILE *, fpos_t * );
  107.    char   * _Optlink fgets( char *, int, FILE * );
  108.    FILE   * _Optlink fopen( const char *, const char * );
  109.    int      _Optlink fputc( int, FILE * );
  110.    int      _Optlink fputs( const char *, FILE * );
  111.    size_t   _Optlink fread( void *, size_t, size_t, FILE * );
  112.    FILE   * _Optlink freopen( const char *, const char *, FILE * );
  113.    int      _Optlink fseek( FILE *, long int, int );
  114.    int      _Optlink fsetpos( FILE *, const fpos_t * );
  115.    long int _Optlink ftell( FILE * );
  116.    size_t   _Optlink fwrite( const void *, size_t, size_t, FILE * );
  117.    int      _Optlink getc( FILE * );
  118.    int      _Optlink getchar( void );
  119.    char   * _Optlink gets( char * );
  120.    void     _Optlink perror( const char * );
  121.    int      _Optlink putc( int, FILE * );
  122.    int      _Optlink putchar( int );
  123.    int      _Optlink puts( const char * );
  124.    int      _Optlink remove( const char * );
  125.    int      _Optlink rename( const char *, const char * );
  126.    void     _Optlink rewind( FILE * );
  127.    void     _Optlink setbuf( FILE *, char * );
  128.    int      _Optlink setvbuf( FILE *, char *, int, size_t );
  129.    FILE   * _Optlink tmpfile( void );
  130.    char   * _Optlink tmpnam( char * );
  131.    int      _Optlink ungetc( int, FILE * );
  132.    int      _Optlink vfprintf( FILE *, const char *, __va_list );
  133.    int      _Optlink vprintf( const char *, __va_list );
  134.    int      _Optlink vsprintf( char *, const char *, __va_list );
  135.  
  136.    #pragma info( none )
  137.    int      _Optlink fprintf( );
  138.    int      _Optlink fscanf( );
  139.    int      _Optlink printf( );
  140.    int      _Optlink scanf( );
  141.    int      _Optlink sprintf( );
  142.    int      _Optlink sscanf( );
  143.  
  144.    #define fprintf _fprintf_ansi
  145.    #define printf  _printf_ansi
  146.    #define sprintf _sprintf_ansi
  147.    #define fscanf  _fscanf_ansi
  148.    #define scanf   _scanf_ansi
  149.    #define sscanf  _sscanf_ansi
  150.    #pragma info( restore )
  151.  
  152.    #define __getc(p) (((p)->lastOp == _IOREAD) ?\
  153.                       ((p)->ungetCount)? \
  154.                       ((int) (p)->ungetBuf [--((p)->ungetCount)]):\
  155.                        (((p)->count)? \
  156.                        (--(p)->count, (int)(*(p)->bufPtr++)) :\
  157.                       fgetc(p)) : \
  158.                      fgetc(p))
  159.  
  160.    #define __putc(c, p)                                           \
  161.     (((p) == NULL) ? fputc((c),(p)):\
  162.      ((((p)->tempStore = (c)) != '\n') && ((p)->count < (p)->bufLen) && \
  163.       ((p)->lastOp == _IOWRITE) \
  164.      ) ?                                                          \
  165.      (++(p)->count, *(p)->bufPtr++ = (p)->tempStore):                \
  166.      fputc((p)->tempStore,(p))                                               \
  167.     )
  168.  
  169.    #pragma info( none )
  170.    #ifndef __MULTI__
  171.       #define getc( p )    __getc( (p) )
  172.       #define putc( c, p ) __putc( (c), (p) )
  173.    #else
  174.       #define getc( p )  fgetc( (p) )
  175.       #define putc( c, p ) fputc( (c), (p) )
  176.    #endif
  177.  
  178.    #define getchar( )   getc( stdin )
  179.    #define putchar( c ) putc( (c), stdout )
  180.  
  181.    /* clearerr, feof, and ferror macros - single threaded only */
  182.  
  183.    #ifndef __MULTI__
  184.       #define clearerr( stream ) \
  185.          ( ((stream) == NULL) ? clearerr( (stream) ):\
  186.                                 ( ( void )( (stream)->userFlags = 0L ) ) )
  187.       #define feof( stream ) \
  188.          ( ((stream) == NULL) ? feof( (stream) ):\
  189.                                 ( ( int )( (stream)->userFlags & _IOEOF ) ) )
  190.       #define ferror( stream ) \
  191.          ( ((stream) == NULL) ? ferror( (stream) ):\
  192.                                 ( ( int )( (stream)->userFlags & _IOERR ) ) )
  193.    #endif
  194.    #pragma info( restore )
  195.  
  196.    #if (defined(__cplusplus) || !defined(__ANSI__))
  197.       #ifndef __SAA_L2__
  198.  
  199.          #define _IO_WRITETHRU  0x0004   /* WRITETHRU mask */
  200.  
  201.          #undef fprintf
  202.          #undef printf
  203.          #undef sprintf
  204.          #undef fscanf
  205.          #undef scanf
  206.          #undef sscanf
  207.  
  208.          int _Optlink _fcloseall( void );
  209.          int _Optlink _fprintfieee( FILE *, const char *, ... );
  210.          int _Optlink _fscanfieee( FILE *, const char *, ... );
  211.          int _Optlink _printfieee( const char *, ... );
  212.          int _Optlink _rmtmp( void );
  213.          int _Optlink _scanfieee( const char *, ... );
  214.          int _Optlink _sprintfieee( char *, const char *, ... );
  215.          int _Optlink _sscanfieee( const char *, const char *, ... );
  216.          int _Optlink _vfprintfieee( FILE *, const char *, __va_list );
  217.          int _Optlink _vprintfieee( const char *, __va_list );
  218.          int _Optlink _vsprintfieee( char *, const char *, __va_list );
  219.  
  220.          #pragma info( none )
  221.          #define fprintf  _fprintfieee
  222.          #define fscanf   _fscanfieee
  223.          #define printf   _printfieee
  224.          #define scanf    _scanfieee
  225.          #define sprintf  _sprintfieee
  226.          #define sscanf   _sscanfieee
  227.          #define vfprintf _vfprintfieee
  228.          #define vprintf  _vprintfieee
  229.          #define vsprintf _vsprintfieee
  230.          #pragma info( restore )
  231.  
  232.          #if defined(__EXTENDED__)
  233.  
  234.             #define P_tmpdir "\\"
  235.  
  236.             FILE * _Optlink _fdopen( int, const char *);
  237.             int    _Optlink _fgetchar( void );
  238.             int    _Optlink _fileno( FILE * );
  239.             int    _Optlink _flushall( void );
  240.             int    _Optlink _fputchar( int );
  241.             char * _Optlink _tempnam( char *, char * );
  242.             #ifdef __cplusplus
  243.                int    _Optlink _unlink( const char * );
  244.             #else
  245.                int    _Optlink _unlink( char * );
  246.             #endif
  247.  
  248.             #ifdef __cplusplus
  249.  
  250.                inline   FILE * _Optlink fdopen( int a, const char *b )   { return  _fdopen(a,b );  }
  251.                inline   int    _Optlink fgetchar()                       { return  _fgetchar();    }
  252.                inline   int    _Optlink fileno( FILE *a )                { return  _fileno(a);     }
  253.                inline   int    _Optlink flushall()                       { return  _flushall();    }
  254.                inline   int    _Optlink fputchar( int a )                { return  _fputchar(a);   }
  255.                inline   char * _Optlink tempnam( char *a, char *b )      { return  _tempnam(a,b);  }
  256.                #ifndef __unlink__
  257.                   #define __unlink__
  258.                   inline   int    _Optlink unlink( const char *a)        { return  _unlink(a);     }
  259.                #endif
  260.  
  261.             #else
  262.  
  263.                #define fdopen( a,b )       _fdopen( (a),(b) )
  264.                #define fgetchar( a )       _fgetchar( a )
  265.                #define fileno( a )         _fileno( a )
  266.                #define flushall            _flushall
  267.                #define fputchar( a )       _fputchar( a )
  268.                #define tempnam( a,b )      _tempnam( (a),(b) )
  269.  
  270.                #ifndef unlink
  271.                   #define unlink _unlink
  272.                #endif
  273.  
  274.            #endif
  275.  
  276.          #endif
  277.  
  278.       #endif
  279.  
  280.    #endif
  281.  
  282.    #ifdef __cplusplus
  283.       }
  284.    #endif
  285.  
  286.    #pragma info( none )
  287.    #ifndef __CHKHDR__
  288.       #pragma info( restore )
  289.    #endif
  290.    #pragma info( restore )
  291.  
  292. #endif
  293.