diff --git a/libisofs/trunk/libisofs/ecma119.c b/libisofs/trunk/libisofs/ecma119.c index 017680d2..0f484ce8 100755 --- a/libisofs/trunk/libisofs/ecma119.c +++ b/libisofs/trunk/libisofs/ecma119.c @@ -438,16 +438,16 @@ write_pri_vol_desc(struct ecma119_write_target *t, uint8_t *buf) { struct ecma119_pri_vol_desc *vol = (struct ecma119_pri_vol_desc*)buf; struct iso_volume *volume = t->volset->volume[t->volnum]; - char *vol_id = str2ascii(volume->volume_id); - char *pub_id = str2ascii(volume->publisher_id); - char *data_id = str2ascii(volume->data_preparer_id); - char *volset_id = str2ascii(t->volset->volset_id); + char *vol_id = str2d_char(volume->volume_id); + char *pub_id = str2a_char(volume->publisher_id); + char *data_id = str2a_char(volume->data_preparer_id); + char *volset_id = str2d_char(t->volset->volset_id); - char *system_id = str2ascii(volume->system_id); - char *application_id = str2ascii(volume->application_id); - char *copyright_file_id = str2ascii(volume->copyright_file_id); - char *abstract_file_id = str2ascii(volume->abstract_file_id); - char *biblio_file_id = str2ascii(volume->biblio_file_id); + char *system_id = str2a_char(volume->system_id); + char *application_id = str2a_char(volume->application_id); + char *copyright_file_id = str2d_char(volume->copyright_file_id); + char *abstract_file_id = str2d_char(volume->abstract_file_id); + char *biblio_file_id = str2d_char(volume->biblio_file_id); vol->vol_desc_type[0] = 1; memcpy(vol->std_identifier, "CD001", 5); diff --git a/libisofs/trunk/libisofs/util.c b/libisofs/trunk/libisofs/util.c index bfa9610e..b7eb547a 100755 --- a/libisofs/trunk/libisofs/util.c +++ b/libisofs/trunk/libisofs/util.c @@ -78,7 +78,6 @@ static wchar_t *str2wchar(const char *str, const char *codeset) } iconv_close(conv); - //TODO is needed this?? *( (wchar_t *)ret )='\0'; return wstr; } @@ -250,7 +249,6 @@ uint16_t *str2ucs(const char *src_arg) return (uint16_t*)ret_; } - static int valid_d_char(char c) { return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c == '_'); @@ -278,6 +276,42 @@ static int valid_p_char(char c) || (c == '.') || (c == '_') || (c == '-'); } +char *str2d_char(const char *str) { + char *ret; + size_t len, i; + + if (!str) + return NULL; + + ret = str2ascii(str); + len = strlen(ret); + + for (i = 0; i < len; ++i) { + char c = toupper(ret[i]); + ret[i] = valid_d_char(c) ? c : '_'; + } + + return ret; +} + +char *str2a_char(const char *str) { + char *ret; + size_t len, i; + + if (!str) + return NULL; + + ret = str2ascii(str); + len = strlen(ret); + + for (i = 0; i < len; ++i) { + char c = toupper(ret[i]); + ret[i] = valid_a_char(c) ? c : '_'; + } + + return ret; +} + static char *iso_dirid(const char *src, int size) { char *ret = str2ascii(src); diff --git a/libisofs/trunk/libisofs/util.h b/libisofs/trunk/libisofs/util.h index c8736aca..c8f50d10 100755 --- a/libisofs/trunk/libisofs/util.h +++ b/libisofs/trunk/libisofs/util.h @@ -34,6 +34,9 @@ wchar_t *towcs(const char *); char *str2ascii(const char*); uint16_t *str2ucs(const char*); +char *str2d_char(const char*); +char *str2a_char(const char*); + /** * Create a level 1 directory identifier. */