| 1 |
#ifndef SYSDEP_H_INCLUDED |
| 2 |
#include "sysdep1.h" |
| 3 |
#endif |
| 4 |
#include "stdio.h" |
| 5 |
#include "errno.h" |
| 6 |
#ifndef NULL |
| 7 |
/* ANSI C */ |
| 8 |
#include "stddef.h" |
| 9 |
#endif |
| 10 |
#ifdef _WIN32 |
| 11 |
#include <io.h> /* for isatty() */ |
| 12 |
#endif |
| 13 |
|
| 14 |
#ifndef SEEK_SET |
| 15 |
#define SEEK_SET 0 |
| 16 |
#define SEEK_CUR 1 |
| 17 |
#define SEEK_END 2 |
| 18 |
#endif |
| 19 |
|
| 20 |
#ifndef FOPEN |
| 21 |
#define FOPEN fopen |
| 22 |
#endif |
| 23 |
|
| 24 |
#ifndef FREOPEN |
| 25 |
#define FREOPEN freopen |
| 26 |
#endif |
| 27 |
|
| 28 |
#ifndef FSEEK |
| 29 |
#define FSEEK fseek |
| 30 |
#endif |
| 31 |
|
| 32 |
#ifndef FSTAT |
| 33 |
#define FSTAT fstat |
| 34 |
#endif |
| 35 |
|
| 36 |
#ifndef FTELL |
| 37 |
#define FTELL ftell |
| 38 |
#endif |
| 39 |
|
| 40 |
#ifndef OFF_T |
| 41 |
#define OFF_T long |
| 42 |
#endif |
| 43 |
|
| 44 |
#ifndef STAT_ST |
| 45 |
#define STAT_ST stat |
| 46 |
#endif |
| 47 |
|
| 48 |
#ifndef STAT |
| 49 |
#define STAT stat |
| 50 |
#endif |
| 51 |
|
| 52 |
#ifdef MSDOS |
| 53 |
#ifndef NON_UNIX_STDIO |
| 54 |
#define NON_UNIX_STDIO |
| 55 |
#endif |
| 56 |
#endif |
| 57 |
|
| 58 |
#ifdef UIOLEN_int |
| 59 |
typedef int uiolen; |
| 60 |
#else |
| 61 |
typedef long uiolen; |
| 62 |
#endif |
| 63 |
|
| 64 |
/*units*/ |
| 65 |
typedef struct |
| 66 |
{ FILE *ufd; /*0=unconnected*/ |
| 67 |
char *ufnm; |
| 68 |
#ifndef MSDOS |
| 69 |
long uinode; |
| 70 |
int udev; |
| 71 |
#endif |
| 72 |
int url; /*0=sequential*/ |
| 73 |
flag useek; /*true=can backspace, use dir, ...*/ |
| 74 |
flag ufmt; |
| 75 |
flag urw; /* (1 for can read) | (2 for can write) */ |
| 76 |
flag ublnk; |
| 77 |
flag uend; |
| 78 |
flag uwrt; /*last io was write*/ |
| 79 |
flag uscrtch; |
| 80 |
} unit; |
| 81 |
|
| 82 |
extern flag f__init; |
| 83 |
extern cilist *f__elist; /*active external io list*/ |
| 84 |
extern flag f__reading,f__external,f__sequential,f__formatted; |
| 85 |
#undef Void |
| 86 |
#ifdef KR_headers |
| 87 |
#define Void /*void*/ |
| 88 |
extern int (*f__getn)(); /* for formatted input */ |
| 89 |
extern void (*f__putn)(); /* for formatted output */ |
| 90 |
extern void x_putc(); |
| 91 |
extern long f__inode(); |
| 92 |
extern VOID sig_die(); |
| 93 |
extern int (*f__donewrec)(), t_putc(), x_wSL(); |
| 94 |
extern int c_sfe(), err__fl(), xrd_SL(), f__putbuf(); |
| 95 |
#else |
| 96 |
#define Void void |
| 97 |
#ifdef __cplusplus |
| 98 |
extern "C" { |
| 99 |
#endif |
| 100 |
extern int (*f__getn)(void); /* for formatted input */ |
| 101 |
extern void (*f__putn)(int); /* for formatted output */ |
| 102 |
extern void x_putc(int); |
| 103 |
extern long f__inode(char*,int*); |
| 104 |
extern void sig_die(char*,int); |
| 105 |
extern void f__fatal(int,char*); |
| 106 |
extern int t_runc(alist*); |
| 107 |
extern int f__nowreading(unit*), f__nowwriting(unit*); |
| 108 |
extern int fk_open(int,int,ftnint); |
| 109 |
extern int en_fio(void); |
| 110 |
extern void f_init(void); |
| 111 |
extern int (*f__donewrec)(void), t_putc(int), x_wSL(void); |
| 112 |
extern void b_char(char*,char*,ftnlen), g_char(char*,ftnlen,char*); |
| 113 |
extern int c_sfe(cilist*), z_rnew(void); |
| 114 |
#ifndef _WIN32 |
| 115 |
extern int isatty(int); |
| 116 |
#endif |
| 117 |
extern int err__fl(int,int,char*); |
| 118 |
extern int xrd_SL(void); |
| 119 |
extern int f__putbuf(int); |
| 120 |
#ifdef __cplusplus |
| 121 |
} |
| 122 |
#endif |
| 123 |
#endif |
| 124 |
extern int (*f__doend)(Void); |
| 125 |
extern FILE *f__cf; /*current file*/ |
| 126 |
extern unit *f__curunit; /*current unit*/ |
| 127 |
extern unit f__units[]; |
| 128 |
#define err(f,m,s) {if(f) errno= m; else f__fatal(m,s); return(m);} |
| 129 |
#define errfl(f,m,s) return err__fl((int)f,m,s) |
| 130 |
|
| 131 |
/*Table sizes*/ |
| 132 |
#define MXUNIT 100 |
| 133 |
|
| 134 |
extern int f__recpos; /*position in current record*/ |
| 135 |
extern OFF_T f__cursor; /* offset to move to */ |
| 136 |
extern OFF_T f__hiwater; /* so TL doesn't confuse us */ |
| 137 |
|
| 138 |
#define WRITE 1 |
| 139 |
#define READ 2 |
| 140 |
#define SEQ 3 |
| 141 |
#define DIR 4 |
| 142 |
#define FMT 5 |
| 143 |
#define UNF 6 |
| 144 |
#define EXT 7 |
| 145 |
#define INT 8 |
| 146 |
|
| 147 |
#define buf_end(x) (x->_flag & _IONBF ? x->_ptr : x->_base + BUFSIZ) |