int main(int argc, char **argv) { struct text_info ti; FILE *f; char buf[BUF_SIZE*2]; /* Room for lfexpand */ int len; int speed; char *scrollbuf; char *infile=NULL; char title[MAX_PATH+1]; int expand=0; int i; textmode(C80); gettextinfo(&ti); if((scrollbuf=malloc(SCROLL_LINES*ti.screenwidth*2))==NULL) { cprintf("Cannot allocate memory\n\n\rPress any key to exit."); getch(); return(-1); } /* Parse command line */ for(i=1; i<argc; i++) { if(argv[i][0]=='-') { if(argv[i][1]=='l' && argv[i][2]==0) expand=1; else goto usage; } else { if(infile==NULL) infile=argv[i]; else goto usage; } } cterm_init(ti.screenheight, ti.screenwidth, 0, 0, SCROLL_LINES, scrollbuf); if(infile) { if((f=fopen(infile,"r"))==NULL) { cprintf("Cannot read %s\n\n\rPress any key to exit.",argv[1]); getch(); return(-1); } sprintf(title,"SyncView: %s",getfname(argv[1])); } else { f=stdin; strcpy(title,"SyncView: [stdin]"); } settitle(title); while((len=fread(buf, 1, BUF_SIZE, f))!=0) { if(expand) lfexpand(buf, &len); cterm_write(buf, len, NULL, 0, &speed); } viewscroll(); return(0); usage: cprintf("Usage: %s [-l] [filename]\r\n\r\n" "Displays the ANSI file filename expanding \\n to \\r\\n if -l is specified.\r\n" "If no filename is specified, reads input from stdin\r\n" "\r\n" "Press any key to exit."); getch(); return(-1); }
int main(int argc, char **argv) { struct text_info ti; FILE *f; char buf[BUF_SIZE*2]; /* Room for lfexpand */ int len; int speed=0; char *scrollbuf; char *infile=NULL; char title[MAX_PATH+1]; int expand=0; int ansi=0; int i; /* Parse command line */ for(i=1; i<argc; i++) { if(argv[i][0]=='-') { if(argv[i][1]=='l' && argv[i][2]==0) expand=1; else if(argv[i][1]=='a' && argv[i][2]==0) ansi=1; else goto usage; } else { if(infile==NULL) infile=argv[i]; else goto usage; } } if(ansi) { initciolib(CIOLIB_MODE_ANSI); puts("START OF ANSI..."); } textmode(C80); gettextinfo(&ti); if((scrollbuf=malloc(SCROLL_LINES*ti.screenwidth*2))==NULL) { cprintf("Cannot allocate memory\n\n\rPress any key to exit."); getch(); return(-1); } cterm=cterm_init(ti.screenheight, ti.screenwidth, 1, 1, SCROLL_LINES, scrollbuf, CTERM_EMULATION_ANSI_BBS); if(!cterm) { fputs("ERROR Initializing CTerm!\n", stderr); return 1; } if(infile) { if((f=fopen(infile,"r"))==NULL) { cprintf("Cannot read %s\n\n\rPress any key to exit.",argv[1]); getch(); return(-1); } sprintf(title,"SyncView: %s",getfname(argv[1])); } else { f=stdin; strcpy(title,"SyncView: [stdin]"); } settitle(title); while((len=fread(buf, 1, BUF_SIZE, f))!=0) { if(expand) lfexpand(buf, &len); cterm_write(cterm, buf, len, NULL, 0, &speed); } if(ansi) { puts(""); puts("END OF ANSI"); gettext(1,1,ti.screenwidth,ti.screenheight,scrollbuf); puttext_can_move=1; puts("START OF SCREEN DUMP..."); clrscr(); puttext(1,1,ti.screenwidth,ti.screenheight,scrollbuf); } else viewscroll(); return(0); usage: cprintf("Usage: %s [-l] [-a] [filename]\r\n\r\n" "Displays the ANSI file filename expanding \\n to \\r\\n if -l is specified.\r\n" "If no filename is specified, reads input from stdin\r\n" "If -a is specified, outputs ANSI to stdout\r\n" "\r\n" "Press any key to exit."); getch(); return(-1); }