home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / detk45he.zip / libc / stdio.h < prev    next >
C/C++ Source or Header  |  1999-03-15  |  13KB  |  348 lines

  1. #if __IBMC__ || __IBMCPP__
  2. #pragma info( none )
  3. #ifndef __CHKHDR__
  4.    #pragma info( none )
  5. #endif
  6. #pragma info( restore )
  7. #endif
  8.  
  9. #ifndef __stdio_h
  10.    #define __stdio_h
  11.  
  12.    #ifdef __cplusplus
  13.       extern "C" {
  14.    #endif
  15.  
  16.    #ifndef  _LNK_CONV
  17.       #if __IBMC__ || __IBMCPP__ || defined(_OPTLINK_SUPPORTED)
  18.          #define _LNK_CONV   _Optlink
  19.       #else
  20.          #define _LNK_CONV
  21.       #endif
  22.    #endif
  23.  
  24.    #ifndef _IMPORT
  25.       #ifdef __IMPORTLIB__
  26.          #define _IMPORT _Import
  27.       #else
  28.          #define _IMPORT
  29.       #endif
  30.    #endif
  31.  
  32.    /********************************************************************/
  33.    /*  <stdio.h> header file                                           */
  34.    /*                                                                  */
  35.    /*  (C) Copyright IBM Corp. 1991, 1995.                             */
  36.    /*  - Licensed Material - Program-Property of IBM                   */
  37.    /*  - All rights reserved                                           */
  38.    /*                                                                  */
  39.    /********************************************************************/
  40.  
  41.    #ifndef __size_t
  42.       #define __size_t
  43.       typedef unsigned int size_t;
  44.    #endif
  45.  
  46.    enum _OPERATIONS { _IOINIT, _IOREAD, _IOWRITE, _IOREPOSITION,
  47.                       _IOFLUSH, _IOUNDEFOP };
  48.  
  49.    #define _MAX_UNGET 4
  50.  
  51.    #if __THW_PPC__
  52.       typedef struct __file       /* visible portion of the FILE struct */
  53.          {
  54.          unsigned char     *_bufPtr;
  55.          unsigned long int  _count;
  56.          unsigned long int  _userFlags;
  57.          unsigned long int  _bufLen;
  58.          unsigned long int  _ungetCount;
  59.          int                _tempStore;
  60.          enum _OPERATIONS   _lastOp;
  61.          unsigned char      _ungetBuf[_MAX_UNGET];
  62.          char               _filler;
  63.          } FILE;
  64.    #else /* __THW_INTEL__ */
  65.       #pragma pack( 1 )
  66.       typedef struct __file       /* visible portion of the FILE struct */
  67.          {
  68.          unsigned char     *_bufPtr;
  69.          unsigned long int  _count;
  70.          unsigned long int  _userFlags;
  71.          unsigned long int  _bufLen;
  72.          unsigned long int  _ungetCount;
  73.          int                _tempStore;
  74.          unsigned char      _ungetBuf[_MAX_UNGET];
  75.          enum _OPERATIONS   _lastOp;
  76.          char               _filler;
  77.          } FILE;
  78.       #pragma pack( )
  79.    #endif
  80.  
  81.    typedef struct __fpos_t      /* Definition of file positioning structure */
  82.       {
  83.       long int __fpos_elem[2];
  84.       } fpos_t;
  85.  
  86.    #ifndef NULL
  87.       #if (defined(__EXTENDED__)  || defined( __cplusplus ))
  88.          #define NULL 0
  89.       #else
  90.          #define NULL ((void *)0)
  91.       #endif
  92.    #endif
  93.  
  94.    #define _IOFBF              1   /* Buffer modes */
  95.    #define _IOLBF              2
  96.    #define _IONBF              3
  97.    #define BUFSIZ           4096   /* Default buffer size */
  98.    #define EOF              (-1)
  99.    #define L_tmpnam          260   /* Maximum length of temporary names */
  100.    #define FOPEN_MAX          20   /* Minimum number of open files guaranteed */
  101.    #define FILENAME_MAX      260   /* Maximum file name length */
  102.    #define SEEK_SET            0   /* fseek constants */
  103.    #define SEEK_CUR            1
  104.    #define SEEK_END            2
  105.    #define TMP_MAX        100000   /* Maximum guaranteed unique file names */
  106.  
  107.    #define _IOEOF         0x0001   /* EOF flag mask */
  108.    #define _IOERR         0x0002   /* ERR flag mask */
  109.  
  110.    #if __THW_PPC__
  111.       #ifndef __def_va_list
  112.          #define __def_va_list
  113.          typedef struct {
  114.              char gpr;
  115.              char fpr;
  116.              char reserved[2];
  117.              char *input_arg_area;
  118.              char *reg_save_area;
  119.          } __va_list[1];
  120.       #endif
  121.    #else /* __THW_INTEL__ */
  122.       typedef char *__va_list;
  123.    #endif
  124.  
  125.    /* Standard stream pointers. */
  126.  
  127.    #ifdef _WIN32S
  128.       extern FILE ** const _IMPORT _LNK_CONV _stdin( void );
  129.       extern FILE ** const _IMPORT _LNK_CONV _stdout( void );
  130.       extern FILE ** const _IMPORT _LNK_CONV _stderr( void );
  131.  
  132.       #define stdin          (*_stdin())
  133.       #define stdout         (*_stdout())
  134.       #define stderr         (*_stderr())
  135.    #else
  136.       extern FILE * const _IMPORT stdin;
  137.       extern FILE * const _IMPORT stdout;
  138.       extern FILE * const _IMPORT stderr;
  139.  
  140.       #define stdin          stdin
  141.       #define stdout         stdout
  142.       #define stderr         stderr
  143.    #endif
  144.  
  145.    /* Function declarations. */
  146.  
  147.    void     _IMPORT _LNK_CONV clearerr( FILE * );
  148.    int      _IMPORT _LNK_CONV fclose( FILE * );
  149.    int      _IMPORT _LNK_CONV feof( FILE * );
  150.    int      _IMPORT _LNK_CONV ferror( FILE * );
  151.    int      _IMPORT _LNK_CONV fflush( FILE * );
  152.    int      _IMPORT _LNK_CONV fgetc( FILE * );
  153.    int      _IMPORT _LNK_CONV fgetpos( FILE *, fpos_t * );
  154.    char   * _IMPORT _LNK_CONV fgets( char *, int, FILE * );
  155.    FILE   * _IMPORT _LNK_CONV fopen( const char *, const char * );
  156.    int      _IMPORT _LNK_CONV fputc( int, FILE * );
  157.    int      _IMPORT _LNK_CONV fputs( const char *, FILE * );
  158.    size_t   _IMPORT _LNK_CONV fread( void *, size_t, size_t, FILE * );
  159.    FILE   * _IMPORT _LNK_CONV freopen( const char *, const char *, FILE * );
  160.    int      _IMPORT _LNK_CONV fseek( FILE *, long int, int );
  161.    int      _IMPORT _LNK_CONV fsetpos( FILE *, const fpos_t * );
  162.    long int _IMPORT _LNK_CONV ftell( FILE * );
  163.    size_t   _IMPORT _LNK_CONV fwrite( const void *, size_t, size_t, FILE * );
  164.    int              _LNK_CONV getc( FILE * );
  165.    int              _LNK_CONV getchar( void );
  166.    char   * _IMPORT _LNK_CONV gets( char * );
  167.    void     _IMPORT _LNK_CONV perror( const char * );
  168.    int              _LNK_CONV putc( int, FILE * );
  169.    int              _LNK_CONV putchar( int );
  170.    int      _IMPORT _LNK_CONV puts( const char * );
  171.    int      _IMPORT _LNK_CONV remove( const char * );
  172.    int      _IMPORT _LNK_CONV rename( const char *, const char * );
  173.    void     _IMPORT _LNK_CONV rewind( FILE * );
  174.    void     _IMPORT _LNK_CONV setbuf( FILE *, char * );
  175.    int      _IMPORT _LNK_CONV setvbuf( FILE *, char *, int, size_t );
  176.    FILE   * _IMPORT _LNK_CONV tmpfile( void );
  177.    char   * _IMPORT _LNK_CONV tmpnam( char * );
  178.    int      _IMPORT _LNK_CONV ungetc( int, FILE * );
  179.  
  180.    #define __getc(p) ( \
  181.       (  ((p)->_ungetCount==0) && ((p)->_count!=0))? \
  182.          (--(p)->_count, (int)(*(p)->_bufPtr++)) :\
  183.          fgetc((p)) )
  184.  
  185.    #define __putc(c, p) ( \
  186.       ((((p)->_tempStore = (c)) != '\n') && \
  187.       ((p)->_lastOp == _IOWRITE) && ((p)->_count < (p)->_bufLen)) ? \
  188.          (++(p)->_count, *(p)->_bufPtr++ = (p)->_tempStore): \
  189.          fputc((p)->_tempStore,(p)) )
  190.  
  191.    #ifndef __MULTI__
  192.       #ifdef __cplusplus
  193.          inline int getc( FILE * p )        { return __getc( p ); }
  194.          inline int putc( int c, FILE * p ) { return __putc( c, p ); }
  195.       #else
  196.          #define getc( p )    __getc( (p) )
  197.          #define putc( c, p ) __putc( (c), (p) )
  198.       #endif
  199.    #else
  200.       #ifdef __cplusplus
  201.          inline int getc( FILE * p )        { return fgetc( p ); }
  202.          inline int putc( int c, FILE * p ) { return fputc( c, p ); }
  203.       #else
  204.          #define getc( p )  fgetc( (p) )
  205.          #define putc( c, p ) fputc( (c), (p) )
  206.       #endif
  207.    #endif
  208.  
  209.    #ifdef __cplusplus
  210.       inline int getchar( void )   { return getc( stdin ); }
  211.       inline int putchar( int c ) { return putc( c, stdout ); }
  212.    #else
  213.       #define getchar( )   getc( stdin )
  214.       #define putchar( c ) putc( (c), stdout )
  215.    #endif
  216.  
  217.    /* clearerr, feof, and ferror macros - single threaded only */
  218.  
  219.    #ifndef __MULTI__
  220.       #define clearerr( stream ) ( ( void )( (stream)->_userFlags = 0L ) )
  221.       #define feof( stream )     ( ( int  )( (stream)->_userFlags & _IOEOF ) )
  222.       #define ferror( stream )   ( ( int  )( (stream)->_userFlags & _IOERR ) )
  223.    #endif
  224.  
  225.    #if __EXTENDED__ || defined(__cplusplus)
  226.  
  227.       #define _IO_WRITETHRU  0x0004   /* WRITETHRU mask */
  228.  
  229.       #if __IBMC__ || __IBMCPP__
  230.          #if __WINDOWS__ && __THW_INTEL__
  231.             #pragma map( fprintf, "?_fprintfieee" )
  232.             #pragma map( printf , "?_printfieee"  )
  233.             #pragma map( sprintf, "?_sprintfieee" )
  234.             #pragma map( fscanf , "?_fscanfieee"  )
  235.             #pragma map( scanf  , "?_scanfieee"   )
  236.             #pragma map( sscanf , "?_sscanfieee"  )
  237.             #pragma map( vfprintf, "?_vfprintfieee" )
  238.             #pragma map( vprintf , "?_vprintfieee"  )
  239.             #pragma map( vsprintf, "?_vsprintfieee" )
  240.          #else
  241.             #pragma map( fprintf, "_fprintfieee" )
  242.             #pragma map( printf , "_printfieee"  )
  243.             #pragma map( sprintf, "_sprintfieee" )
  244.             #pragma map( fscanf , "_fscanfieee"  )
  245.             #pragma map( scanf  , "_scanfieee"   )
  246.             #pragma map( sscanf , "_sscanfieee"  )
  247.             #pragma map( vfprintf, "_vfprintfieee" )
  248.             #pragma map( vprintf , "_vprintfieee"  )
  249.             #pragma map( vsprintf, "_vsprintfieee" )
  250.          #endif
  251.       #else
  252.          #define fprintf _fprintfieee
  253.          #define printf _printfieee
  254.          #define sprintf _sprintfieee
  255.          #define fscanf _fscanfieee
  256.          #define scanf _scanfieee
  257.          #define sscanf _sscanfieee
  258.          #define vfprintf _vfprintfieee
  259.          #define vprintf _vprintfieee
  260.          #define fsprintf _fsprintfieee
  261.       #endif
  262.  
  263.       int _LNK_CONV _fcloseall( void );
  264.       int _LNK_CONV _rmtmp( void );
  265.  
  266.       #define P_tmpdir "\\"
  267.       FILE * _IMPORT _LNK_CONV fdopen( int, const char *);
  268.       int    _IMPORT _LNK_CONV fgetchar( void );
  269.       int    _IMPORT _LNK_CONV fileno( FILE * );
  270.       int    _IMPORT _LNK_CONV flushall( void );
  271.       int    _IMPORT _LNK_CONV fputchar( int );
  272.       char * _IMPORT _LNK_CONV tempnam( char *, char * );
  273.       int    _IMPORT _LNK_CONV unlink( const char * );
  274.  
  275.       FILE * _IMPORT _LNK_CONV _fdopen( int, const char *);
  276.       int    _IMPORT _LNK_CONV _fgetchar( void );
  277.       int    _IMPORT _LNK_CONV _fileno( FILE * );
  278.       int    _IMPORT _LNK_CONV _flushall( void );
  279.       int    _IMPORT _LNK_CONV _fputchar( int );
  280.       char * _IMPORT _LNK_CONV _tempnam( char *, char * );
  281.       int    _IMPORT _LNK_CONV _unlink( const char * );
  282.  
  283.       int    _IMPORT _LNK_CONV _set_crt_msg_handle( int );
  284.  
  285.       #if __IBMC__ || __IBMCPP__
  286.          #if __WINDOWS__ && __THW_INTEL__
  287.             #pragma map( fdopen  , "?_fdopen"   )
  288.             #pragma map( fgetchar, "?_fgetchar" )
  289.             #pragma map( fileno  , "?_fileno"   )
  290.             #pragma map( flushall, "?_flushall" )
  291.             #pragma map( fputchar, "?_fputchar" )
  292.             #pragma map( tempnam , "?_tempnam"  )
  293.             #ifndef __unlink
  294.                #define __unlink
  295.                #pragma map( unlink  , "?_unlink"   )
  296.             #endif
  297.          #else
  298.             #pragma map( fdopen  , "_fdopen"   )
  299.             #pragma map( fgetchar, "_fgetchar" )
  300.             #pragma map( fileno  , "_fileno"   )
  301.             #pragma map( flushall, "_flushall" )
  302.             #pragma map( fputchar, "_fputchar" )
  303.             #pragma map( tempnam , "_tempnam"  )
  304.             #ifndef __unlink
  305.                #define __unlink
  306.                #pragma map( unlink  , "_unlink"   )
  307.             #endif
  308.          #endif
  309.       #else
  310.          #define fdopen _fdopen
  311.          #define fgetchar _fgetchar
  312.          #define fileno _fileno
  313.          #define flushall _flushall
  314.          #define fputchar _fputchar
  315.          #define tempnam _tempnam
  316.          #ifndef __unlink
  317.             #define __unlink
  318.             #define unlink _unlink
  319.          #endif
  320.       #endif
  321.  
  322.    #endif
  323.  
  324.    int      _IMPORT _LNK_CONV fprintf( FILE *, const char *, ... );
  325.    int      _IMPORT _LNK_CONV fscanf( FILE *, const char *, ... );
  326.    int      _IMPORT _LNK_CONV printf( const char *, ... );
  327.    int      _IMPORT _LNK_CONV scanf( const char *, ... );
  328.    int      _IMPORT _LNK_CONV sprintf( char *, const char *, ... );
  329.    int      _IMPORT _LNK_CONV sscanf( const char *, const char *, ... );
  330.    int      _IMPORT _LNK_CONV vfprintf( FILE *, const char *, __va_list );
  331.    int      _IMPORT _LNK_CONV vprintf( const char *, __va_list );
  332.    int      _IMPORT _LNK_CONV vsprintf( char *, const char *, __va_list );
  333.  
  334.    #ifdef __cplusplus
  335.       }
  336.    #endif
  337.  
  338. #endif
  339.  
  340. #if __IBMC__ || __IBMCPP__
  341. #pragma info( none )
  342. #ifndef __CHKHDR__
  343.    #pragma info( restore )
  344. #endif
  345. #pragma info( restore )
  346. #endif
  347.  
  348.