xref: /titanic_41/usr/src/lib/libc/inc/msgfmt.h (revision 6185db853e024a486ff8837e6784dd290d866112)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1998, 2001 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef _MSGFMT_H
28 #define	_MSGFMT_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  *	Sun MO file format
38  */
39 
40 /*
41  *
42  *		+-------------------------------+
43  *		| (int) middle message id       |
44  *		+-------------------------------+
45  *		| (int) total # of messages     |
46  *		+-------------------------------+
47  *		| (int) total msgid length      |
48  *		+-------------------------------+
49  *		| (int) total msgstr length     |
50  *		+-------------------------------+
51  *		| (int) size of msg_struct size	|
52  *		+-------------------------------+
53  *		+-------------------------------+
54  *		| (int) less                    |
55  *		+-------------------------------+
56  *		| (int) more                    |
57  *		+-------------------------------+
58  *		| (int) msgid offset            |
59  *		+-------------------------------+
60  *		| (int) msgstr offset           |
61  *		+-------------------------------+
62  *			................
63  *		+-------------------------------+
64  *		| (variable str) msgid          |
65  *		+-------------------------------+
66  *		| (variable str) msgid          |
67  *		+-------------------------------+
68  *			................
69  *		+-------------------------------+
70  *		| (variable str) msgid          |
71  *		+-------------------------------+
72  *		+-------------------------------+
73  *		| (variable str) msgstr         |
74  *		+-------------------------------+
75  *		| (variable str) msgstr         |
76  *		+-------------------------------+
77  *			................
78  *		+-------------------------------+
79  *		| (variable str) msgstr         |
80  *		+-------------------------------+
81  */
82 
83 struct msg_info {
84 	int	msg_mid;			/* middle message id */
85 	int	msg_count;			/* total # of messages */
86 	int	str_count_msgid;	/* total msgid length */
87 	int	str_count_msgstr;	/* total msgstr length */
88 	int	msg_struct_size;	/* size of msg_struct_size */
89 };
90 
91 struct msg_struct {
92 	int	less;				/* index of left leaf */
93 	int	more;				/* index of right leaf */
94 	int	msgid_offset;		/* msgid offset */
95 	int msgstr_offset;		/* msgstr offset */
96 };
97 
98 #define	MSG_STRUCT_SIZE		(sizeof (struct msg_struct))
99 
100 /*
101  * The following is the size of the old msg_struct used be defined
102  * in usr/src/cmd/msgfmt/msgfmt.c.
103  * Old msg_struct contained:
104  * struct msg_struct {
105  *		char	*msgid;
106  *		char	*msgstr;
107  *		int	msgid_offset;
108  *		int	msgstr_offset;
109  *		struct msg_struct	*next;
110  * };
111  */
112 #define	OLD_MSG_STRUCT_SIZE	20
113 
114 #define	LEAFINDICATOR		-99
115 
116 /*
117  *	GNU MO file format
118  */
119 
120 /*
121  *
122  *             +-----------------------------------------+
123  *           0 | (unsigned int) magic number             |
124  *             +-----------------------------------------+
125  *           4 | (unsigned int) format revision          |
126  *             +-----------------------------------------+
127  *           8 | (unsigned int) number of strings        | == N
128  *             +-----------------------------------------+
129  *          12 | (unsigned int) offset of msgid table    | == O
130  *             +-----------------------------------------+
131  *          16 | (unsigned int) offset of msgstr table   | == T
132  *             +-----------------------------------------+
133  *          20 | (unsigned int) size of hashing table    | == S
134  *             +-----------------------------------------+
135  *          24 | (unsigned int) offset of hashing table  | == H
136  *             +-----------------------------------------+
137  *             +-----------------------------------------+
138  *           O | (unsigned int) length of 0th msgid      |
139  *             +-----------------------------------------+
140  *         O+4 | (unsigned int) offset of 0th msgid      | == M(0)
141  *             +-----------------------------------------+
142  *             ...............................
143  *             +-----------------------------------------+
144  * O+((N-1)*8) | (unsigned int) length of (N-1)th msgid  |
145  *             +-----------------------------------------+
146  * O+((N-1)*8) | (unsigned int) offset of (N-1)th msgid  | == M(N-1)
147  *       +4    +-----------------------------------------+
148  *           T | (unsigned int) length of 0th msgstr     |
149  *             +-----------------------------------------+
150  *         T+4 | (unsigned int) offset of 0th msgstr     | == Q(0)
151  *             +-----------------------------------------+
152  *             ...............................
153  *             +-----------------------------------------+
154  * T+((N-1)*8) | (unsigned int) length of (N-1)th msgstr |
155  *             +-----------------------------------------+
156  * T+((N-1)*8) | (unsigned int) offset of (N-1)th msgstr | == Q(N-1)
157  *       +4    +-----------------------------------------+
158  *           H | (unsigned int) start hashing table      |
159  *             +-----------------------------------------+
160  *             ...............................
161  *             +-----------------------------------------+
162  *   H + S * 4 | (unsigned int) end hashing table        |
163  *             +-----------------------------------------+
164  *        M(0) | NULL terminated 0th msgid string        |
165  *             +-----------------------------------------+
166  *        M(1) | NULL terminated 1st msgid string        |
167  *             +-----------------------------------------+
168  *             ...............................
169  *             +-----------------------------------------+
170  *      M(N-1) | NULL terminated (N-1)th msgid string    |
171  *             +-----------------------------------------+
172  *        Q(0) | NULL terminated 0th msgstr string       |
173  *             +-----------------------------------------+
174  *        Q(1) | NULL terminated 1st msgstr string       |
175  *             +-----------------------------------------+
176  *             ...............................
177  *             +-----------------------------------------+
178  *      Q(N-1) | NULL terminated (N-1)th msgstr string   |
179  *             +-----------------------------------------+
180  */
181 
182 #define	GNU_MAGIC	0x950412de
183 #define	GNU_MAGIC_SWAPPED	0xde120495
184 #define	GNU_REVISION	0
185 #define	GNU_REVISION_SWAPPED	0
186 
187 struct gnu_msg_info {
188 	unsigned int	magic;
189 	unsigned int	revision;
190 	unsigned int	num_of_str;
191 	unsigned int	off_msgid_tbl;
192 	unsigned int	off_msgstr_tbl;
193 	unsigned int	sz_hashtbl;
194 	unsigned int	off_hashtbl;
195 };
196 
197 struct gnu_msg_ent {
198 	unsigned int	len;
199 	unsigned int	offset;
200 };
201 
202 #ifdef	__cplusplus
203 }
204 #endif
205 
206 #endif /* _MSGFMT_H */
207