X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=fsed.cpm.c;h=f120b77c4a364749a3cdc119469acd710576a24b;hb=be51a0b47ec4edacc689851a88ec6172737cb61c;hp=9e1592d9f96edc09084b9527a2da0331af951144;hpb=0493acd9ceadbe13553c5b9eb254fbd3f2e46939;p=debian%2Fcpmtools diff --git a/fsed.cpm.c b/fsed.cpm.c index 9e1592d..f120b77 100644 --- a/fsed.cpm.c +++ b/fsed.cpm.c @@ -3,13 +3,27 @@ #include #include +#if NEED_NCURSES +#if HAVE_NCURSES_NCURSES_H +#include +#else +#include +#endif +#else #include +#endif #include #include #include #include +#include #include "cpmfs.h" +#include "getopt_.h" + +#ifdef USE_DMALLOC +#include +#endif /*}}}*/ extern char **environ; @@ -21,7 +35,7 @@ static struct tm *cpmtime(char lday, char hday, char hour, char min) /*{{{*/ static struct tm tm; unsigned long days=(lday&0xff)|((hday&0xff)<<8); int d; - int md[12]={31,0,31,30,31,30,31,31,30,31,30,31}; + unsigned int md[12]={31,0,31,30,31,30,31,31,30,31,30,31}; tm.tm_sec=0; tm.tm_min=((min>>4)&0xf)*10+(min&0xf); @@ -83,7 +97,8 @@ static void map(struct cpmSuperBlock *sb) /*{{{*/ { const char *msg; char bmap[18*80]; - int secmap,pos,sys,directory; + int secmap,sys,directory; + int pos; clear(); msg="Data map"; @@ -110,7 +125,7 @@ static void map(struct cpmSuperBlock *sb) /*{{{*/ { for (i=0; i<16; ++i) { - unsigned int sector; + int sector; sector=mapbuf[entry*32+16+i]&0xff; if (sb->size>=256) sector|=(((mapbuf[entry*32+16+ ++i]&0xff)<<8)); @@ -125,7 +140,7 @@ static void map(struct cpmSuperBlock *sb) /*{{{*/ } } - for (pos=0; possecLength)&~0x7f; - int i; + unsigned int i; for (i=0; i<128; ++i) { @@ -162,16 +177,17 @@ int main(int argc, char *argv[]) /*{{{*/ const char *err; struct cpmSuperBlock drive; struct cpmInode root; - const char *format=FORMAT; + const char *format; int c,usage=0; - unsigned long pos; + off_t pos; chtype ch; int reload; char *buf; /*}}}*/ /* parse options */ /*{{{*/ - while ((c=getopt(argc,argv,"f:h?"))!=EOF) switch(c) + if (!(format=getenv("CPMTOOLSFMT"))) format=FORMAT; + while ((c=getopt(argc,argv,"T:f:h?"))!=EOF) switch(c) { case 'f': format=optarg; break; case 'T': devopts=optarg; break; @@ -180,7 +196,7 @@ int main(int argc, char *argv[]) /*{{{*/ } if (optind!=(argc-1)) usage=1; - else image=argv[optind]; + else image=argv[optind++]; if (usage) { @@ -191,10 +207,14 @@ int main(int argc, char *argv[]) /*{{{*/ /* open image */ /*{{{*/ if ((err=Device_open(&drive.dev,image,O_RDONLY,devopts))) { - fprintf(stderr,"%s: can not open %s (%s)\n",cmd,image,err); + fprintf(stderr,"%s: cannot open %s (%s)\n",cmd,image,err); + exit(1); + } + if (cpmReadSuper(&drive,&root,format)==-1) + { + fprintf(stderr,"%s: cannot read superblock (%s)\n",cmd,boo); exit(1); } - cpmReadSuper(&drive,&root,format); /*}}}*/ /* alloc sector buffers */ /*{{{*/ if ((buf=malloc(drive.secLength))==(char*)0 || (mapbuf=malloc(drive.secLength))==(char*)0) @@ -220,18 +240,18 @@ int main(int argc, char *argv[]) /*{{{*/ { /* display position and load data */ /*{{{*/ clear(); - move(2,0); printw("Byte %8d (0x%08x) ",pos,pos); + move(2,0); printw("Byte %8lu (0x%08lx) ",pos,pos); if (pos<(drive.boottrk*drive.sectrk*drive.secLength)) { - printw("Physical sector %3d ",((pos/drive.secLength)%drive.sectrk)+1); + printw("Physical sector %3lu ",((pos/drive.secLength)%drive.sectrk)+1); } else { - printw("Sector %3d ",((pos/drive.secLength)%drive.sectrk)+1); + printw("Sector %3lu ",((pos/drive.secLength)%drive.sectrk)+1); printw("(physical %3d) ",drive.skewtab[(pos/drive.secLength)%drive.sectrk]+1); } - printw("Offset %5d ",pos%drive.secLength); - printw("Track %5d",pos/(drive.secLength*drive.sectrk)); + 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"); @@ -265,7 +285,7 @@ int main(int argc, char *argv[]) /*{{{*/ { case 'F': /* next 16 byte */ /*{{{*/ { - if (pos+16<(drive.sectrk*drive.tracks*(unsigned long)drive.secLength)) + if (pos+16<(drive.sectrk*drive.tracks*(off_t)drive.secLength)) { if (pos/drive.secLength!=(pos+16)/drive.secLength) reload=1; pos+=16; @@ -616,7 +636,7 @@ int main(int argc, char *argv[]) /*{{{*/ { case 'F': /* next entry */ /*{{{*/ { - if (pos+32<(drive.sectrk*drive.tracks*(unsigned long)drive.secLength)) + if (pos+32<(drive.sectrk*drive.tracks*(off_t)drive.secLength)) { if (pos/drive.secLength!=(pos+32)/drive.secLength) reload=1; pos+=32; @@ -652,7 +672,7 @@ int main(int argc, char *argv[]) /*{{{*/ { case 'n': /* next record */ /*{{{*/ { - if (pos+128<(drive.sectrk*drive.tracks*(unsigned long)drive.secLength)) + if (pos+128<(drive.sectrk*drive.tracks*(off_t)drive.secLength)) { if (pos/drive.secLength!=(pos+128)/drive.secLength) reload=1; pos+=128;