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