xref: /aosp_15_r20/external/one-true-awk/proto.h (revision 9a7741de182b2776d7b30d6355f2585c0780a51b)
1*9a7741deSElliott Hughes /****************************************************************
2*9a7741deSElliott Hughes Copyright (C) Lucent Technologies 1997
3*9a7741deSElliott Hughes All Rights Reserved
4*9a7741deSElliott Hughes 
5*9a7741deSElliott Hughes Permission to use, copy, modify, and distribute this software and
6*9a7741deSElliott Hughes its documentation for any purpose and without fee is hereby
7*9a7741deSElliott Hughes granted, provided that the above copyright notice appear in all
8*9a7741deSElliott Hughes copies and that both that the copyright notice and this
9*9a7741deSElliott Hughes permission notice and warranty disclaimer appear in supporting
10*9a7741deSElliott Hughes documentation, and that the name Lucent Technologies or any of
11*9a7741deSElliott Hughes its entities not be used in advertising or publicity pertaining
12*9a7741deSElliott Hughes to distribution of the software without specific, written prior
13*9a7741deSElliott Hughes permission.
14*9a7741deSElliott Hughes 
15*9a7741deSElliott Hughes LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16*9a7741deSElliott Hughes INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
17*9a7741deSElliott Hughes IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
18*9a7741deSElliott Hughes SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19*9a7741deSElliott Hughes WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
20*9a7741deSElliott Hughes IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
21*9a7741deSElliott Hughes ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
22*9a7741deSElliott Hughes THIS SOFTWARE.
23*9a7741deSElliott Hughes ****************************************************************/
24*9a7741deSElliott Hughes 
25*9a7741deSElliott Hughes extern	int	yywrap(void);
26*9a7741deSElliott Hughes extern	void	setfname(Cell *);
27*9a7741deSElliott Hughes extern	int	constnode(Node *);
28*9a7741deSElliott Hughes extern	char	*strnode(Node *);
29*9a7741deSElliott Hughes extern	Node	*notnull(Node *);
30*9a7741deSElliott Hughes extern	int	yyparse(void);
31*9a7741deSElliott Hughes 
32*9a7741deSElliott Hughes extern	int	yylex(void);
33*9a7741deSElliott Hughes extern	void	startreg(void);
34*9a7741deSElliott Hughes extern	int	input(void);
35*9a7741deSElliott Hughes extern	void	unput(int);
36*9a7741deSElliott Hughes extern	void	unputstr(const char *);
37*9a7741deSElliott Hughes 
38*9a7741deSElliott Hughes extern	fa	*makedfa(const char *, bool);
39*9a7741deSElliott Hughes extern	fa	*mkdfa(const char *, bool);
40*9a7741deSElliott Hughes extern	int	makeinit(fa *, bool);
41*9a7741deSElliott Hughes extern	void	penter(Node *);
42*9a7741deSElliott Hughes extern	void	freetr(Node *);
43*9a7741deSElliott Hughes extern	int	quoted(const uschar **);
44*9a7741deSElliott Hughes extern	int	*cclenter(const char *);
45*9a7741deSElliott Hughes extern	noreturn void	overflo(const char *);
46*9a7741deSElliott Hughes extern	void	cfoll(fa *, Node *);
47*9a7741deSElliott Hughes extern	int	first(Node *);
48*9a7741deSElliott Hughes extern	void	follow(Node *);
49*9a7741deSElliott Hughes extern	int	member(int, int *);
50*9a7741deSElliott Hughes extern	int	match(fa *, const char *);
51*9a7741deSElliott Hughes extern	int	pmatch(fa *, const char *);
52*9a7741deSElliott Hughes extern	int	nematch(fa *, const char *);
53*9a7741deSElliott Hughes extern	bool	fnematch(fa *, FILE *, char **, int *, int);
54*9a7741deSElliott Hughes extern	Node	*reparse(const char *);
55*9a7741deSElliott Hughes extern	Node	*regexp(void);
56*9a7741deSElliott Hughes extern	Node	*primary(void);
57*9a7741deSElliott Hughes extern	Node	*concat(Node *);
58*9a7741deSElliott Hughes extern	Node	*alt(Node *);
59*9a7741deSElliott Hughes extern	Node	*unary(Node *);
60*9a7741deSElliott Hughes extern	int	relex(void);
61*9a7741deSElliott Hughes extern	int	cgoto(fa *, int, int);
62*9a7741deSElliott Hughes extern	void	freefa(fa *);
63*9a7741deSElliott Hughes 
64*9a7741deSElliott Hughes extern	int	pgetc(void);
65*9a7741deSElliott Hughes extern	char	*cursource(void);
66*9a7741deSElliott Hughes 
67*9a7741deSElliott Hughes extern	Node	*nodealloc(size_t);
68*9a7741deSElliott Hughes extern	Node	*exptostat(Node *);
69*9a7741deSElliott Hughes extern	Node	*node1(int, Node *);
70*9a7741deSElliott Hughes extern	Node	*node2(int, Node *, Node *);
71*9a7741deSElliott Hughes extern	Node	*node3(int, Node *, Node *, Node *);
72*9a7741deSElliott Hughes extern	Node	*node4(int, Node *, Node *, Node *, Node *);
73*9a7741deSElliott Hughes extern	Node	*stat3(int, Node *, Node *, Node *);
74*9a7741deSElliott Hughes extern	Node	*op2(int, Node *, Node *);
75*9a7741deSElliott Hughes extern	Node	*op1(int, Node *);
76*9a7741deSElliott Hughes extern	Node	*stat1(int, Node *);
77*9a7741deSElliott Hughes extern	Node	*op3(int, Node *, Node *, Node *);
78*9a7741deSElliott Hughes extern	Node	*op4(int, Node *, Node *, Node *, Node *);
79*9a7741deSElliott Hughes extern	Node	*stat2(int, Node *, Node *);
80*9a7741deSElliott Hughes extern	Node	*stat4(int, Node *, Node *, Node *, Node *);
81*9a7741deSElliott Hughes extern	Node	*celltonode(Cell *, int);
82*9a7741deSElliott Hughes extern	Node	*rectonode(void);
83*9a7741deSElliott Hughes extern	Node	*makearr(Node *);
84*9a7741deSElliott Hughes extern	Node	*pa2stat(Node *, Node *, Node *);
85*9a7741deSElliott Hughes extern	Node	*linkum(Node *, Node *);
86*9a7741deSElliott Hughes extern	void	defn(Cell *, Node *, Node *);
87*9a7741deSElliott Hughes extern	int	isarg(const char *);
88*9a7741deSElliott Hughes extern	const char *tokname(int);
89*9a7741deSElliott Hughes extern	Cell	*(*proctab[])(Node **, int);
90*9a7741deSElliott Hughes extern	int	ptoi(void *);
91*9a7741deSElliott Hughes extern	Node	*itonp(int);
92*9a7741deSElliott Hughes 
93*9a7741deSElliott Hughes extern	void	syminit(void);
94*9a7741deSElliott Hughes extern	void	arginit(int, char **);
95*9a7741deSElliott Hughes extern	void	envinit(char **);
96*9a7741deSElliott Hughes extern	Array	*makesymtab(int);
97*9a7741deSElliott Hughes extern	void	freesymtab(Cell *);
98*9a7741deSElliott Hughes extern	void	freeelem(Cell *, const char *);
99*9a7741deSElliott Hughes extern	Cell	*setsymtab(const char *, const char *, double, unsigned int, Array *);
100*9a7741deSElliott Hughes extern	int	hash(const char *, int);
101*9a7741deSElliott Hughes extern	void	rehash(Array *);
102*9a7741deSElliott Hughes extern	Cell	*lookup(const char *, Array *);
103*9a7741deSElliott Hughes extern	double	setfval(Cell *, double);
104*9a7741deSElliott Hughes extern	void	funnyvar(Cell *, const char *);
105*9a7741deSElliott Hughes extern	char	*setsval(Cell *, const char *);
106*9a7741deSElliott Hughes extern	double	getfval(Cell *);
107*9a7741deSElliott Hughes extern	char	*getsval(Cell *);
108*9a7741deSElliott Hughes extern	char	*getpssval(Cell *);     /* for print */
109*9a7741deSElliott Hughes extern	char	*tostring(const char *);
110*9a7741deSElliott Hughes extern	char	*tostringN(const char *, size_t);
111*9a7741deSElliott Hughes extern	char	*qstring(const char *, int);
112*9a7741deSElliott Hughes extern	Cell	*catstr(Cell *, Cell *);
113*9a7741deSElliott Hughes 
114*9a7741deSElliott Hughes extern	void	recinit(unsigned int);
115*9a7741deSElliott Hughes extern	void	initgetrec(void);
116*9a7741deSElliott Hughes extern	void	makefields(int, int);
117*9a7741deSElliott Hughes extern	void	growfldtab(int n);
118*9a7741deSElliott Hughes extern	void	savefs(void);
119*9a7741deSElliott Hughes extern	int	getrec(char **, int *, bool);
120*9a7741deSElliott Hughes extern	void	nextfile(void);
121*9a7741deSElliott Hughes extern	int	readrec(char **buf, int *bufsize, FILE *inf, bool isnew);
122*9a7741deSElliott Hughes extern	char	*getargv(int);
123*9a7741deSElliott Hughes extern	void	setclvar(char *);
124*9a7741deSElliott Hughes extern	void	fldbld(void);
125*9a7741deSElliott Hughes extern	void	cleanfld(int, int);
126*9a7741deSElliott Hughes extern	void	newfld(int);
127*9a7741deSElliott Hughes extern	void	setlastfld(int);
128*9a7741deSElliott Hughes extern	int	refldbld(const char *, const char *);
129*9a7741deSElliott Hughes extern	void	recbld(void);
130*9a7741deSElliott Hughes extern	Cell	*fieldadr(int);
131*9a7741deSElliott Hughes extern	void	yyerror(const char *);
132*9a7741deSElliott Hughes extern	void	bracecheck(void);
133*9a7741deSElliott Hughes extern	void	bcheck2(int, int, int);
134*9a7741deSElliott Hughes extern	void	SYNTAX(const char *, ...)
135*9a7741deSElliott Hughes     __attribute__((__format__(__printf__, 1, 2)));
136*9a7741deSElliott Hughes extern	noreturn void	FATAL(const char *, ...)
137*9a7741deSElliott Hughes     __attribute__((__format__(__printf__, 1, 2)));
138*9a7741deSElliott Hughes extern	void	WARNING(const char *, ...)
139*9a7741deSElliott Hughes     __attribute__((__format__(__printf__, 1, 2)));
140*9a7741deSElliott Hughes extern	void	error(void);
141*9a7741deSElliott Hughes extern	void	eprint(void);
142*9a7741deSElliott Hughes extern	void	bclass(int);
143*9a7741deSElliott Hughes extern	double	errcheck(double, const char *);
144*9a7741deSElliott Hughes extern	int	isclvar(const char *);
145*9a7741deSElliott Hughes extern	bool	is_valid_number(const char *s, bool trailing_stuff_ok,
146*9a7741deSElliott Hughes 				bool *no_trailing, double *result);
147*9a7741deSElliott Hughes #define is_number(s, val)	is_valid_number(s, false, NULL, val)
148*9a7741deSElliott Hughes 
149*9a7741deSElliott Hughes extern	int	adjbuf(char **pb, int *sz, int min, int q, char **pbp, const char *what);
150*9a7741deSElliott Hughes extern	void	run(Node *);
151*9a7741deSElliott Hughes extern	Cell	*execute(Node *);
152*9a7741deSElliott Hughes extern	Cell	*program(Node **, int);
153*9a7741deSElliott Hughes extern	Cell	*call(Node **, int);
154*9a7741deSElliott Hughes extern	Cell	*copycell(Cell *);
155*9a7741deSElliott Hughes extern	Cell	*arg(Node **, int);
156*9a7741deSElliott Hughes extern	Cell	*jump(Node **, int);
157*9a7741deSElliott Hughes extern	Cell	*awkgetline(Node **, int);
158*9a7741deSElliott Hughes extern	Cell	*getnf(Node **, int);
159*9a7741deSElliott Hughes extern	Cell	*array(Node **, int);
160*9a7741deSElliott Hughes extern	Cell	*awkdelete(Node **, int);
161*9a7741deSElliott Hughes extern	Cell	*intest(Node **, int);
162*9a7741deSElliott Hughes extern	Cell	*matchop(Node **, int);
163*9a7741deSElliott Hughes extern	Cell	*boolop(Node **, int);
164*9a7741deSElliott Hughes extern	Cell	*relop(Node **, int);
165*9a7741deSElliott Hughes extern	void	tfree(Cell *);
166*9a7741deSElliott Hughes extern	Cell	*gettemp(void);
167*9a7741deSElliott Hughes extern	Cell	*indirect(Node **, int);
168*9a7741deSElliott Hughes extern	Cell	*substr(Node **, int);
169*9a7741deSElliott Hughes extern	Cell	*sindex(Node **, int);
170*9a7741deSElliott Hughes extern	int	format(char **, int *, const char *, Node *);
171*9a7741deSElliott Hughes extern	Cell	*awksprintf(Node **, int);
172*9a7741deSElliott Hughes extern	Cell	*awkprintf(Node **, int);
173*9a7741deSElliott Hughes extern	Cell	*arith(Node **, int);
174*9a7741deSElliott Hughes extern	double	ipow(double, int);
175*9a7741deSElliott Hughes extern	Cell	*incrdecr(Node **, int);
176*9a7741deSElliott Hughes extern	Cell	*assign(Node **, int);
177*9a7741deSElliott Hughes extern	Cell	*cat(Node **, int);
178*9a7741deSElliott Hughes extern	Cell	*pastat(Node **, int);
179*9a7741deSElliott Hughes extern	Cell	*dopa2(Node **, int);
180*9a7741deSElliott Hughes extern	Cell	*split(Node **, int);
181*9a7741deSElliott Hughes extern	Cell	*condexpr(Node **, int);
182*9a7741deSElliott Hughes extern	Cell	*ifstat(Node **, int);
183*9a7741deSElliott Hughes extern	Cell	*whilestat(Node **, int);
184*9a7741deSElliott Hughes extern	Cell	*dostat(Node **, int);
185*9a7741deSElliott Hughes extern	Cell	*forstat(Node **, int);
186*9a7741deSElliott Hughes extern	Cell	*instat(Node **, int);
187*9a7741deSElliott Hughes extern	Cell	*bltin(Node **, int);
188*9a7741deSElliott Hughes extern	Cell	*printstat(Node **, int);
189*9a7741deSElliott Hughes extern	Cell	*nullproc(Node **, int);
190*9a7741deSElliott Hughes extern	FILE	*redirect(int, Node *);
191*9a7741deSElliott Hughes extern	FILE	*openfile(int, const char *, bool *);
192*9a7741deSElliott Hughes extern	const char	*filename(FILE *);
193*9a7741deSElliott Hughes extern	Cell	*closefile(Node **, int);
194*9a7741deSElliott Hughes extern	void	closeall(void);
195*9a7741deSElliott Hughes extern	Cell	*dosub(Node **, int);
196*9a7741deSElliott Hughes 
197*9a7741deSElliott Hughes extern	FILE	*popen(const char *, const char *);
198*9a7741deSElliott Hughes extern	int	pclose(FILE *);
199*9a7741deSElliott Hughes 
200*9a7741deSElliott Hughes extern  const char	*flags2str(int flags);
201