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 #pragma ident "%Z%%M% %I% %E% SMI"
28
29 #include "gnu_msgfmt.h"
30
31 static char *cmd;
32 int fuzzy_flag = 0;
33 int verbose_flag = 0;
34 int strict_flag = 0;
35 int po_error = 0;
36 char *inputdir = NULL;
37 char *outfile = NULL;
38 char **po_names;
39
40 static void
usage(void)41 usage(void)
42 {
43 (void) fprintf(stderr,
44 gettext(ERR_USAGE), cmd);
45 exit(1);
46 }
47
48 int
main(int argc,char ** argv)49 main(int argc, char **argv)
50 {
51 int i, ret;
52 static struct flags flag;
53
54 (void) setlocale(LC_ALL, "");
55 #if !defined(TEXT_DOMAIN)
56 #define TEXT_DOMAIN "SYS_TEST"
57 #endif
58 (void) textdomain(TEXT_DOMAIN);
59
60 if (cmd = strrchr(argv[0], '/'))
61 ++cmd;
62 else
63 cmd = argv[0];
64
65 ret = parse_option(&argc, &argv, &flag);
66 if (ret == -1) {
67 usage();
68 /* NOTREACHED */
69 }
70 if (flag.idir) {
71 inputdir = flag.idir;
72 }
73 if (flag.ofile) {
74 outfile = flag.ofile;
75 catalog_init(outfile);
76 }
77 if (flag.fuzzy) {
78 fuzzy_flag = 1;
79 }
80 if (flag.sun_p) {
81 error(gettext(ERR_SUN_ON_GNU), cmd);
82 /* NOTREACHED */
83 }
84 if (flag.verbose) {
85 verbose_flag = 1;
86 }
87 if (flag.strict) {
88 strict_flag = 1;
89 }
90
91 po_names = (char **)Xmalloc(argc * sizeof (char *));
92 while (argc-- > 0) {
93 if (verbose_flag) {
94 diag(gettext(DIAG_START_PROC), *argv);
95 }
96 po_init(*argv);
97 (void) yyparse();
98 po_fini();
99 argv++;
100 }
101 for (i = 0; i < cur_po_index; i++) {
102 free(po_names[i]);
103 }
104 free(po_names);
105 if (po_error) {
106 /* error found */
107 error(gettext(ERR_ERROR_FOUND), po_error);
108 /* NOTREACHED */
109 }
110 output_all_gnu_mo_files();
111
112 return (0);
113 }
114