1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 1997-9, 2000, 2006, 2010, 2011, 2014 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/>. */
23 #include "libpspp/compiler.h"
27 /* What kind of message is this? */
30 MSG_C_GENERAL, /* General info. */
31 MSG_C_SYNTAX, /* Messages that relate to syntax files. */
32 MSG_C_DATA, /* Messages that relate to data files. */
36 /* How important a condition is it? */
45 const char *msg_severity_to_string (enum msg_severity);
47 /* Combination of a category and a severity for convenience. */
50 ME, MW, MN, /* General error/warning/note. */
51 SE, SW, SN, /* Script error/warning/note. */
52 DE, DW, DN, /* Data-file error/note. */
56 static inline enum msg_category
57 msg_class_to_category (enum msg_class class)
62 static inline enum msg_severity
63 msg_class_to_severity (enum msg_class class)
68 static inline enum msg_class
69 msg_class_from_category_and_severity (enum msg_category category,
70 enum msg_severity severity)
72 return category * 3 + severity;
77 char *file_name; /* Name of file containing error, or NULL. */
78 int first_line; /* 1-based line number, or 0 if none. */
79 int last_line; /* 1-based exclusive last line (0=none). */
80 int first_column; /* 1-based first column, or 0 if none. */
81 int last_column; /* 1-based exclusive last column (0=none). */
84 void msg_location_uninit (struct msg_location *);
85 void msg_location_destroy (struct msg_location *);
86 struct msg_location *msg_location_dup (const struct msg_location *);
88 void msg_location_merge (struct msg_location **, const struct msg_location *);
90 bool msg_location_is_empty (const struct msg_location *);
91 void msg_location_format (const struct msg_location *, struct string *);
95 struct msg_location *location;
99 void msg_stack_destroy (struct msg_stack *);
100 struct msg_stack *msg_stack_dup (const struct msg_stack *);
105 enum msg_category category; /* Message category. */
106 enum msg_severity severity; /* Message severity. */
107 struct msg_location *location; /* Code location. */
108 struct msg_stack **stack;
110 char *command_name; /* Name of erroneous command, or NULL. */
111 char *text; /* Error text. */
114 /* Initialization. */
115 void msg_set_handler (void (*handler) (const struct msg *, void *lexer),
118 /* Working with messages. */
119 struct msg *msg_dup (const struct msg *);
120 void msg_destroy(struct msg *);
121 char *msg_to_string (const struct msg *);
123 /* Emitting messages. */
124 void vmsg (enum msg_class, const struct msg_location *,
125 const char *format, va_list args)
126 PRINTF_FORMAT (3, 0);
127 void msg (enum msg_class, const char *format, ...)
128 PRINTF_FORMAT (2, 3);
129 void msg_at (enum msg_class, const struct msg_location *,
130 const char *format, ...)
131 PRINTF_FORMAT (3, 4);
132 void msg_emit (struct msg *);
134 void msg_error (int errnum, const char *format, ...)
135 PRINTF_FORMAT (2, 3);
138 /* Enable and disable messages. */
139 void msg_enable (void);
140 void msg_disable (void);
143 bool msg_ui_too_many_errors (void);
144 void msg_ui_reset_counts (void);
145 bool msg_ui_any_errors (void);
146 void msg_ui_disable_warnings (bool);
149 /* Used in panic situations only. */
150 const char * prepare_diagnostic_information (void);
151 const char * prepare_fatal_error_message (void);
152 void request_bug_report (const char *msg);
155 #endif /* message.h */