1 /* PSPP - computes sample statistics.
2 Copyright (C) 1997-9, 2000, 2006 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
25 #include <libpspp/compiler.h>
27 /* What kind of message is this? */
30 MSG_GENERAL, /* General info. */
31 MSG_SYNTAX, /* Messages that relate to syntax files. */
32 MSG_DATA /* Messages that relate to data files. */
35 /* How important a condition is it? */
43 /* Combination of a category and a severity for convenience. */
46 ME, MW, MN, /* General error/warning/note. */
47 SE, SW, SN, /* Script error/warning/note. */
48 DE, DW, DN, /* Data-file error/note. */
53 static inline enum msg_category
54 msg_class_to_category (enum msg_class class)
59 static inline enum msg_severity
60 msg_class_to_severity (enum msg_class class)
65 static inline enum msg_class
66 msg_class_from_category_and_severity (enum msg_category category,
67 enum msg_severity severity)
69 return category * 3 + severity;
72 /* A file location. */
75 const char *file_name; /* File name. */
76 int line_number; /* Line number. */
82 enum msg_category category; /* Message category. */
83 enum msg_severity severity; /* Message severity. */
84 struct msg_locator where; /* File location, or (NULL, -1). */
85 char *text; /* Error text. */
88 /* Number of errors, warnings reported. */
89 extern int err_error_count;
90 extern int err_warning_count;
92 /* If number of allowable errors/warnings is exceeded, then a message
93 is displayed and this flag is set to suppress subsequent
95 extern int err_already_flagged;
97 /* Nonnegative verbosity level. Higher value == more verbose. */
98 extern int err_verbosity;
100 /* Initialization. */
101 void msg_done (void);
103 /* Emitting messages. */
104 void msg (enum msg_class, const char *format, ...)
105 PRINTF_FORMAT (2, 3);
106 void msg_emit (const struct msg *);
108 void verbose_msg (int level, const char *format, ...)
109 PRINTF_FORMAT (2, 3);
112 void msg_set_command_name (const char *);
113 void msg_push_msg_locator (const struct msg_locator *);
114 void msg_pop_msg_locator (const struct msg_locator *);
115 void msg_location (struct msg_locator *);
116 void err_check_count (void);
118 /* Used in panic situations only. */
119 void request_bug_report_and_abort (const char *msg);
121 void msg_assert_fail (const char *expr, const char *file, int line);
124 #define __STRING(x) #x
127 #define assert(expr) ( (void) ( expr ? (void) 0 : \
128 msg_assert_fail(__STRING(expr), __FILE__, __LINE__)) )
130 #endif /* message.h */