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