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_C_GENERAL, /* General info. */
28 MSG_C_SYNTAX, /* Messages that relate to syntax files. */
29 MSG_C_DATA, /* Messages that relate to data files. */
33 /* How important a condition is it? */
42 /* Combination of a category and a severity for convenience. */
45 ME, MW, MN, /* General error/warning/note. */
46 SE, SW, SN, /* Script error/warning/note. */
47 DE, DW, DN, /* Data-file error/note. */
51 static inline enum msg_category
52 msg_class_to_category (enum msg_class class)
57 static inline enum msg_severity
58 msg_class_to_severity (enum msg_class class)
63 static inline enum msg_class
64 msg_class_from_category_and_severity (enum msg_category category,
65 enum msg_severity severity)
67 return category * 3 + severity;
70 /* A file location. */
73 char *file_name; /* File name. */
74 int line_number; /* Line number. */
80 enum msg_category category; /* Message category. */
81 enum msg_severity severity; /* Message severity. */
82 struct msg_locator where; /* File location, or (NULL, -1). */
83 char *text; /* Error text. */
86 struct source_stream ;
89 void msg_init (struct source_stream *, void (*handler) (const struct msg *) );
93 /* Working with messages. */
94 struct msg *msg_dup (const struct msg *);
95 void msg_destroy(struct msg *);
96 char *msg_to_string (const struct msg *, const char *command_name);
98 /* Emitting messages. */
99 void msg (enum msg_class, const char *format, ...)
100 PRINTF_FORMAT (2, 3);
101 void msg_emit (struct msg *);
103 /* Enable and disable messages. */
104 void msg_enable (void);
105 void msg_disable (void);
108 void msg_push_msg_locator (const struct msg_locator *);
109 void msg_pop_msg_locator (const struct msg_locator *);
112 /* Used in panic situations only. */
113 void request_bug_report_and_abort (const char *msg) NO_RETURN;
115 #endif /* message.h */