X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=cpmrm.c;h=65430da6d752548e98648baad4f7d0cbe722af84;hb=b1e873c5b2f6376bb39ff0fda1464cbbacbae5f7;hp=e9353412510b93ff505b4971b99b2c8d7d68945b;hpb=224b4e6d27a3af235500d9d8028ddbd3a60af7ed;p=debian%2Fcpmtools diff --git a/cpmrm.c b/cpmrm.c index e935341..65430da 100644 --- a/cpmrm.c +++ b/cpmrm.c @@ -7,7 +7,7 @@ #include #include -#include "getopt.h" +#include "getopt_.h" #include "cpmfs.h" #ifdef USE_DMALLOC @@ -22,7 +22,7 @@ int main(int argc, char *argv[]) /*{{{*/ /* variables */ /*{{{*/ const char *err; const char *image; - const char *format=FORMAT; + const char *format; const char *devopts=NULL; int c,i,usage=0,exitcode=0; struct cpmSuperBlock drive; @@ -32,6 +32,7 @@ int main(int argc, char *argv[]) /*{{{*/ /*}}}*/ /* parse options */ /*{{{*/ + if (!(format=getenv("CPMTOOLSFMT"))) format=FORMAT; while ((c=getopt(argc,argv,"T:f:h?"))!=EOF) switch(c) { case 'T': devopts=optarg; break; @@ -41,7 +42,7 @@ int main(int argc, char *argv[]) /*{{{*/ } if (optind>=(argc-1)) usage=1; - else image=argv[optind]; + else image=argv[optind++]; if (usage) { @@ -52,10 +53,14 @@ int main(int argc, char *argv[]) /*{{{*/ /* open image */ /*{{{*/ if ((err=Device_open(&drive.dev, image, O_RDWR, 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); /*}}}*/ cpmglob(optind,argc,argv,&root,&gargc,&gargv); for (i=0; i