| 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); |