Merge branch 'master' of git@git.gromacs.org:gromacs
[gromacs/qmmm-gamess-us.git] / include / warninp.h
blob5b75e87b9a2d07fdb4faf8baffe7136fbad440e5
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.
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.
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.
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.
30 * For more info, check our website at http://www.gromacs.org
32 * And Hey:
33 * Gromacs Runs On Most of All Computer Systems
36 #ifndef _warninp_h
37 #define _warninp_h
39 #ifdef HAVE_CONFIG_H
40 #include <config.h>
41 #endif
43 #include "typedefs.h"
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
50 /* Abstract type for warning bookkeeping */
51 typedef struct warninp *warninp_t;
54 warninp_t
55 init_warning(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.
66 void
67 set_warning_line(warninp_t wi,const char *fn,int line);
68 /* Set filename and linenumber for the warning */
70 int
71 get_warning_line(warninp_t wi);
72 /* Get linenumber for the warning */
75 const char *
76 get_warning_file(warninp_t wi);
77 /* Get filename for the warning */
79 void
80 warning(warninp_t wi,const char *s);
81 /* Issue a warning, with the string s. If s == NULL, then warn_buf
82 * will be printed instead. The file and line set by set_warning_line
83 * are printed, nwarn_warn (local) is incremented.
84 * A fatal error will be generated after processing the input
85 * when nwarn_warn is larger than maxwarning passed to init_warning.
86 * So warning should only be called for issues that should be resolved,
87 * otherwise warning_note should be called.
90 void
91 warning_note(warninp_t wi,const char *s);
92 /* Issue a note, with the string s. If s == NULL, then warn_buf
93 * will be printed instead. The file and line set by set_warning_line
94 * are printed, nwarn_note (local) is incremented.
95 * This is for issues which could be a problem for some systems,
96 * but 100% ok for other systems.
99 void
100 warning_error(warninp_t wi,const char *s);
101 /* Issue an error, with the string s. If s == NULL, then warn_buf
102 * will be printed instead. The file and line set by set_warning_line
103 * are printed, nwarn_error (local) is incremented.
106 void
107 check_warning_error(warninp_t wi,int f_errno,const char *file,int line);
108 /* When warning_error has been called at least once gmx_fatal is called,
109 * otherwise does nothing.
112 void
113 done_warning(warninp_t wi,int f_errno,const char *file,int line);
114 /* Should be called when finished processing the input file.
115 * Prints the number of notes and warnings
116 * and generates a fatal error when errors were found or too many
117 * warnings were generatesd.
118 * Frees the data structure pointed to by wi.
121 void
122 _too_few(warninp_t wi,const char *fn,int line);
123 #define too_few(wi) _too_few(wi,__FILE__,__LINE__)
124 /* Issue a warning stating 'Too few parameters' */
126 void
127 _incorrect_n_param(warninp_t wi,const char *fn,int line);
128 #define incorrect_n_param(wi) _incorrect_n_param(wi,__FILE__,__LINE__)
129 /* Issue a warning stating 'Incorrect number of parameters' */
131 #ifdef __cplusplus
133 #endif
135 #endif /* _warninp_h */