Return the extracted serial number for real.
This commit is contained in:
parent
a9798ac94e
commit
cb0d0e6941
1 changed files with 42 additions and 4 deletions
|
@ -119,7 +119,13 @@
|
||||||
|
|
||||||
#define GET_UBYTE(a) a_to_u_byte(a)
|
#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 {
|
enum ScanRetCode {
|
||||||
ScanRetCode_Ok = 100,
|
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,
|
LOCAL void extract_file __PR((struct scsi_dev *dev, int f,
|
||||||
struct iso_directory_record * idr,
|
struct iso_directory_record * idr,
|
||||||
char *fname));
|
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,
|
LOCAL void parse_cl_dir __PR((struct scsi_dev *dev,
|
||||||
struct iso_directory_record *idr, int extent));
|
struct iso_directory_record *idr, int extent));
|
||||||
LOCAL BOOL parse_de __PR((struct iso_directory_record *idr));
|
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;
|
struct todo *td;
|
||||||
int i;
|
int i;
|
||||||
struct iso_directory_record * idr;
|
struct iso_directory_record * idr;
|
||||||
|
struct iso_extract_handle extr_handle;
|
||||||
unsigned char cl_buffer[2048];
|
unsigned char cl_buffer[2048];
|
||||||
unsigned char flags = 0;
|
unsigned char flags = 0;
|
||||||
Llong size = 0;
|
Llong size = 0;
|
||||||
|
@ -989,7 +998,7 @@ static int nlen = 0;
|
||||||
int nextent;
|
int nextent;
|
||||||
struct todo *tp = dp;
|
struct todo *tp = dp;
|
||||||
|
|
||||||
stop_now = (*callback)(user_data, n, 1);
|
stop_now = (*callback)(user_data, n, 1, 0, NULL);
|
||||||
if (stop_now)
|
if (stop_now)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1007,7 +1016,7 @@ static int nlen = 0;
|
||||||
comerr(_("No memory.\n"));
|
comerr(_("No memory.\n"));
|
||||||
td->next = NULL;
|
td->next = NULL;
|
||||||
td->prev = dp;
|
td->prev = dp;
|
||||||
td->extent = isonum_733((unsigned char *)idr->extent);
|
td->extent = nextent;
|
||||||
td->length = isonum_733((unsigned char *)idr->size);
|
td->length = isonum_733((unsigned char *)idr->size);
|
||||||
td->name = (char *) malloc(strlen(rootname)
|
td->name = (char *) malloc(strlen(rootname)
|
||||||
+ strlen(name_buf) + 2);
|
+ strlen(name_buf) + 2);
|
||||||
|
@ -1024,7 +1033,10 @@ static int nlen = 0;
|
||||||
(idr->name[0] != 0 || idr->name[0] != 1)) {
|
(idr->name[0] != 0 || idr->name[0] != 1)) {
|
||||||
/* this is . or .. */
|
/* this is . or .. */
|
||||||
} else {
|
} 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)
|
if (stop_now)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1107,6 +1119,32 @@ static int nlen = 0;
|
||||||
return stop_now;
|
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
|
EXPORT int
|
||||||
scan_iso (filename, callback, user_data)
|
scan_iso (filename, callback, user_data)
|
||||||
const char* filename;
|
const char* filename;
|
||||||
|
|
Loading…
Reference in a new issue