Commit | Line | Data |
---|---|---|
378cc40b | 1 | /* $Header: perl.h,v 2.0 88/06/05 00:09:21 root Exp $ |
8d063cd8 LW |
2 | * |
3 | * $Log: perl.h,v $ | |
378cc40b LW |
4 | * Revision 2.0 88/06/05 00:09:21 root |
5 | * Baseline version 2.0. | |
8d063cd8 LW |
6 | * |
7 | */ | |
8 | ||
378cc40b | 9 | #ifndef lint |
8d063cd8 | 10 | #define DEBUGGING |
378cc40b | 11 | #endif |
8d063cd8 LW |
12 | |
13 | #define VOIDUSED 1 | |
14 | #include "config.h" | |
15 | ||
378cc40b LW |
16 | #ifdef MEMCPY |
17 | extern char *memcpy(), *memset(); | |
18 | #define bcopy(s1,s2,l) memcpy(s2,s1,l); | |
19 | #define bzero(s,l) memset(s,0,l); | |
8d063cd8 LW |
20 | #endif |
21 | ||
22 | #include <stdio.h> | |
23 | #include <ctype.h> | |
24 | #include <setjmp.h> | |
378cc40b LW |
25 | #include <sys/param.h> /* if this needs types.h we're still wrong */ |
26 | ||
27 | #ifndef _TYPES_ /* If types.h defines this it's easy. */ | |
28 | #ifndef major /* Does everyone's types.h define this? */ | |
8d063cd8 | 29 | #include <sys/types.h> |
378cc40b LW |
30 | #endif |
31 | #endif | |
32 | ||
8d063cd8 | 33 | #include <sys/stat.h> |
135863df AB |
34 | |
35 | #ifdef TMINSYS | |
36 | #include <sys/time.h> | |
37 | #else | |
8d063cd8 | 38 | #include <time.h> |
135863df AB |
39 | #endif |
40 | ||
8d063cd8 LW |
41 | #include <sys/times.h> |
42 | ||
43 | typedef struct arg ARG; | |
44 | typedef struct cmd CMD; | |
45 | typedef struct formcmd FCMD; | |
46 | typedef struct scanpat SPAT; | |
47 | typedef struct stab STAB; | |
48 | typedef struct stio STIO; | |
378cc40b | 49 | typedef struct sub SUBR; |
8d063cd8 LW |
50 | typedef struct string STR; |
51 | typedef struct atbl ARRAY; | |
52 | typedef struct htbl HASH; | |
378cc40b | 53 | typedef struct regexp REGEXP; |
8d063cd8 | 54 | |
378cc40b LW |
55 | #include "handy.h" |
56 | #include "regexp.h" | |
8d063cd8 | 57 | #include "str.h" |
378cc40b | 58 | #include "util.h" |
8d063cd8 LW |
59 | #include "form.h" |
60 | #include "stab.h" | |
61 | #include "spat.h" | |
62 | #include "arg.h" | |
63 | #include "cmd.h" | |
64 | #include "array.h" | |
65 | #include "hash.h" | |
66 | ||
135863df AB |
67 | #ifdef CHARSPRINTF |
68 | char *sprintf(); | |
69 | #else | |
70 | int sprintf(); | |
71 | #endif | |
72 | ||
8d063cd8 LW |
73 | /* A string is TRUE if not "" or "0". */ |
74 | #define True(val) (tmps = (val), (*tmps && !(*tmps == '0' && !tmps[1]))) | |
75 | EXT char *Yes INIT("1"); | |
76 | EXT char *No INIT(""); | |
77 | ||
78 | #define str_true(str) (Str = (str), (Str->str_pok ? True(Str->str_ptr) : (Str->str_nok ? (Str->str_nval != 0.0) : 0 ))) | |
79 | ||
135863df | 80 | #ifdef DEBUGGING |
378cc40b | 81 | #define str_peek(str) (Str = (str), (Str->str_pok ? Str->str_ptr : (Str->str_nok ? (sprintf(buf,"num(%g)",Str->str_nval),(char*)buf) : "" ))) |
135863df AB |
82 | #endif |
83 | ||
8d063cd8 LW |
84 | #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str))) |
85 | #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_nval : str_2num(Str))) | |
86 | EXT STR *Str; | |
87 | ||
88 | #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len) | |
89 | ||
90 | CMD *add_label(); | |
91 | CMD *block_head(); | |
92 | CMD *append_line(); | |
93 | CMD *make_acmd(); | |
94 | CMD *make_ccmd(); | |
95 | CMD *invert(); | |
96 | CMD *addcond(); | |
97 | CMD *addloop(); | |
98 | CMD *wopt(); | |
378cc40b | 99 | CMD *over(); |
8d063cd8 | 100 | |
378cc40b | 101 | SPAT *stab2spat(); |
8d063cd8 LW |
102 | |
103 | STAB *stabent(); | |
378cc40b | 104 | STAB *genstab(); |
8d063cd8 | 105 | |
378cc40b | 106 | ARG *stab2arg(); |
8d063cd8 LW |
107 | ARG *op_new(); |
108 | ARG *make_op(); | |
109 | ARG *make_lval(); | |
110 | ARG *make_match(); | |
111 | ARG *make_split(); | |
112 | ARG *flipflip(); | |
378cc40b LW |
113 | ARG *listish(); |
114 | ARG *localize(); | |
115 | ARG *l(); | |
116 | ARG *mod_match(); | |
117 | ARG *make_list(); | |
118 | ARG *cmd_to_arg(); | |
119 | ARG *addflags(); | |
120 | ARG *hide_ary(); | |
121 | ARG *cval_to_arg(); | |
8d063cd8 LW |
122 | |
123 | STR *arg_to_str(); | |
124 | STR *str_new(); | |
125 | STR *stab_str(); | |
a559c259 LW |
126 | STR *eval(); /* this evaluates expressions */ |
127 | STR *do_eval(); /* this evaluates eval operator */ | |
378cc40b LW |
128 | STR *do_each(); |
129 | STR *do_subr(); | |
130 | STR *do_match(); | |
131 | ||
132 | SUBR *make_sub(); | |
8d063cd8 LW |
133 | |
134 | FCMD *load_format(); | |
135 | ||
136 | char *scanpat(); | |
137 | char *scansubst(); | |
138 | char *scantrans(); | |
139 | char *scanstr(); | |
140 | char *scanreg(); | |
141 | char *reg_get(); | |
142 | char *str_append_till(); | |
143 | char *str_gets(); | |
144 | ||
8d063cd8 LW |
145 | bool do_open(); |
146 | bool do_close(); | |
147 | bool do_print(); | |
378cc40b LW |
148 | bool do_aprint(); |
149 | bool do_exec(); | |
150 | bool do_aexec(); | |
8d063cd8 LW |
151 | |
152 | int do_subst(); | |
378cc40b LW |
153 | int cando(); |
154 | int ingroup(); | |
8d063cd8 | 155 | |
378cc40b LW |
156 | void str_grow(); |
157 | void str_replace(); | |
158 | void str_inc(); | |
159 | void str_dec(); | |
8d063cd8 LW |
160 | void str_free(); |
161 | void freearg(); | |
378cc40b LW |
162 | void savelist(); |
163 | void restorelist(); | |
164 | void ajoin(); | |
165 | void do_join(); | |
166 | void do_assign(); | |
167 | void do_sprintf(); | |
168 | ||
169 | EXT line_t line INIT(0); | |
8d063cd8 LW |
170 | EXT int arybase INIT(0); |
171 | ||
172 | struct outrec { | |
378cc40b LW |
173 | line_t o_lines; |
174 | char *o_str; | |
175 | int o_len; | |
8d063cd8 LW |
176 | }; |
177 | ||
178 | EXT struct outrec outrec; | |
179 | EXT struct outrec toprec; | |
180 | ||
181 | EXT STAB *last_in_stab INIT(Nullstab); | |
182 | EXT STAB *defstab INIT(Nullstab); | |
183 | EXT STAB *argvstab INIT(Nullstab); | |
184 | EXT STAB *envstab INIT(Nullstab); | |
185 | EXT STAB *sigstab INIT(Nullstab); | |
186 | EXT STAB *defoutstab INIT(Nullstab); | |
187 | EXT STAB *curoutstab INIT(Nullstab); | |
188 | EXT STAB *argvoutstab INIT(Nullstab); | |
378cc40b | 189 | EXT STAB *incstab INIT(Nullstab); |
8d063cd8 LW |
190 | |
191 | EXT STR *freestrroot INIT(Nullstr); | |
378cc40b | 192 | EXT STR *lastretstr INIT(Nullstr); |
8d063cd8 | 193 | |
378cc40b LW |
194 | EXT char *filename; |
195 | EXT char *origfilename; | |
8d063cd8 LW |
196 | EXT FILE *rsfp; |
197 | EXT char buf[1024]; | |
198 | EXT char *bufptr INIT(buf); | |
199 | ||
200 | EXT STR *linestr INIT(Nullstr); | |
201 | ||
202 | EXT char record_separator INIT('\n'); | |
203 | EXT char *ofs INIT(Nullch); | |
204 | EXT char *ors INIT(Nullch); | |
205 | EXT char *ofmt INIT(Nullch); | |
206 | EXT char *inplace INIT(Nullch); | |
207 | ||
378cc40b LW |
208 | EXT bool preprocess INIT(FALSE); |
209 | EXT bool minus_n INIT(FALSE); | |
210 | EXT bool minus_p INIT(FALSE); | |
211 | EXT bool minus_a INIT(FALSE); | |
212 | EXT bool doswitches INIT(FALSE); | |
213 | EXT bool dowarn INIT(FALSE); | |
214 | EXT bool allstabs INIT(FALSE); /* init all customary symbols in symbol table?*/ | |
215 | EXT bool sawampersand INIT(FALSE); /* must save all match strings */ | |
216 | EXT bool sawstudy INIT(FALSE); /* do fbminstr on all strings */ | |
217 | ||
218 | #define TMPPATH "/tmp/perl-eXXXXXX" | |
219 | EXT char *e_tmpname; | |
220 | EXT FILE *e_fp INIT(Nullfp); | |
221 | ||
8d063cd8 LW |
222 | EXT char tokenbuf[256]; |
223 | EXT int expectterm INIT(TRUE); | |
224 | EXT int lex_newlines INIT(FALSE); | |
a559c259 | 225 | EXT int in_eval INIT(FALSE); |
378cc40b LW |
226 | EXT int multiline INIT(0); |
227 | EXT int forkprocess; | |
8d063cd8 LW |
228 | |
229 | FILE *popen(); | |
230 | /* char *str_get(); */ | |
231 | STR *interp(); | |
232 | void free_arg(); | |
233 | STIO *stio_new(); | |
234 | ||
235 | EXT struct stat statbuf; | |
236 | EXT struct tms timesbuf; | |
378cc40b LW |
237 | EXT int uid; |
238 | EXT int euid; | |
239 | UIDTYPE getuid(); | |
240 | UIDTYPE geteuid(); | |
241 | GIDTYPE getgid(); | |
242 | GIDTYPE getegid(); | |
243 | EXT int unsafe; | |
8d063cd8 LW |
244 | |
245 | #ifdef DEBUGGING | |
246 | EXT int debug INIT(0); | |
247 | EXT int dlevel INIT(0); | |
378cc40b LW |
248 | EXT char debname[128]; |
249 | EXT char debdelim[128]; | |
d96024cf | 250 | #define YYDEBUG 1 |
8d063cd8 LW |
251 | extern int yydebug; |
252 | #endif | |
253 | ||
378cc40b LW |
254 | EXT line_t cmdline INIT(NOLINE); |
255 | ||
8d063cd8 LW |
256 | EXT STR str_no; |
257 | EXT STR str_yes; | |
258 | ||
259 | /* runtime control stuff */ | |
260 | ||
261 | EXT struct loop { | |
262 | char *loop_label; | |
263 | jmp_buf loop_env; | |
378cc40b | 264 | } loop_stack[64]; |
8d063cd8 LW |
265 | |
266 | EXT int loop_ptr INIT(-1); | |
267 | ||
268 | EXT jmp_buf top_env; | |
a559c259 | 269 | EXT jmp_buf eval_env; |
8d063cd8 LW |
270 | |
271 | EXT char *goto_targ INIT(Nullch); /* cmd_exec gets strange when set */ | |
272 | ||
378cc40b LW |
273 | EXT ARRAY *savestack; /* to save non-local values on */ |
274 | ||
275 | EXT ARRAY *tosave; /* strings to save on recursive subroutine */ | |
276 | ||
8d063cd8 | 277 | double atof(); |
378cc40b LW |
278 | unsigned sleep(); |
279 | long time(), times(); | |
8d063cd8 | 280 | struct tm *gmtime(), *localtime(); |
378cc40b LW |
281 | char *mktemp(); |
282 | char *index(), *rindex(); | |
283 | char *strcpy(), *strcat(); | |
8d063cd8 | 284 | |
8d063cd8 | 285 | #ifdef EUNICE |
378cc40b LW |
286 | #define UNLINK unlnk |
287 | int unlnk(); | |
8d063cd8 LW |
288 | #else |
289 | #define UNLINK unlink | |
290 | #endif |