Commit | Line | Data |
2b69d0c2 |
1 | /* $RCSfile: stab.h,v $$Revision: 4.0.1.3 $$Date: 92/06/08 15:33:44 $ |
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 $ |
2b69d0c2 |
9 | * Revision 4.0.1.3 92/06/08 15:33:44 lwall |
10 | * patch20: fixed confusion between a *var's real name and its effective name |
11 | * patch20: ($<,$>) = ... didn't work on some architectures |
12 | * |
f0fcb552 |
13 | * Revision 4.0.1.2 91/11/05 18:36:15 lwall |
14 | * patch11: length($x) was sometimes wrong for numeric $x |
15 | * |
d48672a2 |
16 | * Revision 4.0.1.1 91/06/07 11:56:35 lwall |
17 | * patch4: new copyright notice |
18 | * patch4: length($`), length($&), length($') now optimized to avoid string copy |
19 | * |
fe14fcc3 |
20 | * Revision 4.0 91/03/20 01:39:49 lwall |
21 | * 4.0 baseline. |
8d063cd8 |
22 | * |
23 | */ |
24 | |
a687059c |
25 | struct stabptrs { |
26 | char stbp_magic[4]; |
27 | STR *stbp_val; /* scalar value */ |
28 | struct stio *stbp_io; /* filehandle value */ |
29 | FCMD *stbp_form; /* format value */ |
30 | ARRAY *stbp_array; /* array value */ |
31 | HASH *stbp_hash; /* associative array value */ |
2b69d0c2 |
32 | STAB *stbp_stab; /* effective stab, if *glob */ |
a687059c |
33 | SUBR *stbp_sub; /* subroutine value */ |
34 | int stbp_lastexpr; /* used by nothing_in_common() */ |
35 | line_t stbp_line; /* line first declared at (for -w) */ |
36 | char stbp_flags; |
8d063cd8 |
37 | }; |
38 | |
663a0e37 |
39 | #if defined(CRIPPLED_CC) && (defined(iAPX286) || defined(M_I286) || defined(I80286)) |
40 | #define MICROPORT |
41 | #endif |
42 | |
a687059c |
43 | #define stab_magic(stab) (((STBP*)(stab->str_ptr))->stbp_magic) |
44 | #define stab_val(stab) (((STBP*)(stab->str_ptr))->stbp_val) |
45 | #define stab_io(stab) (((STBP*)(stab->str_ptr))->stbp_io) |
46 | #define stab_form(stab) (((STBP*)(stab->str_ptr))->stbp_form) |
47 | #define stab_xarray(stab) (((STBP*)(stab->str_ptr))->stbp_array) |
663a0e37 |
48 | #ifdef MICROPORT /* Microport 2.4 hack */ |
49 | ARRAY *stab_array(); |
50 | #else |
a687059c |
51 | #define stab_array(stab) (((STBP*)(stab->str_ptr))->stbp_array ? \ |
52 | ((STBP*)(stab->str_ptr))->stbp_array : \ |
53 | ((STBP*)(aadd(stab)->str_ptr))->stbp_array) |
663a0e37 |
54 | #endif |
a687059c |
55 | #define stab_xhash(stab) (((STBP*)(stab->str_ptr))->stbp_hash) |
663a0e37 |
56 | #ifdef MICROPORT /* Microport 2.4 hack */ |
57 | HASH *stab_hash(); |
58 | #else |
a687059c |
59 | #define stab_hash(stab) (((STBP*)(stab->str_ptr))->stbp_hash ? \ |
60 | ((STBP*)(stab->str_ptr))->stbp_hash : \ |
61 | ((STBP*)(hadd(stab)->str_ptr))->stbp_hash) |
663a0e37 |
62 | #endif /* Microport 2.4 hack */ |
a687059c |
63 | #define stab_sub(stab) (((STBP*)(stab->str_ptr))->stbp_sub) |
64 | #define stab_lastexpr(stab) (((STBP*)(stab->str_ptr))->stbp_lastexpr) |
65 | #define stab_line(stab) (((STBP*)(stab->str_ptr))->stbp_line) |
66 | #define stab_flags(stab) (((STBP*)(stab->str_ptr))->stbp_flags) |
2b69d0c2 |
67 | |
68 | #define stab_stab(stab) (stab->str_magic->str_u.str_stab) |
69 | #define stab_estab(stab) (((STBP*)(stab->str_ptr))->stbp_stab) |
70 | |
a687059c |
71 | #define stab_name(stab) (stab->str_magic->str_ptr) |
2b69d0c2 |
72 | #define stab_ename(stab) stab_name(stab_estab(stab)) |
73 | |
74 | #define stab_stash(stab) (stab->str_magic->str_u.str_stash) |
75 | #define stab_estash(stab) stab_stash(stab_estab(stab)) |
a687059c |
76 | |
8d063cd8 |
77 | #define SF_VMAGIC 1 /* call routine to dereference STR val */ |
378cc40b |
78 | #define SF_MULTI 2 /* seen more than once */ |
8d063cd8 |
79 | |
80 | struct stio { |
a687059c |
81 | FILE *ifp; /* ifp and ofp are normally the same */ |
82 | FILE *ofp; /* but sockets need separate streams */ |
fe14fcc3 |
83 | #ifdef HAS_READDIR |
a687059c |
84 | DIR *dirp; /* for opendir, readdir, etc */ |
85 | #endif |
86 | long lines; /* $. */ |
87 | long page; /* $% */ |
88 | long page_len; /* $= */ |
89 | long lines_left; /* $- */ |
90 | char *top_name; /* $^ */ |
91 | STAB *top_stab; /* $^ */ |
92 | char *fmt_name; /* $~ */ |
93 | STAB *fmt_stab; /* $~ */ |
94 | short subprocess; /* -| or |- */ |
8d063cd8 |
95 | char type; |
96 | char flags; |
97 | }; |
98 | |
99 | #define IOF_ARGV 1 /* this fp iterates over ARGV */ |
100 | #define IOF_START 2 /* check for null ARGV and substitute '-' */ |
101 | #define IOF_FLUSH 4 /* this fp wants a flush after write op */ |
102 | |
378cc40b |
103 | struct sub { |
104 | CMD *cmd; |
e929a76b |
105 | int (*usersub)(); |
106 | int userindex; |
76854fea |
107 | STAB *filestab; |
378cc40b |
108 | long depth; /* >= 2 indicates recursive call */ |
109 | ARRAY *tosave; |
110 | }; |
111 | |
8d063cd8 |
112 | #define Nullstab Null(STAB*) |
113 | |
d48672a2 |
114 | STRLEN stab_len(); |
115 | |
a687059c |
116 | #define STAB_STR(s) (tmpstab = (s), stab_flags(tmpstab) & SF_VMAGIC ? stab_str(stab_val(tmpstab)->str_magic) : stab_val(tmpstab)) |
f0fcb552 |
117 | #define STAB_LEN(s) (tmpstab = (s), stab_flags(tmpstab) & SF_VMAGIC ? stab_len(stab_val(tmpstab)->str_magic) : str_len(stab_val(tmpstab))) |
a687059c |
118 | #define STAB_GET(s) (tmpstab = (s), str_get(stab_flags(tmpstab) & SF_VMAGIC ? stab_str(tmpstab->str_magic) : stab_val(tmpstab))) |
119 | #define STAB_GNUM(s) (tmpstab = (s), str_gnum(stab_flags(tmpstab) & SF_VMAGIC ? stab_str(tmpstab->str_magic) : stab_val(tmpstab))) |
8d063cd8 |
120 | |
121 | EXT STAB *tmpstab; |
122 | |
123 | EXT STAB *stab_index[128]; |
124 | |
378cc40b |
125 | EXT unsigned short statusvalue; |
8d063cd8 |
126 | |
a687059c |
127 | EXT int delaymagic INIT(0); |
2b69d0c2 |
128 | #define DM_UID 0x003 |
129 | #define DM_RUID 0x001 |
130 | #define DM_EUID 0x002 |
131 | #define DM_GID 0x030 |
132 | #define DM_RGID 0x010 |
133 | #define DM_EGID 0x020 |
134 | #define DM_DELAY 0x100 |
a687059c |
135 | |
8d063cd8 |
136 | STAB *aadd(); |
137 | STAB *hadd(); |
76854fea |
138 | STAB *fstab(); |
2b69d0c2 |
139 | void stabset(); |
140 | void stab_fullname(); |
141 | void stab_efullname(); |
142 | void stab_check(); |