1 /* $Header: perl.h,v 3.0.1.2 89/11/11 04:39:38 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.2 89/11/11 04:39:38 lwall
10 * patch2: Configure may now set -DDEBUGGING
11 * patch2: netinet/in.h needed sys/types.h some places
12 * patch2: more <sys/time.h> and <time.h> wrangling
13 * patch2: yydebug moved to where type doesn't matter
15 * Revision 3.0.1.1 89/10/26 23:17:08 lwall
16 * patch1: vfork now conditionally defined based on VFORK
17 * patch1: DEC risc machines have a buggy memcmp
18 * patch1: perl.h now includes <netinet/in.h> if it exists
20 * Revision 3.0 89/10/18 15:21:21 lwall
38 #if defined(MEMCMP) && defined(mips) && BYTEORDER == 01234
43 extern char *memcpy(), *memset();
44 #define bcopy(s1,s2,l) memcpy(s2,s1,l)
45 #define bzero(s,l) memset(s,0,l)
47 #ifndef BCMP /* prefer bcmp slightly 'cuz it doesn't order */
48 #define bcmp(s1,s2,l) memcmp(s1,s2,l)
54 #include <sys/param.h> /* if this needs types.h we're still wrong */
56 #ifndef _TYPES_ /* If types.h defines this it's easy. */
57 #ifndef major /* Does everyone's types.h define this? */
58 #include <sys/types.h>
63 #include <netinet/in.h>
68 #if defined(TMINSYS) || defined(I_SYSTIME)
77 #include <sys/times.h>
81 #include <sys/ioctl.h>
85 #if defined(mc300) || defined(mc500) || defined(mc700) /* MASSCOMP */
103 #undef NULL /* suppress redefinition message */
109 #define NULL 0 /* silly thing is, we don't even use this */
111 #define dbm_fetch(db,dkey) fetch(dkey)
112 #define dbm_delete(db,dkey) delete(dkey)
113 #define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent)
114 #define dbm_close(db) dbmclose()
115 #define dbm_firstkey(db) firstkey()
133 #define DIRENT dirent
137 #include <ndir.h> /* may be wrong in the future */
141 #define DIRENT direct
145 typedef struct arg ARG;
146 typedef struct cmd CMD;
147 typedef struct formcmd FCMD;
148 typedef struct scanpat SPAT;
149 typedef struct stio STIO;
150 typedef struct sub SUBR;
151 typedef struct string STR;
152 typedef struct atbl ARRAY;
153 typedef struct htbl HASH;
154 typedef struct regexp REGEXP;
155 typedef struct stabptrs STBP;
156 typedef struct stab STAB;
170 #if defined(iAPX286) || defined(M_I286) || defined(I80286)
182 EXT char *Yes INIT("1");
183 EXT char *No INIT("");
187 /* Note: cmd.c assumes that it can use && to produce one of these values! */
193 #else /* !CRIPPLED_CC */
194 #define str_true(str) (Str = (str), \
196 ((*Str->str_ptr > '0' || \
197 Str->str_cur > 1 || \
198 (Str->str_cur && *Str->str_ptr != '0')) ? 1 : 0) \
200 (Str->str_nok ? (Str->str_u.str_nval != 0.0) : 0 ) ))
201 #endif /* CRIPPLED_CC */
204 #define str_peek(str) (Str = (str), \
208 (sprintf(tokenbuf,"num(%g)",Str->str_u.str_nval), \
217 #define str_get(str) (Str = (str), tainted |= Str->str_tainted, \
218 (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
220 #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
222 #endif /* CRIPPLED_CC */
226 #else /* !CRIPPLED_CC */
228 #define str_gnum(str) (Str = (str), tainted |= Str->str_tainted, \
229 (Str->str_nok ? Str->str_u.str_nval : str_2num(Str)))
231 #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_u.str_nval : str_2num(Str)))
233 #endif /* CRIPPLED_CC */
236 #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
238 #define STR_GROW(str,len) if ((str)->str_len < (len)) str_grow(str,len)
241 #define BYTEORDER 01234
244 #if defined(htonl) && !defined(HTONL)
247 #if defined(htons) && !defined(HTONS)
250 #if defined(ntohl) && !defined(NTOHL)
253 #if defined(ntohs) && !defined(NTOHS)
257 #if (BYTEORDER != 04321) && (BYTEORDER != 087654321)
263 #define htons my_swap
264 #define htonl my_htonl
265 #define ntohs my_swap
266 #define ntohl my_ntohl
269 #if (BYTEORDER == 04321) || (BYTEORDER == 087654321)
319 int eval(); /* this evaluates expressions */
320 int do_eval(); /* this evaluates eval operator */
332 char *str_append_till();
366 EXT line_t line INIT(0);
367 EXT line_t subline INIT(0);
368 EXT STR *subname INIT(Nullstr);
369 EXT int arybase INIT(0);
377 EXT struct outrec outrec;
378 EXT struct outrec toprec;
380 EXT STAB *stdinstab INIT(Nullstab);
381 EXT STAB *last_in_stab INIT(Nullstab);
382 EXT STAB *defstab INIT(Nullstab);
383 EXT STAB *argvstab INIT(Nullstab);
384 EXT STAB *envstab INIT(Nullstab);
385 EXT STAB *sigstab INIT(Nullstab);
386 EXT STAB *defoutstab INIT(Nullstab);
387 EXT STAB *curoutstab INIT(Nullstab);
388 EXT STAB *argvoutstab INIT(Nullstab);
389 EXT STAB *incstab INIT(Nullstab);
390 EXT STAB *leftstab INIT(Nullstab);
391 EXT STAB *amperstab INIT(Nullstab);
392 EXT STAB *rightstab INIT(Nullstab);
393 EXT STAB *DBstab INIT(Nullstab);
394 EXT STAB *DBsub INIT(Nullstab);
396 EXT HASH *defstash; /* main symbol table */
397 EXT HASH *curstash; /* symbol table for current package */
398 EXT HASH *debstash; /* symbol table for perldb package */
400 EXT STR *curstname; /* name of current package */
402 EXT STR *freestrroot INIT(Nullstr);
403 EXT STR *lastretstr INIT(Nullstr);
404 EXT STR *DBsingle INIT(Nullstr);
410 EXT char *origfilename;
415 EXT char *oldoldbufptr;
418 EXT STR *linestr INIT(Nullstr);
420 EXT char record_separator INIT('\n');
421 EXT int rslen INIT(1);
422 EXT char *ofs INIT(Nullch);
423 EXT int ofslen INIT(0);
424 EXT char *ors INIT(Nullch);
425 EXT int orslen INIT(0);
426 EXT char *ofmt INIT(Nullch);
427 EXT char *inplace INIT(Nullch);
428 EXT char *nointrp INIT("");
430 EXT bool preprocess INIT(FALSE);
431 EXT bool minus_n INIT(FALSE);
432 EXT bool minus_p INIT(FALSE);
433 EXT bool minus_a INIT(FALSE);
434 EXT bool doswitches INIT(FALSE);
435 EXT bool dowarn INIT(FALSE);
436 EXT bool allstabs INIT(FALSE); /* init all customary symbols in symbol table?*/
437 EXT bool sawampersand INIT(FALSE); /* must save all match strings */
438 EXT bool sawstudy INIT(FALSE); /* do fbminstr on all strings */
439 EXT bool sawi INIT(FALSE); /* study must assume case insensitive */
440 EXT bool sawvec INIT(FALSE);
443 char *cshname INIT(CSH);
448 EXT bool tainted INIT(FALSE); /* using variables controlled by $< */
451 #define TMPPATH "/tmp/perl-eXXXXXX"
453 EXT FILE *e_fp INIT(Nullfp);
455 EXT char tokenbuf[256];
456 EXT int expectterm INIT(TRUE); /* how to interpret ambiguous tokens */
457 EXT int in_eval INIT(FALSE); /* trap fatal errors? */
458 EXT int multiline INIT(0); /* $*--do strings hold >1 line? */
459 EXT int forkprocess; /* so do_open |- can return proc# */
460 EXT int do_undump INIT(0); /* -u or dump seen? */
461 EXT int error_count INIT(0); /* how many errors so far, max 10 */
462 EXT int multi_start INIT(0); /* 1st line of multi-line string */
463 EXT int multi_end INIT(0); /* last line of multi-line string */
464 EXT int multi_open INIT(0); /* delimiter of said string */
465 EXT int multi_close INIT(0); /* delimiter of said string */
468 /* char *str_get(); */
473 EXT struct stat statbuf;
474 EXT struct stat statcache;
475 STAB *statstab INIT(Nullstab);
477 EXT struct tms timesbuf;
489 EXT int debug INIT(0);
490 EXT int dlevel INIT(0);
491 EXT int dlmax INIT(128);
496 EXT int perldb INIT(0);
498 EXT line_t cmdline INIT(NOLINE);
504 /* runtime control stuff */
507 char *loop_label; /* what the loop was called, if anything */
508 int loop_sp; /* stack pointer to copy stuff down to */
512 EXT int loop_ptr INIT(-1);
513 EXT int loop_max INIT(128);
516 EXT jmp_buf eval_env;
518 EXT char *goto_targ INIT(Nullch); /* cmd_exec gets strange when set */
520 EXT ARRAY *stack; /* THE STACK */
522 EXT ARRAY *savestack; /* to save non-local values on */
524 EXT ARRAY *tosave; /* strings to save on recursive subroutine */
526 EXT ARRAY *lineary; /* lines of script for debugger */
528 EXT ARRAY *pidstatary; /* keep pids and statuses by fd for mypopen */
532 struct tm *gmtime(), *localtime();
534 char *index(), *rindex();
535 char *strcpy(), *strcat();
541 #define UNLINK unlink
546 #define setreuid(r,e) setresuid(r,e,-1)
552 #define setregid(r,e) setresgid(r,e,-1)