xref: /titanic_51/usr/src/cmd/msgfmt/sun_msgfmt.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
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 (c) 2001 by Sun Microsystems, Inc.
24*7c478bd9Sstevel@tonic-gate  * All rights reserved.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef	_SUN_MSGFMT_H
28*7c478bd9Sstevel@tonic-gate #define	_SUN_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 <string.h>
33*7c478bd9Sstevel@tonic-gate #include <locale.h>
34*7c478bd9Sstevel@tonic-gate #include <stdio.h>
35*7c478bd9Sstevel@tonic-gate #include <wchar.h>
36*7c478bd9Sstevel@tonic-gate #include <ctype.h>
37*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
38*7c478bd9Sstevel@tonic-gate #include <sys/param.h>
39*7c478bd9Sstevel@tonic-gate #include <sys/stat.h>
40*7c478bd9Sstevel@tonic-gate #include <sys/mman.h>
41*7c478bd9Sstevel@tonic-gate #include <signal.h>
42*7c478bd9Sstevel@tonic-gate #include <malloc.h>
43*7c478bd9Sstevel@tonic-gate #include <libintl.h>
44*7c478bd9Sstevel@tonic-gate #include <stdlib.h>
45*7c478bd9Sstevel@tonic-gate #include <fcntl.h>
46*7c478bd9Sstevel@tonic-gate #include <unistd.h>
47*7c478bd9Sstevel@tonic-gate #include "../../lib/libc/inc/msgfmt.h"
48*7c478bd9Sstevel@tonic-gate #include "common.h"
49*7c478bd9Sstevel@tonic-gate 
50*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
51*7c478bd9Sstevel@tonic-gate extern "C" {
52*7c478bd9Sstevel@tonic-gate #endif
53*7c478bd9Sstevel@tonic-gate 
54*7c478bd9Sstevel@tonic-gate #define	DOMAIN_TOKEN	L"domain"	/* domain token in po file  */
55*7c478bd9Sstevel@tonic-gate #define	DOMAIN_LEN	6
56*7c478bd9Sstevel@tonic-gate #define	MSGID_TOKEN	L"msgid"	/* msg id token in po file  */
57*7c478bd9Sstevel@tonic-gate #define	MSGID_LEN	5
58*7c478bd9Sstevel@tonic-gate #define	MSGSTR_TOKEN	L"msgstr"	/* target str token in po file */
59*7c478bd9Sstevel@tonic-gate #define	MSGSTR_LEN	6
60*7c478bd9Sstevel@tonic-gate 
61*7c478bd9Sstevel@tonic-gate #ifdef	DEBUG_MMAP
62*7c478bd9Sstevel@tonic-gate #define	MAX_VALUE_LEN		3	/* size of msg id and target str */
63*7c478bd9Sstevel@tonic-gate #define	LINE_SIZE	1
64*7c478bd9Sstevel@tonic-gate #else
65*7c478bd9Sstevel@tonic-gate #define	MAX_VALUE_LEN		512	/* size of msg id and target str */
66*7c478bd9Sstevel@tonic-gate #define	LINE_SIZE	512
67*7c478bd9Sstevel@tonic-gate #endif
68*7c478bd9Sstevel@tonic-gate 
69*7c478bd9Sstevel@tonic-gate /*
70*7c478bd9Sstevel@tonic-gate  * check if the next character is possible valid character.
71*7c478bd9Sstevel@tonic-gate  */
72*7c478bd9Sstevel@tonic-gate #define	CK_NXT_CH(a, l)	\
73*7c478bd9Sstevel@tonic-gate 	((a[(l) - 1] == L' ') || (a[(l) - 1] == L'\t') || \
74*7c478bd9Sstevel@tonic-gate 	(a[(l) - 1] == L'\n') || (a[(l) - 1] == L'\0'))
75*7c478bd9Sstevel@tonic-gate 
76*7c478bd9Sstevel@tonic-gate struct msg_chain {
77*7c478bd9Sstevel@tonic-gate 	char	*msgid;		/* msg id string */
78*7c478bd9Sstevel@tonic-gate 	char	*msgstr;	/* msg target string */
79*7c478bd9Sstevel@tonic-gate 	int	msgid_offset;	/* msg id offset in mo file */
80*7c478bd9Sstevel@tonic-gate 	int	msgstr_offset;	/* msg target string offset in mo file */
81*7c478bd9Sstevel@tonic-gate 	struct  msg_chain *next;	/* next node */
82*7c478bd9Sstevel@tonic-gate };
83*7c478bd9Sstevel@tonic-gate 
84*7c478bd9Sstevel@tonic-gate struct  domain_struct {
85*7c478bd9Sstevel@tonic-gate 	char			*domain;	/* domain name */
86*7c478bd9Sstevel@tonic-gate 	struct msg_chain	*first_elem;	/* head of msg link list */
87*7c478bd9Sstevel@tonic-gate 	struct msg_chain	*current_elem;	/* most recently used msg */
88*7c478bd9Sstevel@tonic-gate 	struct domain_struct	*next;		/* next domain node */
89*7c478bd9Sstevel@tonic-gate };
90*7c478bd9Sstevel@tonic-gate 
91*7c478bd9Sstevel@tonic-gate #define	ERR_EXEC_FAILED \
92*7c478bd9Sstevel@tonic-gate 	"failed to execute %s.\n"
93*7c478bd9Sstevel@tonic-gate 
94*7c478bd9Sstevel@tonic-gate #define	ERR_USAGE \
95*7c478bd9Sstevel@tonic-gate 	"Usage: msgfmt [-D dir | --directory=dir] [-f | --use-fuzzy]\n" \
96*7c478bd9Sstevel@tonic-gate 	"               [-g] [-o outfile | --output-file=outfile]\n" \
97*7c478bd9Sstevel@tonic-gate 	"               [-s] [--strict] [-v] [--verbose] files ...\n"
98*7c478bd9Sstevel@tonic-gate 
99*7c478bd9Sstevel@tonic-gate #define	ERR_GNU_ON_SUN \
100*7c478bd9Sstevel@tonic-gate 	"-g and -s are mutually exclusive.\n"
101*7c478bd9Sstevel@tonic-gate 
102*7c478bd9Sstevel@tonic-gate #define	ERR_STAT_FAILED \
103*7c478bd9Sstevel@tonic-gate 	"stat failed for %s.\n"
104*7c478bd9Sstevel@tonic-gate 
105*7c478bd9Sstevel@tonic-gate #define	ERR_MMAP_FAILED \
106*7c478bd9Sstevel@tonic-gate 	"mmap failed for %s.\n"
107*7c478bd9Sstevel@tonic-gate 
108*7c478bd9Sstevel@tonic-gate #define	ERR_MUNMAP_FAILED \
109*7c478bd9Sstevel@tonic-gate 	"munmap failed for %s.\n"
110*7c478bd9Sstevel@tonic-gate 
111*7c478bd9Sstevel@tonic-gate #define	ERR_NOSPC \
112*7c478bd9Sstevel@tonic-gate 	"Error, No space after directive at line number %d.\n"
113*7c478bd9Sstevel@tonic-gate 
114*7c478bd9Sstevel@tonic-gate #define	ERR_EXITING \
115*7c478bd9Sstevel@tonic-gate 	"Exiting...\n"
116*7c478bd9Sstevel@tonic-gate 
117*7c478bd9Sstevel@tonic-gate #define	WARN_NO_MSGSTR \
118*7c478bd9Sstevel@tonic-gate 	"Consecutive MSGID tokens " \
119*7c478bd9Sstevel@tonic-gate 	"encountered at line number: %d, ignored.\n"
120*7c478bd9Sstevel@tonic-gate 
121*7c478bd9Sstevel@tonic-gate #define	WARN_NO_MSGID \
122*7c478bd9Sstevel@tonic-gate 	"Consecutive MSGSTR tokens " \
123*7c478bd9Sstevel@tonic-gate 	"encountered at line number: %d, ignored.\n"
124*7c478bd9Sstevel@tonic-gate 
125*7c478bd9Sstevel@tonic-gate #define	WARN_SYNTAX_ERR \
126*7c478bd9Sstevel@tonic-gate 	"Syntax at line number: %d, " \
127*7c478bd9Sstevel@tonic-gate 	"line ignored\n"
128*7c478bd9Sstevel@tonic-gate 
129*7c478bd9Sstevel@tonic-gate #define	WARN_MISSING_QUOTE \
130*7c478bd9Sstevel@tonic-gate 	"Syntax at line number: %d, " \
131*7c478bd9Sstevel@tonic-gate 	"Missing \", ignored\n"
132*7c478bd9Sstevel@tonic-gate 
133*7c478bd9Sstevel@tonic-gate #define	WARN_MISSING_QUOTE_AT_EOL \
134*7c478bd9Sstevel@tonic-gate 	"Syntax at line number: %d, " \
135*7c478bd9Sstevel@tonic-gate 	"Missing \" at EOL, ignored\n"
136*7c478bd9Sstevel@tonic-gate 
137*7c478bd9Sstevel@tonic-gate #define	WARN_INVALID_STRING \
138*7c478bd9Sstevel@tonic-gate 	"the string after closing \" " \
139*7c478bd9Sstevel@tonic-gate 	"is ignored at line number %d.\n"
140*7c478bd9Sstevel@tonic-gate 
141*7c478bd9Sstevel@tonic-gate #define	WARN_DUP_MSG \
142*7c478bd9Sstevel@tonic-gate 	"Duplicate id \"%s\" at line number: " \
143*7c478bd9Sstevel@tonic-gate 	"%d, line ignored\n"
144*7c478bd9Sstevel@tonic-gate 
145*7c478bd9Sstevel@tonic-gate #define	DIAG_GNU_FOUND \
146*7c478bd9Sstevel@tonic-gate 	"GNU PO file found.\n"
147*7c478bd9Sstevel@tonic-gate 
148*7c478bd9Sstevel@tonic-gate #define	DIAG_INVOKING_GNU \
149*7c478bd9Sstevel@tonic-gate 	"Generating the MO file in the GNU MO format.\n"
150*7c478bd9Sstevel@tonic-gate 
151*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
152*7c478bd9Sstevel@tonic-gate }
153*7c478bd9Sstevel@tonic-gate #endif
154*7c478bd9Sstevel@tonic-gate 
155*7c478bd9Sstevel@tonic-gate #endif /* _SUN_MSGFMT_H */
156