int dcl_recall(PARAM_T *p,PARAM_T *q) { char token[MAX_TOKEN]; char sel[MAX_TOKEN]; int i = 0; int retcod = 0; int f_all = 0; int f_erase = 0; int f_save = 0; NEXT_LINE(); if (cmd[C].subr) return(0); if (!dcl[D].cc[dcl[D].ccl]) return(0); if (mode != MODE_INTERACTIVE || D != 1) return(0); if (p == NULL || q == NULL) return(DCL_ERROR); (void)mkcdptr(cmd_stack,1); (void)deln(cmd_stack); *token = 0; *sel = 0; (void)cmd_parse_line(dcl_line,RECALL_PARAM,RECALL_QUAL,p,q); for (i = 0; q[i].tag; i++) { if (q[i].flag & PRESENT) switch (q[i].tag) { case 1: /* /ALL */ f_all = TRUE; break; case 2: /* /ERASE */ f_erase = TRUE; break; case 3: /* /SAVE */ f_save = TRUE; break; default: ; } /* end switch */ } /* end for */ dcl_string(p[0].value,sel,MAX_TOKEN); if (f_all){ (void)mkcdptr(cmd_stack,0); while (nextdptr(cmd_stack,token)) { (void) dcl_printf(dcl[D].SYS_OUTPUT,"%3d %s\n",ncur(cmd_stack),token); } goto exit_label; } if (f_save){ FILE *fp = fopen(history_filename, "w"); char buffer[1024]; if (fp != NULL) { (void)mkcdptr(cmd_stack,0); //cmd_stack->nodes while(prevdptr(cmd_stack,buffer)) { fprintf(fp, "%s\n", buffer); } (void)fclose(fp); } goto exit_label; } if (f_erase){ (void) clrFlist(cmd_stack); goto exit_label; } i = 1; if (*sel){ i = atoi(sel); if (i) { if (i < 1 || i > MAX_KBD_STACK){ (void) dcl_printf(dcl[D].SYS_OUTPUT,"Invalid value\n"); _SEVERITY = 2; _STATUS = 19; retcod = -1; goto exit_label; } if (i > (int) nempty(cmd_stack)) i = (int) nempty(cmd_stack); } else { (void) mkcdptr(cmd_stack,0); while (nextdptr(cmd_stack,token)) { if (strncasecmp(token,sel,strlen(sel)) == 0) { i = (int)ncur(cmd_stack); break; } } if (i == 0) { (void) dcl_printf(dcl[D].SYS_OUTPUT,"No command found\n"); _SEVERITY = 2; _STATUS = 19; retcod = -1; goto exit_label; } } } if (rcld(cmd_stack,dcl_line,(unsigned int)i)){ recall = 1; } else { dcl_line[0] = 0; } exit_label: return(retcod); }
int dump(char *fname) { Flist df, newdf; char c, *txt; int i, r, n; if ((df = loaddf(fname)) == (Flist) 0) return 1; for (c = -Home; c != ESC; c = getPC()) { switch (c) { case -PgDn: if (ncur(df) < nempty(df)) txt = nextdptr(df,(void *) 0); else continue; break; case -PgUp: if (ncur(df) > 1) txt = prevdptr(df,(void *) 0); else continue; break; case -Home: txt = mkcdptr(df,1); break; case -EndKey: txt = mkcdptr(df,nempty(df)); break; case -F1: textcolor(mcolor); textbackground(mbgrd); gotoxy(1,25); clreol(); cprintf("Keys: PgUp, PgDn, Home = top," " End = bottom, F3 = new file, ESC = Quit"); continue; case -F3: if ((newdf = loaddf(newFile())) != (Flist) 0) { rmFlist(&df); df = newdf; txt = mkcdptr(df,1); } break; default: continue; } textcolor(color); textbackground(bgrd); window(1,1,80,24); clrscr(); cprintf(" Addr Dword Dword " " Dword Dword ASCII" "\n\r\n\r\n\r"); for (n = ncur(df) - 1, r = 0; r < 16; r++, txt += 16) { cprintf("\n\r%06x ",n * NSIZE + r * 16); for (i = 0; i < 16; i++) { if (i % 4 == 0) putch(' '); cprintf("%02X ",(unsigned char) txt[i]); } cprintf(" "); for (i = 0; i < 16; i++) switch (txt[i]) { case 7: case 8: case 9: case 10: case 13: putch(' '); break; default: if (txt[i] < 26) { /* ctrl char */ textcolor(ccolor); textbackground(cbgrd); putch(txt[i] + 'A' - 1); textcolor(color); textbackground(bgrd); } else putch(txt[i]); } } textcolor(mcolor); textbackground(mbgrd); window(1,1,80,25); gotoxy(1,25); clreol(); cprintf("Dump file: %s",(char *) Flistdptr(df)); } rmFlist(&df); return 0; }