4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
29 #pragma ident "%Z%%M% %I% %E% SMI"
44 * +-------------------------------+
45 * | (int) middle message id |
46 * +-------------------------------+
47 * | (int) total # of messages |
48 * +-------------------------------+
49 * | (int) total msgid length |
50 * +-------------------------------+
51 * | (int) total msgstr length |
52 * +-------------------------------+
53 * | (int) size of msg_struct size |
54 * +-------------------------------+
55 * +-------------------------------+
57 * +-------------------------------+
59 * +-------------------------------+
60 * | (int) msgid offset |
61 * +-------------------------------+
62 * | (int) msgstr offset |
63 * +-------------------------------+
65 * +-------------------------------+
66 * | (variable str) msgid |
67 * +-------------------------------+
68 * | (variable str) msgid |
69 * +-------------------------------+
71 * +-------------------------------+
72 * | (variable str) msgid |
73 * +-------------------------------+
74 * +-------------------------------+
75 * | (variable str) msgstr |
76 * +-------------------------------+
77 * | (variable str) msgstr |
78 * +-------------------------------+
80 * +-------------------------------+
81 * | (variable str) msgstr |
82 * +-------------------------------+
86 int msg_mid
; /* middle message id */
87 int msg_count
; /* total # of messages */
88 int str_count_msgid
; /* total msgid length */
89 int str_count_msgstr
; /* total msgstr length */
90 int msg_struct_size
; /* size of msg_struct_size */
94 int less
; /* index of left leaf */
95 int more
; /* index of right leaf */
96 int msgid_offset
; /* msgid offset */
97 int msgstr_offset
; /* msgstr offset */
100 #define MSG_STRUCT_SIZE (sizeof (struct msg_struct))
103 * The following is the size of the old msg_struct used be defined
104 * in usr/src/cmd/msgfmt/msgfmt.c.
105 * Old msg_struct contained:
106 * struct msg_struct {
111 * struct msg_struct *next;
114 #define OLD_MSG_STRUCT_SIZE 20
116 #define LEAFINDICATOR -99
124 * +-----------------------------------------+
125 * 0 | (uint32_t) magic number |
126 * +-----------------------------------------+
127 * 4 | (uint32_t) format revision |
128 * +-----------------------------------------+
129 * 8 | (uint32_t) number of strings | == N
130 * +-----------------------------------------+
131 * 12 | (uint32_t) offset of msgid table | == O
132 * +-----------------------------------------+
133 * 16 | (uint32_t) offset of msgstr table | == T
134 * +-----------------------------------------+
135 * 20 | (uint32_t) size of hashing table | == S
136 * +-----------------------------------------+
137 * 24 | (uint32_t) offset of hashing table | == H
138 * +-----------------------------------------+
139 * +-----------------------------------------+
140 * O | (uint32_t) length of 0th msgid |
141 * +-----------------------------------------+
142 * O+4 | (uint32_t) offset of 0th msgid | == M(0)
143 * +-----------------------------------------+
144 * ...............................
145 * +-----------------------------------------+
146 * O+((N-1)*8) | (uint32_t) length of (N-1)th msgid |
147 * +-----------------------------------------+
148 * O+((N-1)*8) | (uint32_t) offset of (N-1)th msgid | == M(N-1)
149 * +4 +-----------------------------------------+
150 * +-----------------------------------------+
151 * T | (uint32_t) length of 0th msgstr |
152 * +-----------------------------------------+
153 * T+4 | (uint32_t) offset of 0th msgstr | == Q(0)
154 * +-----------------------------------------+
155 * ...............................
156 * +-----------------------------------------+
157 * T+((N-1)*8) | (uint32_t) length of (N-1)th msgstr |
158 * +-----------------------------------------+
159 * T+((N-1)*8) | (uint32_t) offset of (N-1)th msgstr | == Q(N-1)
160 * +4 +-----------------------------------------+
161 * +-----------------------------------------+
162 * H | (uint32_t) start hashing table |
163 * +-----------------------------------------+
164 * ...............................
165 * +-----------------------------------------+
166 * H + S * 4 | (uint32_t) end hashing table |
167 * +-----------------------------------------+
168 * +-----------------------------------------+
169 * M(0) | NULL terminated 0th msgid string |
170 * +-----------------------------------------+
171 * M(1) | NULL terminated 1st msgid string |
172 * +-----------------------------------------+
173 * ...............................
174 * +-----------------------------------------+
175 * M(N-1) | NULL terminated (N-1)th msgid string |
176 * +-----------------------------------------+
177 * +-----------------------------------------+
178 * Q(0) | NULL terminated 0th msgstr string |
179 * +-----------------------------------------+
180 * Q(1) | NULL terminated 1st msgstr string |
181 * +-----------------------------------------+
182 * ...............................
183 * +-----------------------------------------+
184 * Q(N-1) | NULL terminated (N-1)th msgstr string |
185 * +-----------------------------------------+
189 * GNU MO file format (Revision 1)
193 * +-----------------------------------------------+
194 * 0 | (uint32_t) magic number |
195 * +-----------------------------------------------+
196 * 4 | (uint32_t) format revision |
197 * +-----------------------------------------------+
198 * 8 | (uint32_t) number of strings | == N
199 * +-----------------------------------------------+
200 * 12 | (uint32_t) offset of msgid table | == O
201 * +-----------------------------------------------+
202 * 16 | (uint32_t) offset of msgstr table | == T
203 * +-----------------------------------------------+
204 * 20 | (uint32_t) size of hashing table | == S
205 * +-----------------------------------------------+
206 * 24 | (uint32_t) offset of hashing table | == H
207 * +-----------------------------------------------+
208 * 32 | (uint32_t) number of dynamic macros | == M
209 * +-----------------------------------------------+
210 * 36 | (uint32_t) offset of dynamic macros | == P
211 * +-----------------------------------------------+
212 * 40 | (uint32_t) number of dynamic strings | == D
213 * +-----------------------------------------------+
214 * 44 | (uint32_t) offset of dynamic msgid tbl | == A
215 * +-----------------------------------------------+
216 * 48 | (uint32_t) offset of dynamic msgstr tbl | == B
217 * +-----------------------------------------------+
218 * +-----------------------------------------------+
219 * O | (uint32_t) length of 0th msgid |
220 * +-----------------------------------------------+
221 * O+4 | (uint32_t) offset of 0th msgid | == M(0)
222 * +-----------------------------------------------+
223 * ...............................
224 * +-----------------------------------------------+
225 * O+((N-1)*8) | (uint32_t) length of (N-1)th msgid |
226 * +-----------------------------------------------+
227 * O+((N-1)*8) | (uint32_t) offset of (N-1)th msgid | == M(N-1)
228 * +4 +-----------------------------------------------+
229 * +-----------------------------------------------+
230 * T | (uint32_t) length of 0th msgstr |
231 * +-----------------------------------------------+
232 * T+4 | (uint32_t) offset of 0th msgstr | == Q(0)
233 * +-----------------------------------------------+
234 * ...............................
235 * +-----------------------------------------------+
236 * T+((N-1)*8) | (uint32_t) length of (N-1)th msgstr |
237 * +-----------------------------------------------+
238 * T+((N-1)*8) | (uint32_t) offset of (N-1)th msgstr | == Q(N-1)
239 * +4 +-----------------------------------------------+
240 * +-----------------------------------------------+
241 * H | (uint32_t) start hashing table |
242 * +-----------------------------------------------+
243 * ...............................
244 * +-----------------------------------------------+
245 * H + S * 4 | (uint32_t) end hashing table |
246 * +-----------------------------------------------+
247 * +-----------------------------------------------+
248 * P | (uint32_t) length of 0th macro |
249 * +-----------------------------------------------+
250 * P+4 | (uint32_t) offset of 0th macro | == C(0)
251 * +-----------------------------------------------+
252 * ...............................
253 * +-----------------------------------------------+
254 * P+((M-1)*8) | (uint32_t) length of (M-1)th macro |
255 * +-----------------------------------------------+
256 * P+((M-1)*8) | (uint32_t) offset of (M-1)th macro | == C(M-1)
257 * +4 +-----------------------------------------------+
258 * +-----------------------------------------------+
259 * A | (uint32_t) offset of 0th d_msgid | == L(0)
260 * +-----------------------------------------------+
261 * ...............................
262 * +-----------------------------------------------+
263 * A+((D-1)*4) | (uint32_t) offset of (D-1)th d_msgid | == L(D-1)
264 * +-----------------------------------------------+
265 * +-----------------------------------------------+
266 * B | (uint32_t) offset of 0th d_msgstr | == E(0)
267 * +-----------------------------------------------+
268 * ...............................
269 * +-----------------------------------------------+
270 * B+((D-1)*4) | (uint32_t) offset of (D-1)th d_msgstr | == E(D-1)
271 * +-----------------------------------------------+
272 * +-----------------------------------------------+
273 * L(0) | (uint32_t) offset of 0th d_msgid message | == F(0)
274 * +-----------------------------------------------+
275 * L(0)+4 | (uint32_t) length of 0th fixed substring |
276 * +-----------------------------------------------+
277 * L(0)+8 | (uint32_t) index to a dynamic macro |
278 * +-----------------------------------------------+
279 * ...............................
280 * +-----------------------------------------------+
281 * L(0)+4+ | (uint32_t) length of (m-1)th fixed substring |
282 * ((m-1)*8) +-----------------------------------------------+
283 * L(0)+8+ | (uint32_t) NOMORE_DYNAMIC_STR |
284 * ((m-1)*8) +-----------------------------------------------+
285 * +-----------------------------------------------+
286 * L(D-1) | (uint32_t) offset of 0th d_msgid message | == F(D-1)
287 * +-----------------------------------------------+
288 * L(D-1)+4 | (uint32_t) length of 0th fixed substring |
289 * +-----------------------------------------------+
290 * L(D-1)+8 | (uint32_t) index to a dynamic macro |
291 * +-----------------------------------------------+
292 * ...............................
293 * +-----------------------------------------------+
294 * L(D-1)+4 | (uint32_t) length of (m-1)th fixed substring |
295 * ((m-1)*8) +-----------------------------------------------+
296 * L(D-1)+8 | (uint32_t) NOMORE_DYNAMIC_STR |
297 * ((m-1)*8) +-----------------------------------------------+
298 * +-----------------------------------------------+
299 * E(0) | (uint32_t) offset of 0th d_msgstr message | == G(0)
300 * +-----------------------------------------------+
301 * E(0)+4 | (uint32_t) length of 0th fixed substring |
302 * +-----------------------------------------------+
303 * E(0)+8 | (uint32_t) index to a dynamic macro |
304 * +-----------------------------------------------+
305 * ...............................
306 * +-----------------------------------------------+
307 * E(0)+4+ | (uint32_t) length of (m-1)th fixed substring |
308 * ((m-1)*8) +-----------------------------------------------+
309 * E(0)+8+ | (uint32_t) NOMORE_DYNAMIC_STR |
310 * ((m-1)*8) +-----------------------------------------------+
311 * +-----------------------------------------------+
312 * E(D-1) | (uint32_t) offset of 0th d_msgstr message | == G(D-1)
313 * +-----------------------------------------------+
314 * E(D-1)+4 | (uint32_t) length of 0th fixed substring |
315 * +-----------------------------------------------+
316 * E(D-1)+8 | (uint32_t) index to a dynamic macro |
317 * +-----------------------------------------------+
318 * ...............................
319 * +-----------------------------------------------+
320 * E(D-1)+4 | (uint32_t) length of (m-1)th fixed substring |
321 * ((m-1)*8) +-----------------------------------------------+
322 * E(D-1)+8 | (uint32_t) NOMORE_DYNAMIC_STR |
323 * ((m-1)*8) +-----------------------------------------------+
324 * +-----------------------------------------------+
325 * M(0) | NULL terminated 0th msgid string |
326 * +-----------------------------------------------+
327 * M(1) | NULL terminated 1st msgid string |
328 * +-----------------------------------------------+
329 * ...............................
330 * +-----------------------------------------------+
331 * M(N-1) | NULL terminated (N-1)th msgid string |
332 * +-----------------------------------------------+
333 * Q(0) | NULL terminated 0th msgstr string |
334 * +-----------------------------------------------+
335 * Q(1) | NULL terminated 1st msgstr string |
336 * +-----------------------------------------------+
337 * ...............................
338 * +-----------------------------------------------+
339 * Q(N-1) | NULL terminated (N-1)th msgstr string |
340 * +-----------------------------------------------+
341 * +-----------------------------------------------+
342 * C(0) | NULL terminated 0th macro |
343 * +-----------------------------------------------+
344 * ...............................
345 * +-----------------------------------------------+
346 * C(M-1) | NULL terminated (M-1)th macro |
347 * +-----------------------------------------------+
348 * +-----------------------------------------------+
349 * F(0) | NULL terminated 0th dynamic msgid string |
350 * +-----------------------------------------------+
351 * ...............................
352 * +-----------------------------------------------+
353 * F(D-1) | NULL terminated (D-1)th dynamic msgid string |
354 * +-----------------------------------------------+
355 * +-----------------------------------------------+
356 * G(0) | NULL terminated 0th dynamic msgstr string |
357 * +-----------------------------------------------+
358 * ...............................
359 * +-----------------------------------------------+
360 * G(D-1) | NULL terminated (D-1)th dynamic msgstr string |
361 * +-----------------------------------------------+
364 #define GNU_MAGIC 0x950412de
365 #define GNU_MAGIC_SWAPPED 0xde120495
366 #define GNU_REVISION 0
367 #define GNU_REVISION_0_0 0
368 #define GNU_REVISION_0_0_SWAPPED 0
369 #define GNU_REVISION_0_1 0x00000001
370 #define GNU_REVISION_0_1_SWAPPED 0x01000000
371 #define GNU_REVISION_1_1 0x00010001
372 #define GNU_REVISION_1_1_SWAPPED 0x01000100
373 #define NOMORE_DYNAMIC_MACRO 0xffffffff
380 struct gnu_msg_info
{
384 uint32_t off_msgid_tbl
;
385 uint32_t off_msgstr_tbl
;
387 uint32_t off_hashtbl
;
390 struct gnu_msg_rev1_info
{
391 uint32_t num_of_dynamic_macro
;
392 uint32_t off_dynamic_macro
;
393 uint32_t num_of_dynamic_str
;
394 uint32_t off_dynamic_msgid_tbl
;
395 uint32_t off_dynamic_msgstr_tbl
;
403 struct gnu_dynamic_ent
{
408 struct gnu_dynamic_tbl
{
410 struct gnu_dynamic_ent entry
[1];
417 #endif /* _MSGFMT_H */