]>
Commit | Line | Data |
---|---|---|
2bd0ea18 | 1 | /* |
0d3e0b37 | 2 | * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. |
2bd0ea18 NS |
3 | * |
4 | * This program is free software; you can redistribute it and/or modify it | |
5 | * under the terms of version 2 of the GNU General Public License as | |
6 | * published by the Free Software Foundation. | |
7 | * | |
8 | * This program is distributed in the hope that it would be useful, but | |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
11 | * | |
12 | * Further, this software is distributed without any warranty that it is | |
13 | * free of the rightful claim of any third person regarding infringement | |
14 | * or the like. Any license provided herein, whether implied or | |
15 | * otherwise, applies only to this software file. Patent licenses, if | |
16 | * any, provided herein do not apply to combinations of this program with | |
17 | * other software, or any other product whatsoever. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License along | |
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | |
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | |
22 | * | |
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | |
24 | * Mountain View, CA 94043, or: | |
25 | * | |
26 | * http://www.sgi.com | |
27 | * | |
28 | * For further information regarding this notice, see: | |
29 | * | |
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | |
31 | */ | |
32 | ||
33 | typedef enum fldt { | |
34 | FLDT_AEXTNUM, | |
35 | FLDT_AGBLOCK, | |
36 | FLDT_AGBLOCKNZ, | |
37 | FLDT_AGF, | |
38 | FLDT_AGFL, | |
39 | FLDT_AGI, | |
40 | FLDT_AGINO, | |
41 | FLDT_AGINONN, | |
42 | FLDT_AGNUMBER, | |
43 | FLDT_ATTR, | |
44 | FLDT_ATTR_BLKINFO, | |
45 | FLDT_ATTR_LEAF_ENTRY, | |
46 | FLDT_ATTR_LEAF_HDR, | |
47 | FLDT_ATTR_LEAF_MAP, | |
48 | FLDT_ATTR_LEAF_NAME, | |
49 | FLDT_ATTR_NODE_ENTRY, | |
50 | FLDT_ATTR_NODE_HDR, | |
51 | FLDT_ATTR_SF_ENTRY, | |
52 | FLDT_ATTR_SF_HDR, | |
53 | FLDT_ATTRBLOCK, | |
54 | FLDT_ATTRSHORT, | |
55 | FLDT_BMAPBTA, | |
56 | FLDT_BMAPBTAKEY, | |
57 | FLDT_BMAPBTAPTR, | |
58 | FLDT_BMAPBTAREC, | |
59 | FLDT_BMAPBTD, | |
60 | FLDT_BMAPBTDKEY, | |
61 | FLDT_BMAPBTDPTR, | |
62 | FLDT_BMAPBTDREC, | |
63 | FLDT_BMROOTA, | |
64 | FLDT_BMROOTAKEY, | |
65 | FLDT_BMROOTAPTR, | |
66 | FLDT_BMROOTD, | |
67 | FLDT_BMROOTDKEY, | |
68 | FLDT_BMROOTDPTR, | |
69 | FLDT_BNOBT, | |
70 | FLDT_BNOBTKEY, | |
71 | FLDT_BNOBTPTR, | |
72 | FLDT_BNOBTREC, | |
73 | FLDT_CEXTFLG, | |
74 | FLDT_CEXTLEN, | |
75 | FLDT_CFILEOFFA, | |
76 | FLDT_CFILEOFFD, | |
77 | FLDT_CFSBLOCK, | |
78 | FLDT_CHARNS, | |
79 | FLDT_CHARS, | |
80 | FLDT_CNTBT, | |
81 | FLDT_CNTBTKEY, | |
82 | FLDT_CNTBTPTR, | |
83 | FLDT_CNTBTREC, | |
84 | FLDT_DEV, | |
85 | FLDT_DFILOFFA, | |
86 | FLDT_DFILOFFD, | |
87 | FLDT_DFSBNO, | |
88 | FLDT_DINODE_A, | |
89 | FLDT_DINODE_CORE, | |
90 | FLDT_DINODE_FMT, | |
91 | FLDT_DINODE_U, | |
92 | FLDT_DIR, | |
93 | FLDT_DIR2, | |
94 | FLDT_DIR2_BLOCK_TAIL, | |
95 | FLDT_DIR2_DATA_FREE, | |
96 | FLDT_DIR2_DATA_HDR, | |
97 | FLDT_DIR2_DATA_OFF, | |
98 | FLDT_DIR2_DATA_OFFNZ, | |
99 | FLDT_DIR2_DATA_UNION, | |
100 | FLDT_DIR2_FREE_HDR, | |
101 | FLDT_DIR2_INO4, | |
102 | FLDT_DIR2_INO8, | |
103 | FLDT_DIR2_INOU, | |
104 | FLDT_DIR2_LEAF_ENTRY, | |
105 | FLDT_DIR2_LEAF_HDR, | |
106 | FLDT_DIR2_LEAF_TAIL, | |
107 | FLDT_DIR2_SF_ENTRY, | |
108 | FLDT_DIR2_SF_HDR, | |
109 | FLDT_DIR2_SF_OFF, | |
110 | FLDT_DIR2SF, | |
111 | FLDT_DIR_BLKINFO, | |
112 | FLDT_DIR_INO, | |
113 | FLDT_DIR_LEAF_ENTRY, | |
114 | FLDT_DIR_LEAF_HDR, | |
115 | FLDT_DIR_LEAF_MAP, | |
116 | FLDT_DIR_LEAF_NAME, | |
117 | FLDT_DIR_NODE_ENTRY, | |
118 | FLDT_DIR_NODE_HDR, | |
119 | FLDT_DIR_SF_ENTRY, | |
120 | FLDT_DIR_SF_HDR, | |
121 | FLDT_DIRBLOCK, | |
122 | FLDT_DIRSHORT, | |
123 | FLDT_DISK_DQUOT, | |
124 | FLDT_DQBLK, | |
125 | FLDT_DQID, | |
126 | FLDT_DRFSBNO, | |
127 | FLDT_DRTBNO, | |
128 | FLDT_EXTLEN, | |
129 | FLDT_EXTNUM, | |
130 | FLDT_FSIZE, | |
131 | FLDT_INO, | |
132 | FLDT_INOBT, | |
133 | FLDT_INOBTKEY, | |
134 | FLDT_INOBTPTR, | |
135 | FLDT_INOBTREC, | |
136 | FLDT_INODE, | |
137 | FLDT_INOFREE, | |
138 | FLDT_INT16D, | |
139 | FLDT_INT32D, | |
140 | FLDT_INT64D, | |
141 | FLDT_INT8D, | |
142 | FLDT_NSEC, | |
143 | FLDT_QCNT, | |
144 | FLDT_QWARNCNT, | |
145 | FLDT_SB, | |
146 | FLDT_TIME, | |
147 | FLDT_TIMESTAMP, | |
148 | FLDT_UINT1, | |
149 | FLDT_UINT16D, | |
150 | FLDT_UINT16O, | |
151 | FLDT_UINT16X, | |
152 | FLDT_UINT32D, | |
153 | FLDT_UINT32O, | |
154 | FLDT_UINT32X, | |
155 | FLDT_UINT64D, | |
156 | FLDT_UINT64O, | |
157 | FLDT_UINT64X, | |
158 | FLDT_UINT8D, | |
159 | FLDT_UINT8O, | |
160 | FLDT_UINT8X, | |
161 | FLDT_UUID, | |
162 | FLDT_ZZZ /* mark last entry */ | |
163 | } fldt_t; | |
164 | ||
165 | typedef int (*offset_fnc_t)(void *obj, int startoff, int idx); | |
166 | #define OI(o) ((offset_fnc_t)(__psint_t)(o)) | |
167 | ||
168 | typedef int (*count_fnc_t)(void *obj, int startoff); | |
169 | #define CI(c) ((count_fnc_t)(__psint_t)(c)) | |
170 | #define C1 CI(1) | |
171 | ||
172 | typedef struct field | |
173 | { | |
174 | char *name; | |
175 | fldt_t ftyp; | |
176 | offset_fnc_t offset; | |
177 | count_fnc_t count; | |
178 | int flags; | |
179 | typnm_t next; | |
180 | } field_t; | |
181 | ||
182 | /* | |
183 | * flag values | |
184 | */ | |
185 | #define FLD_ABASE1 1 /* field array base is 1 not 0 */ | |
186 | #define FLD_SKIPALL 2 /* skip this field in an all-fields print */ | |
187 | #define FLD_ARRAY 4 /* this field is an array */ | |
188 | #define FLD_OFFSET 8 /* offset value is a function pointer */ | |
189 | #define FLD_COUNT 16 /* count value is a function pointer */ | |
190 | ||
191 | typedef int (*size_fnc_t)(void *obj, int startoff, int idx); | |
192 | #define SI(s) ((size_fnc_t)(__psint_t)(s)) | |
193 | ||
194 | typedef struct ftattr | |
195 | { | |
196 | fldt_t ftyp; | |
197 | char *name; | |
198 | prfnc_t prfunc; | |
199 | char *fmtstr; | |
200 | size_fnc_t size; | |
201 | int arg; | |
202 | adfnc_t adfunc; | |
203 | const field_t *subfld; | |
204 | } ftattr_t; | |
205 | extern const ftattr_t ftattrtab[]; | |
206 | ||
207 | /* | |
208 | * arg values | |
209 | */ | |
210 | #define FTARG_SKIPZERO 1 /* skip 0 words */ | |
211 | #define FTARG_DONULL 2 /* make -1 words be "null" */ | |
212 | #define FTARG_SKIPNULL 4 /* skip -1 words */ | |
213 | #define FTARG_SIGNED 8 /* field value is signed */ | |
214 | #define FTARG_SIZE 16 /* size field is a function */ | |
215 | #define FTARG_SKIPNMS 32 /* skip printing names this time */ | |
216 | #define FTARG_OKEMPTY 64 /* ok if this (union type) is empty */ | |
217 | ||
218 | extern int bitoffset(const field_t *f, void *obj, int startoff, | |
219 | int idx); | |
220 | extern int fcount(const field_t *f, void *obj, int startoff); | |
221 | extern const field_t *findfield(char *name, const field_t *fields, | |
222 | void *obj, int startoff); | |
223 | extern int fsize(const field_t *f, void *obj, int startoff, | |
224 | int idx); |