1 /* $OpenBSD: cmd-queue.c,v 1.92 2020/05/16 15:40:04 nicm Exp $ */ 2 3 /* 4 * Copyright (c) 2013 Nicholas Marriott <nicholas.marriott@gmail.com> 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER 15 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 16 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 #include <sys/types.h> 20 21 #include <ctype.h> 22 #include <stdlib.h> 23 #include <string.h> 24 #include <time.h> 25 26 #include "tmux.h" 27 28 /* Command queue flags. */ 29 #define CMDQ_FIRED 0x1 30 #define CMDQ_WAITING 0x2 31 32 /* Command queue item type. */ 33 enum cmdq_type { 34 CMDQ_COMMAND, 35 CMDQ_CALLBACK, 36 }; 37 38 /* Command queue item. */ 39 struct cmdq_item { 40 char *name; 41 struct cmdq_list *queue; 42 struct cmdq_item *next; 43 44 struct client *client; 45 struct client *target_client; 46 47 enum cmdq_type type; 48 u_int group; 49 50 u_int number; 51 time_t time; 52 53 int flags; 54 55 struct cmdq_state *state; 56 struct cmd_find_state source; 57 struct cmd_find_state target; 58 59 struct cmd_list *cmdlist; 60 struct cmd *cmd; 61 62 cmdq_cb cb; 63 void *data; 64 65 TAILQ_ENTRY(cmdq_item) entry; 66 }; 67 TAILQ_HEAD(cmdq_item_list, cmdq_item); 68 69 /* 70 * Command queue state. This is the context for commands on the command queue. 71 * It holds information about how the commands were fired (the key and flags), 72 * any additional formats for the commands, and the current default target. 73 * Multiple commands can share the same state and a command may update the 74 * default target. 75 */ 76 struct cmdq_state { 77 int references; 78 int flags; 79 80 struct format_tree *formats; 81 82 struct key_event event; 83 struct cmd_find_state current; 84 }; 85 86 /* Command queue. */ 87 struct cmdq_list { 88 struct cmdq_item *item; 89 struct cmdq_item_list list; 90 }; 91 92 /* Get command queue name. */ 93 static const char * 94 cmdq_name(struct client *c) 95 { 96 static char s[256]; 97 98 if (c == NULL) 99 return ("<global>"); 100 if (c->name != NULL) 101 xsnprintf(s, sizeof s, "<%s>", c->name); 102 else 103 xsnprintf(s, sizeof s, "<%p>", c); 104 return (s); 105 } 106 107 /* Get command queue from client. */ 108 static struct cmdq_list * 109 cmdq_get(struct client *c) 110 { 111 static struct cmdq_list *global_queue; 112 113 if (c == NULL) { 114 if (global_queue == NULL) 115 global_queue = cmdq_new(); 116 return (global_queue); 117 } 118 return (c->queue); 119 } 120 121 /* Create a queue. */ 122 struct cmdq_list * 123 cmdq_new(void) 124 { 125 struct cmdq_list *queue; 126 127 queue = xcalloc (1, sizeof *queue); 128 TAILQ_INIT (&queue->list); 129 return (queue); 130 } 131 132 /* Free a queue. */ 133 void 134 cmdq_free(struct cmdq_list *queue) 135 { 136 if (!TAILQ_EMPTY(&queue->list)) 137 fatalx("queue not empty"); 138 free(queue); 139 } 140 141 /* Get item name. */ 142 const char * 143 cmdq_get_name(struct cmdq_item *item) 144 { 145 return (item->name); 146 } 147 148 /* Get item client. */ 149 struct client * 150 cmdq_get_client(struct cmdq_item *item) 151 { 152 return (item->client); 153 } 154 155 /* Get item target client. */ 156 struct client * 157 cmdq_get_target_client(struct cmdq_item *item) 158 { 159 return (item->target_client); 160 } 161 162 /* Get item state. */ 163 struct cmdq_state * 164 cmdq_get_state(struct cmdq_item *item) 165 { 166 return (item->state); 167 } 168 169 /* Get item target. */ 170 struct cmd_find_state * 171 cmdq_get_target(struct cmdq_item *item) 172 { 173 return (&item->target); 174 } 175 176 /* Get item source. */ 177 struct cmd_find_state * 178 cmdq_get_source(struct cmdq_item *item) 179 { 180 return (&item->source); 181 } 182 183 /* Get state event. */ 184 struct key_event * 185 cmdq_get_event(struct cmdq_item *item) 186 { 187 return (&item->state->event); 188 } 189 190 /* Get state current target. */ 191 struct cmd_find_state * 192 cmdq_get_current(struct cmdq_item *item) 193 { 194 return (&item->state->current); 195 } 196 197 /* Get state flags. */ 198 int 199 cmdq_get_flags(struct cmdq_item *item) 200 { 201 return (item->state->flags); 202 } 203 204 /* Create a new state. */ 205 struct cmdq_state * 206 cmdq_new_state(struct cmd_find_state *current, struct key_event *event, 207 int flags) 208 { 209 struct cmdq_state *state; 210 211 state = xcalloc(1, sizeof *state); 212 state->references = 1; 213 state->flags = flags; 214 215 if (event != NULL) 216 memcpy(&state->event, event, sizeof state->event); 217 else 218 state->event.key = KEYC_NONE; 219 if (current != NULL && cmd_find_valid_state(current)) 220 cmd_find_copy_state(&state->current, current); 221 else 222 cmd_find_clear_state(&state->current, 0); 223 224 return (state); 225 } 226 227 /* Add a reference to a state. */ 228 struct cmdq_state * 229 cmdq_link_state(struct cmdq_state *state) 230 { 231 state->references++; 232 return (state); 233 } 234 235 /* Make a copy of a state. */ 236 struct cmdq_state * 237 cmdq_copy_state(struct cmdq_state *state) 238 { 239 return (cmdq_new_state(&state->current, &state->event, state->flags)); 240 } 241 242 /* Free a state. */ 243 void 244 cmdq_free_state(struct cmdq_state *state) 245 { 246 if (--state->references != 0) 247 return; 248 249 if (state->formats != NULL) 250 format_free(state->formats); 251 free(state); 252 } 253 254 /* Add a format to command queue. */ 255 void 256 cmdq_add_format(struct cmdq_state *state, const char *key, const char *fmt, ...) 257 { 258 va_list ap; 259 char *value; 260 261 va_start(ap, fmt); 262 xvasprintf(&value, fmt, ap); 263 va_end(ap); 264 265 if (state->formats == NULL) 266 state->formats = format_create(NULL, NULL, FORMAT_NONE, 0); 267 format_add(state->formats, key, "%s", value); 268 269 free(value); 270 } 271 272 /* Merge formats from item. */ 273 void 274 cmdq_merge_formats(struct cmdq_item *item, struct format_tree *ft) 275 { 276 const struct cmd_entry *entry; 277 278 if (item->cmd != NULL) { 279 entry = cmd_get_entry (item->cmd); 280 format_add(ft, "command", "%s", entry->name); 281 } 282 if (item->state->formats != NULL) 283 format_merge(ft, item->state->formats); 284 } 285 286 /* Append an item. */ 287 struct cmdq_item * 288 cmdq_append(struct client *c, struct cmdq_item *item) 289 { 290 struct cmdq_list *queue = cmdq_get(c); 291 struct cmdq_item *next; 292 293 do { 294 next = item->next; 295 item->next = NULL; 296 297 if (c != NULL) 298 c->references++; 299 item->client = c; 300 301 item->queue = queue; 302 TAILQ_INSERT_TAIL(&queue->list, item, entry); 303 log_debug("%s %s: %s", __func__, cmdq_name(c), item->name); 304 305 item = next; 306 } while (item != NULL); 307 return (TAILQ_LAST(&queue->list, cmdq_item_list)); 308 } 309 310 /* Insert an item. */ 311 struct cmdq_item * 312 cmdq_insert_after(struct cmdq_item *after, struct cmdq_item *item) 313 { 314 struct client *c = after->client; 315 struct cmdq_list *queue = after->queue; 316 struct cmdq_item *next; 317 318 do { 319 next = item->next; 320 item->next = after->next; 321 after->next = item; 322 323 if (c != NULL) 324 c->references++; 325 item->client = c; 326 327 item->queue = queue; 328 TAILQ_INSERT_AFTER(&queue->list, after, item, entry); 329 log_debug("%s %s: %s after %s", __func__, cmdq_name(c), 330 item->name, after->name); 331 332 after = item; 333 item = next; 334 } while (item != NULL); 335 return (after); 336 } 337 338 /* Insert a hook. */ 339 void 340 cmdq_insert_hook(struct session *s, struct cmdq_item *item, 341 struct cmd_find_state *current, const char *fmt, ...) 342 { 343 struct cmdq_state *state = item->state; 344 struct cmd *cmd = item->cmd; 345 struct args *args = cmd_get_args(cmd); 346 struct args_entry *entryp; 347 struct args_value *valuep; 348 struct options *oo; 349 va_list ap; 350 char *name, tmp[32], flag, *arguments; 351 int i; 352 const char *value; 353 struct cmdq_item *new_item; 354 struct cmdq_state *new_state; 355 struct options_entry *o; 356 struct options_array_item *a; 357 struct cmd_list *cmdlist; 358 359 if (item->state->flags & CMDQ_STATE_NOHOOKS) 360 return; 361 if (s == NULL) 362 oo = global_s_options; 363 else 364 oo = s->options; 365 366 va_start(ap, fmt); 367 xvasprintf(&name, fmt, ap); 368 va_end(ap); 369 370 o = options_get(oo, name); 371 if (o == NULL) { 372 free(name); 373 return; 374 } 375 log_debug("running hook %s (parent %p)", name, item); 376 377 /* 378 * The hooks get a new state because they should not update the current 379 * target or formats for any subsequent commands. 380 */ 381 new_state = cmdq_new_state(current, &state->event, CMDQ_STATE_NOHOOKS); 382 cmdq_add_format(new_state, "hook", "%s", name); 383 384 arguments = args_print(args); 385 cmdq_add_format(new_state, "hook_arguments", "%s", arguments); 386 free(arguments); 387 388 for (i = 0; i < args->argc; i++) { 389 xsnprintf(tmp, sizeof tmp, "hook_argument_%d", i); 390 cmdq_add_format(new_state, tmp, "%s", args->argv[i]); 391 } 392 flag = args_first(args, &entryp); 393 while (flag != 0) { 394 value = args_get(args, flag); 395 if (value == NULL) { 396 xsnprintf(tmp, sizeof tmp, "hook_flag_%c", flag); 397 cmdq_add_format(new_state, tmp, "1"); 398 } else { 399 xsnprintf(tmp, sizeof tmp, "hook_flag_%c", flag); 400 cmdq_add_format(new_state, tmp, "%s", value); 401 } 402 403 i = 0; 404 value = args_first_value(args, flag, &valuep); 405 while (value != NULL) { 406 xsnprintf(tmp, sizeof tmp, "hook_flag_%c_%d", flag, i); 407 cmdq_add_format(new_state, tmp, "%s", value); 408 i++; 409 value = args_next_value(&valuep); 410 } 411 412 flag = args_next(&entryp); 413 } 414 415 a = options_array_first(o); 416 while (a != NULL) { 417 cmdlist = options_array_item_value(a)->cmdlist; 418 if (cmdlist != NULL) { 419 new_item = cmdq_get_command(cmdlist, new_state); 420 if (item != NULL) 421 item = cmdq_insert_after(item, new_item); 422 else 423 item = cmdq_append(NULL, new_item); 424 } 425 a = options_array_next(a); 426 } 427 428 cmdq_free_state(new_state); 429 free(name); 430 } 431 432 /* Continue processing command queue. */ 433 void 434 cmdq_continue(struct cmdq_item *item) 435 { 436 item->flags &= ~CMDQ_WAITING; 437 } 438 439 /* Remove an item. */ 440 static void 441 cmdq_remove(struct cmdq_item *item) 442 { 443 if (item->client != NULL) 444 server_client_unref(item->client); 445 if (item->cmdlist != NULL) 446 cmd_list_free(item->cmdlist); 447 cmdq_free_state(item->state); 448 449 TAILQ_REMOVE(&item->queue->list, item, entry); 450 451 free(item->name); 452 free(item); 453 } 454 455 /* Remove all subsequent items that match this item's group. */ 456 static void 457 cmdq_remove_group(struct cmdq_item *item) 458 { 459 struct cmdq_item *this, *next; 460 461 if (item->group == 0) 462 return; 463 this = TAILQ_NEXT(item, entry); 464 while (this != NULL) { 465 next = TAILQ_NEXT(this, entry); 466 if (this->group == item->group) 467 cmdq_remove(this); 468 this = next; 469 } 470 } 471 472 /* Get a command for the command queue. */ 473 struct cmdq_item * 474 cmdq_get_command(struct cmd_list *cmdlist, struct cmdq_state *state) 475 { 476 struct cmdq_item *item, *first = NULL, *last = NULL; 477 struct cmd *cmd; 478 const struct cmd_entry *entry; 479 int created = 0; 480 481 if (state == NULL) { 482 state = cmdq_new_state(NULL, NULL, 0); 483 created = 1; 484 } 485 486 cmd = cmd_list_first(cmdlist); 487 while (cmd != NULL) { 488 entry = cmd_get_entry(cmd); 489 490 item = xcalloc(1, sizeof *item); 491 xasprintf(&item->name, "[%s/%p]", entry->name, item); 492 item->type = CMDQ_COMMAND; 493 494 item->group = cmd_get_group(cmd); 495 item->state = cmdq_link_state(state); 496 497 item->cmdlist = cmdlist; 498 item->cmd = cmd; 499 500 cmdlist->references++; 501 log_debug("%s: %s group %u", __func__, item->name, item->group); 502 503 if (first == NULL) 504 first = item; 505 if (last != NULL) 506 last->next = item; 507 last = item; 508 509 cmd = cmd_list_next(cmd); 510 } 511 512 if (created) 513 cmdq_free_state(state); 514 return (first); 515 } 516 517 /* Fill in flag for a command. */ 518 static enum cmd_retval 519 cmdq_find_flag(struct cmdq_item *item, struct cmd_find_state *fs, 520 const struct cmd_entry_flag *flag) 521 { 522 const char *value; 523 524 if (flag->flag == 0) { 525 cmd_find_clear_state(fs, 0); 526 return (CMD_RETURN_NORMAL); 527 } 528 529 value = args_get(cmd_get_args(item->cmd), flag->flag); 530 if (cmd_find_target(fs, item, value, flag->type, flag->flags) != 0) { 531 cmd_find_clear_state(fs, 0); 532 return (CMD_RETURN_ERROR); 533 } 534 return (CMD_RETURN_NORMAL); 535 } 536 537 /* Fire command on command queue. */ 538 static enum cmd_retval 539 cmdq_fire_command(struct cmdq_item *item) 540 { 541 const char *name = cmdq_name(item->client); 542 struct cmdq_state *state = item->state; 543 struct cmd *cmd = item->cmd; 544 struct args *args = cmd_get_args(cmd); 545 const struct cmd_entry *entry = cmd_get_entry(cmd); 546 struct client *tc, *saved = item->client; 547 enum cmd_retval retval; 548 struct cmd_find_state *fsp, fs; 549 int flags, quiet = 0; 550 char *tmp; 551 552 if (log_get_level() > 1) { 553 tmp = cmd_print(cmd); 554 log_debug("%s %s: (%u) %s", __func__, name, item->group, tmp); 555 free(tmp); 556 } 557 558 flags = !!(state->flags & CMDQ_STATE_CONTROL); 559 cmdq_guard(item, "begin", flags); 560 561 if (item->client == NULL) 562 item->client = cmd_find_client(item, NULL, 1); 563 564 if (entry->flags & CMD_CLIENT_CANFAIL) 565 quiet = 1; 566 if (entry->flags & CMD_CLIENT_CFLAG) { 567 tc = cmd_find_client(item, args_get(args, 'c'), quiet); 568 if (tc == NULL && !quiet) { 569 retval = CMD_RETURN_ERROR; 570 goto out; 571 } 572 } else if (entry->flags & CMD_CLIENT_TFLAG) { 573 tc = cmd_find_client(item, args_get(args, 't'), quiet); 574 if (tc == NULL && !quiet) { 575 retval = CMD_RETURN_ERROR; 576 goto out; 577 } 578 } else 579 tc = cmd_find_client(item, NULL, 1); 580 item->target_client = tc; 581 582 retval = cmdq_find_flag(item, &item->source, &entry->source); 583 if (retval == CMD_RETURN_ERROR) 584 goto out; 585 retval = cmdq_find_flag(item, &item->target, &entry->target); 586 if (retval == CMD_RETURN_ERROR) 587 goto out; 588 589 590 retval = entry->exec(cmd, item); 591 if (retval == CMD_RETURN_ERROR) 592 goto out; 593 594 if (entry->flags & CMD_AFTERHOOK) { 595 if (cmd_find_valid_state(&item->target)) 596 fsp = &item->target; 597 else if (cmd_find_valid_state(&item->state->current)) 598 fsp = &item->state->current; 599 else if (cmd_find_from_client(&fs, item->client, 0) == 0) 600 fsp = &fs; 601 else 602 goto out; 603 cmdq_insert_hook(fsp->s, item, fsp, "after-%s", entry->name); 604 } 605 606 out: 607 item->client = saved; 608 if (retval == CMD_RETURN_ERROR) 609 cmdq_guard(item, "error", flags); 610 else 611 cmdq_guard(item, "end", flags); 612 return (retval); 613 } 614 615 /* Get a callback for the command queue. */ 616 struct cmdq_item * 617 cmdq_get_callback1(const char *name, cmdq_cb cb, void *data) 618 { 619 struct cmdq_item *item; 620 621 item = xcalloc(1, sizeof *item); 622 xasprintf(&item->name, "[%s/%p]", name, item); 623 item->type = CMDQ_CALLBACK; 624 625 item->group = 0; 626 item->state = cmdq_new_state(NULL, NULL, 0); 627 628 item->cb = cb; 629 item->data = data; 630 631 return (item); 632 } 633 634 /* Generic error callback. */ 635 static enum cmd_retval 636 cmdq_error_callback(struct cmdq_item *item, void *data) 637 { 638 char *error = data; 639 640 cmdq_error(item, "%s", error); 641 free(error); 642 643 return (CMD_RETURN_NORMAL); 644 } 645 646 /* Get an error callback for the command queue. */ 647 struct cmdq_item * 648 cmdq_get_error(const char *error) 649 { 650 return (cmdq_get_callback(cmdq_error_callback, xstrdup(error))); 651 } 652 653 /* Fire callback on callback queue. */ 654 static enum cmd_retval 655 cmdq_fire_callback(struct cmdq_item *item) 656 { 657 return (item->cb(item, item->data)); 658 } 659 660 /* Process next item on command queue. */ 661 u_int 662 cmdq_next(struct client *c) 663 { 664 struct cmdq_list *queue = cmdq_get(c); 665 const char *name = cmdq_name(c); 666 struct cmdq_item *item; 667 enum cmd_retval retval; 668 u_int items = 0; 669 static u_int number; 670 671 if (TAILQ_EMPTY(&queue->list)) { 672 log_debug("%s %s: empty", __func__, name); 673 return (0); 674 } 675 if (TAILQ_FIRST(&queue->list)->flags & CMDQ_WAITING) { 676 log_debug("%s %s: waiting", __func__, name); 677 return (0); 678 } 679 680 log_debug("%s %s: enter", __func__, name); 681 for (;;) { 682 item = queue->item = TAILQ_FIRST(&queue->list); 683 if (item == NULL) 684 break; 685 log_debug("%s %s: %s (%d), flags %x", __func__, name, 686 item->name, item->type, item->flags); 687 688 /* 689 * Any item with the waiting flag set waits until an external 690 * event clears the flag (for example, a job - look at 691 * run-shell). 692 */ 693 if (item->flags & CMDQ_WAITING) 694 goto waiting; 695 696 /* 697 * Items are only fired once, once the fired flag is set, a 698 * waiting flag can only be cleared by an external event. 699 */ 700 if (~item->flags & CMDQ_FIRED) { 701 item->time = time(NULL); 702 item->number = ++number; 703 704 switch (item->type) { 705 case CMDQ_COMMAND: 706 retval = cmdq_fire_command(item); 707 708 /* 709 * If a command returns an error, remove any 710 * subsequent commands in the same group. 711 */ 712 if (retval == CMD_RETURN_ERROR) 713 cmdq_remove_group(item); 714 break; 715 case CMDQ_CALLBACK: 716 retval = cmdq_fire_callback(item); 717 break; 718 default: 719 retval = CMD_RETURN_ERROR; 720 break; 721 } 722 item->flags |= CMDQ_FIRED; 723 724 if (retval == CMD_RETURN_WAIT) { 725 item->flags |= CMDQ_WAITING; 726 goto waiting; 727 } 728 items++; 729 } 730 cmdq_remove(item); 731 } 732 queue->item = NULL; 733 734 log_debug("%s %s: exit (empty)", __func__, name); 735 return (items); 736 737 waiting: 738 log_debug("%s %s: exit (wait)", __func__, name); 739 return (items); 740 } 741 742 /* Get running item if any. */ 743 struct cmdq_item * 744 cmdq_running(struct client *c) 745 { 746 struct cmdq_list *queue = cmdq_get(c); 747 748 return (queue->item); 749 } 750 751 /* Print a guard line. */ 752 void 753 cmdq_guard(struct cmdq_item *item, const char *guard, int flags) 754 { 755 struct client *c = item->client; 756 long t = item->time; 757 u_int number = item->number; 758 759 if (c != NULL && (c->flags & CLIENT_CONTROL)) 760 file_print(c, "%%%s %ld %u %d\n", guard, t, number, flags); 761 } 762 763 /* Show message from command. */ 764 void 765 cmdq_print(struct cmdq_item *item, const char *fmt, ...) 766 { 767 struct client *c = item->client; 768 struct window_pane *wp; 769 struct window_mode_entry *wme; 770 va_list ap; 771 char *tmp, *msg; 772 773 va_start(ap, fmt); 774 xvasprintf(&msg, fmt, ap); 775 va_end(ap); 776 777 log_debug("%s: %s", __func__, msg); 778 779 if (c == NULL) 780 /* nothing */; 781 else if (c->session == NULL || (c->flags & CLIENT_CONTROL)) { 782 if (~c->flags & CLIENT_UTF8) { 783 tmp = msg; 784 msg = utf8_sanitize(tmp); 785 free(tmp); 786 } 787 file_print(c, "%s\n", msg); 788 } else { 789 wp = c->session->curw->window->active; 790 wme = TAILQ_FIRST(&wp->modes); 791 if (wme == NULL || wme->mode != &window_view_mode) { 792 window_pane_set_mode(wp, NULL, &window_view_mode, NULL, 793 NULL); 794 } 795 window_copy_add(wp, "%s", msg); 796 } 797 798 free(msg); 799 } 800 801 /* Show error from command. */ 802 void 803 cmdq_error(struct cmdq_item *item, const char *fmt, ...) 804 { 805 struct client *c = item->client; 806 struct cmd *cmd = item->cmd; 807 va_list ap; 808 char *msg, *tmp; 809 const char *file; 810 u_int line; 811 812 va_start(ap, fmt); 813 xvasprintf(&msg, fmt, ap); 814 va_end(ap); 815 816 log_debug("%s: %s", __func__, msg); 817 818 if (c == NULL) { 819 cmd_get_source(cmd, &file, &line); 820 cfg_add_cause("%s:%u: %s", file, line, msg); 821 } else if (c->session == NULL || (c->flags & CLIENT_CONTROL)) { 822 if (~c->flags & CLIENT_UTF8) { 823 tmp = msg; 824 msg = utf8_sanitize(tmp); 825 free(tmp); 826 } 827 if (c->flags & CLIENT_CONTROL) 828 file_print(c, "%s\n", msg); 829 else 830 file_error(c, "%s\n", msg); 831 c->retval = 1; 832 } else { 833 *msg = toupper((u_char) *msg); 834 status_message_set(c, "%s", msg); 835 } 836 837 free(msg); 838 } 839