1 /* liblouis Braille Translation and Back-Translation Library
3 Based on the Linux screenreader BRLTTY, copyright (C) 1999-2006 by
6 Copyright (C) 2004, 2005, 2006, 2009
7 ViewPlus Technologies, Inc. www.viewplus.com and
8 JJB Software, Inc. www.jjb-software.com
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.
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.
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/>.
23 Maintained by John J. Boyer john.boyer@jjb-software.com
37 #include "version-etc.h"
39 static const struct option longopts[] =
41 { "help", no_argument, NULL, 'h' },
42 { "version", no_argument, NULL, 'v' },
46 const char version_etc_copyright[] =
47 "Copyright %s %d ViewPlus Technologies, Inc. and JJB Software, Inc.";
49 #define AUTHORS "John J. Boyer"
55 Usage: %s [OPTIONS]\n", program_name);
58 Check the accuracy of hyphenation in Braille translation for both\n\
59 translated and untranslated words.\n\n", stdout);
62 -h, --help display this help and exit\n\
63 -v, --version display version information and exit\n", stdout);
66 printf ("Report bugs to %s.\n", PACKAGE_BUGREPORT);
68 #ifdef PACKAGE_PACKAGER_BUG_REPORTS
69 printf ("Report %s bugs to: %s\n", PACKAGE_PACKAGER, PACKAGE_PACKAGER_BUG_REPORTS);
72 printf ("%s home page: <%s>\n", PACKAGE_NAME, PACKAGE_URL);
78 static char inputBuffer[BUFSIZE];
79 static const TranslationTableHeader *validTable = NULL;
80 static unsigned int mode;
81 static char table[BUFSIZE];
88 fgets (inputBuffer, sizeof (inputBuffer), stdin);
89 inputLength = strlen (inputBuffer) - 1;
90 if (inputLength < 0) /*EOF on script */
92 inputBuffer[inputLength] = 0;
99 printf ("Press one of the letters in parentheses, then enter.\n");
100 printf ("(t)able, tr(a)nslated, (u)ntranslated, (r)un, (h)elp, (q)uit\n");
109 printf ("Command: ");
111 switch (inputBuffer[0])
118 printf ("Enter the name of a table or a list: ");
120 strcpy (table, inputBuffer);
121 validTable = lou_getTable (table);
122 if (validTable != NULL && validTable->hyphenStatesArray == 0)
124 printf ("No hyphenation table.\n");
128 while (validTable == NULL);
137 if (validTable == NULL)
139 printf ("You must enter a valid table name or list.\n");
144 printf ("Commands: action\n");
145 printf ("(t)able: Enter a table name or list\n");
146 printf ("(r)un: run the hyphenation test loop\n");
147 printf ("tr(a)nslated: translated input\n");
148 printf ("(u)ntranslated: untranslated input\n");
149 printf ("(h)elp: print this page\n");
150 printf ("(q)uit: leave the program\n");
157 printf ("Bad choice.\n");
161 while (inputBuffer[0] != 'r');
166 main (int argc, char **argv)
168 widechar inbuf[BUFSIZE];
169 char hyphens[BUFSIZE];
174 set_program_name (argv[0]);
176 while ((optc = getopt_long (argc, argv, "hv", longopts, NULL)) != -1)
179 /* --help and --version exit immediately, per GNU coding standards. */
181 version_etc (stdout, program_name, PACKAGE_NAME, VERSION, AUTHORS, (char *) NULL);
189 fprintf (stderr, "Try `%s --help' for more information.\n",
197 /* Print error message and exit. */
198 fprintf (stderr, "%s: extra operand: %s\n",
199 program_name, argv[optind]);
200 fprintf (stderr, "Try `%s --help' for more information.\n",
211 printf ("Type something, press enter, and view the results.\n");
212 printf ("A blank line returns to command entry.\n");
218 for (k = 0; k < inlen; k++)
219 inbuf[k] = inputBuffer[k];
220 if (!lou_hyphenate (table, inbuf, inlen, hyphens, mode))
222 printf ("Hyphenation error\n");
225 printf ("Hyphenation mask: %s\n", hyphens);
226 printf ("Hyphenated word: ");
227 for (k = 0; k < inlen; k++)
229 if (hyphens[k] == '1')
231 printf ("%c", inbuf[k]);