source: buchla-68k/orig/LATTICE/STDIO.H@ 7bf3856

Last change on this file since 7bf3856 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 8 years ago

Imported original source code.

  • Property mode set to 100755
File size: 2.3 KB
Line 
1/**
2*
3* This header file defines the information used by the standard I/O
4* package.
5*
6**/
7#define _BUFSIZ 512 /* standard buffer size */
8#define BUFSIZ 512 /* standard buffer size */
9#define _NFILE 20 /* maximum number of files */
10
11struct _iobuf
12{
13char *_ptr; /* current buffer pointer */
14int _rcnt; /* current byte count for reading */
15int _wcnt; /* current byte count for writing */
16char *_base; /* base address of I/O buffer */
17char _flag; /* control flags */
18char _file; /* file number */
19int _size; /* size of buffer */
20char _cbuff; /* single char buffer */
21char _pad; /* (pad to even number of bytes) */
22};
23
24extern struct _iobuf _iob[_NFILE];
25
26#define _IOREAD 1 /* read flag */
27#define _IOWRT 2 /* write flag */
28#define _IONBF 4 /* non-buffered flag */
29#define _IOMYBUF 8 /* private buffer flag */
30#define _IOEOF 16 /* end-of-file flag */
31#define _IOERR 32 /* error flag */
32#define _IOSTRG 64
33#define _IORW 128 /* read-write (update) flag */
34
35#if SPTR
36#define NULL 0 /* null pointer value */
37#else
38#define NULL 0L
39#endif
40#define FILE struct _iobuf /* shorthand */
41#define EOF (-1) /* end-of-file code */
42
43#define stdin (&_iob[0]) /* standard input file pointer */
44#define stdout (&_iob[1]) /* standard output file pointer */
45#define stderr (&_iob[2]) /* standard error file pointer */
46
47#define getc(p) (--(p)->_rcnt>=0? ((unsigned char)(*(p)->_ptr++)):_filbf(p))
48#define getchar() getc(stdin)
49#define putc(c,p) (--(p)->_wcnt>=0? ((int)(*(p)->_ptr++=(c))):_flsbf((c),p))
50#define putchar(c) putc(c,stdout)
51#define feof(p) (((p)->_flag&_IOEOF)!=0)
52#define ferror(p) (((p)->_flag&_IOERR)!=0)
53#define fileno(p) (p)->_file
54#define rewind(fp) fseek(fp,0L,0)
55#define fflush(fp) _flsbf(-1,fp)
56#define clearerr(fp) clrerr(fp)
57
58FILE *fopen();
59FILE *freopen();
60long ftell();
61char *fgets();
62
63#define abs(x) ((x)<0?-(x):(x))
64#define max(a,b) ((a)>(b)?(a):(b))
65#define min(a,b) ((a)<=(b)?(a):(b))
66
67
Note: See TracBrowser for help on using the repository browser.