xref: /illumos-gate/usr/src/cmd/msgfmt/sun_msgfmt.h (revision 2a8bcb4efb45d99ac41c94a75c396b362c414f7f)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 2001 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef	_SUN_MSGFMT_H
28 #define	_SUN_MSGFMT_H
29 
30 #include <string.h>
31 #include <locale.h>
32 #include <stdio.h>
33 #include <wchar.h>
34 #include <ctype.h>
35 #include <sys/types.h>
36 #include <sys/param.h>
37 #include <sys/stat.h>
38 #include <sys/mman.h>
39 #include <signal.h>
40 #include <malloc.h>
41 #include <libintl.h>
42 #include <stdlib.h>
43 #include <fcntl.h>
44 #include <unistd.h>
45 #include "../../lib/libc/inc/msgfmt.h"
46 #include "common.h"
47 
48 #ifdef	__cplusplus
49 extern "C" {
50 #endif
51 
52 #define	DOMAIN_TOKEN	L"domain"	/* domain token in po file  */
53 #define	DOMAIN_LEN	6
54 #define	MSGID_TOKEN	L"msgid"	/* msg id token in po file  */
55 #define	MSGID_LEN	5
56 #define	MSGSTR_TOKEN	L"msgstr"	/* target str token in po file */
57 #define	MSGSTR_LEN	6
58 
59 #ifdef	DEBUG_MMAP
60 #define	MAX_VALUE_LEN		3	/* size of msg id and target str */
61 #define	LINE_SIZE	1
62 #else
63 #define	MAX_VALUE_LEN		512	/* size of msg id and target str */
64 #define	LINE_SIZE	512
65 #endif
66 
67 /*
68  * check if the next character is possible valid character.
69  */
70 #define	CK_NXT_CH(a, l)	\
71 	((a[(l) - 1] == L' ') || (a[(l) - 1] == L'\t') || \
72 	(a[(l) - 1] == L'\n') || (a[(l) - 1] == L'\0'))
73 
74 struct msg_chain {
75 	char	*msgid;		/* msg id string */
76 	char	*msgstr;	/* msg target string */
77 	int	msgid_offset;	/* msg id offset in mo file */
78 	int	msgstr_offset;	/* msg target string offset in mo file */
79 	struct  msg_chain *next;	/* next node */
80 };
81 
82 struct  domain_struct {
83 	char			*domain;	/* domain name */
84 	struct msg_chain	*first_elem;	/* head of msg link list */
85 	struct msg_chain	*current_elem;	/* most recently used msg */
86 	struct domain_struct	*next;		/* next domain node */
87 };
88 
89 #define	ERR_EXEC_FAILED \
90 	"failed to execute %s.\n"
91 
92 #define	ERR_USAGE \
93 	"Usage: msgfmt [-D dir | --directory=dir] [-f | --use-fuzzy]\n" \
94 	"               [-g] [-o outfile | --output-file=outfile]\n" \
95 	"               [-s] [--strict] [-v] [--verbose] files ...\n"
96 
97 #define	ERR_GNU_ON_SUN \
98 	"-g and -s are mutually exclusive.\n"
99 
100 #define	ERR_STAT_FAILED \
101 	"stat failed for %s.\n"
102 
103 #define	ERR_MMAP_FAILED \
104 	"mmap failed for %s.\n"
105 
106 #define	ERR_MUNMAP_FAILED \
107 	"munmap failed for %s.\n"
108 
109 #define	ERR_NOSPC \
110 	"Error, No space after directive at line number %d.\n"
111 
112 #define	ERR_EXITING \
113 	"Exiting...\n"
114 
115 #define	WARN_NO_MSGSTR \
116 	"Consecutive MSGID tokens " \
117 	"encountered at line number: %d, ignored.\n"
118 
119 #define	WARN_NO_MSGID \
120 	"Consecutive MSGSTR tokens " \
121 	"encountered at line number: %d, ignored.\n"
122 
123 #define	WARN_SYNTAX_ERR \
124 	"Syntax at line number: %d, " \
125 	"line ignored\n"
126 
127 #define	WARN_MISSING_QUOTE \
128 	"Syntax at line number: %d, " \
129 	"Missing \", ignored\n"
130 
131 #define	WARN_MISSING_QUOTE_AT_EOL \
132 	"Syntax at line number: %d, " \
133 	"Missing \" at EOL, ignored\n"
134 
135 #define	WARN_INVALID_STRING \
136 	"the string after closing \" " \
137 	"is ignored at line number %d.\n"
138 
139 #define	WARN_DUP_MSG \
140 	"Duplicate id \"%s\" at line number: " \
141 	"%d, line ignored\n"
142 
143 #define	DIAG_GNU_FOUND \
144 	"GNU PO file found.\n"
145 
146 #define	DIAG_INVOKING_GNU \
147 	"Generating the MO file in the GNU MO format.\n"
148 
149 #ifdef	__cplusplus
150 }
151 #endif
152 
153 #endif /* _SUN_MSGFMT_H */
154