Commit | Line | Data |
35c8bce7 |
1 | /* $RCSfile: perl.h,v $$Revision: 4.0.1.1 $$Date: 91/04/11 17:49:51 $ |
a687059c |
2 | * |
3 | * Copyright (c) 1989, Larry Wall |
4 | * |
5 | * You may distribute under the terms of the GNU General Public License |
6 | * as specified in the README file that comes with the perl 3.0 kit. |
8d063cd8 |
7 | * |
8 | * $Log: perl.h,v $ |
35c8bce7 |
9 | * Revision 4.0.1.1 91/04/11 17:49:51 lwall |
10 | * patch1: hopefully straightened out some of the Xenix mess |
11 | * |
fe14fcc3 |
12 | * Revision 4.0 91/03/20 01:37:56 lwall |
13 | * 4.0 baseline. |
8d063cd8 |
14 | * |
15 | */ |
16 | |
35c8bce7 |
17 | #define VOIDWANT 1 |
ac58e20f |
18 | #include "config.h" |
19 | |
0f85fab0 |
20 | #ifdef MSDOS |
fe14fcc3 |
21 | /* This stuff now in the MS-DOS config.h file. */ |
0f85fab0 |
22 | #else /* !MSDOS */ |
23 | |
24 | /* |
25 | * The following symbols are defined if your operating system supports |
26 | * functions by that name. All Unixes I know of support them, thus they |
27 | * are not checked by the configuration script, but are directly defined |
28 | * here. |
29 | */ |
fe14fcc3 |
30 | #define HAS_ALARM |
31 | #define HAS_CHOWN |
32 | #define HAS_CHROOT |
33 | #define HAS_FORK |
34 | #define HAS_GETLOGIN |
35 | #define HAS_GETPPID |
36 | #define HAS_KILL |
37 | #define HAS_LINK |
38 | #define HAS_PIPE |
39 | #define HAS_WAIT |
40 | #define HAS_UMASK |
0f85fab0 |
41 | /* |
42 | * The following symbols are defined if your operating system supports |
43 | * password and group functions in general. All Unix systems do. |
44 | */ |
fe14fcc3 |
45 | #define HAS_GROUP |
46 | #define HAS_PASSWD |
0f85fab0 |
47 | |
48 | #endif /* !MSDOS */ |
49 | |
ac58e20f |
50 | #if defined(HASVOLATILE) || defined(__STDC__) |
663a0e37 |
51 | #define VOLATILE volatile |
663a0e37 |
52 | #else |
53 | #define VOLATILE |
663a0e37 |
54 | #endif |
55 | |
a687059c |
56 | #ifdef IAMSUID |
57 | # ifndef TAINT |
58 | # define TAINT |
59 | # endif |
60 | #endif |
61 | |
fe14fcc3 |
62 | #ifndef HAS_VFORK |
03a14243 |
63 | # define vfork fork |
64 | #endif |
65 | |
fe14fcc3 |
66 | #ifdef HAS_GETPGRP2 |
67 | # ifndef HAS_GETPGRP |
68 | # define HAS_GETPGRP |
663a0e37 |
69 | # endif |
70 | # define getpgrp getpgrp2 |
71 | #endif |
72 | |
fe14fcc3 |
73 | #ifdef HAS_SETPGRP2 |
74 | # ifndef HAS_SETPGRP |
75 | # define HAS_SETPGRP |
663a0e37 |
76 | # endif |
77 | # define setpgrp setpgrp2 |
78 | #endif |
79 | |
fe14fcc3 |
80 | #include <stdio.h> |
81 | #include <ctype.h> |
82 | #include <setjmp.h> |
83 | #ifndef MSDOS |
84 | #include <sys/param.h> /* if this needs types.h we're still wrong */ |
03a14243 |
85 | #endif |
fe14fcc3 |
86 | #ifdef __STDC__ |
87 | /* Use all the "standard" definitions */ |
88 | #include <stdlib.h> |
89 | #include <string.h> |
90 | #endif /* __STDC__ */ |
03a14243 |
91 | |
fe14fcc3 |
92 | #if defined(HAS_MEMCMP) && defined(mips) && BYTEORDER == 0x1234 |
93 | #undef HAS_MEMCMP |
663a0e37 |
94 | #endif |
fe14fcc3 |
95 | |
96 | #ifdef HAS_MEMCPY |
97 | |
98 | # ifndef __STDC__ |
99 | # ifndef memcpy |
100 | extern char * memcpy(), *memset(); |
450a55e4 |
101 | extern int memcmp(); |
fe14fcc3 |
102 | # endif /* ndef memcpy */ |
103 | # endif /* ndef __STDC__ */ |
104 | |
a687059c |
105 | #define bcopy(s1,s2,l) memcpy(s2,s1,l) |
106 | #define bzero(s,l) memset(s,0,l) |
fe14fcc3 |
107 | #endif /* HAS_MEMCPY */ |
8d063cd8 |
108 | |
fe14fcc3 |
109 | #ifndef HAS_BCMP /* prefer bcmp slightly 'cuz it doesn't order */ |
110 | #define bcmp(s1,s2,l) memcmp(s1,s2,l) |
d9d8d8de |
111 | #endif |
378cc40b |
112 | |
113 | #ifndef _TYPES_ /* If types.h defines this it's easy. */ |
114 | #ifndef major /* Does everyone's types.h define this? */ |
8d063cd8 |
115 | #include <sys/types.h> |
378cc40b |
116 | #endif |
117 | #endif |
118 | |
ae986130 |
119 | #ifdef I_NETINET_IN |
120 | #include <netinet/in.h> |
121 | #endif |
122 | |
8d063cd8 |
123 | #include <sys/stat.h> |
135863df |
124 | |
663a0e37 |
125 | #ifdef I_TIME |
126 | # include <time.h> |
ffed7fef |
127 | #endif |
663a0e37 |
128 | |
fe14fcc3 |
129 | #ifdef I_SYS_TIME |
663a0e37 |
130 | # ifdef SYSTIMEKERNEL |
131 | # define KERNEL |
132 | # endif |
133 | # include <sys/time.h> |
134 | # ifdef SYSTIMEKERNEL |
135 | # undef KERNEL |
136 | # endif |
a687059c |
137 | #endif |
135863df |
138 | |
d9d8d8de |
139 | #ifndef MSDOS |
8d063cd8 |
140 | #include <sys/times.h> |
d9d8d8de |
141 | #endif |
8d063cd8 |
142 | |
fe14fcc3 |
143 | #if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR)) |
144 | #undef HAS_STRERROR |
663a0e37 |
145 | #endif |
146 | |
147 | #include <errno.h> |
d9d8d8de |
148 | #ifndef MSDOS |
663a0e37 |
149 | #ifndef errno |
150 | extern int errno; /* ANSI allows errno to be an lvalue expr */ |
151 | #endif |
d9d8d8de |
152 | #endif |
663a0e37 |
153 | |
35c8bce7 |
154 | #ifndef strerror |
fe14fcc3 |
155 | #ifdef HAS_STRERROR |
663a0e37 |
156 | char *strerror(); |
157 | #else |
158 | extern int sys_nerr; |
159 | extern char *sys_errlist[]; |
160 | #define strerror(e) ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e]) |
161 | #endif |
35c8bce7 |
162 | #endif |
663a0e37 |
163 | |
a687059c |
164 | #ifdef I_SYSIOCTL |
165 | #ifndef _IOCTL_ |
166 | #include <sys/ioctl.h> |
167 | #endif |
168 | #endif |
169 | |
170 | #if defined(mc300) || defined(mc500) || defined(mc700) /* MASSCOMP */ |
fe14fcc3 |
171 | #ifdef HAS_SOCKETPAIR |
172 | #undef HAS_SOCKETPAIR |
a687059c |
173 | #endif |
fe14fcc3 |
174 | #ifdef HAS_NDBM |
175 | #undef HAS_NDBM |
a687059c |
176 | #endif |
177 | #endif |
178 | |
fe14fcc3 |
179 | #ifdef HAS_GDBM |
180 | #ifdef I_GDBM |
181 | #include <gdbm.h> |
182 | #endif |
183 | #define SOME_DBM |
184 | #ifdef HAS_NDBM |
185 | #undef HAS_NDBM |
186 | #endif |
187 | #ifdef HAS_ODBM |
188 | #undef HAS_ODBM |
189 | #endif |
190 | #else |
191 | #ifdef HAS_NDBM |
a687059c |
192 | #include <ndbm.h> |
193 | #define SOME_DBM |
fe14fcc3 |
194 | #ifdef HAS_ODBM |
195 | #undef HAS_ODBM |
ae986130 |
196 | #endif |
a687059c |
197 | #else |
fe14fcc3 |
198 | #ifdef HAS_ODBM |
a687059c |
199 | #ifdef NULL |
200 | #undef NULL /* suppress redefinition message */ |
201 | #endif |
202 | #include <dbm.h> |
203 | #ifdef NULL |
204 | #undef NULL |
205 | #endif |
206 | #define NULL 0 /* silly thing is, we don't even use this */ |
207 | #define SOME_DBM |
208 | #define dbm_fetch(db,dkey) fetch(dkey) |
209 | #define dbm_delete(db,dkey) delete(dkey) |
210 | #define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent) |
211 | #define dbm_close(db) dbmclose() |
212 | #define dbm_firstkey(db) firstkey() |
fe14fcc3 |
213 | #endif /* HAS_ODBM */ |
214 | #endif /* HAS_NDBM */ |
215 | #endif /* HAS_GDBM */ |
a687059c |
216 | #ifdef SOME_DBM |
217 | EXT char *dbmkey; |
218 | EXT int dbmlen; |
219 | #endif |
220 | |
221 | #if INTSIZE == 2 |
222 | #define htoni htons |
223 | #define ntohi ntohs |
224 | #else |
225 | #define htoni htonl |
226 | #define ntohi ntohl |
227 | #endif |
228 | |
35c8bce7 |
229 | #if defined(I_DIRENT) |
663a0e37 |
230 | # include <dirent.h> |
231 | # define DIRENT dirent |
ae986130 |
232 | #else |
fe14fcc3 |
233 | # ifdef I_SYS_NDIR |
79a0689e |
234 | # include <sys/ndir.h> |
663a0e37 |
235 | # define DIRENT direct |
236 | # else |
fe14fcc3 |
237 | # ifdef I_SYS_DIR |
79a0689e |
238 | # ifdef hp9000s500 |
239 | # include <ndir.h> /* may be wrong in the future */ |
240 | # else |
241 | # include <sys/dir.h> |
242 | # endif |
663a0e37 |
243 | # define DIRENT direct |
244 | # endif |
245 | # endif |
a687059c |
246 | #endif |
247 | |
c623bd54 |
248 | /* |
249 | * The following gobbledygook brought to you on behalf of __STDC__. |
250 | * (I could just use #ifndef __STDC__, but this is more bulletproof |
251 | * in the face of half-implementations.) |
252 | */ |
253 | |
254 | #ifndef S_IFMT |
255 | # ifdef _S_IFMT |
256 | # define S_IFMT _S_IFMT |
257 | # else |
258 | # define S_IFMT 0170000 |
259 | # endif |
260 | #endif |
261 | |
262 | #ifndef S_ISDIR |
263 | # define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR) |
264 | #endif |
265 | |
266 | #ifndef S_ISCHR |
267 | # define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR) |
268 | #endif |
269 | |
270 | #ifndef S_ISBLK |
fe14fcc3 |
271 | # ifdef S_IFBLK |
272 | # define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK) |
273 | # else |
274 | # define S_ISBLK(m) (0) |
275 | # endif |
c623bd54 |
276 | #endif |
277 | |
278 | #ifndef S_ISREG |
279 | # define S_ISREG(m) ((m & S_IFMT) == S_IFREG) |
280 | #endif |
281 | |
282 | #ifndef S_ISFIFO |
fe14fcc3 |
283 | # ifdef S_IFIFO |
284 | # define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO) |
285 | # else |
286 | # define S_ISFIFO(m) (0) |
287 | # endif |
c623bd54 |
288 | #endif |
289 | |
290 | #ifndef S_ISLNK |
291 | # ifdef _S_ISLNK |
292 | # define S_ISLNK(m) _S_ISLNK(m) |
293 | # else |
294 | # ifdef _S_IFLNK |
295 | # define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK) |
296 | # else |
297 | # ifdef S_IFLNK |
298 | # define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK) |
299 | # else |
300 | # define S_ISLNK(m) (0) |
301 | # endif |
302 | # endif |
303 | # endif |
304 | #endif |
305 | |
306 | #ifndef S_ISSOCK |
307 | # ifdef _S_ISSOCK |
308 | # define S_ISSOCK(m) _S_ISSOCK(m) |
309 | # else |
310 | # ifdef _S_IFSOCK |
311 | # define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK) |
312 | # else |
313 | # ifdef S_IFSOCK |
314 | # define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK) |
315 | # else |
316 | # define S_ISSOCK(m) (0) |
317 | # endif |
318 | # endif |
319 | # endif |
320 | #endif |
321 | |
322 | #ifndef S_IRUSR |
323 | # ifdef S_IREAD |
324 | # define S_IRUSR S_IREAD |
325 | # define S_IWUSR S_IWRITE |
326 | # define S_IXUSR S_IEXEC |
327 | # else |
328 | # define S_IRUSR 0400 |
329 | # define S_IWUSR 0200 |
330 | # define S_IXUSR 0100 |
331 | # endif |
332 | # define S_IRGRP (S_IRUSR>>3) |
333 | # define S_IWGRP (S_IWUSR>>3) |
334 | # define S_IXGRP (S_IXUSR>>3) |
335 | # define S_IROTH (S_IRUSR>>6) |
336 | # define S_IWOTH (S_IWUSR>>6) |
337 | # define S_IXOTH (S_IXUSR>>6) |
338 | #endif |
339 | |
340 | #ifndef S_ISUID |
341 | # define S_ISUID 04000 |
342 | #endif |
343 | |
344 | #ifndef S_ISGID |
345 | # define S_ISGID 02000 |
346 | #endif |
347 | |
450a55e4 |
348 | typedef unsigned int STRLEN; |
349 | |
8d063cd8 |
350 | typedef struct arg ARG; |
351 | typedef struct cmd CMD; |
352 | typedef struct formcmd FCMD; |
353 | typedef struct scanpat SPAT; |
8d063cd8 |
354 | typedef struct stio STIO; |
378cc40b |
355 | typedef struct sub SUBR; |
8d063cd8 |
356 | typedef struct string STR; |
357 | typedef struct atbl ARRAY; |
358 | typedef struct htbl HASH; |
378cc40b |
359 | typedef struct regexp REGEXP; |
a687059c |
360 | typedef struct stabptrs STBP; |
361 | typedef struct stab STAB; |
d9d8d8de |
362 | typedef struct callsave CSV; |
8d063cd8 |
363 | |
378cc40b |
364 | #include "handy.h" |
365 | #include "regexp.h" |
8d063cd8 |
366 | #include "str.h" |
378cc40b |
367 | #include "util.h" |
8d063cd8 |
368 | #include "form.h" |
369 | #include "stab.h" |
370 | #include "spat.h" |
371 | #include "arg.h" |
372 | #include "cmd.h" |
373 | #include "array.h" |
374 | #include "hash.h" |
375 | |
450a55e4 |
376 | #if defined(iAPX286) || defined(M_I286) || defined(I80286) |
a687059c |
377 | # define I286 |
378 | #endif |
379 | |
380 | #ifndef __STDC__ |
135863df |
381 | #ifdef CHARSPRINTF |
382 | char *sprintf(); |
383 | #else |
384 | int sprintf(); |
385 | #endif |
a687059c |
386 | #endif |
135863df |
387 | |
8d063cd8 |
388 | EXT char *Yes INIT("1"); |
389 | EXT char *No INIT(""); |
390 | |
a687059c |
391 | /* "gimme" values */ |
392 | |
393 | /* Note: cmd.c assumes that it can use && to produce one of these values! */ |
394 | #define G_SCALAR 0 |
395 | #define G_ARRAY 1 |
396 | |
397 | #ifdef CRIPPLED_CC |
398 | int str_true(); |
399 | #else /* !CRIPPLED_CC */ |
400 | #define str_true(str) (Str = (str), \ |
401 | (Str->str_pok ? \ |
402 | ((*Str->str_ptr > '0' || \ |
403 | Str->str_cur > 1 || \ |
404 | (Str->str_cur && *Str->str_ptr != '0')) ? 1 : 0) \ |
405 | : \ |
406 | (Str->str_nok ? (Str->str_u.str_nval != 0.0) : 0 ) )) |
407 | #endif /* CRIPPLED_CC */ |
8d063cd8 |
408 | |
135863df |
409 | #ifdef DEBUGGING |
a687059c |
410 | #define str_peek(str) (Str = (str), \ |
411 | (Str->str_pok ? \ |
412 | Str->str_ptr : \ |
413 | (Str->str_nok ? \ |
414 | (sprintf(tokenbuf,"num(%g)",Str->str_u.str_nval), \ |
415 | (char*)tokenbuf) : \ |
416 | "" ))) |
135863df |
417 | #endif |
418 | |
a687059c |
419 | #ifdef CRIPPLED_CC |
420 | char *str_get(); |
421 | #else |
422 | #ifdef TAINT |
423 | #define str_get(str) (Str = (str), tainted |= Str->str_tainted, \ |
424 | (Str->str_pok ? Str->str_ptr : str_2ptr(Str))) |
425 | #else |
8d063cd8 |
426 | #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str))) |
a687059c |
427 | #endif /* TAINT */ |
428 | #endif /* CRIPPLED_CC */ |
429 | |
430 | #ifdef CRIPPLED_CC |
431 | double str_gnum(); |
432 | #else /* !CRIPPLED_CC */ |
433 | #ifdef TAINT |
434 | #define str_gnum(str) (Str = (str), tainted |= Str->str_tainted, \ |
435 | (Str->str_nok ? Str->str_u.str_nval : str_2num(Str))) |
436 | #else /* !TAINT */ |
437 | #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_u.str_nval : str_2num(Str))) |
438 | #endif /* TAINT*/ |
439 | #endif /* CRIPPLED_CC */ |
8d063cd8 |
440 | EXT STR *Str; |
441 | |
442 | #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len) |
443 | |
450a55e4 |
444 | #ifndef MSDOS |
a687059c |
445 | #define STR_GROW(str,len) if ((str)->str_len < (len)) str_grow(str,len) |
450a55e4 |
446 | #define Str_Grow str_grow |
447 | #else |
448 | /* extra parentheses intentionally NOT placed around "len"! */ |
449 | #define STR_GROW(str,len) if ((str)->str_len < (unsigned long)len) \ |
450 | str_grow(str,(unsigned long)len) |
451 | #define Str_Grow(str,len) str_grow(str,(unsigned long)(len)) |
452 | #endif /* MSDOS */ |
a687059c |
453 | |
454 | #ifndef BYTEORDER |
ffed7fef |
455 | #define BYTEORDER 0x1234 |
a687059c |
456 | #endif |
457 | |
fe14fcc3 |
458 | #if defined(htonl) && !defined(HAS_HTONL) |
459 | #define HAS_HTONL |
ae986130 |
460 | #endif |
fe14fcc3 |
461 | #if defined(htons) && !defined(HAS_HTONS) |
462 | #define HAS_HTONS |
ae986130 |
463 | #endif |
fe14fcc3 |
464 | #if defined(ntohl) && !defined(HAS_NTOHL) |
465 | #define HAS_NTOHL |
ae986130 |
466 | #endif |
fe14fcc3 |
467 | #if defined(ntohs) && !defined(HAS_NTOHS) |
468 | #define HAS_NTOHS |
ae986130 |
469 | #endif |
fe14fcc3 |
470 | #ifndef HAS_HTONL |
d9d8d8de |
471 | #if (BYTEORDER & 0xffff) != 0x4321 |
fe14fcc3 |
472 | #define HAS_HTONS |
473 | #define HAS_HTONL |
474 | #define HAS_NTOHS |
475 | #define HAS_NTOHL |
a687059c |
476 | #define MYSWAP |
477 | #define htons my_swap |
478 | #define htonl my_htonl |
479 | #define ntohs my_swap |
480 | #define ntohl my_ntohl |
481 | #endif |
482 | #else |
d9d8d8de |
483 | #if (BYTEORDER & 0xffff) == 0x4321 |
fe14fcc3 |
484 | #undef HAS_HTONS |
485 | #undef HAS_HTONL |
486 | #undef HAS_NTOHS |
487 | #undef HAS_NTOHL |
a687059c |
488 | #endif |
489 | #endif |
490 | |
0f85fab0 |
491 | #ifdef CASTNEGFLOAT |
492 | #define U_S(what) ((unsigned short)(what)) |
493 | #define U_I(what) ((unsigned int)(what)) |
494 | #define U_L(what) ((unsigned long)(what)) |
495 | #else |
496 | unsigned long castulong(); |
497 | #define U_S(what) ((unsigned int)castulong(what)) |
498 | #define U_I(what) ((unsigned int)castulong(what)) |
499 | #define U_L(what) (castulong(what)) |
500 | #endif |
501 | |
8d063cd8 |
502 | CMD *add_label(); |
503 | CMD *block_head(); |
504 | CMD *append_line(); |
505 | CMD *make_acmd(); |
506 | CMD *make_ccmd(); |
a687059c |
507 | CMD *make_icmd(); |
8d063cd8 |
508 | CMD *invert(); |
509 | CMD *addcond(); |
510 | CMD *addloop(); |
511 | CMD *wopt(); |
378cc40b |
512 | CMD *over(); |
8d063cd8 |
513 | |
8d063cd8 |
514 | STAB *stabent(); |
378cc40b |
515 | STAB *genstab(); |
8d063cd8 |
516 | |
378cc40b |
517 | ARG *stab2arg(); |
8d063cd8 |
518 | ARG *op_new(); |
519 | ARG *make_op(); |
8d063cd8 |
520 | ARG *make_match(); |
521 | ARG *make_split(); |
a687059c |
522 | ARG *rcatmaybe(); |
378cc40b |
523 | ARG *listish(); |
a687059c |
524 | ARG *maybelistish(); |
378cc40b |
525 | ARG *localize(); |
a687059c |
526 | ARG *fixeval(); |
527 | ARG *jmaybe(); |
378cc40b |
528 | ARG *l(); |
a687059c |
529 | ARG *fixl(); |
378cc40b |
530 | ARG *mod_match(); |
531 | ARG *make_list(); |
532 | ARG *cmd_to_arg(); |
533 | ARG *addflags(); |
534 | ARG *hide_ary(); |
535 | ARG *cval_to_arg(); |
8d063cd8 |
536 | |
8d063cd8 |
537 | STR *str_new(); |
538 | STR *stab_str(); |
a687059c |
539 | |
540 | int do_each(); |
541 | int do_subr(); |
542 | int do_match(); |
543 | int do_unpack(); |
544 | int eval(); /* this evaluates expressions */ |
545 | int do_eval(); /* this evaluates eval operator */ |
546 | int do_assign(); |
378cc40b |
547 | |
548 | SUBR *make_sub(); |
8d063cd8 |
549 | |
550 | FCMD *load_format(); |
551 | |
552 | char *scanpat(); |
553 | char *scansubst(); |
554 | char *scantrans(); |
555 | char *scanstr(); |
fe14fcc3 |
556 | char *scanident(); |
8d063cd8 |
557 | char *str_append_till(); |
558 | char *str_gets(); |
a687059c |
559 | char *str_grow(); |
8d063cd8 |
560 | |
8d063cd8 |
561 | bool do_open(); |
562 | bool do_close(); |
563 | bool do_print(); |
378cc40b |
564 | bool do_aprint(); |
565 | bool do_exec(); |
566 | bool do_aexec(); |
8d063cd8 |
567 | |
568 | int do_subst(); |
378cc40b |
569 | int cando(); |
570 | int ingroup(); |
8d063cd8 |
571 | |
378cc40b |
572 | void str_replace(); |
573 | void str_inc(); |
574 | void str_dec(); |
8d063cd8 |
575 | void str_free(); |
a687059c |
576 | void stab_clear(); |
378cc40b |
577 | void do_join(); |
378cc40b |
578 | void do_sprintf(); |
a687059c |
579 | void do_accept(); |
ac58e20f |
580 | void do_pipe(); |
a687059c |
581 | void do_vecset(); |
fe14fcc3 |
582 | void do_unshift(); |
583 | void do_execfree(); |
584 | void magicalize(); |
585 | void magicname(); |
a687059c |
586 | void savelist(); |
587 | void saveitem(); |
588 | void saveint(); |
589 | void savelong(); |
590 | void savesptr(); |
591 | void savehptr(); |
592 | void restorelist(); |
ac58e20f |
593 | void repeatcpy(); |
a687059c |
594 | HASH *savehash(); |
595 | ARRAY *saveary(); |
378cc40b |
596 | |
ac58e20f |
597 | EXT char **origargv; |
598 | EXT int origargc; |
fe14fcc3 |
599 | EXT char **origenviron; |
35c8bce7 |
600 | extern char **environ; |
601 | |
a687059c |
602 | EXT line_t subline INIT(0); |
603 | EXT STR *subname INIT(Nullstr); |
8d063cd8 |
604 | EXT int arybase INIT(0); |
605 | |
606 | struct outrec { |
d9d8d8de |
607 | long o_lines; |
608 | char *o_str; |
609 | int o_len; |
8d063cd8 |
610 | }; |
611 | |
612 | EXT struct outrec outrec; |
613 | EXT struct outrec toprec; |
614 | |
a687059c |
615 | EXT STAB *stdinstab INIT(Nullstab); |
8d063cd8 |
616 | EXT STAB *last_in_stab INIT(Nullstab); |
617 | EXT STAB *defstab INIT(Nullstab); |
618 | EXT STAB *argvstab INIT(Nullstab); |
619 | EXT STAB *envstab INIT(Nullstab); |
620 | EXT STAB *sigstab INIT(Nullstab); |
621 | EXT STAB *defoutstab INIT(Nullstab); |
622 | EXT STAB *curoutstab INIT(Nullstab); |
623 | EXT STAB *argvoutstab INIT(Nullstab); |
378cc40b |
624 | EXT STAB *incstab INIT(Nullstab); |
a687059c |
625 | EXT STAB *leftstab INIT(Nullstab); |
626 | EXT STAB *amperstab INIT(Nullstab); |
627 | EXT STAB *rightstab INIT(Nullstab); |
628 | EXT STAB *DBstab INIT(Nullstab); |
d9d8d8de |
629 | EXT STAB *DBline INIT(Nullstab); |
a687059c |
630 | EXT STAB *DBsub INIT(Nullstab); |
631 | |
632 | EXT HASH *defstash; /* main symbol table */ |
633 | EXT HASH *curstash; /* symbol table for current package */ |
634 | EXT HASH *debstash; /* symbol table for perldb package */ |
635 | |
636 | EXT STR *curstname; /* name of current package */ |
8d063cd8 |
637 | |
638 | EXT STR *freestrroot INIT(Nullstr); |
378cc40b |
639 | EXT STR *lastretstr INIT(Nullstr); |
a687059c |
640 | EXT STR *DBsingle INIT(Nullstr); |
d9d8d8de |
641 | EXT STR *DBtrace INIT(Nullstr); |
642 | EXT STR *DBsignal INIT(Nullstr); |
a687059c |
643 | |
644 | EXT int lastspbase; |
645 | EXT int lastsize; |
8d063cd8 |
646 | |
fe14fcc3 |
647 | EXT char *hexdigit INIT("0123456789abcdef0123456789ABCDEF"); |
378cc40b |
648 | EXT char *origfilename; |
ac58e20f |
649 | EXT FILE * VOLATILE rsfp; |
8d063cd8 |
650 | EXT char buf[1024]; |
a687059c |
651 | EXT char *bufptr; |
652 | EXT char *oldbufptr; |
653 | EXT char *oldoldbufptr; |
654 | EXT char *bufend; |
8d063cd8 |
655 | |
656 | EXT STR *linestr INIT(Nullstr); |
657 | |
fe14fcc3 |
658 | EXT char *rs INIT("\n"); |
659 | EXT int rschar INIT('\n'); /* final char of rs, or 0777 if none */ |
a687059c |
660 | EXT int rslen INIT(1); |
8d063cd8 |
661 | EXT char *ofs INIT(Nullch); |
a687059c |
662 | EXT int ofslen INIT(0); |
8d063cd8 |
663 | EXT char *ors INIT(Nullch); |
a687059c |
664 | EXT int orslen INIT(0); |
8d063cd8 |
665 | EXT char *ofmt INIT(Nullch); |
666 | EXT char *inplace INIT(Nullch); |
a687059c |
667 | EXT char *nointrp INIT(""); |
8d063cd8 |
668 | |
378cc40b |
669 | EXT bool preprocess INIT(FALSE); |
670 | EXT bool minus_n INIT(FALSE); |
671 | EXT bool minus_p INIT(FALSE); |
fe14fcc3 |
672 | EXT bool minus_l INIT(FALSE); |
378cc40b |
673 | EXT bool minus_a INIT(FALSE); |
674 | EXT bool doswitches INIT(FALSE); |
675 | EXT bool dowarn INIT(FALSE); |
450a55e4 |
676 | EXT bool doextract INIT(FALSE); |
378cc40b |
677 | EXT bool allstabs INIT(FALSE); /* init all customary symbols in symbol table?*/ |
678 | EXT bool sawampersand INIT(FALSE); /* must save all match strings */ |
679 | EXT bool sawstudy INIT(FALSE); /* do fbminstr on all strings */ |
a687059c |
680 | EXT bool sawi INIT(FALSE); /* study must assume case insensitive */ |
681 | EXT bool sawvec INIT(FALSE); |
ac58e20f |
682 | EXT bool localizing INIT(FALSE); /* are we processing a local() list? */ |
a687059c |
683 | |
ae986130 |
684 | #ifdef CSH |
685 | char *cshname INIT(CSH); |
686 | int cshlen INIT(0); |
687 | #endif /* CSH */ |
a687059c |
688 | |
689 | #ifdef TAINT |
690 | EXT bool tainted INIT(FALSE); /* using variables controlled by $< */ |
691 | #endif |
378cc40b |
692 | |
450a55e4 |
693 | #ifndef MSDOS |
378cc40b |
694 | #define TMPPATH "/tmp/perl-eXXXXXX" |
450a55e4 |
695 | #else |
57ebbfd0 |
696 | #define TMPPATH "plXXXXXX" |
450a55e4 |
697 | #endif /* MSDOS */ |
378cc40b |
698 | EXT char *e_tmpname; |
699 | EXT FILE *e_fp INIT(Nullfp); |
700 | |
8d063cd8 |
701 | EXT char tokenbuf[256]; |
a687059c |
702 | EXT int expectterm INIT(TRUE); /* how to interpret ambiguous tokens */ |
ac58e20f |
703 | EXT VOLATILE int in_eval INIT(FALSE); /* trap fatal errors? */ |
a687059c |
704 | EXT int multiline INIT(0); /* $*--do strings hold >1 line? */ |
705 | EXT int forkprocess; /* so do_open |- can return proc# */ |
706 | EXT int do_undump INIT(0); /* -u or dump seen? */ |
707 | EXT int error_count INIT(0); /* how many errors so far, max 10 */ |
708 | EXT int multi_start INIT(0); /* 1st line of multi-line string */ |
709 | EXT int multi_end INIT(0); /* last line of multi-line string */ |
710 | EXT int multi_open INIT(0); /* delimiter of said string */ |
711 | EXT int multi_close INIT(0); /* delimiter of said string */ |
8d063cd8 |
712 | |
713 | FILE *popen(); |
714 | /* char *str_get(); */ |
715 | STR *interp(); |
716 | void free_arg(); |
717 | STIO *stio_new(); |
718 | |
719 | EXT struct stat statbuf; |
a687059c |
720 | EXT struct stat statcache; |
721 | STAB *statstab INIT(Nullstab); |
722 | STR *statname; |
d9d8d8de |
723 | #ifndef MSDOS |
8d063cd8 |
724 | EXT struct tms timesbuf; |
d9d8d8de |
725 | #endif |
378cc40b |
726 | EXT int uid; |
727 | EXT int euid; |
a687059c |
728 | EXT int gid; |
729 | EXT int egid; |
378cc40b |
730 | UIDTYPE getuid(); |
731 | UIDTYPE geteuid(); |
732 | GIDTYPE getgid(); |
733 | GIDTYPE getegid(); |
734 | EXT int unsafe; |
8d063cd8 |
735 | |
736 | #ifdef DEBUGGING |
ac58e20f |
737 | EXT VOLATILE int debug INIT(0); |
8d063cd8 |
738 | EXT int dlevel INIT(0); |
a687059c |
739 | EXT int dlmax INIT(128); |
740 | EXT char *debname; |
741 | EXT char *debdelim; |
d96024cf |
742 | #define YYDEBUG 1 |
8d063cd8 |
743 | #endif |
a687059c |
744 | EXT int perldb INIT(0); |
fe14fcc3 |
745 | #define YYMAXDEPTH 300 |
8d063cd8 |
746 | |
378cc40b |
747 | EXT line_t cmdline INIT(NOLINE); |
748 | |
a687059c |
749 | EXT STR str_undef; |
8d063cd8 |
750 | EXT STR str_no; |
751 | EXT STR str_yes; |
752 | |
753 | /* runtime control stuff */ |
754 | |
755 | EXT struct loop { |
a687059c |
756 | char *loop_label; /* what the loop was called, if anything */ |
757 | int loop_sp; /* stack pointer to copy stuff down to */ |
8d063cd8 |
758 | jmp_buf loop_env; |
a687059c |
759 | } *loop_stack; |
8d063cd8 |
760 | |
761 | EXT int loop_ptr INIT(-1); |
a687059c |
762 | EXT int loop_max INIT(128); |
8d063cd8 |
763 | |
764 | EXT jmp_buf top_env; |
765 | |
ac58e20f |
766 | EXT char * VOLATILE goto_targ INIT(Nullch); /* cmd_exec gets strange when set */ |
8d063cd8 |
767 | |
450a55e4 |
768 | struct ufuncs { |
769 | int (*uf_val)(); |
770 | int (*uf_set)(); |
771 | int uf_index; |
772 | }; |
773 | |
a687059c |
774 | EXT ARRAY *stack; /* THE STACK */ |
775 | |
ac58e20f |
776 | EXT ARRAY * VOLATILE savestack; /* to save non-local values on */ |
378cc40b |
777 | |
778 | EXT ARRAY *tosave; /* strings to save on recursive subroutine */ |
779 | |
a687059c |
780 | EXT ARRAY *lineary; /* lines of script for debugger */ |
d9d8d8de |
781 | EXT ARRAY *dbargs; /* args to call listed by caller function */ |
a687059c |
782 | |
d9d8d8de |
783 | EXT ARRAY *fdpid; /* keep fd-to-pid mappings for mypopen */ |
784 | EXT HASH *pidstatus; /* keep pid-to-status mappings for waitpid */ |
a687059c |
785 | |
ac58e20f |
786 | EXT int *di; /* for tmp use in debuggers */ |
787 | EXT char *dc; |
788 | EXT short *ds; |
789 | |
fe14fcc3 |
790 | /* Fix these up for __STDC__ */ |
791 | EXT long basetime INIT(0); |
792 | char *mktemp(); |
793 | #ifndef __STDC__ |
794 | /* All of these are in stdlib.h or time.h for ANSI C */ |
8d063cd8 |
795 | double atof(); |
a687059c |
796 | long time(); |
8d063cd8 |
797 | struct tm *gmtime(), *localtime(); |
378cc40b |
798 | char *index(), *rindex(); |
799 | char *strcpy(), *strcat(); |
fe14fcc3 |
800 | #endif /* ! __STDC__ */ |
8d063cd8 |
801 | |
8d063cd8 |
802 | #ifdef EUNICE |
378cc40b |
803 | #define UNLINK unlnk |
804 | int unlnk(); |
8d063cd8 |
805 | #else |
806 | #define UNLINK unlink |
807 | #endif |
a687059c |
808 | |
fe14fcc3 |
809 | #ifndef HAS_SETREUID |
810 | #ifdef HAS_SETRESUID |
a687059c |
811 | #define setreuid(r,e) setresuid(r,e,-1) |
fe14fcc3 |
812 | #define HAS_SETREUID |
a687059c |
813 | #endif |
814 | #endif |
fe14fcc3 |
815 | #ifndef HAS_SETREGID |
816 | #ifdef HAS_SETRESGID |
a687059c |
817 | #define setregid(r,e) setresgid(r,e,-1) |
fe14fcc3 |
818 | #define HAS_SETREGID |
a687059c |
819 | #endif |
820 | #endif |