void check_all_prompts(struct session *ses, char *original, char *line) { struct listroot *root = ses->list[LIST_PROMPT]; struct listnode *node; if (!HAS_BIT(ses->flags, SES_FLAG_SPLIT)) { return; } 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]; if (*node->right) { substitute(ses, node->right, original, SUB_ARG); substitute(ses, original, original, SUB_VAR|SUB_FUN|SUB_COL|SUB_ESC); } show_debug(ses, LIST_PROMPT, "#DEBUG PROMPT {%s}", node->left); do_one_prompt(ses, original, atoi(node->pr)); SET_BIT(ses->flags, SES_FLAG_GAG); } } }
int check_all_aliases(struct session *ses, char *input) { struct listnode *node; struct listroot *root; char line[BUFFER_SIZE], tmp[BUFFER_SIZE], *arg; int i; root = ses->list[LIST_ALIAS]; if (HAS_BIT(root->flags, LIST_FLAG_IGNORE)) { return FALSE; } for (i = 1; i < 100; i++) { if (*gtd->vars[i]) { RESTRING(gtd->vars[i], ""); } } substitute(ses, input, line, SUB_VAR | SUB_FUN); for (root->update = 0; root->update < root->used; root->update++) { if (check_one_regexp(ses, root->list[root->update], line, line, PCRE_ANCHORED)) { node = root->list[root->update]; i = strlen(node->left); if (!strncmp(node->left, line, i)) { if (line[i] && line[i] != ' ') { continue; } arg = get_arg_in_braces(ses, line, tmp, FALSE); RESTRING(gtd->vars[0], arg) for (i = 1; i < 100 && *arg; i++) { arg = get_arg_in_braces(ses, arg, tmp, FALSE); RESTRING(gtd->vars[i], tmp); } } substitute(ses, node->right, tmp, SUB_ARG); if (!strncmp(node->left, line, strlen(node->left)) && !strcmp(node->right, tmp) && *gtd->vars[0]) { sprintf(input, "%s %s", tmp, gtd->vars[0]); } else { sprintf(input, "%s", tmp); } show_debug(ses, LIST_ALIAS, "#DEBUG ALIAS {%s} {%s}", node->left, gtd->vars[0]); return TRUE; } }
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); } } }