Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/ksh93/include/fcin.h
1810 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 1982-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* David Korn <[email protected]> *
18
* *
19
***********************************************************************/
20
#pragma prototyped
21
#ifndef fcgetc
22
/*
23
* David Korn
24
* AT&T Labs
25
*
26
* Fast character input with sfio text streams and strings
27
*
28
*/
29
30
#include <sfio.h>
31
32
typedef struct _fcin
33
{
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
short fclen; /* last multibyte char len */
40
void (*fcfun)(Sfio_t*,const char*,int,void*); /* advance function */
41
void *context; /* context pointer */
42
int fcleft; /* for multibyte boundary */
43
Sfoff_t fcoff; /* offset for last read */
44
} Fcin_t;
45
46
#if SHOPT_MULTIBYTE
47
# define fcmbget(x) (mbwide()?_fcmbget(x):fcget())
48
#else
49
# define fcmbget(x) (fcget())
50
#endif
51
#define fcfile() (_Fcin._fcfile)
52
#define fcgetc(c) (((c=fcget()) || (c=fcfill())), c)
53
#define fcget() ((int)(*_Fcin.fcptr++))
54
#define fcpeek(n) ((int)_Fcin.fcptr[n])
55
#define fcseek(n) ((char*)(_Fcin.fcptr+=(n)))
56
#define fcfirst() ((char*)_Fcin.fcbuff)
57
#define fclast() ((char*)_Fcin.fclast)
58
#define fcleft() (_Fcin.fclast-_Fcin.fcptr)
59
#define fcsopen(s) (_Fcin._fcfile=(Sfio_t*)0,_Fcin.fclen=1,_Fcin.fcbuff=_Fcin.fcptr=(unsigned char*)(s))
60
#define fctell() (_Fcin.fcoff + (_Fcin.fcptr-_Fcin.fcbuff))
61
#define fcsave(x) (*(x) = _Fcin)
62
#define fcrestore(x) (_Fcin = *(x))
63
extern int fcfill(void);
64
extern int fcfopen(Sfio_t*);
65
extern int fcclose(void);
66
void fcnotify(void(*)(Sfio_t*,const char*,int,void*),void*);
67
extern int _fcmbget(short*);
68
69
extern Fcin_t _Fcin; /* used by macros */
70
71
#endif /* fcgetc */
72
73