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

« back to all changes in this revision

Viewing changes to tools/lou_checktable.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
Test a Braille translation table. If the table contains errors,\n\
 
58
appropriate messages are displayed. If there are no errors the\n\
 
59
message \"no errors found.\" is shown.\n", stdout);
 
60
 
 
61
  fputs ("\
 
62
  -h, --help          display this help and exit\n\
 
63
  -v, --version       display version information and exit\n", stdout);
 
64
 
 
65
  printf ("\n");
 
66
  printf ("\
 
67
Report bugs to <%s>.\n", PACKAGE_BUGREPORT);
 
68
}
42
69
 
43
70
int
44
71
main (int argc, char **argv)
45
72
{
46
73
  const TranslationTableHeader *table;
47
 
  if (argc != 2)
 
74
  int optc;
 
75
 
 
76
  set_program_name (argv[0]);
 
77
 
 
78
  while ((optc = getopt_long (argc, argv, "hv", longopts, NULL)) != -1)
 
79
    switch (optc)
 
80
      {
 
81
      /* --help and --version exit immediately, per GNU coding standards.  */
 
82
      case 'v':
 
83
        version_etc (stdout, program_name, PACKAGE_NAME, VERSION, AUTHORS, (char *) NULL);
 
84
        exit (EXIT_SUCCESS);
 
85
        break;
 
86
      case 'h':
 
87
        print_help ();
 
88
        exit (EXIT_SUCCESS);
 
89
        break;
 
90
      default:
 
91
        fprintf (stderr, "Try `%s --help' for more information.\n",
 
92
                 program_name);
 
93
        exit (EXIT_FAILURE);
 
94
        break;
 
95
      }
 
96
 
 
97
  if (optind != argc - 1)
48
98
    {
49
 
      fprintf (stderr, "Usage: lou_checktable tablename\n");
50
 
      exit (1);
 
99
      /* Print error message and exit.  */
 
100
      if (optind < argc - 1)
 
101
        fprintf (stderr, "%s: extra operand: %s\n",
 
102
                 program_name, argv[optind + 1]);
 
103
      else
 
104
        fprintf (stderr, "%s: no table specified\n", 
 
105
                 program_name);
 
106
      fprintf (stderr, "Try `%s --help' for more information.\n",
 
107
               program_name);
 
108
      exit (EXIT_FAILURE);
51
109
    }
52
 
  if (!(table = lou_getTable (argv[1])))
 
110
 
 
111
  if (!(table = lou_getTable (argv[optind])))
53
112
    {
54
113
      lou_free ();
55
 
      return 1;
 
114
      exit (EXIT_FAILURE);
56
115
    }
57
116
  fprintf (stderr, "No errors found.\n");
58
117
  lou_free ();
59
 
  return 0;
 
118
  exit (EXIT_SUCCESS);
60
119
}
 
120