Changed struct isoburn_read_opts to opaque handle

This commit is contained in:
Thomas Schmitt 2008-01-29 13:00:46 +00:00
parent 6225d48f2c
commit ddc26570fd
5 changed files with 301 additions and 62 deletions

View File

@ -408,12 +408,137 @@ int isoburn_prepare_new_image(struct burn_drive *d, struct burn_disc **disc,
void isoburn_version(int *major, int *minor, int *micro)
{
*major = ISOBURN_MAJOR_VERSION;
*minor = ISOBURN_MINOR_VERSION;
*micro = ISOBURN_MICRO_VERSION;
*major = ISOBURN_MAJOR_VERSION;
*minor = ISOBURN_MINOR_VERSION;
*micro = ISOBURN_MICRO_VERSION;
}
int isoburn_is_compatible(int major, int minor, int micro, int flag)
{
int own_major, own_minor, own_micro;
isoburn_version(&own_major, &own_minor, &own_micro);
return(own_major > major ||
(own_major == major && (own_minor > minor ||
(own_minor == minor && own_micro >= micro))));
}
/* ----------------------------------------------------------------------- */
/*
Options for image reading.
*/
/* ----------------------------------------------------------------------- */
int isoburn_ropt_new(struct isoburn_read_opts **new_o, int flag)
{
struct isoburn_read_opts *o;
o= (*new_o)= calloc(1, sizeof(struct isoburn_read_opts));
if(o==NULL)
return(-1);
o->norock= 0;
o->nojoliet= 0;
o->noiso1999= 1;
o->preferjoliet= 0;
o->uid= geteuid();
o->gid= getegid();
o->mode= 0444; /* >>> would need 0555 for directories */
o->input_charset= NULL;
o->hasRR= 0;
o->hasJoliet= 0;
o->hasIso1999= 0;
o->hasElTorito= 0;
o->size= 0;
o->pretend_blank= 1;
return(1);
}
int isoburn_ropt_destroy(struct isoburn_read_opts **o, int flag)
{
if(*o==NULL)
return(0);
free(*o);
*o= NULL;
return(1);
}
int isoburn_ropt_set_extensions(struct isoburn_read_opts *o, int ext)
{
o->norock= !!(ext&1);
o->nojoliet= !!(ext&2);
o->noiso1999= !!(ext&4);
o->preferjoliet= !!(ext&8);
o->pretend_blank= !!(ext&16);
return(1);
}
int isoburn_ropt_get_extensions(struct isoburn_read_opts *o, int *ext)
{
*ext= (!!o->norock) | ((!!o->nojoliet)<<1) | ((!!o->noiso1999)<<2) |
((!!o->preferjoliet)<<3) | ((!!o->pretend_blank)<<4);
return(1);
}
int isoburn_ropt_set_default_perms(struct isoburn_read_opts *o,
uid_t uid, gid_t gid, mode_t mode)
{
o->uid= uid;
o->gid= gid;
o->mode= mode;
return(1);
}
int isoburn_ropt_get_default_perms(struct isoburn_read_opts *o,
uid_t *uid, gid_t *gid, mode_t *mode)
{
*uid= o->uid;
*gid= o->gid;
*mode= o->mode;
return(1);
}
int isoburn_ropt_set_input_charset(struct isoburn_read_opts *o,
char *input_charset)
{
o->input_charset= input_charset;
return(1);
}
int isoburn_igopt_get_in_charset(struct isoburn_read_opts *o,
char **input_charset)
{
*input_charset= o->input_charset;
return(1);
}
int isoburn_ropt_get_size_what(struct isoburn_read_opts *o,
uint32_t *size, int *has_what)
{
*size= o->size;
*has_what= (!!o->hasRR) | ((!!o->hasJoliet)<<1) |
((!!o->hasIso1999)<<2) | ((!!o->hasElTorito)<<3);
return(1);
}
/* ----------------------------------------------------------------------- */
/*
Options for image generation by libisofs and image transport to libburn.
*/
/* ----------------------------------------------------------------------- */
int isoburn_igopt_new(struct isoburn_imgen_opts **new_o, int flag)
{
struct isoburn_imgen_opts *o;

View File

@ -144,8 +144,54 @@ IsoDataSource *
isoburn_data_source_new(struct burn_drive *d);
/**
* Options for image reading.
(Comments here may be outdated. API getter/setter function descriptions
may override the descriptions here. Any difference is supposed to be a
minor correction only.)
*/
struct isoburn_read_opts {
unsigned int norock:1; /*< Do not read Rock Ridge extensions */
unsigned int nojoliet:1; /*< Do not read Joliet extensions */
unsigned int noiso1999:1; /*< Do not read ISO 9660:1999 enhanced tree */
unsigned int preferjoliet:1;
/*< When both Joliet and RR extensions are present, the RR
* tree is used. If you prefer using Joliet, set this to 1. */
uid_t uid; /**< Default uid when no RR */
gid_t gid; /**< Default uid when no RR */
mode_t mode; /**< Default mode when no RR (only permissions) */
/**
* Input charset for RR file names. NULL to use default locale charset.
*/
char *input_charset;
/* modified by the function isoburn_read_image */
unsigned int hasRR:1; /*< It will be set to 1 if RR extensions are present,
to 0 if not. */
unsigned int hasJoliet:1; /*< It will be set to 1 if Joliet extensions are
present, to 0 if not. */
/**
* It will be set to 1 if the image is an ISO 9660:1999, i.e. it has
* a version 2 Enhanced Volume Descriptor.
*/
unsigned int hasIso1999:1;
/** It will be set to 1 if El-Torito boot record is present, to 0 if not.*/
unsigned int hasElTorito:1;
uint32_t size; /**< Will be filled with the size (in 2048 byte block) of
* the image, as reported in the PVM. */
unsigned int pretend_blank:1; /* always create empty image */
};
/**
* Options for image generation by libisofs and image transport to libburn.
(Comments here may be outdated. API getter/setter function descriptions
may override the descriptions here. Any difference is supposed to be a
minor correction only.)
*/
struct isoburn_imgen_opts {

View File

@ -23,13 +23,13 @@ The priciple of this frontend is that you may use any call of libisofs or
libburn unless it has a isoburn_*() wrapper listed in the following function
documentation.
E.g. call isoburn_initialize() rather than iso_init(); burn_initialize()
E.g. call isoburn_initialize() rather than iso_init(); burn_initialize();
and call isoburn_drive_scan_and_grab() rather than burn_drive_scan_and_grab().
But you may call burn_disc_get_profile() directly if you want to display
the media type.
The wrappers will transparently provide the necessary emulations which
are appropriate for particular target "drives" and media states.
are appropriate for particular target drives and media states.
To learn about them you have to read both API descriptions: the one of
the wrapper and the one of the underlying libburn or libisofs call.
@ -45,26 +45,24 @@ Both drive roles can be fulfilled by the same drive.
Input can be a random access readable libburn drive:
optical media, regular files, block devices.
Output can be any writeable libburn drive:
writeable optical media in burner, writeable file objects (no directories).\
writeable optical media in burner, writeable file objects (no directories).
libburn needs rw-permissions to drive device file resp. file object.
libburn demands rw-permissions to drive device file resp. file object.
If the input drive provides a suitable ISO RockRidge image, then its tree
may be loaded into memory and can then be manipulated by libisofs API calls.
The loading is done by isoburn_read_image() under control of
struct isoburn_read_opts
>>> which the application obtains from libisoburn.
struct isoburn_read_opts which the application obtains from libisoburn.
It may be manipulated by the family of isoburn_ropt_set_*() functions.
Writing of result images is controlled by libisofs related parameters
in struct isoburn_imgen_opts
>>> which the application obtains from libisoburn.
in a struct isoburn_imgen_opts which the application obtains from libisoburn.
It may be manipulated by the family of isoburn_igopt_set_*() functions.
All multi-session aspects are handled by libisoburn according to these
settings. The application does not have to analyze media state and write
job parameters.
job parameters. It rather states its desires which libisoburn tries to
fulfill, or else will refuse to start the write run.
Setup for Growing or Modifying
@ -174,57 +172,112 @@ int isoburn_disc_erasable(struct burn_drive *d);
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.
/**
* Options for image reading.
*/
struct isoburn_read_opts {
unsigned int norock:1; /*< Do not read Rock Ridge extensions */
unsigned int nojoliet:1; /*< Do not read Joliet extensions */
unsigned int noiso1999:1; /*< Do not read ISO 9660:1999 enhanced tree */
unsigned int preferjoliet:1;
/*< When both Joliet and RR extensions are present, the RR
* tree is used. If you prefer using Joliet, set this to 1. */
uid_t uid; /**< Default uid when no RR */
gid_t gid; /**< Default uid when no RR */
mode_t mode; /**< Default mode when no RR (only permissions) */
An application shall create an option set object by isoburn_ropt_new(),
program it by isoburn_ropt_set_*(), use it with isoburn_read_image(),
and finally delete it by isoburn_ropt_destroy().
/**
* Input charset for RR file names. NULL to use default locale charset.
*/
char *input_charset;
*/
/* ----------------------------------------------------------------------- */
/* modified by the function isoburn_read_image */
unsigned int hasRR:1; /*< It will be set to 1 if RR extensions are present,
to 0 if not. */
unsigned int hasJoliet:1; /*< It will be set to 1 if Joliet extensions are
present, to 0 if not. */
struct isoburn_read_opts;
/**
* It will be set to 1 if the image is an ISO 9660:1999, i.e. it has
* a version 2 Enhanced Volume Descriptor.
*/
unsigned int hasIso1999:1;
/** Produces a set of image read options, initialized with default values.
@param o the newly created option set object
@return 1=ok , <0 = failure
*/
int isoburn_ropt_new(struct isoburn_read_opts **o, int flag);
/** It will be set to 1 if El-Torito boot record is present, to 0 if not.*/
unsigned int hasElTorito:1;
uint32_t size; /**< Will be filled with the size (in 2048 byte block) of
* the image, as reported in the PVM. */
unsigned int pretend_blank:1; /* always create empty image */
};
/** Deletes an option set which was created by isoburn_ropt_new().
@return 1= **o destroyed , 0= *o was already NULL (harmless)
*/
int isoburn_ropt_destroy(struct isoburn_read_opts **o, int flag);
/** Which existing ISO 9660 extensions in the image to read or not to read.
Whether to read the content of an existing image at all.
The bits can be combined by | resp. inquired by &.
@param ext Bitfield:
bit0= norock
Do not read Rock Ridge extensions
bit1= nojoliet
Do not read Joliet extensions
bit2= noiso1999
Do not read ISO 9660:1999 enhanced tree
bit3= preferjoliet
When both Joliet and RR extensions are present, the RR
tree is used. If you prefer using Joliet, set this to 1.
bit4= pretend_blank
Always create empty image.Ignore any image on input drive.
*/
#define isoburn_ropt_norock 1
#define isoburn_ropt_nojoliet 2
#define isoburn_ropt_noiso1999 4
#define isoburn_ropt_preferjoliet 8
#define isoburn_ropt_pretend_blank 16
int isoburn_ropt_set_extensions(struct isoburn_read_opts *o, int ext);
int isoburn_ropt_get_extensions(struct isoburn_read_opts *o, int *ext);
/** Default attributes to use if no RockRidge extension gets loaded.
@param uid user id number (see /etc/passwd)
@param gid group id number (see /etc/group)
@param mode permissions (not file type) as of man 2 stat.
*/
int isoburn_ropt_set_default_perms(struct isoburn_read_opts *o,
uid_t uid, gid_t gid, mode_t mode);
int isoburn_ropt_get_default_perms(struct isoburn_read_opts *o,
uid_t *uid, gid_t *gid, mode_t *mode);
/** Input charset for RR file names. NULL to use default locale charset.
>>> what if not NULL ?
*/
int isoburn_ropt_set_input_charset(struct isoburn_read_opts *o,
char *input_charset);
int isoburn_ropt_get_input_charset(struct isoburn_read_opts *o,
char **input_charset);
/** After calling function isoburn_read_image() there are informations
available in the option set.
This info can be obtained as bits in parameter has_what. Like:
joliet_available = (has_what & isoburn_ropt_has_joliet);
@param size Number of image data blocks, 2048 bytes each.
@param has_what Bitfield:
bit0= has_rockridge
RockRidge extension info is available (POSIX filesystem)
bit1= has_joliet
Joliet extension info is available (suitable for MS-Windows)
bit2= has_iso1999
ISO version 2 Enhanced Volume Descriptor is available
>>> what is ISO 1999 good for ?
bit3= has_el_torito
El-Torito boot record is present
*/
#define isoburn_ropt_has_rockridge 1
#define isoburn_ropt_has_joliet 2
#define isoburn_ropt_has_iso1999 4
#define isoburn_ropt_has_el_torito 8
int isoburn_ropt_get_size_what(struct isoburn_read_opts *o,
uint32_t *size, int *has_what);
/* ----------------------------------------------------------------------- */
/* End of Options for image reading */
/* ----------------------------------------------------------------------- */
/* ----------------------------------------------------------------------- */
/*
Options for image generation by libisofs and image transport to libburn.
An application shall create an option set object by isoburn_igopt_new(),
An application shall create an option set 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().
@ -243,7 +296,7 @@ int isoburn_igopt_new(struct isoburn_imgen_opts **o, int flag);
/** Deletes an option set which was created by isoburn_igopt_new().
It is harmless to submit *o == NULL.
@return 1= **o destroyed , 0= *o was already NULL (harmless)
*/
int isoburn_igopt_destroy(struct isoburn_imgen_opts **o, int flag);

View File

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

View File

@ -211,7 +211,7 @@ int Xorriso_create_empty_iso(struct XorrisO *xorriso, int flag)
{
int ret;
IsoImage *volset;
struct isoburn_read_opts ropts;
struct isoburn_read_opts *ropts;
struct burn_drive_info *dinfo= NULL;
struct burn_drive *drive= NULL;
@ -227,11 +227,16 @@ int Xorriso_create_empty_iso(struct XorrisO *xorriso, int flag)
xorriso->loaded_volid[0]= 0;
xorriso->volset_change_pending= 0;
}
memset(&ropts, sizeof(ropts), 0);
ropts.pretend_blank= 1;
ropts.input_charset= NULL;
ret= isoburn_read_image(drive, &ropts, &volset);
ret= isoburn_ropt_new(&ropts, 0);
if(ret<=0)
return(ret);
/* Note: no return before isoburn_ropt_destroy() */
isoburn_ropt_set_extensions(ropts, isoburn_ropt_pretend_blank);
isoburn_ropt_set_input_charset(ropts, NULL);
ret= isoburn_read_image(drive, ropts, &volset);
Xorriso_process_msg_queues(xorriso,0);
isoburn_ropt_destroy(&ropts, 0);
if(ret<=0) {
sprintf(xorriso->info_text, "Failed to create new empty ISO image object");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
@ -257,7 +262,7 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag)
struct burn_drive *drive, *out_drive, *in_drive;
enum burn_disc_status state;
IsoImage *volset = NULL;
struct isoburn_read_opts ropts;
struct isoburn_read_opts *ropts= NULL;
char adr_data[SfileadrL], *libburn_adr;
if((flag&3)==0) {
@ -367,6 +372,14 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag)
return(0);
}
/* fill read opts */
ret= isoburn_ropt_new(&ropts, 0);
if(ret<=0)
return(ret);
isoburn_ropt_set_extensions(ropts, isoburn_ropt_noiso1999);
isoburn_ropt_set_default_perms(ropts, (uid_t) 0, (gid_t) 0, (mode_t) 0555);
isoburn_ropt_set_input_charset(ropts, NULL);
#ifdef NIX
memset(&ropts, sizeof(ropts), 0);
ropts.norock= 0;
ropts.nojoliet= 0;
@ -377,9 +390,10 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag)
ropts.mode= 0555;
ropts.input_charset= NULL;
ropts.pretend_blank= 0;
#endif /* NIX */
Xorriso_set_image_severities(xorriso, 1); /* No DEBUG messages */
if(isoburn_read_image(drive, &ropts, &volset) <= 0) {
if(isoburn_read_image(drive, ropts, &volset) <= 0) {
Xorriso_process_msg_queues(xorriso,0);
Xorriso_set_image_severities(xorriso, 0);
sprintf(xorriso->info_text,"Cannot read ISO image volset");
@ -411,12 +425,13 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag)
}
ret= 1+not_writeable;
ex:
Xorriso_process_msg_queues(xorriso,0);
if(ret<=0) {
hret= Xorriso_give_up_drive(xorriso, flag&3);
if(hret<ret)
ret= hret;
}
Xorriso_process_msg_queues(xorriso,0);
isoburn_ropt_destroy(&ropts, 0);
return(ret);
}