Merge branch release-5-1
[alexxy/gromacs.git] / src / gromacs / fileio / warninp.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5  * Copyright (c) 2001-2004, The GROMACS development team.
6  * Copyright (c) 2010,2014,2015,2016, by the GROMACS development team, led by
7  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
8  * and including many others, as listed in the AUTHORS file in the
9  * top-level source directory and at http://www.gromacs.org.
10  *
11  * GROMACS is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public License
13  * as published by the Free Software Foundation; either version 2.1
14  * of the License, or (at your option) any later version.
15  *
16  * GROMACS is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with GROMACS; if not, see
23  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
24  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
25  *
26  * If you want to redistribute modifications to GROMACS, please
27  * consider that scientific software is very special. Version
28  * control is crucial - bugs must be traceable. We will be happy to
29  * consider code for inclusion in the official distribution, but
30  * derived work must not be called official GROMACS. Details are found
31  * in the README & COPYING files - if they are missing, get the
32  * official version at http://www.gromacs.org.
33  *
34  * To help us fund GROMACS development, we humbly ask that you cite
35  * the research papers on the package. Check out http://www.gromacs.org.
36  */
37 #ifndef GMX_FILEIO_WARNINP_H
38 #define GMX_FILEIO_WARNINP_H
39
40 #include "gromacs/utility/basedefinitions.h"
41
42 /* Abstract type for warning bookkeeping */
43 typedef struct warninp *warninp_t;
44
45
46 warninp_t
47 init_warning(gmx_bool bAllowWarnings, int maxwarning);
48 /* Initialize the warning data structure.
49  * If bAllowWarnings=FALSE, all warnings (calls to warning()) will be
50  * transformed into errors, calls to warning_note still produce notes.
51  * maxwarning determines the maximum number of warnings that are allowed
52  * for proceeding. When this number is exceeded check_warning_error
53  * and done_warning will generate a fatal error.
54  * bAllowWarnings=TRUE should only be used by programs that have
55  * a -maxwarn command line option.
56  */
57
58 void
59 set_warning_line(warninp_t wi, const char *fn, int line);
60 /* Set filename and linenumber for the warning */
61
62 int
63 get_warning_line(warninp_t wi);
64 /* Get linenumber for the warning */
65
66
67 const char *
68 get_warning_file(warninp_t wi);
69 /* Get filename for the warning */
70
71 void
72 warning(warninp_t wi, const char *s);
73 /* Issue a warning, with the string s. If s == NULL, then warn_buf
74  * will be printed instead. The file and line set by set_warning_line
75  * are printed, nwarn_warn (local) is incremented.
76  * A fatal error will be generated after processing the input
77  * when nwarn_warn is larger than maxwarning passed to init_warning.
78  * So warning should only be called for issues that should be resolved,
79  * otherwise warning_note should be called.
80  */
81
82 void
83 warning_note(warninp_t wi, const char *s);
84 /* Issue a note, with the string s. If s == NULL, then warn_buf
85  * will be printed instead. The file and line set by set_warning_line
86  * are printed, nwarn_note (local) is incremented.
87  * This is for issues which could be a problem for some systems,
88  * but 100% ok for other systems.
89  */
90
91 void
92 warning_error(warninp_t wi, const char *s);
93 /* Issue an error, with the string s. If s == NULL, then warn_buf
94  * will be printed instead. The file and line set by set_warning_line
95  * are printed, nwarn_error (local) is incremented.
96  */
97
98 gmx_bool warning_errors_exist(warninp_t wi);
99 /* Return whether any error-level warnings were issued to wi. */
100
101 void
102 check_warning_error(warninp_t wi, int f_errno, const char *file, int line);
103 /* When warning_error has been called at least once gmx_fatal is called,
104  * otherwise does nothing.
105  */
106
107 void
108 done_warning(warninp_t wi, int f_errno, const char *file, int line);
109 /* Should be called when finished processing the input file.
110  * Prints the number of notes and warnings
111  * and generates a fatal error when errors were found or too many
112  * warnings were generatesd.
113  * Frees the data structure pointed to by wi.
114  */
115
116 void
117 free_warning(warninp_t wi);
118 /* Frees the data structure pointed to by wi. */
119
120 void
121 _too_few(warninp_t wi, const char *fn, int line);
122 #define too_few(wi) _too_few(wi, __FILE__, __LINE__)
123 /* Issue a warning stating 'Too few parameters' */
124
125 void
126 _incorrect_n_param(warninp_t wi, const char *fn, int line);
127 #define incorrect_n_param(wi) _incorrect_n_param(wi, __FILE__, __LINE__)
128 /* Issue a warning stating 'Incorrect number of parameters' */
129
130 #endif