Fixed segv in make_edi when no reference structure given
[gromacs/adressmacs.git] / include / futil.h
blobc297071457cbcea0dd1b0d7cc27a98fc1105da09
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.2.0
11 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
12 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
13 * Copyright (c) 2001-2004, The GROMACS development team,
14 * check out http://www.gromacs.org for more information.
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.
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.
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.
31 * For more info, check our website at http://www.gromacs.org
33 * And Hey:
34 * Gromacs Runs On Most of All Computer Systems
37 #ifndef _futil_h
38 #define _futil_h
40 #ifdef HAVE_CONFIG_H
41 #include <config.h>
42 #endif
44 #include <stdio.h>
45 #include "typedefs.h"
47 /* Native windows uses backslash path separators.
48 * Cygwin and everybody else in the world use slash.
49 * When reading the PATH environment variable, Unix separates entries
50 * with colon, while windows uses semicolon.
52 #if ((defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64) && !defined __CYGWIN__ && !defined __CYGWIN32__)
53 #define DIR_SEPARATOR '\\'
54 #define PATH_SEPARATOR ";"
55 #else
56 #define DIR_SEPARATOR '/'
57 #define PATH_SEPARATOR ":"
58 #endif
60 #ifdef CPLUSPLUS
61 extern "C" {
62 #endif
64 extern void no_buffers(void);
65 /* Turn off buffering of files (which is default) for debugging purposes */
67 extern bool fexist(const char *fname);
68 /* Return TRUE when fname exists, FALSE otherwise */
70 extern bool eof(FILE *fp);
71 /* Return TRUE on end-of-file, FALSE otherwise */
73 extern bool is_pipe(FILE *fp);
74 /* Check whether the file (opened by ffopen) is a pipe */
76 extern char *backup_fn(const char *file);
77 /* Return a backup name for file (name with # before and after) */
79 /* Make a backup of file if necessary.
80 Return false if there was a problem.
82 extern bool make_backup(const char * file);
84 extern FILE *ffopen(const char *file,char *mode);
85 /* Return a valid file pointer when succesfull, exits otherwise
86 * If the file is in compressed format, open a pipe which uncompresses
87 * the file! Therefore, files must be closed with ffclose (see below)
90 extern void ffclose(FILE *fp);
91 /* Close files or pipes */
94 extern void frewind(FILE *fp);
95 /* Does not rewind pipes, but does so for normal files */
97 #define rewind frewind
99 bool is_pipe(FILE *fp);
101 extern const char *libfn(const char *file);
103 extern FILE *libopen(const char *file);
104 /* Open a library file for reading. This looks in the current directory
105 * first, and then in the library directory. If the file is not found,
106 * it terminates with a fatal_error
109 extern bool get_libdir(char *libdir);
111 extern const char *low_libfn(const char *file,bool bFatal);
113 extern FILE *low_libopen(const char *file,bool bFatal);
114 /* The same as the above, but does not terminate if (!bFatal) */
116 /* Create unique name for temp file (wrapper around mkstemp).
117 * Buf should be at least 7 bytes long
119 extern void gmx_tmpnam(char *buf);
121 #ifdef CPLUSPLUS
123 #endif
125 #endif /* _futil_h */