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. */
89 void msg_init ( void (*handler) (const struct msg *),
90 void (*location) (struct msg_locator *) ) ;
94 struct msg * msg_dup(const struct msg *m);
95 void msg_destroy(struct msg *m);
97 /* Emitting messages. */
98 void msg (enum msg_class, const char *format, ...)
100 void msg_emit (struct msg *);
103 void msg_set_command_name (const char *);
104 const char *msg_get_command_name (void);
105 void msg_push_msg_locator (const struct msg_locator *);
106 void msg_pop_msg_locator (const struct msg_locator *);
109 /* Used in panic situations only. */
110 void request_bug_report_and_abort (const char *msg) NO_RETURN;
112 #endif /* message.h */