1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 #include <libpspp/compiler.h>
24 /* What kind of message is this? */
27 MSG_GENERAL, /* General info. */
28 MSG_SYNTAX, /* Messages that relate to syntax files. */
29 MSG_DATA /* Messages that relate to data files. */
32 /* How important a condition is it? */
40 /* Combination of a category and a severity for convenience. */
43 ME, MW, MN, /* General error/warning/note. */
44 SE, SW, SN, /* Script error/warning/note. */
45 DE, DW, DN, /* Data-file error/note. */
50 static inline enum msg_category
51 msg_class_to_category (enum msg_class class)
56 static inline enum msg_severity
57 msg_class_to_severity (enum msg_class class)
62 static inline enum msg_class
63 msg_class_from_category_and_severity (enum msg_category category,
64 enum msg_severity severity)
66 return category * 3 + severity;
69 /* A file location. */
72 const char *file_name; /* File name. */
73 int line_number; /* Line number. */
79 enum msg_category category; /* Message category. */
80 enum msg_severity severity; /* Message severity. */
81 struct msg_locator where; /* File location, or (NULL, -1). */
82 char *text; /* Error text. */
85 struct source_stream ;
88 void msg_init (struct source_stream *, void (*handler) (const struct msg *) );
92 struct msg * msg_dup(const struct msg *m);
93 void msg_destroy(struct msg *m);
95 /* Emitting messages. */
96 void msg (enum msg_class, const char *format, ...)
98 void msg_emit (struct msg *);
100 /* Enable and disable messages. */
101 void msg_enable (void);
102 void msg_disable (void);
105 void msg_set_command_name (const char *);
106 const char *msg_get_command_name (void);
107 void msg_push_msg_locator (const struct msg_locator *);
108 void msg_pop_msg_locator (const struct msg_locator *);
111 /* Used in panic situations only. */
112 void request_bug_report_and_abort (const char *msg) NO_RETURN;
114 #endif /* message.h */