xref: /illumos-gate/usr/src/lib/libc/inc/msgfmt.h (revision f13ac639)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*f13ac639Smuffin  * Common Development and Distribution License (the "License").
6*f13ac639Smuffin  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*f13ac639Smuffin  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23*f13ac639Smuffin  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef _MSGFMT_H
277c478bd9Sstevel@tonic-gate #define	_MSGFMT_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
307c478bd9Sstevel@tonic-gate 
31*f13ac639Smuffin #include <stdint.h>
32*f13ac639Smuffin #include <stddef.h>
33*f13ac639Smuffin 
347c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
357c478bd9Sstevel@tonic-gate extern "C" {
367c478bd9Sstevel@tonic-gate #endif
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate /*
397c478bd9Sstevel@tonic-gate  *	Sun MO file format
407c478bd9Sstevel@tonic-gate  */
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate /*
437c478bd9Sstevel@tonic-gate  *
447c478bd9Sstevel@tonic-gate  *		+-------------------------------+
457c478bd9Sstevel@tonic-gate  *		| (int) middle message id       |
467c478bd9Sstevel@tonic-gate  *		+-------------------------------+
477c478bd9Sstevel@tonic-gate  *		| (int) total # of messages     |
487c478bd9Sstevel@tonic-gate  *		+-------------------------------+
497c478bd9Sstevel@tonic-gate  *		| (int) total msgid length      |
507c478bd9Sstevel@tonic-gate  *		+-------------------------------+
517c478bd9Sstevel@tonic-gate  *		| (int) total msgstr length     |
527c478bd9Sstevel@tonic-gate  *		+-------------------------------+
537c478bd9Sstevel@tonic-gate  *		| (int) size of msg_struct size	|
547c478bd9Sstevel@tonic-gate  *		+-------------------------------+
557c478bd9Sstevel@tonic-gate  *		+-------------------------------+
567c478bd9Sstevel@tonic-gate  *		| (int) less                    |
577c478bd9Sstevel@tonic-gate  *		+-------------------------------+
587c478bd9Sstevel@tonic-gate  *		| (int) more                    |
597c478bd9Sstevel@tonic-gate  *		+-------------------------------+
607c478bd9Sstevel@tonic-gate  *		| (int) msgid offset            |
617c478bd9Sstevel@tonic-gate  *		+-------------------------------+
627c478bd9Sstevel@tonic-gate  *		| (int) msgstr offset           |
637c478bd9Sstevel@tonic-gate  *		+-------------------------------+
647c478bd9Sstevel@tonic-gate  *			................
657c478bd9Sstevel@tonic-gate  *		+-------------------------------+
667c478bd9Sstevel@tonic-gate  *		| (variable str) msgid          |
677c478bd9Sstevel@tonic-gate  *		+-------------------------------+
687c478bd9Sstevel@tonic-gate  *		| (variable str) msgid          |
697c478bd9Sstevel@tonic-gate  *		+-------------------------------+
707c478bd9Sstevel@tonic-gate  *			................
717c478bd9Sstevel@tonic-gate  *		+-------------------------------+
727c478bd9Sstevel@tonic-gate  *		| (variable str) msgid          |
737c478bd9Sstevel@tonic-gate  *		+-------------------------------+
747c478bd9Sstevel@tonic-gate  *		+-------------------------------+
757c478bd9Sstevel@tonic-gate  *		| (variable str) msgstr         |
767c478bd9Sstevel@tonic-gate  *		+-------------------------------+
777c478bd9Sstevel@tonic-gate  *		| (variable str) msgstr         |
787c478bd9Sstevel@tonic-gate  *		+-------------------------------+
797c478bd9Sstevel@tonic-gate  *			................
807c478bd9Sstevel@tonic-gate  *		+-------------------------------+
817c478bd9Sstevel@tonic-gate  *		| (variable str) msgstr         |
827c478bd9Sstevel@tonic-gate  *		+-------------------------------+
837c478bd9Sstevel@tonic-gate  */
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate struct msg_info {
867c478bd9Sstevel@tonic-gate 	int	msg_mid;			/* middle message id */
877c478bd9Sstevel@tonic-gate 	int	msg_count;			/* total # of messages */
887c478bd9Sstevel@tonic-gate 	int	str_count_msgid;	/* total msgid length */
897c478bd9Sstevel@tonic-gate 	int	str_count_msgstr;	/* total msgstr length */
907c478bd9Sstevel@tonic-gate 	int	msg_struct_size;	/* size of msg_struct_size */
917c478bd9Sstevel@tonic-gate };
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate struct msg_struct {
947c478bd9Sstevel@tonic-gate 	int	less;				/* index of left leaf */
957c478bd9Sstevel@tonic-gate 	int	more;				/* index of right leaf */
967c478bd9Sstevel@tonic-gate 	int	msgid_offset;		/* msgid offset */
977c478bd9Sstevel@tonic-gate 	int msgstr_offset;		/* msgstr offset */
987c478bd9Sstevel@tonic-gate };
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate #define	MSG_STRUCT_SIZE		(sizeof (struct msg_struct))
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate /*
1037c478bd9Sstevel@tonic-gate  * The following is the size of the old msg_struct used be defined
1047c478bd9Sstevel@tonic-gate  * in usr/src/cmd/msgfmt/msgfmt.c.
1057c478bd9Sstevel@tonic-gate  * Old msg_struct contained:
1067c478bd9Sstevel@tonic-gate  * struct msg_struct {
1077c478bd9Sstevel@tonic-gate  *		char	*msgid;
1087c478bd9Sstevel@tonic-gate  *		char	*msgstr;
1097c478bd9Sstevel@tonic-gate  *		int	msgid_offset;
1107c478bd9Sstevel@tonic-gate  *		int	msgstr_offset;
1117c478bd9Sstevel@tonic-gate  *		struct msg_struct	*next;
1127c478bd9Sstevel@tonic-gate  * };
1137c478bd9Sstevel@tonic-gate  */
1147c478bd9Sstevel@tonic-gate #define	OLD_MSG_STRUCT_SIZE	20
1157c478bd9Sstevel@tonic-gate 
1167c478bd9Sstevel@tonic-gate #define	LEAFINDICATOR		-99
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate /*
1197c478bd9Sstevel@tonic-gate  *	GNU MO file format
1207c478bd9Sstevel@tonic-gate  */
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate /*
1237c478bd9Sstevel@tonic-gate  *
1247c478bd9Sstevel@tonic-gate  *             +-----------------------------------------+
125*f13ac639Smuffin  *           0 | (uint32_t) magic number                 |
1267c478bd9Sstevel@tonic-gate  *             +-----------------------------------------+
127*f13ac639Smuffin  *           4 | (uint32_t) format revision              |
1287c478bd9Sstevel@tonic-gate  *             +-----------------------------------------+
129*f13ac639Smuffin  *           8 | (uint32_t) number of strings            | == N
1307c478bd9Sstevel@tonic-gate  *             +-----------------------------------------+
131*f13ac639Smuffin  *          12 | (uint32_t) offset of msgid table        | == O
1327c478bd9Sstevel@tonic-gate  *             +-----------------------------------------+
133*f13ac639Smuffin  *          16 | (uint32_t) offset of msgstr table       | == T
1347c478bd9Sstevel@tonic-gate  *             +-----------------------------------------+
135*f13ac639Smuffin  *          20 | (uint32_t) size of hashing table        | == S
1367c478bd9Sstevel@tonic-gate  *             +-----------------------------------------+
137*f13ac639Smuffin  *          24 | (uint32_t) offset of hashing table      | == H
1387c478bd9Sstevel@tonic-gate  *             +-----------------------------------------+
1397c478bd9Sstevel@tonic-gate  *             +-----------------------------------------+
140*f13ac639Smuffin  *           O | (uint32_t) length of 0th msgid          |
1417c478bd9Sstevel@tonic-gate  *             +-----------------------------------------+
142*f13ac639Smuffin  *         O+4 | (uint32_t) offset of 0th msgid          | == M(0)
1437c478bd9Sstevel@tonic-gate  *             +-----------------------------------------+
1447c478bd9Sstevel@tonic-gate  *             ...............................
1457c478bd9Sstevel@tonic-gate  *             +-----------------------------------------+
146*f13ac639Smuffin  * O+((N-1)*8) | (uint32_t) length of (N-1)th msgid      |
1477c478bd9Sstevel@tonic-gate  *             +-----------------------------------------+
148*f13ac639Smuffin  * O+((N-1)*8) | (uint32_t) offset of (N-1)th msgid      | == M(N-1)
1497c478bd9Sstevel@tonic-gate  *       +4    +-----------------------------------------+
1507c478bd9Sstevel@tonic-gate  *             +-----------------------------------------+
151*f13ac639Smuffin  *           T | (uint32_t) length of 0th msgstr         |
152*f13ac639Smuffin  *             +-----------------------------------------+
153*f13ac639Smuffin  *         T+4 | (uint32_t) offset of 0th msgstr         | == Q(0)
1547c478bd9Sstevel@tonic-gate  *             +-----------------------------------------+
1557c478bd9Sstevel@tonic-gate  *             ...............................
1567c478bd9Sstevel@tonic-gate  *             +-----------------------------------------+
157*f13ac639Smuffin  * T+((N-1)*8) | (uint32_t) length of (N-1)th msgstr     |
1587c478bd9Sstevel@tonic-gate  *             +-----------------------------------------+
159*f13ac639Smuffin  * T+((N-1)*8) | (uint32_t) offset of (N-1)th msgstr     | == Q(N-1)
1607c478bd9Sstevel@tonic-gate  *       +4    +-----------------------------------------+
161*f13ac639Smuffin  *             +-----------------------------------------+
162*f13ac639Smuffin  *           H | (uint32_t) start hashing table          |
1637c478bd9Sstevel@tonic-gate  *             +-----------------------------------------+
1647c478bd9Sstevel@tonic-gate  *             ...............................
1657c478bd9Sstevel@tonic-gate  *             +-----------------------------------------+
166*f13ac639Smuffin  *   H + S * 4 | (uint32_t) end hashing table            |
167*f13ac639Smuffin  *             +-----------------------------------------+
1687c478bd9Sstevel@tonic-gate  *             +-----------------------------------------+
1697c478bd9Sstevel@tonic-gate  *        M(0) | NULL terminated 0th msgid string        |
1707c478bd9Sstevel@tonic-gate  *             +-----------------------------------------+
1717c478bd9Sstevel@tonic-gate  *        M(1) | NULL terminated 1st msgid string        |
1727c478bd9Sstevel@tonic-gate  *             +-----------------------------------------+
1737c478bd9Sstevel@tonic-gate  *             ...............................
1747c478bd9Sstevel@tonic-gate  *             +-----------------------------------------+
1757c478bd9Sstevel@tonic-gate  *      M(N-1) | NULL terminated (N-1)th msgid string    |
1767c478bd9Sstevel@tonic-gate  *             +-----------------------------------------+
177*f13ac639Smuffin  *             +-----------------------------------------+
1787c478bd9Sstevel@tonic-gate  *        Q(0) | NULL terminated 0th msgstr string       |
1797c478bd9Sstevel@tonic-gate  *             +-----------------------------------------+
1807c478bd9Sstevel@tonic-gate  *        Q(1) | NULL terminated 1st msgstr string       |
1817c478bd9Sstevel@tonic-gate  *             +-----------------------------------------+
1827c478bd9Sstevel@tonic-gate  *             ...............................
1837c478bd9Sstevel@tonic-gate  *             +-----------------------------------------+
1847c478bd9Sstevel@tonic-gate  *      Q(N-1) | NULL terminated (N-1)th msgstr string   |
1857c478bd9Sstevel@tonic-gate  *             +-----------------------------------------+
1867c478bd9Sstevel@tonic-gate  */
1877c478bd9Sstevel@tonic-gate 
188*f13ac639Smuffin /*
189*f13ac639Smuffin  *	GNU MO file format (Revision 1)
190*f13ac639Smuffin  */
191*f13ac639Smuffin /*
192*f13ac639Smuffin  *
193*f13ac639Smuffin  *             +-----------------------------------------------+
194*f13ac639Smuffin  *           0 | (uint32_t) magic number                       |
195*f13ac639Smuffin  *             +-----------------------------------------------+
196*f13ac639Smuffin  *           4 | (uint32_t) format revision                    |
197*f13ac639Smuffin  *             +-----------------------------------------------+
198*f13ac639Smuffin  *           8 | (uint32_t) number of strings                  | == N
199*f13ac639Smuffin  *             +-----------------------------------------------+
200*f13ac639Smuffin  *          12 | (uint32_t) offset of msgid table              | == O
201*f13ac639Smuffin  *             +-----------------------------------------------+
202*f13ac639Smuffin  *          16 | (uint32_t) offset of msgstr table             | == T
203*f13ac639Smuffin  *             +-----------------------------------------------+
204*f13ac639Smuffin  *          20 | (uint32_t) size of hashing table              | == S
205*f13ac639Smuffin  *             +-----------------------------------------------+
206*f13ac639Smuffin  *          24 | (uint32_t) offset of hashing table            | == H
207*f13ac639Smuffin  *             +-----------------------------------------------+
208*f13ac639Smuffin  *          32 | (uint32_t) number of dynamic macros           | == M
209*f13ac639Smuffin  *             +-----------------------------------------------+
210*f13ac639Smuffin  *          36 | (uint32_t) offset of dynamic macros           | == P
211*f13ac639Smuffin  *             +-----------------------------------------------+
212*f13ac639Smuffin  *          40 | (uint32_t) number of dynamic strings          | == D
213*f13ac639Smuffin  *             +-----------------------------------------------+
214*f13ac639Smuffin  *          44 | (uint32_t) offset of dynamic msgid tbl        | == A
215*f13ac639Smuffin  *             +-----------------------------------------------+
216*f13ac639Smuffin  *          48 | (uint32_t) offset of dynamic msgstr tbl       | == B
217*f13ac639Smuffin  *             +-----------------------------------------------+
218*f13ac639Smuffin  *             +-----------------------------------------------+
219*f13ac639Smuffin  *           O | (uint32_t) length of 0th msgid                |
220*f13ac639Smuffin  *             +-----------------------------------------------+
221*f13ac639Smuffin  *         O+4 | (uint32_t) offset of 0th msgid                | == M(0)
222*f13ac639Smuffin  *             +-----------------------------------------------+
223*f13ac639Smuffin  *             ...............................
224*f13ac639Smuffin  *             +-----------------------------------------------+
225*f13ac639Smuffin  * O+((N-1)*8) | (uint32_t) length of (N-1)th msgid            |
226*f13ac639Smuffin  *             +-----------------------------------------------+
227*f13ac639Smuffin  * O+((N-1)*8) | (uint32_t) offset of (N-1)th msgid            | == M(N-1)
228*f13ac639Smuffin  *       +4    +-----------------------------------------------+
229*f13ac639Smuffin  *             +-----------------------------------------------+
230*f13ac639Smuffin  *           T | (uint32_t) length of 0th msgstr               |
231*f13ac639Smuffin  *             +-----------------------------------------------+
232*f13ac639Smuffin  *         T+4 | (uint32_t) offset of 0th msgstr               | == Q(0)
233*f13ac639Smuffin  *             +-----------------------------------------------+
234*f13ac639Smuffin  *             ...............................
235*f13ac639Smuffin  *             +-----------------------------------------------+
236*f13ac639Smuffin  * T+((N-1)*8) | (uint32_t) length of (N-1)th msgstr           |
237*f13ac639Smuffin  *             +-----------------------------------------------+
238*f13ac639Smuffin  * T+((N-1)*8) | (uint32_t) offset of (N-1)th msgstr           | == Q(N-1)
239*f13ac639Smuffin  *       +4    +-----------------------------------------------+
240*f13ac639Smuffin  *             +-----------------------------------------------+
241*f13ac639Smuffin  *           H | (uint32_t) start hashing table                |
242*f13ac639Smuffin  *             +-----------------------------------------------+
243*f13ac639Smuffin  *             ...............................
244*f13ac639Smuffin  *             +-----------------------------------------------+
245*f13ac639Smuffin  *   H + S * 4 | (uint32_t) end hashing table                  |
246*f13ac639Smuffin  *             +-----------------------------------------------+
247*f13ac639Smuffin  *             +-----------------------------------------------+
248*f13ac639Smuffin  *           P | (uint32_t) length of 0th macro                |
249*f13ac639Smuffin  *             +-----------------------------------------------+
250*f13ac639Smuffin  *         P+4 | (uint32_t) offset of 0th macro                | == C(0)
251*f13ac639Smuffin  *             +-----------------------------------------------+
252*f13ac639Smuffin  *             ...............................
253*f13ac639Smuffin  *             +-----------------------------------------------+
254*f13ac639Smuffin  * P+((M-1)*8) | (uint32_t) length of (M-1)th macro            |
255*f13ac639Smuffin  *             +-----------------------------------------------+
256*f13ac639Smuffin  * P+((M-1)*8) | (uint32_t) offset of (M-1)th macro            | == C(M-1)
257*f13ac639Smuffin  *       +4    +-----------------------------------------------+
258*f13ac639Smuffin  *             +-----------------------------------------------+
259*f13ac639Smuffin  *           A | (uint32_t) offset of 0th d_msgid              | == L(0)
260*f13ac639Smuffin  *             +-----------------------------------------------+
261*f13ac639Smuffin  *             ...............................
262*f13ac639Smuffin  *             +-----------------------------------------------+
263*f13ac639Smuffin  * A+((D-1)*4) | (uint32_t) offset of (D-1)th d_msgid          | == L(D-1)
264*f13ac639Smuffin  *             +-----------------------------------------------+
265*f13ac639Smuffin  *             +-----------------------------------------------+
266*f13ac639Smuffin  *           B | (uint32_t) offset of 0th d_msgstr             | == E(0)
267*f13ac639Smuffin  *             +-----------------------------------------------+
268*f13ac639Smuffin  *             ...............................
269*f13ac639Smuffin  *             +-----------------------------------------------+
270*f13ac639Smuffin  * B+((D-1)*4) | (uint32_t) offset of (D-1)th d_msgstr         | == E(D-1)
271*f13ac639Smuffin  *             +-----------------------------------------------+
272*f13ac639Smuffin  *             +-----------------------------------------------+
273*f13ac639Smuffin  *        L(0) | (uint32_t) offset of 0th d_msgid message      | == F(0)
274*f13ac639Smuffin  *             +-----------------------------------------------+
275*f13ac639Smuffin  *      L(0)+4 | (uint32_t) length of 0th fixed substring      |
276*f13ac639Smuffin  *             +-----------------------------------------------+
277*f13ac639Smuffin  *      L(0)+8 | (uint32_t) index to a dynamic macro           |
278*f13ac639Smuffin  *             +-----------------------------------------------+
279*f13ac639Smuffin  *             ...............................
280*f13ac639Smuffin  *             +-----------------------------------------------+
281*f13ac639Smuffin  *     L(0)+4+ | (uint32_t) length of (m-1)th fixed substring  |
282*f13ac639Smuffin  *   ((m-1)*8) +-----------------------------------------------+
283*f13ac639Smuffin  *     L(0)+8+ | (uint32_t) NOMORE_DYNAMIC_STR                 |
284*f13ac639Smuffin  *   ((m-1)*8) +-----------------------------------------------+
285*f13ac639Smuffin  *             +-----------------------------------------------+
286*f13ac639Smuffin  *      L(D-1) | (uint32_t) offset of 0th d_msgid message      | == F(D-1)
287*f13ac639Smuffin  *             +-----------------------------------------------+
288*f13ac639Smuffin  *    L(D-1)+4 | (uint32_t) length of 0th fixed substring      |
289*f13ac639Smuffin  *             +-----------------------------------------------+
290*f13ac639Smuffin  *    L(D-1)+8 | (uint32_t) index to a dynamic macro           |
291*f13ac639Smuffin  *             +-----------------------------------------------+
292*f13ac639Smuffin  *             ...............................
293*f13ac639Smuffin  *             +-----------------------------------------------+
294*f13ac639Smuffin  *    L(D-1)+4 | (uint32_t) length of (m-1)th fixed substring  |
295*f13ac639Smuffin  *   ((m-1)*8) +-----------------------------------------------+
296*f13ac639Smuffin  *    L(D-1)+8 | (uint32_t) NOMORE_DYNAMIC_STR                 |
297*f13ac639Smuffin  *   ((m-1)*8) +-----------------------------------------------+
298*f13ac639Smuffin  *             +-----------------------------------------------+
299*f13ac639Smuffin  *        E(0) | (uint32_t) offset of 0th d_msgstr message     | == G(0)
300*f13ac639Smuffin  *             +-----------------------------------------------+
301*f13ac639Smuffin  *      E(0)+4 | (uint32_t) length of 0th fixed substring      |
302*f13ac639Smuffin  *             +-----------------------------------------------+
303*f13ac639Smuffin  *      E(0)+8 | (uint32_t) index to a dynamic macro           |
304*f13ac639Smuffin  *             +-----------------------------------------------+
305*f13ac639Smuffin  *             ...............................
306*f13ac639Smuffin  *             +-----------------------------------------------+
307*f13ac639Smuffin  *     E(0)+4+ | (uint32_t) length of (m-1)th fixed substring  |
308*f13ac639Smuffin  *   ((m-1)*8) +-----------------------------------------------+
309*f13ac639Smuffin  *     E(0)+8+ | (uint32_t) NOMORE_DYNAMIC_STR                 |
310*f13ac639Smuffin  *   ((m-1)*8) +-----------------------------------------------+
311*f13ac639Smuffin  *             +-----------------------------------------------+
312*f13ac639Smuffin  *      E(D-1) | (uint32_t) offset of 0th d_msgstr message     | == G(D-1)
313*f13ac639Smuffin  *             +-----------------------------------------------+
314*f13ac639Smuffin  *    E(D-1)+4 | (uint32_t) length of 0th fixed substring      |
315*f13ac639Smuffin  *             +-----------------------------------------------+
316*f13ac639Smuffin  *    E(D-1)+8 | (uint32_t) index to a dynamic macro           |
317*f13ac639Smuffin  *             +-----------------------------------------------+
318*f13ac639Smuffin  *             ...............................
319*f13ac639Smuffin  *             +-----------------------------------------------+
320*f13ac639Smuffin  *    E(D-1)+4 | (uint32_t) length of (m-1)th fixed substring  |
321*f13ac639Smuffin  *   ((m-1)*8) +-----------------------------------------------+
322*f13ac639Smuffin  *    E(D-1)+8 | (uint32_t) NOMORE_DYNAMIC_STR                 |
323*f13ac639Smuffin  *   ((m-1)*8) +-----------------------------------------------+
324*f13ac639Smuffin  *             +-----------------------------------------------+
325*f13ac639Smuffin  *        M(0) | NULL terminated 0th msgid string              |
326*f13ac639Smuffin  *             +-----------------------------------------------+
327*f13ac639Smuffin  *        M(1) | NULL terminated 1st msgid string              |
328*f13ac639Smuffin  *             +-----------------------------------------------+
329*f13ac639Smuffin  *             ...............................
330*f13ac639Smuffin  *             +-----------------------------------------------+
331*f13ac639Smuffin  *      M(N-1) | NULL terminated (N-1)th msgid string          |
332*f13ac639Smuffin  *             +-----------------------------------------------+
333*f13ac639Smuffin  *        Q(0) | NULL terminated 0th msgstr string             |
334*f13ac639Smuffin  *             +-----------------------------------------------+
335*f13ac639Smuffin  *        Q(1) | NULL terminated 1st msgstr string             |
336*f13ac639Smuffin  *             +-----------------------------------------------+
337*f13ac639Smuffin  *             ...............................
338*f13ac639Smuffin  *             +-----------------------------------------------+
339*f13ac639Smuffin  *      Q(N-1) | NULL terminated (N-1)th msgstr string         |
340*f13ac639Smuffin  *             +-----------------------------------------------+
341*f13ac639Smuffin  *             +-----------------------------------------------+
342*f13ac639Smuffin  *        C(0) | NULL terminated 0th macro                     |
343*f13ac639Smuffin  *             +-----------------------------------------------+
344*f13ac639Smuffin  *             ...............................
345*f13ac639Smuffin  *             +-----------------------------------------------+
346*f13ac639Smuffin  *      C(M-1) | NULL terminated (M-1)th macro                 |
347*f13ac639Smuffin  *             +-----------------------------------------------+
348*f13ac639Smuffin  *             +-----------------------------------------------+
349*f13ac639Smuffin  *        F(0) | NULL terminated 0th dynamic msgid string      |
350*f13ac639Smuffin  *             +-----------------------------------------------+
351*f13ac639Smuffin  *             ...............................
352*f13ac639Smuffin  *             +-----------------------------------------------+
353*f13ac639Smuffin  *      F(D-1) | NULL terminated (D-1)th dynamic msgid string  |
354*f13ac639Smuffin  *             +-----------------------------------------------+
355*f13ac639Smuffin  *             +-----------------------------------------------+
356*f13ac639Smuffin  *        G(0) | NULL terminated 0th dynamic msgstr string     |
357*f13ac639Smuffin  *             +-----------------------------------------------+
358*f13ac639Smuffin  *             ...............................
359*f13ac639Smuffin  *             +-----------------------------------------------+
360*f13ac639Smuffin  *      G(D-1) | NULL terminated (D-1)th dynamic msgstr string |
361*f13ac639Smuffin  *             +-----------------------------------------------+
362*f13ac639Smuffin  */
363*f13ac639Smuffin 
364*f13ac639Smuffin #define	GNU_MAGIC			0x950412de
365*f13ac639Smuffin #define	GNU_MAGIC_SWAPPED		0xde120495
366*f13ac639Smuffin #define	GNU_REVISION			0
367*f13ac639Smuffin #define	GNU_REVISION_0_0		0
368*f13ac639Smuffin #define	GNU_REVISION_0_0_SWAPPED	0
369*f13ac639Smuffin #define	GNU_REVISION_0_1		0x00000001
370*f13ac639Smuffin #define	GNU_REVISION_0_1_SWAPPED	0x01000000
371*f13ac639Smuffin #define	GNU_REVISION_1_1		0x00010001
372*f13ac639Smuffin #define	GNU_REVISION_1_1_SWAPPED	0x01000100
373*f13ac639Smuffin #define	NOMORE_DYNAMIC_MACRO		0xffffffff
374*f13ac639Smuffin 
375*f13ac639Smuffin enum gnu_msgidstr {
376*f13ac639Smuffin 	MSGID = 0,
377*f13ac639Smuffin 	MSGSTR = 1
378*f13ac639Smuffin };
3797c478bd9Sstevel@tonic-gate 
3807c478bd9Sstevel@tonic-gate struct gnu_msg_info {
381*f13ac639Smuffin 	uint32_t	magic;
382*f13ac639Smuffin 	uint32_t	revision;
383*f13ac639Smuffin 	uint32_t	num_of_str;
384*f13ac639Smuffin 	uint32_t	off_msgid_tbl;
385*f13ac639Smuffin 	uint32_t	off_msgstr_tbl;
386*f13ac639Smuffin 	uint32_t	sz_hashtbl;
387*f13ac639Smuffin 	uint32_t	off_hashtbl;
388*f13ac639Smuffin };
389*f13ac639Smuffin 
390*f13ac639Smuffin struct gnu_msg_rev1_info {
391*f13ac639Smuffin 	uint32_t	num_of_dynamic_macro;
392*f13ac639Smuffin 	uint32_t	off_dynamic_macro;
393*f13ac639Smuffin 	uint32_t	num_of_dynamic_str;
394*f13ac639Smuffin 	uint32_t	off_dynamic_msgid_tbl;
395*f13ac639Smuffin 	uint32_t	off_dynamic_msgstr_tbl;
3967c478bd9Sstevel@tonic-gate };
3977c478bd9Sstevel@tonic-gate 
3987c478bd9Sstevel@tonic-gate struct gnu_msg_ent {
399*f13ac639Smuffin 	uint32_t	len;
400*f13ac639Smuffin 	uint32_t	offset;
401*f13ac639Smuffin };
402*f13ac639Smuffin 
403*f13ac639Smuffin struct gnu_dynamic_ent {
404*f13ac639Smuffin 	uint32_t	len;
405*f13ac639Smuffin 	uint32_t	idx;
406*f13ac639Smuffin };
407*f13ac639Smuffin 
408*f13ac639Smuffin struct gnu_dynamic_tbl {
409*f13ac639Smuffin 	uint32_t	offset;
410*f13ac639Smuffin 	struct gnu_dynamic_ent	entry[1];
4117c478bd9Sstevel@tonic-gate };
4127c478bd9Sstevel@tonic-gate 
4137c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
4147c478bd9Sstevel@tonic-gate }
4157c478bd9Sstevel@tonic-gate #endif
4167c478bd9Sstevel@tonic-gate 
4177c478bd9Sstevel@tonic-gate #endif /* _MSGFMT_H */
418