void do_one_line(char *line, struct session *ses) { char strip[BUFFER_SIZE]; push_call("[%s] do_one_line(%s)",ses->name,line); if (HAS_BIT(ses->flags, SES_FLAG_IGNORELINE)) { pop_call(); return; } strip_vt102_codes(line, strip); if (!HAS_BIT(ses->list[LIST_ACTION]->flags, LIST_FLAG_IGNORE)) { check_all_actions(ses, line, strip); } if (!HAS_BIT(ses->list[LIST_PROMPT]->flags, LIST_FLAG_IGNORE)) { if (HAS_BIT(ses->flags, SES_FLAG_SPLIT)) { check_all_prompts(ses, line, strip); } } if (!HAS_BIT(ses->list[LIST_GAG]->flags, LIST_FLAG_IGNORE)) { check_all_gags(ses, line, strip); } if (!HAS_BIT(ses->list[LIST_SUBSTITUTE]->flags, LIST_FLAG_IGNORE)) { check_all_substitutions(ses, line, strip); } if (!HAS_BIT(ses->list[LIST_HIGHLIGHT]->flags, LIST_FLAG_IGNORE)) { check_all_highlights(ses, line, strip); } if (ses->logline) { logit(ses, line, ses->logline, TRUE); fclose(ses->logline); ses->logline = NULL; } pop_call(); return; }
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 do_one_line(char *line, struct session *ses) { char strip[BUFFER_SIZE]; push_call("[%s] do_one_line(%s)",ses->name,line); if (gtd->ignore_level) { pop_call(); return; } strip_vt102_codes(line, strip); if (!HAS_BIT(ses->list[LIST_ACTION]->flags, LIST_FLAG_IGNORE)) { check_all_actions(ses, line, strip); } if (!HAS_BIT(ses->list[LIST_PROMPT]->flags, LIST_FLAG_IGNORE)) { check_all_prompts(ses, line, strip); } if (!HAS_BIT(ses->list[LIST_GAG]->flags, LIST_FLAG_IGNORE)) { check_all_gags(ses, line, strip); } if (!HAS_BIT(ses->list[LIST_SUBSTITUTE]->flags, LIST_FLAG_IGNORE)) { check_all_substitutions(ses, line, strip); } if (!HAS_BIT(ses->list[LIST_HIGHLIGHT]->flags, LIST_FLAG_IGNORE)) { check_all_highlights(ses, line, strip); } if (HAS_BIT(ses->flags, SES_FLAG_LOGNEXT)) { logit(ses, line, ses->lognext_file, TRUE); DEL_BIT(ses->flags, SES_FLAG_LOGNEXT); } pop_call(); return; }
int cursor_auto_tab_add(int input_now, int stop_after_first) { char tab[BUFFER_SIZE], buf[BUFFER_SIZE]; int scroll_cnt, line_cnt, tab_len; char *arg; line_cnt = 0; scroll_cnt = gtd->ses->scroll_row; do { if (scroll_cnt == gtd->ses->scroll_max - 1) { scroll_cnt = 0; } else { scroll_cnt++; } if (gtd->ses->buffer[scroll_cnt] == NULL) { break; } if (str_hash_grep(gtd->ses->buffer[scroll_cnt], FALSE)) { continue; } if (line_cnt++ >= gtd->ses->auto_tab) { break; } strip_vt102_codes(gtd->ses->buffer[scroll_cnt], buf); arg = buf; while (*arg) { arg = get_arg_stop_spaces(gtd->ses, arg, tab, 0); if (!strncmp(tab, >d->input_buf[input_now], strlen(>d->input_buf[input_now]))) { tab_len = strlen(tab) - 1; if (tab_len > 0) { if (tab[tab_len] == '.' || tab[tab_len] == ',') { tab[tab_len] = 0; } } if (search_node_list(gtd->ses->list[LIST_TABCYCLE], tab)) { continue; } insert_node_list(gtd->ses->list[LIST_TABCYCLE], tab, "", ""); if (stop_after_first) { return TRUE; } } if (*arg == COMMAND_SEPARATOR) { arg++; } } } while (scroll_cnt != gtd->ses->scroll_row); return FALSE; }
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); } } }