Commit | Line | Data |
45d8adaa |
1 | /* $RCSfile: perl.h,v $$Revision: 4.0.1.4 $$Date: 91/11/05 18:06:10 $ |
a687059c |
2 | * |
352d5a3a |
3 | * Copyright (c) 1991, Larry Wall |
a687059c |
4 | * |
352d5a3a |
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. |
8d063cd8 |
7 | * |
8 | * $Log: perl.h,v $ |
45d8adaa |
9 | * Revision 4.0.1.4 91/11/05 18:06:10 lwall |
10 | * patch11: various portability fixes |
11 | * patch11: added support for dbz |
12 | * patch11: added some support for 64-bit integers |
13 | * patch11: hex() didn't understand leading 0x |
14 | * |
1462b684 |
15 | * Revision 4.0.1.3 91/06/10 01:25:10 lwall |
16 | * patch10: certain pattern optimizations were botched |
17 | * |
352d5a3a |
18 | * Revision 4.0.1.2 91/06/07 11:28:33 lwall |
19 | * patch4: new copyright notice |
20 | * patch4: made some allowances for "semi-standard" C |
21 | * patch4: many, many itty-bitty portability fixes |
22 | * |
35c8bce7 |
23 | * Revision 4.0.1.1 91/04/11 17:49:51 lwall |
24 | * patch1: hopefully straightened out some of the Xenix mess |
25 | * |
fe14fcc3 |
26 | * Revision 4.0 91/03/20 01:37:56 lwall |
27 | * 4.0 baseline. |
8d063cd8 |
28 | * |
29 | */ |
30 | |
35c8bce7 |
31 | #define VOIDWANT 1 |
ac58e20f |
32 | #include "config.h" |
33 | |
45d8adaa |
34 | #ifdef MYMALLOC |
35 | # ifdef HIDEMYMALLOC |
36 | # define malloc Mymalloc |
37 | # define realloc Myremalloc |
38 | # define free Myfree |
39 | # endif |
40 | # define safemalloc malloc |
41 | # define saferealloc realloc |
42 | # define safefree free |
43 | #endif |
44 | |
45 | /* work around some libPW problems */ |
46 | #define fatal Myfatal |
47 | #ifdef DOINIT |
48 | char Error[1]; |
49 | #endif |
50 | |
0f85fab0 |
51 | #ifdef MSDOS |
fe14fcc3 |
52 | /* This stuff now in the MS-DOS config.h file. */ |
0f85fab0 |
53 | #else /* !MSDOS */ |
54 | |
55 | /* |
56 | * The following symbols are defined if your operating system supports |
57 | * functions by that name. All Unixes I know of support them, thus they |
58 | * are not checked by the configuration script, but are directly defined |
59 | * here. |
60 | */ |
fe14fcc3 |
61 | #define HAS_ALARM |
62 | #define HAS_CHOWN |
63 | #define HAS_CHROOT |
64 | #define HAS_FORK |
65 | #define HAS_GETLOGIN |
66 | #define HAS_GETPPID |
67 | #define HAS_KILL |
68 | #define HAS_LINK |
69 | #define HAS_PIPE |
70 | #define HAS_WAIT |
71 | #define HAS_UMASK |
0f85fab0 |
72 | /* |
73 | * The following symbols are defined if your operating system supports |
74 | * password and group functions in general. All Unix systems do. |
75 | */ |
fe14fcc3 |
76 | #define HAS_GROUP |
77 | #define HAS_PASSWD |
0f85fab0 |
78 | |
79 | #endif /* !MSDOS */ |
80 | |
352d5a3a |
81 | #if defined(__STDC__) || defined(_AIX) || defined(__stdc__) |
82 | # define STANDARD_C 1 |
83 | #endif |
84 | |
85 | #if defined(HASVOLATILE) || defined(STANDARD_C) |
663a0e37 |
86 | #define VOLATILE volatile |
663a0e37 |
87 | #else |
88 | #define VOLATILE |
663a0e37 |
89 | #endif |
90 | |
a687059c |
91 | #ifdef IAMSUID |
92 | # ifndef TAINT |
93 | # define TAINT |
94 | # endif |
95 | #endif |
96 | |
fe14fcc3 |
97 | #ifndef HAS_VFORK |
03a14243 |
98 | # define vfork fork |
99 | #endif |
100 | |
fe14fcc3 |
101 | #ifdef HAS_GETPGRP2 |
102 | # ifndef HAS_GETPGRP |
103 | # define HAS_GETPGRP |
663a0e37 |
104 | # endif |
105 | # define getpgrp getpgrp2 |
106 | #endif |
107 | |
fe14fcc3 |
108 | #ifdef HAS_SETPGRP2 |
109 | # ifndef HAS_SETPGRP |
110 | # define HAS_SETPGRP |
663a0e37 |
111 | # endif |
112 | # define setpgrp setpgrp2 |
113 | #endif |
114 | |
fe14fcc3 |
115 | #include <stdio.h> |
116 | #include <ctype.h> |
117 | #include <setjmp.h> |
118 | #ifndef MSDOS |
352d5a3a |
119 | #ifdef PARAM_NEEDS_TYPES |
120 | #include <sys/types.h> |
03a14243 |
121 | #endif |
352d5a3a |
122 | #include <sys/param.h> |
123 | #endif |
124 | #ifdef STANDARD_C |
fe14fcc3 |
125 | /* Use all the "standard" definitions */ |
126 | #include <stdlib.h> |
127 | #include <string.h> |
352d5a3a |
128 | #endif /* STANDARD_C */ |
03a14243 |
129 | |
fe14fcc3 |
130 | #if defined(HAS_MEMCMP) && defined(mips) && BYTEORDER == 0x1234 |
131 | #undef HAS_MEMCMP |
663a0e37 |
132 | #endif |
fe14fcc3 |
133 | |
134 | #ifdef HAS_MEMCPY |
135 | |
352d5a3a |
136 | # ifndef STANDARD_C |
fe14fcc3 |
137 | # ifndef memcpy |
138 | extern char * memcpy(), *memset(); |
450a55e4 |
139 | extern int memcmp(); |
fe14fcc3 |
140 | # endif /* ndef memcpy */ |
352d5a3a |
141 | # endif /* ndef STANDARD_C */ |
fe14fcc3 |
142 | |
352d5a3a |
143 | # ifndef bcopy |
144 | # define bcopy(s1,s2,l) memcpy(s2,s1,l) |
145 | # endif |
146 | # ifndef bzero |
147 | # define bzero(s,l) memset(s,0,l) |
148 | # endif |
fe14fcc3 |
149 | #endif /* HAS_MEMCPY */ |
8d063cd8 |
150 | |
fe14fcc3 |
151 | #ifndef HAS_BCMP /* prefer bcmp slightly 'cuz it doesn't order */ |
352d5a3a |
152 | # ifndef bcmp |
153 | # define bcmp(s1,s2,l) memcmp(s1,s2,l) |
154 | # endif |
d9d8d8de |
155 | #endif |
378cc40b |
156 | |
157 | #ifndef _TYPES_ /* If types.h defines this it's easy. */ |
158 | #ifndef major /* Does everyone's types.h define this? */ |
8d063cd8 |
159 | #include <sys/types.h> |
378cc40b |
160 | #endif |
161 | #endif |
162 | |
ae986130 |
163 | #ifdef I_NETINET_IN |
164 | #include <netinet/in.h> |
165 | #endif |
166 | |
8d063cd8 |
167 | #include <sys/stat.h> |
135863df |
168 | |
663a0e37 |
169 | #ifdef I_TIME |
170 | # include <time.h> |
ffed7fef |
171 | #endif |
663a0e37 |
172 | |
fe14fcc3 |
173 | #ifdef I_SYS_TIME |
663a0e37 |
174 | # ifdef SYSTIMEKERNEL |
175 | # define KERNEL |
176 | # endif |
177 | # include <sys/time.h> |
178 | # ifdef SYSTIMEKERNEL |
179 | # undef KERNEL |
180 | # endif |
a687059c |
181 | #endif |
135863df |
182 | |
d9d8d8de |
183 | #ifndef MSDOS |
8d063cd8 |
184 | #include <sys/times.h> |
d9d8d8de |
185 | #endif |
8d063cd8 |
186 | |
fe14fcc3 |
187 | #if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR)) |
188 | #undef HAS_STRERROR |
663a0e37 |
189 | #endif |
190 | |
191 | #include <errno.h> |
d9d8d8de |
192 | #ifndef MSDOS |
663a0e37 |
193 | #ifndef errno |
194 | extern int errno; /* ANSI allows errno to be an lvalue expr */ |
195 | #endif |
d9d8d8de |
196 | #endif |
663a0e37 |
197 | |
35c8bce7 |
198 | #ifndef strerror |
fe14fcc3 |
199 | #ifdef HAS_STRERROR |
663a0e37 |
200 | char *strerror(); |
201 | #else |
202 | extern int sys_nerr; |
203 | extern char *sys_errlist[]; |
204 | #define strerror(e) ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e]) |
205 | #endif |
35c8bce7 |
206 | #endif |
663a0e37 |
207 | |
a687059c |
208 | #ifdef I_SYSIOCTL |
209 | #ifndef _IOCTL_ |
210 | #include <sys/ioctl.h> |
211 | #endif |
212 | #endif |
213 | |
214 | #if defined(mc300) || defined(mc500) || defined(mc700) /* MASSCOMP */ |
fe14fcc3 |
215 | #ifdef HAS_SOCKETPAIR |
216 | #undef HAS_SOCKETPAIR |
a687059c |
217 | #endif |
fe14fcc3 |
218 | #ifdef HAS_NDBM |
219 | #undef HAS_NDBM |
a687059c |
220 | #endif |
221 | #endif |
222 | |
45d8adaa |
223 | #ifdef WANT_DBZ |
224 | #include <dbz.h> |
225 | #define SOME_DBM |
226 | #define dbm_fetch(db,dkey) fetch(dkey) |
227 | #define dbm_delete(db,dkey) fatal("dbz doesn't implement delete") |
228 | #define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent) |
229 | #define dbm_close(db) dbmclose() |
230 | #define dbm_firstkey(db) (fatal("dbz doesn't implement traversal"),fetch()) |
231 | #define nextkey() (fatal("dbz doesn't implement traversal"),fetch()) |
232 | #define dbm_nextkey(db) (fatal("dbz doesn't implement traversal"),fetch()) |
233 | #ifdef HAS_NDBM |
234 | #undef HAS_NDBM |
235 | #endif |
236 | #ifndef HAS_ODBM |
237 | #define HAS_ODBM |
238 | #endif |
239 | #else |
fe14fcc3 |
240 | #ifdef HAS_GDBM |
241 | #ifdef I_GDBM |
242 | #include <gdbm.h> |
243 | #endif |
244 | #define SOME_DBM |
245 | #ifdef HAS_NDBM |
246 | #undef HAS_NDBM |
247 | #endif |
248 | #ifdef HAS_ODBM |
249 | #undef HAS_ODBM |
250 | #endif |
251 | #else |
252 | #ifdef HAS_NDBM |
a687059c |
253 | #include <ndbm.h> |
254 | #define SOME_DBM |
fe14fcc3 |
255 | #ifdef HAS_ODBM |
256 | #undef HAS_ODBM |
ae986130 |
257 | #endif |
a687059c |
258 | #else |
fe14fcc3 |
259 | #ifdef HAS_ODBM |
a687059c |
260 | #ifdef NULL |
261 | #undef NULL /* suppress redefinition message */ |
262 | #endif |
263 | #include <dbm.h> |
264 | #ifdef NULL |
265 | #undef NULL |
266 | #endif |
267 | #define NULL 0 /* silly thing is, we don't even use this */ |
268 | #define SOME_DBM |
269 | #define dbm_fetch(db,dkey) fetch(dkey) |
270 | #define dbm_delete(db,dkey) delete(dkey) |
271 | #define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent) |
272 | #define dbm_close(db) dbmclose() |
273 | #define dbm_firstkey(db) firstkey() |
fe14fcc3 |
274 | #endif /* HAS_ODBM */ |
275 | #endif /* HAS_NDBM */ |
276 | #endif /* HAS_GDBM */ |
45d8adaa |
277 | #endif /* WANT_DBZ */ |
a687059c |
278 | #ifdef SOME_DBM |
279 | EXT char *dbmkey; |
280 | EXT int dbmlen; |
281 | #endif |
282 | |
283 | #if INTSIZE == 2 |
284 | #define htoni htons |
285 | #define ntohi ntohs |
286 | #else |
287 | #define htoni htonl |
288 | #define ntohi ntohl |
289 | #endif |
290 | |
35c8bce7 |
291 | #if defined(I_DIRENT) |
663a0e37 |
292 | # include <dirent.h> |
293 | # define DIRENT dirent |
ae986130 |
294 | #else |
fe14fcc3 |
295 | # ifdef I_SYS_NDIR |
79a0689e |
296 | # include <sys/ndir.h> |
663a0e37 |
297 | # define DIRENT direct |
298 | # else |
fe14fcc3 |
299 | # ifdef I_SYS_DIR |
79a0689e |
300 | # ifdef hp9000s500 |
301 | # include <ndir.h> /* may be wrong in the future */ |
302 | # else |
303 | # include <sys/dir.h> |
304 | # endif |
663a0e37 |
305 | # define DIRENT direct |
306 | # endif |
307 | # endif |
a687059c |
308 | #endif |
309 | |
352d5a3a |
310 | #ifdef FPUTS_BOTCH |
311 | /* work around botch in SunOS 4.0.1 and 4.0.2 */ |
312 | # ifndef fputs |
313 | # define fputs(str,fp) fprintf(fp,"%s",str) |
314 | # endif |
315 | #endif |
316 | |
c623bd54 |
317 | /* |
318 | * The following gobbledygook brought to you on behalf of __STDC__. |
319 | * (I could just use #ifndef __STDC__, but this is more bulletproof |
320 | * in the face of half-implementations.) |
321 | */ |
322 | |
323 | #ifndef S_IFMT |
324 | # ifdef _S_IFMT |
325 | # define S_IFMT _S_IFMT |
326 | # else |
327 | # define S_IFMT 0170000 |
328 | # endif |
329 | #endif |
330 | |
331 | #ifndef S_ISDIR |
332 | # define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR) |
333 | #endif |
334 | |
335 | #ifndef S_ISCHR |
336 | # define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR) |
337 | #endif |
338 | |
339 | #ifndef S_ISBLK |
fe14fcc3 |
340 | # ifdef S_IFBLK |
341 | # define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK) |
342 | # else |
343 | # define S_ISBLK(m) (0) |
344 | # endif |
c623bd54 |
345 | #endif |
346 | |
45d8adaa |
347 | #if S_ISBLK(060000) == 060000 |
348 | XXX Your sys/stat.h appears to be buggy. Please fix it. |
349 | #endif |
350 | |
c623bd54 |
351 | #ifndef S_ISREG |
352 | # define S_ISREG(m) ((m & S_IFMT) == S_IFREG) |
353 | #endif |
354 | |
355 | #ifndef S_ISFIFO |
fe14fcc3 |
356 | # ifdef S_IFIFO |
357 | # define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO) |
358 | # else |
359 | # define S_ISFIFO(m) (0) |
360 | # endif |
c623bd54 |
361 | #endif |
362 | |
363 | #ifndef S_ISLNK |
364 | # ifdef _S_ISLNK |
365 | # define S_ISLNK(m) _S_ISLNK(m) |
366 | # else |
367 | # ifdef _S_IFLNK |
368 | # define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK) |
369 | # else |
370 | # ifdef S_IFLNK |
371 | # define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK) |
372 | # else |
373 | # define S_ISLNK(m) (0) |
374 | # endif |
375 | # endif |
376 | # endif |
377 | #endif |
378 | |
379 | #ifndef S_ISSOCK |
380 | # ifdef _S_ISSOCK |
381 | # define S_ISSOCK(m) _S_ISSOCK(m) |
382 | # else |
383 | # ifdef _S_IFSOCK |
384 | # define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK) |
385 | # else |
386 | # ifdef S_IFSOCK |
387 | # define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK) |
388 | # else |
389 | # define S_ISSOCK(m) (0) |
390 | # endif |
391 | # endif |
392 | # endif |
393 | #endif |
394 | |
395 | #ifndef S_IRUSR |
396 | # ifdef S_IREAD |
397 | # define S_IRUSR S_IREAD |
398 | # define S_IWUSR S_IWRITE |
399 | # define S_IXUSR S_IEXEC |
400 | # else |
401 | # define S_IRUSR 0400 |
402 | # define S_IWUSR 0200 |
403 | # define S_IXUSR 0100 |
404 | # endif |
405 | # define S_IRGRP (S_IRUSR>>3) |
406 | # define S_IWGRP (S_IWUSR>>3) |
407 | # define S_IXGRP (S_IXUSR>>3) |
408 | # define S_IROTH (S_IRUSR>>6) |
409 | # define S_IWOTH (S_IWUSR>>6) |
410 | # define S_IXOTH (S_IXUSR>>6) |
411 | #endif |
412 | |
413 | #ifndef S_ISUID |
414 | # define S_ISUID 04000 |
415 | #endif |
416 | |
417 | #ifndef S_ISGID |
418 | # define S_ISGID 02000 |
419 | #endif |
420 | |
352d5a3a |
421 | #ifdef f_next |
422 | #undef f_next |
423 | #endif |
424 | |
45d8adaa |
425 | #if defined(cray) || defined(gould) |
426 | # define SLOPPYDIVIDE |
427 | #endif |
428 | |
429 | #if defined(cray) || defined(convex) || BYTEORDER > 0xffff |
430 | # define QUAD |
431 | #endif |
432 | |
433 | #ifdef QUAD |
434 | # ifdef cray |
435 | # define quad int |
436 | # else |
437 | # ifdef convex |
438 | # define quad long long |
439 | # else |
440 | # define quad long |
441 | # endif |
442 | # endif |
443 | #endif |
444 | |
450a55e4 |
445 | typedef unsigned int STRLEN; |
446 | |
8d063cd8 |
447 | typedef struct arg ARG; |
448 | typedef struct cmd CMD; |
449 | typedef struct formcmd FCMD; |
450 | typedef struct scanpat SPAT; |
8d063cd8 |
451 | typedef struct stio STIO; |
378cc40b |
452 | typedef struct sub SUBR; |
8d063cd8 |
453 | typedef struct string STR; |
454 | typedef struct atbl ARRAY; |
455 | typedef struct htbl HASH; |
378cc40b |
456 | typedef struct regexp REGEXP; |
a687059c |
457 | typedef struct stabptrs STBP; |
458 | typedef struct stab STAB; |
d9d8d8de |
459 | typedef struct callsave CSV; |
8d063cd8 |
460 | |
378cc40b |
461 | #include "handy.h" |
462 | #include "regexp.h" |
8d063cd8 |
463 | #include "str.h" |
378cc40b |
464 | #include "util.h" |
8d063cd8 |
465 | #include "form.h" |
466 | #include "stab.h" |
467 | #include "spat.h" |
468 | #include "arg.h" |
469 | #include "cmd.h" |
470 | #include "array.h" |
471 | #include "hash.h" |
472 | |
450a55e4 |
473 | #if defined(iAPX286) || defined(M_I286) || defined(I80286) |
a687059c |
474 | # define I286 |
475 | #endif |
476 | |
352d5a3a |
477 | #ifndef STANDARD_C |
135863df |
478 | #ifdef CHARSPRINTF |
479 | char *sprintf(); |
480 | #else |
481 | int sprintf(); |
482 | #endif |
a687059c |
483 | #endif |
135863df |
484 | |
8d063cd8 |
485 | EXT char *Yes INIT("1"); |
486 | EXT char *No INIT(""); |
487 | |
a687059c |
488 | /* "gimme" values */ |
489 | |
490 | /* Note: cmd.c assumes that it can use && to produce one of these values! */ |
491 | #define G_SCALAR 0 |
492 | #define G_ARRAY 1 |
493 | |
494 | #ifdef CRIPPLED_CC |
495 | int str_true(); |
496 | #else /* !CRIPPLED_CC */ |
497 | #define str_true(str) (Str = (str), \ |
498 | (Str->str_pok ? \ |
499 | ((*Str->str_ptr > '0' || \ |
500 | Str->str_cur > 1 || \ |
501 | (Str->str_cur && *Str->str_ptr != '0')) ? 1 : 0) \ |
502 | : \ |
503 | (Str->str_nok ? (Str->str_u.str_nval != 0.0) : 0 ) )) |
504 | #endif /* CRIPPLED_CC */ |
8d063cd8 |
505 | |
135863df |
506 | #ifdef DEBUGGING |
a687059c |
507 | #define str_peek(str) (Str = (str), \ |
508 | (Str->str_pok ? \ |
509 | Str->str_ptr : \ |
510 | (Str->str_nok ? \ |
511 | (sprintf(tokenbuf,"num(%g)",Str->str_u.str_nval), \ |
512 | (char*)tokenbuf) : \ |
513 | "" ))) |
135863df |
514 | #endif |
515 | |
a687059c |
516 | #ifdef CRIPPLED_CC |
517 | char *str_get(); |
518 | #else |
519 | #ifdef TAINT |
520 | #define str_get(str) (Str = (str), tainted |= Str->str_tainted, \ |
521 | (Str->str_pok ? Str->str_ptr : str_2ptr(Str))) |
522 | #else |
8d063cd8 |
523 | #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str))) |
a687059c |
524 | #endif /* TAINT */ |
525 | #endif /* CRIPPLED_CC */ |
526 | |
527 | #ifdef CRIPPLED_CC |
528 | double str_gnum(); |
529 | #else /* !CRIPPLED_CC */ |
530 | #ifdef TAINT |
531 | #define str_gnum(str) (Str = (str), tainted |= Str->str_tainted, \ |
532 | (Str->str_nok ? Str->str_u.str_nval : str_2num(Str))) |
533 | #else /* !TAINT */ |
534 | #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_u.str_nval : str_2num(Str))) |
535 | #endif /* TAINT*/ |
536 | #endif /* CRIPPLED_CC */ |
8d063cd8 |
537 | EXT STR *Str; |
538 | |
539 | #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len) |
540 | |
450a55e4 |
541 | #ifndef MSDOS |
a687059c |
542 | #define STR_GROW(str,len) if ((str)->str_len < (len)) str_grow(str,len) |
450a55e4 |
543 | #define Str_Grow str_grow |
544 | #else |
545 | /* extra parentheses intentionally NOT placed around "len"! */ |
546 | #define STR_GROW(str,len) if ((str)->str_len < (unsigned long)len) \ |
547 | str_grow(str,(unsigned long)len) |
548 | #define Str_Grow(str,len) str_grow(str,(unsigned long)(len)) |
549 | #endif /* MSDOS */ |
a687059c |
550 | |
551 | #ifndef BYTEORDER |
ffed7fef |
552 | #define BYTEORDER 0x1234 |
a687059c |
553 | #endif |
554 | |
fe14fcc3 |
555 | #if defined(htonl) && !defined(HAS_HTONL) |
556 | #define HAS_HTONL |
ae986130 |
557 | #endif |
fe14fcc3 |
558 | #if defined(htons) && !defined(HAS_HTONS) |
559 | #define HAS_HTONS |
ae986130 |
560 | #endif |
fe14fcc3 |
561 | #if defined(ntohl) && !defined(HAS_NTOHL) |
562 | #define HAS_NTOHL |
ae986130 |
563 | #endif |
fe14fcc3 |
564 | #if defined(ntohs) && !defined(HAS_NTOHS) |
565 | #define HAS_NTOHS |
ae986130 |
566 | #endif |
fe14fcc3 |
567 | #ifndef HAS_HTONL |
d9d8d8de |
568 | #if (BYTEORDER & 0xffff) != 0x4321 |
fe14fcc3 |
569 | #define HAS_HTONS |
570 | #define HAS_HTONL |
571 | #define HAS_NTOHS |
572 | #define HAS_NTOHL |
a687059c |
573 | #define MYSWAP |
574 | #define htons my_swap |
575 | #define htonl my_htonl |
576 | #define ntohs my_swap |
577 | #define ntohl my_ntohl |
578 | #endif |
579 | #else |
d9d8d8de |
580 | #if (BYTEORDER & 0xffff) == 0x4321 |
fe14fcc3 |
581 | #undef HAS_HTONS |
582 | #undef HAS_HTONL |
583 | #undef HAS_NTOHS |
584 | #undef HAS_NTOHL |
a687059c |
585 | #endif |
586 | #endif |
587 | |
0f85fab0 |
588 | #ifdef CASTNEGFLOAT |
589 | #define U_S(what) ((unsigned short)(what)) |
590 | #define U_I(what) ((unsigned int)(what)) |
591 | #define U_L(what) ((unsigned long)(what)) |
592 | #else |
593 | unsigned long castulong(); |
594 | #define U_S(what) ((unsigned int)castulong(what)) |
595 | #define U_I(what) ((unsigned int)castulong(what)) |
596 | #define U_L(what) (castulong(what)) |
597 | #endif |
598 | |
8d063cd8 |
599 | CMD *add_label(); |
600 | CMD *block_head(); |
601 | CMD *append_line(); |
602 | CMD *make_acmd(); |
603 | CMD *make_ccmd(); |
a687059c |
604 | CMD *make_icmd(); |
8d063cd8 |
605 | CMD *invert(); |
606 | CMD *addcond(); |
607 | CMD *addloop(); |
608 | CMD *wopt(); |
378cc40b |
609 | CMD *over(); |
8d063cd8 |
610 | |
8d063cd8 |
611 | STAB *stabent(); |
378cc40b |
612 | STAB *genstab(); |
8d063cd8 |
613 | |
378cc40b |
614 | ARG *stab2arg(); |
8d063cd8 |
615 | ARG *op_new(); |
616 | ARG *make_op(); |
8d063cd8 |
617 | ARG *make_match(); |
618 | ARG *make_split(); |
a687059c |
619 | ARG *rcatmaybe(); |
378cc40b |
620 | ARG *listish(); |
a687059c |
621 | ARG *maybelistish(); |
378cc40b |
622 | ARG *localize(); |
a687059c |
623 | ARG *fixeval(); |
624 | ARG *jmaybe(); |
378cc40b |
625 | ARG *l(); |
a687059c |
626 | ARG *fixl(); |
378cc40b |
627 | ARG *mod_match(); |
628 | ARG *make_list(); |
629 | ARG *cmd_to_arg(); |
630 | ARG *addflags(); |
631 | ARG *hide_ary(); |
632 | ARG *cval_to_arg(); |
8d063cd8 |
633 | |
8d063cd8 |
634 | STR *str_new(); |
635 | STR *stab_str(); |
a687059c |
636 | |
637 | int do_each(); |
638 | int do_subr(); |
639 | int do_match(); |
640 | int do_unpack(); |
641 | int eval(); /* this evaluates expressions */ |
642 | int do_eval(); /* this evaluates eval operator */ |
643 | int do_assign(); |
378cc40b |
644 | |
645 | SUBR *make_sub(); |
8d063cd8 |
646 | |
647 | FCMD *load_format(); |
648 | |
649 | char *scanpat(); |
650 | char *scansubst(); |
651 | char *scantrans(); |
652 | char *scanstr(); |
fe14fcc3 |
653 | char *scanident(); |
8d063cd8 |
654 | char *str_append_till(); |
655 | char *str_gets(); |
a687059c |
656 | char *str_grow(); |
8d063cd8 |
657 | |
8d063cd8 |
658 | bool do_open(); |
659 | bool do_close(); |
660 | bool do_print(); |
378cc40b |
661 | bool do_aprint(); |
662 | bool do_exec(); |
663 | bool do_aexec(); |
8d063cd8 |
664 | |
665 | int do_subst(); |
378cc40b |
666 | int cando(); |
667 | int ingroup(); |
8d063cd8 |
668 | |
378cc40b |
669 | void str_replace(); |
670 | void str_inc(); |
671 | void str_dec(); |
8d063cd8 |
672 | void str_free(); |
a687059c |
673 | void stab_clear(); |
378cc40b |
674 | void do_join(); |
378cc40b |
675 | void do_sprintf(); |
a687059c |
676 | void do_accept(); |
ac58e20f |
677 | void do_pipe(); |
a687059c |
678 | void do_vecset(); |
fe14fcc3 |
679 | void do_unshift(); |
680 | void do_execfree(); |
681 | void magicalize(); |
682 | void magicname(); |
a687059c |
683 | void savelist(); |
684 | void saveitem(); |
685 | void saveint(); |
686 | void savelong(); |
687 | void savesptr(); |
688 | void savehptr(); |
689 | void restorelist(); |
ac58e20f |
690 | void repeatcpy(); |
a687059c |
691 | HASH *savehash(); |
692 | ARRAY *saveary(); |
378cc40b |
693 | |
ac58e20f |
694 | EXT char **origargv; |
695 | EXT int origargc; |
fe14fcc3 |
696 | EXT char **origenviron; |
35c8bce7 |
697 | extern char **environ; |
698 | |
45d8adaa |
699 | EXT long subline INIT(0); |
a687059c |
700 | EXT STR *subname INIT(Nullstr); |
8d063cd8 |
701 | EXT int arybase INIT(0); |
702 | |
703 | struct outrec { |
d9d8d8de |
704 | long o_lines; |
705 | char *o_str; |
706 | int o_len; |
8d063cd8 |
707 | }; |
708 | |
709 | EXT struct outrec outrec; |
710 | EXT struct outrec toprec; |
711 | |
a687059c |
712 | EXT STAB *stdinstab INIT(Nullstab); |
8d063cd8 |
713 | EXT STAB *last_in_stab INIT(Nullstab); |
714 | EXT STAB *defstab INIT(Nullstab); |
715 | EXT STAB *argvstab INIT(Nullstab); |
716 | EXT STAB *envstab INIT(Nullstab); |
717 | EXT STAB *sigstab INIT(Nullstab); |
718 | EXT STAB *defoutstab INIT(Nullstab); |
719 | EXT STAB *curoutstab INIT(Nullstab); |
720 | EXT STAB *argvoutstab INIT(Nullstab); |
378cc40b |
721 | EXT STAB *incstab INIT(Nullstab); |
a687059c |
722 | EXT STAB *leftstab INIT(Nullstab); |
723 | EXT STAB *amperstab INIT(Nullstab); |
724 | EXT STAB *rightstab INIT(Nullstab); |
725 | EXT STAB *DBstab INIT(Nullstab); |
d9d8d8de |
726 | EXT STAB *DBline INIT(Nullstab); |
a687059c |
727 | EXT STAB *DBsub INIT(Nullstab); |
728 | |
729 | EXT HASH *defstash; /* main symbol table */ |
730 | EXT HASH *curstash; /* symbol table for current package */ |
731 | EXT HASH *debstash; /* symbol table for perldb package */ |
732 | |
733 | EXT STR *curstname; /* name of current package */ |
8d063cd8 |
734 | |
735 | EXT STR *freestrroot INIT(Nullstr); |
378cc40b |
736 | EXT STR *lastretstr INIT(Nullstr); |
a687059c |
737 | EXT STR *DBsingle INIT(Nullstr); |
d9d8d8de |
738 | EXT STR *DBtrace INIT(Nullstr); |
739 | EXT STR *DBsignal INIT(Nullstr); |
a687059c |
740 | |
741 | EXT int lastspbase; |
742 | EXT int lastsize; |
8d063cd8 |
743 | |
45d8adaa |
744 | EXT char *hexdigit INIT("0123456789abcdef0123456789ABCDEFx"); |
378cc40b |
745 | EXT char *origfilename; |
ac58e20f |
746 | EXT FILE * VOLATILE rsfp; |
8d063cd8 |
747 | EXT char buf[1024]; |
a687059c |
748 | EXT char *bufptr; |
749 | EXT char *oldbufptr; |
750 | EXT char *oldoldbufptr; |
751 | EXT char *bufend; |
8d063cd8 |
752 | |
753 | EXT STR *linestr INIT(Nullstr); |
754 | |
fe14fcc3 |
755 | EXT char *rs INIT("\n"); |
756 | EXT int rschar INIT('\n'); /* final char of rs, or 0777 if none */ |
a687059c |
757 | EXT int rslen INIT(1); |
8d063cd8 |
758 | EXT char *ofs INIT(Nullch); |
a687059c |
759 | EXT int ofslen INIT(0); |
8d063cd8 |
760 | EXT char *ors INIT(Nullch); |
a687059c |
761 | EXT int orslen INIT(0); |
8d063cd8 |
762 | EXT char *ofmt INIT(Nullch); |
763 | EXT char *inplace INIT(Nullch); |
a687059c |
764 | EXT char *nointrp INIT(""); |
8d063cd8 |
765 | |
378cc40b |
766 | EXT bool preprocess INIT(FALSE); |
767 | EXT bool minus_n INIT(FALSE); |
768 | EXT bool minus_p INIT(FALSE); |
fe14fcc3 |
769 | EXT bool minus_l INIT(FALSE); |
378cc40b |
770 | EXT bool minus_a INIT(FALSE); |
771 | EXT bool doswitches INIT(FALSE); |
772 | EXT bool dowarn INIT(FALSE); |
450a55e4 |
773 | EXT bool doextract INIT(FALSE); |
378cc40b |
774 | EXT bool allstabs INIT(FALSE); /* init all customary symbols in symbol table?*/ |
775 | EXT bool sawampersand INIT(FALSE); /* must save all match strings */ |
776 | EXT bool sawstudy INIT(FALSE); /* do fbminstr on all strings */ |
a687059c |
777 | EXT bool sawi INIT(FALSE); /* study must assume case insensitive */ |
778 | EXT bool sawvec INIT(FALSE); |
ac58e20f |
779 | EXT bool localizing INIT(FALSE); /* are we processing a local() list? */ |
a687059c |
780 | |
352d5a3a |
781 | #ifndef MAXSYSFD |
782 | # define MAXSYSFD 2 |
783 | #endif |
784 | EXT int maxsysfd INIT(MAXSYSFD); /* top fd to pass to subprocesses */ |
785 | |
ae986130 |
786 | #ifdef CSH |
787 | char *cshname INIT(CSH); |
788 | int cshlen INIT(0); |
789 | #endif /* CSH */ |
a687059c |
790 | |
791 | #ifdef TAINT |
792 | EXT bool tainted INIT(FALSE); /* using variables controlled by $< */ |
793 | #endif |
378cc40b |
794 | |
450a55e4 |
795 | #ifndef MSDOS |
378cc40b |
796 | #define TMPPATH "/tmp/perl-eXXXXXX" |
450a55e4 |
797 | #else |
57ebbfd0 |
798 | #define TMPPATH "plXXXXXX" |
450a55e4 |
799 | #endif /* MSDOS */ |
378cc40b |
800 | EXT char *e_tmpname; |
801 | EXT FILE *e_fp INIT(Nullfp); |
802 | |
8d063cd8 |
803 | EXT char tokenbuf[256]; |
a687059c |
804 | EXT int expectterm INIT(TRUE); /* how to interpret ambiguous tokens */ |
ac58e20f |
805 | EXT VOLATILE int in_eval INIT(FALSE); /* trap fatal errors? */ |
a687059c |
806 | EXT int multiline INIT(0); /* $*--do strings hold >1 line? */ |
807 | EXT int forkprocess; /* so do_open |- can return proc# */ |
808 | EXT int do_undump INIT(0); /* -u or dump seen? */ |
809 | EXT int error_count INIT(0); /* how many errors so far, max 10 */ |
810 | EXT int multi_start INIT(0); /* 1st line of multi-line string */ |
811 | EXT int multi_end INIT(0); /* last line of multi-line string */ |
812 | EXT int multi_open INIT(0); /* delimiter of said string */ |
813 | EXT int multi_close INIT(0); /* delimiter of said string */ |
8d063cd8 |
814 | |
815 | FILE *popen(); |
816 | /* char *str_get(); */ |
817 | STR *interp(); |
818 | void free_arg(); |
819 | STIO *stio_new(); |
1462b684 |
820 | void hoistmust(); |
45d8adaa |
821 | void scanconst(); |
8d063cd8 |
822 | |
823 | EXT struct stat statbuf; |
a687059c |
824 | EXT struct stat statcache; |
825 | STAB *statstab INIT(Nullstab); |
826 | STR *statname; |
d9d8d8de |
827 | #ifndef MSDOS |
8d063cd8 |
828 | EXT struct tms timesbuf; |
d9d8d8de |
829 | #endif |
378cc40b |
830 | EXT int uid; |
831 | EXT int euid; |
a687059c |
832 | EXT int gid; |
833 | EXT int egid; |
378cc40b |
834 | UIDTYPE getuid(); |
835 | UIDTYPE geteuid(); |
836 | GIDTYPE getgid(); |
837 | GIDTYPE getegid(); |
838 | EXT int unsafe; |
8d063cd8 |
839 | |
840 | #ifdef DEBUGGING |
ac58e20f |
841 | EXT VOLATILE int debug INIT(0); |
8d063cd8 |
842 | EXT int dlevel INIT(0); |
a687059c |
843 | EXT int dlmax INIT(128); |
844 | EXT char *debname; |
845 | EXT char *debdelim; |
d96024cf |
846 | #define YYDEBUG 1 |
8d063cd8 |
847 | #endif |
a687059c |
848 | EXT int perldb INIT(0); |
fe14fcc3 |
849 | #define YYMAXDEPTH 300 |
8d063cd8 |
850 | |
378cc40b |
851 | EXT line_t cmdline INIT(NOLINE); |
852 | |
a687059c |
853 | EXT STR str_undef; |
8d063cd8 |
854 | EXT STR str_no; |
855 | EXT STR str_yes; |
856 | |
857 | /* runtime control stuff */ |
858 | |
859 | EXT struct loop { |
a687059c |
860 | char *loop_label; /* what the loop was called, if anything */ |
861 | int loop_sp; /* stack pointer to copy stuff down to */ |
8d063cd8 |
862 | jmp_buf loop_env; |
a687059c |
863 | } *loop_stack; |
8d063cd8 |
864 | |
865 | EXT int loop_ptr INIT(-1); |
a687059c |
866 | EXT int loop_max INIT(128); |
8d063cd8 |
867 | |
868 | EXT jmp_buf top_env; |
869 | |
ac58e20f |
870 | EXT char * VOLATILE goto_targ INIT(Nullch); /* cmd_exec gets strange when set */ |
8d063cd8 |
871 | |
450a55e4 |
872 | struct ufuncs { |
873 | int (*uf_val)(); |
874 | int (*uf_set)(); |
875 | int uf_index; |
876 | }; |
877 | |
a687059c |
878 | EXT ARRAY *stack; /* THE STACK */ |
879 | |
ac58e20f |
880 | EXT ARRAY * VOLATILE savestack; /* to save non-local values on */ |
378cc40b |
881 | |
882 | EXT ARRAY *tosave; /* strings to save on recursive subroutine */ |
883 | |
a687059c |
884 | EXT ARRAY *lineary; /* lines of script for debugger */ |
d9d8d8de |
885 | EXT ARRAY *dbargs; /* args to call listed by caller function */ |
a687059c |
886 | |
d9d8d8de |
887 | EXT ARRAY *fdpid; /* keep fd-to-pid mappings for mypopen */ |
888 | EXT HASH *pidstatus; /* keep pid-to-status mappings for waitpid */ |
a687059c |
889 | |
ac58e20f |
890 | EXT int *di; /* for tmp use in debuggers */ |
891 | EXT char *dc; |
892 | EXT short *ds; |
893 | |
fe14fcc3 |
894 | /* Fix these up for __STDC__ */ |
895 | EXT long basetime INIT(0); |
896 | char *mktemp(); |
352d5a3a |
897 | #ifndef STANDARD_C |
fe14fcc3 |
898 | /* All of these are in stdlib.h or time.h for ANSI C */ |
8d063cd8 |
899 | double atof(); |
a687059c |
900 | long time(); |
8d063cd8 |
901 | struct tm *gmtime(), *localtime(); |
378cc40b |
902 | char *index(), *rindex(); |
903 | char *strcpy(), *strcat(); |
352d5a3a |
904 | #endif /* ! STANDARD_C */ |
8d063cd8 |
905 | |
8d063cd8 |
906 | #ifdef EUNICE |
378cc40b |
907 | #define UNLINK unlnk |
908 | int unlnk(); |
8d063cd8 |
909 | #else |
910 | #define UNLINK unlink |
911 | #endif |
a687059c |
912 | |
fe14fcc3 |
913 | #ifndef HAS_SETREUID |
914 | #ifdef HAS_SETRESUID |
a687059c |
915 | #define setreuid(r,e) setresuid(r,e,-1) |
fe14fcc3 |
916 | #define HAS_SETREUID |
a687059c |
917 | #endif |
918 | #endif |
fe14fcc3 |
919 | #ifndef HAS_SETREGID |
920 | #ifdef HAS_SETRESGID |
a687059c |
921 | #define setregid(r,e) setresgid(r,e,-1) |
fe14fcc3 |
922 | #define HAS_SETREGID |
a687059c |
923 | #endif |
924 | #endif |