1 /***********************************************************************
3 * This software is part of the ast package *
4 * Copyright (c) 1982-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
13 * Information and Software Systems Research *
17 * David Korn <dgk@research.att.com> *
19 ***********************************************************************/
26 * Fast character input with sfio text streams and strings
34 Sfio_t
*_fcfile
; /* input file pointer */
35 unsigned char *fcbuff
; /* pointer to input buffer */
36 unsigned char *fclast
; /* pointer to end of input buffer */
37 unsigned char *fcptr
; /* pointer to next input char */
38 unsigned char fcchar
; /* saved character */
39 void (*fcfun
)(Sfio_t
*,const char*,int,void*); /* advance function */
40 void *context
; /* context pointer */
41 int fcleft
; /* for multibyte boundary */
42 Sfoff_t fcoff
; /* offset for last read */
45 #define fcfile() (_Fcin._fcfile)
46 #define fcgetc(c) (((c=fcget()) || (c=fcfill())), c)
47 #define fcget() ((int)(*_Fcin.fcptr++))
48 #define fcpeek(n) ((int)_Fcin.fcptr[n])
49 #define fcseek(n) ((char*)(_Fcin.fcptr+=(n)))
50 #define fcfirst() ((char*)_Fcin.fcbuff)
51 #define fcsopen(s) (_Fcin._fcfile=(Sfio_t*)0,_Fcin.fcbuff=_Fcin.fcptr=(unsigned char*)(s))
52 #define fctell() (_Fcin.fcoff + (_Fcin.fcptr-_Fcin.fcbuff))
53 #define fcsave(x) (*(x) = _Fcin)
54 #define fcrestore(x) (_Fcin = *(x))
55 extern int fcfill(void);
56 extern int fcfopen(Sfio_t
*);
57 extern int fcclose(void);
58 void fcnotify(void(*)(Sfio_t
*,const char*,int,void*),void*);
59 extern int fcmbstate(const char*,int*,int*);
61 extern Fcin_t _Fcin
; /* used by macros */