1 /* $RCSfile: perl.h,v $$Revision: 4.0.1.3 $$Date: 91/06/10 01:25:10 $
3 * Copyright (c) 1991, Larry Wall
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.
9 * Revision 4.0.1.3 91/06/10 01:25:10 lwall
10 * patch10: certain pattern optimizations were botched
12 * Revision 4.0.1.2 91/06/07 11:28:33 lwall
13 * patch4: new copyright notice
14 * patch4: made some allowances for "semi-standard" C
15 * patch4: many, many itty-bitty portability fixes
17 * Revision 4.0.1.1 91/04/11 17:49:51 lwall
18 * patch1: hopefully straightened out some of the Xenix mess
20 * Revision 4.0 91/03/20 01:37:56 lwall
29 /* This stuff now in the MS-DOS config.h file. */
33 * The following symbols are defined if your operating system supports
34 * functions by that name. All Unixes I know of support them, thus they
35 * are not checked by the configuration script, but are directly defined
50 * The following symbols are defined if your operating system supports
51 * password and group functions in general. All Unix systems do.
58 #if defined(__STDC__) || defined(_AIX) || defined(__stdc__)
62 #if defined(HASVOLATILE) || defined(STANDARD_C)
63 #define VOLATILE volatile
82 # define getpgrp getpgrp2
89 # define setpgrp setpgrp2
96 #ifdef PARAM_NEEDS_TYPES
97 #include <sys/types.h>
99 #include <sys/param.h>
102 /* Use all the "standard" definitions */
105 #endif /* STANDARD_C */
107 #if defined(HAS_MEMCMP) && defined(mips) && BYTEORDER == 0x1234
115 extern char * memcpy(), *memset();
117 # endif /* ndef memcpy */
118 # endif /* ndef STANDARD_C */
121 # define bcopy(s1,s2,l) memcpy(s2,s1,l)
124 # define bzero(s,l) memset(s,0,l)
126 #endif /* HAS_MEMCPY */
128 #ifndef HAS_BCMP /* prefer bcmp slightly 'cuz it doesn't order */
130 # define bcmp(s1,s2,l) memcmp(s1,s2,l)
134 #ifndef _TYPES_ /* If types.h defines this it's easy. */
135 #ifndef major /* Does everyone's types.h define this? */
136 #include <sys/types.h>
141 #include <netinet/in.h>
144 #include <sys/stat.h>
151 # ifdef SYSTIMEKERNEL
154 # include <sys/time.h>
155 # ifdef SYSTIMEKERNEL
161 #include <sys/times.h>
164 #if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR))
171 extern int errno; /* ANSI allows errno to be an lvalue expr */
180 extern char *sys_errlist[];
181 #define strerror(e) ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e])
187 #include <sys/ioctl.h>
191 #if defined(mc300) || defined(mc500) || defined(mc700) /* MASSCOMP */
192 #ifdef HAS_SOCKETPAIR
193 #undef HAS_SOCKETPAIR
221 #undef NULL /* suppress redefinition message */
227 #define NULL 0 /* silly thing is, we don't even use this */
229 #define dbm_fetch(db,dkey) fetch(dkey)
230 #define dbm_delete(db,dkey) delete(dkey)
231 #define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent)
232 #define dbm_close(db) dbmclose()
233 #define dbm_firstkey(db) firstkey()
234 #endif /* HAS_ODBM */
235 #endif /* HAS_NDBM */
236 #endif /* HAS_GDBM */
250 #if defined(I_DIRENT)
252 # define DIRENT dirent
255 # include <sys/ndir.h>
256 # define DIRENT direct
260 # include <ndir.h> /* may be wrong in the future */
262 # include <sys/dir.h>
264 # define DIRENT direct
270 /* work around botch in SunOS 4.0.1 and 4.0.2 */
272 # define fputs(str,fp) fprintf(fp,"%s",str)
277 * The following gobbledygook brought to you on behalf of __STDC__.
278 * (I could just use #ifndef __STDC__, but this is more bulletproof
279 * in the face of half-implementations.)
284 # define S_IFMT _S_IFMT
286 # define S_IFMT 0170000
291 # define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
295 # define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR)
300 # define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK)
302 # define S_ISBLK(m) (0)
307 # define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
312 # define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
314 # define S_ISFIFO(m) (0)
320 # define S_ISLNK(m) _S_ISLNK(m)
323 # define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK)
326 # define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
328 # define S_ISLNK(m) (0)
336 # define S_ISSOCK(m) _S_ISSOCK(m)
339 # define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK)
342 # define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK)
344 # define S_ISSOCK(m) (0)
352 # define S_IRUSR S_IREAD
353 # define S_IWUSR S_IWRITE
354 # define S_IXUSR S_IEXEC
356 # define S_IRUSR 0400
357 # define S_IWUSR 0200
358 # define S_IXUSR 0100
360 # define S_IRGRP (S_IRUSR>>3)
361 # define S_IWGRP (S_IWUSR>>3)
362 # define S_IXGRP (S_IXUSR>>3)
363 # define S_IROTH (S_IRUSR>>6)
364 # define S_IWOTH (S_IWUSR>>6)
365 # define S_IXOTH (S_IXUSR>>6)
369 # define S_ISUID 04000
373 # define S_ISGID 02000
380 typedef unsigned int STRLEN;
382 typedef struct arg ARG;
383 typedef struct cmd CMD;
384 typedef struct formcmd FCMD;
385 typedef struct scanpat SPAT;
386 typedef struct stio STIO;
387 typedef struct sub SUBR;
388 typedef struct string STR;
389 typedef struct atbl ARRAY;
390 typedef struct htbl HASH;
391 typedef struct regexp REGEXP;
392 typedef struct stabptrs STBP;
393 typedef struct stab STAB;
394 typedef struct callsave CSV;
408 #if defined(iAPX286) || defined(M_I286) || defined(I80286)
420 EXT char *Yes INIT("1");
421 EXT char *No INIT("");
425 /* Note: cmd.c assumes that it can use && to produce one of these values! */
431 #else /* !CRIPPLED_CC */
432 #define str_true(str) (Str = (str), \
434 ((*Str->str_ptr > '0' || \
435 Str->str_cur > 1 || \
436 (Str->str_cur && *Str->str_ptr != '0')) ? 1 : 0) \
438 (Str->str_nok ? (Str->str_u.str_nval != 0.0) : 0 ) ))
439 #endif /* CRIPPLED_CC */
442 #define str_peek(str) (Str = (str), \
446 (sprintf(tokenbuf,"num(%g)",Str->str_u.str_nval), \
455 #define str_get(str) (Str = (str), tainted |= Str->str_tainted, \
456 (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
458 #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
460 #endif /* CRIPPLED_CC */
464 #else /* !CRIPPLED_CC */
466 #define str_gnum(str) (Str = (str), tainted |= Str->str_tainted, \
467 (Str->str_nok ? Str->str_u.str_nval : str_2num(Str)))
469 #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_u.str_nval : str_2num(Str)))
471 #endif /* CRIPPLED_CC */
474 #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
477 #define STR_GROW(str,len) if ((str)->str_len < (len)) str_grow(str,len)
478 #define Str_Grow str_grow
480 /* extra parentheses intentionally NOT placed around "len"! */
481 #define STR_GROW(str,len) if ((str)->str_len < (unsigned long)len) \
482 str_grow(str,(unsigned long)len)
483 #define Str_Grow(str,len) str_grow(str,(unsigned long)(len))
487 #define BYTEORDER 0x1234
490 #if defined(htonl) && !defined(HAS_HTONL)
493 #if defined(htons) && !defined(HAS_HTONS)
496 #if defined(ntohl) && !defined(HAS_NTOHL)
499 #if defined(ntohs) && !defined(HAS_NTOHS)
503 #if (BYTEORDER & 0xffff) != 0x4321
509 #define htons my_swap
510 #define htonl my_htonl
511 #define ntohs my_swap
512 #define ntohl my_ntohl
515 #if (BYTEORDER & 0xffff) == 0x4321
524 #define U_S(what) ((unsigned short)(what))
525 #define U_I(what) ((unsigned int)(what))
526 #define U_L(what) ((unsigned long)(what))
528 unsigned long castulong();
529 #define U_S(what) ((unsigned int)castulong(what))
530 #define U_I(what) ((unsigned int)castulong(what))
531 #define U_L(what) (castulong(what))
576 int eval(); /* this evaluates expressions */
577 int do_eval(); /* this evaluates eval operator */
589 char *str_append_till();
631 EXT char **origenviron;
632 extern char **environ;
634 EXT line_t subline INIT(0);
635 EXT STR *subname INIT(Nullstr);
636 EXT int arybase INIT(0);
644 EXT struct outrec outrec;
645 EXT struct outrec toprec;
647 EXT STAB *stdinstab INIT(Nullstab);
648 EXT STAB *last_in_stab INIT(Nullstab);
649 EXT STAB *defstab INIT(Nullstab);
650 EXT STAB *argvstab INIT(Nullstab);
651 EXT STAB *envstab INIT(Nullstab);
652 EXT STAB *sigstab INIT(Nullstab);
653 EXT STAB *defoutstab INIT(Nullstab);
654 EXT STAB *curoutstab INIT(Nullstab);
655 EXT STAB *argvoutstab INIT(Nullstab);
656 EXT STAB *incstab INIT(Nullstab);
657 EXT STAB *leftstab INIT(Nullstab);
658 EXT STAB *amperstab INIT(Nullstab);
659 EXT STAB *rightstab INIT(Nullstab);
660 EXT STAB *DBstab INIT(Nullstab);
661 EXT STAB *DBline INIT(Nullstab);
662 EXT STAB *DBsub INIT(Nullstab);
664 EXT HASH *defstash; /* main symbol table */
665 EXT HASH *curstash; /* symbol table for current package */
666 EXT HASH *debstash; /* symbol table for perldb package */
668 EXT STR *curstname; /* name of current package */
670 EXT STR *freestrroot INIT(Nullstr);
671 EXT STR *lastretstr INIT(Nullstr);
672 EXT STR *DBsingle INIT(Nullstr);
673 EXT STR *DBtrace INIT(Nullstr);
674 EXT STR *DBsignal INIT(Nullstr);
679 EXT char *hexdigit INIT("0123456789abcdef0123456789ABCDEF");
680 EXT char *origfilename;
681 EXT FILE * VOLATILE rsfp;
685 EXT char *oldoldbufptr;
688 EXT STR *linestr INIT(Nullstr);
690 EXT char *rs INIT("\n");
691 EXT int rschar INIT('\n'); /* final char of rs, or 0777 if none */
692 EXT int rslen INIT(1);
693 EXT char *ofs INIT(Nullch);
694 EXT int ofslen INIT(0);
695 EXT char *ors INIT(Nullch);
696 EXT int orslen INIT(0);
697 EXT char *ofmt INIT(Nullch);
698 EXT char *inplace INIT(Nullch);
699 EXT char *nointrp INIT("");
701 EXT bool preprocess INIT(FALSE);
702 EXT bool minus_n INIT(FALSE);
703 EXT bool minus_p INIT(FALSE);
704 EXT bool minus_l INIT(FALSE);
705 EXT bool minus_a INIT(FALSE);
706 EXT bool doswitches INIT(FALSE);
707 EXT bool dowarn INIT(FALSE);
708 EXT bool doextract INIT(FALSE);
709 EXT bool allstabs INIT(FALSE); /* init all customary symbols in symbol table?*/
710 EXT bool sawampersand INIT(FALSE); /* must save all match strings */
711 EXT bool sawstudy INIT(FALSE); /* do fbminstr on all strings */
712 EXT bool sawi INIT(FALSE); /* study must assume case insensitive */
713 EXT bool sawvec INIT(FALSE);
714 EXT bool localizing INIT(FALSE); /* are we processing a local() list? */
719 EXT int maxsysfd INIT(MAXSYSFD); /* top fd to pass to subprocesses */
722 char *cshname INIT(CSH);
727 EXT bool tainted INIT(FALSE); /* using variables controlled by $< */
731 #define TMPPATH "/tmp/perl-eXXXXXX"
733 #define TMPPATH "plXXXXXX"
736 EXT FILE *e_fp INIT(Nullfp);
738 EXT char tokenbuf[256];
739 EXT int expectterm INIT(TRUE); /* how to interpret ambiguous tokens */
740 EXT VOLATILE int in_eval INIT(FALSE); /* trap fatal errors? */
741 EXT int multiline INIT(0); /* $*--do strings hold >1 line? */
742 EXT int forkprocess; /* so do_open |- can return proc# */
743 EXT int do_undump INIT(0); /* -u or dump seen? */
744 EXT int error_count INIT(0); /* how many errors so far, max 10 */
745 EXT int multi_start INIT(0); /* 1st line of multi-line string */
746 EXT int multi_end INIT(0); /* last line of multi-line string */
747 EXT int multi_open INIT(0); /* delimiter of said string */
748 EXT int multi_close INIT(0); /* delimiter of said string */
751 /* char *str_get(); */
757 EXT struct stat statbuf;
758 EXT struct stat statcache;
759 STAB *statstab INIT(Nullstab);
762 EXT struct tms timesbuf;
775 EXT VOLATILE int debug INIT(0);
776 EXT int dlevel INIT(0);
777 EXT int dlmax INIT(128);
782 EXT int perldb INIT(0);
783 #define YYMAXDEPTH 300
785 EXT line_t cmdline INIT(NOLINE);
791 /* runtime control stuff */
794 char *loop_label; /* what the loop was called, if anything */
795 int loop_sp; /* stack pointer to copy stuff down to */
799 EXT int loop_ptr INIT(-1);
800 EXT int loop_max INIT(128);
804 EXT char * VOLATILE goto_targ INIT(Nullch); /* cmd_exec gets strange when set */
812 EXT ARRAY *stack; /* THE STACK */
814 EXT ARRAY * VOLATILE savestack; /* to save non-local values on */
816 EXT ARRAY *tosave; /* strings to save on recursive subroutine */
818 EXT ARRAY *lineary; /* lines of script for debugger */
819 EXT ARRAY *dbargs; /* args to call listed by caller function */
821 EXT ARRAY *fdpid; /* keep fd-to-pid mappings for mypopen */
822 EXT HASH *pidstatus; /* keep pid-to-status mappings for waitpid */
824 EXT int *di; /* for tmp use in debuggers */
828 /* Fix these up for __STDC__ */
829 EXT long basetime INIT(0);
832 /* All of these are in stdlib.h or time.h for ANSI C */
835 struct tm *gmtime(), *localtime();
836 char *index(), *rindex();
837 char *strcpy(), *strcat();
838 #endif /* ! STANDARD_C */
844 #define UNLINK unlink
849 #define setreuid(r,e) setresuid(r,e,-1)
855 #define setregid(r,e) setresgid(r,e,-1)