Changed struct isoburn_source_opts to opaque handle struct isoburn_imgen_opts

This commit is contained in:
Thomas Schmitt 2008-01-28 23:58:12 +00:00
parent 55b155efb9
commit 0c40b2f513
5 changed files with 480 additions and 113 deletions

View File

@ -253,7 +253,7 @@ int isoburn_find_by_drive(struct isoburn **pt, struct burn_drive *d, int flag)
static
int isoburn_prepare_disc_aux(struct burn_drive *d, struct burn_disc **disc,
struct isoburn_source_opts *opts, int new_img)
struct isoburn_imgen_opts *opts, int new_img)
{
struct burn_source *wsrc;
struct burn_session *session;
@ -370,13 +370,13 @@ ex:
}
int isoburn_prepare_disc(struct burn_drive *d, struct burn_disc **disc,
struct isoburn_source_opts *opts)
struct isoburn_imgen_opts *opts)
{
return isoburn_prepare_disc_aux(d, disc, opts, 0);
}
int isoburn_prepare_new_image(struct burn_drive *d, struct burn_disc **disc,
struct isoburn_source_opts *opts,
struct isoburn_imgen_opts *opts,
struct burn_drive *out_drive)
{
int ret;
@ -413,3 +413,193 @@ void isoburn_version(int *major, int *minor, int *micro)
*micro = ISOBURN_MICRO_VERSION;
}
int isoburn_igopt_new(struct isoburn_imgen_opts **new_o, int flag)
{
struct isoburn_imgen_opts *o;
o= (*new_o)= calloc(1, sizeof(struct isoburn_imgen_opts));
if(o==NULL)
return(-1);
o->level= 2;
o->rockridge= 1;
o->joliet= 0;
o->iso1999= 0;
o->omit_version_numbers= 0;
o->allow_deep_paths= 1;
o->allow_longer_paths= 0;
o->max_37_char_filenames= 0;
o->no_force_dots= 0;
o->allow_lowercase= 0;
o->allow_full_ascii= 0;
o->joliet_longer_paths= 0;
o->sort_files= 0;
o->replace_dir_mode= 0;
o->replace_file_mode= 0;
o->replace_uid= 0;
o->replace_gid= 0;
o->dir_mode= 0555;
o->file_mode= 0444;
o->uid= 0;
o->gid= 0;
o->output_charset= 0;
o->fifo_size= 4*1024*1024;
return(1);
}
int isoburn_igopt_destroy(struct isoburn_imgen_opts **o, int flag)
{
if(*o==NULL)
return(0);
free(*o);
*o= NULL;
return(1);
}
int isoburn_igopt_set_level(struct isoburn_imgen_opts *o, int level)
{
o->level= level;
return(1);
}
int isoburn_igopt_get_level(struct isoburn_imgen_opts *o, int *level)
{
*level= o->level;
return(1);
}
int isoburn_igopt_set_extensions(struct isoburn_imgen_opts *o, int ext)
{
o->rockridge= !!(ext&1);
o->joliet= !!(ext&2);
o->iso1999= !!(ext&4);
return(1);
}
int isoburn_igopt_get_extensions(struct isoburn_imgen_opts *o, int *ext)
{
*ext= (!!o->rockridge) | ((!!o->joliet)<<1) | ((!!o->iso1999)<<2);
return(1);
}
int isoburn_igopt_set_relaxed(struct isoburn_imgen_opts *o, int relax)
{
o->omit_version_numbers= !!(relax&1);
o->allow_deep_paths= !!(relax&2);
o->allow_longer_paths= !!(relax&4);
o->max_37_char_filenames= !!(relax&8);
o->no_force_dots= !!(relax&16);
o->allow_lowercase= !!(relax&32);
o->allow_full_ascii= !!(relax&64);
o->joliet_longer_paths= !!(relax&128);
return(1);
}
int isoburn_igopt_get_relaxed(struct isoburn_imgen_opts *o, int *relax)
{
*relax= (!!o->omit_version_numbers) | ((!!o->allow_deep_paths)<<1) |
((!!o->allow_longer_paths)<<2) | ((!!o->max_37_char_filenames)<<3) |
((!!o->no_force_dots)<<4) | ((!!o->allow_lowercase)<<5) |
((!!o->allow_full_ascii)<<6) | ((!!o->joliet_longer_paths)<<7);
return(1);
}
int isoburn_igopt_set_sort_files(struct isoburn_imgen_opts *o, int value)
{
o->sort_files= !!(value&1);
return(1);
}
int isoburn_igopt_get_sort_files(struct isoburn_imgen_opts *o, int *value)
{
*value= !!o->sort_files;
return(1);
}
int isoburn_igopt_set_over_mode(struct isoburn_imgen_opts *o,
int replace_dir_mode, int replace_file_mode,
mode_t dir_mode, mode_t file_mode)
{
o->replace_dir_mode= replace_dir_mode%3;
o->replace_file_mode= replace_file_mode%3;
o->dir_mode= dir_mode;
o->file_mode= file_mode;
return(1);
}
int isoburn_igopt_get_over_mode(struct isoburn_imgen_opts *o,
int *replace_dir_mode, int *replace_file_mode,
mode_t *dir_mode, mode_t *file_mode)
{
*replace_dir_mode= o->replace_dir_mode%3;
*replace_file_mode= o->replace_file_mode%3;
*dir_mode= o->dir_mode;
*file_mode= o->file_mode;
return(1);
}
int isoburn_igopt_set_over_ugid(struct isoburn_imgen_opts *o,
int replace_uid, int replace_gid,
uid_t uid, gid_t gid)
{
o->replace_uid= replace_uid%3;
o->replace_gid= replace_gid%3;
o->uid= uid;
o->gid= gid;
return(1);
}
int isoburn_igopt_get_over_ugid(struct isoburn_imgen_opts *o,
int *replace_uid, int *replace_gid,
uid_t *uid, gid_t *gid)
{
*replace_uid= o->replace_uid%3;
*replace_gid= o->replace_gid%3;
*uid= o->uid;
*gid= o->gid;
return(1);
}
int isoburn_igopt_set_out_charset(struct isoburn_imgen_opts *o,
char *output_charset)
{
o->output_charset= output_charset;
return(1);
}
int isoburn_igopt_get_out_charset(struct isoburn_imgen_opts *o,
char **output_charset)
{
*output_charset= o->output_charset;
return(1);
}
int isoburn_igopt_set_fifo_size(struct isoburn_imgen_opts *o, int fifo_size)
{
o->fifo_size= fifo_size;
return(1);
}
int isoburn_igopt_get_fifo_size(struct isoburn_imgen_opts *o, int *fifo_size)
{
*fifo_size= o->fifo_size;
return(1);
}

View File

@ -143,5 +143,115 @@ int isoburn_set_start_byte(struct isoburn *o, off_t value, int flag);
IsoDataSource *
isoburn_data_source_new(struct burn_drive *d);
/**
* Options for image generation by libisofs and image transport to libburn.
*/
struct isoburn_imgen_opts {
/* Options for image generation */
int level; /**< ISO level to write at. */
/** Which extensions to support. */
unsigned int rockridge :1;
unsigned int joliet :1;
unsigned int iso1999 :1;
/* relaxed constraints */
/*
* Relaxed constraints. Setting any of these to 1 break the specifications,
* but it is supposed to work on most moderns systems. Use with caution.
*/
/**
* Omit the version number (";1") at the end of the ISO-9660 identifiers.
* Version numbers are usually not used.
*/
unsigned int omit_version_numbers :1;
/**
* Allow ISO-9660 directory hierarchy to be deeper than 8 levels.
*/
unsigned int allow_deep_paths :1;
/**
* Allow path in the ISO-9660 tree to have more than 255 characters.
*/
unsigned int allow_longer_paths :1;
/**
* Allow a single file or directory hierarchy to have up to 37 characters.
* This is larger than the 31 characters allowed by ISO level 2, and the
* extra space is taken from the version number, so this also forces
* omit_version_numbers.
*/
unsigned int max_37_char_filenames :1;
/**
* ISO-9660 forces filenames to have a ".", that separates file name from
* extension. libisofs adds it if original filename doesn't has one. Set
* this to 1 to prevent this behavior
*/
unsigned int no_force_dots :1;
/**
* Allow lowercase characters in ISO-9660 filenames. By default, only
* uppercase characters, numbers and a few other characters are allowed.
*/
unsigned int allow_lowercase :1;
/**
* Allow all ASCII characters to be appear on an ISO-9660 filename. Note
* that "/" and "\0" characters are never allowed, even in RR names.
*/
unsigned int allow_full_ascii :1;
/**
* Allow paths in the Joliet tree to have more than 240 characters.
*/
unsigned int joliet_longer_paths :1;
unsigned int sort_files:1;
/**< If files should be sorted based on their weight. */
/**
* The following options set the default values for files and directory
* permissions, gid and uid. All these take one of three values: 0, 1 or 2.
* If 0, the corresponding attribute will be kept as set in the IsoNode.
* Unless you have changed it, it corresponds to the value on disc, so it
* is suitable for backup purposes. If set to 1, the corresponding attrib.
* will be changed by a default suitable value. Finally, if you set it to
* 2, the attrib. will be changed with the value specified in the options
* below. Note that for mode attributes, only the permissions are set, the
* file type remains unchanged.
*/
unsigned int replace_dir_mode :2;
unsigned int replace_file_mode :2;
unsigned int replace_uid :2;
unsigned int replace_gid :2;
mode_t dir_mode; /** Mode to use on dirs when replace_dir_mode == 2. */
mode_t file_mode; /** Mode to use on files when replace_file_mode == 2. */
uid_t uid; /** uid to use when replace_uid == 2. */
gid_t gid; /** gid to use when replace_gid == 2. */
char *output_charset; /**< NULL to use default charset */
/* Options for image transport */
/** The number of bytes to be used for the fifo which decouples libisofs
and libburn for better throughput and for reducing the risk of
interrupting signals hitting the libburn thread which operates the
MMC drive.
The size will be rounded up to the next full 2048.
Minimum is 64kiB, maximum is 1 GiB (but that is too much anyway).
*/
int fifo_size;
};
#endif /* Isoburn_includeD */

View File

@ -58,7 +58,7 @@ struct isoburn_read_opts
Writing of result images is controlled by libisofs related parameters
in struct isoburn_source_opts
in struct isoburn_imgen_opts
>>> which the application obtains from libisoburn.
@ -175,6 +175,10 @@ void isoburn_disc_erase(struct burn_drive *drive, int fast);
/* >>> this goes to isoburn.h */
/* >>> Opaque definition of isoburn_read_opts */
/* >>> Constructor, destructor, getters, setters. */
/**
* Options for image reading.
*/
@ -214,119 +218,168 @@ struct isoburn_read_opts {
unsigned int pretend_blank:1; /* always create empty image */
};
/* >>> this goes to isoburn.h */
/**
* Options for image generation by libisofs and image transport to libburn.
*/
struct isoburn_source_opts {
/* Options for image generation */
/* ----------------------------------------------------------------------- */
/*
int level; /**< ISO level to write at. */
/** Which extensions to support. */
unsigned int rockridge :1;
unsigned int joliet :1;
unsigned int iso1999 :1;
Options for image generation by libisofs and image transport to libburn.
/* relaxed constraints */
An application shall create an option set object by isoburn_igopt_new(),
program it by isoburn_igopt_set_*(), use it with either
isoburn_prepare_new_image() or isoburn_prepare_disc(), and finally delete
it by isoburn_igopt_destroy().
/*
* Relaxed constraints. Setting any of these to 1 break the specifications,
* but it is supposed to work on most moderns systems. Use with caution.
*/
*/
/* ----------------------------------------------------------------------- */
/**
* Omit the version number (";1") at the end of the ISO-9660 identifiers.
* Version numbers are usually not used.
*/
unsigned int omit_version_numbers :1;
struct isoburn_imgen_opts;
/**
* Allow ISO-9660 directory hierarchy to be deeper than 8 levels.
*/
unsigned int allow_deep_paths :1;
/**
* Allow path in the ISO-9660 tree to have more than 255 characters.
*/
unsigned int allow_longer_paths :1;
/**
* Allow a single file or directory hierarchy to have up to 37 characters.
* This is larger than the 31 characters allowed by ISO level 2, and the
* extra space is taken from the version number, so this also forces
* omit_version_numbers.
*/
unsigned int max_37_char_filenames :1;
/**
* ISO-9660 forces filenames to have a ".", that separates file name from
* extension. libisofs adds it if original filename doesn't has one. Set
* this to 1 to prevent this behavior
*/
unsigned int no_force_dots :1;
/**
* Allow lowercase characters in ISO-9660 filenames. By default, only
* uppercase characters, numbers and a few other characters are allowed.
*/
unsigned int allow_lowercase :1;
/**
* Allow all ASCII characters to be appear on an ISO-9660 filename. Note
* that "/" and "\0" characters are never allowed, even in RR names.
*/
unsigned int allow_full_ascii :1;
/**
* Allow paths in the Joliet tree to have more than 240 characters.
*/
unsigned int joliet_longer_paths :1;
unsigned int sort_files:1;
/**< If files should be sorted based on their weight. */
/**
* The following options set the default values for files and directory
* permissions, gid and uid. All these take one of three values: 0, 1 or 2.
* If 0, the corresponding attribute will be kept as set in the IsoNode.
* Unless you have changed it, it corresponds to the value on disc, so it
* is suitable for backup purposes. If set to 1, the corresponding attrib.
* will be changed by a default suitable value. Finally, if you set it to
* 2, the attrib. will be changed with the value specified in the options
* below. Note that for mode attributes, only the permissions are set, the
* file type remains unchanged.
*/
unsigned int replace_dir_mode :2;
unsigned int replace_file_mode :2;
unsigned int replace_uid :2;
unsigned int replace_gid :2;
mode_t dir_mode; /** Mode to use on dirs when replace_dir_mode == 2. */
mode_t file_mode; /** Mode to use on files when replace_file_mode == 2. */
uid_t uid; /** uid to use when replace_uid == 2. */
gid_t gid; /** gid to use when replace_gid == 2. */
char *output_charset; /**< NULL to use default charset */
/** Produces a set of generation and transfer options, initialized with default
values.
@param o the newly created option set object
@return 1=ok , <0 = failure
*/
int isoburn_igopt_new(struct isoburn_imgen_opts **o, int flag);
/* Options for image transport */
/** Deletes an option set which was created by isoburn_igopt_new().
It is harmless to submit *o == NULL.
*/
int isoburn_igopt_destroy(struct isoburn_imgen_opts **o, int flag);
/** The number of bytes to be used for the fifo which decouples libisofs
and libburn for better throughput and for reducing the risk of
interrupting signals hitting the libburn thread which operates the
MMC drive.
The size will be rounded up to the next full 2048.
Minimum is 64kiB, maximum is 1 GiB (but that is too much anyway).
*/
int fifo_size;
};
/** ISO level to write at.
>>> what is an ISO level ? xorriso uses 2.
*/
int isoburn_igopt_set_level(struct isoburn_imgen_opts *o, int level);
int isoburn_igopt_get_level(struct isoburn_imgen_opts *o, int *level);
/* >>> Opaque definitions of isoburn_read_opts and isoburn_source_opts */
/* >>> Constructors, destructors, getters, setters. */
/* >>> Learn what libisofs does */
/** Which extensions to support.
@param ext Bitfield: bit0= rockridge, bit1= joliet, bit2= iso1999
*/
#define isoburn_igopt_rockridge 1
#define isoburn_igopt_joliet 2
#define isoburn_igopt_iso1999 4
int isoburn_igopt_set_extensions(struct isoburn_imgen_opts *o, int ext);
int isoburn_igopt_get_extensions(struct isoburn_imgen_opts *o, int *ext);
/** Relaxed constraints. Setting any of the bits to 1 break the specifications,
but it is supposed to work on most moderns systems. Use with caution.
@param relax Bitfield:
bit0= omit_version_numbers
Omit the version number (";1") at the end of the
ISO-9660 identifiers. Version numbers are usually
not used.
bit1= allow_deep_paths
Allow ISO-9660 directory hierarchy to be deeper
than 8 levels.
bit2= allow_longer_paths
Allow path in the ISO-9660 tree to have more than
255 characters.
bit3= max_37_char_filenames
Allow a single file or directory hierarchy to have
up to 37 characters. This is larger than the 31
characters allowed by ISO level 2, and the extra space
is taken from the version number, so this also forces
omit_version_numbers.
bit4= no_force_dots
ISO-9660 forces filenames to have a ".", that separates
file name from extension. libisofs adds it if original
filename has none. Set this to 1 to prevent this
behavior.
bit5= allow_lowercase
Allow lowercase characters in ISO-9660 filenames.
By default, only uppercase characters, numbers and
a few other characters are allowed.
bit6= allow_full_ascii
Allow all ASCII characters to be appear on an ISO-9660
filename. Note * that "/" and "\0" characters are never
allowed, even in RR names.
bit7= joliet_longer_paths
Allow paths in the Joliet tree to have more than
240 characters.
*/
#define isoburn_igopt_omit_version_numbers 1
#define isoburn_igopt_allow_deep_paths 2
#define isoburn_igopt_allow_longer_paths 4
#define isoburn_igopt_max_37_char_filenames 8
#define isoburn_igopt_no_force_dots 16
#define isoburn_igopt_allow_lowercase 32
#define isoburn_igopt_allow_full_ascii 64
#define isoburn_igopt_joliet_longer_paths 128
int isoburn_igopt_set_relaxed(struct isoburn_imgen_opts *o, int relax);
int isoburn_igopt_get_relaxed(struct isoburn_imgen_opts *o, int *relax);
/** Whether and how files should be sorted.
@param value Bitfield: bit0= sort_files_by_weight
files should be sorted based on their weight.
>>> what is weight ?
*/
#define isoburn_igopt_sort_files_by_weight 1
int isoburn_igopt_set_sort_files(struct isoburn_imgen_opts *o, int value);
int isoburn_igopt_get_sort_files(struct isoburn_imgen_opts *o, int *value);
/** Set the override values for files and directory permissions.
The parameters replace_* these take one of three values: 0, 1 or 2.
If 0, the corresponding attribute will be kept as set in the IsoNode
at the time of image generation.
If set to 1, the corresponding attrib. will be changed by a default
suitable value.
With value 2, the attrib. will be changed with the value specified
in the corresponding *_mode options. Note that only the permissions
are set, the file type remains unchanged.
@param replace_dir_mode whether and how to override directories
@param replace_file_mode whether and how to override files of other type
@param dir_mode Mode to use on dirs with replace_dir_mode == 2.
@param file_mode; Mode to use on files with replace_file_mode == 2.
*/
int isoburn_igopt_set_over_mode(struct isoburn_imgen_opts *o,
int replace_dir_mode, int replace_file_mode,
mode_t dir_mode, mode_t file_mode);
int isoburn_igopt_get_over_mode(struct isoburn_imgen_opts *o,
int *replace_dir_mode, int *replace_file_mode,
mode_t *dir_mode, mode_t *file_mode);
/** Set the override values values for group id and user id.
The rules are like with above overriding of mode values. replace_* controls
whether and how. The other two parameters provide values for eventual use.
@param replace_uid whether and how to override user ids
@param replace_gid whether and how to override group ids
@param uid User id to use with replace_uid == 2.
@param gid Group id to use on files with replace_gid == 2.
*/
int isoburn_igopt_set_over_ugid(struct isoburn_imgen_opts *o,
int replace_uid, int replace_gid,
uid_t uid, gid_t gid);
int isoburn_igopt_get_over_ugid(struct isoburn_imgen_opts *o,
int *replace_uid, int *replace_gid,
uid_t *uid, gid_t *gid);
/** Set this to NULL to use the default charset.
>>> What if not NULL or not want default ?
*/
int isoburn_igopt_set_out_charset(struct isoburn_imgen_opts *o,
char *output_charset);
int isoburn_igopt_get_out_charset(struct isoburn_imgen_opts *o,
char **output_charset);
/** The number of bytes to be used for the fifo which decouples libisofs
and libburn for better throughput and for reducing the risk of
interrupting signals hitting the libburn thread which operates the
MMC drive.
The size will be rounded up to the next full 2048.
Minimum is 64kiB, maximum is 1 GiB (but that is too much anyway).
*/
int isoburn_igopt_set_fifo_size(struct isoburn_imgen_opts *o, int fifo_size);
int isoburn_igopt_get_fifo_size(struct isoburn_imgen_opts *o, int *fifo_size);
/* ----------------------------------------------------------------------- */
/* End of Options for image generation */
/* ----------------------------------------------------------------------- */
/** Get the image attached to a drive, if any.
@ -422,7 +475,7 @@ int isoburn_get_min_start_byte(struct burn_drive *d, off_t *start_byte,
@return <=0 error , 1 = success
*/
int isoburn_prepare_disc(struct burn_drive *d, struct burn_disc **disc,
struct isoburn_source_opts *opts);
struct isoburn_imgen_opts *opts);
/** Create a disc object for producing a new image from a previous image
@ -447,7 +500,7 @@ int isoburn_prepare_disc(struct burn_drive *d, struct burn_disc **disc,
*/
int isoburn_prepare_new_image(struct burn_drive *in_drive,
struct burn_disc **disc,
struct isoburn_source_opts *opts,
struct isoburn_imgen_opts *opts,
struct burn_drive *out_drive);
/** Start writing of the new session.

View File

@ -1 +1 @@
#define Xorriso_timestamP "2008.01.28.171915"
#define Xorriso_timestamP "2008.01.28.235717"

View File

@ -519,7 +519,7 @@ int Xorriso_make_write_options(
int Xorriso_write_session(struct XorrisO *xorriso, int flag)
{
int ret, media_space;
struct isoburn_source_opts sopts;
struct isoburn_imgen_opts *sopts= NULL;
struct burn_drive_info *dinfo, *source_dinfo;
struct burn_drive *drive, *source_drive;
struct burn_disc *disc= NULL;
@ -535,8 +535,20 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag)
if(ret<=0)
return(0);
memset(&sopts, 0, sizeof(sopts));
ret= isoburn_igopt_new(&sopts, 0);
if(ret<=0)
return(ret);
isoburn_igopt_set_level(sopts, 2);
isoburn_igopt_set_extensions(sopts, 1|((!!xorriso->do_joliet)<<1));
isoburn_igopt_set_relaxed(sopts, isoburn_igopt_allow_deep_paths);
isoburn_igopt_set_sort_files(sopts, 1);
isoburn_igopt_set_over_mode(sopts, 0, 0, (mode_t) 0, (mode_t) 0);
isoburn_igopt_set_over_ugid(sopts, 0, 0, (uid_t) 0, (gid_t) 0);
isoburn_igopt_set_out_charset(sopts, NULL);
isoburn_igopt_set_fifo_size(sopts, xorriso->fs * 2048);
#ifdef NIX
memset(&sopts, 0, sizeof(sopts));
sopts.level= 2;
sopts.rockridge= 1;
sopts.joliet= !!xorriso->do_joliet;
@ -560,10 +572,11 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag)
sopts.gid= xorriso->global_gid;
sopts.output_charset= NULL;
sopts.fifo_size= xorriso->fs * 2048;
#endif /* NIX */
if(xorriso->out_drive_handle == xorriso->in_drive_handle ||
xorriso->in_drive_handle == NULL) {
ret= isoburn_prepare_disc(drive, &disc, &sopts);
ret= isoburn_prepare_disc(drive, &disc, sopts);
} else {
s= isoburn_disc_get_status(drive);
if(s!=BURN_DISC_BLANK) {
@ -581,7 +594,7 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag)
"on attempt to get source for write", 0);
if(ret<=0)
goto ex;
ret= isoburn_prepare_new_image(source_drive, &disc, &sopts, drive);
ret= isoburn_prepare_new_image(source_drive, &disc, sopts, drive);
}
if (ret <= 0) {
Xorriso_process_msg_queues(xorriso,0);
@ -649,6 +662,7 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag)
ex:;
if(disc!=NULL)
burn_disc_free(disc);
isoburn_igopt_destroy(&sopts, 0);
Xorriso_process_msg_queues(xorriso,0);
return(ret);
}