17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 237c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _GNU_MSGFMT_H 287c478bd9Sstevel@tonic-gate #define _GNU_MSGFMT_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #include <stdio.h> 317c478bd9Sstevel@tonic-gate #include <limits.h> 327c478bd9Sstevel@tonic-gate #include <stdarg.h> 337c478bd9Sstevel@tonic-gate #include <locale.h> 347c478bd9Sstevel@tonic-gate #include <libintl.h> 357c478bd9Sstevel@tonic-gate #include <string.h> 367c478bd9Sstevel@tonic-gate #include <stdlib.h> 377c478bd9Sstevel@tonic-gate #include <iconv.h> 387c478bd9Sstevel@tonic-gate #include <ctype.h> 397c478bd9Sstevel@tonic-gate #include <fcntl.h> 407c478bd9Sstevel@tonic-gate #include <sys/types.h> 417c478bd9Sstevel@tonic-gate #include <sys/stat.h> 427c478bd9Sstevel@tonic-gate #include <sys/mman.h> 437c478bd9Sstevel@tonic-gate #include <alloca.h> 447c478bd9Sstevel@tonic-gate #include <unistd.h> 457c478bd9Sstevel@tonic-gate #include <errno.h> 467c478bd9Sstevel@tonic-gate #include "gnu_errmsg.h" 477c478bd9Sstevel@tonic-gate #include "common.h" 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate #ifdef __cplusplus 507c478bd9Sstevel@tonic-gate extern "C" { 517c478bd9Sstevel@tonic-gate #endif 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate #define _ENCODING_ALIAS_PATH "/usr/lib/iconv/alias" 547c478bd9Sstevel@tonic-gate #define DEST_CHARSET "UTF-8" 557c478bd9Sstevel@tonic-gate #define CHARSET_STR "charset=" 567c478bd9Sstevel@tonic-gate #define CHARSET_LEN 8 577c478bd9Sstevel@tonic-gate #define NPLURALS_STR "nplurals=" 587c478bd9Sstevel@tonic-gate #define NPLURALS_LEN 9 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate #define CBUFSIZE 128 617c478bd9Sstevel@tonic-gate #define MBUFSIZE 128 627c478bd9Sstevel@tonic-gate #define KBUFSIZE 16 637c478bd9Sstevel@tonic-gate #define NBUFSIZE 8 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate #define cur_po (po_names[cur_po_index]) 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate struct loc { 687c478bd9Sstevel@tonic-gate off_t off; /* offset to the string */ 697c478bd9Sstevel@tonic-gate size_t len; /* length of the string including null-termination */ 707c478bd9Sstevel@tonic-gate unsigned int num; /* line number */ 717c478bd9Sstevel@tonic-gate }; 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate struct entry { 747c478bd9Sstevel@tonic-gate int no; /* # of plural forms */ 757c478bd9Sstevel@tonic-gate unsigned int num; /* line number */ 767c478bd9Sstevel@tonic-gate char *str; /* string */ 777c478bd9Sstevel@tonic-gate size_t len; /* length of the string including null-termination */ 787c478bd9Sstevel@tonic-gate struct loc *pos; 797c478bd9Sstevel@tonic-gate }; 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate struct messages { 827c478bd9Sstevel@tonic-gate char *id; /* msgid + (msgid_plural) */ 837c478bd9Sstevel@tonic-gate char *str; /* msgstr + (msgstr[n]) */ 847c478bd9Sstevel@tonic-gate size_t id_len; /* length of id */ 857c478bd9Sstevel@tonic-gate size_t str_len; /* length of str */ 867c478bd9Sstevel@tonic-gate unsigned int hash; /* hash value of msgid */ 877c478bd9Sstevel@tonic-gate unsigned int num; /* line number */ 887c478bd9Sstevel@tonic-gate int po; /* po index */ 897c478bd9Sstevel@tonic-gate }; 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate #define DEF_MSG_NUM 100 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate struct catalog { 947c478bd9Sstevel@tonic-gate int header; /* 1: header found, 0: header missing */ 957c478bd9Sstevel@tonic-gate char *fname; /* mo filename */ 967c478bd9Sstevel@tonic-gate struct messages *msg; /* ptr to the messages struct array */ 977c478bd9Sstevel@tonic-gate unsigned int nmsg; /* # of messages */ 987c478bd9Sstevel@tonic-gate unsigned int msg_size; /* message_size */ 997c478bd9Sstevel@tonic-gate unsigned int fnum; /* # of fuzzy translations */ 1007c478bd9Sstevel@tonic-gate unsigned int unum; /* # of untranslated msgs */ 1017c478bd9Sstevel@tonic-gate unsigned int hash_size; /* hash table size */ 1027c478bd9Sstevel@tonic-gate unsigned int nplurals; /* # of plural forms */ 1037c478bd9Sstevel@tonic-gate unsigned int *thash; 1047c478bd9Sstevel@tonic-gate unsigned int thash_size; 1057c478bd9Sstevel@tonic-gate struct catalog *next; /* next catalog */ 1067c478bd9Sstevel@tonic-gate }; 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate struct msgtbl { 1097c478bd9Sstevel@tonic-gate unsigned int len; 1107c478bd9Sstevel@tonic-gate unsigned int offset; 1117c478bd9Sstevel@tonic-gate }; 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate extern int yyparse(void); 1147c478bd9Sstevel@tonic-gate extern int yylex(void); 115*1a90c98dSToomas Soome extern int yyerror(const char *) __NORETURN; 1167c478bd9Sstevel@tonic-gate extern void handle_domain(char *); 1177c478bd9Sstevel@tonic-gate extern void handle_comment(char *); 1187c478bd9Sstevel@tonic-gate extern void handle_message(struct entry *, struct entry *); 1197c478bd9Sstevel@tonic-gate extern void clear_state(void); 1207c478bd9Sstevel@tonic-gate extern void po_init(const char *); 1217c478bd9Sstevel@tonic-gate extern void po_fini(void); 1227c478bd9Sstevel@tonic-gate extern void catalog_init(const char *); 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate extern struct messages *search_msg(struct catalog *, 1257c478bd9Sstevel@tonic-gate const char *, unsigned int); 1267c478bd9Sstevel@tonic-gate extern unsigned int hashpjw(const char *); 1277c478bd9Sstevel@tonic-gate extern unsigned int find_prime(unsigned int); 1287c478bd9Sstevel@tonic-gate extern void output_all_gnu_mo_files(void); 1297c478bd9Sstevel@tonic-gate extern unsigned int get_hash_index(unsigned int *, 1307c478bd9Sstevel@tonic-gate unsigned int, unsigned int); 1317c478bd9Sstevel@tonic-gate extern void check_format(struct entry *, struct entry *, int); 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate extern char **po_names; 1347c478bd9Sstevel@tonic-gate extern int cur_po_index; 1357c478bd9Sstevel@tonic-gate extern int po_error; 1367c478bd9Sstevel@tonic-gate extern char *inputdir; 1377c478bd9Sstevel@tonic-gate extern char *outfile; 1387c478bd9Sstevel@tonic-gate extern int cur_line; 1397c478bd9Sstevel@tonic-gate extern int fuzzy_flag; 1407c478bd9Sstevel@tonic-gate extern int verbose_flag; 1417c478bd9Sstevel@tonic-gate extern int strict_flag; 1427c478bd9Sstevel@tonic-gate extern struct catalog *catalog_head; 1437c478bd9Sstevel@tonic-gate extern FILE *fp; 1447c478bd9Sstevel@tonic-gate extern iconv_t cd; 1457c478bd9Sstevel@tonic-gate 1467c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1477c478bd9Sstevel@tonic-gate } 1487c478bd9Sstevel@tonic-gate #endif 1497c478bd9Sstevel@tonic-gate 1507c478bd9Sstevel@tonic-gate #endif /* _GNU_MSGFMT_H */ 151