blob: 3bf062d5813e5453acdd3d6d0641c5f1cc667c1e [file] [log] [blame]
Eitan Isaacson109996e2008-12-20 14:52:53 +00001/* liblouis Braille Translation and Back-Translation Library
2
3 Based on BRLTTY, copyright (C) 1999-2006 by
4 The BRLTTY Team
5
Christian Egli08d96a72009-10-08 08:49:13 +00006 Copyright (C) 2004, 2005, 2006, 2009
7 ViewPlus Technologies, Inc. www.viewplus.com and
Eitan Isaacson109996e2008-12-20 14:52:53 +00008 JJB Software, Inc. www.jjb-software.com
9
Christian Egli08d96a72009-10-08 08:49:13 +000010 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
Eitan Isaacson109996e2008-12-20 14:52:53 +000020 You should have received a copy of the GNU General Public License
Christian Egli08d96a72009-10-08 08:49:13 +000021 along with this program. If not, see <http://www.gnu.org/licenses/>.
Eitan Isaacson109996e2008-12-20 14:52:53 +000022
Eitan Isaacson109996e2008-12-20 14:52:53 +000023 */
24
Christian Eglibe149002009-10-09 09:09:07 +000025#ifdef HAVE_CONFIG_H
26# include "config.h"
27#endif
28
Eitan Isaacson109996e2008-12-20 14:52:53 +000029#include <stdio.h>
30#include <string.h>
31#include <stdlib.h>
32#include "louis.h"
Christian Eglibe149002009-10-09 09:09:07 +000033#include <getopt.h>
34#include "progname.h"
35#include "version-etc.h"
36
37static const struct option longopts[] =
38{
39 { "help", no_argument, NULL, 'h' },
40 { "version", no_argument, NULL, 'v' },
41 { NULL, 0, NULL, 0 }
42};
43
44const char version_etc_copyright[] =
45 "Copyright %s %d ViewPlus Technologies, Inc. and JJB Software, Inc.";
46
47#define AUTHORS "John J. Boyer"
48
49static void
50print_help (void)
51{
52 printf ("\
Christian Eglibaefdb22012-12-19 09:48:54 +000053Usage: %s [OPTIONS] TABLE[,TABLE,...]\n", program_name);
Christian Eglibe149002009-10-09 09:09:07 +000054
55 fputs ("\
56Examine and debug Braille translation tables. This program allows you\n\
57to inspect liblouis translation tables and gather information about\n\
58them, such as forward and backward rules, characters and dot patterns,\n\
59specific opcodes, the size of a table, whether a hyphenation\n\
60table is used, how many passes the translation takes and much\n\
61more.\n\n", stdout);
62
63 fputs ("\
64 -h, --help display this help and exit\n\
65 -v, --version display version information and exit\n", stdout);
66
67 printf ("\n");
Christian Eglidc50af92012-09-27 13:10:51 +000068 printf ("Report bugs to %s.\n", PACKAGE_BUGREPORT);
69
70#ifdef PACKAGE_PACKAGER_BUG_REPORTS
71 printf ("Report %s bugs to: %s\n", PACKAGE_PACKAGER, PACKAGE_PACKAGER_BUG_REPORTS);
72#endif
73#ifdef PACKAGE_URL
74 printf ("%s home page: <%s>\n", PACKAGE_NAME, PACKAGE_URL);
75#endif
Christian Eglibe149002009-10-09 09:09:07 +000076}
77
Eitan Isaacson109996e2008-12-20 14:52:53 +000078#define BUFSIZE 256
79
John Boyer16689ac2009-01-12 15:11:39 +000080static const TranslationTableHeader *table;
Eitan Isaacson109996e2008-12-20 14:52:53 +000081static char inputBuffer[BUFSIZE];
82
83static int
Eitan Isaacson109996e2008-12-20 14:52:53 +000084getInput (void)
85{
John Boyer16689ac2009-01-12 15:11:39 +000086 int inputLength;
87 inputBuffer[0] = 0;
Eitan Isaacson109996e2008-12-20 14:52:53 +000088 fgets (inputBuffer, sizeof (inputBuffer), stdin);
John Boyer16689ac2009-01-12 15:11:39 +000089 inputLength = strlen (inputBuffer) - 1;
90 if (inputLength < 0) /*EOF on script */
91 exit (0);
92 inputBuffer[inputLength] = 0;
93 return inputLength;
Eitan Isaacson109996e2008-12-20 14:52:53 +000094}
95
96static int
John Boyer16689ac2009-01-12 15:11:39 +000097printRule (TranslationTableRule * thisRule, int mode)
98{
99 printf ("Rule: ");
100 printf ("opcode=%s, ", findOpcodeName (thisRule->opcode));
101 if (thisRule->before)
102 printf ("before=%x, ", thisRule->before);
103 if (thisRule->after)
104 printf ("after=%x, ", thisRule->after);
105 switch (thisRule->opcode)
106 {
107 case CTO_Context:
108 case CTO_Correct:
109 case CTO_SwapCd:
110 case CTO_SwapDd:
111 case CTO_Pass2:
112 case CTO_Pass3:
113 case CTO_Pass4:
114 printf ("code=%s ", showString (thisRule->charsdots, thisRule->charslen
115 + thisRule->dotslen));
116 break;
117 default:
118 if (mode == 0)
119 {
120 printf ("chars=%s, ", showString (thisRule->charsdots,
121 thisRule->charslen));
122 printf ("dots=%s, ",
123 showDots (&thisRule->charsdots[thisRule->charslen],
124 thisRule->dotslen));
125 }
126 else
127 {
128 printf ("dots=%s, ",
129 showDots (&thisRule->charsdots[thisRule->charslen],
130 thisRule->dotslen));
131 printf ("chars=%s, ", showString (thisRule->charsdots,
132 thisRule->charslen));
133 }
134 break;
135 }
136 return 1;
137}
138
139static int
140printCharacter (TranslationTableCharacter * thisChar, int mode)
141{
142 TranslationTableRule *thisRule;
143 TranslationTableOffset nextRule;
144 if (mode == 0)
145 {
146 printf ("Char: ");
147 printf ("real=%s, ", showString (&thisChar->realchar, 1));
148 printf ("upper=%s, ", showString (&thisChar->uppercase, 1));
149 printf ("lower=%s, ", showString (&thisChar->lowercase, 1));
150 }
151 else
152 printf ("Dots: real=%s, ", showDots (&thisChar->realchar, 1));
153 printf ("attr=%s, ", showAttributes (thisChar->attributes));
154 nextRule = thisChar->otherRules;
155 while (nextRule)
156 {
157 thisRule = (TranslationTableRule *) & table->ruleArea[nextRule];
John Boyerc675d7a2009-01-15 14:32:20 +0000158 if (nextRule == thisChar->definitionRule)
John Boyer16689ac2009-01-12 15:11:39 +0000159 printf ("definition ");
160 printRule (thisRule, mode);
161 printf ("\n");
162 if (mode == 0)
163 nextRule = thisRule->charsnext;
164 else
165 nextRule = thisRule->dotsnext;
166 }
167 return 1;
168}
169
170static int
171show_characters (int startHash)
172{
173 int k;
174 TranslationTableCharacter *thisChar;
175 TranslationTableOffset nextChar;
176 printf ("Press enter for next or (e)xit, next-(h)ash, then enter\n");
177 if (startHash < 0)
178 k = 0;
179 else
180 k = startHash;
181 for (; k < HASHNUM; k++)
182 if (table->characters[k])
183 {
184 printf ("Hash=%d\n", k);
185 nextChar = table->characters[k];
186 while (nextChar)
187 {
188 thisChar =
189 (TranslationTableCharacter *) & table->ruleArea[nextChar];
190 printCharacter (thisChar, 0);
191 printf ("=> ");
192 getInput ();
193 if (*inputBuffer == 'h')
194 break;
195 if (*inputBuffer == 'e')
196 return 1;
197 nextChar = thisChar->next;
198 }
199 }
200 return 1;
201}
202
203static int
204show_dots (int startHash)
205{
206 int k;
207 TranslationTableCharacter *thisDots;
208 TranslationTableOffset nextDots;
209 printf ("Press enter for next or (e)xit, next-(h)ash, then enter\n");
210 if (startHash < 0)
211 k = 0;
212 else
213 k = startHash;
214 for (; k < HASHNUM; k++)
215 if (table->dots[k])
216 {
217 printf ("Hash=%d\n", k);
218 nextDots = table->dots[k];
219 while (nextDots)
220 {
221 thisDots =
222 (TranslationTableCharacter *) & table->ruleArea[nextDots];
223 printCharacter (thisDots, 1);
224 printf ("=> ");
225 getInput ();
226 if (*inputBuffer == 'h')
227 break;
228 if (*inputBuffer == 'e')
229 return 1;
230 nextDots = thisDots->next;
231 }
232 }
233 return 1;
234}
235
236static int
237show_forRules (int startHash)
238{
239 int k;
240 TranslationTableRule *thisRule;
241 TranslationTableOffset nextRule;
242 printf ("Press enter for next or (e)xit, next-(h)ash, then enter\n");
243 if (startHash < 0)
244 k = 0;
245 else
246 k = startHash;
247 for (; k < HASHNUM; k++)
248 if (table->forRules[k])
249 {
250 printf ("Hash=%d\n", k);
251 nextRule = table->forRules[k];
252 while (nextRule)
253 {
254 thisRule = (TranslationTableRule *) & table->ruleArea[nextRule];
255 printRule (thisRule, 0);
256 printf ("=> ");
257 getInput ();
258 if (*inputBuffer == 'h')
259 break;
260 if (*inputBuffer == 'e')
261 return 1;
262 nextRule = thisRule->charsnext;
263 }
264 }
265 return 1;
266}
267
268static int
269show_backRules (int startHash)
270{
271 int k;
272 TranslationTableRule *thisRule;
273 TranslationTableOffset nextRule;
274 printf ("Press enter for next or (e)xit, next-(h)ash, then enter\n");
275 if (startHash < 0)
276 k = 0;
277 else
278 k = startHash;
279 for (; k < HASHNUM; k++)
280 if (table->backRules[k])
281 {
282 printf ("Hash=%d\n", k);
283 nextRule = table->backRules[k];
284 while (nextRule)
285 {
286 thisRule = (TranslationTableRule *) & table->ruleArea[nextRule];
287 printRule (thisRule, 1);
288 printf ("=> ");
289 getInput ();
290 if (*inputBuffer == 'h')
291 break;
292 if (*inputBuffer == 'e')
293 return 1;
294 nextRule = thisRule->dotsnext;
295 }
296 }
297 return 1;
298}
299
300static int
301print_brailleIndicator (TranslationTableOffset offset, char *opcode)
302{
303 TranslationTableRule *thisRule;
304 if (!offset)
305 return 0;
306 thisRule = (TranslationTableRule *) & table->ruleArea[offset];
307 printf ("%s %s\n", opcode,
308 showDots (&thisRule->charsdots[0], thisRule->dotslen));
309 return 1;
310}
311
312static int
313print_phraseLength (TranslationTableOffset offset, char *opcode)
314{
315 if (!offset)
316 return 0;
317 printf ("%s %d\n", opcode, offset);
Christian Eglifbfea8b2009-08-11 11:24:40 +0000318 return 1;
John Boyer16689ac2009-01-12 15:11:39 +0000319}
320
321static int
322show_brailleIndicators (void)
323{
324 print_brailleIndicator (table->capitalSign, "capsign");
325 print_brailleIndicator (table->beginCapitalSign, "begcaps");
326 print_phraseLength (table->lenBeginCaps, "lenbegcaps");
327 print_brailleIndicator (table->endCapitalSign, "endcaps");
328 print_brailleIndicator (table->firstWordCaps, "firstwordcaps");
329 print_brailleIndicator (table->lastWordCapsAfter, "lastwordaftercaps");
330 print_phraseLength (table->lenCapsPhrase, "lencapsphrase");
331 print_brailleIndicator (table->letterSign, "letsign");
332 print_brailleIndicator (table->numberSign, "numsign");
333 print_brailleIndicator (table->firstWordItal, "firstwordital");
334 print_brailleIndicator (table->lastWordItalBefore, "lastworditalbefore");
335 print_brailleIndicator (table->lastWordItalAfter, "lastworditalafter");
336 print_brailleIndicator (table->firstLetterItal, "firstletterital");
337 print_brailleIndicator (table->lastLetterItal, "lastletterital");
338 print_brailleIndicator (table->singleLetterItal, "singleletterital");
339 print_brailleIndicator (table->italWord, "italword");
340 print_phraseLength (table->lenItalPhrase, "lenitalphrase");
341 print_brailleIndicator (table->firstWordBold, "firstwordbold");
342 print_brailleIndicator (table->lastWordBoldBefore, "lastwordboldbefore");
343 print_brailleIndicator (table->lastWordBoldAfter, "lastwordboldafter");
344 print_brailleIndicator (table->firstLetterBold, "firstletterbold");
345 print_brailleIndicator (table->lastLetterBold, "lastletterbold");
346 print_brailleIndicator (table->singleLetterBold, "singleletterbold");
347 print_brailleIndicator (table->boldWord, "boldword");
348 print_phraseLength (table->lenBoldPhrase, "lenboldphrase");
349 print_brailleIndicator (table->firstWordUnder, "firstwordunder");
350 print_brailleIndicator (table->lastWordUnderBefore, "lastwordunderbefore");
351 print_brailleIndicator (table->lastWordUnderAfter, "lastwordunderafter");
352 print_brailleIndicator (table->firstLetterUnder, "firstletterunder");
353 print_brailleIndicator (table->lastLetterUnder, "lastletterunder");
354 print_brailleIndicator (table->singleLetterUnder, "singleletterunder");
355 print_brailleIndicator (table->underWord, "underword");
356 print_phraseLength (table->lenUnderPhrase, "lenunderphrase");
357 print_brailleIndicator (table->begComp, "begcomp");
358 print_brailleIndicator (table->compBegEmph1, "compbegemph1");
359 print_brailleIndicator (table->compEndEmph1, "compendemph1");
360 print_brailleIndicator (table->compBegEmph2, "compbegemph2");
361 print_brailleIndicator (table->compEndEmph2, "compendemph2");
362 print_brailleIndicator (table->compBegEmph3, "compbegemph3");
363 print_brailleIndicator (table->compEndEmph3, "compendemph3");
364 print_brailleIndicator (table->compCapSign, "compcapsign");
365 print_brailleIndicator (table->compBegCaps, "compbegcaps");
366 print_brailleIndicator (table->compEndCaps, "compendcaps");
367 print_brailleIndicator (table->endComp, "endcomp");
368 return 1;
369}
370
371static char *
372pickYN (int a)
373{
374 if (!a)
375 return "no";
376 return "yes";
377}
378
379static int
380show_misc (void)
381{
382 printf ("Table size: %d\n", table->tableSize);
383 printf ("Bytes used: %d\n", table->bytesUsed);
384 printf ("Number of passes: %d\n", table->numPasses);
Christian Egli5e8c3892009-01-15 16:30:59 +0000385 printf ("'correct' opcodes: %s\n", pickYN (table->corrections));
John Boyer16689ac2009-01-12 15:11:39 +0000386 printf ("'syllable' opcodes: %s\n", pickYN (table->syllables));
387 printf ("'capsnocont' opcode: %s\n", pickYN (table->capsNoCont));
388 printf ("Hyphenation table: %s\n", pickYN (table->hyphenStatesArray));
389 printf ("noletsignbefore %s\n", showString (&table->noLetsignBefore[0],
390 table->noLetsignBeforeCount));
391 printf ("noletsign %s\n", showString (&table->noLetsign[0],
392 table->noLetsignCount));
393 printf ("noletsignafter %s\n", showString (&table->noLetsignAfter[0],
394 table->noLetsignAfterCount));
Christian Eglifbfea8b2009-08-11 11:24:40 +0000395 return 1;
John Boyer16689ac2009-01-12 15:11:39 +0000396}
397
398static int
399show_charMap (int startHash)
400{
401 int k;
402 CharOrDots *thisChar;
403 TranslationTableOffset nextChar;
404 printf ("Press enter for next or (e)xit, next-(h)ash, then enter\n");
405 if (startHash < 0)
406 k = 0;
407 else
408 k = startHash;
409 for (; k < HASHNUM; k++)
410 if (table->charToDots[k])
411 {
412 printf ("Hash=%d\n", k);
413 nextChar = table->charToDots[k];
414 while (nextChar)
415 {
416 thisChar = (CharOrDots *) & table->ruleArea[nextChar];
417 printf ("Char: %s ", showString (&thisChar->lookFor, 1));
418 printf ("dots=%s\n", showDots (&thisChar->found, 1));
419 printf ("=> ");
420 getInput ();
421 if (*inputBuffer == 'h')
422 break;
423 if (*inputBuffer == 'e')
424 return 1;
425 nextChar = thisChar->next;
426 }
427 }
428 return 1;
429}
430
431static int
432show_dotsMap (int startHash)
433{
434 int k;
435 CharOrDots *thisDots;
436 TranslationTableOffset nextDots;
437 printf ("Press enter for next or (e)xit, next-(h)ash, then enter\n");
438 if (startHash < 0)
439 k = 0;
440 else
441 k = startHash;
442 for (; k < HASHNUM; k++)
443 if (table->dotsToChar[k])
444 {
445 printf ("Hash=%d\n", k);
446 nextDots = table->dotsToChar[k];
447 while (nextDots)
448 {
449 thisDots = (CharOrDots *) & table->ruleArea[nextDots];
450 printf ("Dots: %s ", showDots (&thisDots->lookFor, 1));
451 printf ("char=%s\n", showString (&thisDots->found, 1));
452 printf ("=> ");
453 getInput ();
454 if (*inputBuffer == 'h')
455 break;
456 if (*inputBuffer == 'e')
457 return 1;
458 nextDots = thisDots->next;
459 }
460 }
461 return 1;
462}
463
464static int
465show_compDots (int startChar)
466{
467 widechar k;
468 printf ("Press enter for next or (e)xit, next-(h)ash, then enter\n");
469 if (startChar < 0)
470 k = 0;
471 else
472 k = startChar;
473 for (; k < 256; k++)
474 if (table->compdotsPattern[k])
475 {
476 TranslationTableRule *thisRule = (TranslationTableRule *)
477 & table->ruleArea[table->compdotsPattern[k]];
478 printf ("Char: %s ", showString (&k, 1));
479 printf ("dots=%s\n",
480 showDots (&thisRule->charsdots[1], thisRule->dotslen));
481 printf ("=> ");
482 getInput ();
483 if (*inputBuffer == 'e')
484 return 1;
485 }
486 return 1;
487}
488
489static void
490part_paramLetters ()
491{
492 printf ("show particular hash chains.\n");
493 printf
494 ("show-(f)orward-rules, show-(b)ackward-rules, show-(c)haracters, \n");
495 printf ("show-(d)ot-patterns, show-(C)har-to-dots, show-(D)ots-tochar\n");
496 printf ("(z)-compdots, (h)elp, e(x)it\n");
497}
498
499static void
500particularHelp (void)
501{
502 part_paramLetters ();
503}
504
505static int
506particular (void)
507{
508 int startHash;
509 widechar parsed[BUFSIZE];
510 part_paramLetters ();
511 do
512 {
513 printf ("particular: ");
514 getInput ();
515 switch (inputBuffer[0])
516 {
517 case 0:
518 break;
519 case 'h':
520 particularHelp ();
521 break;
522 case 'c':
523 printf ("-> ");
524 getInput ();
525 if (!extParseChars (inputBuffer, parsed))
526 break;
527 startHash = charHash (*parsed);
528 if (table->characters[startHash] == 0)
529 {
530 printf ("Character not in table.\n");
531 break;
532 }
533 show_characters (startHash);
534 break;
535 case 'd':
536 printf ("-> ");
537 getInput ();
538 if (!extParseDots (inputBuffer, parsed))
539 break;
540 startHash = charHash (*parsed);
541 if (table->dots[startHash] == 0)
542 {
543 printf ("Dot pattern not in table.\n");
544 break;
545 }
546 show_dots (startHash);
547 break;
548 case 'C':
549 printf ("-> ");
550 getInput ();
551 if (!extParseChars (inputBuffer, parsed))
552 break;
553 startHash = charHash (*parsed);
554 if (table->charToDots[startHash] == 0)
555 {
556 printf ("Character not in table.\n");
557 break;
558 }
559 show_charMap (startHash);
560 break;
561 case 'D':
562 printf ("-> ");
563 getInput ();
564 if (!extParseDots (inputBuffer, parsed))
565 break;
566 startHash = charHash (*parsed);
567 if (table->dotsToChar[startHash] == 0)
568 {
569 printf ("Dot pattern not in table.\n");
570 break;
571 }
572 show_dotsMap (startHash);
573 break;
574 case 'f':
575 printf ("-> ");
576 getInput ();
577 if (!extParseChars (inputBuffer, parsed))
578 break;
579 startHash = stringHash (parsed);
580 if (table->forRules[startHash] == 0)
581 {
582 printf ("Character string not in table.\n");
583 break;
584 }
585 show_forRules (startHash);
586 break;
587 case 'b':
588 printf ("-> ");
589 getInput ();
590 if (!extParseDots (inputBuffer, parsed))
591 break;
592 startHash = stringHash (parsed);
593 if (table->backRules[startHash] == 0)
594 {
595 printf ("Dot pattern not in table.\n");
596 break;
597 }
598 show_backRules (startHash);
599 break;
600 case 'z':
601 printf ("-> ");
602 getInput ();
603 if (!extParseChars (inputBuffer, parsed))
604 break;
605 startHash = charHash (*parsed);
606 if (*parsed > 255 || table->compdotsPattern[startHash] == 0)
607 {
608 printf ("Character not in table.\n");
609 break;
610 }
611 show_compDots (startHash);
612 break;
613 case 'x':
614 return 1;
615 default:
616 printf ("Bad choice.\n");
617 break;
618 }
619 }
620 while (inputBuffer[0] != 'x');
621 return 1;
622}
623
Eitan Isaacson109996e2008-12-20 14:52:53 +0000624static void
625paramLetters (void)
626{
John Boyer16689ac2009-01-12 15:11:39 +0000627 printf ("Press one of the letters in parentheses, then enter.\n");
628 printf
629 ("show-(f)orward-rules, show-(b)ackward-rules, show-(c)haracters, \n");
630 printf ("show-(d)ot-patterns, show-(C)har-to-dots, show-(D)ots-tochar\n");
631 printf ("show-(m)isc, show-(z)-compdots\n");
632 printf ("show-(p)articulars, (h)elp, (q)uit\n");
633}
634
635static void
636commandHelp (void)
637{
638 paramLetters ();
Eitan Isaacson109996e2008-12-20 14:52:53 +0000639}
640
641static int
642getCommands (void)
643{
644 paramLetters ();
645 do
646 {
647 printf ("Command: ");
648 getInput ();
649 switch (inputBuffer[0])
650 {
651 case 0:
652 break;
John Boyer16689ac2009-01-12 15:11:39 +0000653 case 'h':
654 commandHelp ();
655 break;
656 case 'C':
657 show_charMap (-1);
658 break;
659 case 'D':
660 show_dotsMap (-1);
661 break;
662 case 'z':
663 show_compDots (-1);
664 break;
665 case 'c':
666 show_characters (-1);
667 break;
668 case 'd':
669 show_dots (-1);
670 break;
671 case 'f':
672 show_forRules (-1);
673 break;
674 case 'b':
675 show_backRules (-1);
676 break;
677 case 'i':
678 show_brailleIndicators ();
679 break;
680 case 'm':
681 show_misc ();
682 break;
683 case 'p':
684 particular ();
685 break;
686 case 'q':
687 return 1;
Eitan Isaacson109996e2008-12-20 14:52:53 +0000688 default:
689 printf ("Bad choice.\n");
690 break;
691 }
692 }
John Boyer16689ac2009-01-12 15:11:39 +0000693 while (inputBuffer[0] != 'q');
Eitan Isaacson109996e2008-12-20 14:52:53 +0000694 return 1;
695}
696
697int
698main (int argc, char **argv)
699{
Christian Eglibe149002009-10-09 09:09:07 +0000700 int optc;
701
702 set_program_name (argv[0]);
703
704 while ((optc = getopt_long (argc, argv, "hv", longopts, NULL)) != -1)
705 switch (optc)
706 {
707 /* --help and --version exit immediately, per GNU coding standards. */
708 case 'v':
709 version_etc (stdout, program_name, PACKAGE_NAME, VERSION, AUTHORS, (char *) NULL);
710 exit (EXIT_SUCCESS);
711 break;
712 case 'h':
713 print_help ();
714 exit (EXIT_SUCCESS);
715 break;
716 default:
717 fprintf (stderr, "Try `%s --help' for more information.\n",
718 program_name);
719 exit (EXIT_FAILURE);
720 break;
721 }
722
723 if (optind != argc - 1)
Eitan Isaacson109996e2008-12-20 14:52:53 +0000724 {
Christian Eglibe149002009-10-09 09:09:07 +0000725 /* Print error message and exit. */
726 if (optind < argc - 1)
727 fprintf (stderr, "%s: extra operand: %s\n",
728 program_name, argv[optind + 1]);
729 else
730 fprintf (stderr, "%s: no table specified\n",
731 program_name);
732 fprintf (stderr, "Try `%s --help' for more information.\n",
733 program_name);
734 exit (EXIT_FAILURE);
Eitan Isaacson109996e2008-12-20 14:52:53 +0000735 }
Christian Eglibe149002009-10-09 09:09:07 +0000736
737 if (!(table = lou_getTable (argv[optind])))
John Boyer16689ac2009-01-12 15:11:39 +0000738 {
739 lou_free ();
Christian Eglibe149002009-10-09 09:09:07 +0000740 exit (EXIT_FAILURE);
John Boyer16689ac2009-01-12 15:11:39 +0000741 }
742 getCommands ();
Eitan Isaacson109996e2008-12-20 14:52:53 +0000743 lou_free ();
Christian Eglibe149002009-10-09 09:09:07 +0000744 exit (EXIT_SUCCESS);
Eitan Isaacson109996e2008-12-20 14:52:53 +0000745}