diff options
Diffstat (limited to 'src/pproc.cpp')
-rw-r--r-- | src/pproc.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/pproc.cpp b/src/pproc.cpp new file mode 100644 index 0000000..f5cb869 --- /dev/null +++ b/src/pproc.cpp | |||
@@ -0,0 +1,60 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <string.h> | ||
3 | #include "pproc.h" | ||
4 | |||
5 | void processParams( int argc, char *argv[], PPROC *pproc ) | ||
6 | { | ||
7 | // Loop over all the params except the first, no params, no looping! | ||
8 | for( int j = 1; j < argc; j++ ) | ||
9 | { | ||
10 | //printf("Param[%d]: \"%s\"\n", j, argv[j] ); | ||
11 | if( argv[j][0] == '-' ) | ||
12 | { | ||
13 | if( argv[j][1] == '-' ) | ||
14 | { | ||
15 | // Proccess a long-word param string | ||
16 | for( int k = 0; | ||
17 | pproc[k].proc != NULL || pproc[k].stateVar != NULL; | ||
18 | k++ ) | ||
19 | { | ||
20 | if( !strcmp( pproc[k].lpWord, &argv[j][2] ) ) | ||
21 | { | ||
22 | if( pproc[k].proc != NULL ) | ||
23 | { | ||
24 | j += pproc[k].proc( argc-j, &argv[j] ); | ||
25 | } | ||
26 | if( pproc[k].stateVar != NULL ) | ||
27 | { | ||
28 | (*(pproc[k].stateVar)) = pproc[k].bSetState; | ||
29 | } | ||
30 | } | ||
31 | } | ||
32 | } | ||
33 | else | ||
34 | { | ||
35 | // Process a one char param string | ||
36 | for( int k = 0; | ||
37 | pproc[k].proc != NULL || pproc[k].stateVar != NULL; | ||
38 | k++ ) | ||
39 | { | ||
40 | if( pproc[k].cChar == argv[j][1] ) | ||
41 | { | ||
42 | if( pproc[k].proc != NULL ) | ||
43 | { | ||
44 | j += pproc[k].proc( argc-j, &argv[j] ); | ||
45 | } | ||
46 | if( pproc[k].stateVar != NULL ) | ||
47 | { | ||
48 | (*(pproc[k].stateVar)) = pproc[k].bSetState; | ||
49 | } | ||
50 | } | ||
51 | } | ||
52 | } | ||
53 | } | ||
54 | else | ||
55 | { | ||
56 | // Handle generic params here. | ||
57 | } | ||
58 | } | ||
59 | } | ||
60 | |||