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("Errors, warnings, ... are sent to stdout\n");
53 void default_cb(Gedcom_elt elt UNUSED, Gedcom_ctxt ctxt UNUSED,
54 int level UNUSED, char *tag UNUSED,
55 char *raw_value UNUSED, int tag_value UNUSED)
60 void gedcom_message_handler(Gedcom_msg_type type UNUSED, char *msg)
62 char *converted = NULL;
64 converted = convert_utf8_to_locale(msg, &conv_fails);
65 printf("%s\n", converted);
68 int main(int argc, char* argv[])
70 Gedcom_err_mech mech = DEFER_FAIL;
71 int compat_enabled = 0;
72 char* file_name = NULL;
77 for (i=1; i<argc; i++) {
78 if (!strncmp(argv[i], "-c", 3))
80 else if (!strncmp(argv[i], "-h", 3)) {
84 else if (strncmp(argv[i], "-", 1)) {
89 printf ("Unrecognized option: %s\n", argv[i]);
97 printf("No file name given\n");
103 setlocale(LC_ALL, "");
104 gedcom_set_compat_handling(compat_enabled);
105 gedcom_set_error_handling(mech);
106 gedcom_set_message_handler(gedcom_message_handler);
107 gedcom_set_default_callback(default_cb);
109 result = gedcom_parse_file(file_name);
112 printf(_("Parse succeeded\n"));
115 printf(_("Parse failed\n"));