DMFCBase::InputCommandHandle Goes through the list of input commands and calls the associated handle (if it exists). Returns true if it called a handler, else false.
| 3414 | // Goes through the list of input commands and calls the associated handle (if it exists). Returns |
| 3415 | // true if it called a handler, else false. |
| 3416 | bool DMFCBase::InputCommandHandle(char *command_string) { |
| 3417 | ASSERT(command_string != NULL); |
| 3418 | |
| 3419 | // make sure it's a valid command (starts with a $) |
| 3420 | if (command_string[0] != '$') |
| 3421 | return false; |
| 3422 | |
| 3423 | /* |
| 3424 | if(!stricmp(command_string,"$help dump")) |
| 3425 | { |
| 3426 | mprintf(0,"Dumping help commands to file\n"); |
| 3427 | tInputCommandNode *node = m_InputCommandRootNode; |
| 3428 | |
| 3429 | CFILE *file; |
| 3430 | DLLOpenCFILE(&file,"C:\\DMFCHelp.txt","wt"); |
| 3431 | |
| 3432 | if(!file) |
| 3433 | return false; |
| 3434 | |
| 3435 | char buffer[1024]; |
| 3436 | |
| 3437 | while(node){ |
| 3438 | |
| 3439 | sprintf(buffer,"$%s",node->data); |
| 3440 | DLLcf_WriteString(file,buffer); |
| 3441 | DLLcf_WriteString(file,"-------------------------------------------"); |
| 3442 | sprintf(buffer,"%s\n",node->desc); |
| 3443 | DLLcf_WriteString(file,buffer); |
| 3444 | node = node->next; |
| 3445 | } |
| 3446 | |
| 3447 | DLLcfclose(file); |
| 3448 | } |
| 3449 | */ |
| 3450 | |
| 3451 | // now extract the command |
| 3452 | char command[64], index = 0; |
| 3453 | char *p = &command_string[1]; |
| 3454 | |
| 3455 | // lowercase the command_string |
| 3456 | while (*p && *p != ' ') { |
| 3457 | if ((*p >= 'A') && (*p <= 'Z')) { |
| 3458 | *p = tolower(*p); |
| 3459 | } |
| 3460 | p++; |
| 3461 | } |
| 3462 | |
| 3463 | p = &command_string[1]; |
| 3464 | |
| 3465 | // break off the first string |
| 3466 | while ((*p) && (*p != ' ')) { |
| 3467 | ASSERT(index < 64); |
| 3468 | command[index] = *p; |
| 3469 | p++; |
| 3470 | index++; |
| 3471 | } |
| 3472 | command[index] = '\0'; // tack on an ending NULL |
| 3473 |
no outgoing calls
no test coverage detected