1 /* $RCSfile: perl.h,v $$Revision: 4.0.1.2 $$Date: 91/06/07 11:28:33 $
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.2 91/06/07 11:28:33 lwall
10 * patch4: new copyright notice
11 * patch4: made some allowances for "semi-standard" C
12 * patch4: many, many itty-bitty portability fixes
14 * Revision 4.0.1.1 91/04/11 17:49:51 lwall
15 * patch1: hopefully straightened out some of the Xenix mess
17 * Revision 4.0 91/03/20 01:37:56 lwall
26 /* This stuff now in the MS-DOS config.h file. */
30 * The following symbols are defined if your operating system supports
31 * functions by that name. All Unixes I know of support them, thus they
32 * are not checked by the configuration script, but are directly defined
47 * The following symbols are defined if your operating system supports
48 * password and group functions in general. All Unix systems do.
55 #if defined(__STDC__) || defined(_AIX) || defined(__stdc__)
59 #if defined(HASVOLATILE) || defined(STANDARD_C)
60 #define VOLATILE volatile
79 # define getpgrp getpgrp2
86 # define setpgrp setpgrp2
93 #ifdef PARAM_NEEDS_TYPES
94 #include <sys/types.h>
96 #include <sys/param.h>
99 /* Use all the "standard" definitions */
102 #endif /* STANDARD_C */
104 #if defined(HAS_MEMCMP) && defined(mips) && BYTEORDER == 0x1234
112 extern char * memcpy(), *memset();
114 # endif /* ndef memcpy */
115 # endif /* ndef STANDARD_C */
118 # define bcopy(s1,s2,l) memcpy(s2,s1,l)
121 # define bzero(s,l) memset(s,0,l)
123 #endif /* HAS_MEMCPY */
125 #ifndef HAS_BCMP /* prefer bcmp slightly 'cuz it doesn't order */
127 # define bcmp(s1,s2,l) memcmp(s1,s2,l)
131 #ifndef _TYPES_ /* If types.h defines this it's easy. */
132 #ifndef major /* Does everyone's types.h define this? */
133 #include <sys/types.h>
138 #include <netinet/in.h>
141 #include <sys/stat.h>
148 # ifdef SYSTIMEKERNEL
151 # include <sys/time.h>
152 # ifdef SYSTIMEKERNEL
158 #include <sys/times.h>
161 #if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR))
168 extern int errno; /* ANSI allows errno to be an lvalue expr */
177 extern char *sys_errlist[];
178 #define strerror(e) ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e])
184 #include <sys/ioctl.h>
188 #if defined(mc300) || defined(mc500) || defined(mc700) /* MASSCOMP */
189 #ifdef HAS_SOCKETPAIR
190 #undef HAS_SOCKETPAIR
218 #undef NULL /* suppress redefinition message */
224 #define NULL 0 /* silly thing is, we don't even use this */
226 #define dbm_fetch(db,dkey) fetch(dkey)
227 #define dbm_delete(db,dkey) delete(dkey)
228 #define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent)
229 #define dbm_close(db) dbmclose()
230 #define dbm_firstkey(db) firstkey()
231 #endif /* HAS_ODBM */
232 #endif /* HAS_NDBM */
233 #endif /* HAS_GDBM */
247 #if defined(I_DIRENT)
249 # define DIRENT dirent
252 # include <sys/ndir.h>
253 # define DIRENT direct
257 # include <ndir.h> /* may be wrong in the future */
259 # include <sys/dir.h>
261 # define DIRENT direct
267 /* work around botch in SunOS 4.0.1 and 4.0.2 */
269 # define fputs(str,fp) fprintf(fp,"%s",str)
274 * The following gobbledygook brought to you on behalf of __STDC__.
275 * (I could just use #ifndef __STDC__, but this is more bulletproof
276 * in the face of half-implementations.)
281 # define S_IFMT _S_IFMT
283 # define S_IFMT 0170000
288 # define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
292 # define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR)
297 # define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK)
299 # define S_ISBLK(m) (0)
304 # define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
309 # define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
311 # define S_ISFIFO(m) (0)
317 # define S_ISLNK(m) _S_ISLNK(m)
320 # define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK)
323 # define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
325 # define S_ISLNK(m) (0)
333 # define S_ISSOCK(m) _S_ISSOCK(m)
336 # define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK)
339 # define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK)
341 # define S_ISSOCK(m) (0)
349 # define S_IRUSR S_IREAD
350 # define S_IWUSR S_IWRITE
351 # define S_IXUSR S_IEXEC
353 # define S_IRUSR 0400
354 # define S_IWUSR 0200
355 # define S_IXUSR 0100
357 # define S_IRGRP (S_IRUSR>>3)
358 # define S_IWGRP (S_IWUSR>>3)
359 # define S_IXGRP (S_IXUSR>>3)
360 # define S_IROTH (S_IRUSR>>6)
361 # define S_IWOTH (S_IWUSR>>6)
362 # define S_IXOTH (S_IXUSR>>6)
366 # define S_ISUID 04000
370 # define S_ISGID 02000
377 typedef unsigned int STRLEN;
379 typedef struct arg ARG;
380 typedef struct cmd CMD;
381 typedef struct formcmd FCMD;
382 typedef struct scanpat SPAT;
383 typedef struct stio STIO;
384 typedef struct sub SUBR;
385 typedef struct string STR;
386 typedef struct atbl ARRAY;
387 typedef struct htbl HASH;
388 typedef struct regexp REGEXP;
389 typedef struct stabptrs STBP;
390 typedef struct stab STAB;
391 typedef struct callsave CSV;
405 #if defined(iAPX286) || defined(M_I286) || defined(I80286)
417 EXT char *Yes INIT("1");
418 EXT char *No INIT("");
422 /* Note: cmd.c assumes that it can use && to produce one of these values! */
428 #else /* !CRIPPLED_CC */
429 #define str_true(str) (Str = (str), \
431 ((*Str->str_ptr > '0' || \
432 Str->str_cur > 1 || \
433 (Str->str_cur && *Str->str_ptr != '0')) ? 1 : 0) \
435 (Str->str_nok ? (Str->str_u.str_nval != 0.0) : 0 ) ))
436 #endif /* CRIPPLED_CC */
439 #define str_peek(str) (Str = (str), \
443 (sprintf(tokenbuf,"num(%g)",Str->str_u.str_nval), \
452 #define str_get(str) (Str = (str), tainted |= Str->str_tainted, \
453 (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
455 #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
457 #endif /* CRIPPLED_CC */
461 #else /* !CRIPPLED_CC */
463 #define str_gnum(str) (Str = (str), tainted |= Str->str_tainted, \
464 (Str->str_nok ? Str->str_u.str_nval : str_2num(Str)))
466 #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_u.str_nval : str_2num(Str)))
468 #endif /* CRIPPLED_CC */
471 #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
474 #define STR_GROW(str,len) if ((str)->str_len < (len)) str_grow(str,len)
475 #define Str_Grow str_grow
477 /* extra parentheses intentionally NOT placed around "len"! */
478 #define STR_GROW(str,len) if ((str)->str_len < (unsigned long)len) \
479 str_grow(str,(unsigned long)len)
480 #define Str_Grow(str,len) str_grow(str,(unsigned long)(len))
484 #define BYTEORDER 0x1234
487 #if defined(htonl) && !defined(HAS_HTONL)
490 #if defined(htons) && !defined(HAS_HTONS)
493 #if defined(ntohl) && !defined(HAS_NTOHL)
496 #if defined(ntohs) && !defined(HAS_NTOHS)
500 #if (BYTEORDER & 0xffff) != 0x4321
506 #define htons my_swap
507 #define htonl my_htonl
508 #define ntohs my_swap
509 #define ntohl my_ntohl
512 #if (BYTEORDER & 0xffff) == 0x4321
521 #define U_S(what) ((unsigned short)(what))
522 #define U_I(what) ((unsigned int)(what))
523 #define U_L(what) ((unsigned long)(what))
525 unsigned long castulong();
526 #define U_S(what) ((unsigned int)castulong(what))
527 #define U_I(what) ((unsigned int)castulong(what))
528 #define U_L(what) (castulong(what))
573 int eval(); /* this evaluates expressions */
574 int do_eval(); /* this evaluates eval operator */
586 char *str_append_till();
628 EXT char **origenviron;
629 extern char **environ;
631 EXT line_t subline INIT(0);
632 EXT STR *subname INIT(Nullstr);
633 EXT int arybase INIT(0);
641 EXT struct outrec outrec;
642 EXT struct outrec toprec;
644 EXT STAB *stdinstab INIT(Nullstab);
645 EXT STAB *last_in_stab INIT(Nullstab);
646 EXT STAB *defstab INIT(Nullstab);
647 EXT STAB *argvstab INIT(Nullstab);
648 EXT STAB *envstab INIT(Nullstab);
649 EXT STAB *sigstab INIT(Nullstab);
650 EXT STAB *defoutstab INIT(Nullstab);
651 EXT STAB *curoutstab INIT(Nullstab);
652 EXT STAB *argvoutstab INIT(Nullstab);
653 EXT STAB *incstab INIT(Nullstab);
654 EXT STAB *leftstab INIT(Nullstab);
655 EXT STAB *amperstab INIT(Nullstab);
656 EXT STAB *rightstab INIT(Nullstab);
657 EXT STAB *DBstab INIT(Nullstab);
658 EXT STAB *DBline INIT(Nullstab);
659 EXT STAB *DBsub INIT(Nullstab);
661 EXT HASH *defstash; /* main symbol table */
662 EXT HASH *curstash; /* symbol table for current package */
663 EXT HASH *debstash; /* symbol table for perldb package */
665 EXT STR *curstname; /* name of current package */
667 EXT STR *freestrroot INIT(Nullstr);
668 EXT STR *lastretstr INIT(Nullstr);
669 EXT STR *DBsingle INIT(Nullstr);
670 EXT STR *DBtrace INIT(Nullstr);
671 EXT STR *DBsignal INIT(Nullstr);
676 EXT char *hexdigit INIT("0123456789abcdef0123456789ABCDEF");
677 EXT char *origfilename;
678 EXT FILE * VOLATILE rsfp;
682 EXT char *oldoldbufptr;
685 EXT STR *linestr INIT(Nullstr);
687 EXT char *rs INIT("\n");
688 EXT int rschar INIT('\n'); /* final char of rs, or 0777 if none */
689 EXT int rslen INIT(1);
690 EXT char *ofs INIT(Nullch);
691 EXT int ofslen INIT(0);
692 EXT char *ors INIT(Nullch);
693 EXT int orslen INIT(0);
694 EXT char *ofmt INIT(Nullch);
695 EXT char *inplace INIT(Nullch);
696 EXT char *nointrp INIT("");
698 EXT bool preprocess INIT(FALSE);
699 EXT bool minus_n INIT(FALSE);
700 EXT bool minus_p INIT(FALSE);
701 EXT bool minus_l INIT(FALSE);
702 EXT bool minus_a INIT(FALSE);
703 EXT bool doswitches INIT(FALSE);
704 EXT bool dowarn INIT(FALSE);
705 EXT bool doextract INIT(FALSE);
706 EXT bool allstabs INIT(FALSE); /* init all customary symbols in symbol table?*/
707 EXT bool sawampersand INIT(FALSE); /* must save all match strings */
708 EXT bool sawstudy INIT(FALSE); /* do fbminstr on all strings */
709 EXT bool sawi INIT(FALSE); /* study must assume case insensitive */
710 EXT bool sawvec INIT(FALSE);
711 EXT bool localizing INIT(FALSE); /* are we processing a local() list? */
716 EXT int maxsysfd INIT(MAXSYSFD); /* top fd to pass to subprocesses */
719 char *cshname INIT(CSH);
724 EXT bool tainted INIT(FALSE); /* using variables controlled by $< */
728 #define TMPPATH "/tmp/perl-eXXXXXX"
730 #define TMPPATH "plXXXXXX"
733 EXT FILE *e_fp INIT(Nullfp);
735 EXT char tokenbuf[256];
736 EXT int expectterm INIT(TRUE); /* how to interpret ambiguous tokens */
737 EXT VOLATILE int in_eval INIT(FALSE); /* trap fatal errors? */
738 EXT int multiline INIT(0); /* $*--do strings hold >1 line? */
739 EXT int forkprocess; /* so do_open |- can return proc# */
740 EXT int do_undump INIT(0); /* -u or dump seen? */
741 EXT int error_count INIT(0); /* how many errors so far, max 10 */
742 EXT int multi_start INIT(0); /* 1st line of multi-line string */
743 EXT int multi_end INIT(0); /* last line of multi-line string */
744 EXT int multi_open INIT(0); /* delimiter of said string */
745 EXT int multi_close INIT(0); /* delimiter of said string */
748 /* char *str_get(); */
753 EXT struct stat statbuf;
754 EXT struct stat statcache;
755 STAB *statstab INIT(Nullstab);
758 EXT struct tms timesbuf;
771 EXT VOLATILE int debug INIT(0);
772 EXT int dlevel INIT(0);
773 EXT int dlmax INIT(128);
778 EXT int perldb INIT(0);
779 #define YYMAXDEPTH 300
781 EXT line_t cmdline INIT(NOLINE);
787 /* runtime control stuff */
790 char *loop_label; /* what the loop was called, if anything */
791 int loop_sp; /* stack pointer to copy stuff down to */
795 EXT int loop_ptr INIT(-1);
796 EXT int loop_max INIT(128);
800 EXT char * VOLATILE goto_targ INIT(Nullch); /* cmd_exec gets strange when set */
808 EXT ARRAY *stack; /* THE STACK */
810 EXT ARRAY * VOLATILE savestack; /* to save non-local values on */
812 EXT ARRAY *tosave; /* strings to save on recursive subroutine */
814 EXT ARRAY *lineary; /* lines of script for debugger */
815 EXT ARRAY *dbargs; /* args to call listed by caller function */
817 EXT ARRAY *fdpid; /* keep fd-to-pid mappings for mypopen */
818 EXT HASH *pidstatus; /* keep pid-to-status mappings for waitpid */
820 EXT int *di; /* for tmp use in debuggers */
824 /* Fix these up for __STDC__ */
825 EXT long basetime INIT(0);
828 /* All of these are in stdlib.h or time.h for ANSI C */
831 struct tm *gmtime(), *localtime();
832 char *index(), *rindex();
833 char *strcpy(), *strcat();
834 #endif /* ! STANDARD_C */
840 #define UNLINK unlink
845 #define setreuid(r,e) setresuid(r,e,-1)
851 #define setregid(r,e) setresgid(r,e,-1)