1 /* $Header: perl.h,v 4.0 91/03/20 01:37:56 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 4.0 91/03/20 01:37:56 lwall
18 /* This stuff now in the MS-DOS config.h file. */
22 * The following symbols are defined if your operating system supports
23 * functions by that name. All Unixes I know of support them, thus they
24 * are not checked by the configuration script, but are directly defined
39 * The following symbols are defined if your operating system supports
40 * password and group functions in general. All Unix systems do.
47 #if defined(HASVOLATILE) || defined(__STDC__)
48 #define VOLATILE volatile
67 # define getpgrp getpgrp2
74 # define setpgrp setpgrp2
81 #include <sys/param.h> /* if this needs types.h we're still wrong */
84 /* Use all the "standard" definitions */
89 #if defined(HAS_MEMCMP) && defined(mips) && BYTEORDER == 0x1234
97 extern char * memcpy(), *memset();
99 # endif /* ndef memcpy */
100 # endif /* ndef __STDC__ */
102 #define bcopy(s1,s2,l) memcpy(s2,s1,l)
103 #define bzero(s,l) memset(s,0,l)
104 #endif /* HAS_MEMCPY */
106 #ifndef HAS_BCMP /* prefer bcmp slightly 'cuz it doesn't order */
107 #define bcmp(s1,s2,l) memcmp(s1,s2,l)
110 #ifndef _TYPES_ /* If types.h defines this it's easy. */
111 #ifndef major /* Does everyone's types.h define this? */
112 #include <sys/types.h>
117 #include <netinet/in.h>
120 #include <sys/stat.h>
127 # ifdef SYSTIMEKERNEL
130 # include <sys/time.h>
131 # ifdef SYSTIMEKERNEL
137 #include <sys/times.h>
140 #if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR))
147 extern int errno; /* ANSI allows errno to be an lvalue expr */
155 extern char *sys_errlist[];
156 #define strerror(e) ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e])
161 #include <sys/ioctl.h>
165 #if defined(mc300) || defined(mc500) || defined(mc700) /* MASSCOMP */
166 #ifdef HAS_SOCKETPAIR
167 #undef HAS_SOCKETPAIR
195 #undef NULL /* suppress redefinition message */
201 #define NULL 0 /* silly thing is, we don't even use this */
203 #define dbm_fetch(db,dkey) fetch(dkey)
204 #define dbm_delete(db,dkey) delete(dkey)
205 #define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent)
206 #define dbm_close(db) dbmclose()
207 #define dbm_firstkey(db) firstkey()
208 #endif /* HAS_ODBM */
209 #endif /* HAS_NDBM */
210 #endif /* HAS_GDBM */
224 #if defined(I_DIRENT) && !defined(M_XENIX)
226 # define DIRENT dirent
229 # include <sys/ndir.h>
230 # define DIRENT direct
234 # include <ndir.h> /* may be wrong in the future */
236 # include <sys/dir.h>
238 # define DIRENT direct
244 * The following gobbledygook brought to you on behalf of __STDC__.
245 * (I could just use #ifndef __STDC__, but this is more bulletproof
246 * in the face of half-implementations.)
251 # define S_IFMT _S_IFMT
253 # define S_IFMT 0170000
258 # define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
262 # define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR)
267 # define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK)
269 # define S_ISBLK(m) (0)
274 # define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
279 # define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
281 # define S_ISFIFO(m) (0)
287 # define S_ISLNK(m) _S_ISLNK(m)
290 # define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK)
293 # define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
295 # define S_ISLNK(m) (0)
303 # define S_ISSOCK(m) _S_ISSOCK(m)
306 # define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK)
309 # define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK)
311 # define S_ISSOCK(m) (0)
319 # define S_IRUSR S_IREAD
320 # define S_IWUSR S_IWRITE
321 # define S_IXUSR S_IEXEC
323 # define S_IRUSR 0400
324 # define S_IWUSR 0200
325 # define S_IXUSR 0100
327 # define S_IRGRP (S_IRUSR>>3)
328 # define S_IWGRP (S_IWUSR>>3)
329 # define S_IXGRP (S_IXUSR>>3)
330 # define S_IROTH (S_IRUSR>>6)
331 # define S_IWOTH (S_IWUSR>>6)
332 # define S_IXOTH (S_IXUSR>>6)
336 # define S_ISUID 04000
340 # define S_ISGID 02000
343 typedef unsigned int STRLEN;
345 typedef struct arg ARG;
346 typedef struct cmd CMD;
347 typedef struct formcmd FCMD;
348 typedef struct scanpat SPAT;
349 typedef struct stio STIO;
350 typedef struct sub SUBR;
351 typedef struct string STR;
352 typedef struct atbl ARRAY;
353 typedef struct htbl HASH;
354 typedef struct regexp REGEXP;
355 typedef struct stabptrs STBP;
356 typedef struct stab STAB;
357 typedef struct callsave CSV;
371 #if defined(iAPX286) || defined(M_I286) || defined(I80286)
383 EXT char *Yes INIT("1");
384 EXT char *No INIT("");
388 /* Note: cmd.c assumes that it can use && to produce one of these values! */
394 #else /* !CRIPPLED_CC */
395 #define str_true(str) (Str = (str), \
397 ((*Str->str_ptr > '0' || \
398 Str->str_cur > 1 || \
399 (Str->str_cur && *Str->str_ptr != '0')) ? 1 : 0) \
401 (Str->str_nok ? (Str->str_u.str_nval != 0.0) : 0 ) ))
402 #endif /* CRIPPLED_CC */
405 #define str_peek(str) (Str = (str), \
409 (sprintf(tokenbuf,"num(%g)",Str->str_u.str_nval), \
418 #define str_get(str) (Str = (str), tainted |= Str->str_tainted, \
419 (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
421 #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
423 #endif /* CRIPPLED_CC */
427 #else /* !CRIPPLED_CC */
429 #define str_gnum(str) (Str = (str), tainted |= Str->str_tainted, \
430 (Str->str_nok ? Str->str_u.str_nval : str_2num(Str)))
432 #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_u.str_nval : str_2num(Str)))
434 #endif /* CRIPPLED_CC */
437 #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
440 #define STR_GROW(str,len) if ((str)->str_len < (len)) str_grow(str,len)
441 #define Str_Grow str_grow
443 /* extra parentheses intentionally NOT placed around "len"! */
444 #define STR_GROW(str,len) if ((str)->str_len < (unsigned long)len) \
445 str_grow(str,(unsigned long)len)
446 #define Str_Grow(str,len) str_grow(str,(unsigned long)(len))
450 #define BYTEORDER 0x1234
453 #if defined(htonl) && !defined(HAS_HTONL)
456 #if defined(htons) && !defined(HAS_HTONS)
459 #if defined(ntohl) && !defined(HAS_NTOHL)
462 #if defined(ntohs) && !defined(HAS_NTOHS)
466 #if (BYTEORDER & 0xffff) != 0x4321
472 #define htons my_swap
473 #define htonl my_htonl
474 #define ntohs my_swap
475 #define ntohl my_ntohl
478 #if (BYTEORDER & 0xffff) == 0x4321
487 #define U_S(what) ((unsigned short)(what))
488 #define U_I(what) ((unsigned int)(what))
489 #define U_L(what) ((unsigned long)(what))
491 unsigned long castulong();
492 #define U_S(what) ((unsigned int)castulong(what))
493 #define U_I(what) ((unsigned int)castulong(what))
494 #define U_L(what) (castulong(what))
539 int eval(); /* this evaluates expressions */
540 int do_eval(); /* this evaluates eval operator */
552 char *str_append_till();
594 EXT char **origenviron;
595 EXT line_t subline INIT(0);
596 EXT STR *subname INIT(Nullstr);
597 EXT int arybase INIT(0);
605 EXT struct outrec outrec;
606 EXT struct outrec toprec;
608 EXT STAB *stdinstab INIT(Nullstab);
609 EXT STAB *last_in_stab INIT(Nullstab);
610 EXT STAB *defstab INIT(Nullstab);
611 EXT STAB *argvstab INIT(Nullstab);
612 EXT STAB *envstab INIT(Nullstab);
613 EXT STAB *sigstab INIT(Nullstab);
614 EXT STAB *defoutstab INIT(Nullstab);
615 EXT STAB *curoutstab INIT(Nullstab);
616 EXT STAB *argvoutstab INIT(Nullstab);
617 EXT STAB *incstab INIT(Nullstab);
618 EXT STAB *leftstab INIT(Nullstab);
619 EXT STAB *amperstab INIT(Nullstab);
620 EXT STAB *rightstab INIT(Nullstab);
621 EXT STAB *DBstab INIT(Nullstab);
622 EXT STAB *DBline INIT(Nullstab);
623 EXT STAB *DBsub INIT(Nullstab);
625 EXT HASH *defstash; /* main symbol table */
626 EXT HASH *curstash; /* symbol table for current package */
627 EXT HASH *debstash; /* symbol table for perldb package */
629 EXT STR *curstname; /* name of current package */
631 EXT STR *freestrroot INIT(Nullstr);
632 EXT STR *lastretstr INIT(Nullstr);
633 EXT STR *DBsingle INIT(Nullstr);
634 EXT STR *DBtrace INIT(Nullstr);
635 EXT STR *DBsignal INIT(Nullstr);
640 EXT char *hexdigit INIT("0123456789abcdef0123456789ABCDEF");
641 EXT char *origfilename;
642 EXT FILE * VOLATILE rsfp;
646 EXT char *oldoldbufptr;
649 EXT STR *linestr INIT(Nullstr);
651 EXT char *rs INIT("\n");
652 EXT int rschar INIT('\n'); /* final char of rs, or 0777 if none */
653 EXT int rslen INIT(1);
654 EXT char *ofs INIT(Nullch);
655 EXT int ofslen INIT(0);
656 EXT char *ors INIT(Nullch);
657 EXT int orslen INIT(0);
658 EXT char *ofmt INIT(Nullch);
659 EXT char *inplace INIT(Nullch);
660 EXT char *nointrp INIT("");
662 EXT bool preprocess INIT(FALSE);
663 EXT bool minus_n INIT(FALSE);
664 EXT bool minus_p INIT(FALSE);
665 EXT bool minus_l INIT(FALSE);
666 EXT bool minus_a INIT(FALSE);
667 EXT bool doswitches INIT(FALSE);
668 EXT bool dowarn INIT(FALSE);
669 EXT bool doextract INIT(FALSE);
670 EXT bool allstabs INIT(FALSE); /* init all customary symbols in symbol table?*/
671 EXT bool sawampersand INIT(FALSE); /* must save all match strings */
672 EXT bool sawstudy INIT(FALSE); /* do fbminstr on all strings */
673 EXT bool sawi INIT(FALSE); /* study must assume case insensitive */
674 EXT bool sawvec INIT(FALSE);
675 EXT bool localizing INIT(FALSE); /* are we processing a local() list? */
678 char *cshname INIT(CSH);
683 EXT bool tainted INIT(FALSE); /* using variables controlled by $< */
687 #define TMPPATH "/tmp/perl-eXXXXXX"
689 #define TMPPATH "plXXXXXX"
692 EXT FILE *e_fp INIT(Nullfp);
694 EXT char tokenbuf[256];
695 EXT int expectterm INIT(TRUE); /* how to interpret ambiguous tokens */
696 EXT VOLATILE int in_eval INIT(FALSE); /* trap fatal errors? */
697 EXT int multiline INIT(0); /* $*--do strings hold >1 line? */
698 EXT int forkprocess; /* so do_open |- can return proc# */
699 EXT int do_undump INIT(0); /* -u or dump seen? */
700 EXT int error_count INIT(0); /* how many errors so far, max 10 */
701 EXT int multi_start INIT(0); /* 1st line of multi-line string */
702 EXT int multi_end INIT(0); /* last line of multi-line string */
703 EXT int multi_open INIT(0); /* delimiter of said string */
704 EXT int multi_close INIT(0); /* delimiter of said string */
707 /* char *str_get(); */
712 EXT struct stat statbuf;
713 EXT struct stat statcache;
714 STAB *statstab INIT(Nullstab);
717 EXT struct tms timesbuf;
730 EXT VOLATILE int debug INIT(0);
731 EXT int dlevel INIT(0);
732 EXT int dlmax INIT(128);
737 EXT int perldb INIT(0);
738 #define YYMAXDEPTH 300
740 EXT line_t cmdline INIT(NOLINE);
746 /* runtime control stuff */
749 char *loop_label; /* what the loop was called, if anything */
750 int loop_sp; /* stack pointer to copy stuff down to */
754 EXT int loop_ptr INIT(-1);
755 EXT int loop_max INIT(128);
759 EXT char * VOLATILE goto_targ INIT(Nullch); /* cmd_exec gets strange when set */
767 EXT ARRAY *stack; /* THE STACK */
769 EXT ARRAY * VOLATILE savestack; /* to save non-local values on */
771 EXT ARRAY *tosave; /* strings to save on recursive subroutine */
773 EXT ARRAY *lineary; /* lines of script for debugger */
774 EXT ARRAY *dbargs; /* args to call listed by caller function */
776 EXT ARRAY *fdpid; /* keep fd-to-pid mappings for mypopen */
777 EXT HASH *pidstatus; /* keep pid-to-status mappings for waitpid */
779 EXT int *di; /* for tmp use in debuggers */
783 /* Fix these up for __STDC__ */
784 EXT long basetime INIT(0);
787 /* All of these are in stdlib.h or time.h for ANSI C */
790 struct tm *gmtime(), *localtime();
791 char *index(), *rindex();
792 char *strcpy(), *strcat();
793 #endif /* ! __STDC__ */
799 #define UNLINK unlink
804 #define setreuid(r,e) setresuid(r,e,-1)
810 #define setregid(r,e) setresgid(r,e,-1)