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
27 /* Message classes. */
30 ME, MW, MN, /* General error/warning/note. */
31 SE, SW, SN, /* Script error/warning/note. */
32 DE, DW, DN, /* Data-file error/note. */
36 /* What kind of message is this? */
39 MSG_GENERAL, /* General info. */
40 MSG_SYNTAX, /* Messages that relate to syntax files. */
41 MSG_DATA /* Messages that relate to data files. */
44 /* How important a condition is it? */
52 static inline enum msg_category
53 msg_class_to_category (enum msg_class class)
58 static inline enum msg_severity
59 msg_class_to_severity (enum msg_class class)
64 static inline enum msg_class
65 msg_class_from_category_and_severity (enum msg_category category,
66 enum msg_severity severity)
68 return category * 3 + severity;
71 /* A file location. */
74 const char *file_name; /* File name. */
75 int line_number; /* Line number. */
78 /* An error message. */
81 enum msg_category category; /* Message category. */
82 enum msg_severity severity; /* Message severity. */
83 struct file_locator where; /* File location, or (NULL, -1). */
84 const char *title; /* Special text inserted if not null. */
87 /* Number of errors, warnings reported. */
88 extern int err_error_count;
89 extern int err_warning_count;
91 /* If number of allowable errors/warnings is exceeded, then a message
92 is displayed and this flag is set to suppress subsequent
94 extern int err_already_flagged;
96 /* Nonnegative verbosity level. Higher value == more verbose. */
97 extern int err_verbosity;
100 void msg (enum msg_class, const char *format, ...)
101 PRINTF_FORMAT (2, 3);
102 void tmsg (enum msg_class, const char *title, const char *format, ...)
103 PRINTF_FORMAT (3, 4);
105 void verbose_msg (int level, const char *format, ...)
106 PRINTF_FORMAT (2, 3);
108 /* File-locator stack. */
109 void err_push_file_locator (const struct file_locator *);
110 void err_pop_file_locator (const struct file_locator *);
111 void err_location (struct file_locator *);
113 /* Obscure functions. */
114 void err_set_command_name (const char *);
115 void err_done (void);
116 void err_check_count (void);
117 void err_vmsg (const struct error *, const char *, va_list);
119 /* Used in panic situations only */
120 void request_bug_report_and_abort(const char *msg );
122 void err_assert_fail(const char *expr, const char *file, int line);
125 #define __STRING(x) #x
129 #define assert(expr) ( (void) ( expr ? (void) 0 : \
130 err_assert_fail(__STRING(expr), __FILE__, __LINE__)) )