891d8ee413e5eef8303421b1b86570fccc544087
[alexxy/gromacs.git] / include / futil.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 2.0
11  * 
12  * Copyright (c) 1991-1999
13  * BIOSON Research Institute, Dept. of Biophysical Chemistry
14  * University of Groningen, The Netherlands
15  * 
16  * Please refer to:
17  * GROMACS: A message-passing parallel molecular dynamics implementation
18  * H.J.C. Berendsen, D. van der Spoel and R. van Drunen
19  * Comp. Phys. Comm. 91, 43-56 (1995)
20  * 
21  * Also check out our WWW page:
22  * http://md.chem.rug.nl/~gmx
23  * or e-mail to:
24  * gromacs@chem.rug.nl
25  * 
26  * And Hey:
27  * Good ROcking Metal Altar for Chronical Sinners
28  */
29
30 #ifndef _futil_h
31 #define _futil_h
32
33 static char *SRCID_futil_h = "$Id$";
34
35 #ifdef HAVE_CONFIG_H
36 #include <config.h>
37 #endif
38
39 #ifdef HAVE_IDENT
40 #ident  "@(#) futil.h 1.1 11/23/92"
41 #endif /* HAVE_IDENT */
42 #include <stdio.h>
43 #include "typedefs.h"
44
45 #ifdef CPLUSPLUS
46 extern "C" { 
47 #endif
48
49 extern void no_buffers(void);
50 /* Turn off buffering of files (which is default) for debugging purposes */
51
52 extern bool fexist(char *fname);
53 /* Return TRUE when fname exists, FALSE otherwise */
54
55 extern bool eof(FILE *fp);
56 /* Return TRUE on end-of-file, FALSE otherwise */
57
58 extern bool is_pipe(FILE *fp);
59 /* Check whether the file (opened by ffopen) is a pipe */
60
61 extern char *backup_fn(char *file);
62 /* Return a backup name for file (name with # before and after) */
63
64 extern FILE *ffopen(char *file,char *mode);
65 /* Return a valid file pointer when succesfull, exits otherwise 
66  * If the file is in compressed format, open a pipe which uncompresses
67  * the file! Therefore, files must be closed with ffclose (see below)
68  */
69
70 extern void ffclose(FILE *fp);
71 /* Close files or pipes */
72
73 #define fclose ffclose
74
75 extern void frewind(FILE *fp);
76 /* Does not rewind pipes, but does so for normal files */
77
78 #define rewind frewind
79
80 bool is_pipe(FILE *fp);
81
82 extern FILE *uncompress(char *fn,char *mode);
83 extern FILE *gunzip(char *fn,char *mode);
84 /* Open a pipe to uncompress or unzip files. Must be closed with pclose */
85
86 extern char *libfn(char *file);
87
88 extern FILE *libopen(char *file);
89 /* Open a library file for reading. This looks in the current directory
90  * first, and then in the library directory. If the file is not found,
91  * it terminates with a fatal_error
92  */
93
94 extern char *low_libfn(char *file,bool bFatal);
95
96 extern FILE *low_libopen(char *file,bool bFatal);
97 /* The same as the above, but does not terminate if (!bFatal) */
98
99 #ifdef CPLUSPLUS
100 }
101 #endif
102
103 #endif  /* _futil_h */