| 1 | /* liblouis Braille Translation and Back-Translation Library |
| 2 | |
| 3 | Copyright (C) 2017 Bert Frees |
| 4 | |
| 5 | This program is free software: you can redistribute it and/or modify |
| 6 | it under the terms of the GNU General Public License as published by |
| 7 | the Free Software Foundation, either version 3 of the License, or |
| 8 | (at your option) any later version. |
| 9 | |
| 10 | This program is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | GNU General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU General Public License |
| 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #include <config.h>cxx . . $ `<file>/liblouis/config.h`/ |
| 20 | |
| 21 | #include <stdlib.h>cxx . . $ `<file>/gnulib/stdlib.h`/ |
| 22 | #include "liblouis.h"cxx . . $ `<file>/liblouis/liblouis.h`/ |
| 23 | #include <getopt.h> |
| 24 | #include "progname.h"cxx . . $ `<file>/tools/gnulib/progname.h`/ |
| 25 | #include "version-etc.h"cxx . . $ `<file>/tools/gnulib/version-etc.h`/ |
| 26 | |
| 27 | static const struct optioncxx . . $ option# longoptscxx . . $ longopts.[] = { |
| 28 | { "help", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, 'h' }, |
| 29 | { "version", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, 'v' }, |
| 30 | { NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, 0, NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, 0 }, |
| 31 | }; |
| 32 | |
| 33 | const char version_etc_copyrightcxx . . $ version_etc_copyright.[] = "Copyright %s %d Bert Frees"; |
| 34 | |
| 35 | #define AUTHORScxx . . $ `tools/lou_tableinfo.c:35:9`! "Bert Frees" |
| 36 | |
| 37 | static void |
| 38 | print_helpcxx . . $ print_help(49f6e7a06ebc5aa8).(void) { |
| 39 | printfcxx . . $ printf(581fddd72a8db8fc).("\ |
| 40 | Usage: %s [KEY] TABLE\n", |
| 41 | program_namecxx . . $ program_name.); |
| 42 | |
| 43 | fputscxx . . $ fputs(874fa6a5e59ab9bd).("\ |
| 44 | Print all table metadata defined in TABLE, or a specific metadata field\n\ |
| 45 | if KEY is specified. Return 0 if the requested metadata could be found,\n\ |
| 46 | 1 otherwise.\n\n", |
| 47 | stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!); |
| 48 | |
| 49 | fputscxx . . $ fputs(874fa6a5e59ab9bd).("\ |
| 50 | -h, --help display this help and exit\n\ |
| 51 | -v, --version display version information and exi\n", |
| 52 | stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!); |
| 53 | |
| 54 | printfcxx . . $ printf(581fddd72a8db8fc).("\n"); |
| 55 | printfcxx . . $ printf(581fddd72a8db8fc).("Report bugs to %s.\n", PACKAGE_BUGREPORTcxx . . $ `liblouis/config.h:628:9`!); |
| 56 | |
| 57 | #ifdef PACKAGE_PACKAGER_BUG_REPORTS |
| 58 | printf("Report %s bugs to: %s\n", PACKAGE_PACKAGER, PACKAGE_PACKAGER_BUG_REPORTS); |
| 59 | #endif |
| 60 | #ifdef PACKAGE_URLcxx . . $ `liblouis/config.h:649:9`! |
| 61 | printfcxx . . $ printf(581fddd72a8db8fc).("%s home page: <%s>\n", PACKAGE_NAMEcxx . . $ `liblouis/config.h:631:9`!, PACKAGE_URLcxx . . $ `liblouis/config.h:649:9`!); |
| 62 | #endif |
| 63 | } |
| 64 | |
| 65 | int |
| 66 | maincxx . . $ main(afcd3168fc1188a4).(int argc, char **argv) { |
| 67 | int optc; |
| 68 | set_program_namecxx . . $ set_program_name(85c52e162fed56f9).(argv[0]); |
| 69 | while ((optc = getopt_longcxx . . $ getopt_long(41f665c090816971).(argc, argv, "hv", longoptscxx . . $ longopts., NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!)) != -1) switch (optc) { |
| 70 | /* --help and --version exit immediately, per GNU coding standards. */ |
| 71 | case 'v': |
| 72 | version_etccxx . . $ version_etc(b5fd392babfe1cc5).( |
| 73 | stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!, program_namecxx . . $ program_name., PACKAGE_NAMEcxx . . $ `liblouis/config.h:631:9`!, VERSIONcxx . . $ `liblouis/config.h:804:9`!, AUTHORScxx . . $ `tools/lou_tableinfo.c:35:9`!, (char *)NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!); |
| 74 | exitcxx . . $ exit(3ca292c338df9bb3).(EXIT_SUCCESScxx . . $ `<external>/10696550936717951914/stdlib.h:97:9`!); |
| 75 | break; |
| 76 | case 'h': |
| 77 | print_helpcxx . . $ print_help(49f6e7a06ebc5aa8).(); |
| 78 | exitcxx . . $ exit(3ca292c338df9bb3).(EXIT_SUCCESScxx . . $ `<external>/10696550936717951914/stdlib.h:97:9`!); |
| 79 | break; |
| 80 | default: |
| 81 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Try `%s --help' for more information.\n", program_namecxx . . $ program_name.); |
| 82 | exitcxx . . $ exit(3ca292c338df9bb3).(EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:96:9`!); |
| 83 | break; |
| 84 | } |
| 85 | if (optindcxx . . $ optind. > argc - 1) { |
| 86 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "%s: no table specified\n", program_namecxx . . $ program_name.); |
| 87 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Try `%s --help' for more information.\n", program_namecxx . . $ program_name.); |
| 88 | exitcxx . . $ exit(3ca292c338df9bb3).(EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:96:9`!); |
| 89 | } else if (optindcxx . . $ optind. == argc - 1) { |
| 90 | // const char *table = argv[optind]; |
| 91 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Not supported yet\n"); |
| 92 | exitcxx . . $ exit(3ca292c338df9bb3).(EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:96:9`!); |
| 93 | } else if (optindcxx . . $ optind. == argc - 2) { |
| 94 | const char *key = argv[optindcxx . . $ optind.]; |
| 95 | const char *table = argv[optindcxx . . $ optind. + 1]; |
| 96 | const char *value = lou_getTableInfocxx . . $ lou_getTableInfo(a713fe7b9a57cf96).(table, key); |
| 97 | if (value != NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!) { |
| 98 | printfcxx . . $ printf(581fddd72a8db8fc).("%s\n", value); |
| 99 | exitcxx . . $ exit(3ca292c338df9bb3).(EXIT_SUCCESScxx . . $ `<external>/10696550936717951914/stdlib.h:97:9`!); |
| 100 | } else { |
| 101 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "%s: no such field in %s\n", key, table); |
| 102 | exitcxx . . $ exit(3ca292c338df9bb3).(EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:96:9`!); |
| 103 | } |
| 104 | } else { |
| 105 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "%s: extra operand: %s\n", program_namecxx . . $ program_name., argv[optindcxx . . $ optind. + 1]); |
| 106 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "Try `%s --help' for more information.\n", program_namecxx . . $ program_name.); |
| 107 | exitcxx . . $ exit(3ca292c338df9bb3).(EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:96:9`!); |
| 108 | } |
| 109 | } |