arguments.c

Tue, 28 Aug 2012 16:44:32 +0200

author
Mike Becker <universe@uap-core.de>
date
Tue, 28 Aug 2012 16:44:32 +0200
changeset 32
51d6e45a7592
parent 30
d642fdb6745e
permissions
-rw-r--r--

changed version output slightly

10
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1 /*
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
2 * arguments.c
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
3 *
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
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
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
6 */
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
7
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
8 #include "arguments.h"
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
9
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
10 int checkArgument(const char* arg, const char* expected) {
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
11 int len = strlen(expected);
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
12 int ret = 0;
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
13
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
14 if (arg[0] == '-') {
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
15 if (arg[1] != '-') {
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
16 for (int t = 0 ; t < len ; t++) {
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
17 ret |= (strchr(arg, expected[t]) > 0) << t;
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
18 }
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
19 }
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
20 }
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
21
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
22 return ret;
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
23 }
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
24
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
25 bool registerArgument(int* reg, int mask) {
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
26 bool ret = (*reg & mask) > 0;
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
27 *reg |= mask;
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
28 return ret;
ecf787666f44 refactored sources
Mike Becker <universe@uap-core.de>
parents:
diff changeset
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 }

mercurial