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 #include "sun_msgfmt.h"
29 static const char *mandatory_fields
[] = {
35 "Content-Transfer-Encoding",
39 static const char *mandatory_fields_new
[] = {
47 extern void invoke_gnu_msgfmt(void);
50 get_one_line(char **bufhead
, char **mbuf
, size_t *fsize
)
67 while (((*fsize
) != 0) && (*p
++ != '\n')) {
74 tmp
= (char *)Xmalloc(len
+ 1);
75 (void) memcpy(tmp
, q
, len
);
83 check_gnu(char *addr
, size_t fsize
)
91 size_t bufsize
, index
;
101 ln_size
= get_one_line(&linebuf
, &mbuf
, &size
);
102 if ((ln_size
== (size_t)-1) ||
108 while ((*p
== '#') || (*p
== '\n')) {
109 ln_size
= get_one_line(&linebuf
, &mbuf
, &size
);
110 if ((ln_size
== (size_t)-1) ||
117 if (strncmp(p
, "domain", 6) == 0)
120 if (strncmp(p
, "msgid", 5) != 0) {
126 if ((*p
!= ' ') && (*p
!= '\t') &&
127 (*p
!= '\n') && (*p
!= '\0')) {
128 /* no space after msgid */
132 while ((*p
== ' ') || (*p
== '\t'))
135 /* check if this entry is an empty string */
136 if ((*p
!= '\"') || (*(p
+ 1) != '\"')) {
137 /* this is not an empty string */
141 while (*p
&& ((*p
== ' ') || (*p
== '\t'))) {
144 if ((*p
!= '\n') && (*p
!= '\0')) {
145 /* other characters than '\n' and '\0' found */
150 ln_size
= get_one_line(&linebuf
, &mbuf
, &size
);
151 if ((ln_size
== (size_t)-1) ||
156 /* skip leading spaces */
157 while ((*p
== ' ') || (*p
== '\t'))
161 if (strncmp(p
, "msgstr", 6) == 0) {
164 /* not a valid entry */
167 if (*(p
+ 1) != '\"') {
168 /* not an empty string */
172 while ((*p
== ' ') || (*p
== '\t'))
175 if ((*p
!= '\n') && (*p
!= '\0')) {
176 /* other characters than '\n' and '\0' found */
182 * msgid for the header entry found
183 * Now p points to "msgstr"
186 if ((*p
!= ' ') && (*p
!= '\t') &&
187 (*p
!= '\n') && (*p
!= '\0')) {
188 /* no space after msgid */
193 while ((*p
== ' ') || (*p
== '\t'))
201 bufsize
= ln_size
+ 1;
203 buf
= (char *)Xmalloc(bufsize
);
207 /* msgstr entry ends */
213 /* no beginning quote */
259 if (isdigit((unsigned char)c
)) {
283 while (*p
&& ((*p
== ' ') || (*p
== '\t'))) {
286 if ((*p
!= '\n') && (*p
!= '\0')) {
293 ln_size
= get_one_line(&linebuf
, &mbuf
, &size
);
294 if ((ln_size
== (size_t)-1) ||
300 while ((*p
== ' ') || (*p
== '\t'))
303 buf
= (char *)Xrealloc(buf
, bufsize
);
306 for (i
= 0; (field
= mandatory_fields
[i
]) != NULL
; i
++) {
307 if (strstr(buf
, field
) == NULL
)
309 /* one of mandatory fields found */
312 (void) munmap(addr
, fsize
);
314 diag(gettext(DIAG_GNU_FOUND
));
318 for (i
= 0; (field
= mandatory_fields_new
[i
]) != NULL
; i
++) {
319 if (strstr(buf
, field
) == NULL
)
321 /* one of mandatory fields found */
324 (void) munmap(addr
, fsize
);
326 diag(gettext(DIAG_GNU_FOUND
));