xref: /netbsd-src/lib/libintl/libintl_local.h (revision 3b01aba77a7a698587faaae455bbfe740923c1f5)
1 /*	$NetBSD: libintl_local.h,v 1.5 2001/02/16 07:20:35 minoura Exp $	*/
2 
3 /*-
4  * Copyright (c) 2000, 2001 Citrus Project,
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  */
28 
29 #define MO_MAGIC		0x950412de
30 #define MO_MAGIC_SWAPPED	0xde120495
31 #define MO_REVISION		0
32 
33 #define GETTEXT_MMAP_MAX	(64 * 1024)	/*XXX*/
34 
35 #define DEFAULT_DOMAINNAME	"messages"
36 
37 /* *.mo file format */
38 struct mo {
39 	u_int32_t mo_magic;	/* determines endian */
40 	u_int32_t mo_revision;	/* file format revision: 0 */
41 	u_int32_t mo_nstring;	/* N: number of strings */
42 	u_int32_t mo_otable;	/* O: original text table offset */
43 	u_int32_t mo_ttable;	/* T: translated text table offset */
44 	u_int32_t mo_hsize;	/* S: size of hashing table */
45 	u_int32_t mo_hoffset;	/* H: offset of hashing table */
46 } __attribute__((__packed__));
47 
48 struct moentry {
49 	u_int32_t len;		/* strlen(str), so region will be len + 1 */
50 	u_int32_t off;		/* offset of \0-terminated string */
51 } __attribute__((__packed__));
52 
53 /* libintl internal data format */
54 struct moentry_h {
55 	size_t len;		/* strlen(str), so region will be len + 1 */
56 	char *off;		/* offset of \0-terminated string */
57 };
58 
59 struct mo_h {
60 	u_int32_t mo_magic;	/* determines endian */
61 	u_int32_t mo_revision;	/* file format revision: 0 */
62 	u_int32_t mo_nstring;	/* N: number of strings */
63 	struct moentry_h *mo_otable;	/* O: original text table offset */
64 	struct moentry_h *mo_ttable;	/* T: translated text table offset */
65 	const char *mo_header;
66 	char *mo_charset;
67 };
68 
69 struct mohandle {
70 	void *addr;		/* mmap'ed region */
71 	size_t len;
72 	struct mo_h mo;		/* endian-flipped mo file header */
73 };
74 
75 struct domainbinding {
76 	struct domainbinding *next;
77 	char domainname[PATH_MAX];
78 	char path[PATH_MAX];
79 	struct mohandle mohandle;
80 };
81 
82 extern struct domainbinding *__bindings;
83 extern char __current_domainname[PATH_MAX];
84