Implemented ECMA constraints on PVD

This commit is contained in:
Mario Danic 2007-05-15 10:35:42 +00:00
parent a97e96c604
commit 0281fcb717
3 changed files with 48 additions and 11 deletions

View File

@ -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 ecma119_pri_vol_desc *vol = (struct ecma119_pri_vol_desc*)buf;
struct iso_volume *volume = t->volset->volume[t->volnum]; struct iso_volume *volume = t->volset->volume[t->volnum];
char *vol_id = str2ascii(volume->volume_id); char *vol_id = str2d_char(volume->volume_id);
char *pub_id = str2ascii(volume->publisher_id); char *pub_id = str2a_char(volume->publisher_id);
char *data_id = str2ascii(volume->data_preparer_id); char *data_id = str2a_char(volume->data_preparer_id);
char *volset_id = str2ascii(t->volset->volset_id); char *volset_id = str2d_char(t->volset->volset_id);
char *system_id = str2ascii(volume->system_id); char *system_id = str2a_char(volume->system_id);
char *application_id = str2ascii(volume->application_id); char *application_id = str2a_char(volume->application_id);
char *copyright_file_id = str2ascii(volume->copyright_file_id); char *copyright_file_id = str2d_char(volume->copyright_file_id);
char *abstract_file_id = str2ascii(volume->abstract_file_id); char *abstract_file_id = str2d_char(volume->abstract_file_id);
char *biblio_file_id = str2ascii(volume->biblio_file_id); char *biblio_file_id = str2d_char(volume->biblio_file_id);
vol->vol_desc_type[0] = 1; vol->vol_desc_type[0] = 1;
memcpy(vol->std_identifier, "CD001", 5); memcpy(vol->std_identifier, "CD001", 5);

View File

@ -78,7 +78,6 @@ static wchar_t *str2wchar(const char *str, const char *codeset)
} }
iconv_close(conv); iconv_close(conv);
//TODO is needed this??
*( (wchar_t *)ret )='\0'; *( (wchar_t *)ret )='\0';
return wstr; return wstr;
} }
@ -250,7 +249,6 @@ uint16_t *str2ucs(const char *src_arg)
return (uint16_t*)ret_; return (uint16_t*)ret_;
} }
static int valid_d_char(char c) static int valid_d_char(char c)
{ {
return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (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 == '-'); || (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) static char *iso_dirid(const char *src, int size)
{ {
char *ret = str2ascii(src); char *ret = str2ascii(src);

View File

@ -34,6 +34,9 @@ wchar_t *towcs(const char *);
char *str2ascii(const char*); char *str2ascii(const char*);
uint16_t *str2ucs(const char*); uint16_t *str2ucs(const char*);
char *str2d_char(const char*);
char *str2a_char(const char*);
/** /**
* Create a level 1 directory identifier. * Create a level 1 directory identifier.
*/ */