Replaced some large local variables by other means in
This commit is contained in:
@@ -518,26 +518,19 @@ int isoburn_drive_aquire(struct burn_drive_info *drive_infos[],
|
||||
{
|
||||
int ret, drive_grabbed= 0;
|
||||
struct isoburn *o= NULL;
|
||||
|
||||
#ifndef NIX
|
||||
|
||||
/* <<< should be obsolete by new drive addressing of libburn-0.5.2 */
|
||||
/* >>> but helps with kernel 2.4 to use /dev/sr */
|
||||
|
||||
int conv_ret;
|
||||
char libburn_drive_adr[BURN_DRIVE_ADR_LEN];
|
||||
char *libburn_drive_adr= NULL;
|
||||
|
||||
/* Should be obsolete by new drive addressing of libburn-0.5.2 */
|
||||
/* but helps with kernel 2.4 to use /dev/sr */
|
||||
libburn_drive_adr= calloc(1, BURN_DRIVE_ADR_LEN);
|
||||
if(libburn_drive_adr == NULL)
|
||||
{ret= -1; goto ex;}
|
||||
conv_ret= burn_drive_convert_fs_adr(adr, libburn_drive_adr);
|
||||
if(conv_ret<=0)
|
||||
strcpy(libburn_drive_adr, adr);
|
||||
|
||||
ret= burn_drive_scan_and_grab(drive_infos, libburn_drive_adr, flag&1);
|
||||
|
||||
#else
|
||||
|
||||
ret= burn_drive_scan_and_grab(drive_infos, adr, flag & 1);
|
||||
|
||||
#endif /* ! NIX */
|
||||
|
||||
if(ret<=0)
|
||||
goto ex;
|
||||
drive_grabbed= 1;
|
||||
@@ -559,6 +552,8 @@ ex:
|
||||
burn_drive_release((*drive_infos)[0].drive, 0);
|
||||
isoburn_destroy(&o, 0);
|
||||
}
|
||||
if(libburn_drive_adr != NULL)
|
||||
free(libburn_drive_adr);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@@ -656,9 +651,16 @@ void isoburn_disc_erase(struct burn_drive *drive, int fast)
|
||||
int ret, do_pseudo_blank= 0, role;
|
||||
struct isoburn *o;
|
||||
enum burn_disc_status s;
|
||||
char zero_buffer[Libisoburn_target_head_sizE];
|
||||
char *zero_buffer= NULL;
|
||||
struct burn_multi_caps *caps= NULL;
|
||||
|
||||
zero_buffer= calloc(1, Libisoburn_target_head_sizE);
|
||||
if(zero_buffer == NULL) {
|
||||
/* To cause a negative reply with burn_drive_wrote_well() */
|
||||
burn_drive_cancel(drive);
|
||||
goto ex;
|
||||
}
|
||||
|
||||
ret= isoburn_find_emulator(&o, drive, 0);
|
||||
if(ret>0) {
|
||||
if(o->emulation_mode==-1) {
|
||||
@@ -698,6 +700,8 @@ void isoburn_disc_erase(struct burn_drive *drive, int fast)
|
||||
ex:;
|
||||
if(caps!=NULL)
|
||||
burn_disc_free_multi_caps(&caps);
|
||||
if(zero_buffer != NULL)
|
||||
free(zero_buffer);
|
||||
}
|
||||
|
||||
|
||||
@@ -836,15 +840,24 @@ void isoburn_disc_write(struct burn_write_opts *opts, struct burn_disc *disc)
|
||||
off_t nwa= 0;
|
||||
struct isoburn *o;
|
||||
struct burn_drive *drive;
|
||||
char reasons[BURN_REASONS_LEN],msg[160+BURN_REASONS_LEN];
|
||||
char adr[BURN_DRIVE_ADR_LEN];
|
||||
char *reasons= NULL, *msg= NULL, *adr= NULL;
|
||||
enum burn_write_types write_type;
|
||||
struct stat stbuf;
|
||||
|
||||
drive= burn_write_opts_get_drive(opts);
|
||||
|
||||
reasons= calloc(1, BURN_REASONS_LEN);
|
||||
msg= calloc(1, 160+BURN_REASONS_LEN);
|
||||
adr= calloc(1, BURN_DRIVE_ADR_LEN);
|
||||
if(reasons == NULL || msg == NULL || adr == NULL) {
|
||||
/* To cause a negative reply with burn_drive_wrote_well() */
|
||||
burn_drive_cancel(drive);
|
||||
goto ex;
|
||||
}
|
||||
|
||||
ret= isoburn_find_emulator(&o, drive, 0);
|
||||
if(ret<0)
|
||||
return;
|
||||
goto ex;
|
||||
if(o!=NULL) {
|
||||
o->wrote_well= -1;
|
||||
if(o->emulation_mode!=0) {
|
||||
@@ -874,7 +887,7 @@ void isoburn_disc_write(struct burn_write_opts *opts, struct burn_disc *disc)
|
||||
"It might help to first deformat it and then format it again");
|
||||
isoburn_msgs_submit(o, 0x00060000, msg, 0, "HINT", 0);
|
||||
burn_drive_cancel(drive); /* mark run as failure */
|
||||
return;
|
||||
goto ex;
|
||||
}
|
||||
/* end of DVD-RW oriented check */
|
||||
burn_write_opts_set_start_byte(opts, nwa * (off_t) 2048);
|
||||
@@ -890,7 +903,7 @@ void isoburn_disc_write(struct burn_write_opts *opts, struct burn_disc *disc)
|
||||
o->wrote_well= 0;
|
||||
/* To cause a negative reply with burn_drive_wrote_well() */
|
||||
burn_drive_cancel(drive);
|
||||
return;
|
||||
goto ex;
|
||||
}
|
||||
|
||||
sprintf(reasons, "%d", (int) write_type);
|
||||
@@ -921,6 +934,13 @@ void isoburn_disc_write(struct burn_write_opts *opts, struct burn_disc *disc)
|
||||
}
|
||||
|
||||
burn_disc_write(opts, disc);
|
||||
ex:;
|
||||
if(reasons != NULL)
|
||||
free(reasons);
|
||||
if(msg != NULL)
|
||||
free(msg);
|
||||
if(adr != NULL)
|
||||
free(adr);
|
||||
}
|
||||
|
||||
|
||||
@@ -1187,12 +1207,16 @@ int isoburn_read_iso_head_parse(struct burn_drive *d, unsigned char *data,
|
||||
int isoburn_read_iso_head(struct burn_drive *d, int lba,
|
||||
int *image_blocks, char *info, int flag)
|
||||
{
|
||||
unsigned char buffer[64*1024];
|
||||
unsigned char *buffer= NULL;
|
||||
int ret, info_mode, capacity, role;
|
||||
off_t data_count, to_read;
|
||||
enum burn_disc_status s;
|
||||
struct isoburn *o;
|
||||
|
||||
buffer= calloc(1, 64 * 1024);
|
||||
if(buffer == NULL)
|
||||
{ret= -1; goto ex;}
|
||||
|
||||
info_mode= flag&255;
|
||||
*image_blocks= 0;
|
||||
if(flag&(1<<13)) {
|
||||
@@ -1204,7 +1228,7 @@ int isoburn_read_iso_head(struct burn_drive *d, int lba,
|
||||
if (role == 3 || role == 5)
|
||||
|
||||
/* >>> ??? return always 0 ? */
|
||||
return(-1*!!(flag&(1<<15)));
|
||||
{ret= (-1*!!(flag&(1<<15))); goto ex;}
|
||||
|
||||
ret = burn_get_read_capacity(d, &capacity, 0);
|
||||
if (ret <= 0 && (role == 2 || role == 4)) {
|
||||
@@ -1218,7 +1242,7 @@ int isoburn_read_iso_head(struct burn_drive *d, int lba,
|
||||
ret= isoburn_find_emulator(&o, d, 0);
|
||||
if(ret > 0)
|
||||
if(o->media_read_error)
|
||||
return(-1 * !!(flag & (1 << 15)));
|
||||
{ret= (-1 * !!(flag & (1 << 15))); goto ex;}
|
||||
if(to_read >= (off_t) (64 * 1024))
|
||||
to_read= 64 * 1024;
|
||||
ret = burn_read_data(d, ((off_t) lba) * (off_t) 2048, (char *) buffer,
|
||||
@@ -1226,7 +1250,7 @@ int isoburn_read_iso_head(struct burn_drive *d, int lba,
|
||||
} else
|
||||
ret= 0;
|
||||
if(ret<=0)
|
||||
return(-1*!!(flag&(1<<15)));
|
||||
{ret= (-1*!!(flag&(1<<15))); goto ex;}
|
||||
if(info_mode==2)
|
||||
memcpy(info, buffer, 64*1024);
|
||||
}
|
||||
@@ -1234,15 +1258,19 @@ int isoburn_read_iso_head(struct burn_drive *d, int lba,
|
||||
if(flag&(1<<14)) {
|
||||
ret= isoburn_read_iso_head_parse(d, buffer, image_blocks, info, info_mode);
|
||||
if(ret<0)
|
||||
return(ret);
|
||||
goto ex;
|
||||
if(ret>0)
|
||||
return(2);
|
||||
{ret= 2; goto ex;}
|
||||
}
|
||||
ret= isoburn_read_iso_head_parse(d, buffer+32*1024, image_blocks, info,
|
||||
info_mode);
|
||||
if(ret<=0)
|
||||
return(ret);
|
||||
return(1);
|
||||
goto ex;
|
||||
ret= 1;
|
||||
ex:;
|
||||
if(buffer != NULL)
|
||||
free(buffer);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
@@ -1288,17 +1316,22 @@ int isoburn_emulate_toc(struct burn_drive *d, int flag)
|
||||
int scan_start= 0, scan_count= 0, probe_minus_16= 0, growisofs_nwa, role;
|
||||
int with_enclosure= 0, readable_blocks= -1;
|
||||
struct isoburn *o;
|
||||
char msg[160], size_text[80], *sev, volid[33], *volid_pt= NULL;
|
||||
char *msg= NULL, *size_text= NULL, *sev, volid[33], *volid_pt= NULL;
|
||||
time_t start_time, last_pacifier, now;
|
||||
|
||||
msg= calloc(1, 160);
|
||||
size_text= calloc(1, 80);
|
||||
if(msg == NULL || size_text == NULL)
|
||||
{ret= -1; goto ex;}
|
||||
|
||||
/* is the media emulated multi-session ? */
|
||||
ret= isoburn_find_emulator(&o, d, 0);
|
||||
if(ret<0)
|
||||
return(-1);
|
||||
{ret= -1; goto ex;}
|
||||
if(o==NULL)
|
||||
return(-1);
|
||||
{ret= -1; goto ex;}
|
||||
if(o->emulation_mode<=0 && !(flag&1))
|
||||
return(0);
|
||||
{ret= 0; goto ex;}
|
||||
|
||||
ret= burn_get_read_capacity(d, &readable_blocks, 0);
|
||||
if(ret <= 0) {
|
||||
@@ -1425,7 +1458,7 @@ int isoburn_emulate_toc(struct burn_drive *d, int flag)
|
||||
sprintf(msg, "Found %d ISO sessions by scanning %s in %.f seconds",
|
||||
session_count, size_text, (double) (now - start_time));
|
||||
isoburn_msgs_submit(o, 0x00060000, msg, 0, sev, 0);
|
||||
return(1);
|
||||
{ret= 1; goto ex;}
|
||||
failure:;
|
||||
isoburn_toc_entry_destroy(&(o->toc), 1);
|
||||
if(with_enclosure && o->emulation_mode == 1) {
|
||||
@@ -1438,6 +1471,11 @@ failure:;
|
||||
session_count= 0;
|
||||
ret= isoburn_make_toc_entry(o, &session_count, 0, image_size, NULL, 0);
|
||||
}
|
||||
ex:;
|
||||
if(msg != NULL)
|
||||
free(msg);
|
||||
if(size_text != NULL)
|
||||
free(size_text);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@@ -1775,7 +1813,7 @@ int isoburn_set_msc1(struct burn_drive *d, int adr_mode, char *adr_value,
|
||||
int ret, num_sessions= 0, num_tracks, adr_num, i, j, total_tracks;
|
||||
int lba, best_lba, size, re_valid= 0, track_count= 0;
|
||||
time_t start_time= 0, last_pacifier= 0, now;
|
||||
char volid[33], msg[160];
|
||||
char volid[33], *msg= NULL;
|
||||
struct isoburn *o;
|
||||
struct isoburn_toc_disc *disc= NULL;
|
||||
struct isoburn_toc_session **sessions= NULL;
|
||||
@@ -1792,6 +1830,10 @@ int isoburn_set_msc1(struct burn_drive *d, int adr_mode, char *adr_value,
|
||||
if(o==NULL)
|
||||
return(-1);
|
||||
|
||||
msg= calloc(1, 160);
|
||||
if(msg == NULL)
|
||||
{ret= -1; goto ex;}
|
||||
|
||||
start_time= last_pacifier= time(NULL);
|
||||
adr_num= atoi(adr_value);
|
||||
if(adr_mode!=3 || (flag & 2)) {
|
||||
@@ -1926,6 +1968,8 @@ ex:;
|
||||
isoburn_toc_disc_free(disc);
|
||||
if((flag & 4) && re_valid)
|
||||
regfree(&re);
|
||||
if(msg != NULL)
|
||||
free(msg);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user