da485eda87bdc9d2a8f76abe837be44b63823833
[alexxy/gromacs.git] / src / gromacs / legacyheaders / 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, 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
38 #ifndef _warninp_h
39 #define _warninp_h
40
41 #include "../utility/basedefinitions.h"
42
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46
47
48 /* Abstract type for warning bookkeeping */
49 typedef struct warninp *warninp_t;
50
51
52 warninp_t
53 init_warning(gmx_bool bAllowWarnings, int maxwarning);
54 /* Initialize the warning data structure.
55  * If bAllowWarnings=FALSE, all warnings (calls to warning()) will be
56  * transformed into errors, calls to warning_note still produce notes.
57  * maxwarning determines the maximum number of warnings that are allowed
58  * for proceeding. When this number is exceeded check_warning_error
59  * and done_warning will generate a fatal error.
60  * bAllowWarnings=TRUE should only be used by programs that have
61  * a -maxwarn command line option.
62  */
63
64 void
65 set_warning_line(warninp_t wi, const char *fn, int line);
66 /* Set filename and linenumber for the warning */
67
68 int
69 get_warning_line(warninp_t wi);
70 /* Get linenumber for the warning */
71
72
73 const char *
74 get_warning_file(warninp_t wi);
75 /* Get filename for the warning */
76
77 void
78 warning(warninp_t wi, const char *s);
79 /* Issue a warning, with the string s. If s == NULL, then warn_buf
80  * will be printed instead. The file and line set by set_warning_line
81  * are printed, nwarn_warn (local) is incremented.
82  * A fatal error will be generated after processing the input
83  * when nwarn_warn is larger than maxwarning passed to init_warning.
84  * So warning should only be called for issues that should be resolved,
85  * otherwise warning_note should be called.
86  */
87
88 void
89 warning_note(warninp_t wi, const char *s);
90 /* Issue a note, with the string s. If s == NULL, then warn_buf
91  * will be printed instead. The file and line set by set_warning_line
92  * are printed, nwarn_note (local) is incremented.
93  * This is for issues which could be a problem for some systems,
94  * but 100% ok for other systems.
95  */
96
97 void
98 warning_error(warninp_t wi, const char *s);
99 /* Issue an error, with the string s. If s == NULL, then warn_buf
100  * will be printed instead. The file and line set by set_warning_line
101  * are printed, nwarn_error (local) is incremented.
102  */
103
104 void
105 check_warning_error(warninp_t wi, int f_errno, const char *file, int line);
106 /* When warning_error has been called at least once gmx_fatal is called,
107  * otherwise does nothing.
108  */
109
110 void
111 done_warning(warninp_t wi, int f_errno, const char *file, int line);
112 /* Should be called when finished processing the input file.
113  * Prints the number of notes and warnings
114  * and generates a fatal error when errors were found or too many
115  * warnings were generatesd.
116  * Frees the data structure pointed to by wi.
117  */
118
119 void
120 _too_few(warninp_t wi, const char *fn, int line);
121 #define too_few(wi) _too_few(wi, __FILE__, __LINE__)
122 /* Issue a warning stating 'Too few parameters' */
123
124 void
125 _incorrect_n_param(warninp_t wi, const char *fn, int line);
126 #define incorrect_n_param(wi) _incorrect_n_param(wi, __FILE__, __LINE__)
127 /* Issue a warning stating 'Incorrect number of parameters' */
128
129 #ifdef __cplusplus
130 }
131 #endif
132
133 #endif  /* _warninp_h */