Made product ID surely a single printable word
This commit is contained in:
parent
f1263be867
commit
07f5e48f29
@ -1 +1 @@
|
||||
#define Cdrskin_timestamP "2009.09.05.072512"
|
||||
#define Cdrskin_timestamP "2009.09.05.113043"
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "toc.h"
|
||||
#include "structure.h"
|
||||
#include "options.h"
|
||||
#include "util.h"
|
||||
|
||||
|
||||
/* ts A70223 : in init.c */
|
||||
@ -3942,6 +3943,8 @@ static int mmc_set_product_id(char *reply,
|
||||
int manuf_idx, int type_idx, int rev_idx,
|
||||
char **product_id, char **media_code1, char **media_code2, int flag)
|
||||
{
|
||||
int ret;
|
||||
|
||||
*product_id = calloc(17, 1);
|
||||
*media_code1 = calloc(9, 1);
|
||||
*media_code2 = calloc(8, 1);
|
||||
@ -3949,8 +3952,15 @@ static int mmc_set_product_id(char *reply,
|
||||
*media_code1 == NULL || *media_code2 == NULL)
|
||||
return -1;
|
||||
sprintf(*media_code1, "%.8s", reply + manuf_idx);
|
||||
sprintf(*media_code2, "%.3s/%d", reply + type_idx,
|
||||
(int) ((unsigned char *) reply)[rev_idx]);
|
||||
ret = burn_util_make_printable_word(media_code1, 1);
|
||||
if (ret <= 0)
|
||||
return -1;
|
||||
sprintf(*media_code2, "%.3sxxxx", reply + type_idx);
|
||||
ret = burn_util_make_printable_word(media_code2, 1);
|
||||
if (ret <= 0)
|
||||
return -1;
|
||||
sprintf(*media_code2 + strlen(*media_code2) - 4, "/%d",
|
||||
(int) ((unsigned char *) reply)[rev_idx]);
|
||||
sprintf(*product_id, "%s/%s", *media_code1, *media_code2);
|
||||
return 1;
|
||||
}
|
||||
@ -3968,6 +3978,7 @@ int mmc_get_media_product_id(struct burn_drive *d,
|
||||
int prf, ret, reply_len, i, has_11h = -1, bt, start_lba, end_lba;
|
||||
int min, sec, fr, media_type = 0;
|
||||
char *reply = NULL, *wpt;
|
||||
|
||||
static char *books[16] = {
|
||||
"DVD-ROM", "DVD-RAM", "DVD-R", "DVD-RW",
|
||||
"HD DVD-ROM", "HD DVD-RAM", "HD DVD-R", "unknown",
|
||||
@ -4012,25 +4023,30 @@ int mmc_get_media_product_id(struct burn_drive *d,
|
||||
ret = 0;
|
||||
goto ex;
|
||||
}
|
||||
*product_id = calloc(19, 1);
|
||||
*media_code1 = calloc(19, 1);
|
||||
*media_code2 = strdup("");
|
||||
if (*product_id == NULL ||
|
||||
*media_code1 == NULL || *media_code2 == NULL) {
|
||||
if (*media_code1 == NULL || *media_code2 == NULL) {
|
||||
ret = -1;
|
||||
goto ex;
|
||||
}
|
||||
memcpy(*product_id, reply + 17, 6);
|
||||
memcpy(*product_id + 6, reply + 25, 6);
|
||||
memcpy(*media_code1, reply + 17, 6);
|
||||
memcpy(*media_code1 + 6, reply + 25, 6);
|
||||
if (reply_len > 38)
|
||||
memcpy(*product_id + 12, reply + 33, 6);
|
||||
memcpy(*media_code1 + 12, reply + 33, 6);
|
||||
/* Clean out 0 bytes */
|
||||
wpt = *product_id;
|
||||
wpt = *media_code1;
|
||||
for (i = 0; i < 18; i++)
|
||||
if ((*product_id)[i])
|
||||
*(wpt++) = (*product_id)[i];
|
||||
if ((*media_code1)[i])
|
||||
*(wpt++) = (*media_code1)[i];
|
||||
*wpt = 0;
|
||||
strcpy(*media_code1, *product_id);
|
||||
ret = burn_util_make_printable_word(media_code1, 1);
|
||||
if (ret <= 0)
|
||||
goto ex;
|
||||
*product_id = strdup(*media_code1);
|
||||
if (*product_id == NULL) {
|
||||
ret = -1;
|
||||
goto ex;
|
||||
}
|
||||
|
||||
} else if (prf == 0x1a || prf == 0x1b || prf == 0x2b) { /* DVD+R[W] */
|
||||
|
||||
@ -4124,10 +4140,6 @@ ex:;
|
||||
if (*book_type != NULL)
|
||||
free(*book_type);
|
||||
*product_id = *media_code1 = *media_code2 = *book_type = NULL;
|
||||
} else if(*product_id != NULL) {
|
||||
for (i = 0; (*product_id)[i]; i++)
|
||||
if (isspace((*product_id)[i]))
|
||||
(*product_id)[i] = '_';
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -173,6 +173,10 @@ char *burn_guess_manufacturer(int prf,
|
||||
char buf[1024];
|
||||
char *result = NULL, *cpt;
|
||||
|
||||
/* Important Note: media_code1 and media_code2 are supposed to be
|
||||
encoded by burn_util_make_printable_word().
|
||||
Especially: ' ' -> '_' , {"_%/" unprintables -> %XY)
|
||||
*/
|
||||
static dvd_mid_record_t mid_list[]= {
|
||||
{"AML", "", 8, "UML"},
|
||||
{"BeAll", "", 5, "BeAll Developers, Inc."},
|
||||
@ -223,7 +227,8 @@ char *burn_guess_manufacturer(int prf,
|
||||
(prf == -1 || prf == 0x09 || prf == 0x0A)) {
|
||||
if (strlen(media_code2) == 9 && media_code2[0] == '9' &&
|
||||
media_code2[2] == 'm' && media_code2[5] == 's' &&
|
||||
media_code2[8] == 'f') {
|
||||
media_code2[8] == 'f' &&
|
||||
strchr(media_code2, '%') == NULL) {
|
||||
sscanf(media_code1, "%dm%ds%df", &m_li, &s_li, &f_li);
|
||||
sscanf(media_code2, "%dm%ds%df", &m_lo, &s_lo, &f_lo);
|
||||
if (m_li >= 96 && m_li <= 97 && m_lo > 0) {
|
||||
@ -235,9 +240,9 @@ char *burn_guess_manufacturer(int prf,
|
||||
}
|
||||
|
||||
/* DVD-R do not keep manufacturer id apart from media id.
|
||||
Some manufacturers use a blank as separator.
|
||||
Some manufacturers use a blank as separator which would now be '_'.
|
||||
*/
|
||||
cpt = strchr(media_code1, ' ');
|
||||
cpt = strchr(media_code1, '_');
|
||||
if (cpt != NULL && (prf == -1 || prf == 0x11 || prf == 0x13 ||
|
||||
prf == 0x14 || prf == 0x15))
|
||||
l = cpt - media_code1;
|
||||
@ -260,3 +265,51 @@ char *burn_guess_manufacturer(int prf,
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* ts A90905 */
|
||||
/* IMPORTANT: text must be freeable memory !
|
||||
@param flag bit0=escape '/' too
|
||||
*/
|
||||
int burn_util_make_printable_word(char **text, int flag)
|
||||
{
|
||||
int i, esc_add = 0, ret;
|
||||
char *wpt, *rpt, *new_text = NULL;
|
||||
|
||||
/* Make *text a single printable word */
|
||||
for (i = 0; (*text)[i]; i++) {
|
||||
rpt = (*text) + i;
|
||||
if (*rpt < 32 || *rpt > 126 || *rpt == '_' ||
|
||||
*rpt == 96 || *rpt == '%' ||
|
||||
(*rpt == '/' && (flag & 1)))
|
||||
esc_add += 2;
|
||||
}
|
||||
if (esc_add) {
|
||||
new_text = calloc(strlen(*text) + esc_add + 1, 1);
|
||||
if (new_text == NULL) {
|
||||
ret = -1;
|
||||
goto ex;
|
||||
}
|
||||
wpt = new_text;
|
||||
for (i = 0; (*text)[i]; i++) {
|
||||
rpt = (*text) + i;
|
||||
if (*rpt < 32 || *rpt > 126 || *rpt == '_' ||
|
||||
*rpt == 96 || *rpt == '%' ||
|
||||
(*rpt == '/' && (flag & 1))) {
|
||||
sprintf(wpt, "%%%2.2X",
|
||||
(unsigned int) *((unsigned char *) rpt));
|
||||
wpt+= 3;
|
||||
} else
|
||||
*(wpt++) = *rpt;
|
||||
}
|
||||
*wpt = 0;
|
||||
free(*text);
|
||||
*text = new_text;
|
||||
}
|
||||
for (i = 0; (*text)[i]; i++)
|
||||
if ((*text)[i] == ' ')
|
||||
(*text)[i] = '_';
|
||||
ret = 1;
|
||||
ex:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -5,4 +5,7 @@ char *burn_strdup(char *s);
|
||||
|
||||
char *burn_strndup(char *s, int n);
|
||||
|
||||
/* ts A90905 */
|
||||
int burn_util_make_printable_word(char **text, int flag);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user