Home | History | Annotate | Line # | Download | only in libintl
libintl_local.h revision 1.9
      1  1.9  tshiozak /*	$NetBSD: libintl_local.h,v 1.9 2004/09/23 21:35:27 tshiozak Exp $	*/
      2  1.1    itojun 
      3  1.1    itojun /*-
      4  1.5   minoura  * Copyright (c) 2000, 2001 Citrus Project,
      5  1.1    itojun  * All rights reserved.
      6  1.1    itojun  *
      7  1.1    itojun  * Redistribution and use in source and binary forms, with or without
      8  1.1    itojun  * modification, are permitted provided that the following conditions
      9  1.1    itojun  * are met:
     10  1.1    itojun  * 1. Redistributions of source code must retain the above copyright
     11  1.1    itojun  *    notice, this list of conditions and the following disclaimer.
     12  1.1    itojun  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1    itojun  *    notice, this list of conditions and the following disclaimer in the
     14  1.1    itojun  *    documentation and/or other materials provided with the distribution.
     15  1.1    itojun  *
     16  1.1    itojun  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     17  1.1    itojun  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     18  1.1    itojun  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     19  1.1    itojun  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     20  1.1    itojun  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     21  1.1    itojun  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     22  1.1    itojun  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     23  1.1    itojun  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     24  1.1    itojun  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25  1.1    itojun  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26  1.1    itojun  * SUCH DAMAGE.
     27  1.6      yamt  *
     28  1.6      yamt  * $Citrus: xpg4dl/FreeBSD/lib/libintl/libintl_local.h,v 1.13 2001/09/27 15:18:45 yamt Exp $
     29  1.1    itojun  */
     30  1.1    itojun 
     31  1.1    itojun #define MO_MAGIC		0x950412de
     32  1.1    itojun #define MO_MAGIC_SWAPPED	0xde120495
     33  1.8  tshiozak #define MO_GET_REV_MAJOR(r)	(((r) >> 16) & 0xFFFF)
     34  1.8  tshiozak #define MO_GET_REV_MINOR(r)	((r) & 0xFFFF)
     35  1.8  tshiozak #define MO_MAKE_REV(maj, min)	(((maj) << 16) | (min))
     36  1.1    itojun 
     37  1.6      yamt #define GETTEXT_MMAP_MAX	(1024 * 1024)	/*XXX*/
     38  1.2    itojun 
     39  1.2    itojun #define DEFAULT_DOMAINNAME	"messages"
     40  1.1    itojun 
     41  1.1    itojun /* *.mo file format */
     42  1.1    itojun struct mo {
     43  1.1    itojun 	u_int32_t mo_magic;	/* determines endian */
     44  1.1    itojun 	u_int32_t mo_revision;	/* file format revision: 0 */
     45  1.1    itojun 	u_int32_t mo_nstring;	/* N: number of strings */
     46  1.1    itojun 	u_int32_t mo_otable;	/* O: original text table offset */
     47  1.1    itojun 	u_int32_t mo_ttable;	/* T: translated text table offset */
     48  1.1    itojun 	u_int32_t mo_hsize;	/* S: size of hashing table */
     49  1.1    itojun 	u_int32_t mo_hoffset;	/* H: offset of hashing table */
     50  1.8  tshiozak 	/* rev 0.1 / 1.1 */
     51  1.8  tshiozak 	/* system dependent string support */
     52  1.8  tshiozak 	u_int32_t mo_sysdep_nsegs;	/* number of sysdep segments */
     53  1.8  tshiozak 	u_int32_t mo_sysdep_segoff;	/* offset of sysdep segment table */
     54  1.8  tshiozak 	u_int32_t mo_sysdep_nstring;	/* number of strings */
     55  1.8  tshiozak 	u_int32_t mo_sysdep_otable;	/* offset of original text table */
     56  1.8  tshiozak 	u_int32_t mo_sysdep_ttable;	/* offset of translated text table */
     57  1.3    itojun } __attribute__((__packed__));
     58  1.1    itojun 
     59  1.1    itojun struct moentry {
     60  1.1    itojun 	u_int32_t len;		/* strlen(str), so region will be len + 1 */
     61  1.1    itojun 	u_int32_t off;		/* offset of \0-terminated string */
     62  1.3    itojun } __attribute__((__packed__));
     63  1.1    itojun 
     64  1.9  tshiozak struct mosysdepsegentry {
     65  1.9  tshiozak 	u_int32_t len;		/* length of this part */
     66  1.9  tshiozak 	u_int32_t ref;		/* reference number of the sysdep string,
     67  1.9  tshiozak 				 * concatenated just after this segment.
     68  1.9  tshiozak 				 */
     69  1.9  tshiozak } __attribute__((__packed__));
     70  1.9  tshiozak #define MO_LASTSEG		(0xFFFFFFFF)
     71  1.9  tshiozak 
     72  1.9  tshiozak struct mosysdepstr {
     73  1.9  tshiozak 	u_int32_t off;				/* offset of seed text */
     74  1.9  tshiozak 	struct mosysdepsegentry segs[1];	/* text segments */
     75  1.8  tshiozak } __attribute__((__packed__));
     76  1.8  tshiozak 
     77  1.1    itojun /* libintl internal data format */
     78  1.1    itojun struct moentry_h {
     79  1.1    itojun 	size_t len;		/* strlen(str), so region will be len + 1 */
     80  1.1    itojun 	char *off;		/* offset of \0-terminated string */
     81  1.1    itojun };
     82  1.1    itojun 
     83  1.9  tshiozak struct mosysdepsegs_h {
     84  1.9  tshiozak 	const char *str;
     85  1.9  tshiozak 	size_t len;
     86  1.9  tshiozak };
     87  1.9  tshiozak 
     88  1.9  tshiozak struct mosysdepsegentry_h {
     89  1.9  tshiozak 	u_int32_t len;
     90  1.9  tshiozak 	u_int32_t ref;
     91  1.9  tshiozak };
     92  1.9  tshiozak 
     93  1.9  tshiozak struct mosysdepstr_h {
     94  1.9  tshiozak 	const char *off;			/* offset of the base string */
     95  1.9  tshiozak 	char *expanded;				/* expanded string */
     96  1.9  tshiozak 	size_t expanded_len;			/* length of expanded string */
     97  1.9  tshiozak 	struct mosysdepsegentry_h segs[1];	/* text segments */
     98  1.9  tshiozak };
     99  1.9  tshiozak 
    100  1.1    itojun struct mo_h {
    101  1.1    itojun 	u_int32_t mo_magic;	/* determines endian */
    102  1.1    itojun 	u_int32_t mo_revision;	/* file format revision: 0 */
    103  1.1    itojun 	u_int32_t mo_nstring;	/* N: number of strings */
    104  1.1    itojun 	struct moentry_h *mo_otable;	/* O: original text table offset */
    105  1.1    itojun 	struct moentry_h *mo_ttable;	/* T: translated text table offset */
    106  1.1    itojun 	const char *mo_header;
    107  1.1    itojun 	char *mo_charset;
    108  1.8  tshiozak 	u_int32_t mo_hsize;	/* S: size of hashing table */
    109  1.8  tshiozak 	u_int32_t *mo_htable;	/* H: hashing table */
    110  1.9  tshiozak #define MO_HASH_SYSDEP_MASK	0x80000000	/* means sysdep entry */
    111  1.9  tshiozak 
    112  1.9  tshiozak 	u_int32_t mo_flags;
    113  1.9  tshiozak #define MO_F_SYSDEP	0x00000001	/* enable sysdep string support */
    114  1.9  tshiozak 
    115  1.9  tshiozak 	/* system dependent string support */
    116  1.9  tshiozak 	u_int32_t mo_sysdep_nsegs;	/* number of sysdep segments */
    117  1.9  tshiozak 	u_int32_t mo_sysdep_nstring;	/* number of sysdep strings */
    118  1.9  tshiozak 	struct mosysdepsegs_h *mo_sysdep_segs;	/* sysdep segment table */
    119  1.9  tshiozak 	struct mosysdepstr_h **mo_sysdep_otable;	/* original text */
    120  1.9  tshiozak 	struct mosysdepstr_h **mo_sysdep_ttable;	/* translated text */
    121  1.1    itojun };
    122  1.1    itojun 
    123  1.9  tshiozak 
    124  1.1    itojun struct mohandle {
    125  1.1    itojun 	void *addr;		/* mmap'ed region */
    126  1.1    itojun 	size_t len;
    127  1.1    itojun 	struct mo_h mo;		/* endian-flipped mo file header */
    128  1.1    itojun };
    129  1.4    itojun 
    130  1.4    itojun struct domainbinding {
    131  1.4    itojun 	struct domainbinding *next;
    132  1.4    itojun 	char domainname[PATH_MAX];
    133  1.4    itojun 	char path[PATH_MAX];
    134  1.7      yamt 	char *codeset;
    135  1.5   minoura 	struct mohandle mohandle;
    136  1.4    itojun };
    137  1.4    itojun 
    138  1.5   minoura extern struct domainbinding *__bindings;
    139  1.5   minoura extern char __current_domainname[PATH_MAX];
    140  1.7      yamt 
    141  1.8  tshiozak __BEGIN_DECLS
    142  1.7      yamt const char *__gettext_iconv __P((const char *, struct domainbinding *));
    143  1.8  tshiozak u_int32_t __intl_string_hash __P((const char *));
    144  1.9  tshiozak const char *__intl_sysdep_get_string_by_tag __P((const char *, size_t *));
    145  1.8  tshiozak __END_DECLS
    146