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