~ubuntu-branches/debian/jessie/liblouis/jessie

« back to all changes in this revision

Viewing changes to tools/lou_debug.c

  • Committer: Bazaar Package Importer
  • Author(s): Samuel Thibault
  • Date: 2010-01-12 23:48:47 UTC
  • mto: (1.1.4 upstream) (5.2.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20100112234847-ph9xdk3lrjdox6ks
ImportĀ upstreamĀ versionĀ 1.8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
   Based on BRLTTY, copyright (C) 1999-2006 by
4
4
   The BRLTTY Team
5
5
 
6
 
   Copyright (C) 2004, 2005, 2006
7
 
   ViewPlus Technologies, Inc. www.viewplus.com
8
 
   and
 
6
   Copyright (C) 2004, 2005, 2006, 2009
 
7
   ViewPlus Technologies, Inc. www.viewplus.com and
9
8
   JJB Software, Inc. www.jjb-software.com
10
9
 
11
 
   This file is free software; you can redistribute it and/or modify it
12
 
   under the terms of the GNU General Public License as published by the
13
 
   Free Software Foundation; either version 2, or (at your option) any
14
 
   later version.
15
 
 
16
 
   In addition to the permissions in the GNU General Public License, the
17
 
   copyright holders give you unlimited permission to link the
18
 
   compiled version of this file into combinations with other programs,
19
 
   and to distribute those combinations without any restriction coming
20
 
   from the use of this file.  (The General Public License restrictions
21
 
   do apply in other respects; for example, they cover modification of
22
 
   the file, and distribution when not linked into a combine
23
 
   executable.)
24
 
 
25
 
   This file is distributed in the hope that it will be useful, but
26
 
   WITHOUT ANY WARRANTY; without even the implied warranty of
27
 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
28
 
   General Public License for more details.
29
 
 
 
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
   
30
20
   You should have received a copy of the GNU General Public License
31
 
   along with this program; see the file COPYING.  If not, write to
32
 
   the Free Software Foundation, 51 Franklin Street, Fifth Floor,
33
 
   Boston, MA 02110-1301, USA.
 
21
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
34
22
 
35
23
   Maintained by John J. Boyer john.boyer@jjb-software.com
36
24
   */
37
25
 
 
26
#ifdef HAVE_CONFIG_H
 
27
# include "config.h"
 
28
#endif
 
29
 
38
30
#include <stdio.h>
39
31
#include <string.h>
40
32
#include <stdlib.h>
41
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
 
42
73
#define BUFSIZE 256
43
74
 
44
75
static const TranslationTableHeader *table;
661
692
int
662
693
main (int argc, char **argv)
663
694
{
664
 
  if (argc != 2)
 
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)
665
719
    {
666
 
      fprintf (stderr, "Usage: lou_debug tablename\n");
667
 
      exit (1);
 
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);
668
730
    }
669
 
  if (!(table = lou_getTable (argv[1])))
 
731
 
 
732
  if (!(table = lou_getTable (argv[optind])))
670
733
    {
671
734
      lou_free ();
672
 
      return 1;
 
735
      exit (EXIT_FAILURE);
673
736
    }
674
737
  getCommands ();
675
738
  lou_free ();
676
 
  return 0;
 
739
  exit (EXIT_SUCCESS);
677
740
}