#ifndef _LIBC_PORT_I18N_GETTEXT_H
#define _LIBC_PORT_I18N_GETTEXT_H
#include <sys/param.h>
#include <iconv.h>
#include <synch.h>
#ifdef __cplusplus
extern "C" {
#endif
#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
#define ST_CHK 0x1
#define ST_SWP 0x2
#define ST_REV1 0x4
#define ST_GNU_MSG_FOUND 0x1
#define ST_GNU_MO_FOUND 0x2
#define ST_SUN_MO_FOUND 0x4
typedef struct domain_binding {
char *domain;
char *binding;
char *codeset;
struct domain_binding *next;
} Dbinding;
typedef struct nlstmp {
char pathname[MAXPATHLEN];
size_t len;
struct nlstmp *next;
} Nlstmp;
typedef struct {
struct msg_info *msg_file_info;
struct msg_struct *msg_list;
char *msg_ids;
char *msg_strs;
} Msg_s_node;
typedef struct expr *plural_expr_t;
typedef struct {
unsigned int len;
const char *ptr;
} gnu_d_macro_t;
typedef struct {
struct gnu_msg_info *msg_file_info;
struct gnu_msg_rev1_info *rev1_header;
size_t fsize;
uint32_t flag;
uint32_t num_of_str;
uint32_t num_of_d_str;
uint32_t hash_size;
uint32_t *hash_table;
struct gnu_msg_ent *msg_tbl[2];
struct gnu_msg_ent *d_msg[2];
char *mchunk;
char *src_encoding;
char *dst_encoding;
unsigned int nplurals;
plural_expr_t plural;
iconv_t fd;
uint32_t **conv_msgstr;
} Msg_g_node;
typedef struct msg_node {
uint32_t hashid;
uint16_t type;
uint16_t trusted;
char *path;
union {
Msg_s_node *sunmsg;
Msg_g_node *gnumsg;
} msg;
struct msg_node *next;
} Msg_node;
typedef struct nls_node {
char *domain;
char *locale;
char *nlspath;
char *ppaths;
struct nls_node *next;
} Nls_node;
typedef struct {
char *cur_domain;
Dbinding *dbind;
Msg_node *m_node;
Nls_node *n_node;
Msg_node *c_m_node;
Nls_node *c_n_node;
} Gettext_t;
struct msg_pack {
const char *msgid1;
const char *msgid2;
char *msgfile;
char *domain;
char *binding;
const char *locale;
char *language;
caddr_t addr;
size_t fsz;
uint32_t hash_domain;
uint32_t domain_len;
unsigned int n;
int category;
int plural;
int nlsp;
int trusted;
int status;
};
#define DEFAULT_DOMAIN "messages"
#define DEFAULT_BINDING _DFLT_LOC_PATH
#define MSGFILESUFFIX ".mo"
#define MSGFILESUFFIXLEN (sizeof (MSGFILESUFFIX) - 1)
#define CURRENT_DOMAIN(gt) (gt)->cur_domain
#define FIRSTBIND(gt) (gt)->dbind
#define DFLTMSG(result, msgid1, msgid2, n, plural) \
result = (plural ? \
((n == 1) ? (char *)msgid1 : (char *)msgid2) : \
(char *)msgid1)
#define ROUND(m, s) if ((m) % (s)) (m) += ((s) - ((m) % (s)))
#define SWAP(p, ui32) \
(((p)->flag & ST_SWP) ? doswap32(ui32) : (ui32))
#define HASH_TBL(p, ui32) \
((((p)->flag & (ST_REV1|ST_SWP)) == ST_SWP) ? \
doswap32(ui32) : (ui32))
extern const char *defaultbind;
extern const char default_domain[];
extern Gettext_t *global_gt;
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, locale_t);
extern char *handle_mo(struct msg_pack *);
extern int gnu_setmsg(Msg_node *, char *, size_t);
extern char *handle_lang(struct msg_pack *);
extern char *mk_msgfile(struct msg_pack *);
extern Msg_node *check_cache(struct msg_pack *);
extern uint32_t get_hashid(const char *, uint32_t *);
extern uint32_t doswap32(uint32_t);
extern int plural_expr(plural_expr_t *, const char *);
extern unsigned int plural_eval(plural_expr_t, unsigned int);
extern char *gnu_key_2_text(Msg_g_node *, const char *, struct msg_pack *);
extern char *get_codeset(const char *);
#ifdef GETTEXT_DEBUG
extern void gprintf(int, const char *, ...);
extern void printgt(Gettext_t *, int);
extern void printmp(struct msg_pack *, int);
extern void printsunmsg(Msg_s_node *, int);
extern void printgnumsg(Msg_g_node *, int);
extern void printexpr(plural_expr_t, int);
extern void printmnp(Msg_node *, int);
extern void printlist(void);
extern void print_rev1_info(Msg_g_node *);
#endif
#ifdef __cplusplus
}
#endif
#endif