2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A
2N/A/*
2N/A * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#ifndef _LIBC_PORT_I18N_GETTEXT_H
2N/A#define _LIBC_PORT_I18N_GETTEXT_H
2N/A
2N/A#include <sys/param.h>
2N/A#include <iconv.h>
2N/A#include <synch.h>
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A/* Type of MO file */
2N/A#define T_MO_MASK 0x07
2N/A#define T_SUN_MO 0x01
2N/A#define T_GNU_MO 0x02
2N/A#define T_ILL_MO 0x04
2N/A
2N/A#define T_GNU_MASK 0x300
2N/A#define T_GNU_SWAPPED 0x100
2N/A#define T_GNU_REV1 0x200
2N/A
2N/A#define TP_BINDING 0
2N/A#define TP_CODESET 1
2N/A
2N/A/* Msg_g_node->flag */
2N/A#define ST_CHK 0x1 /* header has been checked? */
2N/A#define ST_SWP 0x2 /* reversed endian? */
2N/A#define ST_REV1 0x4 /* Revision 1 */
2N/A
2N/A/*
2N/A * msg_pack->status:
2N/A * interaction between handle_lang() and handle_mo()
2N/A */
2N/A#define ST_GNU_MSG_FOUND 0x1 /* valid msg found in GNU MO */
2N/A#define ST_GNU_MO_FOUND 0x2 /* GNU MO found */
2N/A#define ST_SUN_MO_FOUND 0x4 /* Sun MO found */
2N/A
2N/Atypedef struct domain_binding {
2N/A char *domain; /* domain name */
2N/A char *binding; /* binding directory */
2N/A char *codeset; /* codeset */
2N/A struct domain_binding *next;
2N/A} Dbinding;
2N/A
2N/A/*
2N/A * this structure is used for preserving nlspath templates at
2N/A * each Nls_node and also to use at _real_gettext_u().
2N/A */
2N/Atypedef struct nlstmp {
2N/A char *pathname; /* the full pathname to file */
2N/A size_t len; /* length of pathname */
2N/A struct nlstmp *next; /* link to the next entry */
2N/A} Nlstmp;
2N/A
2N/Atypedef struct {
2N/A struct msg_info *msg_file_info; /* information of msg file */
2N/A struct msg_struct *msg_list; /* message list */
2N/A char *msg_ids; /* actual message ids */
2N/A char *msg_strs; /* actual message strs */
2N/A} Msg_s_node;
2N/A
2N/Atypedef struct expr *plural_expr_t;
2N/A
2N/Atypedef struct {
2N/A unsigned int len; /* length of the expanded str of macro */
2N/A const char *ptr; /* pointer to the expanded str of macro */
2N/A} gnu_d_macro_t;
2N/A
2N/Atypedef struct {
2N/A struct gnu_msg_info *msg_file_info;
2N/A struct gnu_msg_rev1_info *rev1_header;
2N/A size_t fsize; /* size of the GNU mo file */
2N/A uint32_t flag; /* status */
2N/A uint32_t num_of_str; /* number of static msgs */
2N/A uint32_t num_of_d_str; /* number of dynamic msgs */
2N/A uint32_t hash_size; /* hash table size */
2N/A uint32_t *hash_table; /* hash table */
2N/A struct gnu_msg_ent *msg_tbl[2]; /* msgid/str entries */
2N/A struct gnu_msg_ent *d_msg[2]; /* dynamic msgid/str entries */
2N/A char *mchunk; /* pointer to memory chunk of dynamic strs */
2N/A char *src_encoding; /* src encoding */
2N/A char *dst_encoding; /* dst encoding */
2N/A unsigned int nplurals; /* number of plural forms */
2N/A plural_expr_t plural; /* plural expression */
2N/A iconv_t fd; /* iconv descriptor */
2N/A uint32_t **conv_msgstr; /* code-converted msgstr */
2N/A} Msg_g_node;
2N/A
2N/Atypedef struct msg_node {
2N/A uint32_t hashid; /* hashed value of the domain name */
2N/A uint16_t type; /* T_SUN_MO, T_GNU_MO, or T_ILL_MO */
2N/A uint16_t trusted; /* is this a trusted source? */
2N/A char *path; /* name of message catalog */
2N/A union {
2N/A Msg_s_node *sunmsg;
2N/A Msg_g_node *gnumsg;
2N/A } msg;
2N/A struct msg_node *next; /* link to the next */
2N/A} Msg_node;
2N/A
2N/Atypedef struct nls_node {
2N/A char *domain; /* key: domain name */
2N/A char *locale; /* key: locale name */
2N/A char *nlspath; /* key: NLSPATH */
2N/A Nlstmp *ppaths; /* value: expanded path */
2N/A struct nls_node *next; /* link to the next */
2N/A} Nls_node;
2N/A
2N/Atypedef struct {
2N/A char *cur_domain; /* current domain */
2N/A Dbinding *dbind; /* domain binding */
2N/A Msg_node *m_node; /* link to the Msg_node cache */
2N/A Nls_node *n_node; /* link to the Nls_node cache */
2N/A Msg_node *c_m_node; /* link to the current Msg_node */
2N/A Nls_node *c_n_node; /* link to the current Nls_node */
2N/A} Gettext_t;
2N/A
2N/Astruct msg_pack {
2N/A const char *msgid1; /* msgid1 argument */
2N/A const char *msgid2; /* msgid2 argument */
2N/A char *msgfile; /* msg catalog file to open */
2N/A char *domain; /* textdomain name */
2N/A char *binding; /* binding */
2N/A char *locale; /* locale */
2N/A char *language; /* LANGUAGE env */
2N/A caddr_t addr; /* mmap'ed address */
2N/A size_t fsz; /* file size */
2N/A uint32_t hash_domain; /* hash ID of domain */
2N/A uint32_t domain_len; /* length of domain */
2N/A unsigned int n; /* n argument */
2N/A int category; /* category argument */
2N/A int plural; /* plural or not */
2N/A int nlsp; /* nlsp */
2N/A int trusted; /* trusted msg catalog or not */
2N/A int status; /* status */
2N/A};
2N/A
2N/A#define DEFAULT_DOMAIN "messages"
2N/A#define DEFAULT_BINDING _DFLT_LOC_PATH
2N/A#define MSGFILESUFFIX ".mo"
2N/A#define MSGFILESUFFIXLEN (sizeof (MSGFILESUFFIX))
2N/A
2N/A#define CURRENT_DOMAIN(gt) (gt)->cur_domain
2N/A#define FIRSTBIND(gt) (gt)->dbind
2N/A
2N/A#define DFLTMSG(result, msgid1, msgid2, n, plural) \
2N/A result = (plural ? \
2N/A ((n == 1) ? (char *)msgid1 : (char *)msgid2) : \
2N/A (char *)msgid1)
2N/A
2N/A#define ROUND(m, s) if ((m) % (s)) (m) += ((s) - ((m) % (s)))
2N/A
2N/A#define SWAP(p, ui32) \
2N/A (((p)->flag & ST_SWP) ? doswap32(ui32) : (ui32))
2N/A
2N/A#define HASH_TBL(p, ui32) \
2N/A ((((p)->flag & (ST_REV1|ST_SWP)) == ST_SWP) ? \
2N/A doswap32(ui32) : (ui32))
2N/A
2N/Aextern const char *defaultbind;
2N/Aextern const char default_domain[];
2N/Aextern Gettext_t *global_gt;
2N/A
2N/Aextern char *_textdomain_u(const char *, char *);
2N/Aextern char *_real_bindtextdomain_u(const char *, const char *, int);
2N/Aextern char *_real_gettext_u(const char *, const char *,
2N/A const char *, unsigned long int, int, int);
2N/Aextern char *handle_mo(struct msg_pack *);
2N/A
2N/Aextern int gnu_setmsg(Msg_node *, char *, size_t);
2N/Aextern char *handle_lang(struct msg_pack *);
2N/Aextern char *mk_msgfile(struct msg_pack *);
2N/Aextern char *prepare_msgfile(struct msg_pack *, size_t *, char *, size_t *);
2N/Aextern Msg_node *check_cache(struct msg_pack *);
2N/Aextern uint32_t get_hashid(const char *, uint32_t *);
2N/Aextern uint32_t doswap32(uint32_t);
2N/A
2N/Aextern int plural_expr(plural_expr_t *, const char *);
2N/Aextern unsigned int plural_eval(plural_expr_t, unsigned int);
2N/A
2N/Aextern char *gnu_key_2_text(Msg_g_node *, const char *, struct msg_pack *);
2N/A
2N/Aextern char *get_codeset(const char *);
2N/A
2N/A#ifdef GETTEXT_DEBUG
2N/Aextern void gprintf(int, const char *, ...);
2N/Aextern void printgt(Gettext_t *, int);
2N/Aextern void printmp(struct msg_pack *, int);
2N/Aextern void printsunmsg(Msg_s_node *, int);
2N/Aextern void printgnumsg(Msg_g_node *, int);
2N/Aextern void printexpr(plural_expr_t, int);
2N/Aextern void printmnp(Msg_node *, int);
2N/Aextern void printlist(void);
2N/Aextern void print_rev1_info(Msg_g_node *);
2N/A#endif
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* !_LIBC_PORT_I18N_GETTEXT_H */