Commit | Line | Data |
d48672a2 |
1 | /* $RCSfile: stab.h,v $$Revision: 4.0.1.1 $$Date: 91/06/07 11:56:35 $ |
a687059c |
2 | * |
d48672a2 |
3 | * Copyright (c) 1991, Larry Wall |
a687059c |
4 | * |
d48672a2 |
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: stab.h,v $ |
d48672a2 |
9 | * Revision 4.0.1.1 91/06/07 11:56:35 lwall |
10 | * patch4: new copyright notice |
11 | * patch4: length($`), length($&), length($') now optimized to avoid string copy |
12 | * |
fe14fcc3 |
13 | * Revision 4.0 91/03/20 01:39:49 lwall |
14 | * 4.0 baseline. |
8d063cd8 |
15 | * |
16 | */ |
17 | |
a687059c |
18 | struct stabptrs { |
19 | char stbp_magic[4]; |
20 | STR *stbp_val; /* scalar value */ |
21 | struct stio *stbp_io; /* filehandle value */ |
22 | FCMD *stbp_form; /* format value */ |
23 | ARRAY *stbp_array; /* array value */ |
24 | HASH *stbp_hash; /* associative array value */ |
76854fea |
25 | HASH *stbp_stash; /* symbol table for this stab */ |
a687059c |
26 | SUBR *stbp_sub; /* subroutine value */ |
27 | int stbp_lastexpr; /* used by nothing_in_common() */ |
28 | line_t stbp_line; /* line first declared at (for -w) */ |
29 | char stbp_flags; |
8d063cd8 |
30 | }; |
31 | |
663a0e37 |
32 | #if defined(CRIPPLED_CC) && (defined(iAPX286) || defined(M_I286) || defined(I80286)) |
33 | #define MICROPORT |
34 | #endif |
35 | |
a687059c |
36 | #define stab_magic(stab) (((STBP*)(stab->str_ptr))->stbp_magic) |
37 | #define stab_val(stab) (((STBP*)(stab->str_ptr))->stbp_val) |
38 | #define stab_io(stab) (((STBP*)(stab->str_ptr))->stbp_io) |
39 | #define stab_form(stab) (((STBP*)(stab->str_ptr))->stbp_form) |
40 | #define stab_xarray(stab) (((STBP*)(stab->str_ptr))->stbp_array) |
663a0e37 |
41 | #ifdef MICROPORT /* Microport 2.4 hack */ |
42 | ARRAY *stab_array(); |
43 | #else |
a687059c |
44 | #define stab_array(stab) (((STBP*)(stab->str_ptr))->stbp_array ? \ |
45 | ((STBP*)(stab->str_ptr))->stbp_array : \ |
46 | ((STBP*)(aadd(stab)->str_ptr))->stbp_array) |
663a0e37 |
47 | #endif |
a687059c |
48 | #define stab_xhash(stab) (((STBP*)(stab->str_ptr))->stbp_hash) |
663a0e37 |
49 | #ifdef MICROPORT /* Microport 2.4 hack */ |
50 | HASH *stab_hash(); |
51 | #else |
a687059c |
52 | #define stab_hash(stab) (((STBP*)(stab->str_ptr))->stbp_hash ? \ |
53 | ((STBP*)(stab->str_ptr))->stbp_hash : \ |
54 | ((STBP*)(hadd(stab)->str_ptr))->stbp_hash) |
663a0e37 |
55 | #endif /* Microport 2.4 hack */ |
76854fea |
56 | #define stab_stash(stab) (((STBP*)(stab->str_ptr))->stbp_stash) |
a687059c |
57 | #define stab_sub(stab) (((STBP*)(stab->str_ptr))->stbp_sub) |
58 | #define stab_lastexpr(stab) (((STBP*)(stab->str_ptr))->stbp_lastexpr) |
59 | #define stab_line(stab) (((STBP*)(stab->str_ptr))->stbp_line) |
60 | #define stab_flags(stab) (((STBP*)(stab->str_ptr))->stbp_flags) |
61 | #define stab_name(stab) (stab->str_magic->str_ptr) |
62 | |
8d063cd8 |
63 | #define SF_VMAGIC 1 /* call routine to dereference STR val */ |
378cc40b |
64 | #define SF_MULTI 2 /* seen more than once */ |
8d063cd8 |
65 | |
66 | struct stio { |
a687059c |
67 | FILE *ifp; /* ifp and ofp are normally the same */ |
68 | FILE *ofp; /* but sockets need separate streams */ |
fe14fcc3 |
69 | #ifdef HAS_READDIR |
a687059c |
70 | DIR *dirp; /* for opendir, readdir, etc */ |
71 | #endif |
72 | long lines; /* $. */ |
73 | long page; /* $% */ |
74 | long page_len; /* $= */ |
75 | long lines_left; /* $- */ |
76 | char *top_name; /* $^ */ |
77 | STAB *top_stab; /* $^ */ |
78 | char *fmt_name; /* $~ */ |
79 | STAB *fmt_stab; /* $~ */ |
80 | short subprocess; /* -| or |- */ |
8d063cd8 |
81 | char type; |
82 | char flags; |
83 | }; |
84 | |
85 | #define IOF_ARGV 1 /* this fp iterates over ARGV */ |
86 | #define IOF_START 2 /* check for null ARGV and substitute '-' */ |
87 | #define IOF_FLUSH 4 /* this fp wants a flush after write op */ |
88 | |
378cc40b |
89 | struct sub { |
90 | CMD *cmd; |
e929a76b |
91 | int (*usersub)(); |
92 | int userindex; |
76854fea |
93 | STAB *filestab; |
378cc40b |
94 | long depth; /* >= 2 indicates recursive call */ |
95 | ARRAY *tosave; |
96 | }; |
97 | |
8d063cd8 |
98 | #define Nullstab Null(STAB*) |
99 | |
d48672a2 |
100 | STRLEN stab_len(); |
101 | |
a687059c |
102 | #define STAB_STR(s) (tmpstab = (s), stab_flags(tmpstab) & SF_VMAGIC ? stab_str(stab_val(tmpstab)->str_magic) : stab_val(tmpstab)) |
d48672a2 |
103 | #define STAB_LEN(s) (tmpstab = (s), stab_flags(tmpstab) & SF_VMAGIC ? stab_len(stab_val(tmpstab)->str_magic) : stab_val(tmpstab)->str_cur) |
a687059c |
104 | #define STAB_GET(s) (tmpstab = (s), str_get(stab_flags(tmpstab) & SF_VMAGIC ? stab_str(tmpstab->str_magic) : stab_val(tmpstab))) |
105 | #define STAB_GNUM(s) (tmpstab = (s), str_gnum(stab_flags(tmpstab) & SF_VMAGIC ? stab_str(tmpstab->str_magic) : stab_val(tmpstab))) |
8d063cd8 |
106 | |
107 | EXT STAB *tmpstab; |
108 | |
109 | EXT STAB *stab_index[128]; |
110 | |
378cc40b |
111 | EXT unsigned short statusvalue; |
8d063cd8 |
112 | |
a687059c |
113 | EXT int delaymagic INIT(0); |
114 | #define DM_DELAY 1 |
115 | #define DM_REUID 2 |
116 | #define DM_REGID 4 |
117 | |
8d063cd8 |
118 | STAB *aadd(); |
119 | STAB *hadd(); |
76854fea |
120 | STAB *fstab(); |