1 /* PSPP - computes sample statistics.
2 Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
3 Written by Ben Pfaff <blp@gnu.org>.
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 #include <libpspp/message.h>
28 #include <libpspp/alloc.h>
29 #include <libpspp/version.h>
32 #include "xvasprintf.h"
34 /* Current command name as set by msg_set_command_name(). */
35 static char *command_name;
37 /* Message handler as set by msg_init(). */
38 static void (*msg_handler) (const struct msg *);
40 /* Public functions. */
42 /* Writes error message in CLASS, with text FORMAT, formatted with
43 printf, to the standard places. */
45 msg (enum msg_class class, const char *format, ...)
50 m.category = msg_class_to_category (class);
51 m.severity = msg_class_to_severity (class);
52 msg_location (&m.where);
53 va_start (args, format);
54 m.text = xvasprintf (format, args);
61 msg_init (void (*handler) (const struct msg *))
63 msg_handler = handler;
71 /* Emits M as an error message.
72 Frees allocated data in M. */
74 msg_emit (struct msg *m)
80 /* Private functions. */
82 /* Sets COMMAND_NAME as the command name included in some kinds
85 msg_set_command_name (const char *command_name_)
88 command_name = command_name_ ? xstrdup (command_name_) : NULL;
91 /* Returns the current command name, or NULL if none. */
93 msg_get_command_name (void)
99 request_bug_report_and_abort(const char *msg )
102 "******************************************************************\n"
103 "You have discovered a bug in PSPP.\n\n"
104 " Please report this, by sending "
105 "an email to " PACKAGE_BUGREPORT ",\n"
106 "explaining what you were doing when this happened, and including\n"
107 "a sample of your input file which caused it.\n");
110 "Also, please copy the following lines into your bug report:\n\n"
116 "default_config_path: %s\n"
118 "groff_font_path: %s\n"
120 "compiler version: %s\n"
140 fprintf(stderr,"Diagnosis: %s\n",msg);
143 "******************************************************************\n");
149 msg_assert_fail(const char *expr, const char *file, int line)
152 snprintf(msg,256,"Assertion failed: %s:%d; (%s)",file,line,expr);
153 request_bug_report_and_abort( msg );