1 | /* $RCSfile: stab.h,v $$Revision: 1.1.1.1 $$Date: 1996-10-02 06:39:58 $ |
---|
2 | * |
---|
3 | * Copyright (c) 1991, Larry Wall |
---|
4 | * |
---|
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. |
---|
7 | * |
---|
8 | * $Log: not supported by cvs2svn $ |
---|
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 | * |
---|
13 | * Revision 4.0.1.2 91/11/05 18:36:15 lwall |
---|
14 | * patch11: length($x) was sometimes wrong for numeric $x |
---|
15 | * |
---|
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 | * |
---|
20 | * Revision 4.0 91/03/20 01:39:49 lwall |
---|
21 | * 4.0 baseline. |
---|
22 | * |
---|
23 | */ |
---|
24 | |
---|
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 */ |
---|
32 | STAB *stbp_stab; /* effective stab, if *glob */ |
---|
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; |
---|
37 | }; |
---|
38 | |
---|
39 | #if defined(CRIPPLED_CC) && (defined(iAPX286) || defined(M_I286) || defined(I80286)) |
---|
40 | #define MICROPORT |
---|
41 | #endif |
---|
42 | |
---|
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) |
---|
48 | #ifdef MICROPORT /* Microport 2.4 hack */ |
---|
49 | ARRAY *stab_array(); |
---|
50 | #else |
---|
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) |
---|
54 | #endif |
---|
55 | #define stab_xhash(stab) (((STBP*)(stab->str_ptr))->stbp_hash) |
---|
56 | #ifdef MICROPORT /* Microport 2.4 hack */ |
---|
57 | HASH *stab_hash(); |
---|
58 | #else |
---|
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) |
---|
62 | #endif /* Microport 2.4 hack */ |
---|
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) |
---|
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 | |
---|
71 | #define stab_name(stab) (stab->str_magic->str_ptr) |
---|
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)) |
---|
76 | |
---|
77 | #define SF_VMAGIC 1 /* call routine to dereference STR val */ |
---|
78 | #define SF_MULTI 2 /* seen more than once */ |
---|
79 | |
---|
80 | struct stio { |
---|
81 | FILE *ifp; /* ifp and ofp are normally the same */ |
---|
82 | FILE *ofp; /* but sockets need separate streams */ |
---|
83 | #ifdef HAS_READDIR |
---|
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 |- */ |
---|
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 | |
---|
103 | struct sub { |
---|
104 | CMD *cmd; |
---|
105 | int (*usersub)(); |
---|
106 | int userindex; |
---|
107 | STAB *filestab; |
---|
108 | long depth; /* >= 2 indicates recursive call */ |
---|
109 | ARRAY *tosave; |
---|
110 | }; |
---|
111 | |
---|
112 | #define Nullstab Null(STAB*) |
---|
113 | |
---|
114 | STRLEN stab_len(); |
---|
115 | |
---|
116 | #define STAB_STR(s) (tmpstab = (s), stab_flags(tmpstab) & SF_VMAGIC ? stab_str(stab_val(tmpstab)->str_magic) : stab_val(tmpstab)) |
---|
117 | #define STAB_LEN(s) (tmpstab = (s), stab_flags(tmpstab) & SF_VMAGIC ? stab_len(stab_val(tmpstab)->str_magic) : str_len(stab_val(tmpstab))) |
---|
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))) |
---|
120 | |
---|
121 | EXT STAB *tmpstab; |
---|
122 | |
---|
123 | EXT STAB *stab_index[128]; |
---|
124 | |
---|
125 | EXT unsigned short statusvalue; |
---|
126 | |
---|
127 | EXT int delaymagic INIT(0); |
---|
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 |
---|
135 | |
---|
136 | STAB *aadd(); |
---|
137 | STAB *hadd(); |
---|
138 | STAB *fstab(); |
---|
139 | void stabset(); |
---|
140 | void stab_fullname(); |
---|
141 | void stab_efullname(); |
---|
142 | void stab_check(); |
---|