Completed implementation of API call iso_conv_name_chars()
This commit is contained in:
parent
b0e68bbcaa
commit
1be57e34ec
@ -155,13 +155,13 @@ static int show_chunk_to_jte(Ecma119Image *target, char *buf, int count)
|
||||
* Check if we should add version number ";" to the given node name.
|
||||
*/
|
||||
static
|
||||
int need_version_number(Ecma119Image *t, Ecma119Node *n)
|
||||
int need_version_number(IsoWriteOpts *opts, enum ecma119_node_type node_type)
|
||||
{
|
||||
if ((t->opts->omit_version_numbers & 1) ||
|
||||
t->opts->max_37_char_filenames || t->opts->untranslated_name_len > 0) {
|
||||
if ((opts->omit_version_numbers & 1) ||
|
||||
opts->max_37_char_filenames || opts->untranslated_name_len > 0) {
|
||||
return 0;
|
||||
}
|
||||
if (n->type == ECMA119_DIR || n->type == ECMA119_PLACEHOLDER) {
|
||||
if (node_type == ECMA119_DIR || node_type == ECMA119_PLACEHOLDER) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
@ -175,7 +175,7 @@ static
|
||||
size_t calc_dirent_len(Ecma119Image *t, Ecma119Node *n)
|
||||
{
|
||||
int ret = n->iso_name ? strlen(n->iso_name) + 33 : 34;
|
||||
if (need_version_number(t, n)) {
|
||||
if (need_version_number(t->opts, n->type)) {
|
||||
ret += 2; /* take into account version numbers */
|
||||
}
|
||||
if (ret % 2)
|
||||
@ -384,7 +384,7 @@ void write_one_dir_record(Ecma119Image *t, Ecma119Node *node, int file_id,
|
||||
|
||||
memcpy(rec->file_id, name, len_fi);
|
||||
|
||||
if (need_version_number(t, node)) {
|
||||
if (need_version_number(t->opts, node->type)) {
|
||||
len_dr += 2;
|
||||
rec->file_id[len_fi++] = ';';
|
||||
rec->file_id[len_fi++] = '1';
|
||||
@ -671,7 +671,7 @@ int write_one_dir(Ecma119Image *t, Ecma119Node *dir, Ecma119Node *parent)
|
||||
|
||||
/* compute len of directory entry */
|
||||
len = fi_len + 33 + ((fi_len % 2) ? 0 : 1);
|
||||
if (need_version_number(t, child)) {
|
||||
if (need_version_number(t->opts, child->type)) {
|
||||
len += 2;
|
||||
}
|
||||
|
||||
@ -3483,6 +3483,9 @@ int iso_write_opts_set_hfsp_block_size(IsoWriteOpts *opts,
|
||||
* 2= Joliet (to_charset gets overriden by UCS-2 or UTF-16)
|
||||
* 3= ECMA-119 (dull ISO 9660 character set)
|
||||
* 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)
|
||||
*/
|
||||
@ -3491,20 +3494,30 @@ int iso_conv_name_chars(IsoWriteOpts *opts, char *in_name, size_t name_len,
|
||||
{
|
||||
int name_space, ret, reverse;
|
||||
size_t i;
|
||||
char *from_charset, *to_charset, *conved = NULL, *smashed = NULL, *name;
|
||||
char *tr;
|
||||
size_t joliet_ucs2_failures = ISO_JOLIET_UCS2_WARN_MAX + 1;/* no warning */
|
||||
size_t conved_len;
|
||||
uint16_t *ucs;
|
||||
char *from_charset, *to_charset, *conved, *smashed = NULL, *name;
|
||||
char *tr, *with_version = NULL;
|
||||
uint16_t *ucs = NULL, *hfspcmp = NULL;
|
||||
uint32_t ucs_len;
|
||||
enum IsoNodeType node_type;
|
||||
|
||||
*result = NULL;
|
||||
*result_len = 0;
|
||||
|
||||
name = in_name;
|
||||
from_charset = iso_get_local_charset(0);
|
||||
name_space = flag & 0xff;
|
||||
reverse = !!(flag & (1 << 15));
|
||||
if (name_space == 0) { /* generic */
|
||||
to_charset = opts->output_charset;
|
||||
node_type = (flag & 256) ? LIBISO_DIR : LIBISO_FILE;
|
||||
from_charset = iso_get_local_charset(0);
|
||||
|
||||
} else if (name_space == 1) { /* Rock Ridge */
|
||||
/* Note: Joliet, ECMA-119, HFS+ actually use to_charset only for the
|
||||
reverse conversion case */
|
||||
if (opts->output_charset != NULL)
|
||||
to_charset = opts->output_charset;
|
||||
else
|
||||
to_charset = from_charset;
|
||||
if (name_space == 1) { /* Rock Ridge */
|
||||
if (!reverse) {
|
||||
LIBISO_ALLOC_MEM(smashed, char, name_len + 1);
|
||||
memcpy(smashed, name, name_len);
|
||||
@ -3516,27 +3529,15 @@ int iso_conv_name_chars(IsoWriteOpts *opts, char *in_name, size_t name_len,
|
||||
|
||||
/* >>> ??? truncate to 255 chars */
|
||||
}
|
||||
|
||||
} else if (name_space == 2) { /* Joliet */
|
||||
if (opts->joliet_utf16)
|
||||
to_charset = "UTF-16BE";
|
||||
else
|
||||
to_charset = "UCS-2BE";
|
||||
/* ( Smashing happens after conversion ) */
|
||||
|
||||
} else if (name_space == 3) { /* ECMA-119 */
|
||||
to_charset = "ASCII";
|
||||
|
||||
/* >>> ??? Use an IsoWriteOpts+char of get_iso_name() */
|
||||
|
||||
} else if (name_space == 4) { /* HFS+ */
|
||||
to_charset= "UTF-16BE";
|
||||
|
||||
/* >>> ??? any other conversions for HFS+ ? */;
|
||||
|
||||
} else {
|
||||
ret = ISO_WRONG_ARG_VALUE;
|
||||
goto ex;
|
||||
}
|
||||
if (reverse) {
|
||||
tr = from_charset;
|
||||
@ -3544,30 +3545,76 @@ int iso_conv_name_chars(IsoWriteOpts *opts, char *in_name, size_t name_len,
|
||||
to_charset = tr;
|
||||
}
|
||||
|
||||
ret = strnconvl(name, from_charset, to_charset, name_len,
|
||||
&conved, &conved_len);
|
||||
if (ret != ISO_SUCCESS)
|
||||
if (name_space == 0 || reverse) {
|
||||
ret = strnconvl(name, from_charset, to_charset, name_len,
|
||||
&conved, &conved_len);
|
||||
if (ret != ISO_SUCCESS)
|
||||
goto ex;
|
||||
|
||||
} else if (name_space == 1) { /* Rock Ridge */
|
||||
ret = iso_get_rr_name(opts, from_charset, to_charset, -1, name,
|
||||
&conved, !!(flag & 512));
|
||||
if (ret != ISO_SUCCESS)
|
||||
goto ex;
|
||||
conved_len = strlen(conved);
|
||||
|
||||
} else if (name_space == 2) { /* Joliet */
|
||||
ret = iso_get_joliet_name(opts, from_charset, -1, name, node_type,
|
||||
&joliet_ucs2_failures, &ucs, !!(flag & 512));
|
||||
if (ret != ISO_SUCCESS)
|
||||
goto ex;
|
||||
conved_len = ucslen(ucs) * 2;
|
||||
conved = (char *) ucs; ucs = NULL;
|
||||
if (node_type != LIBISO_DIR && !(opts->omit_version_numbers & 3)) {
|
||||
LIBISO_ALLOC_MEM(with_version, char, conved_len + 6);
|
||||
memcpy(with_version, conved, conved_len);
|
||||
with_version[conved_len++] = 0;
|
||||
with_version[conved_len++] = ';';
|
||||
with_version[conved_len++] = 0;
|
||||
with_version[conved_len++] = '1';
|
||||
with_version[conved_len] = 0;
|
||||
with_version[conved_len + 1] = 0;
|
||||
free(conved);
|
||||
conved = with_version; with_version = NULL;
|
||||
}
|
||||
|
||||
} else if (name_space == 3) { /* ECMA-119 */
|
||||
ret = iso_get_ecma119_name(opts, from_charset, -1, name, node_type,
|
||||
&conved, !!(flag & 512));
|
||||
if (ret != ISO_SUCCESS)
|
||||
goto ex;
|
||||
conved_len = strlen(conved);
|
||||
if (need_version_number(opts, node_type == LIBISO_DIR ?
|
||||
ECMA119_DIR : ECMA119_FILE)) {
|
||||
LIBISO_ALLOC_MEM(with_version, char, conved_len + 3);
|
||||
memcpy(with_version, conved, conved_len + 1);
|
||||
strcat(with_version, ";1");
|
||||
free(conved);
|
||||
conved = with_version; with_version = NULL;
|
||||
conved_len += 2;
|
||||
}
|
||||
|
||||
} else if (name_space == 4) { /* HFS+ */
|
||||
ret = iso_get_hfsplus_name(from_charset, -1, name, &ucs, &ucs_len,
|
||||
&hfspcmp);
|
||||
if (ret != ISO_SUCCESS)
|
||||
goto ex;
|
||||
conved = (char *) ucs; ucs = NULL;
|
||||
conved_len = ucs_len * 2;
|
||||
|
||||
} else {
|
||||
ret = ISO_WRONG_ARG_VALUE;
|
||||
goto ex;
|
||||
|
||||
if (name_space == 2 && !reverse) { /* Joliet */
|
||||
|
||||
/* >>> ??? Rather use iso_j_dir_id()/iso_j_file_id()
|
||||
??? Or even an IsoWriteOpts version of get_joliet_name() ?
|
||||
*/
|
||||
|
||||
ucs = (uint16_t *) conved;
|
||||
iso_smash_chars_for_joliet(ucs);
|
||||
} else if (name_space == 3 && !reverse) { /* ECMA-119 */
|
||||
|
||||
/* >>> smash all forbidden characters ? (or use get_iso_name() ) */;
|
||||
|
||||
}
|
||||
|
||||
*result = conved;
|
||||
*result_len = conved_len;
|
||||
return ISO_SUCCESS;
|
||||
ret = ISO_SUCCESS;
|
||||
ex:
|
||||
LIBISO_FREE_MEM(with_version);
|
||||
LIBISO_FREE_MEM(smashed);
|
||||
LIBISO_FREE_MEM(ucs);
|
||||
LIBISO_FREE_MEM(hfspcmp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -29,29 +29,32 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static
|
||||
int get_iso_name(Ecma119Image *img, IsoNode *iso, char **name)
|
||||
/* @param flag bit0= Do not issue error messages
|
||||
*/
|
||||
int iso_get_ecma119_name(IsoWriteOpts *opts, char *input_charset, int imgid,
|
||||
char *node_name, enum IsoNodeType node_type,
|
||||
char **name, int flag)
|
||||
{
|
||||
int ret, relaxed, free_ascii_name = 0, force_dots = 0;
|
||||
char *ascii_name;
|
||||
char *isoname = NULL;
|
||||
IsoWriteOpts *opts = img->opts;
|
||||
|
||||
if (iso->name == NULL) {
|
||||
if (node_name == NULL) {
|
||||
/* it is not necessarily an error, it can be the root */
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
|
||||
if (opts->untranslated_name_len > 0) {
|
||||
ascii_name = iso->name;
|
||||
ascii_name = node_name;
|
||||
ret = 1;
|
||||
} else {
|
||||
ret = str2ascii(img->input_charset, iso->name, &ascii_name);
|
||||
ret = str2ascii(input_charset, node_name, &ascii_name);
|
||||
free_ascii_name = 1;
|
||||
}
|
||||
if (ret < 0) {
|
||||
iso_msg_submit(img->image->id, ret, 0,
|
||||
"Cannot convert name '%s' to ASCII", iso->name);
|
||||
if (!(flag & 512))
|
||||
iso_msg_submit(imgid, ret, 0,
|
||||
"Cannot convert name '%s' to ASCII", node_name);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -62,11 +65,12 @@ int get_iso_name(Ecma119Image *img, IsoNode *iso, char **name)
|
||||
}
|
||||
if (opts->allow_7bit_ascii)
|
||||
relaxed |= 4;
|
||||
if (iso->type == LIBISO_DIR && !(opts->allow_dir_id_ext)) {
|
||||
if (node_type == LIBISO_DIR && !(opts->allow_dir_id_ext)) {
|
||||
if (opts->untranslated_name_len > 0) {
|
||||
if (strlen(ascii_name) > opts->untranslated_name_len) {
|
||||
needs_transl:;
|
||||
iso_msg_submit(img->image->id, ISO_NAME_NEEDS_TRANSL, 0,
|
||||
if (!(flag & 512))
|
||||
iso_msg_submit(imgid, ISO_NAME_NEEDS_TRANSL, 0,
|
||||
"File name too long (%d > %d) for untranslated recording: '%s'",
|
||||
strlen(ascii_name), opts->untranslated_name_len,
|
||||
ascii_name);
|
||||
@ -101,7 +105,7 @@ needs_transl:;
|
||||
}
|
||||
} else {
|
||||
force_dots = !((opts->no_force_dots & 1) ||
|
||||
iso->type == LIBISO_DIR);
|
||||
node_type == LIBISO_DIR);
|
||||
if (opts->untranslated_name_len > 0) {
|
||||
if (strlen(ascii_name) > opts->untranslated_name_len)
|
||||
goto needs_transl;
|
||||
@ -153,6 +157,16 @@ needs_transl:;
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
int get_iso_name(Ecma119Image *img, IsoNode *iso, char **name)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = iso_get_ecma119_name(img->opts, img->input_charset, img->image->id,
|
||||
iso->name, iso->type, name, 0);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ecma119_is_dedicated_reloc_dir(Ecma119Image *img, Ecma119Node *node)
|
||||
{
|
||||
if (img->rr_reloc_node == node &&
|
||||
|
@ -103,5 +103,13 @@ Ecma119Node *ecma119_search_iso_node(Ecma119Image *img, IsoNode *node);
|
||||
*/
|
||||
int ecma119_is_dedicated_reloc_dir(Ecma119Image *img, Ecma119Node *node);
|
||||
|
||||
/**
|
||||
* Determines the ECMA-119 name from node name.
|
||||
* @param flag bit0= Do not issue error messages
|
||||
*/
|
||||
int iso_get_ecma119_name(IsoWriteOpts *opts, char *input_charset, int imgid,
|
||||
char *node_name, enum IsoNodeType node_type,
|
||||
char **name, int flag);
|
||||
|
||||
|
||||
#endif /*LIBISO_ECMA119_TREE_H_*/
|
||||
|
@ -115,8 +115,8 @@ uint8_t get_class (uint16_t v)
|
||||
return hfsplus_class_pages[high][low];
|
||||
}
|
||||
|
||||
static
|
||||
int set_hfsplus_name(Ecma119Image *t, char *name, HFSPlusNode *node)
|
||||
int iso_get_hfsplus_name(char *input_charset, int imgid, char *name,
|
||||
uint16_t **result, uint32_t *result_len, uint16_t **cmp_name)
|
||||
{
|
||||
int ret;
|
||||
uint16_t *ucs_name, *iptr, *optr;
|
||||
@ -128,19 +128,19 @@ int set_hfsplus_name(Ecma119Image *t, char *name, HFSPlusNode *node)
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
|
||||
ret = str2utf16be(t->input_charset, name, &ucs_name);
|
||||
ret = str2utf16be(input_charset, name, &ucs_name);
|
||||
if (ret < 0) {
|
||||
iso_msg_debug(t->image->id, "Can't convert %s", name);
|
||||
iso_msg_debug(imgid, "Cannot convert '%s'", name);
|
||||
return ret;
|
||||
}
|
||||
|
||||
curlen = ucslen (ucs_name);
|
||||
node->name = calloc ((curlen * HFSPLUS_MAX_DECOMPOSE_LEN + 1),
|
||||
sizeof (node->name[0]));
|
||||
if (!node->name)
|
||||
return ISO_OUT_OF_MEM;
|
||||
*result = calloc ((curlen * HFSPLUS_MAX_DECOMPOSE_LEN + 1),
|
||||
sizeof (uint16_t));
|
||||
if (*result == NULL)
|
||||
return ISO_OUT_OF_MEM;
|
||||
|
||||
for (iptr = ucs_name, optr = node->name; *iptr; iptr++)
|
||||
for (iptr = ucs_name, optr = *result; *iptr; iptr++)
|
||||
{
|
||||
const uint16_t *dptr;
|
||||
uint16_t val = iso_ntohs (*iptr);
|
||||
@ -189,7 +189,7 @@ int set_hfsplus_name(Ecma119Image *t, char *name, HFSPlusNode *node)
|
||||
if (!ucs_name[0])
|
||||
break;
|
||||
last_class = get_class (ucs_name[0]);
|
||||
for (optr = node->name + 1; *optr; optr++)
|
||||
for (optr = *result + 1; *optr; optr++)
|
||||
{
|
||||
uint8_t new_class = get_class (*optr);
|
||||
|
||||
@ -207,11 +207,11 @@ int set_hfsplus_name(Ecma119Image *t, char *name, HFSPlusNode *node)
|
||||
}
|
||||
while (done);
|
||||
|
||||
node->cmp_name = calloc ((ucslen (node->name) + 1), sizeof (node->cmp_name[0]));
|
||||
if (!node->cmp_name)
|
||||
*cmp_name = calloc ((ucslen (*result) + 1), sizeof (uint16_t));
|
||||
if (*cmp_name == NULL)
|
||||
return ISO_OUT_OF_MEM;
|
||||
|
||||
for (iptr = node->name, optr = node->cmp_name; *iptr; iptr++)
|
||||
for (iptr = *result, optr = *cmp_name; *iptr; iptr++)
|
||||
{
|
||||
*optr = iso_hfsplus_cichar(*iptr);
|
||||
if (*optr != 0)
|
||||
@ -221,10 +221,19 @@ int set_hfsplus_name(Ecma119Image *t, char *name, HFSPlusNode *node)
|
||||
|
||||
free (ucs_name);
|
||||
|
||||
node->strlen = ucslen (node->name);
|
||||
*result_len = ucslen (*result);
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
|
||||
static
|
||||
int set_hfsplus_name(Ecma119Image *t, char *name, HFSPlusNode *node)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = iso_get_hfsplus_name(t->input_charset, t->image->id, name,
|
||||
&(node->name), &(node->strlen), &(node->cmp_name));
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* >>> ts B20617
|
||||
This should be HFSPlusNode rather than IsoNode in order to have access
|
||||
|
@ -194,4 +194,8 @@ void make_hfsplus_class_pages();
|
||||
|
||||
extern const uint16_t hfsplus_casefold[];
|
||||
|
||||
int iso_get_hfsplus_name(char *input_charset, int imgid, char *name,
|
||||
uint16_t **result, uint32_t *result_len, uint16_t **cmp_name);
|
||||
|
||||
|
||||
#endif /* LIBISO_HFSPLUS_H */
|
||||
|
@ -28,50 +28,57 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static
|
||||
int get_joliet_name(Ecma119Image *t, IsoNode *iso, uint16_t **name)
|
||||
/* @param flag bit0= Do not issue error messages
|
||||
*/
|
||||
int iso_get_joliet_name(IsoWriteOpts *opts, char *input_charset, int imgid,
|
||||
char *node_name, enum IsoNodeType node_type,
|
||||
size_t *joliet_ucs2_failures,
|
||||
uint16_t **name, int flag)
|
||||
{
|
||||
int ret = ISO_SUCCESS;
|
||||
uint16_t *ucs_name = NULL, *utf16_name = NULL;
|
||||
uint16_t *jname = NULL;
|
||||
|
||||
if (iso->name == NULL) {
|
||||
if (node_name == NULL) {
|
||||
/* it is not necessarily an error, it can be the root */
|
||||
*name = NULL;
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
|
||||
if (t->opts->joliet_utf16) {
|
||||
ret = str2utf16be(t->input_charset, iso->name, &ucs_name);
|
||||
if (opts->joliet_utf16) {
|
||||
ret = str2utf16be(input_charset, node_name, &ucs_name);
|
||||
if (ret < 0) {
|
||||
iso_msg_debug(t->image->id, "Cannot convert to UTF-16 : \"%s\"",
|
||||
iso->name);
|
||||
if (!(flag & 512))
|
||||
iso_msg_debug(imgid, "Cannot convert to UTF-16 : \"%s\"",
|
||||
node_name);
|
||||
goto ex;
|
||||
}
|
||||
} else {
|
||||
ret = str2ucs(t->input_charset, iso->name, &ucs_name);
|
||||
ret = str2ucs(input_charset, node_name, &ucs_name);
|
||||
if (ret < 0) {
|
||||
iso_msg_debug(t->image->id, "Cannot convert to UCS-2 : \"%s\"",
|
||||
iso->name);
|
||||
if (!(flag & 512))
|
||||
iso_msg_debug(imgid, "Cannot convert to UCS-2 : \"%s\"",
|
||||
node_name);
|
||||
goto ex;
|
||||
}
|
||||
ret = str2utf16be(t->input_charset, iso->name, &utf16_name);
|
||||
ret = str2utf16be(input_charset, node_name, &utf16_name);
|
||||
if (ret == ISO_SUCCESS) {
|
||||
if (ucscmp(ucs_name, utf16_name) != 0) {
|
||||
t->joliet_ucs2_failures++;
|
||||
if (t->joliet_ucs2_failures <= ISO_JOLIET_UCS2_WARN_MAX) {
|
||||
iso_msg_submit(t->image->id, ISO_NAME_NOT_UCS2, 0,
|
||||
(*joliet_ucs2_failures)++;
|
||||
if (*joliet_ucs2_failures <= ISO_JOLIET_UCS2_WARN_MAX &&
|
||||
!(flag & 512)) {
|
||||
iso_msg_submit(imgid, ISO_NAME_NOT_UCS2, 0,
|
||||
"Filename not suitable for Joliet character set UCS-2 : \"%s\"",
|
||||
iso->name);
|
||||
node_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (iso->type == LIBISO_DIR) {
|
||||
jname = iso_j_dir_id(ucs_name, t->opts->joliet_long_names << 1);
|
||||
if (node_type == LIBISO_DIR) {
|
||||
jname = iso_j_dir_id(ucs_name, opts->joliet_long_names << 1);
|
||||
} else {
|
||||
jname = iso_j_file_id(ucs_name,
|
||||
(t->opts->joliet_long_names << 1) | !!(t->opts->no_force_dots & 2));
|
||||
(opts->joliet_long_names << 1) | !!(opts->no_force_dots & 2));
|
||||
}
|
||||
ret = ISO_SUCCESS;
|
||||
ex:;
|
||||
@ -95,6 +102,19 @@ ex:;
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
int get_joliet_name(Ecma119Image *t, IsoNode *iso, uint16_t **name)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = iso_get_joliet_name(t->opts, t->input_charset, t->image->id,
|
||||
iso->name, iso->type, &(t->joliet_ucs2_failures),
|
||||
name, 0);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void joliet_node_free(JolietNode *node)
|
||||
{
|
||||
|
@ -63,5 +63,13 @@ int joliet_writer_create(Ecma119Image *target);
|
||||
*/
|
||||
int joliet_writer_write_vol_desc(IsoImageWriter *writer);
|
||||
|
||||
/**
|
||||
* Determine the Joliet name from node name.
|
||||
* @param flag bit0= Do not issue error messages
|
||||
*/
|
||||
int iso_get_joliet_name(IsoWriteOpts *opts, char *input_charset, int imgid,
|
||||
char *node_name, enum IsoNodeType node_type,
|
||||
size_t *joliet_ucs2_failures,
|
||||
uint16_t **name, int flag);
|
||||
|
||||
#endif /* LIBISO_JOLIET_H */
|
||||
|
@ -7112,21 +7112,23 @@ int iso_image_hfsplus_get_blessed(IsoImage *img, IsoNode ***blessed_nodes,
|
||||
/* ----------------------------- Character sets ---------------------------- */
|
||||
|
||||
/**
|
||||
* >>> *** NOT COMPLETELY IMPLEMENTED YET ***
|
||||
* >>> Convert the characters in name from local charset to another charset or
|
||||
* >>> to the representation of a particular ISO image name space.
|
||||
* >>> In the latter case it is assumed that the conversion result does not
|
||||
* >>> collide with any other converted name in the same directory.
|
||||
* >>> I.e. this function does not take into respect possible name changes
|
||||
* >>> due to collision handling.
|
||||
* Convert the characters in name from local charset to another charset or
|
||||
* convert name to the representation of a particular ISO image name space.
|
||||
* In the latter case it is assumed that the conversion result does not
|
||||
* collide with any other converted name in the same directory.
|
||||
* I.e. this function does not take into respect possible name changes
|
||||
* due to collision handling.
|
||||
*
|
||||
* @param opts
|
||||
* Defines 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. Terminated by a trailing zero byte.
|
||||
* 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)
|
||||
@ -7137,11 +7139,12 @@ int iso_image_hfsplus_get_blessed(IsoImage *img, IsoNode ***blessed_nodes,
|
||||
* 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
|
||||
* 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= Input text is a directory name
|
||||
* 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
|
||||
|
@ -294,29 +294,44 @@ int rrip_add_CL(Ecma119Image *t, Ecma119Node *n, struct susp_info *susp)
|
||||
/**
|
||||
* Convert a RR filename to the requested charset. On any conversion error,
|
||||
* the original name will be used.
|
||||
* @param flag bit0= do not issue error messages
|
||||
*/
|
||||
static
|
||||
char *get_rr_fname(Ecma119Image *t, const char *str)
|
||||
int iso_get_rr_name(IsoWriteOpts *opts, char *input_charset,
|
||||
char *output_charset, int imgid,
|
||||
char *str, char **name, int flag)
|
||||
{
|
||||
int ret;
|
||||
char *name;
|
||||
|
||||
if (!strcmp(t->input_charset, t->output_charset)) {
|
||||
if (!strcmp(input_charset, output_charset)) {
|
||||
/* no conversion needed */
|
||||
return strdup(str);
|
||||
ret = iso_clone_mem(str, name, 0);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = strconv(str, t->input_charset, t->output_charset, &name);
|
||||
ret = strconv(str, input_charset, output_charset, name);
|
||||
if (ret < 0) {
|
||||
/* TODO we should check for possible cancelation */
|
||||
iso_msg_submit(t->image->id, ISO_FILENAME_WRONG_CHARSET, ret,
|
||||
"Charset conversion error. Can't convert %s from %s to %s",
|
||||
str, t->input_charset, t->output_charset);
|
||||
if (!(flag & 1))
|
||||
iso_msg_submit(imgid, ISO_FILENAME_WRONG_CHARSET, ret,
|
||||
"Charset conversion error. Cannot convert %s from %s to %s",
|
||||
str, input_charset, output_charset);
|
||||
|
||||
/* use the original name, it's the best we can do */
|
||||
name = strdup(str);
|
||||
ret = iso_clone_mem(str, name, 0);
|
||||
return ISO_FILENAME_WRONG_CHARSET;
|
||||
}
|
||||
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
|
||||
static
|
||||
char *get_rr_fname(Ecma119Image *t, char *str)
|
||||
{
|
||||
int ret;
|
||||
char *name = NULL;
|
||||
|
||||
ret = iso_get_rr_name(t->opts, t->input_charset, t->output_charset,
|
||||
t->image->id, str, &name, 0);
|
||||
return name;
|
||||
}
|
||||
|
||||
|
@ -346,4 +346,13 @@ int read_zisofs_ZF(struct susp_sys_user_entry *zf, uint8_t algorithm[2],
|
||||
uint8_t *header_size_div4, uint8_t *block_size_log2,
|
||||
uint32_t *uncompressed_size, int flag);
|
||||
|
||||
/**
|
||||
* Convert a RR filename to the requested charset. On any conversion error,
|
||||
* the original name will be used.
|
||||
* @param flag bit0= do not issue error messages
|
||||
*/
|
||||
int iso_get_rr_name(IsoWriteOpts *opts, char *input_charset,
|
||||
char *output_charset, int imgid,
|
||||
char *str, char **name, int flag);
|
||||
|
||||
#endif /* LIBISO_ROCKRIDGE_H */
|
||||
|
@ -278,7 +278,8 @@ int strnconvl(const char *str, const char *icharset, const char *ocharset,
|
||||
*ret = '\0';
|
||||
iso_iconv_close(&conv, 0);
|
||||
|
||||
*output = malloc(ret - out + 1);
|
||||
*out_len = ret - out;
|
||||
*output = malloc(*out_len + 1);
|
||||
if (*output == NULL) {
|
||||
retval = ISO_OUT_OF_MEM;
|
||||
goto ex;
|
||||
@ -2238,16 +2239,6 @@ void iso_handle_split_utf16(uint16_t *utf_word)
|
||||
}
|
||||
|
||||
|
||||
void iso_smash_chars_for_joliet(uint16_t *name)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; name[i] != 0; i++)
|
||||
if (! valid_j_char(name[i]))
|
||||
set_ucsbe(name + i, '_');
|
||||
}
|
||||
|
||||
|
||||
int iso_clone_mem(char *in, char **out, size_t size)
|
||||
{
|
||||
if (in == NULL) {
|
||||
|
@ -211,11 +211,6 @@ uint16_t *iso_j_file_id(const uint16_t *src, int flag);
|
||||
*/
|
||||
uint16_t *iso_j_dir_id(const uint16_t *src, int flag);
|
||||
|
||||
/**
|
||||
* Maps forbidden Joliet characters to UCS-2 '_'
|
||||
*/
|
||||
void iso_smash_chars_for_joliet(uint16_t *name);
|
||||
|
||||
/**
|
||||
* Like strlen, but for Joliet strings.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user