summaryrefslogtreecommitdiff
path: root/src/pproc.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2006-05-01 17:11:04 +0000
committerMike Buland <eichlan@xagasoft.com>2006-05-01 17:11:04 +0000
commitf7a9549bd6ad83f2e0bceec9cddacfa5e3f84a54 (patch)
tree53cec4864776e07950e3c72f2a990a1017d08045 /src/pproc.cpp
downloadlibbu++-f7a9549bd6ad83f2e0bceec9cddacfa5e3f84a54.tar.gz
libbu++-f7a9549bd6ad83f2e0bceec9cddacfa5e3f84a54.tar.bz2
libbu++-f7a9549bd6ad83f2e0bceec9cddacfa5e3f84a54.tar.xz
libbu++-f7a9549bd6ad83f2e0bceec9cddacfa5e3f84a54.zip
libbu++ is finally laid out the way it should be, trunk, branches, and tags.
Diffstat (limited to 'src/pproc.cpp')
-rw-r--r--src/pproc.cpp60
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
5void 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