comparison tests/evaltest.c @ 669:440b77b635a5

Add -f option to evaltest.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 16 Apr 2013 09:46:25 +0300
parents 69337f2fc4a4
children 776c22f83726
comparison
equal deleted inserted replaced
668:69337f2fc4a4 669:440b77b635a5
10 DMOptArg optList[] = 10 DMOptArg optList[] =
11 { 11 {
12 { 0, '?', "help", "Show this help", OPT_NONE }, 12 { 0, '?', "help", "Show this help", OPT_NONE },
13 { 1, 'v', "verbose", "Be more verbose", OPT_NONE }, 13 { 1, 'v', "verbose", "Be more verbose", OPT_NONE },
14 { 2, 'b', "benchmark", "Run in benchmark mode", OPT_NONE }, 14 { 2, 'b', "benchmark", "Run in benchmark mode", OPT_NONE },
15 { 3, 'f', "formula", "Next argument is the formula", OPT_ARGREQ },
15 }; 16 };
16 17
17 const int optListN = sizeof(optList) / sizeof(optList[0]); 18 const int optListN = sizeof(optList) / sizeof(optList[0]);
18 19
19 20
20 void argShowHelp() 21 void argShowHelp()
21 { 22 {
22 dmPrintBanner(stdout, dmProgName, "[options] '<formula>'"); 23 dmPrintBanner(stdout, dmProgName, "[options] [-f] '<formula>'");
23 dmArgsPrintHelp(stdout, optList, optListN); 24 dmArgsPrintHelp(stdout, optList, optListN);
24 } 25 }
25 26
26 27
27 BOOL argHandleOpt(const int optN, char *optArg, char *currArg) 28 BOOL argHandleOpt(const int optN, char *optArg, char *currArg)
28 { 29 {
29 (void) optArg;
30
31 switch (optN) 30 switch (optN)
32 { 31 {
33 case 0: 32 case 0:
34 argShowHelp(); 33 argShowHelp();
35 exit(0); 34 exit(0);
40 break; 39 break;
41 40
42 case 2: 41 case 2:
43 optBenchmark = TRUE; 42 optBenchmark = TRUE;
44 break; 43 break;
45 44
45 case 3:
46 optFormula = optArg;
47 break;
48
46 default: 49 default:
47 dmError("Unknown option '%s'.\n", currArg); 50 dmError("Unknown option '%s'.\n", currArg);
48 return FALSE; 51 return FALSE;
49 } 52 }
50 53