[f40a309] | 1 | /*
|
---|
| 2 | =============================================================================
|
---|
| 3 | stdio.h -- Standard I/O Package header for the Buchla 700
|
---|
| 4 | Version 6 -- 1987-10-20 -- D.N. Lynx Crowe
|
---|
| 5 | =============================================================================
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #include "fspars.h" /* file system parameters */
|
---|
| 9 |
|
---|
| 10 | #define NULL 0
|
---|
| 11 | #define EOF -1
|
---|
| 12 |
|
---|
| 13 | #define fgetc getc
|
---|
| 14 | #define fputc putc
|
---|
| 15 |
|
---|
| 16 | #define _BUSY 0x01
|
---|
| 17 | #define _ALLBUF 0x02
|
---|
| 18 | #define _DIRTY 0x04
|
---|
| 19 | #define _EOF 0x08
|
---|
| 20 | #define _IOERR 0x10
|
---|
| 21 |
|
---|
| 22 | typedef struct {
|
---|
| 23 |
|
---|
[7258c6a] | 24 | int8_t *_bp; /* current position in buffer */
|
---|
| 25 | int8_t *_bend; /* last character in buffer + 1 */
|
---|
| 26 | int8_t *_buff; /* address of buffer */
|
---|
| 27 | int8_t _flags; /* {_BUSY, _ALLBUF, _DIRTY, _EOF, _IOERR} */
|
---|
| 28 | int8_t _unit; /* fd token returned by open */
|
---|
| 29 | int8_t _bytbuf; /* single byte buffer for unbuffered streams */
|
---|
| 30 | int8_t _pad; /* pad for alignment -- possibly use later */
|
---|
| 31 | int16_t _buflen; /* length of buffer */
|
---|
[f40a309] | 32 |
|
---|
| 33 | } FILE;
|
---|
| 34 |
|
---|
| 35 | #ifndef _FS_DEF_
|
---|
| 36 |
|
---|
| 37 | extern FILE Cbuffs[NSTREAMS]; /* table of FILE structures */
|
---|
[7258c6a] | 38 | extern int8_t *Stdbufs; /* free list of buffers */
|
---|
| 39 | extern int32_t Stdbuf[MAXDFILE][BUFSIZL]; /* buffers */
|
---|
[f40a309] | 40 |
|
---|
| 41 | #endif
|
---|
| 42 |
|
---|
[7258c6a] | 43 | extern int32_t ftell(FILE *fp);
|
---|
| 44 | extern int8_t *gets(int8_t *line);
|
---|
| 45 | extern int8_t *fgets(int8_t *s, int16_t n, FILE *fp);
|
---|
| 46 | extern FILE *fopen(int8_t *name, int8_t *mode);
|
---|
| 47 | extern FILE *fopena(int8_t *name, int8_t *mode);
|
---|
| 48 | extern FILE *fopenb(int8_t *name, int8_t *mode);
|
---|
[d2d593b] | 49 | extern int16_t fread(int8_t *buffer, uint16_t size, int16_t number, FILE *stream);
|
---|
| 50 | extern int16_t fwrite(int8_t *buffer, int16_t size, int16_t number, FILE *stream);
|
---|
| 51 | extern int16_t fseek(FILE *fp, int32_t pos, int16_t mode);
|
---|
| 52 | extern int16_t fflush(FILE *ptr);
|
---|
| 53 | extern int16_t fclose(FILE *ptr);
|
---|
| 54 |
|
---|
| 55 | extern int32_t printf(int8_t *fmt, ...);
|
---|
| 56 | extern int32_t sprintf(int8_t *str, int8_t *fmt, ...);
|
---|
| 57 |
|
---|
| 58 | extern int16_t getc(FILE *ptr);
|
---|
| 59 | extern int16_t putc(int16_t c, FILE *ptr);
|
---|
| 60 | extern int16_t ungetc(int16_t c, FILE *ptr);
|
---|
[f40a309] | 61 |
|
---|
| 62 | #define stdin (&Cbuffs[0])
|
---|
| 63 | #define stdout (&Cbuffs[1])
|
---|
| 64 | #define stderr (&Cbuffs[2])
|
---|
| 65 |
|
---|
| 66 | #define getchar() getc(stdin)
|
---|
| 67 | #define putchar(c) putc(c, stdout)
|
---|
| 68 | #define feof(fp) (((fp)->_flags & _EOF) != 0)
|
---|
| 69 | #define ferror(fp) (((fp)->_flags & _IOERR) != 0)
|
---|
| 70 | #define clearerr(fp) ((fp)->_flags &= ~(_IOERR | _EOF))
|
---|
| 71 | #define fileno(fp) ((fp)->_unit)
|
---|
| 72 |
|
---|
| 73 | #ifndef O_RDONLY /* only define these once */
|
---|
| 74 |
|
---|
| 75 | #define O_RDONLY 0x0000 /* Read-only value */
|
---|
| 76 | #define O_WRONLY 0x0001 /* Write-only value */
|
---|
| 77 | #define O_RDWR 0x0002 /* Read-write value */
|
---|
| 78 |
|
---|
| 79 | #define O_NDELAY 0x0004 /* Non-blocking I/O flag */
|
---|
| 80 | #define O_APPEND 0x0008 /* Append mode flag (write only at end) */
|
---|
| 81 |
|
---|
| 82 | #define O_CREAT 0x0100 /* File creation flag (uses 3rd argument) */
|
---|
| 83 | #define O_TRUNC 0x0200 /* File truncation flag */
|
---|
| 84 | #define O_EXCL 0x0400 /* Exclusive access flag */
|
---|
| 85 |
|
---|
| 86 | #define O_RAW 0x8000 /* Raw (binary) I/O flag for getc and putc */
|
---|
| 87 |
|
---|
| 88 | #endif
|
---|