Commit | Line | Data |
---|---|---|
bae7117f WH |
1 | #include "stdio.h" |
2 | #include "errno.h" | |
3 | #ifndef NULL | |
4 | /* ANSI C */ | |
5 | #include "stddef.h" | |
6 | #endif | |
7 | ||
8 | #ifndef SEEK_SET | |
9 | #define SEEK_SET 0 | |
10 | #define SEEK_CUR 1 | |
11 | #define SEEK_END 2 | |
12 | #endif | |
13 | ||
14 | #ifdef MSDOS | |
15 | #ifndef NON_UNIX_STDIO | |
16 | #define NON_UNIX_STDIO | |
17 | #endif | |
18 | #endif | |
19 | ||
20 | #ifdef UIOLEN_int | |
21 | typedef int uiolen; | |
22 | #else | |
23 | typedef long uiolen; | |
24 | #endif | |
25 | ||
26 | /*units*/ | |
27 | typedef struct | |
28 | { FILE *ufd; /*0=unconnected*/ | |
29 | char *ufnm; | |
30 | #ifndef MSDOS | |
31 | long uinode; | |
32 | int udev; | |
33 | #endif | |
34 | int url; /*0=sequential*/ | |
35 | flag useek; /*true=can backspace, use dir, ...*/ | |
36 | flag ufmt; | |
37 | flag uprnt; | |
38 | flag ublnk; | |
39 | flag uend; | |
40 | flag uwrt; /*last io was write*/ | |
41 | flag uscrtch; | |
42 | } unit; | |
43 | ||
44 | extern flag f__init; | |
45 | extern cilist *f__elist; /*active external io list*/ | |
46 | extern flag f__reading,f__external,f__sequential,f__formatted; | |
47 | #undef Void | |
48 | #ifdef KR_headers | |
49 | #define Void /*void*/ | |
50 | extern int (*f__getn)(),(*f__putn)(); /*for formatted io*/ | |
51 | extern long f__inode(); | |
52 | extern VOID sig_die(); | |
53 | extern int (*f__donewrec)(), t_putc(), x_wSL(); | |
54 | extern int c_sfe(), err_fl(), xrd_SL(); | |
55 | #else | |
56 | #define Void void | |
57 | #ifdef __cplusplus | |
58 | extern "C" { | |
59 | #endif | |
60 | extern int (*f__getn)(void),(*f__putn)(int); /*for formatted io*/ | |
61 | extern long f__inode(char*,int*); | |
62 | extern void sig_die(char*,int); | |
63 | extern void f__fatal(int,char*); | |
64 | extern int t_runc(alist*); | |
65 | extern int f__nowreading(unit*), f__nowwriting(unit*); | |
66 | extern int fk_open(int,int,ftnint); | |
67 | extern int en_fio(void); | |
68 | extern void f_init(void); | |
69 | extern int (*f__donewrec)(void), t_putc(int), x_wSL(void); | |
70 | extern void b_char(char*,char*,ftnlen), g_char(char*,ftnlen,char*); | |
71 | extern int c_sfe(cilist*), z_rnew(void); | |
72 | extern int isatty(int); | |
73 | extern int err__fl(int,int,char*); | |
74 | extern int xrd_SL(void); | |
75 | #ifdef __cplusplus | |
76 | } | |
77 | #endif | |
78 | #endif | |
79 | extern int (*f__doend)(Void); | |
80 | extern FILE *f__cf; /*current file*/ | |
81 | extern unit *f__curunit; /*current unit*/ | |
82 | extern unit f__units[]; | |
83 | #define err(f,m,s) {if(f) errno= m; else f__fatal(m,s); return(m);} | |
84 | #define errfl(f,m,s) return err__fl(f,m,s) | |
85 | ||
86 | /*Table sizes*/ | |
87 | #define MXUNIT 100 | |
88 | ||
89 | extern int f__recpos; /*position in current record*/ | |
90 | extern int f__cursor; /* offset to move to */ | |
91 | extern int f__hiwater; /* so TL doesn't confuse us */ | |
92 | ||
93 | #define WRITE 1 | |
94 | #define READ 2 | |
95 | #define SEQ 3 | |
96 | #define DIR 4 | |
97 | #define FMT 5 | |
98 | #define UNF 6 | |
99 | #define EXT 7 | |
100 | #define INT 8 | |
101 | ||
102 | #define buf_end(x) (x->_flag & _IONBF ? x->_ptr : x->_base + BUFSIZ) |