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); } }
void check_all_highlights(struct session *ses, char *original, char *line) { struct listroot *root = ses->list[LIST_HIGHLIGHT]; struct listnode *node; char *pto, *ptl, *ptm; char match[BUFFER_SIZE], color[BUFFER_SIZE], reset[BUFFER_SIZE], output[BUFFER_SIZE], plain[BUFFER_SIZE]; for (root->update = 0 ; root->update < root->used ; root->update++) { if (check_one_regexp(ses, root->list[root->update], line, original, 0)) { node = root->list[root->update]; get_highlight_codes(ses, node->right, color); *output = *reset = 0; pto = original; ptl = line; do { if (*gtd->vars[0] == 0) { break; } strcpy(match, gtd->vars[0]); strip_vt102_codes(match, plain); ptm = strstr(pto, match); if (!HAS_BIT(node->flags, NODE_FLAG_META)) { if (ptm == NULL) { break; } ptl = strstr(ptl, match); ptl = ptl + strlen(match); } *ptm = 0; get_color_codes(reset, pto, reset); cat_sprintf(output, "%s%s%s\033[0m%s", pto, color, plain, reset); pto = ptm + strlen(match); show_debug(ses, LIST_HIGHLIGHT, "#DEBUG HIGHLIGHT {%s}", node->left); } while (check_one_regexp(ses, node, ptl, pto, 0)); strcat(output, pto); strcpy(original, output); } } }