Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / liblouis / src / tools / lou_checktable.c
1 /* liblouis Braille Translation and Back-Translation Library
2
3    Based on BRLTTY, copyright (C) 1999-2006 by
4    The BRLTTY Team
5
6    Copyright (C) 2004, 2005, 2006, 2009
7    ViewPlus Technologies, Inc. www.viewplus.com and
8    JJB Software, Inc. www.jjb-software.com
9
10    This program is free software: you can redistribute it and/or modify
11    it under the terms of the GNU General Public License as published by
12    the Free Software Foundation, either version 3 of the License, or
13    (at your option) any later version.
14    
15    This program is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18    GNU General Public License for more details.
19    
20    You should have received a copy of the GNU General Public License
21    along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
23    Maintained by John J. Boyer john.boyer@jjb-software.com
24    */
25
26 #ifdef HAVE_CONFIG_H
27 # include "config.h"
28 #endif
29
30 #include <stdio.h>
31 #include <string.h>
32 #include <stdlib.h>
33 #include "louis.h"
34 #include <getopt.h>
35 #include "progname.h"
36 #include "version-etc.h"
37
38 static const struct option longopts[] =
39 {
40   { "help", no_argument, NULL, 'h' },
41   { "version", no_argument, NULL, 'v' },
42   { "quiet", no_argument, NULL, 'q' },
43   { NULL, 0, NULL, 0 }
44 };
45
46 const char version_etc_copyright[] =
47   "Copyright %s %d ViewPlus Technologies, Inc. and JJB Software, Inc.";
48
49 #define AUTHORS "John J. Boyer"
50
51 static int quiet_flag = 0;
52
53 static void
54 print_help (void)
55 {
56   printf ("\
57 Usage: %s [OPTIONS] TABLE[,TABLE,...]\n", program_name);
58   
59   fputs ("\
60 Test a Braille translation table. If the table contains errors,\n\
61 appropriate messages are displayed. If there are no errors the\n\
62 message \"no errors found.\" is shown unless you specify the --quiet\n\
63 option.\n", stdout);
64
65   fputs ("\
66   -h, --help          display this help and exit\n\
67   -v, --version       display version information and exit\n\
68   -q, --quiet         do not write to standard error if there are no errors.\n", stdout);
69
70   printf ("\n");
71   printf ("Report bugs to %s.\n", PACKAGE_BUGREPORT);
72
73 #ifdef PACKAGE_PACKAGER_BUG_REPORTS
74   printf ("Report %s bugs to: %s\n", PACKAGE_PACKAGER, PACKAGE_PACKAGER_BUG_REPORTS);
75 #endif
76 #ifdef PACKAGE_URL
77   printf ("%s home page: <%s>\n", PACKAGE_NAME, PACKAGE_URL);
78 #endif
79 }
80
81 int
82 main (int argc, char **argv)
83 {
84   const TranslationTableHeader *table;
85   int optc;
86
87   set_program_name (argv[0]);
88
89   while ((optc = getopt_long (argc, argv, "hvq", longopts, NULL)) != -1)
90     switch (optc)
91       {
92       /* --help and --version exit immediately, per GNU coding standards.  */
93       case 'v':
94         version_etc (stdout, program_name, PACKAGE_NAME, VERSION, AUTHORS, (char *) NULL);
95         exit (EXIT_SUCCESS);
96         break;
97       case 'h':
98         print_help ();
99         exit (EXIT_SUCCESS);
100         break;
101       case 'q':
102         quiet_flag = 1;
103         break;
104       default:
105         fprintf (stderr, "Try `%s --help' for more information.\n",
106                  program_name);
107         exit (EXIT_FAILURE);
108         break;
109       }
110
111   if (optind != argc - 1)
112     {
113       /* Print error message and exit.  */
114       if (optind < argc - 1)
115         fprintf (stderr, "%s: extra operand: %s\n",
116                  program_name, argv[optind + 1]);
117       else
118         fprintf (stderr, "%s: no table specified\n", 
119                  program_name);
120       fprintf (stderr, "Try `%s --help' for more information.\n",
121                program_name);
122       exit (EXIT_FAILURE);
123     }
124
125   if (!(table = lou_getTable (argv[optind])))
126     {
127       lou_free ();
128       exit (EXIT_FAILURE);
129     }
130   if (quiet_flag == 0)
131     fprintf (stderr, "No errors found.\n");
132   lou_free ();
133   exit (EXIT_SUCCESS);
134 }
135