1 /* $RCSfile: perl.h,v $$Revision: 4.0.1.1 $$Date: 91/04/11 17:49:51 $
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.1.1 91/04/11 17:49:51 lwall
10 * patch1: hopefully straightened out some of the Xenix mess
12 * Revision 4.0 91/03/20 01:37:56 lwall
21 /* This stuff now in the MS-DOS config.h file. */
25 * The following symbols are defined if your operating system supports
26 * functions by that name. All Unixes I know of support them, thus they
27 * are not checked by the configuration script, but are directly defined
42 * The following symbols are defined if your operating system supports
43 * password and group functions in general. All Unix systems do.
50 #if defined(HASVOLATILE) || defined(__STDC__)
51 #define VOLATILE volatile
70 # define getpgrp getpgrp2
77 # define setpgrp setpgrp2
84 #include <sys/param.h> /* if this needs types.h we're still wrong */
87 /* Use all the "standard" definitions */
92 #if defined(HAS_MEMCMP) && defined(mips) && BYTEORDER == 0x1234
100 extern char * memcpy(), *memset();
102 # endif /* ndef memcpy */
103 # endif /* ndef __STDC__ */
105 #define bcopy(s1,s2,l) memcpy(s2,s1,l)
106 #define bzero(s,l) memset(s,0,l)
107 #endif /* HAS_MEMCPY */
109 #ifndef HAS_BCMP /* prefer bcmp slightly 'cuz it doesn't order */
110 #define bcmp(s1,s2,l) memcmp(s1,s2,l)
113 #ifndef _TYPES_ /* If types.h defines this it's easy. */
114 #ifndef major /* Does everyone's types.h define this? */
115 #include <sys/types.h>
120 #include <netinet/in.h>
123 #include <sys/stat.h>
130 # ifdef SYSTIMEKERNEL
133 # include <sys/time.h>
134 # ifdef SYSTIMEKERNEL
140 #include <sys/times.h>
143 #if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR))
150 extern int errno; /* ANSI allows errno to be an lvalue expr */
159 extern char *sys_errlist[];
160 #define strerror(e) ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e])
166 #include <sys/ioctl.h>
170 #if defined(mc300) || defined(mc500) || defined(mc700) /* MASSCOMP */
171 #ifdef HAS_SOCKETPAIR
172 #undef HAS_SOCKETPAIR
200 #undef NULL /* suppress redefinition message */
206 #define NULL 0 /* silly thing is, we don't even use this */
208 #define dbm_fetch(db,dkey) fetch(dkey)
209 #define dbm_delete(db,dkey) delete(dkey)
210 #define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent)
211 #define dbm_close(db) dbmclose()
212 #define dbm_firstkey(db) firstkey()
213 #endif /* HAS_ODBM */
214 #endif /* HAS_NDBM */
215 #endif /* HAS_GDBM */
229 #if defined(I_DIRENT)
231 # define DIRENT dirent
234 # include <sys/ndir.h>
235 # define DIRENT direct
239 # include <ndir.h> /* may be wrong in the future */
241 # include <sys/dir.h>
243 # define DIRENT direct
249 * The following gobbledygook brought to you on behalf of __STDC__.
250 * (I could just use #ifndef __STDC__, but this is more bulletproof
251 * in the face of half-implementations.)
256 # define S_IFMT _S_IFMT
258 # define S_IFMT 0170000
263 # define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
267 # define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR)
272 # define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK)
274 # define S_ISBLK(m) (0)
279 # define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
284 # define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
286 # define S_ISFIFO(m) (0)
292 # define S_ISLNK(m) _S_ISLNK(m)
295 # define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK)
298 # define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
300 # define S_ISLNK(m) (0)
308 # define S_ISSOCK(m) _S_ISSOCK(m)
311 # define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK)
314 # define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK)
316 # define S_ISSOCK(m) (0)
324 # define S_IRUSR S_IREAD
325 # define S_IWUSR S_IWRITE
326 # define S_IXUSR S_IEXEC
328 # define S_IRUSR 0400
329 # define S_IWUSR 0200
330 # define S_IXUSR 0100
332 # define S_IRGRP (S_IRUSR>>3)
333 # define S_IWGRP (S_IWUSR>>3)
334 # define S_IXGRP (S_IXUSR>>3)
335 # define S_IROTH (S_IRUSR>>6)
336 # define S_IWOTH (S_IWUSR>>6)
337 # define S_IXOTH (S_IXUSR>>6)
341 # define S_ISUID 04000
345 # define S_ISGID 02000
348 typedef unsigned int STRLEN;
350 typedef struct arg ARG;
351 typedef struct cmd CMD;
352 typedef struct formcmd FCMD;
353 typedef struct scanpat SPAT;
354 typedef struct stio STIO;
355 typedef struct sub SUBR;
356 typedef struct string STR;
357 typedef struct atbl ARRAY;
358 typedef struct htbl HASH;
359 typedef struct regexp REGEXP;
360 typedef struct stabptrs STBP;
361 typedef struct stab STAB;
362 typedef struct callsave CSV;
376 #if defined(iAPX286) || defined(M_I286) || defined(I80286)
388 EXT char *Yes INIT("1");
389 EXT char *No INIT("");
393 /* Note: cmd.c assumes that it can use && to produce one of these values! */
399 #else /* !CRIPPLED_CC */
400 #define str_true(str) (Str = (str), \
402 ((*Str->str_ptr > '0' || \
403 Str->str_cur > 1 || \
404 (Str->str_cur && *Str->str_ptr != '0')) ? 1 : 0) \
406 (Str->str_nok ? (Str->str_u.str_nval != 0.0) : 0 ) ))
407 #endif /* CRIPPLED_CC */
410 #define str_peek(str) (Str = (str), \
414 (sprintf(tokenbuf,"num(%g)",Str->str_u.str_nval), \
423 #define str_get(str) (Str = (str), tainted |= Str->str_tainted, \
424 (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
426 #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
428 #endif /* CRIPPLED_CC */
432 #else /* !CRIPPLED_CC */
434 #define str_gnum(str) (Str = (str), tainted |= Str->str_tainted, \
435 (Str->str_nok ? Str->str_u.str_nval : str_2num(Str)))
437 #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_u.str_nval : str_2num(Str)))
439 #endif /* CRIPPLED_CC */
442 #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
445 #define STR_GROW(str,len) if ((str)->str_len < (len)) str_grow(str,len)
446 #define Str_Grow str_grow
448 /* extra parentheses intentionally NOT placed around "len"! */
449 #define STR_GROW(str,len) if ((str)->str_len < (unsigned long)len) \
450 str_grow(str,(unsigned long)len)
451 #define Str_Grow(str,len) str_grow(str,(unsigned long)(len))
455 #define BYTEORDER 0x1234
458 #if defined(htonl) && !defined(HAS_HTONL)
461 #if defined(htons) && !defined(HAS_HTONS)
464 #if defined(ntohl) && !defined(HAS_NTOHL)
467 #if defined(ntohs) && !defined(HAS_NTOHS)
471 #if (BYTEORDER & 0xffff) != 0x4321
477 #define htons my_swap
478 #define htonl my_htonl
479 #define ntohs my_swap
480 #define ntohl my_ntohl
483 #if (BYTEORDER & 0xffff) == 0x4321
492 #define U_S(what) ((unsigned short)(what))
493 #define U_I(what) ((unsigned int)(what))
494 #define U_L(what) ((unsigned long)(what))
496 unsigned long castulong();
497 #define U_S(what) ((unsigned int)castulong(what))
498 #define U_I(what) ((unsigned int)castulong(what))
499 #define U_L(what) (castulong(what))
544 int eval(); /* this evaluates expressions */
545 int do_eval(); /* this evaluates eval operator */
557 char *str_append_till();
599 EXT char **origenviron;
600 extern char **environ;
602 EXT line_t subline INIT(0);
603 EXT STR *subname INIT(Nullstr);
604 EXT int arybase INIT(0);
612 EXT struct outrec outrec;
613 EXT struct outrec toprec;
615 EXT STAB *stdinstab INIT(Nullstab);
616 EXT STAB *last_in_stab INIT(Nullstab);
617 EXT STAB *defstab INIT(Nullstab);
618 EXT STAB *argvstab INIT(Nullstab);
619 EXT STAB *envstab INIT(Nullstab);
620 EXT STAB *sigstab INIT(Nullstab);
621 EXT STAB *defoutstab INIT(Nullstab);
622 EXT STAB *curoutstab INIT(Nullstab);
623 EXT STAB *argvoutstab INIT(Nullstab);
624 EXT STAB *incstab INIT(Nullstab);
625 EXT STAB *leftstab INIT(Nullstab);
626 EXT STAB *amperstab INIT(Nullstab);
627 EXT STAB *rightstab INIT(Nullstab);
628 EXT STAB *DBstab INIT(Nullstab);
629 EXT STAB *DBline INIT(Nullstab);
630 EXT STAB *DBsub INIT(Nullstab);
632 EXT HASH *defstash; /* main symbol table */
633 EXT HASH *curstash; /* symbol table for current package */
634 EXT HASH *debstash; /* symbol table for perldb package */
636 EXT STR *curstname; /* name of current package */
638 EXT STR *freestrroot INIT(Nullstr);
639 EXT STR *lastretstr INIT(Nullstr);
640 EXT STR *DBsingle INIT(Nullstr);
641 EXT STR *DBtrace INIT(Nullstr);
642 EXT STR *DBsignal INIT(Nullstr);
647 EXT char *hexdigit INIT("0123456789abcdef0123456789ABCDEF");
648 EXT char *origfilename;
649 EXT FILE * VOLATILE rsfp;
653 EXT char *oldoldbufptr;
656 EXT STR *linestr INIT(Nullstr);
658 EXT char *rs INIT("\n");
659 EXT int rschar INIT('\n'); /* final char of rs, or 0777 if none */
660 EXT int rslen INIT(1);
661 EXT char *ofs INIT(Nullch);
662 EXT int ofslen INIT(0);
663 EXT char *ors INIT(Nullch);
664 EXT int orslen INIT(0);
665 EXT char *ofmt INIT(Nullch);
666 EXT char *inplace INIT(Nullch);
667 EXT char *nointrp INIT("");
669 EXT bool preprocess INIT(FALSE);
670 EXT bool minus_n INIT(FALSE);
671 EXT bool minus_p INIT(FALSE);
672 EXT bool minus_l INIT(FALSE);
673 EXT bool minus_a INIT(FALSE);
674 EXT bool doswitches INIT(FALSE);
675 EXT bool dowarn INIT(FALSE);
676 EXT bool doextract INIT(FALSE);
677 EXT bool allstabs INIT(FALSE); /* init all customary symbols in symbol table?*/
678 EXT bool sawampersand INIT(FALSE); /* must save all match strings */
679 EXT bool sawstudy INIT(FALSE); /* do fbminstr on all strings */
680 EXT bool sawi INIT(FALSE); /* study must assume case insensitive */
681 EXT bool sawvec INIT(FALSE);
682 EXT bool localizing INIT(FALSE); /* are we processing a local() list? */
685 char *cshname INIT(CSH);
690 EXT bool tainted INIT(FALSE); /* using variables controlled by $< */
694 #define TMPPATH "/tmp/perl-eXXXXXX"
696 #define TMPPATH "plXXXXXX"
699 EXT FILE *e_fp INIT(Nullfp);
701 EXT char tokenbuf[256];
702 EXT int expectterm INIT(TRUE); /* how to interpret ambiguous tokens */
703 EXT VOLATILE int in_eval INIT(FALSE); /* trap fatal errors? */
704 EXT int multiline INIT(0); /* $*--do strings hold >1 line? */
705 EXT int forkprocess; /* so do_open |- can return proc# */
706 EXT int do_undump INIT(0); /* -u or dump seen? */
707 EXT int error_count INIT(0); /* how many errors so far, max 10 */
708 EXT int multi_start INIT(0); /* 1st line of multi-line string */
709 EXT int multi_end INIT(0); /* last line of multi-line string */
710 EXT int multi_open INIT(0); /* delimiter of said string */
711 EXT int multi_close INIT(0); /* delimiter of said string */
714 /* char *str_get(); */
719 EXT struct stat statbuf;
720 EXT struct stat statcache;
721 STAB *statstab INIT(Nullstab);
724 EXT struct tms timesbuf;
737 EXT VOLATILE int debug INIT(0);
738 EXT int dlevel INIT(0);
739 EXT int dlmax INIT(128);
744 EXT int perldb INIT(0);
745 #define YYMAXDEPTH 300
747 EXT line_t cmdline INIT(NOLINE);
753 /* runtime control stuff */
756 char *loop_label; /* what the loop was called, if anything */
757 int loop_sp; /* stack pointer to copy stuff down to */
761 EXT int loop_ptr INIT(-1);
762 EXT int loop_max INIT(128);
766 EXT char * VOLATILE goto_targ INIT(Nullch); /* cmd_exec gets strange when set */
774 EXT ARRAY *stack; /* THE STACK */
776 EXT ARRAY * VOLATILE savestack; /* to save non-local values on */
778 EXT ARRAY *tosave; /* strings to save on recursive subroutine */
780 EXT ARRAY *lineary; /* lines of script for debugger */
781 EXT ARRAY *dbargs; /* args to call listed by caller function */
783 EXT ARRAY *fdpid; /* keep fd-to-pid mappings for mypopen */
784 EXT HASH *pidstatus; /* keep pid-to-status mappings for waitpid */
786 EXT int *di; /* for tmp use in debuggers */
790 /* Fix these up for __STDC__ */
791 EXT long basetime INIT(0);
794 /* All of these are in stdlib.h or time.h for ANSI C */
797 struct tm *gmtime(), *localtime();
798 char *index(), *rindex();
799 char *strcpy(), *strcat();
800 #endif /* ! __STDC__ */
806 #define UNLINK unlink
811 #define setreuid(r,e) setresuid(r,e,-1)
817 #define setregid(r,e) setresgid(r,e,-1)