gettext.h revision f13ac6397da869bb7b7bc8a9f0b2e8fff530c346
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _LIBC_PORT_I18N_GETTEXT_H
#define _LIBC_PORT_I18N_GETTEXT_H
#pragma ident "%Z%%M% %I% %E% SMI"
#include <iconv.h>
#include <synch.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Type of MO file */
#define T_MO_MASK 0x07
#define T_SUN_MO 0x01
#define T_GNU_MO 0x02
#define T_ILL_MO 0x04
#define T_GNU_MASK 0x300
#define T_GNU_SWAPPED 0x100
#define T_GNU_REV1 0x200
#define TP_BINDING 0
#define TP_CODESET 1
/* Msg_g_node->flag */
/*
* msg_pack->status:
* interaction between handle_lang() and handle_mo()
*/
typedef struct domain_binding {
char *domain; /* domain name */
char *binding; /* binding directory */
char *codeset; /* codeset */
struct domain_binding *next;
} Dbinding;
/*
* this structure is used for preserving nlspath templates before
* passing them to bindtextdomain():
*/
typedef struct nlstmp {
} Nlstmp;
typedef struct {
char *msg_ids; /* actual message ids */
char *msg_strs; /* actual message strs */
} Msg_s_node;
typedef struct expr *plural_expr_t;
typedef struct {
unsigned int len; /* length of the expanded str of macro */
const char *ptr; /* pointer to the expanded str of macro */
typedef struct {
struct gnu_msg_info *msg_file_info;
struct gnu_msg_rev1_info *rev1_header;
char *mchunk; /* pointer to memory chunk of dynamic strs */
char *src_encoding; /* src encoding */
char *dst_encoding; /* dst encoding */
unsigned int nplurals; /* number of plural forms */
} Msg_g_node;
typedef struct msg_node {
char *path; /* name of message catalog */
union {
} msg;
} Msg_node;
typedef struct nls_node {
char *domain; /* key: domain name */
char *locale; /* key: locale name */
char *nlspath; /* key: NLSPATH */
char *ppaths; /* value: expanded path */
} Nls_node;
typedef struct {
char *cur_domain; /* current domain */
} Gettext_t;
struct msg_pack {
const char *msgid1; /* msgid1 argument */
const char *msgid2; /* msgid2 argument */
char *msgfile; /* msg catalog file to open */
char *domain; /* textdomain name */
char *binding; /* binding */
char *locale; /* locale */
char *language; /* LANGUAGE env */
unsigned int n; /* n argument */
int category; /* category argument */
int plural; /* plural or not */
int nlsp; /* nlsp */
int trusted; /* trusted msg catalog or not */
int status; /* status */
};
#define DEFAULT_DOMAIN "messages"
#define DEFAULT_BINDING _DFLT_LOC_PATH
#define MSGFILESUFFIX ".mo"
(char *)msgid1)
#define ROUND(m, s) if ((m) % (s)) (m) += ((s) - ((m) % (s)))
extern const char *defaultbind;
extern const char default_domain[];
extern char *_textdomain_u(const char *, char *);
extern char *_real_bindtextdomain_u(const char *, const char *, int);
extern char *_real_gettext_u(const char *, const char *,
const char *, unsigned long int, int, int);
extern char *handle_lang(struct msg_pack *);
extern char *mk_msgfile(struct msg_pack *);
extern int plural_expr(plural_expr_t *, const char *);
extern unsigned int plural_eval(plural_expr_t, unsigned int);
extern char *get_codeset(const char *);
#ifdef GETTEXT_DEBUG
extern void gprintf(int, const char *, ...);
extern void printsunmsg(Msg_s_node *, int);
extern void printgnumsg(Msg_g_node *, int);
extern void printexpr(plural_expr_t, int);
extern void printlist(void);
extern void print_rev1_info(Msg_g_node *);
#endif
#ifdef __cplusplus
}
#endif
#endif /* !_LIBC_PORT_I18N_GETTEXT_H */