Home | History | Annotate | Line # | Download | only in libintl
libintl_local.h revision 1.8
      1 /*	$NetBSD: libintl_local.h,v 1.8 2004/09/23 16:44:26 tshiozak 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  * $Citrus: xpg4dl/FreeBSD/lib/libintl/libintl_local.h,v 1.13 2001/09/27 15:18:45 yamt Exp $
     29  */
     30 
     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))
     36 
     37 #define GETTEXT_MMAP_MAX	(1024 * 1024)	/*XXX*/
     38 
     39 #define DEFAULT_DOMAINNAME	"messages"
     40 
     41 /* *.mo file format */
     42 struct mo {
     43 	u_int32_t mo_magic;	/* determines endian */
     44 	u_int32_t mo_revision;	/* file format revision: 0 */
     45 	u_int32_t mo_nstring;	/* N: number of strings */
     46 	u_int32_t mo_otable;	/* O: original text table offset */
     47 	u_int32_t mo_ttable;	/* T: translated text table offset */
     48 	u_int32_t mo_hsize;	/* S: size of hashing table */
     49 	u_int32_t mo_hoffset;	/* H: offset of hashing table */
     50 	/* rev 0.1 / 1.1 */
     51 	/* system dependent string support */
     52 	u_int32_t mo_sysdep_nsegs;	/* number of sysdep segments */
     53 	u_int32_t mo_sysdep_segoff;	/* offset of sysdep segment table */
     54 	u_int32_t mo_sysdep_nstring;	/* number of strings */
     55 	u_int32_t mo_sysdep_otable;	/* offset of original text table */
     56 	u_int32_t mo_sysdep_ttable;	/* offset of translated text table */
     57 } __attribute__((__packed__));
     58 
     59 struct moentry {
     60 	u_int32_t len;		/* strlen(str), so region will be len + 1 */
     61 	u_int32_t off;		/* offset of \0-terminated string */
     62 } __attribute__((__packed__));
     63 
     64 struct mosysdepstr
     65 {
     66 	u_int32_t off;		/* offset of seed text */
     67 	struct moentry segs[1];	/* text segments */
     68 } __attribute__((__packed__));
     69 
     70 /* libintl internal data format */
     71 struct moentry_h {
     72 	size_t len;		/* strlen(str), so region will be len + 1 */
     73 	char *off;		/* offset of \0-terminated string */
     74 };
     75 
     76 struct mo_h {
     77 	u_int32_t mo_magic;	/* determines endian */
     78 	u_int32_t mo_revision;	/* file format revision: 0 */
     79 	u_int32_t mo_nstring;	/* N: number of strings */
     80 	struct moentry_h *mo_otable;	/* O: original text table offset */
     81 	struct moentry_h *mo_ttable;	/* T: translated text table offset */
     82 	const char *mo_header;
     83 	char *mo_charset;
     84 	u_int32_t mo_hsize;	/* S: size of hashing table */
     85 	u_int32_t *mo_htable;	/* H: hashing table */
     86 };
     87 
     88 struct mohandle {
     89 	void *addr;		/* mmap'ed region */
     90 	size_t len;
     91 	struct mo_h mo;		/* endian-flipped mo file header */
     92 };
     93 
     94 struct domainbinding {
     95 	struct domainbinding *next;
     96 	char domainname[PATH_MAX];
     97 	char path[PATH_MAX];
     98 	char *codeset;
     99 	struct mohandle mohandle;
    100 };
    101 
    102 extern struct domainbinding *__bindings;
    103 extern char __current_domainname[PATH_MAX];
    104 
    105 __BEGIN_DECLS
    106 const char *__gettext_iconv __P((const char *, struct domainbinding *));
    107 u_int32_t __intl_string_hash __P((const char *));
    108 __END_DECLS
    109