Simplify code structure for C++ analysis tools
[alexxy/gromacs.git] / src / gromacs / legacyheaders / filenm.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 _filenm_h
37 #define _filenm_h
38
39 #include "futil.h"
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44
45 void set_default_file_name(const char *name);
46 /* Set the default file name for all file types to name */
47
48 const char *ftp2ext(int ftp);
49 /* Return extension for filetype */
50
51 const char *ftp2ext_generic(int ftp);
52 /* Return extension for filetype, and a generic name for generic types
53    (e.g. trx)*/
54
55 const char *ftp2ext_with_dot(int ftp);
56 /* Return extension for filetype with a leading dot */
57
58 int ftp2generic_count(int ftp);
59 /* Return the number of filetypes for a generic filetype */
60
61 const int *ftp2generic_list(int ftp);
62 /* Return the list of filetypes for a generic filetype */
63
64 const char *ftp2desc(int ftp);
65 /* Return description for file type */
66
67 const char *ftp2defnm(int ftp);
68 /* Return default file name for file type */
69
70 const char *ftp2ftype(int ftp);
71 /* Return Binary or ASCII depending on file type */
72
73 void pr_fns(FILE *fp, int nf, const t_filenm tfn[]);
74 /* Print nf file names and types */
75
76 void pr_fopts(FILE *fp, int nf, const t_filenm tfn[], int shell);
77 /* prints file options in tcsh 'complete' format */
78
79 void parse_file_args(int *argc, char *argv[], int nf, t_filenm fnm[],
80                      gmx_bool bKeep, gmx_bool bReadNode);
81 /* Parse command line for file names. When bKeep is set args are
82  * not removed from argv. */
83
84 const char *opt2fn(const char *opt, int nfile, const t_filenm fnm[]);
85 /* Return the filename belonging to cmd-line option opt, or NULL when
86  * no such option. */
87
88 const char *opt2fn_master(const char *opt, int nfile,
89                           const t_filenm fnm[], t_commrec *cr);
90 /* Return the filename belonging to cmd-line option opt, or NULL when
91  * no such option or not running on master */
92
93
94 int opt2fns(char **fns[], const char *opt, int nfile,
95             const t_filenm fnm[]);
96 /* Return the filenames belonging to cmd-line option opt, or NULL when
97  * no such option. */
98
99 #define opt2FILE(opt, nfile, fnm, mode) ffopen(opt2fn(opt, nfile, fnm), mode)
100 /* Return a file pointer from the filename (see above) */
101
102 int fn2ftp(const char *fn);
103 /* Return the filetype corrsponding to filename */
104
105 const char *ftp2fn(int ftp, int nfile, const t_filenm fnm[]);
106 /* Return the first file name with type ftp, or NULL when none found. */
107
108 int ftp2fns(char **fns[], int ftp, int nfile, const t_filenm fnm[]);
109 /* Return the number of files for the first option with type ftp
110    and the files in **fns[] (will be allocated), or NULL when none found. */
111
112 #if 0
113 /* This function is not thread-safe and used nowhere: */
114 char *ftp2filter(int ftp);
115 /* Return a file extension filter for file type */
116 #endif
117
118 #define ftp2FILE(ftp, nfile, fnm, mode) ffopen(ftp2fn(ftp, nfile, fnm), mode)
119 /* Return a file pointer from the filename (see above) */
120
121 gmx_bool ftp2bSet(int ftp, int nfile, const t_filenm fnm[]);
122 /* Return TRUE when this file type has been found on the cmd-line */
123
124 gmx_bool opt2bSet(const char *opt, int nfile, const t_filenm fnm[]);
125 /* Return TRUE when this option has been found on the cmd-line */
126
127 const char *opt2fn_null(const char *opt, int nfile, const t_filenm fnm[]);
128 /* Return the filenm belonging top cmd-line option opt, or NULL when
129  * no such option.
130  * Also return NULL when opt is optional and option is not set.
131  */
132
133 const char *ftp2fn_null(int ftp, int nfile, const t_filenm fnm[]);
134 /* Return the first file name with type ftp, or NULL when none found.
135  * Also return NULL when ftp is optional and option is not set.
136  */
137
138 gmx_bool is_optional(const t_filenm *fnm);
139 /* Return whether or not this filenm is optional */
140
141 gmx_bool is_output(const t_filenm *fnm);
142 /* Return whether or not this filenm is output */
143
144 gmx_bool is_set(const t_filenm *fnm);
145 /* Return whether or not this filenm is set */
146
147 /* When we do checkpointing, this routine is called to check for previous
148  * output files and append a '.partNNNN' suffix before the (output) file extensions.
149  */
150 int add_suffix_to_output_names(t_filenm *fnm, int nfile, const char *suffix);
151
152 /* duplicate the filename list (to make a private copy for each thread,
153    for example) */
154 t_filenm *dup_tfn(int nf, const t_filenm tfn[]);
155
156 /* Free memory allocated for file names by parse_file_args(). */
157 void done_filenms(int nf, t_filenm fnm[]);
158
159 #ifdef __cplusplus
160 }
161 #endif
162
163 #endif  /* _filenm_h */