/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 1982-2011 AT&T Intellectual Property *4* and is licensed under the *5* Eclipse Public License, Version 1.0 *6* by AT&T Intellectual Property *7* *8* A copy of the License is available at *9* http://www.eclipse.org/org/documents/epl-v10.html *10* (with md5 checksum b35adb5213ca9657e911e9befb180842) *11* *12* Information and Software Systems Research *13* AT&T Research *14* Florham Park NJ *15* *16* David Korn <[email protected]> *17* *18***********************************************************************/19#pragma prototyped20#ifndef fcgetc21/*22* David Korn23* AT&T Labs24*25* Fast character input with sfio text streams and strings26*27*/2829#include <sfio.h>3031typedef struct _fcin32{33Sfio_t *_fcfile; /* input file pointer */34unsigned char *fcbuff; /* pointer to input buffer */35unsigned char *fclast; /* pointer to end of input buffer */36unsigned char *fcptr; /* pointer to next input char */37unsigned char fcchar; /* saved character */38short fclen; /* last multibyte char len */39void (*fcfun)(Sfio_t*,const char*,int,void*); /* advance function */40void *context; /* context pointer */41int fcleft; /* for multibyte boundary */42Sfoff_t fcoff; /* offset for last read */43} Fcin_t;4445#if SHOPT_MULTIBYTE46# define fcmbget(x) (mbwide()?_fcmbget(x):fcget())47#else48# define fcmbget(x) (fcget())49#endif50#define fcfile() (_Fcin._fcfile)51#define fcgetc(c) (((c=fcget()) || (c=fcfill())), c)52#define fcget() ((int)(*_Fcin.fcptr++))53#define fcpeek(n) ((int)_Fcin.fcptr[n])54#define fcseek(n) ((char*)(_Fcin.fcptr+=(n)))55#define fcfirst() ((char*)_Fcin.fcbuff)56#define fclast() ((char*)_Fcin.fclast)57#define fcleft() (_Fcin.fclast-_Fcin.fcptr)58#define fcsopen(s) (_Fcin._fcfile=(Sfio_t*)0,_Fcin.fclen=1,_Fcin.fcbuff=_Fcin.fcptr=(unsigned char*)(s))59#define fctell() (_Fcin.fcoff + (_Fcin.fcptr-_Fcin.fcbuff))60#define fcsave(x) (*(x) = _Fcin)61#define fcrestore(x) (_Fcin = *(x))62extern int fcfill(void);63extern int fcfopen(Sfio_t*);64extern int fcclose(void);65void fcnotify(void(*)(Sfio_t*,const char*,int,void*),void*);66extern int _fcmbget(short*);6768extern Fcin_t _Fcin; /* used by macros */6970#endif /* fcgetc */717273