This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl 3.0: (no announcement message available)
[perl5.git] / perl.h
... / ...
CommitLineData
1/* $Header: perl.h,v 3.0 89/10/18 15:21:21 lwall Locked $
2 *
3 * Copyright (c) 1989, Larry Wall
4 *
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.
7 *
8 * $Log: perl.h,v $
9 * Revision 3.0 89/10/18 15:21:21 lwall
10 * 3.0 baseline
11 *
12 */
13
14#ifndef lint
15#define DEBUGGING
16#endif
17
18#define VOIDUSED 1
19#include "config.h"
20
21#ifdef IAMSUID
22# ifndef TAINT
23# define TAINT
24# endif
25#endif
26
27#ifdef MEMCPY
28extern char *memcpy(), *memset();
29#define bcopy(s1,s2,l) memcpy(s2,s1,l)
30#define bzero(s,l) memset(s,0,l)
31#endif
32#ifndef BCMP /* prefer bcmp slightly 'cuz it doesn't order */
33#define bcmp(s1,s2,l) memcmp(s1,s2,l)
34#endif
35
36#include <stdio.h>
37#include <ctype.h>
38#include <setjmp.h>
39#include <sys/param.h> /* if this needs types.h we're still wrong */
40
41#ifndef _TYPES_ /* If types.h defines this it's easy. */
42#ifndef major /* Does everyone's types.h define this? */
43#include <sys/types.h>
44#endif
45#endif
46
47#include <sys/stat.h>
48
49#ifdef TMINSYS
50#include <sys/time.h>
51#else
52#ifdef I_SYSTIME
53#include <sys/time.h>
54#else
55#include <time.h>
56#endif
57#endif
58
59#include <sys/times.h>
60
61#ifdef I_SYSIOCTL
62#ifndef _IOCTL_
63#include <sys/ioctl.h>
64#endif
65#endif
66
67#if defined(mc300) || defined(mc500) || defined(mc700) /* MASSCOMP */
68#ifdef SOCKETPAIR
69#undef SOCKETPAIR
70#endif
71#ifdef NDBM
72#undef NDBM
73#endif
74#endif
75
76#ifdef NDBM
77#include <ndbm.h>
78#define SOME_DBM
79#else
80#ifdef ODBM
81#ifdef NULL
82#undef NULL /* suppress redefinition message */
83#endif
84#include <dbm.h>
85#ifdef NULL
86#undef NULL
87#endif
88#define NULL 0 /* silly thing is, we don't even use this */
89#define SOME_DBM
90#define dbm_fetch(db,dkey) fetch(dkey)
91#define dbm_delete(db,dkey) delete(dkey)
92#define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent)
93#define dbm_close(db) dbmclose()
94#define dbm_firstkey(db) firstkey()
95#endif /* ODBM */
96#endif /* NDBM */
97#ifdef SOME_DBM
98EXT char *dbmkey;
99EXT int dbmlen;
100#endif
101
102#if INTSIZE == 2
103#define htoni htons
104#define ntohi ntohs
105#else
106#define htoni htonl
107#define ntohi ntohl
108#endif
109
110#ifdef I_DIRENT
111#include <dirent.h>
112#define DIRENT dirent
113#else
114#ifdef I_SYSDIR
115#include <sys/dir.h>
116#define DIRENT direct
117#endif
118#endif
119
120typedef struct arg ARG;
121typedef struct cmd CMD;
122typedef struct formcmd FCMD;
123typedef struct scanpat SPAT;
124typedef struct stio STIO;
125typedef struct sub SUBR;
126typedef struct string STR;
127typedef struct atbl ARRAY;
128typedef struct htbl HASH;
129typedef struct regexp REGEXP;
130typedef struct stabptrs STBP;
131typedef struct stab STAB;
132
133#include "handy.h"
134#include "regexp.h"
135#include "str.h"
136#include "util.h"
137#include "form.h"
138#include "stab.h"
139#include "spat.h"
140#include "arg.h"
141#include "cmd.h"
142#include "array.h"
143#include "hash.h"
144
145#if defined(iAPX286) || defined(M_I286) || defined(I80286)
146# define I286
147#endif
148
149#ifndef __STDC__
150#ifdef CHARSPRINTF
151 char *sprintf();
152#else
153 int sprintf();
154#endif
155#endif
156
157EXT char *Yes INIT("1");
158EXT char *No INIT("");
159
160/* "gimme" values */
161
162/* Note: cmd.c assumes that it can use && to produce one of these values! */
163#define G_SCALAR 0
164#define G_ARRAY 1
165
166#ifdef CRIPPLED_CC
167int str_true();
168#else /* !CRIPPLED_CC */
169#define str_true(str) (Str = (str), \
170 (Str->str_pok ? \
171 ((*Str->str_ptr > '0' || \
172 Str->str_cur > 1 || \
173 (Str->str_cur && *Str->str_ptr != '0')) ? 1 : 0) \
174 : \
175 (Str->str_nok ? (Str->str_u.str_nval != 0.0) : 0 ) ))
176#endif /* CRIPPLED_CC */
177
178#ifdef DEBUGGING
179#define str_peek(str) (Str = (str), \
180 (Str->str_pok ? \
181 Str->str_ptr : \
182 (Str->str_nok ? \
183 (sprintf(tokenbuf,"num(%g)",Str->str_u.str_nval), \
184 (char*)tokenbuf) : \
185 "" )))
186#endif
187
188#ifdef CRIPPLED_CC
189char *str_get();
190#else
191#ifdef TAINT
192#define str_get(str) (Str = (str), tainted |= Str->str_tainted, \
193 (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
194#else
195#define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
196#endif /* TAINT */
197#endif /* CRIPPLED_CC */
198
199#ifdef CRIPPLED_CC
200double str_gnum();
201#else /* !CRIPPLED_CC */
202#ifdef TAINT
203#define str_gnum(str) (Str = (str), tainted |= Str->str_tainted, \
204 (Str->str_nok ? Str->str_u.str_nval : str_2num(Str)))
205#else /* !TAINT */
206#define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_u.str_nval : str_2num(Str)))
207#endif /* TAINT*/
208#endif /* CRIPPLED_CC */
209EXT STR *Str;
210
211#define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
212
213#define STR_GROW(str,len) if ((str)->str_len < (len)) str_grow(str,len)
214
215#ifndef BYTEORDER
216#define BYTEORDER 01234
217#endif
218
219#ifndef HTONL
220#if BYTEORDER != 04321
221#define HTONS
222#define HTONL
223#define NTOHS
224#define NTOHL
225#define MYSWAP
226#define htons my_swap
227#define htonl my_htonl
228#define ntohs my_swap
229#define ntohl my_ntohl
230#endif
231#else
232#if BYTEORDER == 04321
233#undef HTONS
234#undef HTONL
235#undef NTOHS
236#undef NTOHL
237#endif
238#endif
239
240CMD *add_label();
241CMD *block_head();
242CMD *append_line();
243CMD *make_acmd();
244CMD *make_ccmd();
245CMD *make_icmd();
246CMD *invert();
247CMD *addcond();
248CMD *addloop();
249CMD *wopt();
250CMD *over();
251
252STAB *stabent();
253STAB *genstab();
254
255ARG *stab2arg();
256ARG *op_new();
257ARG *make_op();
258ARG *make_match();
259ARG *make_split();
260ARG *rcatmaybe();
261ARG *listish();
262ARG *maybelistish();
263ARG *localize();
264ARG *fixeval();
265ARG *jmaybe();
266ARG *l();
267ARG *fixl();
268ARG *mod_match();
269ARG *make_list();
270ARG *cmd_to_arg();
271ARG *addflags();
272ARG *hide_ary();
273ARG *cval_to_arg();
274
275STR *str_new();
276STR *stab_str();
277
278int do_each();
279int do_subr();
280int do_match();
281int do_unpack();
282int eval(); /* this evaluates expressions */
283int do_eval(); /* this evaluates eval operator */
284int do_assign();
285
286SUBR *make_sub();
287
288FCMD *load_format();
289
290char *scanpat();
291char *scansubst();
292char *scantrans();
293char *scanstr();
294char *scanreg();
295char *str_append_till();
296char *str_gets();
297char *str_grow();
298
299bool do_open();
300bool do_close();
301bool do_print();
302bool do_aprint();
303bool do_exec();
304bool do_aexec();
305
306int do_subst();
307int cando();
308int ingroup();
309
310void str_replace();
311void str_inc();
312void str_dec();
313void str_free();
314void stab_clear();
315void do_join();
316void do_sprintf();
317void do_accept();
318void do_vecset();
319void savelist();
320void saveitem();
321void saveint();
322void savelong();
323void savesptr();
324void savehptr();
325void restorelist();
326HASH *savehash();
327ARRAY *saveary();
328
329EXT line_t line INIT(0);
330EXT line_t subline INIT(0);
331EXT STR *subname INIT(Nullstr);
332EXT int arybase INIT(0);
333
334struct outrec {
335 line_t o_lines;
336 char *o_str;
337 int o_len;
338};
339
340EXT struct outrec outrec;
341EXT struct outrec toprec;
342
343EXT STAB *stdinstab INIT(Nullstab);
344EXT STAB *last_in_stab INIT(Nullstab);
345EXT STAB *defstab INIT(Nullstab);
346EXT STAB *argvstab INIT(Nullstab);
347EXT STAB *envstab INIT(Nullstab);
348EXT STAB *sigstab INIT(Nullstab);
349EXT STAB *defoutstab INIT(Nullstab);
350EXT STAB *curoutstab INIT(Nullstab);
351EXT STAB *argvoutstab INIT(Nullstab);
352EXT STAB *incstab INIT(Nullstab);
353EXT STAB *leftstab INIT(Nullstab);
354EXT STAB *amperstab INIT(Nullstab);
355EXT STAB *rightstab INIT(Nullstab);
356EXT STAB *DBstab INIT(Nullstab);
357EXT STAB *DBsub INIT(Nullstab);
358
359EXT HASH *defstash; /* main symbol table */
360EXT HASH *curstash; /* symbol table for current package */
361EXT HASH *debstash; /* symbol table for perldb package */
362
363EXT STR *curstname; /* name of current package */
364
365EXT STR *freestrroot INIT(Nullstr);
366EXT STR *lastretstr INIT(Nullstr);
367EXT STR *DBsingle INIT(Nullstr);
368
369EXT int lastspbase;
370EXT int lastsize;
371
372EXT char *filename;
373EXT char *origfilename;
374EXT FILE *rsfp;
375EXT char buf[1024];
376EXT char *bufptr;
377EXT char *oldbufptr;
378EXT char *oldoldbufptr;
379EXT char *bufend;
380
381EXT STR *linestr INIT(Nullstr);
382
383EXT char record_separator INIT('\n');
384EXT int rslen INIT(1);
385EXT char *ofs INIT(Nullch);
386EXT int ofslen INIT(0);
387EXT char *ors INIT(Nullch);
388EXT int orslen INIT(0);
389EXT char *ofmt INIT(Nullch);
390EXT char *inplace INIT(Nullch);
391EXT char *nointrp INIT("");
392
393EXT bool preprocess INIT(FALSE);
394EXT bool minus_n INIT(FALSE);
395EXT bool minus_p INIT(FALSE);
396EXT bool minus_a INIT(FALSE);
397EXT bool doswitches INIT(FALSE);
398EXT bool dowarn INIT(FALSE);
399EXT bool allstabs INIT(FALSE); /* init all customary symbols in symbol table?*/
400EXT bool sawampersand INIT(FALSE); /* must save all match strings */
401EXT bool sawstudy INIT(FALSE); /* do fbminstr on all strings */
402EXT bool sawi INIT(FALSE); /* study must assume case insensitive */
403EXT bool sawvec INIT(FALSE);
404
405EXT int csh INIT(0); /* 1 if /bin/csh is there, -1 if not */
406
407#ifdef TAINT
408EXT bool tainted INIT(FALSE); /* using variables controlled by $< */
409#endif
410
411#define TMPPATH "/tmp/perl-eXXXXXX"
412EXT char *e_tmpname;
413EXT FILE *e_fp INIT(Nullfp);
414
415EXT char tokenbuf[256];
416EXT int expectterm INIT(TRUE); /* how to interpret ambiguous tokens */
417EXT int in_eval INIT(FALSE); /* trap fatal errors? */
418EXT int multiline INIT(0); /* $*--do strings hold >1 line? */
419EXT int forkprocess; /* so do_open |- can return proc# */
420EXT int do_undump INIT(0); /* -u or dump seen? */
421EXT int error_count INIT(0); /* how many errors so far, max 10 */
422EXT int multi_start INIT(0); /* 1st line of multi-line string */
423EXT int multi_end INIT(0); /* last line of multi-line string */
424EXT int multi_open INIT(0); /* delimiter of said string */
425EXT int multi_close INIT(0); /* delimiter of said string */
426
427FILE *popen();
428/* char *str_get(); */
429STR *interp();
430void free_arg();
431STIO *stio_new();
432
433EXT struct stat statbuf;
434EXT struct stat statcache;
435STAB *statstab INIT(Nullstab);
436STR *statname;
437EXT struct tms timesbuf;
438EXT int uid;
439EXT int euid;
440EXT int gid;
441EXT int egid;
442UIDTYPE getuid();
443UIDTYPE geteuid();
444GIDTYPE getgid();
445GIDTYPE getegid();
446EXT int unsafe;
447
448#ifdef DEBUGGING
449EXT int debug INIT(0);
450EXT int dlevel INIT(0);
451EXT int dlmax INIT(128);
452EXT char *debname;
453EXT char *debdelim;
454#define YYDEBUG 1
455extern int yydebug;
456#endif
457EXT int perldb INIT(0);
458
459EXT line_t cmdline INIT(NOLINE);
460
461EXT STR str_undef;
462EXT STR str_no;
463EXT STR str_yes;
464
465/* runtime control stuff */
466
467EXT struct loop {
468 char *loop_label; /* what the loop was called, if anything */
469 int loop_sp; /* stack pointer to copy stuff down to */
470 jmp_buf loop_env;
471} *loop_stack;
472
473EXT int loop_ptr INIT(-1);
474EXT int loop_max INIT(128);
475
476EXT jmp_buf top_env;
477EXT jmp_buf eval_env;
478
479EXT char *goto_targ INIT(Nullch); /* cmd_exec gets strange when set */
480
481EXT ARRAY *stack; /* THE STACK */
482
483EXT ARRAY *savestack; /* to save non-local values on */
484
485EXT ARRAY *tosave; /* strings to save on recursive subroutine */
486
487EXT ARRAY *lineary; /* lines of script for debugger */
488
489EXT ARRAY *pidstatary; /* keep pids and statuses by fd for mypopen */
490
491double atof();
492long time();
493struct tm *gmtime(), *localtime();
494char *mktemp();
495char *index(), *rindex();
496char *strcpy(), *strcat();
497
498#ifdef EUNICE
499#define UNLINK unlnk
500int unlnk();
501#else
502#define UNLINK unlink
503#endif
504
505#ifndef SETREUID
506#ifdef SETRESUID
507#define setreuid(r,e) setresuid(r,e,-1)
508#define SETREUID
509#endif
510#endif
511#ifndef SETREGID
512#ifdef SETRESGID
513#define setregid(r,e) setresgid(r,e,-1)
514#define SETREGID
515#endif
516#endif