Tue, 28 Aug 2012 16:44:32 +0200
changed version output slightly
10 | 1 | /* |
2 | * arguments.c | |
3 | * | |
4 | * Created on: 15.09.2011 | |
20
43725438ac50
Changed author comments + added signatures for upcomming bfile heuristics
Mike Becker <universe@uap-core.de>
parents:
10
diff
changeset
|
5 | * Author: Mike |
10 | 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
d642fdb6745e
allow parallel use of -s and -S
Mike Becker <universe@uap-core.de>
parents:
20
diff
changeset
|
30 | |
d642fdb6745e
allow parallel use of -s and -S
Mike Becker <universe@uap-core.de>
parents:
20
diff
changeset
|
31 | bool checkParamOpt(int* paropt) { |
d642fdb6745e
allow parallel use of -s and -S
Mike Becker <universe@uap-core.de>
parents:
20
diff
changeset
|
32 | bool ret = *paropt == 0; |
d642fdb6745e
allow parallel use of -s and -S
Mike Becker <universe@uap-core.de>
parents:
20
diff
changeset
|
33 | *paropt = 1; |
d642fdb6745e
allow parallel use of -s and -S
Mike Becker <universe@uap-core.de>
parents:
20
diff
changeset
|
34 | return ret; |
d642fdb6745e
allow parallel use of -s and -S
Mike Becker <universe@uap-core.de>
parents:
20
diff
changeset
|
35 | } |
d642fdb6745e
allow parallel use of -s and -S
Mike Becker <universe@uap-core.de>
parents:
20
diff
changeset
|
36 | |
d642fdb6745e
allow parallel use of -s and -S
Mike Becker <universe@uap-core.de>
parents:
20
diff
changeset
|
37 | void parseCSL(char* csl, string_list_t* list) { |
d642fdb6745e
allow parallel use of -s and -S
Mike Becker <universe@uap-core.de>
parents:
20
diff
changeset
|
38 | if (csl != NULL) { |
d642fdb6745e
allow parallel use of -s and -S
Mike Becker <universe@uap-core.de>
parents:
20
diff
changeset
|
39 | char* finder = strtok(csl, ","); |
d642fdb6745e
allow parallel use of -s and -S
Mike Becker <universe@uap-core.de>
parents:
20
diff
changeset
|
40 | while (finder != NULL) { |
d642fdb6745e
allow parallel use of -s and -S
Mike Becker <universe@uap-core.de>
parents:
20
diff
changeset
|
41 | add_string(list, finder); |
d642fdb6745e
allow parallel use of -s and -S
Mike Becker <universe@uap-core.de>
parents:
20
diff
changeset
|
42 | finder = strtok(NULL, ","); |
d642fdb6745e
allow parallel use of -s and -S
Mike Becker <universe@uap-core.de>
parents:
20
diff
changeset
|
43 | } |
d642fdb6745e
allow parallel use of -s and -S
Mike Becker <universe@uap-core.de>
parents:
20
diff
changeset
|
44 | } |
d642fdb6745e
allow parallel use of -s and -S
Mike Becker <universe@uap-core.de>
parents:
20
diff
changeset
|
45 | } |