home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v1.zip / IBMCPP / INCLUDE / STDIO.H < prev    next >
Text File  |  1993-09-17  |  10KB  |  262 lines

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