arguments.c

changeset 34
fa9bda32de17
parent 30
d642fdb6745e
equal deleted inserted replaced
33:1a2d7298bc82 34:fa9bda32de17
1 /*
2 * arguments.c
3 *
4 * Created on: 15.09.2011
5 * Author: Mike
6 */
7
8 #include "arguments.h"
9
10 int checkArgument(const char* arg, const char* expected) {
11 int len = strlen(expected);
12 int ret = 0;
13
14 if (arg[0] == '-') {
15 if (arg[1] != '-') {
16 for (int t = 0 ; t < len ; t++) {
17 ret |= (strchr(arg, expected[t]) > 0) << t;
18 }
19 }
20 }
21
22 return ret;
23 }
24
25 bool registerArgument(int* reg, int mask) {
26 bool ret = (*reg & mask) > 0;
27 *reg |= mask;
28 return ret;
29 }
30
31 bool checkParamOpt(int* paropt) {
32 bool ret = *paropt == 0;
33 *paropt = 1;
34 return ret;
35 }
36
37 void parseCSL(char* csl, string_list_t* list) {
38 if (csl != NULL) {
39 char* finder = strtok(csl, ",");
40 while (finder != NULL) {
41 add_string(list, finder);
42 finder = strtok(NULL, ",");
43 }
44 }
45 }

mercurial