New API call iso_write_opts_set_allow_7bit_ascii().

This commit is contained in:
Thomas Schmitt 2012-03-22 11:18:44 +01:00
parent 1247edff95
commit 8a2fa9fe2e
6 changed files with 61 additions and 7 deletions

View File

@ -1674,6 +1674,7 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *opts, Ecma119Image **img)
target->no_force_dots = opts->no_force_dots;
target->allow_lowercase = opts->allow_lowercase;
target->allow_full_ascii = opts->allow_full_ascii;
target->allow_7bit_ascii = opts->allow_7bit_ascii;
target->relaxed_vol_atts = opts->relaxed_vol_atts;
target->joliet_longer_paths = opts->joliet_longer_paths;
target->joliet_long_names = opts->joliet_long_names;
@ -2756,6 +2757,16 @@ int iso_write_opts_set_allow_full_ascii(IsoWriteOpts *opts, int allow)
return ISO_SUCCESS;
}
int iso_write_opts_set_allow_7bit_ascii(IsoWriteOpts *opts, int allow)
{
if (opts == NULL) {
return ISO_NULL_POINTER;
}
opts->allow_7bit_ascii = allow ? 1 : 0;
return ISO_SUCCESS;
}
int iso_write_opts_set_relaxed_vol_atts(IsoWriteOpts *opts, int allow)
{
if (opts == NULL) {

View File

@ -149,6 +149,13 @@ struct iso_write_opts {
*/
unsigned int allow_full_ascii :1;
/**
* If not allow_full_ascii is set: allow all 7 bit characters that would
* be allowed by allow_full_ascii. But still map lowercase to uppercase if
* not allow_lowercase is set to 1.
*/
unsigned int allow_7bit_ascii :1;
/**
* Allow all characters to be part of Volume and Volset identifiers on
* the Primary Volume Descriptor. This breaks ISO-9660 contraints, but
@ -477,6 +484,7 @@ struct ecma119_image
unsigned int no_force_dots :2;
unsigned int allow_lowercase :1;
unsigned int allow_full_ascii :1;
unsigned int allow_7bit_ascii :1;
unsigned int relaxed_vol_atts : 1;

View File

@ -59,6 +59,8 @@ int get_iso_name(Ecma119Image *img, IsoNode *iso, char **name)
} else {
relaxed = (int)img->allow_lowercase;
}
if (img->allow_7bit_ascii)
relaxed |= 4;
if (iso->type == LIBISO_DIR && !(img->allow_dir_id_ext)) {
if (img->untranslated_name_len > 0) {
if (strlen(ascii_name) > img->untranslated_name_len) {
@ -1234,7 +1236,7 @@ int ecma119_tree_create(Ecma119Image *img)
/*
* and we need to remangle the root directory, as the function
* above could insert new directories into the root.
* above could insert new directories into the relocation directory.
* Note that recurse = 0, as we don't need to recurse.
*/

View File

@ -1615,6 +1615,8 @@ int iso_write_opts_set_no_force_dots(IsoWriteOpts *opts, int no);
* Allow lowercase characters in ISO-9660 filenames. By default, only
* uppercase characters, numbers and a few other characters are allowed.
* This breaks ECMA-119 specification. Use with caution.
* If lowercase is not allowed then those letters get mapped to uppercase
* letters.
*
* @since 0.6.2
*/
@ -1629,6 +1631,20 @@ int iso_write_opts_set_allow_lowercase(IsoWriteOpts *opts, int allow);
*/
int iso_write_opts_set_allow_full_ascii(IsoWriteOpts *opts, int allow);
/**
* If not iso_write_opts_set_allow_full_ascii() is set to 1:
* Allow all 7-bit characters that would be allowed by allow_full_ascii, but
* map lowercase to uppercase if iso_write_opts_set_allow_lowercase()
* is not set to 1.
* @param opts
* The option set to be manipulated.
* @param allow
* If not zero, then allow what is described above.
*
* @since 1.2.2
*/
int iso_write_opts_set_allow_7bit_ascii(IsoWriteOpts *opts, int allow);
/**
* Allow all characters to be part of Volume and Volset identifiers on
* the Primary Volume Descriptor. This breaks ISO-9660 contraints, but

View File

@ -265,6 +265,7 @@ iso_write_opts_get_data_start;
iso_write_opts_new;
iso_write_opts_set_aaip;
iso_write_opts_set_aaip_susp_1_10;
iso_write_opts_set_allow_7bit_ascii;
iso_write_opts_set_allow_deep_paths;
iso_write_opts_set_allow_dir_id_ext;
iso_write_opts_set_allow_full_ascii;

View File

@ -685,17 +685,27 @@ static int valid_j_char(uint16_t c)
&& cmp_ucsbe(&c, '\\');
}
/* @param relaxed bit0+1 0= strict ECMA-119
1= additionally allow lowercase (else map to upper)
2= allow all 8-bit characters
bit2 allow all 7-bit characters (but map to upper if
not bit0+1 == 2)
*/
static char map_fileid_char(char c, int relaxed)
{
char upper;
if (relaxed == 2) /* all chars are allowed */
if (c == '/') /* Allowing slashes would cause lots of confusion */
return '_';
if ((relaxed & 3) == 2)
return c;
if (valid_d_char(c))
return c;
if ((relaxed & 4) && (c & 0x7f) == c && (c < 'a' || c > 'z'))
return c;
upper= toupper(c);
if (valid_d_char(upper)) {
if (relaxed) {
if (relaxed & 3) {
/* lower chars are allowed */
return c;
}
@ -871,8 +881,11 @@ char *iso_2_fileid(const char *src)
* @param size
* Max len for the name
* @param relaxed
* 0 only allow d-characters, 1 allow also lowe case chars,
* 2 allow all characters
* bit0+1: 0 only allow d-characters,
* 1 allow also lowe case chars,
* 2 allow all 8-bit characters,
* bit2: allow 7-bit characters (but map lowercase to uppercase if
* not bit0+1 == 2)
*/
char *iso_r_dirid(const char *src, int size, int relaxed)
{
@ -930,8 +943,11 @@ char *iso_r_dirid(const char *src, int size, int relaxed)
* @param len
* Max len for the name, without taken the "." into account.
* @param relaxed
* 0 only allow d-characters, 1 allow also lowe case chars,
* 2 allow all characters
* bit0+1: 0 only allow d-characters,
* 1 allow also lowe case chars,
* 2 allow all 8-bit characters,
* bit2: allow 7-bit characters (but map lowercase to uppercase if
* not bit0+1 == 2)
* @param forcedot
* Whether to ensure that "." is added
*/