diff options
Diffstat (limited to 'cmd2.c')
-rw-r--r-- | cmd2.c | 313 |
1 files changed, 157 insertions, 156 deletions
@@ -2,7 +2,7 @@ * cmd2.c -- back-end for the various #commands * * (created: Massimiliano Ghilardi (Cosmos), Aug 14th, 1998) - * + * * Copyright (C) 1998 by Massimiliano Ghilardi * * This program is free software; you can redistribute it and/or modify @@ -13,6 +13,7 @@ */ +#include <limits.h> #include <stdio.h> #include <string.h> #include <stdlib.h> @@ -52,18 +53,18 @@ static char *colornames[] = { /* * show defined aliases */ -void show_aliases __P0 (void) +void show_aliases(void) { aliasnode *p; char buf[BUFSIZE]; - + PRINTF("#%s alias%s defined%c\n", sortedaliases ? "the following" : "no", (sortedaliases && !sortedaliases->snext) ? " is" : "es are", sortedaliases ? ':' : '.'); reverse_sortedlist((sortednode **)&sortedaliases); for (p = sortedaliases; p; p = p->snext) { escape_specials(buf, p->name); - tty_printf("#alias %s%s%s%s=%s\n", + tty_printf("#alias %s%s%s%s=%s\n", p->active ? "" : "(disabled) ", buf, group_delim, p->group == NULL ? "*" : p->group, p->subst); } @@ -75,7 +76,7 @@ void show_aliases __P0 (void) * return 1 if illegal name (and print reason). * if valid, print a warning for unbalanced () {} and "" */ -static int check_alias __P1 (char *,name) +static int check_alias(char *name) { char *p = name, c; enum { NORM, ESCAPE } state = NORM; @@ -126,13 +127,13 @@ static int check_alias __P1 (char *,name) default: break; } - + if (!ok) { PRINTF("#illegal non-escaped ';' in alias name: \"%s\"\n", name); error = INVALID_NAME_ERROR; return 1; } - + if (quotes || paren || braces) { PRINTF("#warning: unbalanced%s%s%s in alias name \"%s\" may cause problems\n", quotes ? " \"\"" : "", paren ? " ()" : "", braces ? " {}" : "", name); @@ -145,13 +146,13 @@ static int check_alias __P1 (char *,name) /* * parse the #alias command */ -void parse_alias __P1 (char *,str) +void parse_alias(char *str) { char *left, *right, *group; aliasnode **np, *p; - + left = str = skipspace(str); - + str = first_valid(str, '='); if (*str == '=') { @@ -181,12 +182,12 @@ void parse_alias __P1 (char *,str) } } else { /* add/redefine alias */ - + /* direct recursion is supported (alias CAN be defined by itself) */ if (p) { free(p->subst); p->subst = my_strdup(right); - } else + } else add_aliasnode(left, right); /* get alias again to add group (if needed) @@ -209,7 +210,7 @@ void parse_alias __P1 (char *,str) } } else { /* show alias */ - + *str = '\0'; unescape(left); if (check_alias(left)) @@ -219,7 +220,7 @@ void parse_alias __P1 (char *,str) char buf[BUFSIZE]; escape_specials(buf, left); snprintf(inserted_next, BUFSIZE, "#alias %s%s%s=%s", - buf, + buf, group_delim, (*np)->group == NULL ? "*" : (*np)->group, (*np)->subst); @@ -232,7 +233,7 @@ void parse_alias __P1 (char *,str) /* * delete an action node */ -static void delete_action __P1 (actionnode **,nodep) +static void delete_action(actionnode **nodep) { if (opt_info) { PRINTF("#deleting action: >%c%s %s\n", (*nodep)->active ? @@ -244,7 +245,7 @@ static void delete_action __P1 (actionnode **,nodep) /* * delete a prompt node */ -static void delete_prompt __P1 (actionnode **,nodep) +static void delete_prompt(actionnode **nodep) { if (opt_info) { PRINTF("#deleting prompt: >%c%s %s\n", (*nodep)->active ? @@ -256,11 +257,11 @@ static void delete_prompt __P1 (actionnode **,nodep) /* * create new action */ -static void add_new_action __P6 (char *,label, char *,pattern, char *,command, int,active, int,type, void *,q) +static void add_new_action(char *label, char *pattern, char *command, int active, int type, void *q) { add_actionnode(pattern, command, label, active, type, q); if (opt_info) { - PRINTF("#new action: %c%c%s %s=%s\n", + PRINTF("#new action: %c%c%s %s=%s\n", action_chars[type], active ? '+' : '-', label, pattern, command); @@ -270,11 +271,11 @@ static void add_new_action __P6 (char *,label, char *,pattern, char *,command, i /* * create new prompt */ -static void add_new_prompt __P6 (char *,label, char *,pattern, char *,command, int,active, int,type, void *,q) +static void add_new_prompt(char *label, char *pattern, char *command, int active, int type, void *q) { add_promptnode(pattern, command, label, active, type, q); if (opt_info) { - PRINTF("#new prompt: %c%c%s %s=%s\n", + PRINTF("#new prompt: %c%c%s %s=%s\n", action_chars[type], active ? '+' : '-', label, pattern, command); @@ -284,7 +285,7 @@ static void add_new_prompt __P6 (char *,label, char *,pattern, char *,command, i /* * add an action with numbered label */ -static void add_anonymous_action __P4 (char *,pattern, char *,command, int,type, void *,q) +static void add_anonymous_action(char *pattern, char *command, int type, void *q) { static int last = 0; char label[16]; @@ -300,7 +301,7 @@ static void add_anonymous_action __P4 (char *,pattern, char *,command, int,type, * change fields of an existing action node * pattern or commands can be NULL if no change */ -static void change_actionorprompt __P6 (actionnode *,node, char *,pattern, char *,command, int,type, void *,q, int,onprompt) +static void change_actionorprompt(actionnode *node, char *pattern, char *command, int type, void *q, int onprompt) { #ifdef USE_REGEXP if (node->type == ACTION_REGEXP && node->regexp) { @@ -318,7 +319,7 @@ static void change_actionorprompt __P6 (actionnode *,node, char *,pattern, char free(node->command); node->command = my_strdup(command); } - + if (opt_info) { PRINTF("#changed %s %c%c%s %s=%s\n", ONPROMPT, action_chars[node->type], @@ -330,10 +331,10 @@ static void change_actionorprompt __P6 (actionnode *,node, char *,pattern, char /* * show defined actions */ -void show_actions __P0 (void) +void show_actions(void) { actionnode *p; - + PRINTF("#%s action%s defined%c\n", actions ? "the following" : "no", (actions && !actions->next) ? " is" : "s are", actions ? ':' : '.'); for (p = actions; p; p = p->next) @@ -341,7 +342,7 @@ void show_actions __P0 (void) action_chars[p->type], p->active ? '+' : '-', p->label, group_delim, - p->group == NULL ? "*" : p->group, + p->group == NULL ? "*" : p->group, p->pattern, p->command); } @@ -349,10 +350,10 @@ void show_actions __P0 (void) /* * show defined prompts */ -void show_prompts __P0 (void) +void show_prompts(void) { promptnode *p; - + PRINTF("#%s prompt%s defined%c\n", prompts ? "the following" : "no", (prompts && !prompts->next) ? " is" : "s are", prompts ? ':' : '.'); for (p = prompts; p; p = p->next) @@ -367,22 +368,22 @@ void show_prompts __P0 (void) * this function is too damn complex because of the hairy syntax. it should be * split up or rewritten as an fsm instead. */ -void parse_action __P2 (char *,str, int,onprompt) +void parse_action(char *str, int onprompt) { char *p, label[BUFSIZE], pattern[BUFSIZE], *command, *group; actionnode **np = NULL; char sign, assign, hastail; char active, type = ACTION_WEAK, kind; void *regexp = 0; - + sign = *(p = skipspace(str)); if (!sign) { PRINTF("%s: no arguments given\n", ONPROMPT); return; } - + str = p + 1; - + switch (sign) { case '+': case '-': /* edit */ @@ -394,7 +395,7 @@ void parse_action __P2 (char *,str, int,onprompt) type = ACTION_REGEXP; /* falltrough */ case '>': /* action_chars[ACTION_WEAK] */ - + /* define/edit */ assign = '>'; sign = *(p + 1); @@ -411,7 +412,7 @@ void parse_action __P2 (char *,str, int,onprompt) str = p; break; } - + /* labelled action: */ if (assign != 0) { p = first_regular(str, ' '); @@ -424,11 +425,11 @@ void parse_action __P2 (char *,str, int,onprompt) *group = 0; group += strlen( group_delim ); } - + my_strncpy(label, str, BUFSIZE-1); if (hastail) *p++ = ' '; /* p points to start of pattern, or to \0 */ - + if (!*label) { PRINTF("#%s: label expected\n", ONPROMPT); return; @@ -439,7 +440,7 @@ void parse_action __P2 (char *,str, int,onprompt) np = lookup_prompt(label); else np = lookup_action(label); - + /* '<' : remove action */ if (assign == '<') { if (!np || !*np) { @@ -452,26 +453,26 @@ void parse_action __P2 (char *,str, int,onprompt) else delete_action(np); } - + /* '>' : define action */ } else if (assign == '>') { #ifndef USE_REGEXP if (type == ACTION_REGEXP) { PRINTF("#error: regexp not allowed\n"); return; - } + } #endif - + if (sign == '+') active = 1; else active = 0; - + if (!*label) { PRINTF("#%s: label expected\n", ONPROMPT); return; } - + p = skipspace(p); if (*p == '(') { ptr pbuf = (ptr)0; @@ -500,21 +501,21 @@ void parse_action __P2 (char *,str, int,onprompt) if ((hastail = *p)) *p = '\0'; my_strncpy(pattern, command, BUFSIZE-1); - + if (hastail) *p++ = '='; } - + if (!*pattern) { PRINTF("#error: pattern of #%ss must be non-empty.\n", ONPROMPT); return; } - + #ifdef USE_REGEXP if (type == ACTION_REGEXP && hastail) { int errcode; char unesc_pat[BUFSIZE]; - + /* * HACK WARNING: * we unescape regexp patterns now, instead of doing @@ -522,13 +523,13 @@ void parse_action __P2 (char *,str, int,onprompt) */ strcpy(unesc_pat, pattern); unescape(unesc_pat); - - regexp = malloc(sizeof(regex_t)); + + regexp = malloc(sizeof(regex_t)); if (!regexp) { errmsg("malloc"); return; } - + if ((errcode = regcomp((regex_t *)regexp, unesc_pat, REG_EXTENDED))) { int n; char *tmp; @@ -552,17 +553,17 @@ void parse_action __P2 (char *,str, int,onprompt) } #endif command = p; - + if (hastail) { if (np && *np) { change_actionorprompt(*np, pattern, command, type, regexp, onprompt); (*np)->active = active; } else { if (onprompt) - add_new_prompt(label, pattern, command, active, + add_new_prompt(label, pattern, command, active, type, regexp); else - add_new_action(label, pattern, command, active, + add_new_action(label, pattern, command, active, type, regexp); } @@ -582,7 +583,7 @@ void parse_action __P2 (char *,str, int,onprompt) (*np) -> group = my_strdup( group ); } } - + /* '=': list action */ } else if (assign == '='){ if (np && *np) { @@ -596,7 +597,7 @@ void parse_action __P2 (char *,str, int,onprompt) } else { PRINTF("#no %s, cannot list label: \"%s\"\n", ONPROMPT, label); } - + /* '+', '-': turn action on/off */ } else { if (np && *np) { @@ -612,17 +613,17 @@ void parse_action __P2 (char *,str, int,onprompt) (sign == '+') ? "n" : "ff", label); } } - + /* anonymous action, cannot be regexp */ } else { - + if (onprompt) { PRINTF("#anonymous prompts not supported.\n#please use labelled prompts.\n"); return; } - + command = first_regular(str, '='); - + if (*command == '=') { *command = '\0'; @@ -660,7 +661,7 @@ void parse_action __P2 (char *,str, int,onprompt) /* * display attribute syntax */ -void show_attr_syntax __P0 (void) +void show_attr_syntax(void) { int i; PRINTF("#attribute syntax:\n\tOne or more of:\tbold, blink, underline, inverse\n\tand/or\t[foreground] [ON background]\n\tColors: "); @@ -673,17 +674,17 @@ void show_attr_syntax __P0 (void) /* * put escape sequences to turn on/off an attribute in given buffers */ -void attr_string __P3 (int,attrcode, char *,begin, char *,end) +void attr_string(int attrcode, char *begin, char *end) { int fg = FOREGROUND(attrcode), bg = BACKGROUND(attrcode), tok = ATTR(attrcode); char need_end = 0; *begin = *end = '\0'; - + if (tok > (ATTR_BOLD | ATTR_BLINK | ATTR_UNDERLINE | ATTR_INVERSE) || fg > COLORS || bg > COLORS || attrcode == NOATTRCODE) return; /* do nothing */ - + if (fg < COLORS) { if (bg < COLORS) { sprintf(begin, "\033[%c%d;%s%dm", @@ -700,13 +701,13 @@ void attr_string __P3 (int,attrcode, char *,begin, char *,end) #endif } } else if (bg < COLORS) { - sprintf(begin, "\033[%s%dm", + sprintf(begin, "\033[%s%dm", bg<LOWCOLORS ? "4" : "10", bg % LOWCOLORS); #ifdef TERM_LINUX strcpy(end, "\033[49m"); #endif } - + #ifndef TERM_LINUX if (fg < COLORS || bg < COLORS) need_end = 1; @@ -725,7 +726,7 @@ void attr_string __P3 (int,attrcode, char *,begin, char *,end) strcpy(end, tty_modestandoff); } } - + if (tok & ATTR_BLINK) { if (tty_modeblink[0]) { strcat(begin, tty_modeblink); @@ -739,7 +740,7 @@ void attr_string __P3 (int,attrcode, char *,begin, char *,end) strcpy(end, tty_modestandoff); } } - + if (tok & ATTR_UNDERLINE) { if (tty_modeuline[0]) { strcat(begin, tty_modeuline); @@ -753,7 +754,7 @@ void attr_string __P3 (int,attrcode, char *,begin, char *,end) strcpy(end, tty_modestandoff); } } - + if (tok & ATTR_INVERSE) { if (tty_modeinv[0]) { strcat(begin, tty_modeinv); @@ -778,16 +779,16 @@ void attr_string __P3 (int,attrcode, char *,begin, char *,end) * parse attribute description in line. * Return attribute if successful, -1 otherwise. */ -int parse_attributes __P1 (char *,line) +int parse_attributes(char *line) { char *p; int tok = 0, fg, bg, t = -1; - + if (!(p = strtok(line, " "))) return NOATTRCODE; - + fg = bg = NO_COLOR; - + while (t && p) { if (!strcasecmp(p, "bold")) t = ATTR_BOLD; @@ -799,39 +800,39 @@ int parse_attributes __P1 (char *,line) t = ATTR_INVERSE; else t = 0; - - if (t) { + + if (t) { tok |= t; p = strtok(NULL, " "); } } - + if (!p) return ATTRCODE(tok, fg, bg); - + for (t = 0; t <= COLORS && strcmp(p, colornames[t]); t++) ; if (t <= COLORS) { fg = t; p = strtok(NULL, " "); } - + if (!p) return ATTRCODE(tok, fg, bg); - + if (strcasecmp(p, "on")) return -1; /* invalid attribute */ - + if (!(p = strtok(NULL, " "))) return -1; - + for (t = 0; t <= COLORS && strcmp(p, colornames[t]); t++) ; if (t <= COLORS) bg = t; else return -1; - + return ATTRCODE(tok, fg, bg); } @@ -839,15 +840,15 @@ int parse_attributes __P1 (char *,line) /* * return a static pointer to name of given attribute code */ -char *attr_name __P1 (int,attrcode) +char *attr_name(int attrcode) { static char name[BUFSIZE]; int fg = FOREGROUND(attrcode), bg = BACKGROUND(attrcode), tok = ATTR(attrcode); - + name[0] = 0; if (tok > (ATTR_BOLD | ATTR_BLINK | ATTR_UNDERLINE | ATTR_INVERSE) || fg > COLORS || bg > COLORS) return name; /* error! */ - + if (tok & ATTR_BOLD) strcat(name, "bold "); if (tok & ATTR_BLINK) @@ -856,25 +857,25 @@ char *attr_name __P1 (int,attrcode) strcat(name, "underline "); if (tok & ATTR_INVERSE) strcat(name, "inverse "); - + if (fg < COLORS || (fg == bg && fg == COLORS && !tok)) strcat(name, colornames[fg]); - + if (bg < COLORS) { strcat(name, " on "); strcat(name, colornames[bg]); } - + if (!*name) strcpy(name, "none"); - + return name; } /* * show defined marks */ -void show_marks __P0 (void) +void show_marks(void) { marknode *p; PRINTF("#%s marker%s defined%c\n", markers ? "the following" : "no", @@ -889,12 +890,12 @@ void show_marks __P0 (void) /* * parse arguments to the #mark command */ -void parse_mark __P1 (char *,str) +void parse_mark(char *str) { char *p; marknode **np, *n; char mbeg = 0; - + if (*str == '=') { PRINTF("#marker must be non-null.\n"); return; @@ -918,7 +919,7 @@ void parse_mark __P1 (char *,str) } else { PRINTF("#unknown marker, cannot show: \"%s\"\n", str); } - + } else { int attrcode, wild = 0; char pattern[BUFSIZE], *p2; @@ -983,11 +984,11 @@ void parse_mark __P1 (char *,str) * into raw escape sequence * return pointer to end of ASCII description */ -static char *unescape_seq __P3 (char *,buf, char *,seq, int *,seqlen) +static char *unescape_seq(char *buf, char *seq, int *seqlen) { char c, *start = buf; enum { NORM, ESCSINGLE, ESCAPE, CARET, DONE } state = NORM; - + for (; (c = *seq); seq++) { switch (state) { case NORM: @@ -1019,7 +1020,7 @@ static char *unescape_seq __P3 (char *,buf, char *,seq, int *,seqlen) */ if (state == ESCSINGLE && ISODIGIT(seq[0]) && ISODIGIT(seq[1]) && ISODIGIT(seq[2])) { - *(buf++) =(((seq[0] - '0') << 6) | + *(buf++) =(((seq[0] - '0') << 6) | ((seq[1] - '0') << 3) | (seq[2] - '0')); seq += 2; @@ -1047,13 +1048,13 @@ static char *unescape_seq __P3 (char *,buf, char *,seq, int *,seqlen) * timeout == 0 means wait indefinitely (no timeout). * return char or -1 if timeout was reached. */ -static int get_one_char __P1 (int,timeout) +static int get_one_char(int timeout) { struct timeval timeoutbuf; fd_set fds; int n; char c; - + again: FD_ZERO(&fds); FD_SET(tty_read_fd, &fds); @@ -1086,7 +1087,7 @@ static int get_one_char __P1 (int,timeout) /* * print an escape sequence in human-readably form. */ -void print_seq __P2 (char *,seq, int,len) +void print_seq(char *seq, int len) { while (len--) { unsigned char ch = *(seq++); @@ -1113,14 +1114,14 @@ void print_seq __P2 (char *,seq, int,len) * return a static pointer to escape sequence made printable, for use in * definition-files */ -char *seq_name __P2 (char *,seq, int,len) +char *seq_name(char *seq, int len) { static char buf[CAPLEN*4]; char *p = buf; /* * rules: control chars are written as ^X, where * X is char | 64 - * + * * GH: codes > 0x80 ==> octal \012 * * special case: 0x7f is written ^? @@ -1129,7 +1130,7 @@ char *seq_name __P2 (char *,seq, int,len) unsigned char c = *seq++; if (c == '^' || (c && strchr(SPECIAL_CHARS, c))) *(p++) = ESC; - + if (c < ' ') { *(p++) = '^'; *(p++) = c | '@'; @@ -1151,11 +1152,11 @@ char *seq_name __P2 (char *,seq, int,len) * read a single escape sequence from the keyboard * prompting user for it; return static pointer */ -char *read_seq __P2 (char *,name, int *,len) +char *read_seq(char *name, int *len) { static char seq[CAPLEN]; int i = 1, tmp; - + PRINTF("#please press the key \"%s\" : ", name); tty_flush(); @@ -1165,13 +1166,13 @@ char *read_seq __P2 (char *,name, int *,len) tty_puts("#unable to get key. Giving up.\n"); return NULL; } - + while (i < CAPLEN - 1 && (tmp = get_one_char(KBD_TIMEOUT)) >= 0) seq[i++] = tmp; *len = i; print_seq(seq, i); - + tty_putc('\n'); if (seq[0] >= ' ' && seq[0] <= '~') { PRINTF("#that is not a redefinable key.\n"); @@ -1184,7 +1185,7 @@ char *read_seq __P2 (char *,name, int *,len) * show full definition of one binding, * with custom message */ -static void show_single_bind __P2 (char *,msg, keynode *,p) +static void show_single_bind(char *msg, keynode *p) { if (p->funct == key_run_command) { PRINTF("#%s %s %s=%s\n", msg, p->name, @@ -1201,7 +1202,7 @@ static void show_single_bind __P2 (char *,msg, keynode *,p) /* * list keyboard bindings */ -void show_binds __P1 (char,edit) +void show_binds(char edit) { keynode *p; int count = 0; @@ -1227,29 +1228,29 @@ void show_binds __P1 (char,edit) /* * interactively create a new keybinding */ -static void define_new_key __P2 (char *,name, char *,command) +static void define_new_key(char *name, char *command) { char *seq, *arg; keynode *p; int seqlen, function; - + seq = read_seq(name, &seqlen); if (!seq) return; - + for (p = keydefs; p; p = p->next) /* GH: don't allow binding of supersets of another bind */ if (!memcmp(p->sequence, seq, MIN2(p->seqlen, seqlen))) { show_single_bind("key already bound as:", p); return; } - + function = lookup_edit_name(command, &arg); if (function) add_keynode(name, seq, seqlen, internal_functions[function].funct, arg); else add_keynode(name, seq, seqlen, key_run_command, command); - + if (opt_info) { PRINTF("#new key binding: %s %s=%s\n", name, seq_name(seq, seqlen), command); @@ -1259,12 +1260,12 @@ static void define_new_key __P2 (char *,name, char *,command) /* * parse the #bind command non-interactively. */ -static void parse_bind_noninteractive __P1 (char *,arg) +static void parse_bind_noninteractive(char *arg) { char rawseq[CAPLEN], *p, *seq, *params; int function, seqlen; keynode **kp; - + p = strchr(arg, ' '); if (!p) { PRINTF("#syntax error: \"#bind %s\"\n", arg); @@ -1272,24 +1273,24 @@ static void parse_bind_noninteractive __P1 (char *,arg) } *(p++) = '\0'; seq = p = skipspace(p); - + p = unescape_seq(rawseq, p, &seqlen); if (!p[0] || !p[1]) { PRINTF("#syntax error: \"#bind %s %s\"\n", arg, seq); return; } *p++ = '\0'; - + kp = lookup_key(arg); if (kp && *kp) delete_keynode(kp); - + if ((function = lookup_edit_name(p, ¶ms))) - add_keynode(arg, rawseq, seqlen, + add_keynode(arg, rawseq, seqlen, internal_functions[function].funct, params); else add_keynode(arg, rawseq, seqlen, key_run_command, p); - + if (opt_info) { PRINTF("#%s: %s %s=%s\n", (kp && *kp) ? "redefined key" : "new key binding", @@ -1300,22 +1301,22 @@ static void parse_bind_noninteractive __P1 (char *,arg) /* * parse the argument of the #bind command (interactive) */ -void parse_bind __P1 (char *,arg) +void parse_bind(char *arg) { char *p, *q, *command, *params; char *name = arg; keynode **npp, *np; int function; - + p = first_valid(arg, '='); q = first_valid(arg, ' '); q = skipspace(q); - - if (*p && *q && p > q) { + + if (*p && *q && p > q) { parse_bind_noninteractive(arg); return; } - + if (*p) { *(p++) = '\0'; np = *(npp = lookup_key(name)); @@ -1354,7 +1355,7 @@ void parse_bind __P1 (char *,arg) int seqlen; seqname = seq_name(np->sequence, np->seqlen); seqlen = strlen(seqname); - + if (np->funct == key_run_command) sprintf(inserted_next, "#bind %.*s %s=%.*s", BUFSIZE-seqlen-9, name, seqname, @@ -1374,30 +1375,30 @@ void parse_bind __P1 (char *,arg) } } -void parse_rebind __P1 (char *,arg) +void parse_rebind(char *arg) { char rawseq[CAPLEN], *seq, **old; keynode **kp, *p; int seqlen; - + arg = skipspace(arg); if (!*arg) { PRINTF("#rebind: missing key.\n"); return; } - + seq = first_valid(arg, ' '); if (*seq) { *seq++ = '\0'; seq = skipspace(seq); } - + kp = lookup_key(arg); if (!kp || !*kp) { PRINTF("#no such key: \"%s\"\n", arg); return; } - + if (!*seq) { seq = read_seq(arg, &seqlen); if (!seq) @@ -1415,7 +1416,7 @@ void parse_rebind __P1 (char *,arg) return; } } - + old = &((*kp)->sequence); if (*old) free(*old); @@ -1432,24 +1433,24 @@ void parse_rebind __P1 (char *,arg) * if needed, use/malloc "pbuf" as buffer (on error, also free pbuf) * return resulting char * */ -char *redirect __P7 (char *,arg, ptr *,pbuf, char *,kind, char *,name, int,also_num, long *,start, long *,end) +char *redirect(char *arg, ptr *pbuf, char *kind, char *name, int also_num, long *start, long *end) { char *tmp = skipspace(arg), k; int type, i; - + if (!pbuf) { print_error(error=INTERNAL_ERROR); return NULL; } - + k = *tmp; if (k == '!' || k == '<') arg = ++tmp; else k = 0; - + *start = *end = 0; - + if (*tmp=='(') { arg = tmp + 1; @@ -1464,7 +1465,7 @@ char *redirect __P7 (char *,arg, ptr *,pbuf, char *,kind, char *,name, int,also_ } for (i=0; i<2; i++) if (*arg == CMDSEP) { long buf; - + arg++; if (!i && *arg == CMDSEP) { *start = 1; @@ -1474,7 +1475,7 @@ char *redirect __P7 (char *,arg, ptr *,pbuf, char *,kind, char *,name, int,also_ *end = LONG_MAX; continue; } - + type = evall(&buf, &arg); if (!REAL_ERROR && type != TYPE_NUM) error=NO_NUM_VALUE_ERROR; @@ -1510,19 +1511,19 @@ char *redirect __P7 (char *,arg, ptr *,pbuf, char *,kind, char *,name, int,also_ *start = 1; } else unescape(arg); - + *kind = k; return arg; } -void show_vars __P0 (void) -{ +void show_vars(void) +{ varnode *v; int i, type; ptr p = (ptr)0; - + PRINTF("#the following variables are defined:\n"); - + for (type = 0; !REAL_ERROR && type < 2; type++) { reverse_sortedlist((sortednode **)&sortednamed_vars[type]); v = sortednamed_vars[type]; @@ -1556,7 +1557,7 @@ void show_vars __P0 (void) ptrdel(p); } -void show_delaynode __P2 (delaynode *,p, int,in_or_at) +void show_delaynode(delaynode *p, int in_or_at) { long d; struct tm *s; @@ -1564,10 +1565,10 @@ void show_delaynode __P2 (delaynode *,p, int,in_or_at) update_now(); d = diff_vtime(&p->when, &now); - s = localtime((time_t *)&p->when.tv_sec); + s = localtime((time_t *)&p->when.tv_sec); /* s now points to a calendar struct */ if (in_or_at) { - + if (in_or_at == 2) { /* write time in buf */ (void)strftime(buf, BUFSIZE - 1, "%H%M%S", s); @@ -1585,12 +1586,12 @@ void show_delaynode __P2 (delaynode *,p, int,in_or_at) } } -void show_delays __P0 (void) +void show_delays(void) { delaynode *p; int n = (delays ? delays->next ? 2 : 1 : 0) + (dead_delays ? dead_delays->next ? 2 : 1 : 0); - + PRINTF("#%s delay label%s defined%c\n", n ? "the following" : "no", n == 1 ? " is" : "s are", n ? ':' : '.'); for (p = delays; p; p = p->next) @@ -1599,10 +1600,10 @@ void show_delays __P0 (void) show_delaynode(p, 0); } -void change_delaynode __P3 (delaynode **,p, char *,command, long,millisec) +void change_delaynode(delaynode **p, char *command, long millisec) { delaynode *m=*p; - + *p = m->next; m->when.tv_usec = (millisec % mSEC_PER_SEC) * uSEC_PER_mSEC; m->when.tv_sec = millisec / mSEC_PER_SEC; @@ -1626,11 +1627,11 @@ void change_delaynode __P3 (delaynode **,p, char *,command, long,millisec) } } -void new_delaynode __P3 (char *,name, char *,command, long,millisec) +void new_delaynode(char *name, char *command, long millisec) { vtime t; delaynode *node; - + t.tv_usec = (millisec % mSEC_PER_SEC) * uSEC_PER_mSEC; t.tv_sec = millisec / mSEC_PER_SEC; update_now(); @@ -1642,15 +1643,15 @@ void new_delaynode __P3 (char *,name, char *,command, long,millisec) } } -void show_history __P1 (int,count) +void show_history(int count) { int i = curline; - + if (!count) count = lines - 1; if (count >= MAX_HIST) count = MAX_HIST - 1; i -= count; if (i < 0) i += MAX_HIST; - + while (count) { if (hist[i]) { PRINTF("#%2d: %s\n", count, hist[i]); @@ -1660,11 +1661,11 @@ void show_history __P1 (int,count) } } -void exe_history __P1 (int,count) +void exe_history(int count) { int i = curline; char buf[BUFSIZE]; - + if (count >= MAX_HIST) count = MAX_HIST - 1; i -= count; |