New API call isoburn_conv_name_chars()

This commit is contained in:
Thomas Schmitt 2013-12-28 19:48:44 +00:00
parent da50c59d27
commit 61244da0bf
4 changed files with 190 additions and 99 deletions

View File

@ -393,83 +393,22 @@ int isoburn_adjust_target_iso_head(struct isoburn *o,
} }
/* @param flag bit0= modifying rather than growing /* @param out_o The output isoburn object may be NULL if no real write run is
bit1= prepare for early release of input drive: desired with opts.
wait until input and then disable image data source @param flag bit0= modifying rather than growing
*/ */
static static
int isoburn_prepare_disc_aux(struct burn_drive *in_d, struct burn_drive *out_d, int isoburn_make_iso_write_opts(struct isoburn *out_o,
struct burn_disc **disc, struct isoburn_imgen_opts *opts,
struct isoburn_imgen_opts *opts, int flag) int fifo_chunks,
IsoWriteOpts *wopts,
int flag)
{ {
struct burn_source *wsrc; int ret, rec_mtime, new_img, lba, nwa, i;
struct burn_session *session; struct burn_drive *out_d;
struct burn_track *track;
struct isoburn *in_o, *out_o;
IsoWriteOpts *wopts= NULL;
enum burn_disc_status state;
int ret, fifo_chunks, lba, nwa, i, new_img, early_indev_release, rec_mtime;
uint32_t data_start= -1;
size_t buffer_size= 0, buffer_free= 0;
char *msg= NULL;
msg= calloc(1, 160);
if(msg == NULL)
{ret= -1; goto ex;}
new_img= flag&1; new_img= flag&1;
early_indev_release= flag&2;
ret= isoburn_find_emulator(&in_o, in_d, 0);
if(ret<0 || in_o==NULL)
{ret= -1; goto ex;}
ret= isoburn_find_emulator(&out_o, out_d, 0);
if(ret<0 || out_o==NULL)
{ret= -1; goto ex;}
/* early end will be registered as failure */
in_o->wrote_well= out_o->wrote_well= 0;
if(new_img && early_indev_release) {
isoburn_msgs_submit(in_o, 0x00060000,
"Programming error: Wrong session setup: new_img && early_indev_release",
0, "FATAL", 0);
{ret= -4; goto ex;}
}
out_o->do_tao = opts->do_tao;
state = isoburn_disc_get_status(in_d);
if (state != BURN_DISC_BLANK && state != BURN_DISC_APPENDABLE &&
state != BURN_DISC_FULL) {
isoburn_msgs_submit(in_o, 0x00060000, "Unsuitable source media state",
0, "FAILURE", 0);
{ret= -2; goto ex;}
}
state = isoburn_disc_get_status(out_d);
if (state != BURN_DISC_BLANK && state != BURN_DISC_APPENDABLE) {
isoburn_msgs_submit(out_o, 0x00060000, "Unsuitable target media state",
0, "FAILURE", 0);
{ret= -2; goto ex;}
}
if (state != BURN_DISC_BLANK && opts->libjte_handle != NULL) {
isoburn_msgs_submit(out_o, 0x00060000,
"Jigdo Template Extraction works only on blank target media",
0, "FAILURE", 0);
{ret= -2; goto ex;}
}
fifo_chunks= 32;
if(opts->fifo_size >= 64*1024 && opts->fifo_size <= 1024.0 * 1024.0 * 1024.0){
fifo_chunks= opts->fifo_size/2048;
if(fifo_chunks*2048 < opts->fifo_size)
fifo_chunks++;
}
ret = iso_write_opts_new(&wopts, 0);
if (ret < 0) {
isoburn_report_iso_error(ret, "Cannot create iso_write_opts", 0, "FATAL",0);
goto ex;
}
iso_write_opts_set_will_cancel(wopts, opts->will_cancel); iso_write_opts_set_will_cancel(wopts, opts->will_cancel);
iso_write_opts_set_iso_level(wopts, opts->level); iso_write_opts_set_iso_level(wopts, opts->level);
iso_write_opts_set_rockridge(wopts, opts->rockridge); iso_write_opts_set_rockridge(wopts, opts->rockridge);
@ -540,6 +479,8 @@ int isoburn_prepare_disc_aux(struct burn_drive *in_d, struct burn_drive *out_d,
iso_write_opts_attach_jte(wopts, opts->libjte_handle); iso_write_opts_attach_jte(wopts, opts->libjte_handle);
iso_write_opts_set_hfsp_serial_number(wopts, opts->hfsp_serial_number); iso_write_opts_set_hfsp_serial_number(wopts, opts->hfsp_serial_number);
if(out_o != NULL) {
out_d= out_o->drive;
ret= isoburn_adjust_target_iso_head(out_o, opts->partition_offset, 0); ret= isoburn_adjust_target_iso_head(out_o, opts->partition_offset, 0);
if(ret <= 0) if(ret <= 0)
{ret= -1; goto ex;} {ret= -1; goto ex;}
@ -573,6 +514,7 @@ int isoburn_prepare_disc_aux(struct burn_drive *in_d, struct burn_drive *out_d,
iso_write_opts_set_appendable(wopts, !new_img); iso_write_opts_set_appendable(wopts, !new_img);
iso_write_opts_set_overwrite_buf(wopts, iso_write_opts_set_overwrite_buf(wopts,
nwa>0 ? out_o->target_iso_head : NULL); nwa>0 ? out_o->target_iso_head : NULL);
}
iso_write_opts_set_part_offset(wopts, opts->partition_offset, iso_write_opts_set_part_offset(wopts, opts->partition_offset,
opts->partition_secs_per_head, opts->partition_secs_per_head,
opts->partition_heads_per_cyl); opts->partition_heads_per_cyl);
@ -607,6 +549,93 @@ int isoburn_prepare_disc_aux(struct burn_drive *in_d, struct burn_drive *out_d,
} }
iso_write_opts_set_disc_label(wopts, opts->ascii_disc_label); iso_write_opts_set_disc_label(wopts, opts->ascii_disc_label);
ret= 1;
ex:
return(ret);
}
/* @param flag bit0= modifying rather than growing
bit1= prepare for early release of input drive:
wait until input and then disable image data source
*/
static
int isoburn_prepare_disc_aux(struct burn_drive *in_d, struct burn_drive *out_d,
struct burn_disc **disc,
struct isoburn_imgen_opts *opts, int flag)
{
struct burn_source *wsrc;
struct burn_session *session;
struct burn_track *track;
struct isoburn *in_o, *out_o;
IsoWriteOpts *wopts= NULL;
enum burn_disc_status state;
int ret, fifo_chunks, i, new_img, early_indev_release;
uint32_t data_start= -1;
size_t buffer_size= 0, buffer_free= 0;
char *msg= NULL;
msg= calloc(1, 160);
if(msg == NULL)
{ret= -1; goto ex;}
new_img= flag&1;
early_indev_release= flag&2;
ret= isoburn_find_emulator(&in_o, in_d, 0);
if(ret<0 || in_o==NULL)
{ret= -1; goto ex;}
ret= isoburn_find_emulator(&out_o, out_d, 0);
if(ret<0 || out_o==NULL)
{ret= -1; goto ex;}
/* early end will be registered as failure */
in_o->wrote_well= out_o->wrote_well= 0;
if(new_img && early_indev_release) {
isoburn_msgs_submit(in_o, 0x00060000,
"Programming error: Wrong session setup: new_img && early_indev_release",
0, "FATAL", 0);
{ret= -4; goto ex;}
}
out_o->do_tao = opts->do_tao;
state = isoburn_disc_get_status(in_d);
if (state != BURN_DISC_BLANK && state != BURN_DISC_APPENDABLE &&
state != BURN_DISC_FULL) {
isoburn_msgs_submit(in_o, 0x00060000, "Unsuitable source media state",
0, "FAILURE", 0);
{ret= -2; goto ex;}
}
state = isoburn_disc_get_status(out_d);
if (state != BURN_DISC_BLANK && state != BURN_DISC_APPENDABLE) {
isoburn_msgs_submit(out_o, 0x00060000, "Unsuitable target media state",
0, "FAILURE", 0);
{ret= -2; goto ex;}
}
if (state != BURN_DISC_BLANK && opts->libjte_handle != NULL) {
isoburn_msgs_submit(out_o, 0x00060000,
"Jigdo Template Extraction works only on blank target media",
0, "FAILURE", 0);
{ret= -2; goto ex;}
}
fifo_chunks= 32;
if(opts->fifo_size >= 64*1024 && opts->fifo_size <= 1024.0 * 1024.0 * 1024.0){
fifo_chunks= opts->fifo_size/2048;
if(fifo_chunks*2048 < opts->fifo_size)
fifo_chunks++;
}
ret= iso_write_opts_new(&wopts, 0);
if (ret < 0) {
isoburn_report_iso_error(ret, "Cannot create iso_write_opts", 0, "FATAL",0);
goto ex;
}
ret= isoburn_make_iso_write_opts(out_o, opts, fifo_chunks, wopts, flag & 1);
if(ret < 0)
goto ex;
ret = iso_image_create_burn_source(in_o->image, wopts, &wsrc); ret = iso_image_create_burn_source(in_o->image, wopts, &wsrc);
if (ret < 0) { if (ret < 0) {
isoburn_report_iso_error(ret, "Cannot create burn source", 0, "FAILURE", 0); isoburn_report_iso_error(ret, "Cannot create burn source", 0, "FAILURE", 0);
@ -1727,3 +1756,24 @@ int isoburn_igopt_get_write_type(struct isoburn_imgen_opts *opts, int *do_tao)
} }
int isoburn_conv_name_chars(struct isoburn_imgen_opts *opts,
char *name, size_t name_len,
char **result, size_t *result_len, int flag)
{
int ret;
IsoWriteOpts *wopts= NULL;
ret = iso_write_opts_new(&wopts, 0);
if (ret < 0) {
isoburn_report_iso_error(ret, "Cannot create iso_write_opts", 0, "FATAL",0);
goto ex;
}
ret= isoburn_make_iso_write_opts(NULL, opts, 0, wopts, 0);
if(ret < 0)
goto ex;
ret= iso_conv_name_chars(wopts, name, name_len, result, result_len, flag);
ex:;
if(wopts != NULL)
iso_write_opts_free(wopts);
return(ret);
}

View File

@ -1893,6 +1893,46 @@ int isoburn_igopt_set_write_type(struct isoburn_imgen_opts *opts, int do_tao);
int isoburn_igopt_get_write_type(struct isoburn_imgen_opts *opts, int *do_tao); int isoburn_igopt_get_write_type(struct isoburn_imgen_opts *opts, int *do_tao);
/** Frontend of libisofs call iso_conv_name_chars() controlled by
struct isoburn_imgen_opts rather than IsoWriteOpts.
See libisofs.h for a more detailed description.
@since 1.3.6
@param opts
Defines options like output charset, UCS-2 versus UTF-16 for Joliet,
and naming restrictions.
@param name
The input text which shall be converted.
@param name_len
The number of bytes in input text.
@param result
Will return the conversion result in case of success. Terminated by
a trailing zero byte.
Use free() to dispose it when no longer needed.
@param result_len
Will return the number of bytes in result (excluding trailing zero)
@param flag
Bitfield for control purposes.
bit0-bit7= Name space
0= generic (to_charset is valid,
no reserved characters, no length limits)
1= Rock Ridge (to_charset is valid)
2= Joliet (to_charset gets overridden by UCS-2 or UTF-16)
3= ECMA-119 (to_charset gets overridden by the
dull ISO 9660 subset of ASCII)
4= HFS+ (to_charset gets overridden by UTF-16BE)
bit8= Treat input text as directory name
(matters for Joliet and ECMA-119)
bit9= Do not issue error messages
bit15= Reverse operation (best to be done only with results of
previous conversions)
@return
1 means success, <=0 means error
*/
int isoburn_conv_name_chars(struct isoburn_imgen_opts *opts,
char *name, size_t name_len,
char **result, size_t *result_len, int flag);
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/* End of Options for image generation */ /* End of Options for image generation */
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */

View File

@ -3,6 +3,7 @@ global:
isoburn_activate_session; isoburn_activate_session;
isoburn_attach_image; isoburn_attach_image;
isoburn_attach_start_lba; isoburn_attach_start_lba;
isoburn_conv_name_chars;
isoburn_cancel_prepared_write; isoburn_cancel_prepared_write;
isoburn_disc_available_space; isoburn_disc_available_space;
isoburn_disc_erasable; isoburn_disc_erasable;

View File

@ -1 +1 @@
#define Xorriso_timestamP "2013.12.18.074401" #define Xorriso_timestamP "2013.12.28.194725"