1 /* $Header: perl.h,v 3.0.1.7 90/03/27 16:12:52 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.7 90/03/27 16:12:52 lwall
10 * patch16: MSDOS support
11 * patch16: support for machines that can't cast negative floats to unsigned ints
13 * Revision 3.0.1.6 90/03/12 16:40:43 lwall
14 * patch13: did some ndir straightening up for Xenix
16 * Revision 3.0.1.5 90/02/28 17:52:28 lwall
17 * patch9: Configure now determines whether volatile is supported
18 * patch9: volatilized some more variables for super-optimizing compilers
19 * patch9: unused VREG symbol deleted
20 * patch9: perl can now start up other interpreters scripts
21 * patch9: you may now undef $/ to have no input record separator
22 * patch9: nested evals clobbered their longjmp environment
24 * Revision 3.0.1.4 89/12/21 20:07:35 lwall
25 * patch7: arranged for certain registers to be restored after longjmp()
26 * patch7: Configure now compiles a test program to figure out time.h fiasco
27 * patch7: Configure now detects DG/UX thingies like [sg]etpgrp2 and utime.h
28 * patch7: memcpy() and memset() return void in __STDC__
29 * patch7: errno may now be a macro with an lvalue
30 * patch7: ANSI strerror() is now supported
31 * patch7: Xenix support for sys/ndir.h, cross compilation
33 * Revision 3.0.1.3 89/11/17 15:28:57 lwall
34 * patch5: byteorder now is a hex value
35 * patch5: Configure now looks for <time.h> including <sys/time.h>
37 * Revision 3.0.1.2 89/11/11 04:39:38 lwall
38 * patch2: Configure may now set -DDEBUGGING
39 * patch2: netinet/in.h needed sys/types.h some places
40 * patch2: more <sys/time.h> and <time.h> wrangling
41 * patch2: yydebug moved to where type doesn't matter
43 * Revision 3.0.1.1 89/10/26 23:17:08 lwall
44 * patch1: vfork now conditionally defined based on VFORK
45 * patch1: DEC risc machines have a buggy memcmp
46 * patch1: perl.h now includes <netinet/in.h> if it exists
48 * Revision 3.0 89/10/18 15:21:21 lwall
59 * This symbol is defined if you are the unfortunate owner of a buggy
60 * Microsoft C compiler and want to use intrinsic functions. Versions
61 * up to 5.1 are known conform to this definition. This is not needed
64 #define BUGGY_MSC /**/
67 * This symbol is defined if you run under an operating system that
68 * distinguishes between binary and text files. If so the function
69 * setmode will be used to set the file into binary mode. Unix
70 * doesn't distinguish.
77 * The following symbols are defined if your operating system supports
78 * functions by that name. All Unixes I know of support them, thus they
79 * are not checked by the configuration script, but are directly defined
93 * The following symbols are defined if your operating system supports
94 * password and group functions in general. All Unix systems do.
101 #if defined(HASVOLATILE) || defined(__STDC__)
102 #define VOLATILE volatile
121 # define getpgrp getpgrp2
128 # define setpgrp setpgrp2
131 #if defined(MEMCMP) && defined(mips) && BYTEORDER == 0x1234
138 extern void *memcpy(), *memset();
140 extern char *memcpy(), *memset();
143 #define bcopy(s1,s2,l) memcpy(s2,s1,l)
144 #define bzero(s,l) memset(s,0,l)
146 #ifndef BCMP /* prefer bcmp slightly 'cuz it doesn't order */
147 #define bcmp(s1,s2,l) memcmp(s1,s2,l)
153 #include <sys/param.h> /* if this needs types.h we're still wrong */
155 #ifndef _TYPES_ /* If types.h defines this it's easy. */
156 #ifndef major /* Does everyone's types.h define this? */
157 #include <sys/types.h>
162 #include <netinet/in.h>
165 #include <sys/stat.h>
172 # ifdef SYSTIMEKERNEL
175 # include <sys/time.h>
176 # ifdef SYSTIMEKERNEL
181 #include <sys/times.h>
183 #if defined(STRERROR) && (!defined(MKDIR) || !defined(RMDIR))
189 extern int errno; /* ANSI allows errno to be an lvalue expr */
196 extern char *sys_errlist[];
197 #define strerror(e) ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e])
202 #include <sys/ioctl.h>
206 #if defined(mc300) || defined(mc500) || defined(mc700) /* MASSCOMP */
224 #undef NULL /* suppress redefinition message */
230 #define NULL 0 /* silly thing is, we don't even use this */
232 #define dbm_fetch(db,dkey) fetch(dkey)
233 #define dbm_delete(db,dkey) delete(dkey)
234 #define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent)
235 #define dbm_close(db) dbmclose()
236 #define dbm_firstkey(db) firstkey()
252 #if defined(I_DIRENT) && !defined(M_XENIX)
254 # define DIRENT dirent
257 # include <sys/ndir.h>
258 # define DIRENT direct
262 # include <ndir.h> /* may be wrong in the future */
264 # include <sys/dir.h>
266 # define DIRENT direct
271 typedef struct arg ARG;
272 typedef struct cmd CMD;
273 typedef struct formcmd FCMD;
274 typedef struct scanpat SPAT;
275 typedef struct stio STIO;
276 typedef struct sub SUBR;
277 typedef struct string STR;
278 typedef struct atbl ARRAY;
279 typedef struct htbl HASH;
280 typedef struct regexp REGEXP;
281 typedef struct stabptrs STBP;
282 typedef struct stab STAB;
296 #if defined(iAPX286) || defined(M_I286) || defined(I80286) || defined(M_I86)
308 EXT char *Yes INIT("1");
309 EXT char *No INIT("");
313 /* Note: cmd.c assumes that it can use && to produce one of these values! */
319 #else /* !CRIPPLED_CC */
320 #define str_true(str) (Str = (str), \
322 ((*Str->str_ptr > '0' || \
323 Str->str_cur > 1 || \
324 (Str->str_cur && *Str->str_ptr != '0')) ? 1 : 0) \
326 (Str->str_nok ? (Str->str_u.str_nval != 0.0) : 0 ) ))
327 #endif /* CRIPPLED_CC */
330 #define str_peek(str) (Str = (str), \
334 (sprintf(tokenbuf,"num(%g)",Str->str_u.str_nval), \
343 #define str_get(str) (Str = (str), tainted |= Str->str_tainted, \
344 (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
346 #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
348 #endif /* CRIPPLED_CC */
352 #else /* !CRIPPLED_CC */
354 #define str_gnum(str) (Str = (str), tainted |= Str->str_tainted, \
355 (Str->str_nok ? Str->str_u.str_nval : str_2num(Str)))
357 #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_u.str_nval : str_2num(Str)))
359 #endif /* CRIPPLED_CC */
362 #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
364 #define STR_GROW(str,len) if ((str)->str_len < (len)) str_grow(str,len)
367 #define BYTEORDER 0x1234
370 #if defined(htonl) && !defined(HTONL)
373 #if defined(htons) && !defined(HTONS)
376 #if defined(ntohl) && !defined(NTOHL)
379 #if defined(ntohs) && !defined(NTOHS)
383 #if (BYTEORDER != 0x4321) && (BYTEORDER != 0x87654321)
389 #define htons my_swap
390 #define htonl my_htonl
391 #define ntohs my_swap
392 #define ntohl my_ntohl
395 #if (BYTEORDER == 0x4321) || (BYTEORDER == 0x87654321)
404 #define U_S(what) ((unsigned short)(what))
405 #define U_I(what) ((unsigned int)(what))
406 #define U_L(what) ((unsigned long)(what))
408 unsigned long castulong();
409 #define U_S(what) ((unsigned int)castulong(what))
410 #define U_I(what) ((unsigned int)castulong(what))
411 #define U_L(what) (castulong(what))
456 int eval(); /* this evaluates expressions */
457 int do_eval(); /* this evaluates eval operator */
469 char *str_append_till();
507 EXT line_t line INIT(0);
508 EXT line_t subline INIT(0);
509 EXT STR *subname INIT(Nullstr);
510 EXT int arybase INIT(0);
518 EXT struct outrec outrec;
519 EXT struct outrec toprec;
521 EXT STAB *stdinstab INIT(Nullstab);
522 EXT STAB *last_in_stab INIT(Nullstab);
523 EXT STAB *defstab INIT(Nullstab);
524 EXT STAB *argvstab INIT(Nullstab);
525 EXT STAB *envstab INIT(Nullstab);
526 EXT STAB *sigstab INIT(Nullstab);
527 EXT STAB *defoutstab INIT(Nullstab);
528 EXT STAB *curoutstab INIT(Nullstab);
529 EXT STAB *argvoutstab INIT(Nullstab);
530 EXT STAB *incstab INIT(Nullstab);
531 EXT STAB *leftstab INIT(Nullstab);
532 EXT STAB *amperstab INIT(Nullstab);
533 EXT STAB *rightstab INIT(Nullstab);
534 EXT STAB *DBstab INIT(Nullstab);
535 EXT STAB *DBsub INIT(Nullstab);
537 EXT HASH *defstash; /* main symbol table */
538 EXT HASH *curstash; /* symbol table for current package */
539 EXT HASH *debstash; /* symbol table for perldb package */
541 EXT STR *curstname; /* name of current package */
543 EXT STR *freestrroot INIT(Nullstr);
544 EXT STR *lastretstr INIT(Nullstr);
545 EXT STR *DBsingle INIT(Nullstr);
551 EXT char *origfilename;
552 EXT FILE * VOLATILE rsfp;
556 EXT char *oldoldbufptr;
559 EXT STR *linestr INIT(Nullstr);
561 EXT int record_separator INIT('\n');
562 EXT int rslen INIT(1);
563 EXT char *ofs INIT(Nullch);
564 EXT int ofslen INIT(0);
565 EXT char *ors INIT(Nullch);
566 EXT int orslen INIT(0);
567 EXT char *ofmt INIT(Nullch);
568 EXT char *inplace INIT(Nullch);
569 EXT char *nointrp INIT("");
571 EXT bool preprocess INIT(FALSE);
572 EXT bool minus_n INIT(FALSE);
573 EXT bool minus_p INIT(FALSE);
574 EXT bool minus_a INIT(FALSE);
575 EXT bool doswitches INIT(FALSE);
576 EXT bool dowarn INIT(FALSE);
577 EXT bool allstabs INIT(FALSE); /* init all customary symbols in symbol table?*/
578 EXT bool sawampersand INIT(FALSE); /* must save all match strings */
579 EXT bool sawstudy INIT(FALSE); /* do fbminstr on all strings */
580 EXT bool sawi INIT(FALSE); /* study must assume case insensitive */
581 EXT bool sawvec INIT(FALSE);
582 EXT bool localizing INIT(FALSE); /* are we processing a local() list? */
585 char *cshname INIT(CSH);
590 EXT bool tainted INIT(FALSE); /* using variables controlled by $< */
593 #define TMPPATH "/tmp/perl-eXXXXXX"
595 EXT FILE *e_fp INIT(Nullfp);
597 EXT char tokenbuf[256];
598 EXT int expectterm INIT(TRUE); /* how to interpret ambiguous tokens */
599 EXT VOLATILE int in_eval INIT(FALSE); /* trap fatal errors? */
600 EXT int multiline INIT(0); /* $*--do strings hold >1 line? */
601 EXT int forkprocess; /* so do_open |- can return proc# */
602 EXT int do_undump INIT(0); /* -u or dump seen? */
603 EXT int error_count INIT(0); /* how many errors so far, max 10 */
604 EXT int multi_start INIT(0); /* 1st line of multi-line string */
605 EXT int multi_end INIT(0); /* last line of multi-line string */
606 EXT int multi_open INIT(0); /* delimiter of said string */
607 EXT int multi_close INIT(0); /* delimiter of said string */
610 /* char *str_get(); */
615 EXT struct stat statbuf;
616 EXT struct stat statcache;
617 STAB *statstab INIT(Nullstab);
619 EXT struct tms timesbuf;
631 EXT VOLATILE int debug INIT(0);
632 EXT int dlevel INIT(0);
633 EXT int dlmax INIT(128);
638 EXT int perldb INIT(0);
640 EXT line_t cmdline INIT(NOLINE);
646 /* runtime control stuff */
649 char *loop_label; /* what the loop was called, if anything */
650 int loop_sp; /* stack pointer to copy stuff down to */
654 EXT int loop_ptr INIT(-1);
655 EXT int loop_max INIT(128);
659 EXT char * VOLATILE goto_targ INIT(Nullch); /* cmd_exec gets strange when set */
661 EXT ARRAY *stack; /* THE STACK */
663 EXT ARRAY * VOLATILE savestack; /* to save non-local values on */
665 EXT ARRAY *tosave; /* strings to save on recursive subroutine */
667 EXT ARRAY *lineary; /* lines of script for debugger */
669 EXT ARRAY *pidstatary; /* keep pids and statuses by fd for mypopen */
671 EXT int *di; /* for tmp use in debuggers */
677 struct tm *gmtime(), *localtime();
679 char *index(), *rindex();
680 char *strcpy(), *strcat();
686 #define UNLINK unlink
691 #define setreuid(r,e) setresuid(r,e,-1)
697 #define setregid(r,e) setresgid(r,e,-1)