void echo_command(struct session *ses, char *line) { char buffer[STRING_SIZE], result[STRING_SIZE]; if (HAS_BIT(ses->flags, SES_FLAG_SPLIT)) { sprintf(buffer, "%s%s\033[0m", ses->cmd_color, line); } else { sprintf(buffer, "%s", line); } /* Deal with pending output */ if (ses->more_output[0]) { if (ses->check_output) { strcpy(result, ses->more_output); ses->more_output[0] = 0; process_mud_output(ses, result, FALSE); } } DEL_BIT(ses->telopts, TELOPT_FLAG_PROMPT); if (HAS_BIT(ses->flags, SES_FLAG_SPLIT)) { if (!HAS_BIT(ses->flags, SES_FLAG_ECHOCOMMAND)) { sprintf(result, "\033[0;37m"); } else { sprintf(result, "%s%s", ses->more_output, buffer); } add_line_buffer(ses, buffer, -1); SET_BIT(ses->flags, SES_FLAG_SCROLLSTOP); tintin_printf2(ses, "%s", result); DEL_BIT(ses->flags, SES_FLAG_SCROLLSTOP); } else { add_line_buffer(ses, buffer, -1); } }
void process_mud_output(struct session *ses, char *linebuf, int prompt) { char line[STRING_SIZE]; ses->check_output = 0; strip_vt102_codes(linebuf, line); check_all_events(ses, SUB_ARG | SUB_SEC, 0, 2, "RECEIVED LINE", linebuf, line); if (prompt) { check_all_events(ses, SUB_ARG | SUB_SEC, 0, 2, "RECEIVED PROMPT", linebuf, line); } if (HAS_BIT(ses->flags, SES_FLAG_COLORPATCH)) { sprintf(line, "%s%s", ses->color, linebuf); get_color_codes(ses->color, linebuf, ses->color); linebuf = line; } do_one_line(linebuf, ses); /* changes linebuf */ /* Take care of gags, vt102 support still goes */ if (HAS_BIT(ses->flags, SES_FLAG_GAG)) { strip_non_vt102_codes(linebuf, ses->more_output); printf("%s", ses->more_output); ses->more_output[0] = 0; DEL_BIT(ses->flags, SES_FLAG_GAG); return; } add_line_buffer(ses, linebuf, prompt); if (ses == gtd->ses) { printline(ses, linebuf, prompt); } else if (HAS_BIT(ses->flags, SES_FLAG_SNOOP)) { strip_vt102_codes_non_graph(linebuf, linebuf); tintin_printf2(gtd->ses, "[%s] %s", ses->name, linebuf); } }