1 /* $Header: perl.h,v 3.0.1.6 90/03/12 16:40:43 lwall Locked $
3 * Copyright (c) 1989, Larry Wall
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.
9 * Revision 3.0.1.6 90/03/12 16:40:43 lwall
10 * patch13: did some ndir straightening up for Xenix
12 * Revision 3.0.1.5 90/02/28 17:52:28 lwall
13 * patch9: Configure now determines whether volatile is supported
14 * patch9: volatilized some more variables for super-optimizing compilers
15 * patch9: unused VREG symbol deleted
16 * patch9: perl can now start up other interpreters scripts
17 * patch9: you may now undef $/ to have no input record separator
18 * patch9: nested evals clobbered their longjmp environment
20 * Revision 3.0.1.4 89/12/21 20:07:35 lwall
21 * patch7: arranged for certain registers to be restored after longjmp()
22 * patch7: Configure now compiles a test program to figure out time.h fiasco
23 * patch7: Configure now detects DG/UX thingies like [sg]etpgrp2 and utime.h
24 * patch7: memcpy() and memset() return void in __STDC__
25 * patch7: errno may now be a macro with an lvalue
26 * patch7: ANSI strerror() is now supported
27 * patch7: Xenix support for sys/ndir.h, cross compilation
29 * Revision 3.0.1.3 89/11/17 15:28:57 lwall
30 * patch5: byteorder now is a hex value
31 * patch5: Configure now looks for <time.h> including <sys/time.h>
33 * Revision 3.0.1.2 89/11/11 04:39:38 lwall
34 * patch2: Configure may now set -DDEBUGGING
35 * patch2: netinet/in.h needed sys/types.h some places
36 * patch2: more <sys/time.h> and <time.h> wrangling
37 * patch2: yydebug moved to where type doesn't matter
39 * Revision 3.0.1.1 89/10/26 23:17:08 lwall
40 * patch1: vfork now conditionally defined based on VFORK
41 * patch1: DEC risc machines have a buggy memcmp
42 * patch1: perl.h now includes <netinet/in.h> if it exists
44 * Revision 3.0 89/10/18 15:21:21 lwall
52 #if defined(HASVOLATILE) || defined(__STDC__)
53 #define VOLATILE volatile
72 # define getpgrp getpgrp2
79 # define setpgrp setpgrp2
82 #if defined(MEMCMP) && defined(mips) && BYTEORDER == 0x1234
89 extern void *memcpy(), *memset();
91 extern char *memcpy(), *memset();
94 #define bcopy(s1,s2,l) memcpy(s2,s1,l)
95 #define bzero(s,l) memset(s,0,l)
97 #ifndef BCMP /* prefer bcmp slightly 'cuz it doesn't order */
98 #define bcmp(s1,s2,l) memcmp(s1,s2,l)
104 #include <sys/param.h> /* if this needs types.h we're still wrong */
106 #ifndef _TYPES_ /* If types.h defines this it's easy. */
107 #ifndef major /* Does everyone's types.h define this? */
108 #include <sys/types.h>
113 #include <netinet/in.h>
116 #include <sys/stat.h>
123 # ifdef SYSTIMEKERNEL
126 # include <sys/time.h>
127 # ifdef SYSTIMEKERNEL
132 #include <sys/times.h>
134 #if defined(STRERROR) && (!defined(MKDIR) || !defined(RMDIR))
140 extern int errno; /* ANSI allows errno to be an lvalue expr */
147 extern char *sys_errlist[];
148 #define strerror(e) ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e])
153 #include <sys/ioctl.h>
157 #if defined(mc300) || defined(mc500) || defined(mc700) /* MASSCOMP */
175 #undef NULL /* suppress redefinition message */
181 #define NULL 0 /* silly thing is, we don't even use this */
183 #define dbm_fetch(db,dkey) fetch(dkey)
184 #define dbm_delete(db,dkey) delete(dkey)
185 #define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent)
186 #define dbm_close(db) dbmclose()
187 #define dbm_firstkey(db) firstkey()
203 #if defined(I_DIRENT) && !defined(M_XENIX)
205 # define DIRENT dirent
208 # include <sys/ndir.h>
209 # define DIRENT direct
213 # include <ndir.h> /* may be wrong in the future */
215 # include <sys/dir.h>
217 # define DIRENT direct
222 typedef struct arg ARG;
223 typedef struct cmd CMD;
224 typedef struct formcmd FCMD;
225 typedef struct scanpat SPAT;
226 typedef struct stio STIO;
227 typedef struct sub SUBR;
228 typedef struct string STR;
229 typedef struct atbl ARRAY;
230 typedef struct htbl HASH;
231 typedef struct regexp REGEXP;
232 typedef struct stabptrs STBP;
233 typedef struct stab STAB;
247 #if defined(iAPX286) || defined(M_I286) || defined(I80286)
259 EXT char *Yes INIT("1");
260 EXT char *No INIT("");
264 /* Note: cmd.c assumes that it can use && to produce one of these values! */
270 #else /* !CRIPPLED_CC */
271 #define str_true(str) (Str = (str), \
273 ((*Str->str_ptr > '0' || \
274 Str->str_cur > 1 || \
275 (Str->str_cur && *Str->str_ptr != '0')) ? 1 : 0) \
277 (Str->str_nok ? (Str->str_u.str_nval != 0.0) : 0 ) ))
278 #endif /* CRIPPLED_CC */
281 #define str_peek(str) (Str = (str), \
285 (sprintf(tokenbuf,"num(%g)",Str->str_u.str_nval), \
294 #define str_get(str) (Str = (str), tainted |= Str->str_tainted, \
295 (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
297 #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
299 #endif /* CRIPPLED_CC */
303 #else /* !CRIPPLED_CC */
305 #define str_gnum(str) (Str = (str), tainted |= Str->str_tainted, \
306 (Str->str_nok ? Str->str_u.str_nval : str_2num(Str)))
308 #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_u.str_nval : str_2num(Str)))
310 #endif /* CRIPPLED_CC */
313 #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
315 #define STR_GROW(str,len) if ((str)->str_len < (len)) str_grow(str,len)
318 #define BYTEORDER 0x1234
321 #if defined(htonl) && !defined(HTONL)
324 #if defined(htons) && !defined(HTONS)
327 #if defined(ntohl) && !defined(NTOHL)
330 #if defined(ntohs) && !defined(NTOHS)
334 #if (BYTEORDER != 0x4321) && (BYTEORDER != 0x87654321)
340 #define htons my_swap
341 #define htonl my_htonl
342 #define ntohs my_swap
343 #define ntohl my_ntohl
346 #if (BYTEORDER == 0x4321) || (BYTEORDER == 0x87654321)
396 int eval(); /* this evaluates expressions */
397 int do_eval(); /* this evaluates eval operator */
409 char *str_append_till();
447 EXT line_t line INIT(0);
448 EXT line_t subline INIT(0);
449 EXT STR *subname INIT(Nullstr);
450 EXT int arybase INIT(0);
458 EXT struct outrec outrec;
459 EXT struct outrec toprec;
461 EXT STAB *stdinstab INIT(Nullstab);
462 EXT STAB *last_in_stab INIT(Nullstab);
463 EXT STAB *defstab INIT(Nullstab);
464 EXT STAB *argvstab INIT(Nullstab);
465 EXT STAB *envstab INIT(Nullstab);
466 EXT STAB *sigstab INIT(Nullstab);
467 EXT STAB *defoutstab INIT(Nullstab);
468 EXT STAB *curoutstab INIT(Nullstab);
469 EXT STAB *argvoutstab INIT(Nullstab);
470 EXT STAB *incstab INIT(Nullstab);
471 EXT STAB *leftstab INIT(Nullstab);
472 EXT STAB *amperstab INIT(Nullstab);
473 EXT STAB *rightstab INIT(Nullstab);
474 EXT STAB *DBstab INIT(Nullstab);
475 EXT STAB *DBsub INIT(Nullstab);
477 EXT HASH *defstash; /* main symbol table */
478 EXT HASH *curstash; /* symbol table for current package */
479 EXT HASH *debstash; /* symbol table for perldb package */
481 EXT STR *curstname; /* name of current package */
483 EXT STR *freestrroot INIT(Nullstr);
484 EXT STR *lastretstr INIT(Nullstr);
485 EXT STR *DBsingle INIT(Nullstr);
491 EXT char *origfilename;
492 EXT FILE * VOLATILE rsfp;
496 EXT char *oldoldbufptr;
499 EXT STR *linestr INIT(Nullstr);
501 EXT int record_separator INIT('\n');
502 EXT int rslen INIT(1);
503 EXT char *ofs INIT(Nullch);
504 EXT int ofslen INIT(0);
505 EXT char *ors INIT(Nullch);
506 EXT int orslen INIT(0);
507 EXT char *ofmt INIT(Nullch);
508 EXT char *inplace INIT(Nullch);
509 EXT char *nointrp INIT("");
511 EXT bool preprocess INIT(FALSE);
512 EXT bool minus_n INIT(FALSE);
513 EXT bool minus_p INIT(FALSE);
514 EXT bool minus_a INIT(FALSE);
515 EXT bool doswitches INIT(FALSE);
516 EXT bool dowarn INIT(FALSE);
517 EXT bool allstabs INIT(FALSE); /* init all customary symbols in symbol table?*/
518 EXT bool sawampersand INIT(FALSE); /* must save all match strings */
519 EXT bool sawstudy INIT(FALSE); /* do fbminstr on all strings */
520 EXT bool sawi INIT(FALSE); /* study must assume case insensitive */
521 EXT bool sawvec INIT(FALSE);
522 EXT bool localizing INIT(FALSE); /* are we processing a local() list? */
525 char *cshname INIT(CSH);
530 EXT bool tainted INIT(FALSE); /* using variables controlled by $< */
533 #define TMPPATH "/tmp/perl-eXXXXXX"
535 EXT FILE *e_fp INIT(Nullfp);
537 EXT char tokenbuf[256];
538 EXT int expectterm INIT(TRUE); /* how to interpret ambiguous tokens */
539 EXT VOLATILE int in_eval INIT(FALSE); /* trap fatal errors? */
540 EXT int multiline INIT(0); /* $*--do strings hold >1 line? */
541 EXT int forkprocess; /* so do_open |- can return proc# */
542 EXT int do_undump INIT(0); /* -u or dump seen? */
543 EXT int error_count INIT(0); /* how many errors so far, max 10 */
544 EXT int multi_start INIT(0); /* 1st line of multi-line string */
545 EXT int multi_end INIT(0); /* last line of multi-line string */
546 EXT int multi_open INIT(0); /* delimiter of said string */
547 EXT int multi_close INIT(0); /* delimiter of said string */
550 /* char *str_get(); */
555 EXT struct stat statbuf;
556 EXT struct stat statcache;
557 STAB *statstab INIT(Nullstab);
559 EXT struct tms timesbuf;
571 EXT VOLATILE int debug INIT(0);
572 EXT int dlevel INIT(0);
573 EXT int dlmax INIT(128);
578 EXT int perldb INIT(0);
580 EXT line_t cmdline INIT(NOLINE);
586 /* runtime control stuff */
589 char *loop_label; /* what the loop was called, if anything */
590 int loop_sp; /* stack pointer to copy stuff down to */
594 EXT int loop_ptr INIT(-1);
595 EXT int loop_max INIT(128);
599 EXT char * VOLATILE goto_targ INIT(Nullch); /* cmd_exec gets strange when set */
601 EXT ARRAY *stack; /* THE STACK */
603 EXT ARRAY * VOLATILE savestack; /* to save non-local values on */
605 EXT ARRAY *tosave; /* strings to save on recursive subroutine */
607 EXT ARRAY *lineary; /* lines of script for debugger */
609 EXT ARRAY *pidstatary; /* keep pids and statuses by fd for mypopen */
611 EXT int *di; /* for tmp use in debuggers */
617 struct tm *gmtime(), *localtime();
619 char *index(), *rindex();
620 char *strcpy(), *strcat();
626 #define UNLINK unlink
631 #define setreuid(r,e) setresuid(r,e,-1)
637 #define setregid(r,e) setresgid(r,e,-1)