• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /* To avoid conflicts with <stdio.h> getline declaration on Linux */
26 #define getline awk_getline
27 
28 #include <stdint.h>
29 
30 extern	int	yywrap(void);
31 extern	void	setfname(Cell *);
32 extern	int	constnode(Node *);
33 extern	char	*strnode(Node *);
34 extern	Node	*notnull(Node *);
35 extern	int	yyparse(void);
36 
37 extern	int	yylex(void);
38 extern	void	startreg(void);
39 extern	int	input(void);
40 extern	void	unput(int);
41 extern	void	unputstr(const char *);
42 extern	int	yylook(void);
43 extern	int	yyback(int *, int);
44 extern	int	yyinput(void);
45 
46 extern	fa	*makedfa(const char *, int);
47 extern	fa	*mkdfa(const char *, int);
48 extern	int	makeinit(fa *, int);
49 extern	void	penter(Node *);
50 extern	void	freetr(Node *);
51 extern	int	hexstr(char **);
52 extern	int	quoted(char **);
53 extern	char	*cclenter(const char *);
54 extern	void	overflo(const char *);
55 extern	void	cfoll(fa *, Node *);
56 extern	int	first(Node *);
57 extern	void	follow(Node *);
58 extern	int	member(int, const char *);
59 extern	int	match(fa *, const char *);
60 extern	int	pmatch(fa *, const char *);
61 extern	int	nematch(fa *, const char *);
62 extern	Node	*reparse(const char *);
63 extern	Node	*regexp(void);
64 extern	Node	*primary(void);
65 extern	Node	*concat(Node *);
66 extern	Node	*alt(Node *);
67 extern	Node	*unary(Node *);
68 extern	int	relex(void);
69 extern	int	cgoto(fa *, int, int);
70 extern	void	freefa(fa *);
71 
72 extern	int	pgetc(void);
73 extern	char	*cursource(void);
74 
75 extern	Node	*nodealloc(int);
76 extern	Node	*exptostat(Node *);
77 extern	Node	*node1(int, Node *);
78 extern	Node	*node2(int, Node *, Node *);
79 extern	Node	*node3(int, Node *, Node *, Node *);
80 extern	Node	*node4(int, Node *, Node *, Node *, Node *);
81 extern	Node	*stat3(int, Node *, Node *, Node *);
82 extern	Node	*op2(int, Node *, Node *);
83 extern	Node	*op1(int, Node *);
84 extern	Node	*stat1(int, Node *);
85 extern	Node	*op3(int, Node *, Node *, Node *);
86 extern	Node	*op4(int, Node *, Node *, Node *, Node *);
87 extern	Node	*stat2(int, Node *, Node *);
88 extern	Node	*stat4(int, Node *, Node *, Node *, Node *);
89 extern	Node	*celltonode(Cell *, int);
90 extern	Node	*rectonode(void);
91 extern	Node	*makearr(Node *);
92 extern	Node	*pa2stat(Node *, Node *, Node *);
93 extern	Node	*linkum(Node *, Node *);
94 extern	void	defn(Cell *, Node *, Node *);
95 extern	int	isarg(const char *);
96 extern	char	*tokname(int);
97 extern	Cell	*(*proctab[])(Node **, int);
98 extern	intptr_t ptoi(void *);
99 extern	Node	*itonp(intptr_t);
100 
101 extern	void	syminit(void);
102 extern	void	arginit(int, char **);
103 extern	void	envinit(char **);
104 extern	Array	*makesymtab(int);
105 extern	void	freesymtab(Cell *);
106 extern	void	freeelem(Cell *, const char *);
107 extern	Cell	*setsymtab(const char *, const char *, double, unsigned int, Array *);
108 extern	int	hash(const char *, int);
109 extern	void	rehash(Array *);
110 extern	Cell	*lookup(const char *, Array *);
111 extern	double	setfval(Cell *, double);
112 extern	void	funnyvar(Cell *, const char *);
113 extern	char	*setsval(Cell *, const char *);
114 extern	double	getfval(Cell *);
115 extern	char	*getsval(Cell *);
116 extern	char	*getpssval(Cell *);     /* for print */
117 extern	char	*tostring(const char *);
118 extern	char	*qstring(const char *, int);
119 
120 extern	void	recinit(unsigned int);
121 extern	void	initgetrec(void);
122 extern	void	makefields(int, int);
123 extern	void	growfldtab(int n);
124 extern	int	getrec(char **, int *, int);
125 extern	void	nextfile(void);
126 extern	int	readrec(char **buf, int *bufsize, FILE *inf);
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	int	refldbld(const char *, const char *);
133 extern	void	recbld(void);
134 extern	Cell	*fieldadr(int);
135 extern	void	yyerror(const char *);
136 extern	void	fpecatch(int);
137 extern	void	bracecheck(void);
138 extern	void	bcheck2(int, int, int);
139 extern	void	SYNTAX(const char *, ...);
140 extern	void	FATAL(const char *, ...);
141 extern	void	WARNING(const char *, ...);
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	int	is_number(const char *);
148 
149 extern	int	adjbuf(char **pb, int *sz, int min, int q, char **pbp, const char *what);
150 extern	void	run(Node *);
151 extern	Cell	*execute(Node *);
152 extern	Cell	*program(Node **, int);
153 extern	Cell	*call(Node **, int);
154 extern	Cell	*copycell(Cell *);
155 extern	Cell	*arg(Node **, int);
156 extern	Cell	*jump(Node **, int);
157 extern	Cell	*getline(Node **, int);
158 extern	Cell	*getnf(Node **, int);
159 extern	Cell	*array(Node **, int);
160 extern	Cell	*awkdelete(Node **, int);
161 extern	Cell	*intest(Node **, int);
162 extern	Cell	*matchop(Node **, int);
163 extern	Cell	*boolop(Node **, int);
164 extern	Cell	*relop(Node **, int);
165 extern	void	tfree(Cell *);
166 extern	Cell	*gettemp(void);
167 extern	Cell	*field(Node **, int);
168 extern	Cell	*indirect(Node **, int);
169 extern	Cell	*substr(Node **, int);
170 extern	Cell	*sindex(Node **, int);
171 extern	int	format(char **, int *, const char *, Node *);
172 extern	Cell	*awksprintf(Node **, int);
173 extern	Cell	*awkprintf(Node **, int);
174 extern	Cell	*arith(Node **, int);
175 extern	double	ipow(double, int);
176 extern	Cell	*incrdecr(Node **, int);
177 extern	Cell	*assign(Node **, int);
178 extern	Cell	*cat(Node **, int);
179 extern	Cell	*pastat(Node **, int);
180 extern	Cell	*dopa2(Node **, int);
181 extern	Cell	*split(Node **, int);
182 extern	Cell	*condexpr(Node **, int);
183 extern	Cell	*ifstat(Node **, int);
184 extern	Cell	*whilestat(Node **, int);
185 extern	Cell	*dostat(Node **, int);
186 extern	Cell	*forstat(Node **, int);
187 extern	Cell	*instat(Node **, int);
188 extern	Cell	*bltin(Node **, int);
189 extern	Cell	*printstat(Node **, int);
190 extern	Cell	*nullproc(Node **, int);
191 extern	FILE	*redirect(int, Node *);
192 extern	FILE	*openfile(int, const char *);
193 extern	const char	*filename(FILE *);
194 extern	Cell	*closefile(Node **, int);
195 extern	void	closeall(void);
196 extern	Cell	*sub(Node **, int);
197 extern	Cell	*gsub(Node **, int);
198 
199 #if !defined(_WIN32)
200 /* In mingw, the following are defined with dllimport attributes.
201   Redefining here will only get warning reads:
202 
203   ... redeclared without dllimport attribute: previous dllimport ignored
204  */
205 extern	FILE	*popen(const char *, const char *);
206 extern	int	pclose(FILE *);
207 #endif