4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
12 * Copyright (c) 1991-2001
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
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 * Do check out http://www.gromacs.org , or mail us at gromacs@gromacs.org .
34 * GRoups of Organic Molecules in ACtion for Science
40 static char *SRCID_readinp_h = "$Id$";
54 extern t_inpfile *read_inpfile(char *fn,int *ninp);
56 extern void write_inpfile(char *fn,int ninp,t_inpfile inp[]);
58 extern int get_eint(int *ninp,t_inpfile **inp,char *name,int def);
60 extern real get_ereal(int *ninp,t_inpfile **inp,char *name,real def);
62 extern char *get_estr(int *ninp,t_inpfile **inp,char *name,char *def);
64 extern int get_eeenum(int *ninp,t_inpfile **inp,char *name,char **defs,
65 int *nerror,bool bPrintError);
66 /* defs must be NULL terminated,
67 * Add errors to nerror
68 * When bPrintError=TRUE and invalid enum: print "ERROR: ..."
71 extern int get_eenum(int *ninp,t_inpfile **inp,char *name,char **defs);
72 /* defs must be NULL terminated */
74 /* Here are some macros to extract data from the inp structures.
75 * Elements that are removed from the list after reading
77 #define STYPE(name,var,def) if ((tmp=get_estr(&ninp,&inp,name,def)) != NULL) strcpy(var,tmp)
78 #define ITYPE(name,var,def) var=get_eint(&ninp,&inp,name,def)
79 #define RTYPE(name,var,def) var=get_ereal(&ninp,&inp,name,def)
80 #define ETYPE(name,var,defs) var=get_eenum(&ninp,&inp,name,defs)
81 #define EETYPE(name,var,defs,nerr,bErr) var=get_eeenum(&ninp,&inp,name,defs,nerr,bErr)
82 #define CCTYPE(s) STYPE("\n; "s,dummy,NULL)
83 #define CTYPE(s) STYPE("; "s,dummy,NULL)
84 /* This last one prints a comment line where you can add some explanation */
86 /* This structure is used for parsing arguments off the comand line */
88 etINT, etREAL, etTIME, etSTR, etBOOL, etRVEC, etENUM, etNR
90 /* names to print in help info */
91 static char *argtp[etNR] = {
92 "int", "real", "time", "string", "bool", "vector", "enum"
100 void *v; /* This is a nasty workaround, to be able to use initialized */
103 char **c; /* Must be pointer to string (when type == etSTR) */
104 /* or null terminated list of enums (when type == etENUM) */
111 extern void get_pargs(int *argc,char *argv[],int nparg,t_pargs pa[],
113 /* Read a number of arguments from the command line.
114 * For etINT, etREAL and etCHAR an extra argument is read (when present)
115 * for etBOOL the boolean option is changed to the negate value
116 * If !bKeepArgs, the command line arguments are removed from the command line
119 extern bool is_hidden(t_pargs *pa);
120 /* Return TRUE when the option is a secret one */
122 extern char *pa_val(t_pargs *pa);
123 /* Return a pointer to a static buffer containing the value of pa */
125 extern int opt2parg_int(char *option,int nparg,t_pargs pa[]);
127 extern bool opt2parg_bool(char *option,int nparg,t_pargs pa[]);
129 extern real opt2parg_real(char *option,int nparg,t_pargs pa[]);
131 extern char *opt2parg_str(char *option,int nparg,t_pargs pa[]);
133 extern char *opt2parg_enum(char *option,int nparg,t_pargs pa[]);
135 extern bool opt2parg_bSet(char *option,int nparg,t_pargs pa[]);
137 extern void print_pargs(FILE *fp, int npargs,t_pargs pa[]);
139 extern void pr_enums(FILE *fp, int npargs,t_pargs pa[]);