1 /* Check program using the Gedcom library.
2 Copyright (C) 2001, 2002 The Genes Development Team
3 This file is part of the Gedcom parser library.
4 Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2001.
6 The Gedcom parser library is free software; you can redistribute it
7 and/or modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The Gedcom parser library is distributed in the hope that it will be
12 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the Gedcom parser library; if not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
25 #include "utf8tools.h"
34 #define _(string) dgettext(PACKAGE, string)
35 #define N_(string) (string)
38 #define UNUSED __attribute__((unused))
45 printf("Checks a GEDCOM file on standards compliancy\n\n");
46 printf("Usage: gedcom-check [options] file\n");
48 printf(" -h Show this help text\n");
49 printf(" -c Enable compatibility mode\n");
50 printf(" -dg Debug setting: only libgedcom debug messages\n");
51 printf(" -da Debug setting: libgedcom + yacc debug messages\n");
52 printf("Errors, warnings, ... are sent to stdout\n");
55 void default_cb(Gedcom_elt elt UNUSED, Gedcom_ctxt ctxt UNUSED,
56 int level UNUSED, char *tag UNUSED,
57 char *raw_value UNUSED, int tag_value UNUSED)
62 void gedcom_message_handler(Gedcom_msg_type type UNUSED, char *msg)
64 char *converted = NULL;
66 converted = convert_utf8_to_locale(msg, &conv_fails);
67 printf("%s\n", converted);
70 int main(int argc, char* argv[])
72 Gedcom_err_mech mech = DEFER_FAIL;
73 int compat_enabled = 0;
75 char* file_name = NULL;
80 for (i=1; i<argc; i++) {
81 if (!strncmp(argv[i], "-da", 4))
83 else if (!strncmp(argv[i], "-dg", 4))
85 else if (!strncmp(argv[i], "-c", 3))
87 else if (!strncmp(argv[i], "-h", 3)) {
91 else if (strncmp(argv[i], "-", 1)) {
96 printf ("Unrecognized option: %s\n", argv[i]);
104 printf("No file name given\n");
110 setlocale(LC_ALL, "");
111 gedcom_set_debug_level(debug_level, NULL);
112 gedcom_set_compat_handling(compat_enabled);
113 gedcom_set_compat_options(COMPAT_ALLOW_OUT_OF_CONTEXT);
114 gedcom_set_error_handling(mech);
115 gedcom_set_message_handler(gedcom_message_handler);
116 gedcom_set_default_callback(default_cb);
118 result = gedcom_parse_file(file_name);
121 printf(_("Parse succeeded\n"));
124 printf(_("Parse failed\n"));
125 if (!compat_enabled) {
126 printf(_(" Note: Compatibility mode was not enabled\n"));
127 printf(_(" You could try the check again using the '-c' option\n"));