1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _GNU_MSGFMT_H 28*7c478bd9Sstevel@tonic-gate #define _GNU_MSGFMT_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #include <stdio.h> 33*7c478bd9Sstevel@tonic-gate #include <limits.h> 34*7c478bd9Sstevel@tonic-gate #include <stdarg.h> 35*7c478bd9Sstevel@tonic-gate #include <locale.h> 36*7c478bd9Sstevel@tonic-gate #include <libintl.h> 37*7c478bd9Sstevel@tonic-gate #include <string.h> 38*7c478bd9Sstevel@tonic-gate #include <stdlib.h> 39*7c478bd9Sstevel@tonic-gate #include <iconv.h> 40*7c478bd9Sstevel@tonic-gate #include <ctype.h> 41*7c478bd9Sstevel@tonic-gate #include <fcntl.h> 42*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 43*7c478bd9Sstevel@tonic-gate #include <sys/stat.h> 44*7c478bd9Sstevel@tonic-gate #include <sys/mman.h> 45*7c478bd9Sstevel@tonic-gate #include <alloca.h> 46*7c478bd9Sstevel@tonic-gate #include <unistd.h> 47*7c478bd9Sstevel@tonic-gate #include <errno.h> 48*7c478bd9Sstevel@tonic-gate #include "gnu_errmsg.h" 49*7c478bd9Sstevel@tonic-gate #include "common.h" 50*7c478bd9Sstevel@tonic-gate 51*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 52*7c478bd9Sstevel@tonic-gate extern "C" { 53*7c478bd9Sstevel@tonic-gate #endif 54*7c478bd9Sstevel@tonic-gate 55*7c478bd9Sstevel@tonic-gate #define _ENCODING_ALIAS_PATH "/usr/lib/iconv/alias" 56*7c478bd9Sstevel@tonic-gate #define DEST_CHARSET "UTF-8" 57*7c478bd9Sstevel@tonic-gate #define CHARSET_STR "charset=" 58*7c478bd9Sstevel@tonic-gate #define CHARSET_LEN 8 59*7c478bd9Sstevel@tonic-gate #define NPLURALS_STR "nplurals=" 60*7c478bd9Sstevel@tonic-gate #define NPLURALS_LEN 9 61*7c478bd9Sstevel@tonic-gate 62*7c478bd9Sstevel@tonic-gate #define CBUFSIZE 128 63*7c478bd9Sstevel@tonic-gate #define MBUFSIZE 128 64*7c478bd9Sstevel@tonic-gate #define KBUFSIZE 16 65*7c478bd9Sstevel@tonic-gate #define NBUFSIZE 8 66*7c478bd9Sstevel@tonic-gate 67*7c478bd9Sstevel@tonic-gate #define cur_po (po_names[cur_po_index]) 68*7c478bd9Sstevel@tonic-gate 69*7c478bd9Sstevel@tonic-gate struct loc { 70*7c478bd9Sstevel@tonic-gate off_t off; /* offset to the string */ 71*7c478bd9Sstevel@tonic-gate size_t len; /* length of the string including null-termination */ 72*7c478bd9Sstevel@tonic-gate unsigned int num; /* line number */ 73*7c478bd9Sstevel@tonic-gate }; 74*7c478bd9Sstevel@tonic-gate 75*7c478bd9Sstevel@tonic-gate struct entry { 76*7c478bd9Sstevel@tonic-gate int no; /* # of plural forms */ 77*7c478bd9Sstevel@tonic-gate unsigned int num; /* line number */ 78*7c478bd9Sstevel@tonic-gate char *str; /* string */ 79*7c478bd9Sstevel@tonic-gate size_t len; /* length of the string including null-termination */ 80*7c478bd9Sstevel@tonic-gate struct loc *pos; 81*7c478bd9Sstevel@tonic-gate }; 82*7c478bd9Sstevel@tonic-gate 83*7c478bd9Sstevel@tonic-gate struct messages { 84*7c478bd9Sstevel@tonic-gate char *id; /* msgid + (msgid_plural) */ 85*7c478bd9Sstevel@tonic-gate char *str; /* msgstr + (msgstr[n]) */ 86*7c478bd9Sstevel@tonic-gate size_t id_len; /* length of id */ 87*7c478bd9Sstevel@tonic-gate size_t str_len; /* length of str */ 88*7c478bd9Sstevel@tonic-gate unsigned int hash; /* hash value of msgid */ 89*7c478bd9Sstevel@tonic-gate unsigned int num; /* line number */ 90*7c478bd9Sstevel@tonic-gate int po; /* po index */ 91*7c478bd9Sstevel@tonic-gate }; 92*7c478bd9Sstevel@tonic-gate 93*7c478bd9Sstevel@tonic-gate #define DEF_MSG_NUM 100 94*7c478bd9Sstevel@tonic-gate 95*7c478bd9Sstevel@tonic-gate struct catalog { 96*7c478bd9Sstevel@tonic-gate int header; /* 1: header found, 0: header missing */ 97*7c478bd9Sstevel@tonic-gate char *fname; /* mo filename */ 98*7c478bd9Sstevel@tonic-gate struct messages *msg; /* ptr to the messages struct array */ 99*7c478bd9Sstevel@tonic-gate unsigned int nmsg; /* # of messages */ 100*7c478bd9Sstevel@tonic-gate unsigned int msg_size; /* message_size */ 101*7c478bd9Sstevel@tonic-gate unsigned int fnum; /* # of fuzzy translations */ 102*7c478bd9Sstevel@tonic-gate unsigned int unum; /* # of untranslated msgs */ 103*7c478bd9Sstevel@tonic-gate unsigned int hash_size; /* hash table size */ 104*7c478bd9Sstevel@tonic-gate unsigned int nplurals; /* # of plural forms */ 105*7c478bd9Sstevel@tonic-gate unsigned int *thash; 106*7c478bd9Sstevel@tonic-gate unsigned int thash_size; 107*7c478bd9Sstevel@tonic-gate struct catalog *next; /* next catalog */ 108*7c478bd9Sstevel@tonic-gate }; 109*7c478bd9Sstevel@tonic-gate 110*7c478bd9Sstevel@tonic-gate struct msgtbl { 111*7c478bd9Sstevel@tonic-gate unsigned int len; 112*7c478bd9Sstevel@tonic-gate unsigned int offset; 113*7c478bd9Sstevel@tonic-gate }; 114*7c478bd9Sstevel@tonic-gate 115*7c478bd9Sstevel@tonic-gate extern int yyparse(void); 116*7c478bd9Sstevel@tonic-gate extern int yylex(void); 117*7c478bd9Sstevel@tonic-gate extern void yyerror(const char *); 118*7c478bd9Sstevel@tonic-gate extern void handle_domain(char *); 119*7c478bd9Sstevel@tonic-gate extern void handle_comment(char *); 120*7c478bd9Sstevel@tonic-gate extern void handle_message(struct entry *, struct entry *); 121*7c478bd9Sstevel@tonic-gate extern void clear_state(void); 122*7c478bd9Sstevel@tonic-gate extern void po_init(const char *); 123*7c478bd9Sstevel@tonic-gate extern void po_fini(void); 124*7c478bd9Sstevel@tonic-gate extern void catalog_init(const char *); 125*7c478bd9Sstevel@tonic-gate 126*7c478bd9Sstevel@tonic-gate extern struct messages *search_msg(struct catalog *, 127*7c478bd9Sstevel@tonic-gate const char *, unsigned int); 128*7c478bd9Sstevel@tonic-gate extern unsigned int hashpjw(const char *); 129*7c478bd9Sstevel@tonic-gate extern unsigned int find_prime(unsigned int); 130*7c478bd9Sstevel@tonic-gate extern void output_all_gnu_mo_files(void); 131*7c478bd9Sstevel@tonic-gate extern unsigned int get_hash_index(unsigned int *, 132*7c478bd9Sstevel@tonic-gate unsigned int, unsigned int); 133*7c478bd9Sstevel@tonic-gate extern void check_format(struct entry *, struct entry *, int); 134*7c478bd9Sstevel@tonic-gate 135*7c478bd9Sstevel@tonic-gate extern char **po_names; 136*7c478bd9Sstevel@tonic-gate extern int cur_po_index; 137*7c478bd9Sstevel@tonic-gate extern int po_error; 138*7c478bd9Sstevel@tonic-gate extern char *inputdir; 139*7c478bd9Sstevel@tonic-gate extern char *outfile; 140*7c478bd9Sstevel@tonic-gate extern int cur_line; 141*7c478bd9Sstevel@tonic-gate extern int fuzzy_flag; 142*7c478bd9Sstevel@tonic-gate extern int verbose_flag; 143*7c478bd9Sstevel@tonic-gate extern int strict_flag; 144*7c478bd9Sstevel@tonic-gate extern struct catalog *catalog_head; 145*7c478bd9Sstevel@tonic-gate extern FILE *fp; 146*7c478bd9Sstevel@tonic-gate extern iconv_t cd; 147*7c478bd9Sstevel@tonic-gate 148*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 149*7c478bd9Sstevel@tonic-gate } 150*7c478bd9Sstevel@tonic-gate #endif 151*7c478bd9Sstevel@tonic-gate 152*7c478bd9Sstevel@tonic-gate #endif /* _GNU_MSGFMT_H */ 153