fio.h 2.9 KB

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