|
|
@ -90,7 +90,7 @@ int main(int argc,char* argv[]) {
|
|
|
|
enum { BEFOREBEGIN, AFTERBEGIN, SKIPHEADER } state=BEFOREBEGIN;
|
|
|
|
enum { BEFOREBEGIN, AFTERBEGIN, SKIPHEADER } state=BEFOREBEGIN;
|
|
|
|
enum { UUDECODE, YENC } mode=UUDECODE;
|
|
|
|
enum { UUDECODE, YENC } mode=UUDECODE;
|
|
|
|
unsigned long fmode=0,lineno=0;
|
|
|
|
unsigned long fmode=0,lineno=0;
|
|
|
|
unsigned long offset,endoffset,totalsize,linelen,part; /* used only for yenc */
|
|
|
|
unsigned long offset,endoffset,totalsize,linelen,part,reconstructed; /* used only for yenc */
|
|
|
|
static stralloc yencpart;
|
|
|
|
static stralloc yencpart;
|
|
|
|
unsigned int crc;
|
|
|
|
unsigned int crc;
|
|
|
|
|
|
|
|
|
|
|
@ -194,6 +194,7 @@ invalidybegin:
|
|
|
|
l=filename-line+6;
|
|
|
|
l=filename-line+6;
|
|
|
|
if (!(filename=strstr(line," part="))) goto invalidybegin;
|
|
|
|
if (!(filename=strstr(line," part="))) goto invalidybegin;
|
|
|
|
if (filename[6+scan_ulong(filename+6,&part)] != ' ') goto invalidybegin;
|
|
|
|
if (filename[6+scan_ulong(filename+6,&part)] != ' ') goto invalidybegin;
|
|
|
|
|
|
|
|
if (part==1) reconstructed=0;
|
|
|
|
if (!(filename=strstr(line," size="))) goto invalidybegin;
|
|
|
|
if (!(filename=strstr(line," size="))) goto invalidybegin;
|
|
|
|
if (filename[6+scan_ulong(filename+6,&totalsize)] != ' ') goto invalidybegin;
|
|
|
|
if (filename[6+scan_ulong(filename+6,&totalsize)] != ' ') goto invalidybegin;
|
|
|
|
if (!(filename=strstr(line," line="))) goto invalidybegin;
|
|
|
|
if (!(filename=strstr(line," line="))) goto invalidybegin;
|
|
|
@ -242,9 +243,6 @@ invalidpart:
|
|
|
|
/* ok, save block */
|
|
|
|
/* ok, save block */
|
|
|
|
buffer_put(&fileout,out.s,out.len);
|
|
|
|
buffer_put(&fileout,out.s,out.len);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
buffer_puts(buffer_2,"warning: part ");
|
|
|
|
|
|
|
|
buffer_putulong(buffer_2,part);
|
|
|
|
|
|
|
|
buffer_puts(buffer_2," corrupt; attempting reconstruction... ");
|
|
|
|
|
|
|
|
out.len=0;
|
|
|
|
out.len=0;
|
|
|
|
for (i=0; i<yencpart.len; ) {
|
|
|
|
for (i=0; i<yencpart.len; ) {
|
|
|
|
unsigned int x,scanned;
|
|
|
|
unsigned int x,scanned;
|
|
|
@ -253,16 +251,23 @@ invalidpart:
|
|
|
|
i+=x+1; out.len+=scanned;
|
|
|
|
i+=x+1; out.len+=scanned;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i=crc32(0,out.s,out.len);
|
|
|
|
i=crc32(0,out.s,out.len);
|
|
|
|
if (out.len == endoffset-offset && i == wantedcrc) {
|
|
|
|
if (out.len == endoffset-offset && i == wantedcrc)
|
|
|
|
buffer_putsflush(buffer_2,"success!\n");
|
|
|
|
++reconstructed;
|
|
|
|
buffer_put(&fileout,out.s,out.len);
|
|
|
|
else {
|
|
|
|
} else
|
|
|
|
buffer_puts(buffer_2,"warning: part ");
|
|
|
|
buffer_putsflush(buffer_2,"failed!\n");
|
|
|
|
buffer_putulong(buffer_2,part);
|
|
|
|
|
|
|
|
buffer_putsflush(buffer_2," corrupt; reconstruction failed.\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stralloc_free(&out);
|
|
|
|
stralloc_free(&out);
|
|
|
|
buffer_flush(&fileout);
|
|
|
|
buffer_flush(&fileout);
|
|
|
|
close(ofd);
|
|
|
|
close(ofd);
|
|
|
|
ofd=-1;
|
|
|
|
ofd=-1;
|
|
|
|
|
|
|
|
if (endoffset==totalsize && reconstructed) {
|
|
|
|
|
|
|
|
buffer_puts(buffer_2,"warning: had to reconstruct ");
|
|
|
|
|
|
|
|
buffer_putulong(buffer_2,reconstruct);
|
|
|
|
|
|
|
|
buffer_puts(buffer_2," parts!\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
#if 0
|
|
|
|
#if 0
|
|
|
|
unsigned long cur;
|
|
|
|
unsigned long cur;
|
|
|
|
if (ofd>=0) {
|
|
|
|
if (ofd>=0) {
|
|
|
|