1 /* $Header: perl.h,v 3.0.1.3 89/11/17 15:28:57 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.3 89/11/17 15:28:57 lwall
10 * patch5: byteorder now is a hex value
11 * patch5: Configure now looks for <time.h> including <sys/time.h>
13 * Revision 3.0.1.2 89/11/11 04:39:38 lwall
14 * patch2: Configure may now set -DDEBUGGING
15 * patch2: netinet/in.h needed sys/types.h some places
16 * patch2: more <sys/time.h> and <time.h> wrangling
17 * patch2: yydebug moved to where type doesn't matter
19 * Revision 3.0.1.1 89/10/26 23:17:08 lwall
20 * patch1: vfork now conditionally defined based on VFORK
21 * patch1: DEC risc machines have a buggy memcmp
22 * patch1: perl.h now includes <netinet/in.h> if it exists
24 * Revision 3.0 89/10/18 15:21:21 lwall
42 #if defined(MEMCMP) && defined(mips) && BYTEORDER == 0x1234
47 extern char *memcpy(), *memset();
48 #define bcopy(s1,s2,l) memcpy(s2,s1,l)
49 #define bzero(s,l) memset(s,0,l)
51 #ifndef BCMP /* prefer bcmp slightly 'cuz it doesn't order */
52 #define bcmp(s1,s2,l) memcmp(s1,s2,l)
58 #include <sys/param.h> /* if this needs types.h we're still wrong */
60 #ifndef _TYPES_ /* If types.h defines this it's easy. */
61 #ifndef major /* Does everyone's types.h define this? */
62 #include <sys/types.h>
67 #include <netinet/in.h>
72 #if defined(TMINSYS) || defined(I_SYSTIME)
84 #include <sys/times.h>
88 #include <sys/ioctl.h>
92 #if defined(mc300) || defined(mc500) || defined(mc700) /* MASSCOMP */
110 #undef NULL /* suppress redefinition message */
116 #define NULL 0 /* silly thing is, we don't even use this */
118 #define dbm_fetch(db,dkey) fetch(dkey)
119 #define dbm_delete(db,dkey) delete(dkey)
120 #define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent)
121 #define dbm_close(db) dbmclose()
122 #define dbm_firstkey(db) firstkey()
140 #define DIRENT dirent
144 #include <ndir.h> /* may be wrong in the future */
148 #define DIRENT direct
152 typedef struct arg ARG;
153 typedef struct cmd CMD;
154 typedef struct formcmd FCMD;
155 typedef struct scanpat SPAT;
156 typedef struct stio STIO;
157 typedef struct sub SUBR;
158 typedef struct string STR;
159 typedef struct atbl ARRAY;
160 typedef struct htbl HASH;
161 typedef struct regexp REGEXP;
162 typedef struct stabptrs STBP;
163 typedef struct stab STAB;
177 #if defined(iAPX286) || defined(M_I286) || defined(I80286)
189 EXT char *Yes INIT("1");
190 EXT char *No INIT("");
194 /* Note: cmd.c assumes that it can use && to produce one of these values! */
200 #else /* !CRIPPLED_CC */
201 #define str_true(str) (Str = (str), \
203 ((*Str->str_ptr > '0' || \
204 Str->str_cur > 1 || \
205 (Str->str_cur && *Str->str_ptr != '0')) ? 1 : 0) \
207 (Str->str_nok ? (Str->str_u.str_nval != 0.0) : 0 ) ))
208 #endif /* CRIPPLED_CC */
211 #define str_peek(str) (Str = (str), \
215 (sprintf(tokenbuf,"num(%g)",Str->str_u.str_nval), \
224 #define str_get(str) (Str = (str), tainted |= Str->str_tainted, \
225 (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
227 #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
229 #endif /* CRIPPLED_CC */
233 #else /* !CRIPPLED_CC */
235 #define str_gnum(str) (Str = (str), tainted |= Str->str_tainted, \
236 (Str->str_nok ? Str->str_u.str_nval : str_2num(Str)))
238 #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_u.str_nval : str_2num(Str)))
240 #endif /* CRIPPLED_CC */
243 #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
245 #define STR_GROW(str,len) if ((str)->str_len < (len)) str_grow(str,len)
248 #define BYTEORDER 0x1234
251 #if defined(htonl) && !defined(HTONL)
254 #if defined(htons) && !defined(HTONS)
257 #if defined(ntohl) && !defined(NTOHL)
260 #if defined(ntohs) && !defined(NTOHS)
264 #if (BYTEORDER != 0x4321) && (BYTEORDER != 0x87654321)
270 #define htons my_swap
271 #define htonl my_htonl
272 #define ntohs my_swap
273 #define ntohl my_ntohl
276 #if (BYTEORDER == 0x4321) || (BYTEORDER == 0x87654321)
326 int eval(); /* this evaluates expressions */
327 int do_eval(); /* this evaluates eval operator */
339 char *str_append_till();
373 EXT line_t line INIT(0);
374 EXT line_t subline INIT(0);
375 EXT STR *subname INIT(Nullstr);
376 EXT int arybase INIT(0);
384 EXT struct outrec outrec;
385 EXT struct outrec toprec;
387 EXT STAB *stdinstab INIT(Nullstab);
388 EXT STAB *last_in_stab INIT(Nullstab);
389 EXT STAB *defstab INIT(Nullstab);
390 EXT STAB *argvstab INIT(Nullstab);
391 EXT STAB *envstab INIT(Nullstab);
392 EXT STAB *sigstab INIT(Nullstab);
393 EXT STAB *defoutstab INIT(Nullstab);
394 EXT STAB *curoutstab INIT(Nullstab);
395 EXT STAB *argvoutstab INIT(Nullstab);
396 EXT STAB *incstab INIT(Nullstab);
397 EXT STAB *leftstab INIT(Nullstab);
398 EXT STAB *amperstab INIT(Nullstab);
399 EXT STAB *rightstab INIT(Nullstab);
400 EXT STAB *DBstab INIT(Nullstab);
401 EXT STAB *DBsub INIT(Nullstab);
403 EXT HASH *defstash; /* main symbol table */
404 EXT HASH *curstash; /* symbol table for current package */
405 EXT HASH *debstash; /* symbol table for perldb package */
407 EXT STR *curstname; /* name of current package */
409 EXT STR *freestrroot INIT(Nullstr);
410 EXT STR *lastretstr INIT(Nullstr);
411 EXT STR *DBsingle INIT(Nullstr);
417 EXT char *origfilename;
422 EXT char *oldoldbufptr;
425 EXT STR *linestr INIT(Nullstr);
427 EXT char record_separator INIT('\n');
428 EXT int rslen INIT(1);
429 EXT char *ofs INIT(Nullch);
430 EXT int ofslen INIT(0);
431 EXT char *ors INIT(Nullch);
432 EXT int orslen INIT(0);
433 EXT char *ofmt INIT(Nullch);
434 EXT char *inplace INIT(Nullch);
435 EXT char *nointrp INIT("");
437 EXT bool preprocess INIT(FALSE);
438 EXT bool minus_n INIT(FALSE);
439 EXT bool minus_p INIT(FALSE);
440 EXT bool minus_a INIT(FALSE);
441 EXT bool doswitches INIT(FALSE);
442 EXT bool dowarn INIT(FALSE);
443 EXT bool allstabs INIT(FALSE); /* init all customary symbols in symbol table?*/
444 EXT bool sawampersand INIT(FALSE); /* must save all match strings */
445 EXT bool sawstudy INIT(FALSE); /* do fbminstr on all strings */
446 EXT bool sawi INIT(FALSE); /* study must assume case insensitive */
447 EXT bool sawvec INIT(FALSE);
450 char *cshname INIT(CSH);
455 EXT bool tainted INIT(FALSE); /* using variables controlled by $< */
458 #define TMPPATH "/tmp/perl-eXXXXXX"
460 EXT FILE *e_fp INIT(Nullfp);
462 EXT char tokenbuf[256];
463 EXT int expectterm INIT(TRUE); /* how to interpret ambiguous tokens */
464 EXT int in_eval INIT(FALSE); /* trap fatal errors? */
465 EXT int multiline INIT(0); /* $*--do strings hold >1 line? */
466 EXT int forkprocess; /* so do_open |- can return proc# */
467 EXT int do_undump INIT(0); /* -u or dump seen? */
468 EXT int error_count INIT(0); /* how many errors so far, max 10 */
469 EXT int multi_start INIT(0); /* 1st line of multi-line string */
470 EXT int multi_end INIT(0); /* last line of multi-line string */
471 EXT int multi_open INIT(0); /* delimiter of said string */
472 EXT int multi_close INIT(0); /* delimiter of said string */
475 /* char *str_get(); */
480 EXT struct stat statbuf;
481 EXT struct stat statcache;
482 STAB *statstab INIT(Nullstab);
484 EXT struct tms timesbuf;
496 EXT int debug INIT(0);
497 EXT int dlevel INIT(0);
498 EXT int dlmax INIT(128);
503 EXT int perldb INIT(0);
505 EXT line_t cmdline INIT(NOLINE);
511 /* runtime control stuff */
514 char *loop_label; /* what the loop was called, if anything */
515 int loop_sp; /* stack pointer to copy stuff down to */
519 EXT int loop_ptr INIT(-1);
520 EXT int loop_max INIT(128);
523 EXT jmp_buf eval_env;
525 EXT char *goto_targ INIT(Nullch); /* cmd_exec gets strange when set */
527 EXT ARRAY *stack; /* THE STACK */
529 EXT ARRAY *savestack; /* to save non-local values on */
531 EXT ARRAY *tosave; /* strings to save on recursive subroutine */
533 EXT ARRAY *lineary; /* lines of script for debugger */
535 EXT ARRAY *pidstatary; /* keep pids and statuses by fd for mypopen */
539 struct tm *gmtime(), *localtime();
541 char *index(), *rindex();
542 char *strcpy(), *strcat();
548 #define UNLINK unlink
553 #define setreuid(r,e) setresuid(r,e,-1)
559 #define setregid(r,e) setresgid(r,e,-1)