1*46111Sbostic /*- 2*46111Sbostic * Copyright (c) 1990 The Regents of the University of California. 3*46111Sbostic * All rights reserved. 4*46111Sbostic * 5*46111Sbostic * This code is derived from software contributed to Berkeley by 6*46111Sbostic * Chris Torek. 7*46111Sbostic * 8*46111Sbostic * %sccs.include.redist.c% 9*46111Sbostic * 10*46111Sbostic * @(#)local.h 5.1 (Berkeley) 01/20/91 11*46111Sbostic */ 12*46111Sbostic 13*46111Sbostic /* 14*46111Sbostic * Information local to this implementation of stdio, 15*46111Sbostic * in particular, macros and private variables. 16*46111Sbostic */ 17*46111Sbostic 18*46111Sbostic #if __STDC__ || c_plusplus 19*46111Sbostic extern int __sflush(FILE *); 20*46111Sbostic extern FILE *__sfp(void); 21*46111Sbostic extern int __srefill(FILE *); 22*46111Sbostic extern int __sread(void *, char *, int); 23*46111Sbostic extern int __swrite(void *, char const *, int); 24*46111Sbostic extern fpos_t __sseek(void *, fpos_t, int); 25*46111Sbostic extern int __sclose(void *); 26*46111Sbostic extern void __sinit(void); 27*46111Sbostic extern void _cleanup(void); 28*46111Sbostic extern void (*__cleanup)(void); 29*46111Sbostic extern void __smakebuf(FILE *); 30*46111Sbostic extern int _fwalk(int (*)(FILE *)); 31*46111Sbostic #else /* __STDC__ || c_plusplus */ 32*46111Sbostic extern int __sflush(); 33*46111Sbostic extern FILE *__sfp(); 34*46111Sbostic extern int __srefill(); 35*46111Sbostic extern int __sread(); 36*46111Sbostic extern int __swrite(); 37*46111Sbostic extern fpos_t __sseek(); 38*46111Sbostic extern int __sclose(); 39*46111Sbostic extern void __sinit(); 40*46111Sbostic extern void _cleanup(); 41*46111Sbostic extern void (*__cleanup)(); 42*46111Sbostic extern void __smakebuf(); 43*46111Sbostic extern int __sfwalk(); 44*46111Sbostic #endif /* __STDC__ || c_plusplus */ 45*46111Sbostic 46*46111Sbostic extern int __sdidinit; 47*46111Sbostic 48*46111Sbostic /* 49*46111Sbostic * Return true iff the given FILE cannot be written now. 50*46111Sbostic */ 51*46111Sbostic #define cantwrite(fp) \ 52*46111Sbostic ((((fp)->_flags & __SWR) == 0 || (fp)->_bf._base == NULL) && \ 53*46111Sbostic __swsetup(fp)) 54*46111Sbostic 55*46111Sbostic /* 56*46111Sbostic * Test whether the given stdio file has an active ungetc buffer; 57*46111Sbostic * release such a buffer, without restoring ordinary unread data. 58*46111Sbostic */ 59*46111Sbostic #define HASUB(fp) ((fp)->_ub._base != NULL) 60*46111Sbostic #define FREEUB(fp) { \ 61*46111Sbostic if ((fp)->_ub._base != (fp)->_ubuf) \ 62*46111Sbostic free((char *)(fp)->_ub._base); \ 63*46111Sbostic (fp)->_ub._base = NULL; \ 64*46111Sbostic } 65*46111Sbostic 66*46111Sbostic /* 67*46111Sbostic * test for an fgetline() buffer. 68*46111Sbostic */ 69*46111Sbostic #define HASLB(fp) ((fp)->_lb._base != NULL) 70*46111Sbostic #define FREELB(fp) { \ 71*46111Sbostic free((char *)(fp)->_lb._base); \ 72*46111Sbostic (fp)->_lb._base = NULL; \ 73*46111Sbostic } 74