xref: /freebsd/contrib/one-true-awk/proto.h (revision cb14a3fe5122c879eae1fb480ed7ce82a699ddb6)
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 extern	int	yylook(void);
38 extern	int	yyback(int *, int);
39 extern	int	yyinput(void);
40 
41 extern	fa	*makedfa(const char *, bool);
42 extern	fa	*mkdfa(const char *, bool);
43 extern	int	makeinit(fa *, bool);
44 extern	void	penter(Node *);
45 extern	void	freetr(Node *);
46 extern	int	quoted(const uschar **);
47 extern	int	*cclenter(const char *);
48 extern	noreturn void	overflo(const char *);
49 extern	void	cfoll(fa *, Node *);
50 extern	int	first(Node *);
51 extern	void	follow(Node *);
52 extern	int	member(int, int *);
53 extern	int	match(fa *, const char *);
54 extern	int	pmatch(fa *, const char *);
55 extern	int	nematch(fa *, const char *);
56 extern	bool	fnematch(fa *, FILE *, char **, int *, int);
57 extern	Node	*reparse(const char *);
58 extern	Node	*regexp(void);
59 extern	Node	*primary(void);
60 extern	Node	*concat(Node *);
61 extern	Node	*alt(Node *);
62 extern	Node	*unary(Node *);
63 extern	int	relex(void);
64 extern	int	cgoto(fa *, int, int);
65 extern	void	freefa(fa *);
66 
67 extern	int	pgetc(void);
68 extern	char	*cursource(void);
69 
70 extern	Node	*nodealloc(size_t);
71 extern	Node	*exptostat(Node *);
72 extern	Node	*node1(int, Node *);
73 extern	Node	*node2(int, Node *, Node *);
74 extern	Node	*node3(int, Node *, Node *, Node *);
75 extern	Node	*node4(int, Node *, Node *, Node *, Node *);
76 extern	Node	*node5(int, Node *, Node *, Node *, Node *, Node *);
77 extern	Node	*stat3(int, Node *, Node *, Node *);
78 extern	Node	*op2(int, Node *, Node *);
79 extern	Node	*op1(int, Node *);
80 extern	Node	*stat1(int, Node *);
81 extern	Node	*op3(int, Node *, Node *, Node *);
82 extern	Node	*op4(int, Node *, Node *, Node *, Node *);
83 extern	Node	*op5(int, Node *, Node *, Node *, Node *, Node *);
84 extern	Node	*stat2(int, Node *, Node *);
85 extern	Node	*stat4(int, Node *, Node *, Node *, Node *);
86 extern	Node	*celltonode(Cell *, int);
87 extern	Node	*rectonode(void);
88 extern	Node	*makearr(Node *);
89 extern	Node	*pa2stat(Node *, Node *, Node *);
90 extern	Node	*linkum(Node *, Node *);
91 extern	void	defn(Cell *, Node *, Node *);
92 extern	int	isarg(const char *);
93 extern	const char *tokname(int);
94 extern	Cell	*(*proctab[])(Node **, int);
95 extern	int	ptoi(void *);
96 extern	Node	*itonp(int);
97 
98 extern	void	syminit(void);
99 extern	void	arginit(int, char **);
100 extern	void	envinit(char **);
101 extern	Array	*makesymtab(int);
102 extern	void	freesymtab(Cell *);
103 extern	void	freeelem(Cell *, const char *);
104 extern	Cell	*setsymtab(const char *, const char *, double, unsigned int, Array *);
105 extern	int	hash(const char *, int);
106 extern	void	rehash(Array *);
107 extern	Cell	*lookup(const char *, Array *);
108 extern	double	setfval(Cell *, double);
109 extern	void	funnyvar(Cell *, const char *);
110 extern	char	*setsval(Cell *, const char *);
111 extern	double	getfval(Cell *);
112 extern	char	*getsval(Cell *);
113 extern	char	*getpssval(Cell *);     /* for print */
114 extern	char	*tostring(const char *);
115 extern	char	*tostringN(const char *, size_t);
116 extern	char	*qstring(const char *, int);
117 extern	Cell	*catstr(Cell *, Cell *);
118 
119 extern	void	recinit(unsigned int);
120 extern	void	initgetrec(void);
121 extern	void	makefields(int, int);
122 extern	void	growfldtab(int n);
123 extern	void	savefs(void);
124 extern	int	getrec(char **, int *, bool);
125 extern	void	nextfile(void);
126 extern	int	readrec(char **buf, int *bufsize, FILE *inf, bool isnew);
127 extern	char	*getargv(int);
128 extern	void	setclvar(char *);
129 extern	void	fldbld(void);
130 extern	void	cleanfld(int, int);
131 extern	void	newfld(int);
132 extern	void	setlastfld(int);
133 extern	int	refldbld(const char *, const char *);
134 extern	void	recbld(void);
135 extern	Cell	*fieldadr(int);
136 extern	void	yyerror(const char *);
137 extern	void	bracecheck(void);
138 extern	void	bcheck2(int, int, int);
139 extern	void	SYNTAX(const char *, ...)
140     __attribute__((__format__(__printf__, 1, 2)));
141 extern	noreturn void	FATAL(const char *, ...)
142     __attribute__((__format__(__printf__, 1, 2)));
143 extern	void	WARNING(const char *, ...)
144     __attribute__((__format__(__printf__, 1, 2)));
145 extern	void	error(void);
146 extern	void	eprint(void);
147 extern	void	bclass(int);
148 extern	double	errcheck(double, const char *);
149 extern	int	isclvar(const char *);
150 extern	bool	is_valid_number(const char *s, bool trailing_stuff_ok,
151 				bool *no_trailing, double *result);
152 #define is_number(s, val)	is_valid_number(s, false, NULL, val)
153 
154 extern	int	adjbuf(char **pb, int *sz, int min, int q, char **pbp, const char *what);
155 extern	void	run(Node *);
156 extern	Cell	*execute(Node *);
157 extern	Cell	*program(Node **, int);
158 extern	Cell	*call(Node **, int);
159 extern	Cell	*copycell(Cell *);
160 extern	Cell	*arg(Node **, int);
161 extern	Cell	*jump(Node **, int);
162 extern	Cell	*awkgetline(Node **, int);
163 extern	Cell	*getnf(Node **, int);
164 extern	Cell	*array(Node **, int);
165 extern	Cell	*awkdelete(Node **, int);
166 extern	Cell	*intest(Node **, int);
167 extern	Cell	*matchop(Node **, int);
168 extern	Cell	*boolop(Node **, int);
169 extern	Cell	*relop(Node **, int);
170 extern	void	tfree(Cell *);
171 extern	Cell	*gettemp(void);
172 extern	Cell	*field(Node **, int);
173 extern	Cell	*indirect(Node **, int);
174 extern	Cell	*substr(Node **, int);
175 extern	Cell	*sindex(Node **, int);
176 extern	int	format(char **, int *, const char *, Node *);
177 extern	Cell	*awksprintf(Node **, int);
178 extern	Cell	*awkprintf(Node **, int);
179 extern	Cell	*arith(Node **, int);
180 extern	double	ipow(double, int);
181 extern	Cell	*incrdecr(Node **, int);
182 extern	Cell	*assign(Node **, int);
183 extern	Cell	*cat(Node **, int);
184 extern	Cell	*pastat(Node **, int);
185 extern	Cell	*dopa2(Node **, int);
186 extern	Cell	*split(Node **, int);
187 extern	Cell	*condexpr(Node **, int);
188 extern	Cell	*ifstat(Node **, int);
189 extern	Cell	*whilestat(Node **, int);
190 extern	Cell	*dostat(Node **, int);
191 extern	Cell	*forstat(Node **, int);
192 extern	Cell	*instat(Node **, int);
193 extern	Cell	*bltin(Node **, int);
194 extern	Cell	*printstat(Node **, int);
195 extern	Cell	*nullproc(Node **, int);
196 extern	FILE	*redirect(int, Node *);
197 extern	FILE	*openfile(int, const char *, bool *);
198 extern	const char	*filename(FILE *);
199 extern	Cell	*closefile(Node **, int);
200 extern	void	closeall(void);
201 extern	Cell	*dosub(Node **, int);
202 extern	Cell	*gensub(Node **, int);
203 
204 extern	FILE	*popen(const char *, const char *);
205 extern	int	pclose(FILE *);
206 
207 extern  const char	*flags2str(int flags);
208