| 532 | |
| 533 | |
| 534 | int rotctl_parse(ROT *my_rot, FILE *fin, FILE *fout, const char *argv[], |
| 535 | int argc, |
| 536 | int interactive, int prompt, char send_cmd_term) |
| 537 | { |
| 538 | int retcode; /* generic return code from functions */ |
| 539 | unsigned char cmd; |
| 540 | struct test_table *cmd_entry = NULL; |
| 541 | int ext_resp = 0; |
| 542 | char resp_sep = '\n'; |
| 543 | |
| 544 | char command[MAXARGSZ + 1]; |
| 545 | char arg1[MAXARGSZ + 1], *p1 = NULL; |
| 546 | char arg2[MAXARGSZ + 1], *p2 = NULL; |
| 547 | char arg3[MAXARGSZ + 1], *p3 = NULL; |
| 548 | char arg4[MAXARGSZ + 1], *p4 = NULL; |
| 549 | #ifdef __USEP5P6__ |
| 550 | char *p5 = NULL; |
| 551 | char *p6 = NULL; |
| 552 | #endif |
| 553 | char arg_format[8]; |
| 554 | |
| 555 | SNPRINTF(arg_format, sizeof(arg_format), "%%%ds", MAXARGSZ); |
| 556 | |
| 557 | /* cmd, internal, rotctld */ |
| 558 | #ifdef HAVE_LIBREADLINE |
| 559 | |
| 560 | if (!(interactive && prompt && have_rl)) |
| 561 | #endif |
| 562 | { |
| 563 | if (interactive) |
| 564 | { |
| 565 | static int last_was_ret = 1; |
| 566 | |
| 567 | if (prompt) |
| 568 | { |
| 569 | fprintf_flush(fout, "\nRotator command: "); |
| 570 | } |
| 571 | |
| 572 | do |
| 573 | { |
| 574 | if (scanfc(fin, "%c", &cmd) < 1) |
| 575 | { |
| 576 | return -1; |
| 577 | } |
| 578 | |
| 579 | /* Extended response protocol requested with leading '+' on command |
| 580 | * string--rotctld only! |
| 581 | */ |
| 582 | if (cmd == '+' && !prompt) |
| 583 | { |
| 584 | ext_resp = 1; |
| 585 | |
| 586 | if (scanfc(fin, "%c", &cmd) < 1) |
| 587 | { |
| 588 | return -1; |
| 589 | } |
| 590 | } |
| 591 | else if (cmd == '+' && prompt) |
no test coverage detected