| 76 | }; |
| 77 | |
| 78 | static int |
| 79 | doParseCmdLine( |
| 80 | int argc, |
| 81 | char *argv[], |
| 82 | const CmdLineOpt *opts, |
| 83 | unsigned int nrOpts, |
| 84 | TestParams *params) |
| 85 | { |
| 86 | int i = 1, j = 0; |
| 87 | int ret = 0; |
| 88 | const CmdLineOpt *currOpt; |
| 89 | const char *currArg; |
| 90 | SetterArg sarg = {params, NULL, 0}; |
| 91 | |
| 92 | do { |
| 93 | currArg = (const char*)argv[i]; |
| 94 | i++; |
| 95 | |
| 96 | if ( (currArg[0] != '-') && isdigit( currArg[0] ) ){ |
| 97 | // some of size arguments |
| 98 | switch (j) { |
| 99 | case 0: |
| 100 | params->M = atoi(currArg); |
| 101 | params->optFlags |= SET_M; |
| 102 | break; |
| 103 | case 1: |
| 104 | params->N = atoi(currArg); |
| 105 | params->optFlags |= SET_N; |
| 106 | break; |
| 107 | case 2: |
| 108 | params->K = atoi(currArg); |
| 109 | params->optFlags |= SET_K; |
| 110 | break; |
| 111 | } |
| 112 | j++; |
| 113 | continue; |
| 114 | } |
| 115 | else if (currArg[1] != '-') { |
| 116 | // it can be some parameter of a used test framework, skip it |
| 117 | j = 0; |
| 118 | continue; |
| 119 | } |
| 120 | |
| 121 | j = 0; |
| 122 | |
| 123 | for (currOpt = opts; currOpt < opts + nrOpts; currOpt++) { |
| 124 | if (!strcmp(currOpt->name, &currArg[2])) { |
| 125 | if (i == argc) { |
| 126 | printf("Error: parameter '%s' is not specified!\n", |
| 127 | currOpt->name); |
| 128 | ret = -1; |
| 129 | } |
| 130 | else { |
| 131 | sarg.arg = argv[i++]; |
| 132 | sarg.extra = currOpt->setterExtra; |
| 133 | ret = currOpt->setter(&sarg); |
| 134 | params->optFlags |= currOpt->flagToSet; |
| 135 | } |
no outgoing calls
no test coverage detected