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
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.
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]
23 * Copyright (c) 2001 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include "sun_msgfmt.h"
31 static const char *mandatory_fields
[] = {
37 "Content-Transfer-Encoding",
41 static const char *mandatory_fields_new
[] = {
49 extern void invoke_gnu_msgfmt(void);
52 get_one_line(char **bufhead
, char **mbuf
, size_t *fsize
)
69 while (((*fsize
) != 0) && (*p
++ != '\n')) {
76 tmp
= (char *)Xmalloc(len
+ 1);
77 (void) memcpy(tmp
, q
, len
);
85 check_gnu(char *addr
, size_t fsize
)
93 size_t bufsize
, index
;
103 ln_size
= get_one_line(&linebuf
, &mbuf
, &size
);
104 if ((ln_size
== (size_t)-1) ||
110 while ((*p
== '#') || (*p
== '\n')) {
111 ln_size
= get_one_line(&linebuf
, &mbuf
, &size
);
112 if ((ln_size
== (size_t)-1) ||
119 if (strncmp(p
, "domain", 6) == 0)
122 if (strncmp(p
, "msgid", 5) != 0) {
128 if ((*p
!= ' ') && (*p
!= '\t') &&
129 (*p
!= '\n') && (*p
!= '\0')) {
130 /* no space after msgid */
134 while ((*p
== ' ') || (*p
== '\t'))
137 /* check if this entry is an empty string */
138 if ((*p
!= '\"') || (*(p
+ 1) != '\"')) {
139 /* this is not an empty string */
143 while (*p
&& ((*p
== ' ') || (*p
== '\t'))) {
146 if ((*p
!= '\n') && (*p
!= '\0')) {
147 /* other characters than '\n' and '\0' found */
152 ln_size
= get_one_line(&linebuf
, &mbuf
, &size
);
153 if ((ln_size
== (size_t)-1) ||
158 /* skip leading spaces */
159 while ((*p
== ' ') || (*p
== '\t'))
163 if (strncmp(p
, "msgstr", 6) == 0) {
166 /* not a valid entry */
169 if (*(p
+ 1) != '\"') {
170 /* not an empty string */
174 while ((*p
== ' ') || (*p
== '\t'))
177 if ((*p
!= '\n') && (*p
!= '\0')) {
178 /* other characters than '\n' and '\0' found */
184 * msgid for the header entry found
185 * Now p points to "msgstr"
188 if ((*p
!= ' ') && (*p
!= '\t') &&
189 (*p
!= '\n') && (*p
!= '\0')) {
190 /* no space after msgid */
195 while ((*p
== ' ') || (*p
== '\t'))
203 bufsize
= ln_size
+ 1;
205 buf
= (char *)Xmalloc(bufsize
);
209 /* msgstr entry ends */
215 /* no beginning quote */
261 if (isdigit((unsigned char)c
)) {
285 while (*p
&& ((*p
== ' ') || (*p
== '\t'))) {
288 if ((*p
!= '\n') && (*p
!= '\0')) {
295 ln_size
= get_one_line(&linebuf
, &mbuf
, &size
);
296 if ((ln_size
== (size_t)-1) ||
302 while ((*p
== ' ') || (*p
== '\t'))
305 buf
= (char *)Xrealloc(buf
, bufsize
);
308 for (i
= 0; (field
= mandatory_fields
[i
]) != NULL
; i
++) {
309 if (strstr(buf
, field
) == NULL
)
311 /* one of mandatory fields found */
314 (void) munmap(addr
, fsize
);
316 diag(gettext(DIAG_GNU_FOUND
));
320 for (i
= 0; (field
= mandatory_fields_new
[i
]) != NULL
; i
++) {
321 if (strstr(buf
, field
) == NULL
)
323 /* one of mandatory fields found */
326 (void) munmap(addr
, fsize
);
328 diag(gettext(DIAG_GNU_FOUND
));