|
|
|
@ -19,11 +19,87 @@
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
void ecma119_image_free(Ecma119Image *t)
|
|
|
|
|
{
|
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
|
|
ecma119_node_free(t->root);
|
|
|
|
|
iso_image_unref(t->image);
|
|
|
|
|
iso_file_src_free(t);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < t->nwriters; ++i) {
|
|
|
|
|
IsoImageWriter *writer = t->writers[i];
|
|
|
|
|
writer->free_data(writer);
|
|
|
|
|
free(writer);
|
|
|
|
|
}
|
|
|
|
|
free(t->writers);
|
|
|
|
|
free(t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
int ecma119_writer_compute_data_blocks(IsoImageWriter *writer)
|
|
|
|
|
{
|
|
|
|
|
//TODO to implement
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
int ecma119_writer_write_vol_desc(IsoImageWriter *writer)
|
|
|
|
|
{
|
|
|
|
|
//TODO to implement
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
int ecma119_writer_write_data(IsoImageWriter *writer)
|
|
|
|
|
{
|
|
|
|
|
//TODO to implement
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
int ecma119_writer_free_data(IsoImageWriter *writer)
|
|
|
|
|
{
|
|
|
|
|
//TODO to implement
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int ecma119_writer_create(Ecma119Image *target)
|
|
|
|
|
{
|
|
|
|
|
int ret;
|
|
|
|
|
IsoImageWriter *writer;
|
|
|
|
|
|
|
|
|
|
writer = malloc(sizeof(IsoImageWriter));
|
|
|
|
|
if (writer == NULL) {
|
|
|
|
|
return ISO_MEM_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
writer->compute_data_blocks = ecma119_writer_compute_data_blocks;
|
|
|
|
|
writer->write_vol_desc = ecma119_writer_write_vol_desc;
|
|
|
|
|
writer->write_data = ecma119_writer_write_data;
|
|
|
|
|
writer->free_data = ecma119_writer_free_data;
|
|
|
|
|
writer->data = NULL;
|
|
|
|
|
writer->target = target;
|
|
|
|
|
|
|
|
|
|
/* add this writer to image */
|
|
|
|
|
target->writers[target->nwriters++] = writer;
|
|
|
|
|
|
|
|
|
|
ret = ecma119_tree_create(target);
|
|
|
|
|
if (ret < 0) {
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* we need the volume descriptor */
|
|
|
|
|
target->curblock++;
|
|
|
|
|
return ISO_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
int ecma119_image_new(IsoImage *src, Ecma119WriteOpts *opts,
|
|
|
|
|
Ecma119Image **img)
|
|
|
|
|
{
|
|
|
|
|
int ret;
|
|
|
|
|
int ret, i;
|
|
|
|
|
Ecma119Image *target;
|
|
|
|
|
|
|
|
|
|
/* 1. Allocate target and copy opts there */
|
|
|
|
@ -33,16 +109,12 @@ int ecma119_image_new(IsoImage *src, Ecma119WriteOpts *opts,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
target->image = src;
|
|
|
|
|
iso_image_ref(src);
|
|
|
|
|
|
|
|
|
|
target->iso_level = opts->level;
|
|
|
|
|
|
|
|
|
|
target->now = time(NULL);
|
|
|
|
|
|
|
|
|
|
ret = ecma119_tree_create(target, src->root);
|
|
|
|
|
if (ret < 0) {
|
|
|
|
|
// TODO free image data
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 2. Based on those options, create needed writers: iso, joliet...
|
|
|
|
|
* Each writer inits its structures and stores needed info into
|
|
|
|
@ -51,6 +123,25 @@ int ecma119_image_new(IsoImage *src, Ecma119WriteOpts *opts,
|
|
|
|
|
* current block.
|
|
|
|
|
* Finally, create Writer for files.
|
|
|
|
|
*/
|
|
|
|
|
target->curblock = 16;
|
|
|
|
|
|
|
|
|
|
/* the number of writers is dependent of the extensions */
|
|
|
|
|
target->writers = malloc(2 * sizeof(void*));
|
|
|
|
|
if (target->writers == NULL) {
|
|
|
|
|
iso_image_unref(src);
|
|
|
|
|
free(target);
|
|
|
|
|
return ISO_MEM_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* create writer for ECMA-119 structure */
|
|
|
|
|
ret = ecma119_writer_create(target);
|
|
|
|
|
if (ret < 0) {
|
|
|
|
|
goto target_cleanup;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Volume Descriptor Set Terminator */
|
|
|
|
|
target->curblock++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 3.
|
|
|
|
@ -58,12 +149,24 @@ int ecma119_image_new(IsoImage *src, Ecma119WriteOpts *opts,
|
|
|
|
|
* That function computes the size needed by its structures and
|
|
|
|
|
* increments image current block propertly.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < target->nwriters; ++i) {
|
|
|
|
|
IsoImageWriter *writer = target->writers[i];
|
|
|
|
|
ret = writer->compute_data_blocks(writer);
|
|
|
|
|
if (ret < 0) {
|
|
|
|
|
goto target_cleanup;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 4. Start writting thread */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*img = target;
|
|
|
|
|
return ISO_SUCCESS;
|
|
|
|
|
|
|
|
|
|
target_cleanup:;
|
|
|
|
|
ecma119_image_free(target);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
@ -83,12 +186,7 @@ bs_get_size(struct burn_source *bs)
|
|
|
|
|
static void
|
|
|
|
|
bs_free_data(struct burn_source *bs)
|
|
|
|
|
{
|
|
|
|
|
Ecma119Image *t = (Ecma119Image*)bs->data;
|
|
|
|
|
ecma119_node_free(t->root);
|
|
|
|
|
iso_image_unref(t->image);
|
|
|
|
|
iso_file_src_free(t);
|
|
|
|
|
|
|
|
|
|
free(t);
|
|
|
|
|
ecma119_image_free((Ecma119Image*)bs->data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|