home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / gcc / gcc261a.zoo / g++-include / stdio.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-21  |  13.8 KB  |  562 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2. /* 
  3. Copyright (C) 1988 Free Software Foundation
  4.     written by Doug Lea (dl@rocky.oswego.edu)
  5.  
  6. This file is part of the GNU C++ Library.  This library is free
  7. software; you can redistribute it and/or modify it under the terms of
  8. the GNU Library General Public License as published by the Free
  9. Software Foundation; either version 2 of the License, or (at your
  10. option) any later version.  This library is distributed in the hope
  11. that it will be useful, but WITHOUT ANY WARRANTY; without even the
  12. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  13. PURPOSE.  See the GNU Library General Public License for more details.
  14. You should have received a copy of the GNU Library General Public
  15. License along with this library; if not, write to the Free Software
  16. Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18.  
  19. /*
  20.  *  Please check the following before installing this file:
  21.  *
  22.  *  Make sure USG is #defined if you are on a USG system!
  23.  *
  24.  *  Check the value of _NFILE against the one in your /usr/include/stdio.h.
  25.  *  (USG only)
  26.  *
  27.  *  Check whether your libc.a sprintf function returns
  28.  *  an int (as do most) versus a char* (BSD), and (un)comment
  29.  *  the corresponding SPRINTF_RETURNS_INT line.
  30.  *
  31.  *  Check the value of BUFSIZ against the one in your /usr/include/stdio.h.
  32.  *
  33.  *  Carefully check the fields and order of _iobuf declaration against
  34.  *  the one in your /usr/include/stdio.h. Xenix-based systems
  35.  *  may need some re-ordering of _iobuf. fields.
  36.  *
  37.  *  Note that some _IOXXX #defines may not be present in your 
  38.  *  /usr/include/stdio.h. This is ok, so long as the ones that
  39.  *  are present in both are set to the same values.
  40.  *
  41.  *  Some of the prototypes refer to functions that may not be
  42.  *  present in your libc.a. This is ok so long as you do not
  43.  *  actually call such functions.
  44.  *
  45.  */
  46.  
  47. #ifndef _stdio_h
  48. #ifdef __GNUG__
  49. /* #pragma once */
  50. #pragma interface
  51. #endif
  52. #define _stdio_h 1
  53.  
  54. /*
  55.    HAVE_VPRINTF should be set if vprintf is in libc.a
  56.    HAVE_SETVBUF should be set if setvbuf is in libc.a
  57.    HAVE_SETLINEBUF should be set if setlinebuf in libc.a
  58.  
  59.    The following are probably correct for the listed systems
  60.  
  61. */
  62.  
  63. #ifdef SYSTEM_FIVE
  64. #define USG
  65. #endif
  66.  
  67. #if defined(USG)
  68. #define  HAVE_VPRINTF
  69. #define  HAVE_SETVBUF  
  70. //#define  HAVE_SETLINEBUF
  71.  
  72. #elif defined(VMS)
  73. #define  HAVE_VPRINTF
  74. #define  HAVE_SETVBUF  
  75. //#define  HAVE_SETLINEBUF
  76. #define NO_LIBGXX_MALLOC
  77. #define _NFILE 20
  78. #define IOBUF_FLAG_TYPE char
  79. #define IOBUF_BUFSIZ_FIELD    /* we aint got one either*/
  80.  
  81. #elif masscomp
  82. #ifndef _NFILE
  83. #define _NFILE 40
  84. #endif
  85. #ifdef _ATT
  86. #define HAVE_VPRINTF
  87. #define HAVE_SETVBUF  
  88. #define USG
  89. #endif
  90. #ifdef _UCB
  91. #undef HAVE_VPRINTF
  92. #undef HAVE_SETLINEBUF
  93. #define IOBUF_BUFSIZ_FIELD
  94. #endif
  95.  
  96. #elif defined(vax) || defined(sony)
  97. //#define HAVE_VPRINTF
  98. //#define  HAVE_SETVBUF  
  99. #define HAVE_SETLINEBUF
  100.  
  101. #elif defined(sun)
  102. #define  HAVE_VPRINTF
  103. #define  HAVE_SETVBUF  
  104. #define  HAVE_SETLINEBUF
  105.  
  106. #elif defined(sequent)
  107. //#define  HAVE_VPRINTF
  108. //#define  HAVE_SETVBUF  
  109. #define  HAVE_SETLINEBUF
  110.  
  111. #elif defined(DGUX)
  112. #define HAVE_VPRINTF
  113. #define HAVE_SETVBUF
  114. #define HAVE_SETLINEBUF
  115. #define IOBUF_FLAG_TYPE    int
  116. #define IOBUF_FILE_TYPE    int
  117. #define _NFILE 64
  118. #define IOBUF_EXTRA_FIELDS    int _reserve[27];
  119. #define SPRINTF_RETURNS_INT
  120. #define BUFEND_ENTRY_TYPE unsigned char *
  121. #define USG
  122.  
  123. #elif defined(TEKTRONIX_SYSV) || defined(hp9000s300) || defined(i386)
  124. #define  HAVE_VPRINTF
  125. #define  HAVE_SETVBUF  
  126. //#define HAVE_SETLINEBUF
  127. #define  USG
  128.  
  129. #elif defined(convex)
  130. //#define HAVE_VPRINTF
  131. //#define HAVE_SETVBUF
  132. #define HAVE_SETLINEBUF
  133. #define IOBUF_FILE_TYPE unsigned char
  134. #define HAVE_VOID_DOPRNT
  135.  
  136. #elif defined(atarist)
  137. #include <compiler.h>
  138.  
  139. #ifndef _SIZE_T
  140. #define _SIZE_T __SIZE_TYPEDEF__
  141. typedef _SIZE_T size_t;
  142. #endif
  143.  
  144. /* object of type capable of recording uniquely every position in a file */
  145. typedef unsigned long fpos_t;
  146.  
  147. #define HAVE_VSCANF
  148. #define HAVE_VPRINTF
  149. #define HAVE_SETVBUF
  150. #define HAVE_SETLINEBUF
  151. #define IOBUF_FLAG_TYPE unsigned int
  152. #define IOBUF_FILE_TYPE int
  153. #define IOBUF_BUFSIZ_FIELD long _bsiz;
  154. #define IOBUF_EXTRA_FIELDS unsigned char _ch;
  155.  
  156. #ifndef _NFILE
  157. #define _NFILE (20)
  158. #endif
  159.  
  160. #define SPRINTF_RETURNS_INT
  161. #ifndef NULL
  162. #  ifdef __MSHORT__
  163. #    define __NULL ((void *)0)
  164. #  else
  165.      /* avoid complaints about misuse of NULL :-)*/
  166. #    define __NULL (0)
  167. #  endif
  168. #endif
  169. #define L_tmpnam    128
  170. #define TMP_MAX        100
  171. #ifndef NO_LIBGXX_MALLOC
  172. #  define NO_LIBGXX_MALLOC
  173. #endif
  174.  
  175. #endif /* atarist */
  176.  
  177. #ifdef hpux
  178. #define IOBUF_FLAG_TYPE short
  179. #endif
  180.  
  181. #ifdef i386
  182. #define IOBUF_FLAG_TYPE char
  183. #endif
  184.  
  185. #ifdef USG
  186. #define IOBUF_BUFSIZ_FIELD    /* System V ain't got one */
  187. #endif
  188.  
  189. /* Some default definitions for things not defined machine-specifically
  190.    above.  */
  191.  
  192. #ifndef IOBUF_BUFSIZ_FIELD
  193. #define IOBUF_BUFSIZ_FIELD int _bufsiz;
  194. #endif
  195.  
  196. #ifndef IOBUF_FLAG_TYPE
  197. #define IOBUF_FLAG_TYPE short
  198. #endif
  199.  
  200. #ifndef IOBUF_FILE_TYPE
  201. #define IOBUF_FILE_TYPE char
  202. #endif
  203.  
  204. #ifndef IOBUF_EXTRA_FIELDS
  205. #define IOBUF_EXTRA_FIELDS
  206. #endif
  207.  
  208. #if defined(USG) && !defined(_NFILE)
  209. #ifdef hpux
  210. #define _NFILE 60
  211. #elif
  212. #define _NFILE 20
  213. #endif
  214. #endif
  215.  
  216. #ifdef USG
  217. #define _bufend(p) _bufendtab[(p)->_file]
  218. #define _bufsiz(p) (_bufend(p) - (p)->_base)
  219. #ifndef BUFEND_ENTRY_TYPE
  220. #define BUFEND_ENTRY_TYPE char *
  221. #endif
  222. extern "C" {
  223. BUFEND_ENTRY_TYPE _bufendtab[];
  224. }
  225. #endif
  226.  
  227. /* check this -- hardly any systems need this these days */
  228. /* #define SPRINTF_RETURNS_INT */
  229.  
  230. /* check and possibly redefine the following */
  231.  
  232. #ifndef VMS
  233. #define BUFSIZ  ((size_t)1024)
  234. #else
  235. #define BUFSIZ 512
  236. #endif
  237.  
  238. #ifdef masscomp 
  239. extern struct _iobuf {
  240. #ifdef BUFSIZ
  241. #  undef BUFSIZ
  242. #endif
  243. #define BUFSIZ  4096
  244.  
  245. #ifdef mc68000
  246.     unsigned char*    _ptr;
  247.     int      _cnt;
  248. #endif
  249.     char*    _base;
  250.     IOBUF_BUFSIZ_FIELD
  251.     IOBUF_FLAG_TYPE    _flag;
  252.     IOBUF_FILE_TYPE    _file;
  253.     IOBUF_EXTRA_FIELDS
  254. } _iob[];
  255. #else /* not masscomp */
  256. #ifdef atarist
  257. #  ifdef BUFSIZ
  258. #    undef BUFSIZ
  259. #  endif
  260. #  define BUFSIZ ((size_t)1024)
  261. extern "C" { extern unsigned long __DEFAULT_BUFSIZ__; }
  262. extern  struct  _iobuf {
  263.     long                _cnt;
  264.     unsigned char      *_ptr;
  265.     unsigned char      *_base;
  266.     IOBUF_FLAG_TYPE    _flag;
  267.     IOBUF_FILE_TYPE    _file;
  268.     IOBUF_BUFSIZ_FIELD
  269.     IOBUF_EXTRA_FIELDS
  270. } _iob[];
  271. #else /* not atarist */
  272. extern  struct  _iobuf {
  273.     int      _cnt;
  274.     char*    _ptr;
  275.     char*    _base;
  276.     IOBUF_BUFSIZ_FIELD
  277.     IOBUF_FLAG_TYPE    _flag;
  278.     IOBUF_FILE_TYPE    _file;
  279.     IOBUF_EXTRA_FIELDS
  280. } _iob[];
  281. #endif /* not atari */
  282. #endif /* not masscomp */
  283.  
  284. #ifndef VMS
  285. typedef struct _iobuf FILE;
  286. #else
  287. typedef struct _iobuf *FILE;
  288. typedef FILE *VMS_FILE;
  289. #endif
  290.  
  291. #ifndef atarist
  292. #define _IOFBF    00000
  293. #define _IOREAD   00001
  294. #define _IOWRT    00002
  295. #define _IONBF    00004
  296. #define _IOMYBUF  00010
  297. #define _IOEOF    00020
  298. #define _IOERR    00040
  299. #if defined(USG) && !defined(hpux)
  300. #define _IOSTRG   00000  /* faked out for USG */
  301. #define _IOLBF    00100
  302. #define _IORW     00200
  303. #define _IOAPPEND 00000 /* faked out for USG */
  304. #elif defined(masscomp)
  305. #define _IOSTRG        0x00        /* not used in this version of stdio */
  306. #ifdef _IOERR
  307. # undef _IOERR
  308. #endif
  309. #define    _IOERR        0x40        /* i/o error on buffer */
  310. #define    _IOLBF        0x80        /* buffering is by line */
  311. #define    _IORW        0x100        /* read or write ok */
  312. #define _IOAPPEND    0x00        /* not used in this version of stdio */
  313. #elif defined(hpux)
  314. #define _IOSTRG   00000  /* faked out for USG */
  315. #define _IOLBF    00200
  316. #define _IORW     00400
  317. #define _IOAPPEND 00000 /* faked out for USG */
  318. #elif defined(VMS)
  319. #define    _IOSTRG        0100            /* Doing I/O to a string */
  320. #define    _IORW        0200            /* Open for read/write     */
  321. #define _IOAPPEND    00        /* VMS does not actually have this */
  322. #else
  323. #define _IOSTRG   00100
  324. #define _IOLBF    00200
  325. #define _IORW     00400
  326. #define _IOAPPEND 01000
  327. #endif
  328. #ifdef DGUX
  329. #define _IOPBF    00400  /* Boolean - ungetc() not called since fill/flush */
  330. #endif
  331. #else /* atarist */
  332. #define    _IOREAD        0x0001        /* file may be read from */
  333. #define    _IOWRT        0x0002        /* file may be written to */
  334. #define    _IOBIN        0x0004        /* file is in "binary" mode */
  335. #define    _IODEV        0x0008        /* file is a character device */
  336. #define    _IORW        0x0080        /* file is open for update (r+w) */
  337. #define    _IOFBF        0x0100        /* i/o is fully buffered */
  338. #define    _IOLBF        0x0200        /* i/o is line buffered */
  339. #define    _IONBF        0x0400        /* i/o is not buffered */
  340. #define    _IOMYBUF    0x0800        /* standard buffer */
  341. #define    _IOEOF        0x1000        /* EOF has been reached */
  342. #define    _IOERR        0x4000        /* an error has occured */
  343. #define _IOSTRING    0x8000        /* really a string buffer   */
  344. #define    _IOSTRG        _IOSTRING
  345. #define _IOAPPEND    0        /* fake */
  346. #endif /* atarist */
  347.  
  348. #define EOF       (-1)
  349.  
  350. #ifndef NULL
  351. #define NULL      0
  352. #endif
  353.  
  354. #ifndef VMS
  355. #define stdin     (&_iob[0])
  356. #define stdout    (&_iob[1])
  357. #define stderr    (&_iob[2])
  358.  
  359. #ifndef atarist
  360. #define getc(p) (--(p)->_cnt>=0?(int)(*(unsigned char*)(p)->_ptr++):_filbuf(p))
  361. #define putc(x,p) (--(p)->_cnt>=0? ((int)((unsigned char)((*(p)->_ptr++=(unsigned)(x))))):_flsbuf((unsigned)(x),p))
  362. #else
  363. #define getc    fgetc
  364. #define putc    fputc
  365. #define ungetc  fungetc
  366. #define ungetchar(c) fungetc((c), stdin)
  367. #endif
  368.  
  369. #ifdef atarist
  370. #define clearerr(p) ((void) ((p)->_flag &= ~(_IOERR|_IOEOF)))
  371. #else
  372. #define clearerr(p) ((p)->_flag &= ~(_IOERR|_IOEOF))
  373. #endif
  374. #define getchar()   getc(stdin)
  375. #define putchar(x)  putc(x,stdout)
  376. #define feof(p)     (((p)->_flag&_IOEOF)!=0)
  377. #define ferror(p)   (((p)->_flag&_IOERR)!=0)
  378. #define fileno(p)   ((p)->_file)
  379.  
  380. #else
  381.  
  382. #undef _IOFBF
  383. #define _IOLBF 1
  384. #define _IOFBF 2
  385. #define F_RDLCK
  386. /*    Also, stdin/stdout/stderr need to be defined
  387.  *    [We also use a hack here that makes the GCC assembler modify
  388.  *     the psect attributes to match those of the VAX-11 "C" runtime]
  389.  */
  390. #define    stdin    $$PsectAttributes_NOSHR$$stdin
  391. #define    stdout    $$PsectAttributes_NOSHR$$stdout
  392. #define    stderr    $$PsectAttributes_NOSHR$$stderr
  393.  
  394. extern VMS_FILE stdin;
  395. extern VMS_FILE stdout;
  396. extern VMS_FILE stderr;
  397.  
  398. //     Define the stdio macros
  399.  
  400. #define getc(p)        fgetc(p)
  401. #define getchar()    fgetc(stdin)
  402. #define putc(x,p)    fputc(x,p)
  403. #define putchar(x)    fputc(x,stdout)
  404. #define feof(p)        (((*p)->_flag&_IOEOF)!=0)
  405. #define ferror(p)    (((*p)->_flag&_IOERR)!=0)
  406. #define fileno(p)    ((*p)->_file)
  407. #define clearerr(p)    ((*p)->_flag &= ~(_IOERR|_IOEOF))
  408.  
  409. #endif
  410.  
  411. extern "C" {
  412.  
  413. #ifndef atarist
  414. #ifdef VMS
  415. int     c$$doprint(const char*, void*, FILE*);
  416. int     c$$doscan(FILE*, const char*, ...);
  417. int    c$$filbuf(FILE*);
  418. int    c$$flsbuf(unsigned, FILE*);
  419. #else
  420. int    _doprnt(const char*, void*, FILE*);
  421. int    _doscan(FILE*, const char*, ...);
  422. int    _filbuf(FILE*);
  423. int    _flsbuf(unsigned, FILE*);
  424. #endif
  425. int    fclose(FILE*);
  426. FILE*  fdopen(int, const char*);
  427. int    fflush(FILE*);
  428. int    fgetc(FILE*);
  429. char*  fgets _G_ARGS((char*, int, FILE *));
  430. FILE*  fopen(const char*, const char*);
  431. int    fprintf(FILE*, const char* ...);
  432. int    fputc(int, FILE*);
  433. int    fputs(const char*, FILE*);
  434. int    fread(void*, int, int, FILE*);
  435. #ifdef VMS
  436. FILE*  freopen(const char*, const char*, FILE* ...);
  437. #else
  438. FILE*  freopen(const char*, const char*, FILE*);
  439. #endif
  440. int    fscanf(FILE*, const char* ...);
  441. int    fseek(FILE*, long, int);
  442. long   ftell(FILE *);
  443. int    fwrite(const void*, int, int, FILE*);
  444. char*  gets(char*);
  445. int    getw(FILE*);
  446. int    pclose(FILE*);
  447. FILE*  popen(const char*, const char*);
  448. int    printf(const char* ...);
  449. int    puts(const char*);
  450. int    putw(int, FILE*);
  451. int    rewind(FILE*);
  452. int    scanf(const char* ...);
  453. int    setbuf(FILE*, char*);
  454. int    setbuffer(FILE*, char*, int);
  455. int    setlinebuf(FILE*);
  456. int    setvbuf(FILE*, char*, int, int);
  457. int    sscanf(char*, const char* ...);
  458. FILE*  tmpfile();
  459. int    ungetc(int, FILE*);
  460. int    vfprintf(FILE*, const char*, ...);
  461.  
  462. // Third arg to vprintf must be '...' for some machines, & doesn't
  463. // hurt for others.
  464.  
  465. int    vprintf(const char*, ... );
  466.  
  467. #ifdef SPRINTF_RETURNS_INT
  468. int    sprintf(char*, const char* ...);
  469. int    vsprintf(char*, const char*, ...);
  470. #else
  471. char*  sprintf(char*, const char* ...);
  472. char*  vsprintf(char*, const char*, ...);
  473. #endif
  474.  
  475. #else /* atarist */
  476. int remove (const char *filename);
  477. int rename (const char *_oldname, const char *_newname);
  478.  
  479. FILE *tmpfile (void);
  480. char *tmpnam (char *buf);
  481.  
  482. int fclose (FILE *fp);
  483. int fflush (FILE *fp);
  484.  
  485. FILE *fopen (const char *filename, const char *mode);
  486. FILE *freopen (const char *filename, const char *mode, FILE *fp);
  487.  
  488. void setbuf (FILE *fp, char *buf);
  489. int setvbuf (FILE *fp, char *bp, int bmode, size_t size);
  490.  
  491. int fprintf (FILE *fp, const char *fmt, ...);
  492. int printf (const char *fmt, ...);
  493. int sprintf (char *buf, const char *fmt, ...);
  494.  
  495. int fscanf (FILE *fp, const char *fmt, ...);
  496. int scanf (const char *fmt, ...);
  497. int sscanf (const char *buf, const char *fmt, ...);
  498.  
  499. int vfprintf (FILE *, const char *, __VA_LIST__);
  500. int vprintf (const char *, __VA_LIST__);
  501. int vsprintf (char *, const char *, __VA_LIST__);
  502.  
  503. int vfscanf (FILE *, const char *, __VA_LIST__);
  504. int vscanf  (const char *, __VA_LIST__);
  505. int vsscanf (const char *, const char *, __VA_LIST__);
  506.  
  507. int fgetc (FILE *fp);
  508. char *fgets (char *data, int limit, FILE *fp);
  509. char *gets (char *data);
  510.  
  511. int fputc (int c, FILE *fp);
  512. int fputs (const char *data, FILE *fp);
  513. int puts (const char *data);
  514. int fungetc (int c, FILE *fp);
  515.  
  516. size_t fread (void *data, size_t size, size_t count, FILE *fp);
  517. size_t fwrite (const void *data, size_t size, size_t count, FILE *fp);
  518.  
  519. int fgetpos (FILE *fp, fpos_t *pos);
  520. int fsetpos (FILE *fp, fpos_t *pos);
  521.  
  522. long ftell (FILE *fp);
  523. void rewind (FILE *fp);
  524. int fseek (FILE *fp, long offset, int origin);
  525.  
  526. void perror (const char *msg);
  527.  
  528. #ifndef __STRICT_ANSI__
  529. FILE *fdopen (int h, const char *mode);
  530. FILE *popen (const char *command, const char *type);
  531. int pclose (FILE *fp);
  532. # ifndef _POSIX_SOURCE
  533. void _binmode (int force);
  534. long getl (FILE *fp);
  535. long putl (long n, FILE *fp);
  536.  
  537. short getw (FILE *fp);
  538. short putw (short n, FILE *fp);
  539. #endif
  540. #endif
  541. int _filbuf (FILE *);    /* needed for getc */
  542. #endif /* atarist */
  543.  
  544. }
  545.  
  546. #ifndef L_ctermid
  547. #define L_ctermid    9 
  548. #endif
  549. #ifndef L_cuserid
  550. #define L_cuserid    9
  551. #endif
  552. #ifndef P_tmpdir
  553. #define    P_tmpdir    "/tmp/"
  554. #endif
  555. #ifndef L_tmpnam
  556. #define    L_tmpnam    (sizeof(P_tmpdir) + 15)
  557. #endif
  558.  
  559. extern FILE* log_file;
  560.  
  561. #endif // _stdio_h
  562.