mirror of
https://gitlab.xiph.org/xiph/ezstream.git
synced 2025-01-03 14:56:35 -05:00
Update util function naming scheme
This commit is contained in:
parent
6d9ab1d581
commit
59099c6ddf
@ -112,28 +112,28 @@ buildReencodeCommand(const char *extension, const char *fileName,
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
localTitle = UTF8toCHAR(metadata_get_title(mdata), ICONV_REPLACE);
|
||||
localArtist = UTF8toCHAR(metadata_get_artist(mdata), ICONV_REPLACE);
|
||||
localAlbum = UTF8toCHAR(metadata_get_album(mdata), ICONV_REPLACE);
|
||||
localMetaString = UTF8toCHAR(metadata_get_string(mdata),
|
||||
localTitle = util_utf82char(metadata_get_title(mdata), ICONV_REPLACE);
|
||||
localArtist = util_utf82char(metadata_get_artist(mdata), ICONV_REPLACE);
|
||||
localAlbum = util_utf82char(metadata_get_album(mdata), ICONV_REPLACE);
|
||||
localMetaString = util_utf82char(metadata_get_string(mdata),
|
||||
ICONV_REPLACE);
|
||||
|
||||
dec_str = replaceString(cfg_decoder_get_program(decoder),
|
||||
dec_str = util_replacestring(cfg_decoder_get_program(decoder),
|
||||
PLACEHOLDER_TRACK, fileName);
|
||||
if (strstr(dec_str, PLACEHOLDER_ARTIST) != NULL) {
|
||||
char *tmpStr = replaceString(dec_str, PLACEHOLDER_ARTIST,
|
||||
char *tmpStr = util_replacestring(dec_str, PLACEHOLDER_ARTIST,
|
||||
localArtist);
|
||||
xfree(dec_str);
|
||||
dec_str = tmpStr;
|
||||
}
|
||||
if (strstr(dec_str, PLACEHOLDER_TITLE) != NULL) {
|
||||
char *tmpStr = replaceString(dec_str, PLACEHOLDER_TITLE,
|
||||
char *tmpStr = util_replacestring(dec_str, PLACEHOLDER_TITLE,
|
||||
localTitle);
|
||||
xfree(dec_str);
|
||||
dec_str = tmpStr;
|
||||
}
|
||||
if (strstr(dec_str, PLACEHOLDER_ALBUM) != NULL) {
|
||||
char *tmpStr = replaceString(dec_str, PLACEHOLDER_ALBUM,
|
||||
char *tmpStr = util_replacestring(dec_str, PLACEHOLDER_ALBUM,
|
||||
localAlbum);
|
||||
xfree(dec_str);
|
||||
dec_str = tmpStr;
|
||||
@ -153,7 +153,7 @@ buildReencodeCommand(const char *extension, const char *fileName,
|
||||
cfg_get_metadata_format_str()) {
|
||||
char *mdataString = metadata_format_string(mdata,
|
||||
cfg_get_metadata_format_str());
|
||||
char *tmpStr = replaceString(dec_str,
|
||||
char *tmpStr = util_replacestring(dec_str,
|
||||
PLACEHOLDER_METADATA, mdataString);
|
||||
xfree(dec_str);
|
||||
xfree(mdataString);
|
||||
@ -161,12 +161,12 @@ buildReencodeCommand(const char *extension, const char *fileName,
|
||||
} else {
|
||||
if (!cfg_get_metadata_program() &&
|
||||
strstr(dec_str, PLACEHOLDER_TITLE) != NULL) {
|
||||
char *tmpStr = replaceString(dec_str,
|
||||
char *tmpStr = util_replacestring(dec_str,
|
||||
PLACEHOLDER_METADATA, "");
|
||||
xfree(dec_str);
|
||||
dec_str = tmpStr;
|
||||
} else {
|
||||
char *tmpStr = replaceString(dec_str,
|
||||
char *tmpStr = util_replacestring(dec_str,
|
||||
PLACEHOLDER_METADATA, localMetaString);
|
||||
xfree(dec_str);
|
||||
dec_str = tmpStr;
|
||||
@ -177,16 +177,16 @@ buildReencodeCommand(const char *extension, const char *fileName,
|
||||
if (!cfg_encoder_get_program(encoder))
|
||||
return (dec_str);
|
||||
|
||||
enc_str = replaceString(cfg_encoder_get_program(encoder),
|
||||
enc_str = util_replacestring(cfg_encoder_get_program(encoder),
|
||||
PLACEHOLDER_ARTIST, localArtist);
|
||||
if (strstr(enc_str, PLACEHOLDER_TITLE) != NULL) {
|
||||
char *tmpStr = replaceString(enc_str, PLACEHOLDER_TITLE,
|
||||
char *tmpStr = util_replacestring(enc_str, PLACEHOLDER_TITLE,
|
||||
localTitle);
|
||||
xfree(enc_str);
|
||||
enc_str = tmpStr;
|
||||
}
|
||||
if (strstr(enc_str, PLACEHOLDER_ALBUM) != NULL) {
|
||||
char *tmpStr = replaceString(enc_str, PLACEHOLDER_ALBUM,
|
||||
char *tmpStr = util_replacestring(enc_str, PLACEHOLDER_ALBUM,
|
||||
localAlbum);
|
||||
xfree(enc_str);
|
||||
enc_str = tmpStr;
|
||||
@ -196,7 +196,7 @@ buildReencodeCommand(const char *extension, const char *fileName,
|
||||
cfg_get_metadata_format_str()) {
|
||||
char *mdataString = metadata_format_string(mdata,
|
||||
cfg_get_metadata_format_str());
|
||||
char *tmpStr = replaceString(enc_str,
|
||||
char *tmpStr = util_replacestring(enc_str,
|
||||
PLACEHOLDER_METADATA, mdataString);
|
||||
xfree(enc_str);
|
||||
xfree(mdataString);
|
||||
@ -204,12 +204,12 @@ buildReencodeCommand(const char *extension, const char *fileName,
|
||||
} else {
|
||||
if (!cfg_get_metadata_program() &&
|
||||
strstr(enc_str, PLACEHOLDER_TITLE) != NULL) {
|
||||
char *tmpStr = replaceString(enc_str,
|
||||
char *tmpStr = util_replacestring(enc_str,
|
||||
PLACEHOLDER_METADATA, "");
|
||||
xfree(enc_str);
|
||||
enc_str = tmpStr;
|
||||
} else {
|
||||
char *tmpStr = replaceString(enc_str,
|
||||
char *tmpStr = util_replacestring(enc_str,
|
||||
PLACEHOLDER_METADATA, localMetaString);
|
||||
xfree(enc_str);
|
||||
enc_str = tmpStr;
|
||||
@ -587,7 +587,7 @@ streamFile(stream_t stream, const char *fileName)
|
||||
char *tmp, *metaData;
|
||||
|
||||
tmp = metadata_assemble_string(mdata);
|
||||
if ((metaData = UTF8toCHAR(tmp, ICONV_REPLACE)) == NULL)
|
||||
if ((metaData = util_utf82char(tmp, ICONV_REPLACE)) == NULL)
|
||||
metaData = xstrdup("(unknown title)");
|
||||
xfree(tmp);
|
||||
log_notice("streaming: %s (%s)", metaData, fileName);
|
||||
@ -801,7 +801,7 @@ main(int argc, char *argv[])
|
||||
return (ez_shutdown(1));
|
||||
}
|
||||
|
||||
if (0 > writePidfile(cfg_get_program_pid_file()))
|
||||
if (0 > util_write_pid_file(cfg_get_program_pid_file()))
|
||||
log_syserr(WARNING, errno, cfg_get_program_pid_file());
|
||||
|
||||
if (0 > stream_connect(stream)) {
|
||||
@ -815,8 +815,8 @@ main(int argc, char *argv[])
|
||||
if (CFG_MEDIA_PROGRAM == cfg_get_media_type() ||
|
||||
CFG_MEDIA_PLAYLIST == cfg_get_media_type() ||
|
||||
(CFG_MEDIA_AUTODETECT == cfg_get_media_type() &&
|
||||
(strrcasecmp(cfg_get_media_filename(), ".m3u") == 0 ||
|
||||
strrcasecmp(cfg_get_media_filename(), ".txt") == 0)))
|
||||
(util_strrcasecmp(cfg_get_media_filename(), ".m3u") == 0 ||
|
||||
util_strrcasecmp(cfg_get_media_filename(), ".txt") == 0)))
|
||||
playlistMode = 1;
|
||||
else
|
||||
playlistMode = 0;
|
||||
|
@ -176,7 +176,7 @@ metadata_get_name(const char *file)
|
||||
if (strlen(p1) == 0)
|
||||
name = xstrdup("[unknown]");
|
||||
else
|
||||
name = CHARtoUTF8(p1, ICONV_REPLACE);
|
||||
name = util_char2utf8(p1, ICONV_REPLACE);
|
||||
|
||||
xfree(filename);
|
||||
return (name);
|
||||
@ -528,31 +528,31 @@ metadata_format_string(struct metadata *md, const char *format)
|
||||
str = xstrdup(format);
|
||||
|
||||
if (strstr(format, PLACEHOLDER_ARTIST) != NULL) {
|
||||
tmp = replaceString(str, PLACEHOLDER_ARTIST,
|
||||
tmp = util_replacestring(str, PLACEHOLDER_ARTIST,
|
||||
metadata_get_artist(md));
|
||||
xfree(str);
|
||||
str = tmp;
|
||||
}
|
||||
if (strstr(format, PLACEHOLDER_TITLE) != NULL) {
|
||||
tmp = replaceString(str, PLACEHOLDER_TITLE,
|
||||
tmp = util_replacestring(str, PLACEHOLDER_TITLE,
|
||||
metadata_get_title(md));
|
||||
xfree(str);
|
||||
str = tmp;
|
||||
}
|
||||
if (strstr(format, PLACEHOLDER_STRING) != NULL) {
|
||||
tmp = replaceString(str, PLACEHOLDER_STRING,
|
||||
tmp = util_replacestring(str, PLACEHOLDER_STRING,
|
||||
metadata_get_string(md));
|
||||
xfree(str);
|
||||
str = tmp;
|
||||
}
|
||||
if (strstr(format, PLACEHOLDER_TRACK) != NULL) {
|
||||
tmp = replaceString(str, PLACEHOLDER_TRACK,
|
||||
tmp = util_replacestring(str, PLACEHOLDER_TRACK,
|
||||
metadata_get_filename(md));
|
||||
xfree(str);
|
||||
str = tmp;
|
||||
}
|
||||
if (strstr(format, PLACEHOLDER_ALBUM) != NULL) {
|
||||
tmp = replaceString(str, PLACEHOLDER_ALBUM,
|
||||
tmp = util_replacestring(str, PLACEHOLDER_ALBUM,
|
||||
metadata_get_album(md));
|
||||
xfree(str);
|
||||
str = tmp;
|
||||
|
34
src/util.c
34
src/util.c
@ -53,11 +53,11 @@ static FILE *pidfile_file;
|
||||
static pid_t pidfile_pid;
|
||||
static unsigned int pidfile_numlocks;
|
||||
|
||||
static char * iconvert(const char *, const char *, const char *, int);
|
||||
static void cleanupPidfile(void);
|
||||
static char * _iconvert(const char *, const char *, const char *, int);
|
||||
static void _cleanup_pidfile(void);
|
||||
|
||||
static char *
|
||||
iconvert(const char *in_str, const char *from, const char *to, int mode)
|
||||
_iconvert(const char *in_str, const char *from, const char *to, int mode)
|
||||
{
|
||||
#ifdef HAVE_ICONV
|
||||
iconv_t cd;
|
||||
@ -157,7 +157,7 @@ iconvert(const char *in_str, const char *from, const char *to, int mode)
|
||||
}
|
||||
|
||||
static void
|
||||
cleanupPidfile(void)
|
||||
_cleanup_pidfile(void)
|
||||
{
|
||||
if (NULL != pidfile_path && getpid() == pidfile_pid) {
|
||||
(void)unlink(pidfile_path);
|
||||
@ -166,7 +166,7 @@ cleanupPidfile(void)
|
||||
}
|
||||
|
||||
int
|
||||
writePidfile(const char *path)
|
||||
util_write_pid_file(const char *path)
|
||||
{
|
||||
int save_errno = 0;
|
||||
pid_t pid;
|
||||
@ -194,7 +194,7 @@ writePidfile(const char *path)
|
||||
|
||||
if (0 == pidfile_numlocks) {
|
||||
pidfile_pid = pid;
|
||||
if (0 != atexit(cleanupPidfile))
|
||||
if (0 != atexit(_cleanup_pidfile))
|
||||
goto error;
|
||||
pidfile_numlocks++;
|
||||
}
|
||||
@ -215,7 +215,7 @@ error:
|
||||
}
|
||||
|
||||
int
|
||||
strrcmp(const char *s, const char *sub)
|
||||
util_strrcmp(const char *s, const char *sub)
|
||||
{
|
||||
size_t slen = strlen(s);
|
||||
size_t sublen = strlen(sub);
|
||||
@ -227,7 +227,7 @@ strrcmp(const char *s, const char *sub)
|
||||
}
|
||||
|
||||
int
|
||||
strrcasecmp(const char *s, const char *sub)
|
||||
util_strrcasecmp(const char *s, const char *sub)
|
||||
{
|
||||
char *s_cpy = xstrdup(s);
|
||||
char *sub_cpy = xstrdup(sub);
|
||||
@ -240,7 +240,7 @@ strrcasecmp(const char *s, const char *sub)
|
||||
for (p = sub_cpy; *p != '\0'; p++)
|
||||
*p = tolower((int)*p);
|
||||
|
||||
ret = strrcmp(s_cpy, sub_cpy);
|
||||
ret = util_strrcmp(s_cpy, sub_cpy);
|
||||
|
||||
xfree(s_cpy);
|
||||
xfree(sub_cpy);
|
||||
@ -249,7 +249,7 @@ strrcasecmp(const char *s, const char *sub)
|
||||
}
|
||||
|
||||
char *
|
||||
CHARtoUTF8(const char *in_str, int mode)
|
||||
util_char2utf8(const char *in_str, int mode)
|
||||
{
|
||||
char *codeset;
|
||||
|
||||
@ -257,11 +257,11 @@ CHARtoUTF8(const char *in_str, int mode)
|
||||
codeset = nl_langinfo((nl_item)CODESET);
|
||||
setlocale(LC_CTYPE, "C");
|
||||
|
||||
return (iconvert(in_str, codeset, "UTF-8", mode));
|
||||
return (_iconvert(in_str, codeset, "UTF-8", mode));
|
||||
}
|
||||
|
||||
char *
|
||||
UTF8toCHAR(const char *in_str, int mode)
|
||||
util_utf82char(const char *in_str, int mode)
|
||||
{
|
||||
char *codeset;
|
||||
|
||||
@ -269,17 +269,17 @@ UTF8toCHAR(const char *in_str, int mode)
|
||||
codeset = nl_langinfo((nl_item)CODESET);
|
||||
setlocale(LC_CTYPE, "C");
|
||||
|
||||
return (iconvert(in_str, "UTF-8", codeset, mode));
|
||||
return (_iconvert(in_str, "UTF-8", codeset, mode));
|
||||
}
|
||||
|
||||
char *
|
||||
replaceString(const char *source, const char *from, const char *to)
|
||||
util_replacestring(const char *source, const char *from, const char *to)
|
||||
{
|
||||
char *to_quoted, *dest;
|
||||
size_t dest_size;
|
||||
const char *p1, *p2;
|
||||
|
||||
to_quoted = shellQuote(to);
|
||||
to_quoted = util_shellquote(to);
|
||||
dest_size = strlen(source) + strlen(to_quoted) + 1;
|
||||
dest = xcalloc(dest_size, sizeof(char));
|
||||
|
||||
@ -300,7 +300,7 @@ replaceString(const char *source, const char *from, const char *to)
|
||||
#define SHELLQUOTE_INLEN_MAX 8191UL
|
||||
|
||||
char *
|
||||
shellQuote(const char *in)
|
||||
util_shellquote(const char *in)
|
||||
{
|
||||
char *out, *out_p;
|
||||
size_t out_len;
|
||||
@ -336,7 +336,7 @@ shellQuote(const char *in)
|
||||
}
|
||||
|
||||
int
|
||||
urlParse(const char *url, char **hostname, unsigned short *port,
|
||||
util_urlparse(const char *url, char **hostname, unsigned short *port,
|
||||
char **mountname)
|
||||
{
|
||||
const char *p1, *p2, *p3;
|
||||
|
16
src/util.h
16
src/util.h
@ -20,13 +20,13 @@
|
||||
#define ICONV_TRANSLIT 1
|
||||
#define ICONV_IGNORE 2
|
||||
|
||||
int writePidfile(const char *);
|
||||
int strrcmp(const char *, const char *);
|
||||
int strrcasecmp(const char *, const char *);
|
||||
char * CHARtoUTF8(const char *, int);
|
||||
char * UTF8toCHAR(const char *, int);
|
||||
char * replaceString(const char *, const char *, const char *);
|
||||
char * shellQuote(const char *);
|
||||
int urlParse(const char *, char **, unsigned short *, char **);
|
||||
int util_write_pid_file(const char *);
|
||||
int util_strrcmp(const char *, const char *);
|
||||
int util_strrcasecmp(const char *, const char *);
|
||||
char * util_char2utf8(const char *, int);
|
||||
char * util_utf82char(const char *, int);
|
||||
char * util_replacestring(const char *, const char *, const char *);
|
||||
char * util_shellquote(const char *);
|
||||
int util_urlparse(const char *, char **, unsigned short *, char **);
|
||||
|
||||
#endif /* __UTIL_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user