X-Git-Url: https://git.gag.com/?p=debian%2Fcpmtools;a=blobdiff_plain;f=fsed.cpm.c;fp=fsed.cpm.c;h=f4d4235e0e8b33eb01c2464370132cfe122fecc8;hp=f120b77c4a364749a3cdc119469acd710576a24b;hb=0244ff6db7cb417c6210118e14ebc8a11924b7f6;hpb=be51a0b47ec4edacc689851a88ec6172737cb61c diff --git a/fsed.cpm.c b/fsed.cpm.c index f120b77..f4d4235 100644 --- a/fsed.cpm.c +++ b/fsed.cpm.c @@ -3,15 +3,6 @@ #include #include -#if NEED_NCURSES -#if HAVE_NCURSES_NCURSES_H -#include -#else -#include -#endif -#else -#include -#endif #include #include #include @@ -20,10 +11,7 @@ #include "cpmfs.h" #include "getopt_.h" - -#ifdef USE_DMALLOC -#include -#endif +#include "term.h" /*}}}*/ extern char **environ; @@ -64,33 +52,34 @@ static void info(struct cpmSuperBlock *sb, const char *format, const char *image { const char *msg; - clear(); + term_clear(); msg="File system characteristics"; - move(0,(COLS-strlen(msg))/2); printw(msg); - move(2,0); printw(" Image: %s",image); - move(3,0); printw(" Format: %s",format); - move(4,0); printw(" File system: "); + term_xy((term_cols()-strlen(msg))/2,0); term_printf(msg); + term_xy(0,2); term_printf(" Image: %s",image); + term_xy(0,3); term_printf(" Format: %s",format); + term_xy(0,4); term_printf(" File system: "); switch (sb->type) { - case CPMFS_DR22: printw("CP/M 2.2"); break; - case CPMFS_P2DOS: printw("P2DOS 2.3"); break; - case CPMFS_DR3: printw("CP/M Plus"); break; + case CPMFS_DR22: term_printf("CP/M 2.2"); break; + case CPMFS_P2DOS: term_printf("P2DOS 2.3"); break; + case CPMFS_DR3: term_printf("CP/M Plus"); break; } - move(6,0); printw(" Sector length: %d",sb->secLength); - move(7,0); printw(" Number of tracks: %d",sb->tracks); - move(8,0); printw(" Sectors per track: %d",sb->sectrk); + term_xy(0,6); term_printf(" Sector length: %d",sb->secLength); + term_xy(0,7); term_printf(" Number of tracks: %d",sb->tracks); + term_xy(0,8); term_printf(" Sectors per track: %d",sb->sectrk); - move(10,0);printw(" Block size: %d",sb->blksiz); - move(11,0);printw("Number of directory entries: %d",sb->maxdir); - move(12,0);printw(" Logical sector skew: %d",sb->skew); - move(13,0);printw(" Number of system tracks: %d",sb->boottrk); - move(14,0);printw(" Logical extents per extent: %d",sb->extents); - move(15,0);printw(" Allocatable data blocks: %d",sb->size-(sb->maxdir*32+sb->blksiz-1)/sb->blksiz); + term_xy(0,10);term_printf(" Block size: %d",sb->blksiz); + term_xy(0,11);term_printf("Number of directory entries: %d",sb->maxdir); + term_xy(0,12);term_printf(" Number of directory blocks: %d",sb->dirblks); + term_xy(0,13);term_printf(" Logical sector skew: %d",sb->skew); + term_xy(0,14);term_printf(" Number of system tracks: %d",sb->boottrk); + term_xy(0,15);term_printf(" Logical extents per extent: %d",sb->extents); + term_xy(0,16);term_printf(" Allocatable data blocks: %d",sb->size-(sb->maxdir*32+sb->blksiz-1)/sb->blksiz); msg="Any key to continue"; - move(23,(COLS-strlen(msg))/2); printw(msg); - getch(); + term_xy((term_cols()-strlen(msg))/2,23); term_printf(msg); + term_getch(); } /*}}}*/ static void map(struct cpmSuperBlock *sb) /*{{{*/ @@ -100,9 +89,9 @@ static void map(struct cpmSuperBlock *sb) /*{{{*/ int secmap,sys,directory; int pos; - clear(); + term_clear(); msg="Data map"; - move(0,(COLS-strlen(msg))/2); printw(msg); + term_xy((term_cols()-strlen(msg))/2,0); term_printf(msg); secmap=(sb->tracks*sb->sectrk+80*18-1)/(80*18); memset(bmap,' ',sizeof(bmap)); @@ -128,7 +117,7 @@ static void map(struct cpmSuperBlock *sb) /*{{{*/ int sector; sector=mapbuf[entry*32+16+i]&0xff; - if (sb->size>=256) sector|=(((mapbuf[entry*32+16+ ++i]&0xff)<<8)); + if (sb->size>256) sector|=(((mapbuf[entry*32+16+ ++i]&0xff)<<8)); if (sector>0 && sector<=sb->size) { /* not entirely correct without the last extent record count */ @@ -142,13 +131,13 @@ static void map(struct cpmSuperBlock *sb) /*{{{*/ for (pos=0; pos<(int)sizeof(bmap); ++pos) { - move(2+pos%18,pos/18); - addch(bmap[pos]); + term_xy(pos/18,2+pos%18); + term_putch(bmap[pos]); } - move(21,0); printw("S=System area D=Directory area #=File data .=Free"); + term_xy(0,21); term_printf("S=System area D=Directory area #=File data .=Free"); msg="Any key to continue"; - move(23,(COLS-strlen(msg))/2); printw(msg); - getch(); + term_xy((term_cols()-strlen(msg))/2,23); term_printf(msg); + term_getch(); } /*}}}*/ static void data(struct cpmSuperBlock *sb, const char *buf, unsigned long int pos) /*{{{*/ @@ -158,12 +147,12 @@ static void data(struct cpmSuperBlock *sb, const char *buf, unsigned long int po for (i=0; i<128; ++i) { - move(4+(i>>4),(i&0x0f)*3+!!(i&0x8)); printw("%02x",buf[i+offset]&0xff); - if (pos%sb->secLength==i+offset) attron(A_REVERSE); - move(4+(i>>4),50+(i&0x0f)); printw("%c",isprint(buf[i+offset]) ? buf[i+offset] : '.'); - attroff(A_REVERSE); + term_xy((i&0x0f)*3+!!(i&0x8),4+(i>>4)); term_printf("%02x",buf[i+offset]&0xff); + if (pos%sb->secLength==i+offset) term_reverse(1); + term_xy(50+(i&0x0f),4+(i>>4)); term_printf("%c",isprint((unsigned char)buf[i+offset]) ? buf[i+offset] : '.'); + term_reverse(0); } - move(4+((pos&0x7f)>>4),((pos&0x7f)&0x0f)*3+!!((pos&0x7f)&0x8)+1); + term_xy(((pos&0x7f)&0x0f)*3+!!((pos&0x7f)&0x8)+1,4+((pos&0x7f)>>4)); } /*}}}*/ @@ -173,6 +162,7 @@ int main(int argc, char *argv[]) /*{{{*/ { /* variables */ /*{{{*/ const char *devopts=(const char*)0; + int uppercase=0; char *image; const char *err; struct cpmSuperBlock drive; @@ -180,17 +170,18 @@ int main(int argc, char *argv[]) /*{{{*/ const char *format; int c,usage=0; off_t pos; - chtype ch; + int ch; int reload; char *buf; /*}}}*/ /* parse options */ /*{{{*/ if (!(format=getenv("CPMTOOLSFMT"))) format=FORMAT; - while ((c=getopt(argc,argv,"T:f:h?"))!=EOF) switch(c) + while ((c=getopt(argc,argv,"T:f:uh?"))!=EOF) switch(c) { case 'f': format=optarg; break; case 'T': devopts=optarg; break; + case 'u': uppercase=1; break; case 'h': case '?': usage=1; break; } @@ -210,7 +201,7 @@ int main(int argc, char *argv[]) /*{{{*/ fprintf(stderr,"%s: cannot open %s (%s)\n",cmd,image,err); exit(1); } - if (cpmReadSuper(&drive,&root,format)==-1) + if (cpmReadSuper(&drive,&root,format,uppercase)==-1) { fprintf(stderr,"%s: cannot read superblock (%s)\n",cmd,boo); exit(1); @@ -223,38 +214,29 @@ int main(int argc, char *argv[]) /*{{{*/ exit(1); } /*}}}*/ - /* init curses */ /*{{{*/ - initscr(); - noecho(); - raw(); - nonl(); - idlok(stdscr,TRUE); - idcok(stdscr,TRUE); - keypad(stdscr,TRUE); - clear(); - /*}}}*/ + term_init(); pos=0; reload=1; do { /* display position and load data */ /*{{{*/ - clear(); - move(2,0); printw("Byte %8lu (0x%08lx) ",pos,pos); + term_clear(); + term_xy(0,2); term_printf("Byte %8lu (0x%08lx) ",pos,pos); if (pos<(drive.boottrk*drive.sectrk*drive.secLength)) { - printw("Physical sector %3lu ",((pos/drive.secLength)%drive.sectrk)+1); + term_printf("Physical sector %3lu ",((pos/drive.secLength)%drive.sectrk)+1); } else { - printw("Sector %3lu ",((pos/drive.secLength)%drive.sectrk)+1); - printw("(physical %3d) ",drive.skewtab[(pos/drive.secLength)%drive.sectrk]+1); + term_printf("Sector %3lu ",((pos/drive.secLength)%drive.sectrk)+1); + term_printf("(physical %3d) ",drive.skewtab[(pos/drive.secLength)%drive.sectrk]+1); } - printw("Offset %5lu ",pos%drive.secLength); - printw("Track %5lu",pos/(drive.secLength*drive.sectrk)); - move(LINES-3,0); printw("N)ext track P)revious track"); - move(LINES-2,0); printw("n)ext record p)revious record f)orward byte b)ackward byte"); - move(LINES-1,0); printw("i)nfo q)uit"); + term_printf("Offset %5lu ",pos%drive.secLength); + term_printf("Track %5lu",pos/(drive.secLength*drive.sectrk)); + term_xy(0,term_lines()-3); term_printf("N)ext track P)revious track"); + term_xy(0,term_lines()-2); term_printf("n)ext record p)revious record f)orward byte b)ackward byte"); + term_xy(0,term_lines()-1); term_printf("i)nfo q)uit"); if (reload) { if (pos<(drive.boottrk*drive.sectrk*drive.secLength)) @@ -267,7 +249,7 @@ int main(int argc, char *argv[]) /*{{{*/ } if (err) { - move(4,0); printw("Data can not be read: %s",err); + term_xy(0,4); term_printf("Data can not be read: %s",err); } else reload=0; } @@ -278,10 +260,10 @@ int main(int argc, char *argv[]) /*{{{*/ { const char *msg; - msg="System area"; move(0,(COLS-strlen(msg))/2); printw(msg); - move(LINES-3,36); printw("F)orward 16 byte B)ackward 16 byte"); + msg="System area"; term_xy((term_cols()-strlen(msg))/2,0); term_printf(msg); + term_xy(36,term_lines()-3); term_printf("F)orward 16 byte B)ackward 16 byte"); if (!reload) data(&drive,buf,pos); - switch (ch=getch()) + switch (ch=term_getch()) { case 'F': /* next 16 byte */ /*{{{*/ { @@ -314,10 +296,10 @@ int main(int argc, char *argv[]) /*{{{*/ int entry=(pos-(drive.boottrk*drive.sectrk*drive.secLength))>>5; int offset=pos&0x1f; - msg="Directory area"; move(0,(COLS-strlen(msg))/2); printw(msg); - move(LINES-3,36); printw("F)orward entry B)ackward entry"); + msg="Directory area"; term_xy((term_cols()-strlen(msg))/2,0); term_printf(msg); + term_xy(36,term_lines()-3); term_printf("F)orward entry B)ackward entry"); - move(13,0); printw("Entry %3d: ",entry); + term_xy(0,13); term_printf("Entry %3d: ",entry); if /* free or used directory entry */ /*{{{*/ ((buf[entrystart]>=0 && buf[entrystart]<=(drive.type==CPMFS_P2DOS ? 31 : 15)) || buf[entrystart]==(char)0xe5) { @@ -325,69 +307,69 @@ int main(int argc, char *argv[]) /*{{{*/ if (buf[entrystart]==(char)0xe5) { - if (offset==0) attron(A_REVERSE); - printw("Free"); - attroff(A_REVERSE); + if (offset==0) term_reverse(1); + term_printf("Free"); + term_reverse(0); } - else printw("Directory entry"); - move(15,0); + else term_printf("Directory entry"); + term_xy(0,15); if (buf[entrystart]!=(char)0xe5) { - printw("User: "); - if (offset==0) attron(A_REVERSE); - printw("%2d",buf[entrystart]); - attroff(A_REVERSE); - printw(" "); + term_printf("User: "); + if (offset==0) term_reverse(1); + term_printf("%2d",buf[entrystart]); + term_reverse(0); + term_printf(" "); } - printw("Name: "); + term_printf("Name: "); for (i=0; i<8; ++i) { - if (offset==1+i) attron(A_REVERSE); - printw("%c",buf[entrystart+1+i]&0x7f); - attroff(A_REVERSE); + if (offset==1+i) term_reverse(1); + term_printf("%c",buf[entrystart+1+i]&0x7f); + term_reverse(0); } - printw(" Extension: "); + term_printf(" Extension: "); for (i=0; i<3; ++i) { - if (offset==9+i) attron(A_REVERSE); - printw("%c",buf[entrystart+9+i]&0x7f); - attroff(A_REVERSE); + if (offset==9+i) term_reverse(1); + term_printf("%c",buf[entrystart+9+i]&0x7f); + term_reverse(0); } - move(16,0); printw("Extent: %3d",((buf[entrystart+12]&0xff)+((buf[entrystart+14]&0xff)<<5))/drive.extents); - printw(" (low: "); - if (offset==12) attron(A_REVERSE); - printw("%2d",buf[entrystart+12]&0xff); - attroff(A_REVERSE); - printw(", high: "); - if (offset==14) attron(A_REVERSE); - printw("%2d",buf[entrystart+14]&0xff); - attroff(A_REVERSE); - printw(")"); - move(17,0); printw("Last extent record count: "); - if (offset==15) attron(A_REVERSE); - printw("%3d",buf[entrystart+15]&0xff); - attroff(A_REVERSE); - move(18,0); printw("Last record byte count: "); - if (offset==13) attron(A_REVERSE); - printw("%3d",buf[entrystart+13]&0xff); - attroff(A_REVERSE); - move(19,0); printw("Data blocks:"); + term_xy(0,16); term_printf("Extent: %3d",((buf[entrystart+12]&0xff)+((buf[entrystart+14]&0xff)<<5))/drive.extents); + term_printf(" (low: "); + if (offset==12) term_reverse(1); + term_printf("%2d",buf[entrystart+12]&0xff); + term_reverse(0); + term_printf(", high: "); + if (offset==14) term_reverse(1); + term_printf("%2d",buf[entrystart+14]&0xff); + term_reverse(0); + term_printf(")"); + term_xy(0,17); term_printf("Last extent record count: "); + if (offset==15) term_reverse(1); + term_printf("%3d",buf[entrystart+15]&0xff); + term_reverse(0); + term_xy(0,18); term_printf("Last record byte count: "); + if (offset==13) term_reverse(1); + term_printf("%3d",buf[entrystart+13]&0xff); + term_reverse(0); + term_xy(0,19); term_printf("Data blocks:"); for (i=0; i<16; ++i) { unsigned int block=buf[entrystart+16+i]&0xff; - if (drive.size>=256) + if (drive.size>256) { - printw(" "); - if (offset==16+i || offset==16+i+1) attron(A_REVERSE); - printw("%5d",block|(((buf[entrystart+16+ ++i]&0xff)<<8))); - attroff(A_REVERSE); + term_printf(" "); + if (offset==16+i || offset==16+i+1) term_reverse(1); + term_printf("%5d",block|(((buf[entrystart+16+ ++i]&0xff)<<8))); + term_reverse(0); } else { - printw(" "); - if (offset==16+i) attron(A_REVERSE); - printw("%3d",block); - attroff(A_REVERSE); + term_printf(" "); + if (offset==16+i) term_reverse(1); + term_printf("%3d",block); + term_reverse(0); } } } @@ -399,78 +381,78 @@ int main(int argc, char *argv[]) /*{{{*/ const struct tm *tm; char s[30]; - if (offset==0) attron(A_REVERSE); - printw("Disc label"); - attroff(A_REVERSE); - move(15,0); - printw("Label: "); + if (offset==0) term_reverse(1); + term_printf("Disc label"); + term_reverse(0); + term_xy(0,15); + term_printf("Label: "); for (i=0; i<11; ++i) { - if (i+1==offset) attron(A_REVERSE); - printw("%c",buf[entrystart+1+i]&0x7f); - attroff(A_REVERSE); + if (i+1==offset) term_reverse(1); + term_printf("%c",buf[entrystart+1+i]&0x7f); + term_reverse(0); } - move(16,0); - printw("Bit 0,7: "); - if (offset==12) attron(A_REVERSE); - printw("Label %s",buf[entrystart+12]&1 ? "set" : "not set"); - printw(", password protection %s",buf[entrystart+12]&0x80 ? "set" : "not set"); - attroff(A_REVERSE); - move(17,0); - printw("Bit 4,5,6: "); - if (offset==12) attron(A_REVERSE); - printw("Time stamp "); - if (buf[entrystart+12]&0x10) printw("on create, "); - else printw("not on create, "); - if (buf[entrystart+12]&0x20) printw("on modification, "); - else printw("not on modifiction, "); - if (buf[entrystart+12]&0x40) printw("on access"); - else printw("not on access"); - attroff(A_REVERSE); - move(18,0); - printw("Password: "); + term_xy(0,16); + term_printf("Bit 0,7: "); + if (offset==12) term_reverse(1); + term_printf("Label %s",buf[entrystart+12]&1 ? "set" : "not set"); + term_printf(", password protection %s",buf[entrystart+12]&0x80 ? "set" : "not set"); + term_reverse(0); + term_xy(0,17); + term_printf("Bit 4,5,6: "); + if (offset==12) term_reverse(1); + term_printf("Time stamp "); + if (buf[entrystart+12]&0x10) term_printf("on create, "); + else term_printf("not on create, "); + if (buf[entrystart+12]&0x20) term_printf("on modification, "); + else term_printf("not on modifiction, "); + if (buf[entrystart+12]&0x40) term_printf("on access"); + else term_printf("not on access"); + term_reverse(0); + term_xy(0,18); + term_printf("Password: "); for (i=0; i<8; ++i) { char printable; - if (offset==16+(7-i)) attron(A_REVERSE); + if (offset==16+(7-i)) term_reverse(1); printable=(buf[entrystart+16+(7-i)]^buf[entrystart+13])&0x7f; - printw("%c",isprint(printable) ? printable : ' '); - attroff(A_REVERSE); + term_printf("%c",isprint(printable) ? printable : ' '); + term_reverse(0); } - printw(" XOR value: "); - if (offset==13) attron(A_REVERSE); - printw("0x%02x",buf[entrystart+13]&0xff); - attroff(A_REVERSE); - move(19,0); - printw("Created: "); + term_printf(" XOR value: "); + if (offset==13) term_reverse(1); + term_printf("0x%02x",buf[entrystart+13]&0xff); + term_reverse(0); + term_xy(0,19); + term_printf("Created: "); tm=cpmtime(buf[entrystart+24],buf[entrystart+25],buf[entrystart+26],buf[entrystart+27]); - if (offset==24 || offset==25) attron(A_REVERSE); + if (offset==24 || offset==25) term_reverse(1); strftime(s,sizeof(s),"%x",tm); - printw("%s",s); - attroff(A_REVERSE); - printw(" "); - if (offset==26) attron(A_REVERSE); - printw("%2d",tm->tm_hour); - attroff(A_REVERSE); - printw(":"); - if (offset==27) attron(A_REVERSE); - printw("%02d",tm->tm_min); - attroff(A_REVERSE); - printw(" Updated: "); + term_printf("%s",s); + term_reverse(0); + term_printf(" "); + if (offset==26) term_reverse(1); + term_printf("%2d",tm->tm_hour); + term_reverse(0); + term_printf(":"); + if (offset==27) term_reverse(1); + term_printf("%02d",tm->tm_min); + term_reverse(0); + term_printf(" Updated: "); tm=cpmtime(buf[entrystart+28],buf[entrystart+29],buf[entrystart+30],buf[entrystart+31]); - if (offset==28 || offset==29) attron(A_REVERSE); + if (offset==28 || offset==29) term_reverse(1); strftime(s,sizeof(s),"%x",tm); - printw("%s",s); - attroff(A_REVERSE); - printw(" "); - if (offset==30) attron(A_REVERSE); - printw("%2d",tm->tm_hour); - attroff(A_REVERSE); - printw(":"); - if (offset==31) attron(A_REVERSE); - printw("%02d",tm->tm_min); - attroff(A_REVERSE); + term_printf("%s",s); + term_reverse(0); + term_printf(" "); + if (offset==30) term_reverse(1); + term_printf("%2d",tm->tm_hour); + term_reverse(0); + term_printf(":"); + if (offset==31) term_reverse(1); + term_printf("%02d",tm->tm_min); + term_reverse(0); } /*}}}*/ else if /* time stamp */ /*{{{*/ @@ -479,98 +461,98 @@ int main(int argc, char *argv[]) /*{{{*/ const struct tm *tm; char s[30]; - if (offset==0) attron(A_REVERSE); - printw("Time stamps"); - attroff(A_REVERSE); - move(15,0); - printw("3rd last extent: Created/Accessed "); + if (offset==0) term_reverse(1); + term_printf("Time stamps"); + term_reverse(0); + term_xy(0,15); + term_printf("3rd last extent: Created/Accessed "); tm=cpmtime(buf[entrystart+1],buf[entrystart+2],buf[entrystart+3],buf[entrystart+4]); - if (offset==1 || offset==2) attron(A_REVERSE); + if (offset==1 || offset==2) term_reverse(1); strftime(s,sizeof(s),"%x",tm); - printw("%s",s); - attroff(A_REVERSE); - printw(" "); - if (offset==3) attron(A_REVERSE); - printw("%2d",tm->tm_hour); - attroff(A_REVERSE); - printw(":"); - if (offset==4) attron(A_REVERSE); - printw("%02d",tm->tm_min); - attroff(A_REVERSE); - printw(" Modified "); + term_printf("%s",s); + term_reverse(0); + term_printf(" "); + if (offset==3) term_reverse(1); + term_printf("%2d",tm->tm_hour); + term_reverse(0); + term_printf(":"); + if (offset==4) term_reverse(1); + term_printf("%02d",tm->tm_min); + term_reverse(0); + term_printf(" Modified "); tm=cpmtime(buf[entrystart+5],buf[entrystart+6],buf[entrystart+7],buf[entrystart+8]); - if (offset==5 || offset==6) attron(A_REVERSE); + if (offset==5 || offset==6) term_reverse(1); strftime(s,sizeof(s),"%x",tm); - printw("%s",s); - attroff(A_REVERSE); - printw(" "); - if (offset==7) attron(A_REVERSE); - printw("%2d",tm->tm_hour); - attroff(A_REVERSE); - printw(":"); - if (offset==8) attron(A_REVERSE); - printw("%02d",tm->tm_min); - attroff(A_REVERSE); - - move(16,0); - printw("2nd last extent: Created/Accessed "); + term_printf("%s",s); + term_reverse(0); + term_printf(" "); + if (offset==7) term_reverse(1); + term_printf("%2d",tm->tm_hour); + term_reverse(0); + term_printf(":"); + if (offset==8) term_reverse(1); + term_printf("%02d",tm->tm_min); + term_reverse(0); + + term_xy(0,16); + term_printf("2nd last extent: Created/Accessed "); tm=cpmtime(buf[entrystart+11],buf[entrystart+12],buf[entrystart+13],buf[entrystart+14]); - if (offset==11 || offset==12) attron(A_REVERSE); + if (offset==11 || offset==12) term_reverse(1); strftime(s,sizeof(s),"%x",tm); - printw("%s",s); - attroff(A_REVERSE); - printw(" "); - if (offset==13) attron(A_REVERSE); - printw("%2d",tm->tm_hour); - attroff(A_REVERSE); - printw(":"); - if (offset==14) attron(A_REVERSE); - printw("%02d",tm->tm_min); - attroff(A_REVERSE); - printw(" Modified "); + term_printf("%s",s); + term_reverse(0); + term_printf(" "); + if (offset==13) term_reverse(1); + term_printf("%2d",tm->tm_hour); + term_reverse(0); + term_printf(":"); + if (offset==14) term_reverse(1); + term_printf("%02d",tm->tm_min); + term_reverse(0); + term_printf(" Modified "); tm=cpmtime(buf[entrystart+15],buf[entrystart+16],buf[entrystart+17],buf[entrystart+18]); - if (offset==15 || offset==16) attron(A_REVERSE); + if (offset==15 || offset==16) term_reverse(1); strftime(s,sizeof(s),"%x",tm); - printw("%s",s); - attroff(A_REVERSE); - printw(" "); - if (offset==17) attron(A_REVERSE); - printw("%2d",tm->tm_hour); - attroff(A_REVERSE); - printw(":"); - if (offset==18) attron(A_REVERSE); - printw("%02d",tm->tm_min); - attroff(A_REVERSE); - - move(17,0); - printw(" Last extent: Created/Accessed "); + term_printf("%s",s); + term_reverse(0); + term_printf(" "); + if (offset==17) term_reverse(1); + term_printf("%2d",tm->tm_hour); + term_reverse(0); + term_printf(":"); + if (offset==18) term_reverse(1); + term_printf("%02d",tm->tm_min); + term_reverse(0); + + term_xy(0,17); + term_printf(" Last extent: Created/Accessed "); tm=cpmtime(buf[entrystart+21],buf[entrystart+22],buf[entrystart+23],buf[entrystart+24]); - if (offset==21 || offset==22) attron(A_REVERSE); + if (offset==21 || offset==22) term_reverse(1); strftime(s,sizeof(s),"%x",tm); - printw("%s",s); - attroff(A_REVERSE); - printw(" "); - if (offset==23) attron(A_REVERSE); - printw("%2d",tm->tm_hour); - attroff(A_REVERSE); - printw(":"); - if (offset==24) attron(A_REVERSE); - printw("%02d",tm->tm_min); - attroff(A_REVERSE); - printw(" Modified "); + term_printf("%s",s); + term_reverse(0); + term_printf(" "); + if (offset==23) term_reverse(1); + term_printf("%2d",tm->tm_hour); + term_reverse(0); + term_printf(":"); + if (offset==24) term_reverse(1); + term_printf("%02d",tm->tm_min); + term_reverse(0); + term_printf(" Modified "); tm=cpmtime(buf[entrystart+25],buf[entrystart+26],buf[entrystart+27],buf[entrystart+28]); - if (offset==25 || offset==26) attron(A_REVERSE); + if (offset==25 || offset==26) term_reverse(1); strftime(s,sizeof(s),"%x",tm); - printw("%s",s); - attroff(A_REVERSE); - printw(" "); - if (offset==27) attron(A_REVERSE); - printw("%2d",tm->tm_hour); - attroff(A_REVERSE); - printw(":"); - if (offset==28) attron(A_REVERSE); - printw("%02d",tm->tm_min); - attroff(A_REVERSE); + term_printf("%s",s); + term_reverse(0); + term_printf(" "); + if (offset==27) term_reverse(1); + term_printf("%2d",tm->tm_hour); + term_reverse(0); + term_printf(":"); + if (offset==28) term_reverse(1); + term_printf("%02d",tm->tm_min); + term_reverse(0); } /*}}}*/ else if /* password */ /*{{{*/ @@ -578,61 +560,61 @@ int main(int argc, char *argv[]) /*{{{*/ { int i; - if (offset==0) attron(A_REVERSE); - printw("Password"); - attroff(A_REVERSE); + if (offset==0) term_reverse(1); + term_printf("Password"); + term_reverse(0); - move(15,0); - printw("Name: "); + term_xy(0,15); + term_printf("Name: "); for (i=0; i<8; ++i) { - if (offset==1+i) attron(A_REVERSE); - printw("%c",buf[entrystart+1+i]&0x7f); - attroff(A_REVERSE); + if (offset==1+i) term_reverse(1); + term_printf("%c",buf[entrystart+1+i]&0x7f); + term_reverse(0); } - printw(" Extension: "); + term_printf(" Extension: "); for (i=0; i<3; ++i) { - if (offset==9+i) attron(A_REVERSE); - printw("%c",buf[entrystart+9+i]&0x7f); - attroff(A_REVERSE); + if (offset==9+i) term_reverse(1); + term_printf("%c",buf[entrystart+9+i]&0x7f); + term_reverse(0); } - move(16,0); - printw("Password required for: "); - if (offset==12) attron(A_REVERSE); - if (buf[entrystart+12]&0x80) printw("Reading "); - if (buf[entrystart+12]&0x40) printw("Writing "); - if (buf[entrystart+12]&0x20) printw("Deleting "); - attroff(A_REVERSE); + term_xy(0,16); + term_printf("Password required for: "); + if (offset==12) term_reverse(1); + if (buf[entrystart+12]&0x80) term_printf("Reading "); + if (buf[entrystart+12]&0x40) term_printf("Writing "); + if (buf[entrystart+12]&0x20) term_printf("Deleting "); + term_reverse(0); - move(17,0); - printw("Password: "); + term_xy(0,17); + term_printf("Password: "); for (i=0; i<8; ++i) { char printable; - if (offset==16+(7-i)) attron(A_REVERSE); + if (offset==16+(7-i)) term_reverse(1); printable=(buf[entrystart+16+(7-i)]^buf[entrystart+13])&0x7f; - printw("%c",isprint(printable) ? printable : ' '); - attroff(A_REVERSE); + term_printf("%c",isprint(printable) ? printable : ' '); + term_reverse(0); } - printw(" XOR value: "); - if (offset==13) attron(A_REVERSE); - printw("0x%02x",buf[entrystart+13]&0xff); - attroff(A_REVERSE); + term_printf(" XOR value: "); + if (offset==13) term_reverse(1); + term_printf("0x%02x",buf[entrystart+13]&0xff); + term_reverse(0); } /*}}}*/ else /* bad status */ /*{{{*/ { - printw("Bad status "); - if (offset==0) attron(A_REVERSE); - printw("0x%02x",buf[entrystart]); - attroff(A_REVERSE); + term_printf("Bad status "); + if (offset==0) term_reverse(1); + term_printf("0x%02x",buf[entrystart]); + term_reverse(0); } /*}}}*/ if (!reload) data(&drive,buf,pos); - switch (ch=getch()) + switch (ch=term_getch()) { case 'F': /* next entry */ /*{{{*/ { @@ -661,9 +643,9 @@ int main(int argc, char *argv[]) /*{{{*/ { const char *msg; - msg="Data area"; move(0,(COLS-strlen(msg))/2); printw(msg); + msg="Data area"; term_xy((term_cols()-strlen(msg))/2,0); term_printf(msg); if (!reload) data(&drive,buf,pos); - ch=getch(); + ch=term_getch(); } /*}}}*/ @@ -736,13 +718,7 @@ int main(int argc, char *argv[]) /*{{{*/ /*}}}*/ } while (ch!='q'); - /* exit curses */ /*{{{*/ - move(LINES-1,0); - refresh(); - echo(); - noraw(); - endwin(); - /*}}}*/ + term_exit(); exit(0); } /*}}}*/