Return the extracted serial number for real.

This commit is contained in:
King_DuckZ 2020-03-04 01:57:03 +01:00
parent a9798ac94e
commit cb0d0e6941

View file

@ -119,7 +119,13 @@
#define GET_UBYTE(a) a_to_u_byte(a)
typedef int(*iso_listing_callback)(void*,const char*,int is_dir);
struct iso_extract_handle {
struct scsi_dev *dev;
struct iso_directory_record *idr;
};
typedef int(*iso_listing_callback)(void*,const char*,int is_dir,int sz,
struct iso_extract_handle*);
enum ScanRetCode {
ScanRetCode_Ok = 100,
@ -196,6 +202,8 @@ LOCAL void extract __PR((struct scsi_dev *dev,
LOCAL void extract_file __PR((struct scsi_dev *dev, int f,
struct iso_directory_record * idr,
char *fname));
EXPORT void extract_file_from_iso __PR((struct iso_extract_handle *context,
char *out));
LOCAL void parse_cl_dir __PR((struct scsi_dev *dev,
struct iso_directory_record *idr, int extent));
LOCAL BOOL parse_de __PR((struct iso_directory_record *idr));
@ -915,6 +923,7 @@ parse_dir(dev, dp, rootname, extent, len, callback, user_data)
struct todo *td;
int i;
struct iso_directory_record * idr;
struct iso_extract_handle extr_handle;
unsigned char cl_buffer[2048];
unsigned char flags = 0;
Llong size = 0;
@ -989,7 +998,7 @@ static int nlen = 0;
int nextent;
struct todo *tp = dp;
stop_now = (*callback)(user_data, n, 1);
stop_now = (*callback)(user_data, n, 1, 0, NULL);
if (stop_now)
break;
@ -1007,7 +1016,7 @@ static int nlen = 0;
comerr(_("No memory.\n"));
td->next = NULL;
td->prev = dp;
td->extent = isonum_733((unsigned char *)idr->extent);
td->extent = nextent;
td->length = isonum_733((unsigned char *)idr->size);
td->name = (char *) malloc(strlen(rootname)
+ strlen(name_buf) + 2);
@ -1024,7 +1033,10 @@ static int nlen = 0;
(idr->name[0] != 0 || idr->name[0] != 1)) {
/* this is . or .. */
} else {
stop_now = callback(user_data, n, 0);
extr_handle.dev = dev;
extr_handle.idr = idr;
stop_now = callback(user_data, n, 0,
isonum_733((unsigned char *)idr->size), &extr_handle);
if (stop_now)
break;
@ -1107,6 +1119,32 @@ static int nlen = 0;
return stop_now;
}
EXPORT void extract_file_from_iso(context, out)
struct iso_extract_handle *context;
char *out;
{
int extent, len, tlen;
int offs = 0;
unsigned char buff[20480];
extent = isonum_733((unsigned char *)context->idr->extent);
len = isonum_733((unsigned char *)context->idr->size);
while (len > 0) {
tlen = (len > sizeof (buff) ? sizeof (buff) : len);
#ifdef USE_SCG
readsecs(context->dev, extent - sector_offset, buff, ISO_BLOCKS(tlen));
#else
lseek(fileno(infile), ((off_t)(extent - sector_offset)) << 11, SEEK_SET);
read(fileno(infile), buff, tlen);
#endif
memcpy(out + offs, buff, tlen);
len -= tlen;
offs += tlen;
extent += ISO_BLOCKS(tlen);
}
}
EXPORT int
scan_iso (filename, callback, user_data)
const char* filename;