1N/A/***********************************************************************
1N/A* *
1N/A* This software is part of the ast package *
1N/A* Copyright (c) 1982-2011 AT&T Intellectual Property *
1N/A* and is licensed under the *
1N/A* Common Public License, Version 1.0 *
1N/A* by AT&T Intellectual Property *
1N/A* *
1N/A* A copy of the License is available at *
1N/A* http://www.opensource.org/licenses/cpl1.0.txt *
1N/A* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
1N/A* *
1N/A* Information and Software Systems Research *
1N/A* AT&T Research *
1N/A* Florham Park NJ *
1N/A* *
1N/A* David Korn <dgk@research.att.com> *
1N/A* *
1N/A***********************************************************************/
1N/A#pragma prototyped
1N/A#ifndef fcgetc
1N/A/*
1N/A * David Korn
1N/A * AT&T Labs
1N/A *
1N/A * Fast character input with sfio text streams and strings
1N/A *
1N/A */
1N/A
1N/A#include <sfio.h>
1N/A
1N/Atypedef struct _fcin
1N/A{
1N/A Sfio_t *_fcfile; /* input file pointer */
1N/A unsigned char *fcbuff; /* pointer to input buffer */
1N/A unsigned char *fclast; /* pointer to end of input buffer */
1N/A unsigned char *fcptr; /* pointer to next input char */
1N/A unsigned char fcchar; /* saved character */
1N/A short fclen; /* last multibyte char len */
1N/A void (*fcfun)(Sfio_t*,const char*,int,void*); /* advance function */
1N/A void *context; /* context pointer */
1N/A int fcleft; /* for multibyte boundary */
1N/A Sfoff_t fcoff; /* offset for last read */
1N/A} Fcin_t;
1N/A
1N/A#if SHOPT_MULTIBYTE
1N/A# define fcmbget(x) (mbwide()?_fcmbget(x):fcget())
1N/A#else
1N/A# define fcmbget(x) (fcget())
1N/A#endif
1N/A#define fcfile() (_Fcin._fcfile)
1N/A#define fcgetc(c) (((c=fcget()) || (c=fcfill())), c)
1N/A#define fcget() ((int)(*_Fcin.fcptr++))
1N/A#define fcpeek(n) ((int)_Fcin.fcptr[n])
1N/A#define fcseek(n) ((char*)(_Fcin.fcptr+=(n)))
1N/A#define fcfirst() ((char*)_Fcin.fcbuff)
1N/A#define fcsopen(s) (_Fcin._fcfile=(Sfio_t*)0,_Fcin.fclen=1,_Fcin.fcbuff=_Fcin.fcptr=(unsigned char*)(s))
1N/A#define fctell() (_Fcin.fcoff + (_Fcin.fcptr-_Fcin.fcbuff))
1N/A#define fcsave(x) (*(x) = _Fcin)
1N/A#define fcrestore(x) (_Fcin = *(x))
1N/Aextern int fcfill(void);
1N/Aextern int fcfopen(Sfio_t*);
1N/Aextern int fcclose(void);
1N/Avoid fcnotify(void(*)(Sfio_t*,const char*,int,void*),void*);
1N/Aextern int _fcmbget(short*);
1N/A
1N/Aextern Fcin_t _Fcin; /* used by macros */
1N/A
1N/A#endif /* fcgetc */