Pacifier for isoburn_read_image()
This commit is contained in:
@ -81,6 +81,8 @@ int isoburn_new(struct isoburn **objpt, int flag)
|
||||
for(i=0;i<65536;i++)
|
||||
o->target_iso_head[i]= 0;
|
||||
o->image= NULL;
|
||||
o->read_pacifier= NULL;
|
||||
o->read_pacifier_handle= NULL;
|
||||
o->prev= NULL;
|
||||
o->next= NULL;
|
||||
ret= iso_image_new("ISOIMAGE", &o->image);
|
||||
|
@ -74,6 +74,12 @@ struct isoburn {
|
||||
struct burn_source *iso_source;
|
||||
#endif /* Libisoburn_no_fifO */
|
||||
|
||||
/* For iso_tree_set_report_callback() */
|
||||
int (*read_pacifier)(IsoImage*, IsoFileSource*);
|
||||
|
||||
/* For iso_image_attach_data() */
|
||||
void *read_pacifier_handle;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -100,6 +100,12 @@ IsoImage *isoburn_get_attached_image(struct burn_drive *d)
|
||||
}
|
||||
|
||||
|
||||
static void isoburn_idle_free_function(void *ignored)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* API function. See libisoburn.h
|
||||
*/
|
||||
int isoburn_read_image(struct burn_drive *d,
|
||||
@ -195,7 +201,14 @@ int isoburn_read_image(struct burn_drive *d,
|
||||
iso_read_opts_set_default_gid(ropts, read_opts->gid);
|
||||
iso_read_opts_set_input_charset(ropts, read_opts->input_charset);
|
||||
ds = isoburn_data_source_new(d);
|
||||
iso_image_attach_data(o->image, o->read_pacifier_handle,
|
||||
isoburn_idle_free_function);
|
||||
if(o->read_pacifier_handle==NULL)
|
||||
iso_tree_set_report_callback(o->image, NULL);
|
||||
else
|
||||
iso_tree_set_report_callback(o->image, o->read_pacifier);
|
||||
ret = iso_image_import(o->image, ds, ropts, &features);
|
||||
iso_tree_set_report_callback(o->image, NULL);
|
||||
iso_read_opts_free(ropts);
|
||||
iso_data_source_unref(ds);
|
||||
if (ret < 0) {
|
||||
@ -203,12 +216,10 @@ int isoburn_read_image(struct burn_drive *d,
|
||||
return ret;
|
||||
}
|
||||
/* Important: do not return until free(features) */
|
||||
|
||||
if (image!=NULL) {
|
||||
*image = o->image;
|
||||
iso_image_ref(*image); /*protects object from premature free*/
|
||||
}
|
||||
|
||||
read_opts->hasRR = iso_read_image_features_has_rockridge(features);
|
||||
read_opts->hasJoliet = iso_read_image_features_has_joliet(features);
|
||||
read_opts->hasIso1999 = iso_read_image_features_has_iso1999(features);
|
||||
@ -368,3 +379,20 @@ int isoburn_invalidate_iso(struct isoburn *o, int flag)
|
||||
return isoburn_activate_session(o->drive);
|
||||
}
|
||||
|
||||
|
||||
/* API @since 0.1.0 */
|
||||
int isoburn_set_read_pacifier(struct burn_drive *drive,
|
||||
int (*read_pacifier)(IsoImage*, IsoFileSource*),
|
||||
void *read_handle)
|
||||
{
|
||||
int ret;
|
||||
struct isoburn *o;
|
||||
|
||||
ret = isoburn_find_emulator(&o, drive, 0);
|
||||
if(ret < 0 || o == NULL)
|
||||
return -1;
|
||||
o->read_pacifier_handle= read_handle;
|
||||
o->read_pacifier= read_pacifier;
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
@ -618,6 +618,23 @@ int isoburn_read_image(struct burn_drive *d,
|
||||
struct isoburn_read_opts *read_opts,
|
||||
IsoImage **image);
|
||||
|
||||
/* @since 0.1.0 */
|
||||
/** Set a callback function for producing pacifier messages during the lengthy
|
||||
process of image reading. The callback function and the application handle
|
||||
are stored until they are needed for the underlying call to libisofs.
|
||||
Other than with libisofs the handle is managed entirely by the application.
|
||||
An idle .free() function is exposed to libisofs. The handle has to stay
|
||||
valid until isoburn_read_image() is done. It has to be detached by
|
||||
isoburn_set_read_pacifier(drive, NULL, NULL);
|
||||
before it may be removed from memory.
|
||||
@param drive The drive which will be used with isoburn_read_image()
|
||||
@param read_pacifier The callback function
|
||||
@param app_handle The app handle which the callback function can obtain
|
||||
via iso_image_get_attached_data() from its IsoImage*
|
||||
*/
|
||||
int isoburn_set_read_pacifier(struct burn_drive *drive,
|
||||
int (*read_pacifier)(IsoImage*, IsoFileSource*),
|
||||
void *app_handle);
|
||||
|
||||
/** Set the IsoImage to be used with a drive. This eventually releases
|
||||
the reference to the old IsoImage attached to the drive.
|
||||
|
Reference in New Issue
Block a user