mirror of https://github.com/BOINC/boinc.git
*** empty log message ***
svn path=/trunk/boinc_samples/; revision=11568
This commit is contained in:
parent
51c7889174
commit
92c596e6ee
|
@ -208,6 +208,7 @@ David 8 Nov 2006
|
|||
|
||||
David 23 Nov 2006
|
||||
- don't include util.h in worker.C!
|
||||
- fix win compile
|
||||
|
||||
worker/
|
||||
worker.C
|
||||
|
|
|
@ -59,6 +59,67 @@ int main(int, char**) {
|
|||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
|
||||
// take a string containing some space separated words.
|
||||
// return an array of pointers to the null-terminated words.
|
||||
// Modifies the string arg.
|
||||
// Returns argc
|
||||
// TODO: use strtok here
|
||||
|
||||
#define NOT_IN_TOKEN 0
|
||||
#define IN_SINGLE_QUOTED_TOKEN 1
|
||||
#define IN_DOUBLE_QUOTED_TOKEN 2
|
||||
#define IN_UNQUOTED_TOKEN 3
|
||||
|
||||
int parse_command_line(char* p, char** argv) {
|
||||
int state = NOT_IN_TOKEN;
|
||||
int argc=0;
|
||||
|
||||
while (*p) {
|
||||
switch(state) {
|
||||
case NOT_IN_TOKEN:
|
||||
if (isspace(*p)) {
|
||||
} else if (*p == '\'') {
|
||||
p++;
|
||||
argv[argc++] = p;
|
||||
state = IN_SINGLE_QUOTED_TOKEN;
|
||||
break;
|
||||
} else if (*p == '\"') {
|
||||
p++;
|
||||
argv[argc++] = p;
|
||||
state = IN_DOUBLE_QUOTED_TOKEN;
|
||||
break;
|
||||
} else {
|
||||
argv[argc++] = p;
|
||||
state = IN_UNQUOTED_TOKEN;
|
||||
}
|
||||
break;
|
||||
case IN_SINGLE_QUOTED_TOKEN:
|
||||
if (*p == '\'') {
|
||||
*p = 0;
|
||||
state = NOT_IN_TOKEN;
|
||||
}
|
||||
break;
|
||||
case IN_DOUBLE_QUOTED_TOKEN:
|
||||
if (*p == '\"') {
|
||||
*p = 0;
|
||||
state = NOT_IN_TOKEN;
|
||||
}
|
||||
break;
|
||||
case IN_UNQUOTED_TOKEN:
|
||||
if (isspace(*p)) {
|
||||
*p = 0;
|
||||
state = NOT_IN_TOKEN;
|
||||
}
|
||||
break;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
argv[argc] = 0;
|
||||
return argc;
|
||||
}
|
||||
|
||||
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR Args, int WinMode) {
|
||||
LPSTR command_line;
|
||||
char* argv[100];
|
||||
|
|
Loading…
Reference in New Issue