1 /* $NetBSD: libintl_local.h,v 1.11 2007/09/25 08:19:09 junyoung Exp $ */
4 * Copyright (c) 2000, 2001 Citrus Project,
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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.
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
28 * $Citrus: xpg4dl/FreeBSD/lib/libintl/libintl_local.h,v 1.13 2001/09/27 15:18:45 yamt Exp $
31 #define MO_MAGIC 0x950412de
32 #define MO_MAGIC_SWAPPED 0xde120495
33 #define MO_GET_REV_MAJOR(r) (((r) >> 16) & 0xFFFF)
34 #define MO_GET_REV_MINOR(r) ((r) & 0xFFFF)
35 #define MO_MAKE_REV(maj, min) (((maj) << 16) | (min))
37 #define GETTEXT_MMAP_MAX (1024 * 1024) /*XXX*/
39 #define DEFAULT_DOMAINNAME "messages"
41 /* *.mo file format */
43 uint32_t mo_magic
; /* determines endian */
44 uint32_t mo_revision
; /* file format revision: 0 */
45 uint32_t mo_nstring
; /* N: number of strings */
46 uint32_t mo_otable
; /* O: original text table offset */
47 uint32_t mo_ttable
; /* T: translated text table offset */
48 uint32_t mo_hsize
; /* S: size of hashing table */
49 uint32_t mo_hoffset
; /* H: offset of hashing table */
51 /* system dependent string support */
52 uint32_t mo_sysdep_nsegs
; /* number of sysdep segments */
53 uint32_t mo_sysdep_segoff
; /* offset of sysdep segment table */
54 uint32_t mo_sysdep_nstring
; /* number of strings */
55 uint32_t mo_sysdep_otable
; /* offset of original text table */
56 uint32_t mo_sysdep_ttable
; /* offset of translated text table */
60 uint32_t len
; /* strlen(str), so region will be len + 1 */
61 uint32_t off
; /* offset of \0-terminated string */
64 struct mosysdepsegentry
{
65 uint32_t len
; /* length of this part */
66 uint32_t ref
; /* reference number of the sysdep string,
67 * concatenated just after this segment.
70 #define MO_LASTSEG (0xFFFFFFFF)
73 uint32_t off
; /* offset of seed text */
74 struct mosysdepsegentry segs
[1]; /* text segments */
77 /* libintl internal data format */
79 size_t len
; /* strlen(str), so region will be len + 1 */
80 char *off
; /* offset of \0-terminated string */
83 struct mosysdepsegs_h
{
88 struct mosysdepsegentry_h
{
93 struct mosysdepstr_h
{
94 const char *off
; /* offset of the base string */
95 char *expanded
; /* expanded string */
96 size_t expanded_len
; /* length of expanded string */
97 struct mosysdepsegentry_h segs
[1]; /* text segments */
100 struct gettext_plural
;
102 uint32_t mo_magic
; /* determines endian */
103 uint32_t mo_revision
; /* file format revision: 0 */
104 uint32_t mo_nstring
; /* N: number of strings */
105 struct moentry_h
*mo_otable
; /* O: original text table offset */
106 struct moentry_h
*mo_ttable
; /* T: translated text table offset */
107 const char *mo_header
;
108 struct gettext_plural
*mo_plural
;
109 unsigned long mo_nplurals
;
111 uint32_t mo_hsize
; /* S: size of hashing table */
112 uint32_t *mo_htable
; /* H: hashing table */
113 #define MO_HASH_SYSDEP_MASK 0x80000000 /* means sysdep entry */
116 #define MO_F_SYSDEP 0x00000001 /* enable sysdep string support */
118 /* system dependent string support */
119 uint32_t mo_sysdep_nsegs
; /* number of sysdep segments */
120 uint32_t mo_sysdep_nstring
; /* number of sysdep strings */
121 struct mosysdepsegs_h
*mo_sysdep_segs
; /* sysdep segment table */
122 struct mosysdepstr_h
**mo_sysdep_otable
; /* original text */
123 struct mosysdepstr_h
**mo_sysdep_ttable
; /* translated text */
128 void *addr
; /* mmap'ed region */
130 struct mo_h mo
; /* endian-flipped mo file header */
133 struct domainbinding
{
134 struct domainbinding
*next
;
135 char domainname
[PATH_MAX
];
138 struct mohandle mohandle
;
141 extern struct domainbinding
*__bindings
;
142 extern char __current_domainname
[PATH_MAX
];
145 const char *__gettext_iconv(const char *, struct domainbinding
*);
146 uint32_t __intl_string_hash(const char *);
147 const char *__intl_sysdep_get_string_by_tag(const char *, size_t *);