Tagged files with gromacs 3.0 header and added some license info
[alexxy/gromacs.git] / include / fatal.h
1 /*
2  * $Id$
3  * 
4  *                This source code is part of
5  * 
6  *                 G   R   O   M   A   C   S
7  * 
8  *          GROningen MAchine for Chemical Simulations
9  * 
10  *                        VERSION 3.0
11  * 
12  * Copyright (c) 1991-2001
13  * BIOSON Research Institute, Dept. of Biophysical Chemistry
14  * University of Groningen, The Netherlands
15  * 
16  * This program is free software; you can redistribute it and/or
17  * modify it under the terms of the GNU General Public License
18  * as published by the Free Software Foundation; either version 2
19  * of the License, or (at your option) any later version.
20  * 
21  * If you want to redistribute modifications, please consider that
22  * scientific software is very special. Version control is crucial -
23  * bugs must be traceable. We will be happy to consider code for
24  * inclusion in the official distribution, but derived work must not
25  * be called official GROMACS. Details are found in the README & COPYING
26  * files - if they are missing, get the official version at www.gromacs.org.
27  * 
28  * To help us fund GROMACS development, we humbly ask that you cite
29  * the papers on the package - you can find them in the top README file.
30  * 
31  * Do check out http://www.gromacs.org , or mail us at gromacs@gromacs.org .
32  * 
33  * And Hey:
34  * Giving Russians Opium May Alter Current Situation
35  */
36
37 #ifndef _fatal_h
38 #define _fatal_h
39
40 static char *SRCID_fatal_h = "$Id$";
41 #ifdef HAVE_CONFIG_H
42 #include <config.h>
43 #endif
44
45 #ifdef HAVE_IDENT
46 #ident  "@(#) fatal.h 1.9 11/23/92"
47 #endif /* HAVE_IDENT */
48
49 #ifdef CPLUSPLUS
50 extern "C" {
51 #endif
52   
53 #include <stdio.h>
54 #include <stdarg.h>
55 #include <errno.h>
56   
57 extern void _where(char *file,int line);
58 #define where() _where(__FILE__,__LINE__)
59 /* Prints filename and line to stdlog and only on amba memvail */
60   
61 extern void _halt(char *file,int line,char *reason);
62 #define HALT(reason) _halt(__FILE__,__LINE__,reason)
63 /* Halts the program with an error message */
64
65 extern void _set_fatal_tmp_file(char *fn, char *file, int line);
66 #define set_fatal_tmp_file(fn) _set_fatal_tmp_file(fn,__FILE__,__LINE__)
67 /* set filename to be removed when fatal_error is called */
68
69 extern void _unset_fatal_tmp_file(char *fn, char *file, int line);
70 #define unset_fatal_tmp_file(fn) _unset_fatal_tmp_file(fn,__FILE__,__LINE__)
71 /* unsets filename to be removed */
72
73 extern void fatal_error(int fatal_errno,char *fmt,...);
74 /*
75  * Routine fatal_error prints 
76  *
77  *      "fatal error file %s line %s \n\t " 
78  *
79  * followed by the string specified by fmt and supplied parameters. If 
80  * errno is 0, only the message and arguments are printed. If errno is 
81  * a legal system errno or -1, a perror like message is printed after the
82  * first message, if errno is -1, the last system errno will be used.
83  * The format of fmt is that like printf etc, only %d, %x, %c, %f and %s
84  * are allowed as format specifiers.
85  */
86
87 /* This include must not be moved upwards, to prevent compilation problems */  
88 #include "typedefs.h"
89
90 extern void init_warning(int maxwarning);
91 /* Set the max number of warnings */
92
93 extern void set_warning_line(char *fn,int line);
94 /* Set filename and linenumber for the warning */
95   
96 extern int get_warning_line(void);
97 /* Get linenumber for the warning */
98   
99 extern char *get_warning_file(void);
100 /* Get filename for the warning */
101   
102 extern char warn_buf[1024];
103 /* Warning buffer of 1024 bytes, which can be used to print messages to */
104
105 extern void warning(char *s);
106 /* Issue a warning, with the string s. If s == NULL, then warn_buf
107  * will be printed instead.
108  */
109  
110 extern void print_warn_num(void);
111 /* Print the total number of warnings, if larger than 0 */
112   
113 extern void _too_few(char *fn,int line);
114 #define too_few() _too_few(__FILE__,__LINE__)
115 /* Issue a warning stating 'Too few parameters' */
116   
117 extern void _invalid_case(char *fn,int line);
118 #define invalid_case() _invalid_case(__FILE__,__LINE__)
119 /* Issue a warning stating 'Invalid case in switch' */
120   
121 extern void _unexpected_eof(char *fn,int line,char *srcfn,int srcline);
122 #define unexpected_eof(fn,line) _unexpected_eof(fn,line,__FILE__,__LINE__)
123   
124 /* 
125  * Functions can write to this file for debug info
126  * Before writing to it, it should be checked whether
127  * the file is not 0:
128  * if (debug) fprintf(debug,"%s","Hallo");
129  */
130 extern FILE *debug;
131   
132 void init_debug (char *dbgfile);
133   
134 extern bool bDebugMode(void);
135 /* Return TRUE when the program was started in debug mode */
136   
137 #ifdef USE_SGI_FPE
138 extern void doexceptions(void);
139 /* Set exception handlers for debugging */
140 #endif
141   
142 #ifdef CPLUSPLUS
143            }
144 #endif
145
146 #endif  /* _fatal_h */