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