1 /* Implementation of the messaging API to applications.
2 Copyright (C) 2001 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
24 #include "gedcom_internal.h"
28 void cleanup_mess_buffer();
30 struct safe_buffer mess_buffer = { NULL, 0, NULL, 0, cleanup_mess_buffer };
31 Gedcom_msg_handler msg_handler = NULL;
33 void gedcom_set_message_handler(Gedcom_msg_handler func)
38 void cleanup_mess_buffer()
40 cleanup_buffer(&mess_buffer);
43 int gedcom_message(const char* s, ...)
49 reset_buffer(&mess_buffer);
50 res = safe_buf_vappend(&mess_buffer, s, ap);
53 (*msg_handler)(MESSAGE, get_buf_string(&mess_buffer));
57 int gedcom_warning(const char* s, ...)
62 reset_buffer(&mess_buffer);
64 safe_buf_append(&mess_buffer, _("Warning on line %d: "), line_no);
66 safe_buf_append(&mess_buffer, _("Warning: "));
68 res = safe_buf_vappend(&mess_buffer, s, ap);
71 (*msg_handler)(WARNING, get_buf_string(&mess_buffer));
76 int gedcom_error(const char* s, ...)
81 reset_buffer(&mess_buffer);
83 safe_buf_append(&mess_buffer, _("Error on line %d: "), line_no);
85 safe_buf_append(&mess_buffer, _("Error: "));
87 res = safe_buf_vappend(&mess_buffer, s, ap);
90 (*msg_handler)(ERROR, get_buf_string(&mess_buffer));
95 void gedcom_mem_error(const char *filename, int line)
97 gedcom_error(_("Could not allocate memory at %s, %d"), filename, line);