mirror of
https://gitlab.xiph.org/xiph/ezstream.git
synced 2025-02-02 15:07:45 -05:00
Perform more charset conversions where necessary. This should fix the handling
of files with non-ASCII filenames, as well as some more cases related to metadata. From Roman Donchenko <DXDragon at yandex dot ru>, with some minor fixes by myself. git-svn-id: https://svn.xiph.org/trunk/ezstream@15770 0101bb08-14d6-0310-b084-bc0e0c8e3800
This commit is contained in:
parent
057bc88dad
commit
ae3dd91581
@ -29,6 +29,7 @@
|
|||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
#include "configfile.h"
|
#include "configfile.h"
|
||||||
#include "strfctns.h"
|
#include "strfctns.h"
|
||||||
|
#include "util.h"
|
||||||
#include "xalloc.h"
|
#include "xalloc.h"
|
||||||
|
|
||||||
extern char *__progname;
|
extern char *__progname;
|
||||||
@ -175,7 +176,7 @@ parseConfig(const char *fileName)
|
|||||||
config_error++;
|
config_error++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ezConfig.fileName = xstrdup(ls_xmlContentPtr);
|
ezConfig.fileName = UTF8toCHAR(ls_xmlContentPtr, ICONV_REPLACE);
|
||||||
xmlFree(ls_xmlContentPtr);
|
xmlFree(ls_xmlContentPtr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,7 +195,7 @@ parseConfig(const char *fileName)
|
|||||||
config_error++;
|
config_error++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ezConfig.metadataProgram = xstrdup(ls_xmlContentPtr);
|
ezConfig.metadataProgram = UTF8toCHAR(ls_xmlContentPtr, ICONV_REPLACE);
|
||||||
xmlFree(ls_xmlContentPtr);
|
xmlFree(ls_xmlContentPtr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -516,7 +517,7 @@ parseConfig(const char *fileName)
|
|||||||
unsigned int ret;
|
unsigned int ret;
|
||||||
|
|
||||||
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
|
||||||
pformatEncDec->decoder = xstrdup(ls_xmlContentPtr);
|
pformatEncDec->decoder = UTF8toCHAR(ls_xmlContentPtr, ICONV_REPLACE);
|
||||||
xmlFree(ls_xmlContentPtr);
|
xmlFree(ls_xmlContentPtr);
|
||||||
if ((ret = checkDecoderLine(pformatEncDec->decoder,
|
if ((ret = checkDecoderLine(pformatEncDec->decoder,
|
||||||
fileName, xmlGetLineNo(cur3)))
|
fileName, xmlGetLineNo(cur3)))
|
||||||
@ -537,7 +538,7 @@ parseConfig(const char *fileName)
|
|||||||
unsigned int ret;
|
unsigned int ret;
|
||||||
|
|
||||||
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
|
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
|
||||||
pformatEncDec->encoder = xstrdup(ls_xmlContentPtr);
|
pformatEncDec->encoder = UTF8toCHAR(ls_xmlContentPtr, ICONV_REPLACE);
|
||||||
xmlFree(ls_xmlContentPtr);
|
xmlFree(ls_xmlContentPtr);
|
||||||
if ((ret = checkEncoderLine(pformatEncDec->encoder,
|
if ((ret = checkEncoderLine(pformatEncDec->encoder,
|
||||||
fileName, xmlGetLineNo(cur3)))
|
fileName, xmlGetLineNo(cur3)))
|
||||||
|
@ -251,11 +251,20 @@ buildCommandString(const char *extension, const char *fileName,
|
|||||||
size_t newDecoderLen = 0;
|
size_t newDecoderLen = 0;
|
||||||
char *newEncoder = NULL;
|
char *newEncoder = NULL;
|
||||||
size_t newEncoderLen = 0;
|
size_t newEncoderLen = 0;
|
||||||
|
char *localTitle = UTF8toCHAR(metadata_get_title(mdata),
|
||||||
|
ICONV_REPLACE);
|
||||||
|
char *localArtist = UTF8toCHAR(metadata_get_artist(mdata),
|
||||||
|
ICONV_REPLACE);
|
||||||
|
char *localMetaString = UTF8toCHAR(metadata_get_string(mdata),
|
||||||
|
ICONV_REPLACE);
|
||||||
|
|
||||||
decoder = xstrdup(getFormatDecoder(extension));
|
decoder = xstrdup(getFormatDecoder(extension));
|
||||||
if (strlen(decoder) == 0) {
|
if (strlen(decoder) == 0) {
|
||||||
printf("%s: Unknown extension '%s', cannot decode '%s'\n",
|
printf("%s: Unknown extension '%s', cannot decode '%s'\n",
|
||||||
__progname, extension, fileName);
|
__progname, extension, fileName);
|
||||||
|
xfree(localTitle);
|
||||||
|
xfree(localArtist);
|
||||||
|
xfree(localMetaString);
|
||||||
xfree(decoder);
|
xfree(decoder);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
@ -264,18 +273,18 @@ buildCommandString(const char *extension, const char *fileName,
|
|||||||
replaceString(decoder, newDecoder, newDecoderLen, TRACK_PLACEHOLDER,
|
replaceString(decoder, newDecoder, newDecoderLen, TRACK_PLACEHOLDER,
|
||||||
fileName);
|
fileName);
|
||||||
if (strstr(decoder, ARTIST_PLACEHOLDER) != NULL) {
|
if (strstr(decoder, ARTIST_PLACEHOLDER) != NULL) {
|
||||||
size_t tmpLen = strlen(newDecoder) + strlen(metadata_get_artist(mdata)) + 1;
|
size_t tmpLen = strlen(newDecoder) + strlen(localArtist) + 1;
|
||||||
char *tmpStr = xcalloc(tmpLen, sizeof(char));
|
char *tmpStr = xcalloc(tmpLen, sizeof(char));
|
||||||
replaceString(newDecoder, tmpStr, tmpLen, ARTIST_PLACEHOLDER,
|
replaceString(newDecoder, tmpStr, tmpLen, ARTIST_PLACEHOLDER,
|
||||||
metadata_get_artist(mdata));
|
localArtist);
|
||||||
xfree(newDecoder);
|
xfree(newDecoder);
|
||||||
newDecoder = tmpStr;
|
newDecoder = tmpStr;
|
||||||
}
|
}
|
||||||
if (strstr(decoder, TITLE_PLACEHOLDER) != NULL) {
|
if (strstr(decoder, TITLE_PLACEHOLDER) != NULL) {
|
||||||
size_t tmpLen = strlen(newDecoder) + strlen(metadata_get_title(mdata)) + 1;
|
size_t tmpLen = strlen(newDecoder) + strlen(localTitle) + 1;
|
||||||
char *tmpStr = xcalloc(tmpLen, sizeof(char));
|
char *tmpStr = xcalloc(tmpLen, sizeof(char));
|
||||||
replaceString(newDecoder, tmpStr, tmpLen, TITLE_PLACEHOLDER,
|
replaceString(newDecoder, tmpStr, tmpLen, TITLE_PLACEHOLDER,
|
||||||
metadata_get_title(mdata));
|
localTitle);
|
||||||
xfree(newDecoder);
|
xfree(newDecoder);
|
||||||
newDecoder = tmpStr;
|
newDecoder = tmpStr;
|
||||||
}
|
}
|
||||||
@ -308,11 +317,11 @@ buildCommandString(const char *extension, const char *fileName,
|
|||||||
xfree(newDecoder);
|
xfree(newDecoder);
|
||||||
newDecoder = tmpStr;
|
newDecoder = tmpStr;
|
||||||
} else {
|
} else {
|
||||||
size_t tmpLen = strlen(newDecoder) + strlen(metadata_get_string(mdata)) + 1;
|
size_t tmpLen = strlen(newDecoder) + strlen(localMetaString) + 1;
|
||||||
char *tmpStr = xcalloc(tmpLen, sizeof(char));
|
char *tmpStr = xcalloc(tmpLen, sizeof(char));
|
||||||
replaceString(newDecoder, tmpStr, tmpLen,
|
replaceString(newDecoder, tmpStr, tmpLen,
|
||||||
METADATA_PLACEHOLDER,
|
METADATA_PLACEHOLDER,
|
||||||
metadata_get_string(mdata));
|
localMetaString);
|
||||||
xfree(newDecoder);
|
xfree(newDecoder);
|
||||||
newDecoder = tmpStr;
|
newDecoder = tmpStr;
|
||||||
}
|
}
|
||||||
@ -329,21 +338,24 @@ buildCommandString(const char *extension, const char *fileName,
|
|||||||
commandStringLen = strlen(newDecoder) + 1;
|
commandStringLen = strlen(newDecoder) + 1;
|
||||||
commandString = xcalloc(commandStringLen, sizeof(char));
|
commandString = xcalloc(commandStringLen, sizeof(char));
|
||||||
strlcpy(commandString, newDecoder, commandStringLen);
|
strlcpy(commandString, newDecoder, commandStringLen);
|
||||||
|
xfree(localTitle);
|
||||||
|
xfree(localArtist);
|
||||||
|
xfree(localMetaString);
|
||||||
xfree(decoder);
|
xfree(decoder);
|
||||||
xfree(encoder);
|
xfree(encoder);
|
||||||
xfree(newDecoder);
|
xfree(newDecoder);
|
||||||
return (commandString);
|
return (commandString);
|
||||||
}
|
}
|
||||||
|
|
||||||
newEncoderLen = strlen(encoder) + strlen(metadata_get_artist(mdata)) + 1;
|
newEncoderLen = strlen(encoder) + strlen(localArtist) + 1;
|
||||||
newEncoder = xcalloc(newEncoderLen, sizeof(char));
|
newEncoder = xcalloc(newEncoderLen, sizeof(char));
|
||||||
replaceString(encoder, newEncoder, newEncoderLen, ARTIST_PLACEHOLDER,
|
replaceString(encoder, newEncoder, newEncoderLen, ARTIST_PLACEHOLDER,
|
||||||
metadata_get_artist(mdata));
|
localArtist);
|
||||||
if (strstr(encoder, TITLE_PLACEHOLDER) != NULL) {
|
if (strstr(encoder, TITLE_PLACEHOLDER) != NULL) {
|
||||||
size_t tmpLen = strlen(newEncoder) + strlen(metadata_get_title(mdata)) + 1;
|
size_t tmpLen = strlen(newEncoder) + strlen(localTitle) + 1;
|
||||||
char *tmpStr = xcalloc(tmpLen, sizeof(char));
|
char *tmpStr = xcalloc(tmpLen, sizeof(char));
|
||||||
replaceString(newEncoder, tmpStr, tmpLen, TITLE_PLACEHOLDER,
|
replaceString(newEncoder, tmpStr, tmpLen, TITLE_PLACEHOLDER,
|
||||||
metadata_get_title(mdata));
|
localTitle);
|
||||||
xfree(newEncoder);
|
xfree(newEncoder);
|
||||||
newEncoder = tmpStr;
|
newEncoder = tmpStr;
|
||||||
}
|
}
|
||||||
@ -366,11 +378,11 @@ buildCommandString(const char *extension, const char *fileName,
|
|||||||
xfree(newEncoder);
|
xfree(newEncoder);
|
||||||
newEncoder = tmpStr;
|
newEncoder = tmpStr;
|
||||||
} else {
|
} else {
|
||||||
size_t tmpLen = strlen(newEncoder) + strlen(metadata_get_string(mdata)) + 1;
|
size_t tmpLen = strlen(newEncoder) + strlen(localMetaString) + 1;
|
||||||
char *tmpStr = xcalloc(tmpLen, sizeof(char));
|
char *tmpStr = xcalloc(tmpLen, sizeof(char));
|
||||||
replaceString(newEncoder, tmpStr, tmpLen,
|
replaceString(newEncoder, tmpStr, tmpLen,
|
||||||
METADATA_PLACEHOLDER,
|
METADATA_PLACEHOLDER,
|
||||||
metadata_get_string(mdata));
|
localMetaString);
|
||||||
xfree(newEncoder);
|
xfree(newEncoder);
|
||||||
newEncoder = tmpStr;
|
newEncoder = tmpStr;
|
||||||
}
|
}
|
||||||
@ -383,6 +395,9 @@ buildCommandString(const char *extension, const char *fileName,
|
|||||||
snprintf(commandString, commandStringLen, "%s | %s", newDecoder,
|
snprintf(commandString, commandStringLen, "%s | %s", newDecoder,
|
||||||
newEncoder);
|
newEncoder);
|
||||||
|
|
||||||
|
xfree(localTitle);
|
||||||
|
xfree(localArtist);
|
||||||
|
xfree(localMetaString);
|
||||||
xfree(decoder);
|
xfree(decoder);
|
||||||
xfree(encoder);
|
xfree(encoder);
|
||||||
xfree(newDecoder);
|
xfree(newDecoder);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user