Eitan Isaacson | 80be8fd | 2008-01-16 01:14:49 +0000 | [diff] [blame] | 1 | /* liblouis Braille Translation and Back-Translation Library |
| 2 | |
| 3 | Based on BRLTTY, copyright (C) 1999-2006 by |
| 4 | The BRLTTY Team |
| 5 | |
Christian Egli | 08d96a7 | 2009-10-08 08:49:13 +0000 | [diff] [blame] | 6 | Copyright (C) 2004, 2005, 2006, 2009 |
| 7 | ViewPlus Technologies, Inc. www.viewplus.com and |
Eitan Isaacson | 80be8fd | 2008-01-16 01:14:49 +0000 | [diff] [blame] | 8 | JJB Software, Inc. www.jjb-software.com |
| 9 | |
Christian Egli | 08d96a7 | 2009-10-08 08:49:13 +0000 | [diff] [blame] | 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. |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 14 | |
Christian Egli | 08d96a7 | 2009-10-08 08:49:13 +0000 | [diff] [blame] | 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. |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 19 | |
Eitan Isaacson | 80be8fd | 2008-01-16 01:14:49 +0000 | [diff] [blame] | 20 | You should have received a copy of the GNU General Public License |
Christian Egli | 08d96a7 | 2009-10-08 08:49:13 +0000 | [diff] [blame] | 21 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
Bert Frees | 312affd | 2017-09-30 19:49:15 +0200 | [diff] [blame] | 22 | */ |
Eitan Isaacson | 80be8fd | 2008-01-16 01:14:49 +0000 | [diff] [blame] | 23 | |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 24 | #include <config.h> |
Eitan Isaacson | 80be8fd | 2008-01-16 01:14:49 +0000 | [diff] [blame] | 25 | #include <stdio.h> |
| 26 | #include <string.h> |
| 27 | #include <stdlib.h> |
Davy Kager | ff52a4f | 2017-04-26 22:01:10 +0200 | [diff] [blame] | 28 | #include "internal.h" |
Christian Egli | 80d0b50 | 2009-10-08 13:06:33 +0000 | [diff] [blame] | 29 | #include <getopt.h> |
| 30 | #include "progname.h" |
Christian Egli | 80d0b50 | 2009-10-08 13:06:33 +0000 | [diff] [blame] | 31 | #include "version-etc.h" |
| 32 | |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 33 | static const struct option longopts[] = { |
Christian Egli | 585c676 | 2019-06-05 15:19:10 +0200 | [diff] [blame] | 34 | { "help", no_argument, NULL, 'h' }, |
| 35 | { "version", no_argument, NULL, 'v' }, |
| 36 | { "quiet", no_argument, NULL, 'q' }, |
| 37 | { NULL, 0, NULL, 0 }, |
Christian Egli | 80d0b50 | 2009-10-08 13:06:33 +0000 | [diff] [blame] | 38 | }; |
| 39 | |
| 40 | const char version_etc_copyright[] = |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 41 | "Copyright %s %d ViewPlus Technologies, Inc. and JJB Software, Inc."; |
Christian Egli | 80d0b50 | 2009-10-08 13:06:33 +0000 | [diff] [blame] | 42 | |
Christian Egli | c1fe314 | 2009-10-09 08:16:21 +0000 | [diff] [blame] | 43 | #define AUTHORS "John J. Boyer" |
Christian Egli | 80d0b50 | 2009-10-08 13:06:33 +0000 | [diff] [blame] | 44 | |
Christian Egli | 2ac36f7 | 2011-03-14 13:10:39 +0000 | [diff] [blame] | 45 | static int quiet_flag = 0; |
| 46 | |
Christian Egli | 80d0b50 | 2009-10-08 13:06:33 +0000 | [diff] [blame] | 47 | static void |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 48 | print_help(void) { |
| 49 | printf("\ |
| 50 | Usage: %s [OPTIONS] TABLE[,TABLE,...]\n", |
| 51 | program_name); |
| 52 | |
| 53 | fputs("\ |
Christian Egli | c1fe314 | 2009-10-09 08:16:21 +0000 | [diff] [blame] | 54 | Test a Braille translation table. If the table contains errors,\n\ |
| 55 | appropriate messages are displayed. If there are no errors the\n\ |
Christian Egli | 2ac36f7 | 2011-03-14 13:10:39 +0000 | [diff] [blame] | 56 | message \"no errors found.\" is shown unless you specify the --quiet\n\ |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 57 | option.\n", |
| 58 | stdout); |
Christian Egli | 80d0b50 | 2009-10-08 13:06:33 +0000 | [diff] [blame] | 59 | |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 60 | fputs("\ |
Christian Egli | 80d0b50 | 2009-10-08 13:06:33 +0000 | [diff] [blame] | 61 | -h, --help display this help and exit\n\ |
Christian Egli | 2ac36f7 | 2011-03-14 13:10:39 +0000 | [diff] [blame] | 62 | -v, --version display version information and exit\n\ |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 63 | -q, --quiet do not write to standard error if there are no errors.\n", |
| 64 | stdout); |
Christian Egli | 80d0b50 | 2009-10-08 13:06:33 +0000 | [diff] [blame] | 65 | |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 66 | printf("\n"); |
| 67 | printf("Report bugs to %s.\n", PACKAGE_BUGREPORT); |
Christian Egli | dc50af9 | 2012-09-27 13:10:51 +0000 | [diff] [blame] | 68 | |
| 69 | #ifdef PACKAGE_PACKAGER_BUG_REPORTS |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 70 | printf("Report %s bugs to: %s\n", PACKAGE_PACKAGER, PACKAGE_PACKAGER_BUG_REPORTS); |
Christian Egli | dc50af9 | 2012-09-27 13:10:51 +0000 | [diff] [blame] | 71 | #endif |
| 72 | #ifdef PACKAGE_URL |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 73 | printf("%s home page: <%s>\n", PACKAGE_NAME, PACKAGE_URL); |
Christian Egli | dc50af9 | 2012-09-27 13:10:51 +0000 | [diff] [blame] | 74 | #endif |
Christian Egli | 80d0b50 | 2009-10-08 13:06:33 +0000 | [diff] [blame] | 75 | } |
Eitan Isaacson | 80be8fd | 2008-01-16 01:14:49 +0000 | [diff] [blame] | 76 | |
| 77 | int |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 78 | main(int argc, char **argv) { |
| 79 | const TranslationTableHeader *table; |
| 80 | int optc; |
Christian Egli | 80d0b50 | 2009-10-08 13:06:33 +0000 | [diff] [blame] | 81 | |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 82 | set_program_name(argv[0]); |
Christian Egli | 80d0b50 | 2009-10-08 13:06:33 +0000 | [diff] [blame] | 83 | |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 84 | while ((optc = getopt_long(argc, argv, "hvq", longopts, NULL)) != -1) switch (optc) { |
| 85 | /* --help and --version exit immediately, per GNU coding standards. */ |
| 86 | case 'v': |
| 87 | version_etc( |
| 88 | stdout, program_name, PACKAGE_NAME, VERSION, AUTHORS, (char *)NULL); |
| 89 | exit(EXIT_SUCCESS); |
| 90 | break; |
| 91 | case 'h': |
| 92 | print_help(); |
| 93 | exit(EXIT_SUCCESS); |
| 94 | break; |
| 95 | case 'q': |
| 96 | quiet_flag = 1; |
| 97 | break; |
| 98 | default: |
| 99 | fprintf(stderr, "Try `%s --help' for more information.\n", program_name); |
| 100 | exit(EXIT_FAILURE); |
| 101 | break; |
| 102 | } |
Christian Egli | 80d0b50 | 2009-10-08 13:06:33 +0000 | [diff] [blame] | 103 | |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 104 | if (optind != argc - 1) { |
| 105 | /* Print error message and exit. */ |
| 106 | if (optind < argc - 1) |
| 107 | fprintf(stderr, "%s: extra operand: %s\n", program_name, argv[optind + 1]); |
| 108 | else |
| 109 | fprintf(stderr, "%s: no table specified\n", program_name); |
| 110 | fprintf(stderr, "Try `%s --help' for more information.\n", program_name); |
| 111 | exit(EXIT_FAILURE); |
| 112 | } |
Christian Egli | 80d0b50 | 2009-10-08 13:06:33 +0000 | [diff] [blame] | 113 | |
Bert Frees | 92a8035 | 2017-09-30 23:01:02 +0200 | [diff] [blame] | 114 | if (!(table = lou_getTable(argv[optind]))) { |
| 115 | lou_free(); |
| 116 | exit(EXIT_FAILURE); |
| 117 | } |
| 118 | if (quiet_flag == 0) fprintf(stderr, "No errors found.\n"); |
| 119 | lou_free(); |
| 120 | exit(EXIT_SUCCESS); |
Eitan Isaacson | 80be8fd | 2008-01-16 01:14:49 +0000 | [diff] [blame] | 121 | } |