73 |
//! intended to be one or more sentences |
//! intended to be one or more sentences |
74 |
hestOpt *hopt; //!< dynamically managed hest options |
hestOpt *hopt; //!< dynamically managed hest options |
75 |
hestParm *hparm; //!< hest parameters |
hestParm *hparm; //!< hest parameters |
76 |
opt_def_t *odef; //!< dynamically reallocated via odefArr |
opt_def_t **odef; //!< dynamically reallocated via odefArr |
77 |
uint32_t odefNum; //!< length of meaningful values in odef[] |
unsigned int odefNum; //!< length of meaningful values in odef[] |
78 |
airArray *odefArr; //!< manages odef and odefNum; |
airArray *odefArr; //!< manages odef and odefNum; |
79 |
airArray *mop; //!< manages hopt, hparm, and odefArr |
airArray *mop; //!< manages hopt, hparm, and odefArr |
80 |
}; |
}; |
105 |
|
|
106 |
/*! create the container for all option information |
/*! create the container for all option information |
107 |
*/ |
*/ |
108 |
Diderot_Options_t *Diderot_OptNew (void) |
Diderot_Options_t *Diderot_OptNew () |
109 |
{ |
{ |
110 |
static const char *me = "Diderot_Options_New"; |
static const char *me = "Diderot_Options_New"; |
111 |
Diderot_Options_t *dopts = AIR_CALLOC(1, Diderot_Options_t); |
Diderot_Options_t *dopts = AIR_CALLOC(1, Diderot_Options_t); |
112 |
if (!dopts) { |
if (dopts == 0) { |
113 |
fprintf(stderr, "%s: unable to allocate output\n", me); |
fprintf(stderr, "%s: unable to allocate output\n", me); |
114 |
exit(1); |
exit(1); |
115 |
} |
} |
204 |
exit(1); |
exit(1); |
205 |
} |
} |
206 |
/* code here uses "odf" to copy one value of odef[] */ |
/* code here uses "odf" to copy one value of odef[] */ |
207 |
opt_def_t *odf = &(dopts->odef[nidx]); |
opt_def_t *odf = dopts->odef[nidx]; |
208 |
odf->name = airStrdup(name); |
odf->name = airStrdup(name); |
209 |
odf->desc = airStrdup(desc); |
odf->desc = airStrdup(desc); |
210 |
if ((odf->name == 0) || (odf->desc == 0)) { |
if ((odf->name == 0) || (odf->desc == 0)) { |
228 |
NULL, desc); |
NULL, desc); |
229 |
} |
} |
230 |
|
|
231 |
|
/*! \brief add a boolean-valued option to the list of options. |
232 |
|
* \param dopts the list of options |
233 |
|
* \param name the name of the option |
234 |
|
* \param desc a short description string |
235 |
|
* \param v a pointer to the location where the value gets stored |
236 |
|
* \param hasDflt true if there is an initial value |
237 |
|
*/ |
238 |
void Diderot_OptAddBool ( |
void Diderot_OptAddBool ( |
239 |
Diderot_Options_t *dopts, |
Diderot_Options_t *dopts, |
240 |
const char *name, const char *desc, |
const char *name, const char *desc, |
407 |
|
|
408 |
// convert values learned by hest to their Diderot representations |
// convert values learned by hest to their Diderot representations |
409 |
for (int i = 0; i < dopts->odefNum; i++) { |
for (int i = 0; i < dopts->odefNum; i++) { |
410 |
opt_def_t *odf = &(dopts->odef[i]); |
opt_def_t *odf = dopts->odef[i]; |
411 |
switch (odf->ty) { |
switch (odf->ty) { |
412 |
case optTypeFlag: |
case optTypeFlag: |
413 |
case optTypeBool: |
case optTypeBool: |