33 |
void read_commands(FILE * fp) { |
void read_commands(FILE * fp) { |
34 |
|
|
35 |
char command[MAX_COMMAND_LENGTH]; |
char command[MAX_COMMAND_LENGTH]; |
|
int command_length; |
|
36 |
|
|
37 |
fgets(command, MAX_COMMAND_LENGTH, fp); |
fgets(command, MAX_COMMAND_LENGTH, fp); |
38 |
command_length = strlen(command); |
chomp(command); |
|
|
|
|
/* if last char is newline, strip it */ |
|
|
if (command[command_length-1] == '\n') { |
|
|
command[command_length-1] = '\0'; |
|
|
} |
|
39 |
|
|
40 |
process_command(command); |
process_command(command); |
41 |
} |
} |
42 |
|
|
43 |
|
/* if last char is newline, "strip" it */ |
44 |
|
void chomp(char * string) { |
45 |
|
int string_length = strlen(string); |
46 |
|
if (string[string_length-1] == '\n') { |
47 |
|
string[string_length-1] = '\0'; |
48 |
|
} |
49 |
|
} |
50 |
|
|
51 |
void process_command(char * command) { |
void process_command(char * command) { |
52 |
printf("process_command: %s\n", command); |
printf("process_command: %s\n", command); |
53 |
start_process(command, 0); |
start_process(command, 0); |
58 |
STARTUPINFO si; |
STARTUPINFO si; |
59 |
PROCESS_INFORMATION pi; |
PROCESS_INFORMATION pi; |
60 |
|
|
61 |
printf("start_process: '%s'\n", filename); |
//printf("start_process: '%s'\n", filename); |
62 |
|
|
63 |
ZeroMemory(&si,sizeof(si)); |
ZeroMemory(&si,sizeof(si)); |
64 |
si.cb = sizeof(STARTUPINFO); |
si.cb = sizeof(STARTUPINFO); |
65 |
|
|
66 |
ZeroMemory(&pi,sizeof(pi)); |
ZeroMemory(&pi,sizeof(pi)); |
|
//pi.cb=sizeof(PROCESS_INFORMATION); |
|
67 |
|
|
68 |
CreateProcess( |
CreateProcess( |
|
//"C:\windows\system32\notepad.exe", NULL, |
|
|
//"C:\\windows\\system32\\notepad.exe", NULL, |
|
69 |
NULL, filename, |
NULL, filename, |
70 |
NULL, NULL, FALSE, 0, |
NULL, NULL, FALSE, 0, |
71 |
NULL, NULL, |
NULL, NULL, |