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