struct iso_read_image_features is now allocated by libisofs.

This commit is contained in:
Vreixo Formoso 2008-01-26 15:39:58 +01:00
parent 29058378fd
commit 0ad92fc56d
3 changed files with 25 additions and 17 deletions

View File

@ -32,7 +32,7 @@ int main(int argc, char **argv)
unsigned char buf[32 * 2048]; unsigned char buf[32 * 2048];
IsoWriteOpts *opts; IsoWriteOpts *opts;
int ret = 0; int ret = 0;
struct iso_read_image_features features; struct iso_read_image_features *features;
uint32_t ms_block; uint32_t ms_block;
IsoReadOpts *ropts; IsoReadOpts *ropts;
@ -124,10 +124,12 @@ int main(int argc, char **argv)
} }
/* round up to 32kb aligment = 16 block */ /* round up to 32kb aligment = 16 block */
ms_block = ((features.size + 15) / 16 ) * 16; ms_block = ((features->size + 15) / 16 ) * 16;
iso_write_opts_set_ms_block(opts, ms_block); iso_write_opts_set_ms_block(opts, ms_block);
iso_write_opts_set_appendable(opts, 1); iso_write_opts_set_appendable(opts, 1);
iso_write_opts_set_overwrite_buf(opts, buf); iso_write_opts_set_overwrite_buf(opts, buf);
free(features);
result = iso_image_create_burn_source(image, opts, &burn_src); result = iso_image_create_burn_source(image, opts, &burn_src);
if (result < 0) { if (result < 0) {

View File

@ -2202,7 +2202,7 @@ boot_fs_cleanup: ;
int iso_image_import(IsoImage *image, IsoDataSource *src, int iso_image_import(IsoImage *image, IsoDataSource *src,
struct iso_read_opts *opts, struct iso_read_opts *opts,
struct iso_read_image_features *features) struct iso_read_image_features **features)
{ {
int ret; int ret;
IsoImageFilesystem *fs; IsoImageFilesystem *fs;
@ -2346,11 +2346,16 @@ int iso_image_import(IsoImage *image, IsoDataSource *src,
iso_image_set_biblio_file_id(image, data->biblio_file_id); iso_image_set_biblio_file_id(image, data->biblio_file_id);
if (features != NULL) { if (features != NULL) {
features->hasJoliet = data->joliet; *features = malloc(sizeof(struct iso_read_image_features));
features->hasRR = data->rr_version != 0; if (*features == NULL) {
features->hasIso1999 = data->iso1999; ret = ISO_OUT_OF_MEM;
features->hasElTorito = data->eltorito; goto import_cleanup;
features->size = data->nblocks; }
(*features)->hasJoliet = data->joliet;
(*features)->hasRR = data->rr_version != 0;
(*features)->hasIso1999 = data->iso1999;
(*features)->hasElTorito = data->eltorito;
(*features)->size = data->nblocks;
} }
ret = ISO_SUCCESS; ret = ISO_SUCCESS;

View File

@ -171,6 +171,12 @@ struct iso_data_source {
*/ */
struct iso_read_image_features struct iso_read_image_features
{ {
/**
* Will be filled with the size (in 2048 byte block) of the image, as
* reported in the PVM.
*/
uint32_t size;
/** It will be set to 1 if RR extensions are present, to 0 if not. */ /** It will be set to 1 if RR extensions are present, to 0 if not. */
unsigned int hasRR :1; unsigned int hasRR :1;
@ -185,12 +191,6 @@ struct iso_read_image_features
/** It will be set to 1 if El-Torito boot record is present, to 0 if not.*/ /** It will be set to 1 if El-Torito boot record is present, to 0 if not.*/
unsigned int hasElTorito :1; unsigned int hasElTorito :1;
/**
* Will be filled with the size (in 2048 byte block) of the image, as
* reported in the PVM.
*/
uint32_t size;
}; };
typedef struct iso_file_source IsoFileSource; typedef struct iso_file_source IsoFileSource;
@ -946,14 +946,15 @@ int iso_read_opts_set_input_charset(IsoReadOpts *opts, const char *charset);
* @param opts * @param opts
* Options for image import * Options for image import
* @param features * @param features
* Will be filled with the features of the old image. You can pass NULL * If not NULL, a new struct iso_read_image_features will be allocated
* if you're not interested on them. * and filled with the features of the old image. It should be freed when
* no more needed. You can pass NULL if you're not interested on them.
* @return * @return
* 1 on success, < 0 on error * 1 on success, < 0 on error
*/ */
int iso_image_import(IsoImage *image, IsoDataSource *src, int iso_image_import(IsoImage *image, IsoDataSource *src,
IsoReadOpts *opts, IsoReadOpts *opts,
struct iso_read_image_features *features); struct iso_read_image_features **features);
/** /**
* Increments the reference counting of the given image. * Increments the reference counting of the given image.