-
Notifications
You must be signed in to change notification settings - Fork 17
/
options.c
65 lines (48 loc) · 1.94 KB
/
options.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* ------- file: -------------------------- options.c ---------------
Version: rh2.0
Author: Han Uitenbroek ([email protected])
Last modified: Wed Mar 25 14:46:56 2009 --
-------------------------- ----------RH-- */
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include "rh.h"
#include "error.h"
#include "inputs.h"
/* --- Function prototypes -- -------------- */
/* --- Global variables -- -------------- */
extern CommandLine commandline;
extern char messageStr[];
/* ------- begin -------------------------- setOptions.c ------------ */
void setOptions(int argc, char *argv[])
{
const char routineName[] = "setOptions";
static char logfileName[MAX_LINE_SIZE], wavetable[MAX_LINE_SIZE];
int Noption;
Option theOptions[] = {
{"help", 1, FALSE, "", NULL, NULL, "Prints this message"},
{"input", 1, TRUE, "keyword.input",
commandline.keyword_input,
setcharValue, "File name for input keywords"},
{"logfile", 1, TRUE, "",
logfileName,
setcharValue, "File name log file"},
{"quiet", 1, FALSE, "FALSE", &commandline.quiet, setboolValue,
"Turns off warning messages"},
{"showkeywords", 1, FALSE, "FALSE", &commandline.showkeywords,
setboolValue,
"Show keyword values with current keyword input file"}
};
Noption = sizeof(theOptions) / sizeof(Option);
parse(argc, argv, Noption, theOptions);
if (strlen(logfileName) > 0) {
if ((commandline.logfile = fopen(logfileName, "w")) == NULL) {
sprintf(messageStr, "Unable to open log file %s", logfileName);
Error(ERROR_LEVEL_2, routineName, messageStr);
}
setvbuf(commandline.logfile, NULL, _IOLBF, BUFSIZ);
} else
commandline.logfile = stderr;
commandline.wavetable = (strlen(wavetable) > 0) ? wavetable : NULL;
}
/* ------- end ---------------------------- setOptions.c ------------ */