changed reading hint
[gromacs/adressmacs.git] / include / readinp.h
blob21ed691cb0c97d315108967253491edcc83b5313
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
12 * Copyright (c) 1991-1999
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
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)
21 * Also check out our WWW page:
22 * http://md.chem.rug.nl/~gmx
23 * or e-mail to:
24 * gromacs@chem.rug.nl
26 * And Hey:
27 * Green Red Orange Magenta Azure Cyan Skyblue
30 #ifndef _readinp_h
31 #define _readinp_h
33 static char *SRCID_readinp_h = "$Id$";
35 #include "typedefs.h"
37 typedef struct {
38 int count;
39 bool bSet;
40 char *name;
41 char *value;
42 } t_inpfile;
44 extern t_inpfile *read_inpfile(char *fn,int *ninp);
46 extern void write_inpfile(char *fn,int ninp,t_inpfile inp[]);
48 extern int get_eint(int *ninp,t_inpfile **inp,char *name,int def);
50 extern real get_ereal(int *ninp,t_inpfile **inp,char *name,real def);
52 extern char *get_estr(int *ninp,t_inpfile **inp,char *name,char *def);
54 extern int get_eeenum(int *ninp,t_inpfile **inp,char *name,char **defs,
55 int *nerror,bool bPrintError);
56 /* defs must be NULL terminated,
57 * Add errors to nerror
58 * When bPrintError=TRUE and invalid enum: print "ERROR: ..."
61 extern int get_eenum(int *ninp,t_inpfile **inp,char *name,char **defs);
62 /* defs must be NULL terminated */
64 /* Here are some macros to extract data from the inp structures.
65 * Elements that are removed from the list after reading
67 #define STYPE(name,var,def) if ((tmp=get_estr(&ninp,&inp,name,def)) != NULL) strcpy(var,tmp)
68 #define ITYPE(name,var,def) var=get_eint(&ninp,&inp,name,def)
69 #define RTYPE(name,var,def) var=get_ereal(&ninp,&inp,name,def)
70 #define ETYPE(name,var,defs) var=get_eenum(&ninp,&inp,name,defs)
71 #define EETYPE(name,var,defs,nerr,bErr) var=get_eeenum(&ninp,&inp,name,defs,nerr,bErr)
72 #define CCTYPE(s) STYPE("\n; "s,dummy,NULL)
73 #define CTYPE(s) STYPE("; "s,dummy,NULL)
74 /* This last one prints a comment line where you can add some explanation */
76 /* This structure is used for parsing arguments off the comand line */
77 enum { etINT, etREAL, etSTR, etBOOL, etRVEC, etENUM, etNR };
78 /* names to print in help info */
79 static char *argtp[etNR] = { "int", "real", "string", "bool", "vector", "enum" };
81 typedef struct {
82 char *option;
83 bool bSet;
84 int type;
85 union {
86 void *v; /* This is a nasty workaround, to be able to use initialized */
87 int *i; /* arrays */
88 real *r;
89 char **c; /* Must be pointer to string (when type == etSTR) */
90 /* or null terminated list of enums (when type == etENUM) */
91 bool *b;
92 rvec *rv;
93 } u;
94 char *desc;
95 } t_pargs;
97 extern void get_pargs(int *argc,char *argv[],int nparg,t_pargs pa[],
98 bool bKeepArgs);
99 /* Read a number of arguments from the command line.
100 * For etINT, etREAL and etCHAR an extra argument is read (when present)
101 * for etBOOL the boolean option is changed to the negate value
102 * If !bKeepArgs, the command line arguments are removed from the command line
105 extern bool is_hidden(t_pargs *pa);
106 /* Return TRUE when the option is a secret one */
108 extern char *pa_val(t_pargs *pa);
109 /* Return a pointer to a static buffer containing the value of pa */
111 extern int opt2parg_int(char *option,int nparg,t_pargs pa[]);
113 extern bool opt2parg_bool(char *option,int nparg,t_pargs pa[]);
115 extern real opt2parg_real(char *option,int nparg,t_pargs pa[]);
117 extern char *opt2parg_str(char *option,int nparg,t_pargs pa[]);
119 extern char *opt2parg_enum(char *option,int nparg,t_pargs pa[]);
121 extern bool opt2parg_bSet(char *option,int nparg,t_pargs pa[]);
123 extern void print_pargs(FILE *fp, int npargs,t_pargs pa[]);
125 extern void pr_enums(FILE *fp, int npargs,t_pargs pa[]);
127 #endif