1 /* PSPP - computes sample statistics.
2 Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 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, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 #include <libpspp/compiler.h>
26 /* What kind of message is this? */
29 MSG_GENERAL, /* General info. */
30 MSG_SYNTAX, /* Messages that relate to syntax files. */
31 MSG_DATA /* Messages that relate to data files. */
34 /* 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. */
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. */
81 enum msg_category category; /* Message category. */
82 enum msg_severity severity; /* Message severity. */
83 struct msg_locator where; /* File location, or (NULL, -1). */
84 char *text; /* Error text. */
87 struct source_stream ;
90 void msg_init (struct source_stream *, void (*handler) (const struct msg *) );
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 *);
102 /* Enable and disable messages. */
103 void msg_enable (void);
104 void msg_disable (void);
107 void msg_set_command_name (const char *);
108 const char *msg_get_command_name (void);
109 void msg_push_msg_locator (const struct msg_locator *);
110 void msg_pop_msg_locator (const struct msg_locator *);
113 /* Used in panic situations only. */
114 void request_bug_report_and_abort (const char *msg) NO_RETURN;
116 #endif /* message.h */