~mshinke/nvdajp/MiscellaneousDependencies

« back to all changes in this revision

Viewing changes to include/liblouis/tools/lou_debug.c

  • Committer: Masataka Shinke
  • Date: 2012-01-12 20:01:32 UTC
  • mfrom: (26.1.42 miscdep)
  • Revision ID: mshinke@users.sourceforge.jp-20120112200132-fvksmjulcjdzu5mk
mergedĀ lp:~nishimotz/nvdajp/MiscellaneousDependenciesĀ 68

Show diffs side-by-side

added added

removed removed

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