mirror of
https://gitlab.xiph.org/xiph/ezstream.git
synced 2025-02-02 15:07:45 -05:00
Factor out command line parsing
This commit is contained in:
parent
4062cc190a
commit
9bc65bf717
@ -3,7 +3,16 @@ AUTOMAKE_OPTIONS = 1.10 foreign subdir-objects
|
|||||||
bin_PROGRAMS = ezstream
|
bin_PROGRAMS = ezstream
|
||||||
bin_SCRIPTS = ezstream-file.sh
|
bin_SCRIPTS = ezstream-file.sh
|
||||||
|
|
||||||
|
noinst_HEADERS = \
|
||||||
|
cfg.h \
|
||||||
|
configfile.h \
|
||||||
|
ezstream.h \
|
||||||
|
metadata.h \
|
||||||
|
playlist.h \
|
||||||
|
util.h \
|
||||||
|
xalloc.h
|
||||||
ezstream_SOURCES = \
|
ezstream_SOURCES = \
|
||||||
|
cfg.c \
|
||||||
configfile.c \
|
configfile.c \
|
||||||
ezstream.c \
|
ezstream.c \
|
||||||
metadata.c \
|
metadata.c \
|
||||||
@ -16,12 +25,4 @@ AM_CFLAGS = @EZ_CFLAGS@
|
|||||||
AM_CPPFLAGS = @EZ_CPPFLAGS@ -I$(top_srcdir)/compat
|
AM_CPPFLAGS = @EZ_CPPFLAGS@ -I$(top_srcdir)/compat
|
||||||
AM_LDFLAGS = @EZ_LDFLAGS@
|
AM_LDFLAGS = @EZ_LDFLAGS@
|
||||||
|
|
||||||
EXTRA_DIST = \
|
|
||||||
configfile.h \
|
|
||||||
ezstream.h \
|
|
||||||
metadata.h \
|
|
||||||
playlist.h \
|
|
||||||
util.h \
|
|
||||||
xalloc.h
|
|
||||||
|
|
||||||
CLEANFILES = core *.core *~ .*~
|
CLEANFILES = core *.core *~ .*~
|
||||||
|
225
src/cfg.c
Normal file
225
src/cfg.c
Normal file
@ -0,0 +1,225 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015 Moritz Grimm <mgrimm@mrsserver.net>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif /* HAVE_CONFIG_H */
|
||||||
|
|
||||||
|
#include "compat.h"
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif /* HAVE_UNISTD_H */
|
||||||
|
|
||||||
|
#include "cfg.h"
|
||||||
|
|
||||||
|
#define OPTSTRING "c:hmnqs:Vv"
|
||||||
|
enum opt_vals {
|
||||||
|
OPT_CONFIGFILE = 'c',
|
||||||
|
OPT_HELP = 'h',
|
||||||
|
OPT_NOMETADATAUPDATE = 'm',
|
||||||
|
OPT_NORMALIZESTRINGS = 'n',
|
||||||
|
OPT_QUIETSTDERR = 'q',
|
||||||
|
OPT_SHUFFLEFILE = 's',
|
||||||
|
OPT_VERSION = 'V',
|
||||||
|
OPT_VERBOSE = 'v',
|
||||||
|
OPT_INVALID = '?'
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct cfg {
|
||||||
|
char progname[PATH_MAX];
|
||||||
|
char config_file[PATH_MAX];
|
||||||
|
int no_metadata_updates;
|
||||||
|
int normalize_strings;
|
||||||
|
int quiet_stderr;
|
||||||
|
char shuffle_file[PATH_MAX];
|
||||||
|
unsigned int verbosity;
|
||||||
|
} cfg;
|
||||||
|
|
||||||
|
static void usage(void);
|
||||||
|
static void usage_help(void);
|
||||||
|
|
||||||
|
static void
|
||||||
|
_set_progname(const char *argv0)
|
||||||
|
{
|
||||||
|
#ifdef HAVE___PROGNAME
|
||||||
|
extern char *__progname;
|
||||||
|
(void)argv0;
|
||||||
|
snprintf(cfg.progname, sizeof(cfg.progname), "%s", __progname);
|
||||||
|
#else
|
||||||
|
if (argv0 == NULL) {
|
||||||
|
snprintf(cfg.progname, sizeof(cfg.progname), "ezstream");
|
||||||
|
} else {
|
||||||
|
const char *p = strrchr(argv0, '/');
|
||||||
|
if (p == NULL)
|
||||||
|
p = argv0;
|
||||||
|
else
|
||||||
|
p++;
|
||||||
|
snprintf(cfg.progname, sizeof(cfg.progname), "%s", p);
|
||||||
|
}
|
||||||
|
#endif /* HAVE___PROGNAME */
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
usage(void)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "usage: %s [-ghmnqVv] -c cfgfile\n",
|
||||||
|
cfg.progname);
|
||||||
|
fprintf(stderr, " %s [-ghV] -s file\n",
|
||||||
|
cfg.progname);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
usage_help(void)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
fprintf(stderr, " -c cfgfile use XML configuration in cfgfile\n");
|
||||||
|
fprintf(stderr, " -h print this help and exit\n");
|
||||||
|
fprintf(stderr, " -m disable metadata updates\n");
|
||||||
|
fprintf(stderr, " -n normalize metadata strings\n");
|
||||||
|
fprintf(stderr, " -q suppress STDERR output from external en-/decoders\n");
|
||||||
|
fprintf(stderr, " -s file read lines from file, shuffle, print to STDOUT, then exit\n");
|
||||||
|
fprintf(stderr, " -V print the version number and exit\n");
|
||||||
|
fprintf(stderr, " -v verbose output (use twice for more effect)\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
cfg_cmdline_parse(int argc, char *argv[], int *ret_p)
|
||||||
|
{
|
||||||
|
int ch;
|
||||||
|
|
||||||
|
memset(&cfg, 0, sizeof(cfg));
|
||||||
|
|
||||||
|
_set_progname(argv[0]);
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
ch = getopt(argc, argv, OPTSTRING);
|
||||||
|
if (0 > ch)
|
||||||
|
break;
|
||||||
|
|
||||||
|
switch (ch) {
|
||||||
|
case OPT_CONFIGFILE:
|
||||||
|
if (cfg.config_file[0]) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"option -%c may only be given once\n",
|
||||||
|
OPT_CONFIGFILE);
|
||||||
|
usage();
|
||||||
|
*ret_p = 2;
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
(void)snprintf(cfg.config_file,
|
||||||
|
sizeof(cfg.config_file), "%s", optarg);
|
||||||
|
break;
|
||||||
|
case OPT_HELP:
|
||||||
|
usage();
|
||||||
|
usage_help();
|
||||||
|
*ret_p = 0;
|
||||||
|
return (-1);
|
||||||
|
case OPT_NOMETADATAUPDATE:
|
||||||
|
cfg.no_metadata_updates = 1;
|
||||||
|
break;
|
||||||
|
case OPT_NORMALIZESTRINGS:
|
||||||
|
cfg.normalize_strings = 1;
|
||||||
|
break;
|
||||||
|
case OPT_QUIETSTDERR:
|
||||||
|
cfg.quiet_stderr = 1;
|
||||||
|
break;
|
||||||
|
case OPT_SHUFFLEFILE:
|
||||||
|
if (cfg.shuffle_file[0]) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"option -%c may only be given once\n",
|
||||||
|
OPT_SHUFFLEFILE);
|
||||||
|
usage();
|
||||||
|
*ret_p = 2;
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
(void)snprintf(cfg.shuffle_file,
|
||||||
|
sizeof(cfg.shuffle_file), "%s", optarg);
|
||||||
|
break;
|
||||||
|
case OPT_VERSION:
|
||||||
|
fprintf(stdout, "%s version %s\n",
|
||||||
|
PACKAGE_NAME, PACKAGE_VERSION);
|
||||||
|
*ret_p = 0;
|
||||||
|
return (-1);
|
||||||
|
case OPT_VERBOSE:
|
||||||
|
cfg.verbosity++;
|
||||||
|
break;
|
||||||
|
case OPT_INVALID:
|
||||||
|
default:
|
||||||
|
usage();
|
||||||
|
*ret_p = 2;
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
argc -= optind;
|
||||||
|
argv += optind;
|
||||||
|
|
||||||
|
if ((!cfg.config_file[0] && !cfg.shuffle_file[0]) ||
|
||||||
|
(cfg.config_file[0] && cfg.shuffle_file[0])) {
|
||||||
|
fprintf(stderr, "either -%c or -%c must be provided\n",
|
||||||
|
OPT_CONFIGFILE, OPT_SHUFFLEFILE);
|
||||||
|
usage();
|
||||||
|
*ret_p = 2;
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
cfg_progname(void)
|
||||||
|
{
|
||||||
|
return (cfg.progname);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
cfg_config_file(void)
|
||||||
|
{
|
||||||
|
return (cfg.config_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
cfg_no_metadata_updates(void)
|
||||||
|
{
|
||||||
|
return (cfg.no_metadata_updates);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
cfg_normalize_strings(void)
|
||||||
|
{
|
||||||
|
return (cfg.normalize_strings);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
cfg_quiet_stderr(void)
|
||||||
|
{
|
||||||
|
return (cfg.quiet_stderr);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
cfg_shuffle_file(void)
|
||||||
|
{
|
||||||
|
return (cfg.shuffle_file[0] ? cfg.shuffle_file : NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
cfg_verbosity(void)
|
||||||
|
{
|
||||||
|
return (cfg.verbosity);
|
||||||
|
}
|
35
src/cfg.h
Normal file
35
src/cfg.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015 Moritz Grimm <mgrimm@mrsserver.net>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __CFG_H__
|
||||||
|
#define __CFG_H__
|
||||||
|
|
||||||
|
int cfg_cmdline_parse(int, char *[], int *);
|
||||||
|
|
||||||
|
const char *
|
||||||
|
cfg_progname(void);
|
||||||
|
|
||||||
|
const char *
|
||||||
|
cfg_config_file(void);
|
||||||
|
int cfg_no_metadata_updates(void);
|
||||||
|
int cfg_normalize_strings(void);
|
||||||
|
int cfg_quiet_stderr(void);
|
||||||
|
const char *
|
||||||
|
cfg_shuffle_file(void);
|
||||||
|
unsigned int
|
||||||
|
cfg_verbosity(void);
|
||||||
|
|
||||||
|
#endif /* __CFG_H__ */
|
@ -21,12 +21,11 @@
|
|||||||
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
|
|
||||||
|
#include "cfg.h"
|
||||||
#include "configfile.h"
|
#include "configfile.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "xalloc.h"
|
#include "xalloc.h"
|
||||||
|
|
||||||
extern char *__progname;
|
|
||||||
|
|
||||||
static EZCONFIG ezConfig;
|
static EZCONFIG ezConfig;
|
||||||
static const char *blankString = "";
|
static const char *blankString = "";
|
||||||
|
|
||||||
@ -590,7 +589,7 @@ parseConfig(const char *fileName)
|
|||||||
return (1);
|
return (1);
|
||||||
|
|
||||||
freeConfig(&ezConfig);
|
freeConfig(&ezConfig);
|
||||||
printf("%s: %u configuration error(s) in %s\n", __progname,
|
printf("%s: %u configuration error(s) in %s\n", cfg_progname(),
|
||||||
config_error, fileName);
|
config_error, fileName);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
281
src/ezstream.c
281
src/ezstream.c
@ -39,17 +39,6 @@
|
|||||||
#define STREAM_SERVERR 3
|
#define STREAM_SERVERR 3
|
||||||
#define STREAM_UPDMDATA 4
|
#define STREAM_UPDMDATA 4
|
||||||
|
|
||||||
#ifdef HAVE___PROGNAME
|
|
||||||
extern char *__progname;
|
|
||||||
#else
|
|
||||||
char *__progname;
|
|
||||||
#endif /* HAVE___PROGNAME */
|
|
||||||
|
|
||||||
int nFlag;
|
|
||||||
int mFlag;
|
|
||||||
int qFlag;
|
|
||||||
int sFlag;
|
|
||||||
int vFlag;
|
|
||||||
int metadataFromProgram;
|
int metadataFromProgram;
|
||||||
|
|
||||||
EZCONFIG *pezConfig = NULL;
|
EZCONFIG *pezConfig = NULL;
|
||||||
@ -100,9 +89,6 @@ int sendStream(shout_t *, FILE *, const char *, int, const char *,
|
|||||||
struct timeval *);
|
struct timeval *);
|
||||||
int streamFile(shout_t *, const char *);
|
int streamFile(shout_t *, const char *);
|
||||||
int streamPlaylist(shout_t *, const char *);
|
int streamPlaylist(shout_t *, const char *);
|
||||||
char * getProgname(const char *);
|
|
||||||
void usage(void);
|
|
||||||
void usageHelp(void);
|
|
||||||
int ez_shutdown(int);
|
int ez_shutdown(int);
|
||||||
|
|
||||||
#ifdef HAVE_SIGNALS
|
#ifdef HAVE_SIGNALS
|
||||||
@ -147,13 +133,13 @@ urlParse(const char *url, char **hostname, unsigned short *port,
|
|||||||
|
|
||||||
if (hostname == NULL || port == NULL || mountname == NULL) {
|
if (hostname == NULL || port == NULL || mountname == NULL) {
|
||||||
printf("%s: urlParse(): Internal error: Bad arguments\n",
|
printf("%s: urlParse(): Internal error: Bad arguments\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strncmp(url, "http://", strlen("http://")) != 0) {
|
if (strncmp(url, "http://", strlen("http://")) != 0) {
|
||||||
printf("%s: Error: Invalid <url>: Not an HTTP address\n",
|
printf("%s: Error: Invalid <url>: Not an HTTP address\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +147,7 @@ urlParse(const char *url, char **hostname, unsigned short *port,
|
|||||||
p2 = strchr(p1, ':');
|
p2 = strchr(p1, ':');
|
||||||
if (p2 == NULL) {
|
if (p2 == NULL) {
|
||||||
printf("%s: Error: Invalid <url>: Missing port\n",
|
printf("%s: Error: Invalid <url>: Missing port\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
hostsiz = (p2 - p1) + 1;
|
hostsiz = (p2 - p1) + 1;
|
||||||
@ -172,7 +158,7 @@ urlParse(const char *url, char **hostname, unsigned short *port,
|
|||||||
p3 = strchr(p2, '/');
|
p3 = strchr(p2, '/');
|
||||||
if (p3 == NULL || p3 - p2 >= (int)sizeof(tmpPort)) {
|
if (p3 == NULL || p3 - p2 >= (int)sizeof(tmpPort)) {
|
||||||
printf("%s: Error: Invalid <url>: Missing mountpoint or too long port number\n",
|
printf("%s: Error: Invalid <url>: Missing mountpoint or too long port number\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
xfree(*hostname);
|
xfree(*hostname);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -181,7 +167,7 @@ urlParse(const char *url, char **hostname, unsigned short *port,
|
|||||||
*port = (unsigned short)strtonum(tmpPort, 1LL, (long long)USHRT_MAX, &errstr);
|
*port = (unsigned short)strtonum(tmpPort, 1LL, (long long)USHRT_MAX, &errstr);
|
||||||
if (errstr) {
|
if (errstr) {
|
||||||
printf("%s: Error: Invalid <url>: Port '%s' is %s\n",
|
printf("%s: Error: Invalid <url>: Port '%s' is %s\n",
|
||||||
__progname, tmpPort, errstr);
|
cfg_progname(), tmpPort, errstr);
|
||||||
xfree(*hostname);
|
xfree(*hostname);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -276,7 +262,7 @@ buildCommandString(const char *extension, const char *fileName,
|
|||||||
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);
|
cfg_progname(), extension, fileName);
|
||||||
xfree(localTitle);
|
xfree(localTitle);
|
||||||
xfree(localArtist);
|
xfree(localArtist);
|
||||||
xfree(localMetaString);
|
xfree(localMetaString);
|
||||||
@ -331,9 +317,9 @@ buildCommandString(const char *extension, const char *fileName,
|
|||||||
|
|
||||||
encoder = xstrdup(getFormatEncoder(pezConfig->format));
|
encoder = xstrdup(getFormatEncoder(pezConfig->format));
|
||||||
if (strlen(encoder) == 0) {
|
if (strlen(encoder) == 0) {
|
||||||
if (vFlag)
|
if (cfg_verbosity())
|
||||||
printf("%s: Passing through%s%s data from the decoder\n",
|
printf("%s: Passing through%s%s data from the decoder\n",
|
||||||
__progname,
|
cfg_progname(),
|
||||||
(strcmp(pezConfig->format, THEORA_FORMAT) != 0) ? " (unsupported) " : " ",
|
(strcmp(pezConfig->format, THEORA_FORMAT) != 0) ? " (unsupported) " : " ",
|
||||||
pezConfig->format);
|
pezConfig->format);
|
||||||
commandStringLen = strlen(newDecoder) + 1;
|
commandStringLen = strlen(newDecoder) + 1;
|
||||||
@ -402,7 +388,7 @@ getMetadataString(const char *format, metadata_t *mdata)
|
|||||||
|
|
||||||
if (mdata == NULL) {
|
if (mdata == NULL) {
|
||||||
printf("%s: getMetadataString(): Internal error: NULL metadata_t\n",
|
printf("%s: getMetadataString(): Internal error: NULL metadata_t\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,7 +431,7 @@ getMetadata(const char *fileName)
|
|||||||
metadata_t *mdata;
|
metadata_t *mdata;
|
||||||
|
|
||||||
if (metadataFromProgram) {
|
if (metadataFromProgram) {
|
||||||
if ((mdata = metadata_program(fileName, nFlag)) == NULL)
|
if ((mdata = metadata_program(fileName, cfg_normalize_strings())) == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
if (!metadata_program_update(mdata, METADATA_ALL)) {
|
if (!metadata_program_update(mdata, METADATA_ALL)) {
|
||||||
@ -453,7 +439,7 @@ getMetadata(const char *fileName)
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((mdata = metadata_file(fileName, nFlag)) == NULL)
|
if ((mdata = metadata_file(fileName, cfg_normalize_strings())) == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
if (!metadata_file_update(mdata)) {
|
if (!metadata_file_update(mdata)) {
|
||||||
@ -475,18 +461,18 @@ setMetadata(shout_t *shout, metadata_t *mdata, char **mdata_copy)
|
|||||||
|
|
||||||
if (shout == NULL) {
|
if (shout == NULL) {
|
||||||
printf("%s: setMetadata(): Internal error: NULL shout_t\n",
|
printf("%s: setMetadata(): Internal error: NULL shout_t\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mFlag)
|
if (cfg_no_metadata_updates())
|
||||||
return (SHOUTERR_SUCCESS);
|
return (SHOUTERR_SUCCESS);
|
||||||
|
|
||||||
if (mdata == NULL)
|
if (mdata == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if ((shout_mdata = shout_metadata_new()) == NULL) {
|
if ((shout_mdata = shout_metadata_new()) == NULL) {
|
||||||
printf("%s: shout_metadata_new(): %s\n", __progname,
|
printf("%s: shout_metadata_new(): %s\n", cfg_progname(),
|
||||||
strerror(ENOMEM));
|
strerror(ENOMEM));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -502,7 +488,7 @@ setMetadata(shout_t *shout, metadata_t *mdata, char **mdata_copy)
|
|||||||
*/
|
*/
|
||||||
if (shout_metadata_add(shout_mdata, "charset", "UTF-8") != SHOUTERR_SUCCESS) {
|
if (shout_metadata_add(shout_mdata, "charset", "UTF-8") != SHOUTERR_SUCCESS) {
|
||||||
/* Assume SHOUTERR_MALLOC */
|
/* Assume SHOUTERR_MALLOC */
|
||||||
printf("%s: shout_metadata_add(): %s\n", __progname,
|
printf("%s: shout_metadata_add(): %s\n", cfg_progname(),
|
||||||
strerror(ENOMEM));
|
strerror(ENOMEM));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -514,31 +500,31 @@ setMetadata(shout_t *shout, metadata_t *mdata, char **mdata_copy)
|
|||||||
songInfo = metadata_assemble_string(mdata);
|
songInfo = metadata_assemble_string(mdata);
|
||||||
if (artist[0] != '\0' && title[0] != '\0') {
|
if (artist[0] != '\0' && title[0] != '\0') {
|
||||||
if (shout_metadata_add(shout_mdata, "artist", artist) != SHOUTERR_SUCCESS) {
|
if (shout_metadata_add(shout_mdata, "artist", artist) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_metadata_add(): %s\n", __progname,
|
printf("%s: shout_metadata_add(): %s\n", cfg_progname(),
|
||||||
strerror(ENOMEM));
|
strerror(ENOMEM));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (shout_metadata_add(shout_mdata, "title", title) != SHOUTERR_SUCCESS) {
|
if (shout_metadata_add(shout_mdata, "title", title) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_metadata_add(): %s\n", __progname,
|
printf("%s: shout_metadata_add(): %s\n", cfg_progname(),
|
||||||
strerror(ENOMEM));
|
strerror(ENOMEM));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (shout_metadata_add(shout_mdata, "song", songInfo) != SHOUTERR_SUCCESS) {
|
if (shout_metadata_add(shout_mdata, "song", songInfo) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_metadata_add(): %s\n", __progname,
|
printf("%s: shout_metadata_add(): %s\n", cfg_progname(),
|
||||||
strerror(ENOMEM));
|
strerror(ENOMEM));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (shout_metadata_add(shout_mdata, "song", songInfo) != SHOUTERR_SUCCESS) {
|
} else if (shout_metadata_add(shout_mdata, "song", songInfo) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_metadata_add(): %s\n", __progname,
|
printf("%s: shout_metadata_add(): %s\n", cfg_progname(),
|
||||||
strerror(ENOMEM));
|
strerror(ENOMEM));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = shout_set_metadata(shout, shout_mdata)) != SHOUTERR_SUCCESS)
|
if ((ret = shout_set_metadata(shout, shout_mdata)) != SHOUTERR_SUCCESS)
|
||||||
printf("%s: shout_set_metadata(): %s\n",
|
printf("%s: shout_set_metadata(): %s\n",
|
||||||
__progname, shout_get_error(shout));
|
cfg_progname(), shout_get_error(shout));
|
||||||
|
|
||||||
shout_metadata_free(shout_mdata);
|
shout_metadata_free(shout_mdata);
|
||||||
|
|
||||||
@ -598,7 +584,7 @@ openResource(shout_t *shout, const char *fileName, int *popenFlag,
|
|||||||
|
|
||||||
if (strlen(extension) == 0) {
|
if (strlen(extension) == 0) {
|
||||||
printf("%s: Error: Cannot determine file type of '%s'\n",
|
printf("%s: Error: Cannot determine file type of '%s'\n",
|
||||||
__progname, fileName);
|
cfg_progname(), fileName);
|
||||||
return (filep);
|
return (filep);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -621,17 +607,17 @@ openResource(shout_t *shout, const char *fileName, int *popenFlag,
|
|||||||
*mdata_p = mdata;
|
*mdata_p = mdata;
|
||||||
else
|
else
|
||||||
metadata_free(&mdata);
|
metadata_free(&mdata);
|
||||||
if (vFlag > 1)
|
if (cfg_verbosity() > 1)
|
||||||
printf("%s: Running command `%s`\n", __progname,
|
printf("%s: Running command `%s`\n", cfg_progname(),
|
||||||
pCommandString);
|
pCommandString);
|
||||||
|
|
||||||
if (qFlag) {
|
if (cfg_quiet_stderr()) {
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
stderr_fd = dup(fileno(stderr));
|
stderr_fd = dup(fileno(stderr));
|
||||||
if ((fd = open(_PATH_DEVNULL, O_RDWR, 0)) == -1) {
|
if ((fd = open(_PATH_DEVNULL, O_RDWR, 0)) == -1) {
|
||||||
printf("%s: Cannot open %s for redirecting STDERR output: %s\n",
|
printf("%s: Cannot open %s for redirecting STDERR output: %s\n",
|
||||||
__progname, _PATH_DEVNULL, strerror(errno));
|
cfg_progname(), _PATH_DEVNULL, strerror(errno));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -644,7 +630,7 @@ openResource(shout_t *shout, const char *fileName, int *popenFlag,
|
|||||||
errno = 0;
|
errno = 0;
|
||||||
if ((filep = popen(pCommandString, "r")) == NULL) {
|
if ((filep = popen(pCommandString, "r")) == NULL) {
|
||||||
printf("%s: popen(): Error while executing '%s'",
|
printf("%s: popen(): Error while executing '%s'",
|
||||||
__progname, pCommandString);
|
cfg_progname(), pCommandString);
|
||||||
/* popen() does not set errno reliably ... */
|
/* popen() does not set errno reliably ... */
|
||||||
if (errno)
|
if (errno)
|
||||||
printf(": %s\n", strerror(errno));
|
printf(": %s\n", strerror(errno));
|
||||||
@ -655,7 +641,7 @@ openResource(shout_t *shout, const char *fileName, int *popenFlag,
|
|||||||
}
|
}
|
||||||
xfree(pCommandString);
|
xfree(pCommandString);
|
||||||
|
|
||||||
if (qFlag)
|
if (cfg_quiet_stderr())
|
||||||
dup2(stderr_fd, fileno(stderr));
|
dup2(stderr_fd, fileno(stderr));
|
||||||
|
|
||||||
if (stderr_fd > 2)
|
if (stderr_fd > 2)
|
||||||
@ -670,7 +656,7 @@ openResource(shout_t *shout, const char *fileName, int *popenFlag,
|
|||||||
metadata_free(&mdata);
|
metadata_free(&mdata);
|
||||||
|
|
||||||
if ((filep = fopen(fileName, "rb")) == NULL)
|
if ((filep = fopen(fileName, "rb")) == NULL)
|
||||||
printf("%s: %s: %s\n", __progname, fileName,
|
printf("%s: %s: %s\n", cfg_progname(), fileName,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
|
||||||
return (filep);
|
return (filep);
|
||||||
@ -682,11 +668,11 @@ reconnectServer(shout_t *shout, int closeConn)
|
|||||||
unsigned int i;
|
unsigned int i;
|
||||||
int close_conn = closeConn;
|
int close_conn = closeConn;
|
||||||
|
|
||||||
printf("%s: Connection to %s lost\n", __progname, pezConfig->URL);
|
printf("%s: Connection to %s lost\n", cfg_progname(), pezConfig->URL);
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (++i) {
|
while (++i) {
|
||||||
printf("%s: Attempting reconnection #", __progname);
|
printf("%s: Attempting reconnection #", cfg_progname());
|
||||||
if (pezConfig->reconnectAttempts > 0)
|
if (pezConfig->reconnectAttempts > 0)
|
||||||
printf("%u/%u: ", i, pezConfig->reconnectAttempts);
|
printf("%u/%u: ", i, pezConfig->reconnectAttempts);
|
||||||
else
|
else
|
||||||
@ -698,7 +684,7 @@ reconnectServer(shout_t *shout, int closeConn)
|
|||||||
shout_close(shout);
|
shout_close(shout);
|
||||||
if (shout_open(shout) == SHOUTERR_SUCCESS) {
|
if (shout_open(shout) == SHOUTERR_SUCCESS) {
|
||||||
printf("OK\n%s: Reconnect to %s successful\n",
|
printf("OK\n%s: Reconnect to %s successful\n",
|
||||||
__progname, pezConfig->URL);
|
cfg_progname(), pezConfig->URL);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -709,14 +695,14 @@ reconnectServer(shout_t *shout, int closeConn)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
printf("%s: Waiting 5s for %s to come back ...\n",
|
printf("%s: Waiting 5s for %s to come back ...\n",
|
||||||
__progname, pezConfig->URL);
|
cfg_progname(), pezConfig->URL);
|
||||||
if (quit)
|
if (quit)
|
||||||
return (0);
|
return (0);
|
||||||
else
|
else
|
||||||
sleep(5);
|
sleep(5);
|
||||||
};
|
};
|
||||||
|
|
||||||
printf("%s: Giving up\n", __progname);
|
printf("%s: Giving up\n", cfg_progname());
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -752,7 +738,7 @@ sendStream(shout_t *shout, FILE *filepstream, const char *fileName,
|
|||||||
|
|
||||||
if (startTime == NULL) {
|
if (startTime == NULL) {
|
||||||
printf("%s: sendStream(): Internal error: startTime is NULL\n",
|
printf("%s: sendStream(): Internal error: startTime is NULL\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -773,7 +759,7 @@ sendStream(shout_t *shout, FILE *filepstream, const char *fileName,
|
|||||||
shout_sync(shout);
|
shout_sync(shout);
|
||||||
|
|
||||||
if (shout_send(shout, buff, bytes_read) != SHOUTERR_SUCCESS) {
|
if (shout_send(shout, buff, bytes_read) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_send(): %s\n", __progname,
|
printf("%s: shout_send(): %s\n", cfg_progname(),
|
||||||
shout_get_error(shout));
|
shout_get_error(shout));
|
||||||
if (reconnectServer(shout, 1))
|
if (reconnectServer(shout, 1))
|
||||||
break;
|
break;
|
||||||
@ -789,7 +775,7 @@ sendStream(shout_t *shout, FILE *filepstream, const char *fileName,
|
|||||||
rereadPlaylist_notify = 0;
|
rereadPlaylist_notify = 0;
|
||||||
if (!pezConfig->fileNameIsProgram)
|
if (!pezConfig->fileNameIsProgram)
|
||||||
printf("%s: SIGHUP signal received, will reread playlist after this file\n",
|
printf("%s: SIGHUP signal received, will reread playlist after this file\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
}
|
}
|
||||||
if (skipTrack) {
|
if (skipTrack) {
|
||||||
skipTrack = 0;
|
skipTrack = 0;
|
||||||
@ -813,7 +799,7 @@ sendStream(shout_t *shout, FILE *filepstream, const char *fileName,
|
|||||||
}
|
}
|
||||||
|
|
||||||
total += bytes_read;
|
total += bytes_read;
|
||||||
if (qFlag && vFlag) {
|
if (cfg_quiet_stderr() && cfg_verbosity()) {
|
||||||
double oldTime, newTime;
|
double oldTime, newTime;
|
||||||
|
|
||||||
if (!isStdin && playlistMode) {
|
if (!isStdin && playlistMode) {
|
||||||
@ -862,10 +848,10 @@ sendStream(shout_t *shout, FILE *filepstream, const char *fileName,
|
|||||||
ret = STREAM_CONT;
|
ret = STREAM_CONT;
|
||||||
} else if (errno == EBADF && isStdin)
|
} else if (errno == EBADF && isStdin)
|
||||||
printf("%s: No (more) data available on standard input\n",
|
printf("%s: No (more) data available on standard input\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
else
|
else
|
||||||
printf("%s: sendStream(): Error while reading '%s': %s\n",
|
printf("%s: sendStream(): Error while reading '%s': %s\n",
|
||||||
__progname, fileName, strerror(errno));
|
cfg_progname(), fileName, strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (ret);
|
return (ret);
|
||||||
@ -886,7 +872,7 @@ streamFile(shout_t *shout, const char *fileName)
|
|||||||
if ((filepstream = openResource(shout, fileName, &popenFlag, &mdata, &isStdin, &songLen))
|
if ((filepstream = openResource(shout, fileName, &popenFlag, &mdata, &isStdin, &songLen))
|
||||||
== NULL) {
|
== NULL) {
|
||||||
if (++resource_errors > 100) {
|
if (++resource_errors > 100) {
|
||||||
printf("%s: Too many errors -- giving up.\n", __progname);
|
printf("%s: Too many errors -- giving up.\n", cfg_progname());
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
/* Continue with next resource on failure: */
|
/* Continue with next resource on failure: */
|
||||||
@ -901,8 +887,8 @@ streamFile(shout_t *shout, const char *fileName)
|
|||||||
if ((metaData = UTF8toCHAR(tmp, ICONV_REPLACE)) == NULL)
|
if ((metaData = UTF8toCHAR(tmp, ICONV_REPLACE)) == NULL)
|
||||||
metaData = xstrdup("(unknown title)");
|
metaData = xstrdup("(unknown title)");
|
||||||
xfree(tmp);
|
xfree(tmp);
|
||||||
printf("%s: Streaming ``%s''", __progname, metaData);
|
printf("%s: Streaming ``%s''", cfg_progname(), metaData);
|
||||||
if (vFlag)
|
if (cfg_verbosity())
|
||||||
printf(" (file: %s)\n", fileName);
|
printf(" (file: %s)\n", fileName);
|
||||||
else
|
else
|
||||||
printf("\n");
|
printf("\n");
|
||||||
@ -914,7 +900,7 @@ streamFile(shout_t *shout, const char *fileName)
|
|||||||
|
|
||||||
metadata_free(&mdata);
|
metadata_free(&mdata);
|
||||||
} else if (isStdin)
|
} else if (isStdin)
|
||||||
printf("%s: Streaming from standard input\n", __progname);
|
printf("%s: Streaming from standard input\n", cfg_progname());
|
||||||
|
|
||||||
if (songLen > 0)
|
if (songLen > 0)
|
||||||
songLenStr = xstrdup(getTimeString(songLen));
|
songLenStr = xstrdup(getTimeString(songLen));
|
||||||
@ -936,23 +922,23 @@ streamFile(shout_t *shout, const char *fileName)
|
|||||||
}
|
}
|
||||||
if (ret == STREAM_SKIP || skipTrack) {
|
if (ret == STREAM_SKIP || skipTrack) {
|
||||||
skipTrack = 0;
|
skipTrack = 0;
|
||||||
if (!isStdin && vFlag)
|
if (!isStdin && cfg_verbosity())
|
||||||
printf("%s: SIGUSR1 signal received, skipping current track\n",
|
printf("%s: SIGUSR1 signal received, skipping current track\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
retval = 1;
|
retval = 1;
|
||||||
ret = STREAM_DONE;
|
ret = STREAM_DONE;
|
||||||
}
|
}
|
||||||
if (ret == STREAM_UPDMDATA || queryMetadata) {
|
if (ret == STREAM_UPDMDATA || queryMetadata) {
|
||||||
queryMetadata = 0;
|
queryMetadata = 0;
|
||||||
if (mFlag)
|
if (cfg_no_metadata_updates())
|
||||||
continue;
|
continue;
|
||||||
if (metadataFromProgram) {
|
if (metadataFromProgram) {
|
||||||
char *mdataStr = NULL;
|
char *mdataStr = NULL;
|
||||||
metadata_t *prog_mdata;
|
metadata_t *prog_mdata;
|
||||||
|
|
||||||
if (vFlag > 1)
|
if (cfg_verbosity() > 1)
|
||||||
printf("%s: Querying '%s' for fresh metadata\n",
|
printf("%s: Querying '%s' for fresh metadata\n",
|
||||||
__progname, pezConfig->metadataProgram);
|
cfg_progname(), pezConfig->metadataProgram);
|
||||||
if ((prog_mdata = getMetadata(pezConfig->metadataProgram)) == NULL) {
|
if ((prog_mdata = getMetadata(pezConfig->metadataProgram)) == NULL) {
|
||||||
retval = 0;
|
retval = 0;
|
||||||
ret = STREAM_DONE;
|
ret = STREAM_DONE;
|
||||||
@ -964,9 +950,9 @@ streamFile(shout_t *shout, const char *fileName)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
metadata_free(&prog_mdata);
|
metadata_free(&prog_mdata);
|
||||||
if (vFlag > 1)
|
if (cfg_verbosity() > 1)
|
||||||
printf("%s: New metadata: ``%s''\n",
|
printf("%s: New metadata: ``%s''\n",
|
||||||
__progname, mdataStr);
|
cfg_progname(), mdataStr);
|
||||||
xfree(mdataStr);
|
xfree(mdataStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1002,9 +988,9 @@ streamPlaylist(shout_t *shout, const char *fileName)
|
|||||||
} else {
|
} else {
|
||||||
if ((playlist = playlist_read(fileName)) == NULL)
|
if ((playlist = playlist_read(fileName)) == NULL)
|
||||||
return (0);
|
return (0);
|
||||||
if (vFlag && playlist_get_num_items(playlist) == 0)
|
if (cfg_verbosity() && playlist_get_num_items(playlist) == 0)
|
||||||
printf("%s: Warning: Playlist '%s' is empty\n",
|
printf("%s: Warning: Playlist '%s' is empty\n",
|
||||||
__progname, fileName);
|
cfg_progname(), fileName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
@ -1028,7 +1014,7 @@ streamPlaylist(shout_t *shout, const char *fileName)
|
|||||||
rereadPlaylist = rereadPlaylist_notify = 0;
|
rereadPlaylist = rereadPlaylist_notify = 0;
|
||||||
if (pezConfig->fileNameIsProgram)
|
if (pezConfig->fileNameIsProgram)
|
||||||
continue;
|
continue;
|
||||||
printf("%s: Rereading playlist\n", __progname);
|
printf("%s: Rereading playlist\n", cfg_progname());
|
||||||
if (!playlist_reread(&playlist))
|
if (!playlist_reread(&playlist))
|
||||||
return (0);
|
return (0);
|
||||||
if (pezConfig->shuffle)
|
if (pezConfig->shuffle)
|
||||||
@ -1044,32 +1030,6 @@ streamPlaylist(shout_t *shout, const char *fileName)
|
|||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Borrowed from OpenNTPd-portable's compat-openbsd/bsd-misc.c.
|
|
||||||
* Does not use xalloc on purpose, as the 9 bytes of memory that don't get
|
|
||||||
* cleaned up in the end really don't matter.
|
|
||||||
*/
|
|
||||||
char *
|
|
||||||
getProgname(const char *argv0)
|
|
||||||
{
|
|
||||||
#ifdef HAVE___PROGNAME
|
|
||||||
(void)argv0;
|
|
||||||
return (strdup(__progname));
|
|
||||||
#else
|
|
||||||
char *p;
|
|
||||||
|
|
||||||
if (argv0 == NULL)
|
|
||||||
return ((char *)"ezstream");
|
|
||||||
p = strrchr(argv0, '/');
|
|
||||||
if (p == NULL)
|
|
||||||
p = (char *)argv0;
|
|
||||||
else
|
|
||||||
p++;
|
|
||||||
|
|
||||||
return (strdup(p));
|
|
||||||
#endif /* HAVE___PROGNAME */
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
ez_shutdown(int exitval)
|
ez_shutdown(int exitval)
|
||||||
{
|
{
|
||||||
@ -1081,36 +1041,13 @@ ez_shutdown(int exitval)
|
|||||||
return (exitval);
|
return (exitval);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
usage(void)
|
|
||||||
{
|
|
||||||
printf("usage: %s [-hmnqVv] -c configfile\n", __progname);
|
|
||||||
printf(" %s -s [playlist]\n", __progname);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
usageHelp(void)
|
|
||||||
{
|
|
||||||
printf("\n");
|
|
||||||
printf(" -c configfile use XML configuration in configfile (mandatory)\n");
|
|
||||||
printf(" -h display this additional help and exit\n");
|
|
||||||
printf(" -m disable metadata updates\n");
|
|
||||||
printf(" -n normalize metadata strings\n");
|
|
||||||
printf(" -q suppress STDERR output from external en-/decoders\n");
|
|
||||||
printf(" -s [playlist] read lines from playlist (or STDIN), shuffle and print them to\n");
|
|
||||||
printf(" STDOUT, then exit\n");
|
|
||||||
printf(" -V print the version number and exit\n");
|
|
||||||
printf(" -v verbose output (use twice for more effect)\n");
|
|
||||||
printf("\n");
|
|
||||||
printf("See the ezstream(1) manual for detailed information.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int c;
|
int ret;
|
||||||
char *configFile = NULL;
|
|
||||||
char *playlistFile = NULL;
|
const char *configFile;
|
||||||
|
const char *playlistFile;
|
||||||
char *host = NULL;
|
char *host = NULL;
|
||||||
unsigned short port = 0;
|
unsigned short port = 0;
|
||||||
char *mount = NULL;
|
char *mount = NULL;
|
||||||
@ -1121,6 +1058,9 @@ main(int argc, char *argv[])
|
|||||||
struct sigaction act;
|
struct sigaction act;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
#endif
|
#endif
|
||||||
|
ret = 1;
|
||||||
|
if (0 > cfg_cmdline_parse(argc, argv, &ret))
|
||||||
|
return (ret);
|
||||||
|
|
||||||
#ifdef XALLOC_DEBUG
|
#ifdef XALLOC_DEBUG
|
||||||
xalloc_initialize_debug(2, NULL);
|
xalloc_initialize_debug(2, NULL);
|
||||||
@ -1130,63 +1070,10 @@ main(int argc, char *argv[])
|
|||||||
playlist_init();
|
playlist_init();
|
||||||
shout_init();
|
shout_init();
|
||||||
|
|
||||||
__progname = getProgname(argv[0]);
|
|
||||||
pezConfig = getEZConfig();
|
pezConfig = getEZConfig();
|
||||||
|
|
||||||
mFlag = 0;
|
playlistFile = cfg_shuffle_file();
|
||||||
nFlag = 0;
|
if (playlistFile) {
|
||||||
qFlag = 0;
|
|
||||||
vFlag = 0;
|
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "c:hmnqs:Vv")) != -1) {
|
|
||||||
switch (c) {
|
|
||||||
case 'c':
|
|
||||||
if (configFile != NULL) {
|
|
||||||
printf("Error: multiple -c arguments given\n");
|
|
||||||
usage();
|
|
||||||
return (ez_shutdown(2));
|
|
||||||
}
|
|
||||||
configFile = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
case 'h':
|
|
||||||
usage();
|
|
||||||
usageHelp();
|
|
||||||
return (ez_shutdown(0));
|
|
||||||
case 'm':
|
|
||||||
mFlag = 1;
|
|
||||||
break;
|
|
||||||
case 'n':
|
|
||||||
nFlag = 1;
|
|
||||||
break;
|
|
||||||
case 'q':
|
|
||||||
qFlag = 1;
|
|
||||||
break;
|
|
||||||
case 's':
|
|
||||||
sFlag = 1;
|
|
||||||
if (playlistFile != NULL) {
|
|
||||||
printf("Error: multiple -s arguments given\n");
|
|
||||||
usage();
|
|
||||||
return (ez_shutdown(2));
|
|
||||||
}
|
|
||||||
playlistFile = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
case 'V':
|
|
||||||
printf("%s\n", PACKAGE_STRING);
|
|
||||||
return (ez_shutdown(0));
|
|
||||||
case 'v':
|
|
||||||
vFlag++;
|
|
||||||
break;
|
|
||||||
case '?':
|
|
||||||
usage();
|
|
||||||
return (ez_shutdown(2));
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
|
|
||||||
if (sFlag) {
|
|
||||||
playlist_t *pl;
|
playlist_t *pl;
|
||||||
const char *entry;
|
const char *entry;
|
||||||
|
|
||||||
@ -1207,30 +1094,26 @@ main(int argc, char *argv[])
|
|||||||
return (ez_shutdown(0));
|
return (ez_shutdown(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configFile == NULL) {
|
configFile = cfg_config_file();
|
||||||
printf("You must supply a config file with the -c argument.\n");
|
{
|
||||||
usage();
|
|
||||||
return (ez_shutdown(2));
|
|
||||||
} else {
|
|
||||||
/*
|
/*
|
||||||
* Attempt to open configFile here for a more meaningful error
|
* Attempt to open configFile here for a more meaningful error
|
||||||
* message. Where possible, do it with stat() and check for
|
* message. Where possible, do it with stat() and check for
|
||||||
* safe config file permissions.
|
* safe config file permissions.
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_STAT
|
#ifdef HAVE_STAT
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
if (stat(configFile, &st) == -1) {
|
if (stat(configFile, &st) == -1) {
|
||||||
printf("%s: %s\n", configFile, strerror(errno));
|
printf("%s: %s\n", configFile, strerror(errno));
|
||||||
usage();
|
|
||||||
return (ez_shutdown(2));
|
return (ez_shutdown(2));
|
||||||
}
|
}
|
||||||
if (vFlag && (st.st_mode & (S_IRGRP | S_IROTH)))
|
if (cfg_verbosity() && (st.st_mode & (S_IRGRP | S_IROTH)))
|
||||||
printf("%s: Warning: %s is group and/or world readable\n",
|
printf("%s: Warning: %s is group and/or world readable\n",
|
||||||
__progname, configFile);
|
cfg_progname(), configFile);
|
||||||
if (st.st_mode & (S_IWGRP | S_IWOTH)) {
|
if (st.st_mode & (S_IWGRP | S_IWOTH)) {
|
||||||
printf("%s: Error: %s is group and/or world writeable\n",
|
printf("%s: Error: %s is group and/or world writeable\n",
|
||||||
__progname, configFile);
|
cfg_progname(), configFile);
|
||||||
return (ez_shutdown(2));
|
return (ez_shutdown(2));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -1279,8 +1162,6 @@ main(int argc, char *argv[])
|
|||||||
printf("Specify a stream format of either MP3, VORBIS or THEORA\n");
|
printf("Specify a stream format of either MP3, VORBIS or THEORA\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
xfree(configFile);
|
|
||||||
|
|
||||||
if ((shout = stream_setup(host, port, mount)) == NULL)
|
if ((shout = stream_setup(host, port, mount)) == NULL)
|
||||||
return (ez_shutdown(1));
|
return (ez_shutdown(1));
|
||||||
|
|
||||||
@ -1298,7 +1179,7 @@ main(int argc, char *argv[])
|
|||||||
for (i = 0; i < sizeof(ezstream_signals) / sizeof(int); i++) {
|
for (i = 0; i < sizeof(ezstream_signals) / sizeof(int); i++) {
|
||||||
if (sigaction(ezstream_signals[i], &act, NULL) == -1) {
|
if (sigaction(ezstream_signals[i], &act, NULL) == -1) {
|
||||||
printf("%s: sigaction(): %s\n",
|
printf("%s: sigaction(): %s\n",
|
||||||
__progname, strerror(errno));
|
cfg_progname(), strerror(errno));
|
||||||
return (ez_shutdown(1));
|
return (ez_shutdown(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1309,15 +1190,15 @@ main(int argc, char *argv[])
|
|||||||
act.sa_handler = SIG_IGN;
|
act.sa_handler = SIG_IGN;
|
||||||
if (sigaction(SIGPIPE, &act, NULL) == -1) {
|
if (sigaction(SIGPIPE, &act, NULL) == -1) {
|
||||||
printf("%s: sigaction(): %s\n",
|
printf("%s: sigaction(): %s\n",
|
||||||
__progname, strerror(errno));
|
cfg_progname(), strerror(errno));
|
||||||
return (ez_shutdown(1));
|
return (ez_shutdown(1));
|
||||||
}
|
}
|
||||||
#endif /* HAVE_SIGNALS */
|
#endif /* HAVE_SIGNALS */
|
||||||
|
|
||||||
if (shout_open(shout) == SHOUTERR_SUCCESS) {
|
if (shout_open(shout) == SHOUTERR_SUCCESS) {
|
||||||
int ret;
|
int cont;
|
||||||
|
|
||||||
printf("%s: Connected to http://%s:%hu%s\n", __progname,
|
printf("%s: Connected to http://%s:%hu%s\n", cfg_progname(),
|
||||||
host, port, mount);
|
host, port, mount);
|
||||||
|
|
||||||
if (pezConfig->fileNameIsProgram ||
|
if (pezConfig->fileNameIsProgram ||
|
||||||
@ -1327,32 +1208,32 @@ main(int argc, char *argv[])
|
|||||||
else
|
else
|
||||||
playlistMode = 0;
|
playlistMode = 0;
|
||||||
|
|
||||||
if (vFlag && pezConfig->fileNameIsProgram)
|
if (cfg_verbosity() && pezConfig->fileNameIsProgram)
|
||||||
printf("%s: Using program '%s' to get filenames for streaming\n",
|
printf("%s: Using program '%s' to get filenames for streaming\n",
|
||||||
__progname, pezConfig->fileName);
|
cfg_progname(), pezConfig->fileName);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (playlistMode) {
|
if (playlistMode) {
|
||||||
ret = streamPlaylist(shout, pezConfig->fileName);
|
cont = streamPlaylist(shout, pezConfig->fileName);
|
||||||
} else {
|
} else {
|
||||||
ret = streamFile(shout, pezConfig->fileName);
|
cont = streamFile(shout, pezConfig->fileName);
|
||||||
}
|
}
|
||||||
if (quit)
|
if (quit)
|
||||||
break;
|
break;
|
||||||
if (pezConfig->streamOnce)
|
if (pezConfig->streamOnce)
|
||||||
break;
|
break;
|
||||||
} while (ret);
|
} while (cont);
|
||||||
|
|
||||||
shout_close(shout);
|
shout_close(shout);
|
||||||
} else
|
} else
|
||||||
printf("%s: Connection to http://%s:%hu%s failed: %s\n", __progname,
|
printf("%s: Connection to http://%s:%hu%s failed: %s\n", cfg_progname(),
|
||||||
host, port, mount, shout_get_error(shout));
|
host, port, mount, shout_get_error(shout));
|
||||||
|
|
||||||
if (quit)
|
if (quit)
|
||||||
printf("\r%s: SIGINT or SIGTERM received\n", __progname);
|
printf("\r%s: SIGINT or SIGTERM received\n", cfg_progname());
|
||||||
|
|
||||||
if (vFlag)
|
if (cfg_verbosity())
|
||||||
printf("%s: Exiting ...\n", __progname);
|
printf("%s: Exiting ...\n", cfg_progname());
|
||||||
|
|
||||||
xfree(host);
|
xfree(host);
|
||||||
xfree(mount);
|
xfree(mount);
|
||||||
|
@ -50,6 +50,8 @@
|
|||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "cfg.h"
|
||||||
|
|
||||||
#ifndef STDIN_FILENO
|
#ifndef STDIN_FILENO
|
||||||
# define STDIN_FILENO 0
|
# define STDIN_FILENO 0
|
||||||
#endif /* !STDIN_FILENO */
|
#endif /* !STDIN_FILENO */
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#endif /* HAVE_VORBISFILE */
|
#endif /* HAVE_VORBISFILE */
|
||||||
#include <shout/shout.h>
|
#include <shout/shout.h>
|
||||||
|
|
||||||
|
#include "cfg.h"
|
||||||
#include "metadata.h"
|
#include "metadata.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "xalloc.h"
|
#include "xalloc.h"
|
||||||
@ -39,9 +40,6 @@
|
|||||||
# define S_IEXEC S_IXUSR
|
# define S_IEXEC S_IXUSR
|
||||||
#endif /* !S_IEXEC */
|
#endif /* !S_IEXEC */
|
||||||
|
|
||||||
extern char *__progname;
|
|
||||||
extern int vFlag;
|
|
||||||
|
|
||||||
static const char *blankString = "";
|
static const char *blankString = "";
|
||||||
|
|
||||||
struct metadata {
|
struct metadata {
|
||||||
@ -96,7 +94,7 @@ metadata_use_taglib(metadata_t *md, FILE **filep)
|
|||||||
|
|
||||||
if (md == NULL || md->filename == NULL) {
|
if (md == NULL || md->filename == NULL) {
|
||||||
printf("%s: metadata_use_taglib(): Internal error: Bad arguments\n",
|
printf("%s: metadata_use_taglib(): Internal error: Bad arguments\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +146,7 @@ metadata_use_taglib(metadata_t *md, FILE **filep)
|
|||||||
(void)filep;
|
(void)filep;
|
||||||
|
|
||||||
printf("%s: Internal error: metadata_use_taglib() called without TagLib support\n",
|
printf("%s: Internal error: metadata_use_taglib() called without TagLib support\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
#endif /* HAVE_TAGLIB */
|
#endif /* HAVE_TAGLIB */
|
||||||
@ -161,7 +159,7 @@ metadata_use_self(metadata_t *md, FILE **filep)
|
|||||||
(void)filep;
|
(void)filep;
|
||||||
|
|
||||||
printf("%s: Internal error: metadata_use_self() called with TagLib support\n",
|
printf("%s: Internal error: metadata_use_self() called with TagLib support\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -172,7 +170,7 @@ metadata_use_self(metadata_t *md, FILE **filep)
|
|||||||
if (md == NULL || filep == NULL || *filep == NULL ||
|
if (md == NULL || filep == NULL || *filep == NULL ||
|
||||||
md->filename == NULL) {
|
md->filename == NULL) {
|
||||||
printf("%s: metadata_use_self(): Internal error: Bad arguments\n",
|
printf("%s: metadata_use_self(): Internal error: Bad arguments\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,27 +196,27 @@ metadata_use_self(metadata_t *md, FILE **filep)
|
|||||||
switch (ret) {
|
switch (ret) {
|
||||||
case OV_EREAD:
|
case OV_EREAD:
|
||||||
printf("%s: ov_open(): %s: Media read error\n",
|
printf("%s: ov_open(): %s: Media read error\n",
|
||||||
__progname, md->filename);
|
cfg_progname(), md->filename);
|
||||||
break;
|
break;
|
||||||
case OV_ENOTVORBIS:
|
case OV_ENOTVORBIS:
|
||||||
printf("%s: ov_open(): %s: Invalid Vorbis bitstream\n",
|
printf("%s: ov_open(): %s: Invalid Vorbis bitstream\n",
|
||||||
__progname, md->filename);
|
cfg_progname(), md->filename);
|
||||||
break;
|
break;
|
||||||
case OV_EVERSION:
|
case OV_EVERSION:
|
||||||
printf("%s: ov_open(): %s: Vorbis version mismatch\n",
|
printf("%s: ov_open(): %s: Vorbis version mismatch\n",
|
||||||
__progname, md->filename);
|
cfg_progname(), md->filename);
|
||||||
break;
|
break;
|
||||||
case OV_EBADHEADER:
|
case OV_EBADHEADER:
|
||||||
printf("%s: ov_open(): %s: Invalid Vorbis bitstream header\n",
|
printf("%s: ov_open(): %s: Invalid Vorbis bitstream header\n",
|
||||||
__progname, md->filename);
|
cfg_progname(), md->filename);
|
||||||
break;
|
break;
|
||||||
case OV_EFAULT:
|
case OV_EFAULT:
|
||||||
printf("%s: Fatal: Internal libvorbisfile fault\n",
|
printf("%s: Fatal: Internal libvorbisfile fault\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
abort();
|
abort();
|
||||||
default:
|
default:
|
||||||
printf("%s: ov_open(): %s: ov_read() returned unknown error\n",
|
printf("%s: ov_open(): %s: ov_read() returned unknown error\n",
|
||||||
__progname, md->filename);
|
cfg_progname(), md->filename);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -256,7 +254,7 @@ metadata_clean_md(metadata_t *md)
|
|||||||
{
|
{
|
||||||
if (md == NULL) {
|
if (md == NULL) {
|
||||||
printf("%s: Internal error: metadata_clean_md(): NULL argument\n",
|
printf("%s: Internal error: metadata_clean_md(): NULL argument\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,7 +279,7 @@ metadata_get_extension(char *buf, size_t siz, const char *filename)
|
|||||||
|
|
||||||
if (buf == NULL || siz == 0 || filename == NULL) {
|
if (buf == NULL || siz == 0 || filename == NULL) {
|
||||||
printf("%s: metadata_get_extension(): Internal error: Bad arguments\n",
|
printf("%s: metadata_get_extension(): Internal error: Bad arguments\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,13 +299,13 @@ metadata_get_name(const char *file)
|
|||||||
|
|
||||||
if (file == NULL) {
|
if (file == NULL) {
|
||||||
printf("%s: metadata_get_name(): Internal error: Bad arguments\n",
|
printf("%s: metadata_get_name(): Internal error: Bad arguments\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((p1 = basename(filename)) == NULL) {
|
if ((p1 = basename(filename)) == NULL) {
|
||||||
printf("%s: Internal error: basename() failed with '%s'\n",
|
printf("%s: Internal error: basename() failed with '%s'\n",
|
||||||
__progname, filename);
|
cfg_progname(), filename);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,7 +326,7 @@ metadata_process_md(metadata_t *md)
|
|||||||
{
|
{
|
||||||
if (md == NULL) {
|
if (md == NULL) {
|
||||||
printf("%s: metadata_process_md(): Internal error: Bad arguments\n",
|
printf("%s: metadata_process_md(): Internal error: Bad arguments\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,7 +378,7 @@ metadata_file(const char *filename, int normalize)
|
|||||||
|
|
||||||
if (filename == NULL || strlen(filename) == 0) {
|
if (filename == NULL || strlen(filename) == 0) {
|
||||||
printf("%s: metadata_file(): Internal error: Bad arguments\n",
|
printf("%s: metadata_file(): Internal error: Bad arguments\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,7 +405,7 @@ metadata_program(const char *program, int normalize)
|
|||||||
|
|
||||||
if (program == NULL || strlen(program) == 0) {
|
if (program == NULL || strlen(program) == 0) {
|
||||||
printf("%s: metadata_program(): Internal error: Bad arguments\n",
|
printf("%s: metadata_program(): Internal error: Bad arguments\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -417,24 +415,24 @@ metadata_program(const char *program, int normalize)
|
|||||||
|
|
||||||
#ifdef HAVE_STAT
|
#ifdef HAVE_STAT
|
||||||
if (stat(program, &st) == -1) {
|
if (stat(program, &st) == -1) {
|
||||||
printf("%s: %s: %s\n", __progname, program, strerror(errno));
|
printf("%s: %s: %s\n", cfg_progname(), program, strerror(errno));
|
||||||
metadata_free(&md);
|
metadata_free(&md);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (st.st_mode & (S_IWGRP | S_IWOTH)) {
|
if (st.st_mode & (S_IWGRP | S_IWOTH)) {
|
||||||
printf("%s: Error: %s is group and/or world writeable\n",
|
printf("%s: Error: %s is group and/or world writeable\n",
|
||||||
__progname, program);
|
cfg_progname(), program);
|
||||||
metadata_free(&md);
|
metadata_free(&md);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (!(st.st_mode & (S_IEXEC | S_IXGRP | S_IXOTH))) {
|
if (!(st.st_mode & (S_IEXEC | S_IXGRP | S_IXOTH))) {
|
||||||
printf("%s: %s: Not an executable program\n", __progname, program);
|
printf("%s: %s: Not an executable program\n", cfg_progname(), program);
|
||||||
metadata_free(&md);
|
metadata_free(&md);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if ((filep = fopen(program, "r")) == NULL) {
|
if ((filep = fopen(program, "r")) == NULL) {
|
||||||
printf("%s: %s: %s\n", __progname, program, strerror(errno));
|
printf("%s: %s: %s\n", cfg_progname(), program, strerror(errno));
|
||||||
metadata_free(&md);
|
metadata_free(&md);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
@ -471,18 +469,18 @@ metadata_file_update(metadata_t *md)
|
|||||||
|
|
||||||
if (md == NULL) {
|
if (md == NULL) {
|
||||||
printf("%s: metadata_file_update(): Internal error: NULL argument\n",
|
printf("%s: metadata_file_update(): Internal error: NULL argument\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (md->program) {
|
if (md->program) {
|
||||||
printf("%s: metadata_file_update(): Internal error: Called with program handle\n",
|
printf("%s: metadata_file_update(): Internal error: Called with program handle\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((filep = fopen(md->filename, "rb")) == NULL) {
|
if ((filep = fopen(md->filename, "rb")) == NULL) {
|
||||||
printf("%s: %s: %s\n", __progname, md->filename, strerror(errno));
|
printf("%s: %s: %s\n", cfg_progname(), md->filename, strerror(errno));
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -506,13 +504,13 @@ metadata_program_update(metadata_t *md, enum metadata_request md_req)
|
|||||||
|
|
||||||
if (md == NULL) {
|
if (md == NULL) {
|
||||||
printf("%s: metadata_program_update(): Internal error: NULL argument\n",
|
printf("%s: metadata_program_update(): Internal error: NULL argument\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!md->program) {
|
if (!md->program) {
|
||||||
printf("%s: metadata_program_update(): Internal error: Received file handle\n",
|
printf("%s: metadata_program_update(): Internal error: Received file handle\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -548,18 +546,18 @@ metadata_program_update(metadata_t *md, enum metadata_request md_req)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("%s: metadata_program_update(): Internal error: Unknown md_req\n",
|
printf("%s: metadata_program_update(): Internal error: Unknown md_req\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
fflush(NULL);
|
fflush(NULL);
|
||||||
errno = 0;
|
errno = 0;
|
||||||
if (vFlag > 1)
|
if (cfg_verbosity() > 1)
|
||||||
printf("%s: Running command `%s`\n", __progname,
|
printf("%s: Running command `%s`\n", cfg_progname(),
|
||||||
command);
|
command);
|
||||||
if ((filep = popen(command, "r")) == NULL) {
|
if ((filep = popen(command, "r")) == NULL) {
|
||||||
printf("%s: playlist_run_program(): Error while executing '%s'",
|
printf("%s: playlist_run_program(): Error while executing '%s'",
|
||||||
__progname, command);
|
cfg_progname(), command);
|
||||||
/* popen() does not set errno reliably ... */
|
/* popen() does not set errno reliably ... */
|
||||||
if (errno)
|
if (errno)
|
||||||
printf(": %s\n", strerror(errno));
|
printf(": %s\n", strerror(errno));
|
||||||
@ -571,10 +569,10 @@ metadata_program_update(metadata_t *md, enum metadata_request md_req)
|
|||||||
if (fgets(buf, (int)sizeof(buf), filep) == NULL) {
|
if (fgets(buf, (int)sizeof(buf), filep) == NULL) {
|
||||||
if (ferror(filep))
|
if (ferror(filep))
|
||||||
printf("%s: Error while reading output from program '%s': %s\n",
|
printf("%s: Error while reading output from program '%s': %s\n",
|
||||||
__progname, md->filename, strerror(errno));
|
cfg_progname(), md->filename, strerror(errno));
|
||||||
pclose(filep);
|
pclose(filep);
|
||||||
printf("%s: FATAL: External program '%s' not (or no longer) usable.\n",
|
printf("%s: FATAL: External program '%s' not (or no longer) usable.\n",
|
||||||
__progname, md->filename);
|
cfg_progname(), md->filename);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -582,7 +580,7 @@ metadata_program_update(metadata_t *md, enum metadata_request md_req)
|
|||||||
|
|
||||||
if (strlen(buf) == sizeof(buf) - 1)
|
if (strlen(buf) == sizeof(buf) - 1)
|
||||||
printf("%s: Warning: Metadata string received via '%s' is too long and has been truncated\n",
|
printf("%s: Warning: Metadata string received via '%s' is too long and has been truncated\n",
|
||||||
__progname, command);
|
cfg_progname(), command);
|
||||||
|
|
||||||
buf[strcspn(buf, "\n")] = '\0';
|
buf[strcspn(buf, "\n")] = '\0';
|
||||||
buf[strcspn(buf, "\r")] = '\0';
|
buf[strcspn(buf, "\r")] = '\0';
|
||||||
@ -591,7 +589,7 @@ metadata_program_update(metadata_t *md, enum metadata_request md_req)
|
|||||||
case METADATA_STRING:
|
case METADATA_STRING:
|
||||||
if (strlen(buf) == 0) {
|
if (strlen(buf) == 0) {
|
||||||
printf("%s: Warning: Empty metadata string received from '%s'\n",
|
printf("%s: Warning: Empty metadata string received from '%s'\n",
|
||||||
__progname, md->filename);
|
cfg_progname(), md->filename);
|
||||||
md->string = xstrdup("");
|
md->string = xstrdup("");
|
||||||
} else
|
} else
|
||||||
md->string = xstrdup(buf);
|
md->string = xstrdup(buf);
|
||||||
@ -607,7 +605,7 @@ metadata_program_update(metadata_t *md, enum metadata_request md_req)
|
|||||||
case METADATA_ALL:
|
case METADATA_ALL:
|
||||||
default:
|
default:
|
||||||
printf("%s: metadata_program_update(): Internal error: METADATA_ALL in code unreachable by METADATA_ALL\n",
|
printf("%s: metadata_program_update(): Internal error: METADATA_ALL in code unreachable by METADATA_ALL\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -625,13 +623,13 @@ metadata_get_string(metadata_t *md)
|
|||||||
{
|
{
|
||||||
if (md == NULL) {
|
if (md == NULL) {
|
||||||
printf("%s: metadata_get_string(): Internal error: Bad arguments\n",
|
printf("%s: metadata_get_string(): Internal error: Bad arguments\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (md->string == NULL) {
|
if (md->string == NULL) {
|
||||||
printf("%s: metadata_get_string(): Internal error: md->string cannot be NULL\n",
|
printf("%s: metadata_get_string(): Internal error: md->string cannot be NULL\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -643,7 +641,7 @@ metadata_get_artist(metadata_t *md)
|
|||||||
{
|
{
|
||||||
if (md == NULL) {
|
if (md == NULL) {
|
||||||
printf("%s: metadata_get_artist(): Internal error: Bad arguments\n",
|
printf("%s: metadata_get_artist(): Internal error: Bad arguments\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -658,7 +656,7 @@ metadata_get_title(metadata_t *md)
|
|||||||
{
|
{
|
||||||
if (md == NULL) {
|
if (md == NULL) {
|
||||||
printf("%s: metadata_get_title(): Internal error: Bad arguments\n",
|
printf("%s: metadata_get_title(): Internal error: Bad arguments\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -673,7 +671,7 @@ metadata_get_filename(metadata_t *md)
|
|||||||
{
|
{
|
||||||
if (md == NULL) {
|
if (md == NULL) {
|
||||||
printf("%s: metadata_get_filename(): Internal error: Bad arguments\n",
|
printf("%s: metadata_get_filename(): Internal error: Bad arguments\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -689,7 +687,7 @@ metadata_get_length(metadata_t *md)
|
|||||||
{
|
{
|
||||||
if (md == NULL) {
|
if (md == NULL) {
|
||||||
printf("%s: metadata_get_length(): Internal error: Bad arguments\n",
|
printf("%s: metadata_get_length(): Internal error: Bad arguments\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -704,7 +702,7 @@ metadata_assemble_string(metadata_t *md)
|
|||||||
|
|
||||||
if (md == NULL) {
|
if (md == NULL) {
|
||||||
printf("%s: metadata_assemble_string(): Internal error: Bad arguments\n",
|
printf("%s: metadata_assemble_string(): Internal error: Bad arguments\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "ezstream.h"
|
#include "ezstream.h"
|
||||||
|
|
||||||
|
#include "cfg.h"
|
||||||
#include "playlist.h"
|
#include "playlist.h"
|
||||||
#include "xalloc.h"
|
#include "xalloc.h"
|
||||||
|
|
||||||
@ -28,8 +29,6 @@
|
|||||||
# define S_IEXEC S_IXUSR
|
# define S_IEXEC S_IXUSR
|
||||||
#endif /* !S_IEXEC */
|
#endif /* !S_IEXEC */
|
||||||
|
|
||||||
extern char *__progname;
|
|
||||||
|
|
||||||
struct playlist {
|
struct playlist {
|
||||||
char *filename;
|
char *filename;
|
||||||
char **list;
|
char **list;
|
||||||
@ -63,7 +62,7 @@ playlist_add(playlist_t *pl, const char *entry)
|
|||||||
|
|
||||||
if (pl == NULL || entry == NULL) {
|
if (pl == NULL || entry == NULL) {
|
||||||
printf("%s: playlist_add(): Internal error: Bad arguments\n",
|
printf("%s: playlist_add(): Internal error: Bad arguments\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +133,7 @@ playlist_read(const char *filename)
|
|||||||
pl = playlist_create(filename);
|
pl = playlist_create(filename);
|
||||||
|
|
||||||
if ((filep = fopen(filename, "r")) == NULL) {
|
if ((filep = fopen(filename, "r")) == NULL) {
|
||||||
printf("%s: %s: %s\n", __progname, filename, strerror(errno));
|
printf("%s: %s: %s\n", cfg_progname(), filename, strerror(errno));
|
||||||
playlist_free(&pl);
|
playlist_free(&pl);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
@ -142,7 +141,7 @@ playlist_read(const char *filename)
|
|||||||
pl = playlist_create("stdin");
|
pl = playlist_create("stdin");
|
||||||
|
|
||||||
if ((filep = fdopen(STDIN_FILENO, "r")) == NULL) {
|
if ((filep = fdopen(STDIN_FILENO, "r")) == NULL) {
|
||||||
printf("%s: stdin: %s\n", __progname, strerror(errno));
|
printf("%s: stdin: %s\n", cfg_progname(), strerror(errno));
|
||||||
playlist_free(&pl);
|
playlist_free(&pl);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
@ -190,7 +189,7 @@ playlist_read(const char *filename)
|
|||||||
}
|
}
|
||||||
if (ferror(filep)) {
|
if (ferror(filep)) {
|
||||||
printf("%s: playlist_read(): Error while reading %s: %s\n",
|
printf("%s: playlist_read(): Error while reading %s: %s\n",
|
||||||
__progname, pl->filename, strerror(errno));
|
cfg_progname(), pl->filename, strerror(errno));
|
||||||
fclose(filep);
|
fclose(filep);
|
||||||
playlist_free(&pl);
|
playlist_free(&pl);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
@ -215,24 +214,24 @@ playlist_program(const char *filename)
|
|||||||
|
|
||||||
#ifdef HAVE_STAT
|
#ifdef HAVE_STAT
|
||||||
if (stat(filename, &st) == -1) {
|
if (stat(filename, &st) == -1) {
|
||||||
printf("%s: %s: %s\n", __progname, filename, strerror(errno));
|
printf("%s: %s: %s\n", cfg_progname(), filename, strerror(errno));
|
||||||
playlist_free(&pl);
|
playlist_free(&pl);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (st.st_mode & (S_IWGRP | S_IWOTH)) {
|
if (st.st_mode & (S_IWGRP | S_IWOTH)) {
|
||||||
printf("%s: Error: %s is group and/or world writeable\n",
|
printf("%s: Error: %s is group and/or world writeable\n",
|
||||||
__progname, filename);
|
cfg_progname(), filename);
|
||||||
playlist_free(&pl);
|
playlist_free(&pl);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (!(st.st_mode & (S_IEXEC | S_IXGRP | S_IXOTH))) {
|
if (!(st.st_mode & (S_IEXEC | S_IXGRP | S_IXOTH))) {
|
||||||
printf("%s: %s: Not an executable program\n", __progname, filename);
|
printf("%s: %s: Not an executable program\n", cfg_progname(), filename);
|
||||||
playlist_free(&pl);
|
playlist_free(&pl);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if ((filep = fopen(filename, "r")) == NULL) {
|
if ((filep = fopen(filename, "r")) == NULL) {
|
||||||
printf("%s: %s: %s\n", __progname, filename, strerror(errno));
|
printf("%s: %s: %s\n", cfg_progname(), filename, strerror(errno));
|
||||||
playlist_free(&pl);
|
playlist_free(&pl);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
@ -283,7 +282,7 @@ playlist_get_next(playlist_t *pl)
|
|||||||
{
|
{
|
||||||
if (pl == NULL) {
|
if (pl == NULL) {
|
||||||
printf("%s: playlist_get_next(): Internal error: NULL argument\n",
|
printf("%s: playlist_get_next(): Internal error: NULL argument\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,7 +300,7 @@ playlist_peek_next(playlist_t *pl)
|
|||||||
{
|
{
|
||||||
if (pl == NULL) {
|
if (pl == NULL) {
|
||||||
printf("%s: playlist_peek_next(): Internal error: NULL argument\n",
|
printf("%s: playlist_peek_next(): Internal error: NULL argument\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,7 +315,7 @@ playlist_skip_next(playlist_t *pl)
|
|||||||
{
|
{
|
||||||
if (pl == NULL) {
|
if (pl == NULL) {
|
||||||
printf("%s: playlist_skip_next(): Internal error: NULL argument\n",
|
printf("%s: playlist_skip_next(): Internal error: NULL argument\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,7 +331,7 @@ playlist_get_num_items(playlist_t *pl)
|
|||||||
{
|
{
|
||||||
if (pl == NULL) {
|
if (pl == NULL) {
|
||||||
printf("%s: playlist_get_position(): Internal error: NULL argument\n",
|
printf("%s: playlist_get_position(): Internal error: NULL argument\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,7 +346,7 @@ playlist_get_position(playlist_t *pl)
|
|||||||
{
|
{
|
||||||
if (pl == NULL) {
|
if (pl == NULL) {
|
||||||
printf("%s: playlist_get_position(): Internal error: NULL argument\n",
|
printf("%s: playlist_get_position(): Internal error: NULL argument\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -362,7 +361,7 @@ playlist_set_position(playlist_t *pl, unsigned long idx)
|
|||||||
{
|
{
|
||||||
if (pl == NULL) {
|
if (pl == NULL) {
|
||||||
printf("%s: playlist_set_position(): Internal error: NULL argument\n",
|
printf("%s: playlist_set_position(): Internal error: NULL argument\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,7 +380,7 @@ playlist_goto_entry(playlist_t *pl, const char *entry)
|
|||||||
|
|
||||||
if (pl == NULL || entry == NULL) {
|
if (pl == NULL || entry == NULL) {
|
||||||
printf("%s: playlist_goto_entry(): Internal error: Bad arguments\n",
|
printf("%s: playlist_goto_entry(): Internal error: Bad arguments\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,7 +402,7 @@ playlist_rewind(playlist_t *pl)
|
|||||||
{
|
{
|
||||||
if (pl == NULL) {
|
if (pl == NULL) {
|
||||||
printf("%s: playlist_rewind(): Internal error: NULL argument\n",
|
printf("%s: playlist_rewind(): Internal error: NULL argument\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -420,7 +419,7 @@ playlist_reread(playlist_t **plist)
|
|||||||
|
|
||||||
if (plist == NULL || *plist == NULL) {
|
if (plist == NULL || *plist == NULL) {
|
||||||
printf("%s: playlist_reread(): Internal error: NULL argument\n",
|
printf("%s: playlist_reread(): Internal error: NULL argument\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -449,7 +448,7 @@ playlist_shuffle(playlist_t *pl)
|
|||||||
|
|
||||||
if (pl == NULL) {
|
if (pl == NULL) {
|
||||||
printf("%s: playlist_shuffle(): Internal error: NULL argument\n",
|
printf("%s: playlist_shuffle(): Internal error: NULL argument\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -487,7 +486,7 @@ playlist_run_program(playlist_t *pl)
|
|||||||
|
|
||||||
if (pl == NULL) {
|
if (pl == NULL) {
|
||||||
printf("%s: playlist_run_program(): Internal error: NULL argument\n",
|
printf("%s: playlist_run_program(): Internal error: NULL argument\n",
|
||||||
__progname);
|
cfg_progname());
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -498,7 +497,7 @@ playlist_run_program(playlist_t *pl)
|
|||||||
errno = 0;
|
errno = 0;
|
||||||
if ((filep = popen(pl->filename, "r")) == NULL) {
|
if ((filep = popen(pl->filename, "r")) == NULL) {
|
||||||
printf("%s: playlist_run_program(): Error while executing '%s'",
|
printf("%s: playlist_run_program(): Error while executing '%s'",
|
||||||
__progname, pl->filename);
|
cfg_progname(), pl->filename);
|
||||||
/* popen() does not set errno reliably ... */
|
/* popen() does not set errno reliably ... */
|
||||||
if (errno)
|
if (errno)
|
||||||
printf(": %s\n", strerror(errno));
|
printf(": %s\n", strerror(errno));
|
||||||
@ -514,7 +513,7 @@ playlist_run_program(playlist_t *pl)
|
|||||||
|
|
||||||
if (ferror(filep)) {
|
if (ferror(filep)) {
|
||||||
printf("%s: Error while reading output from program '%s': %s\n",
|
printf("%s: Error while reading output from program '%s': %s\n",
|
||||||
__progname, pl->filename, strerror(errnum));
|
cfg_progname(), pl->filename, strerror(errnum));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -525,7 +524,7 @@ playlist_run_program(playlist_t *pl)
|
|||||||
pclose(filep);
|
pclose(filep);
|
||||||
|
|
||||||
if (strlen(buf) == sizeof(buf) - 1) {
|
if (strlen(buf) == sizeof(buf) - 1) {
|
||||||
printf("%s: Output from program '%s' too long\n", __progname,
|
printf("%s: Output from program '%s' too long\n", cfg_progname(),
|
||||||
pl->filename);
|
pl->filename);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
43
src/util.c
43
src/util.c
@ -45,7 +45,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern EZCONFIG *pezConfig;
|
extern EZCONFIG *pezConfig;
|
||||||
extern char *__progname;
|
|
||||||
|
|
||||||
char * iconvert(const char *, const char *, const char *, int);
|
char * iconvert(const char *, const char *, const char *, int);
|
||||||
|
|
||||||
@ -89,42 +88,42 @@ stream_setup(const char *host, unsigned short port, const char *mount)
|
|||||||
shout_t *shout = NULL;
|
shout_t *shout = NULL;
|
||||||
|
|
||||||
if ((shout = shout_new()) == NULL) {
|
if ((shout = shout_new()) == NULL) {
|
||||||
printf("%s: shout_new(): %s", __progname, strerror(ENOMEM));
|
printf("%s: shout_new(): %s", cfg_progname(), strerror(ENOMEM));
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shout_set_host(shout, host) != SHOUTERR_SUCCESS) {
|
if (shout_set_host(shout, host) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_host(): %s\n", __progname,
|
printf("%s: shout_set_host(): %s\n", cfg_progname(),
|
||||||
shout_get_error(shout));
|
shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (shout_set_protocol(shout, SHOUT_PROTOCOL_HTTP) != SHOUTERR_SUCCESS) {
|
if (shout_set_protocol(shout, SHOUT_PROTOCOL_HTTP) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_protocol(): %s\n", __progname,
|
printf("%s: shout_set_protocol(): %s\n", cfg_progname(),
|
||||||
shout_get_error(shout));
|
shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (shout_set_port(shout, port) != SHOUTERR_SUCCESS) {
|
if (shout_set_port(shout, port) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_port: %s\n", __progname,
|
printf("%s: shout_set_port: %s\n", cfg_progname(),
|
||||||
shout_get_error(shout));
|
shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (shout_set_password(shout, pezConfig->password) != SHOUTERR_SUCCESS) {
|
if (shout_set_password(shout, pezConfig->password) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_password(): %s\n", __progname,
|
printf("%s: shout_set_password(): %s\n", cfg_progname(),
|
||||||
shout_get_error(shout));
|
shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (shout_set_mount(shout, mount) != SHOUTERR_SUCCESS) {
|
if (shout_set_mount(shout, mount) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_mount(): %s\n", __progname,
|
printf("%s: shout_set_mount(): %s\n", cfg_progname(),
|
||||||
shout_get_error(shout));
|
shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (shout_set_user(shout, "source") != SHOUTERR_SUCCESS) {
|
if (shout_set_user(shout, "source") != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_user(): %s\n", __progname,
|
printf("%s: shout_set_user(): %s\n", cfg_progname(),
|
||||||
shout_get_error(shout));
|
shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
@ -133,7 +132,7 @@ stream_setup(const char *host, unsigned short port, const char *mount)
|
|||||||
if (!strcmp(pezConfig->format, MP3_FORMAT) &&
|
if (!strcmp(pezConfig->format, MP3_FORMAT) &&
|
||||||
shout_set_format(shout, SHOUT_FORMAT_MP3) != SHOUTERR_SUCCESS) {
|
shout_set_format(shout, SHOUT_FORMAT_MP3) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_format(MP3): %s\n",
|
printf("%s: shout_set_format(MP3): %s\n",
|
||||||
__progname, shout_get_error(shout));
|
cfg_progname(), shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
@ -141,7 +140,7 @@ stream_setup(const char *host, unsigned short port, const char *mount)
|
|||||||
!strcmp(pezConfig->format, THEORA_FORMAT)) &&
|
!strcmp(pezConfig->format, THEORA_FORMAT)) &&
|
||||||
shout_set_format(shout, SHOUT_FORMAT_OGG) != SHOUTERR_SUCCESS) {
|
shout_set_format(shout, SHOUT_FORMAT_OGG) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_format(OGG): %s\n",
|
printf("%s: shout_set_format(OGG): %s\n",
|
||||||
__progname, shout_get_error(shout));
|
cfg_progname(), shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
@ -149,70 +148,70 @@ stream_setup(const char *host, unsigned short port, const char *mount)
|
|||||||
if (pezConfig->username &&
|
if (pezConfig->username &&
|
||||||
shout_set_user(shout, pezConfig->username) != SHOUTERR_SUCCESS) {
|
shout_set_user(shout, pezConfig->username) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_user(): %s\n",
|
printf("%s: shout_set_user(): %s\n",
|
||||||
__progname, shout_get_error(shout));
|
cfg_progname(), shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (pezConfig->serverName &&
|
if (pezConfig->serverName &&
|
||||||
shout_set_name(shout, pezConfig->serverName) != SHOUTERR_SUCCESS) {
|
shout_set_name(shout, pezConfig->serverName) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_name(): %s\n",
|
printf("%s: shout_set_name(): %s\n",
|
||||||
__progname, shout_get_error(shout));
|
cfg_progname(), shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (pezConfig->serverURL &&
|
if (pezConfig->serverURL &&
|
||||||
shout_set_url(shout, pezConfig->serverURL) != SHOUTERR_SUCCESS) {
|
shout_set_url(shout, pezConfig->serverURL) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_url(): %s\n",
|
printf("%s: shout_set_url(): %s\n",
|
||||||
__progname, shout_get_error(shout));
|
cfg_progname(), shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (pezConfig->serverGenre &&
|
if (pezConfig->serverGenre &&
|
||||||
shout_set_genre(shout, pezConfig->serverGenre) != SHOUTERR_SUCCESS) {
|
shout_set_genre(shout, pezConfig->serverGenre) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_genre(): %s\n",
|
printf("%s: shout_set_genre(): %s\n",
|
||||||
__progname, shout_get_error(shout));
|
cfg_progname(), shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (pezConfig->serverDescription &&
|
if (pezConfig->serverDescription &&
|
||||||
shout_set_description(shout, pezConfig->serverDescription) != SHOUTERR_SUCCESS) {
|
shout_set_description(shout, pezConfig->serverDescription) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_description(): %s\n",
|
printf("%s: shout_set_description(): %s\n",
|
||||||
__progname, shout_get_error(shout));
|
cfg_progname(), shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (pezConfig->serverBitrate &&
|
if (pezConfig->serverBitrate &&
|
||||||
shout_set_audio_info(shout, SHOUT_AI_BITRATE, pezConfig->serverBitrate) != SHOUTERR_SUCCESS) {
|
shout_set_audio_info(shout, SHOUT_AI_BITRATE, pezConfig->serverBitrate) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_audio_info(AI_BITRATE): %s\n",
|
printf("%s: shout_set_audio_info(AI_BITRATE): %s\n",
|
||||||
__progname, shout_get_error(shout));
|
cfg_progname(), shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (pezConfig->serverChannels &&
|
if (pezConfig->serverChannels &&
|
||||||
shout_set_audio_info(shout, SHOUT_AI_CHANNELS, pezConfig->serverChannels) != SHOUTERR_SUCCESS) {
|
shout_set_audio_info(shout, SHOUT_AI_CHANNELS, pezConfig->serverChannels) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_audio_info(AI_CHANNELS): %s\n",
|
printf("%s: shout_set_audio_info(AI_CHANNELS): %s\n",
|
||||||
__progname, shout_get_error(shout));
|
cfg_progname(), shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (pezConfig->serverSamplerate &&
|
if (pezConfig->serverSamplerate &&
|
||||||
shout_set_audio_info(shout, SHOUT_AI_SAMPLERATE, pezConfig->serverSamplerate) != SHOUTERR_SUCCESS) {
|
shout_set_audio_info(shout, SHOUT_AI_SAMPLERATE, pezConfig->serverSamplerate) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_audio_info(AI_SAMPLERATE): %s\n",
|
printf("%s: shout_set_audio_info(AI_SAMPLERATE): %s\n",
|
||||||
__progname, shout_get_error(shout));
|
cfg_progname(), shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (pezConfig->serverQuality &&
|
if (pezConfig->serverQuality &&
|
||||||
shout_set_audio_info(shout, SHOUT_AI_QUALITY, pezConfig->serverQuality) != SHOUTERR_SUCCESS) {
|
shout_set_audio_info(shout, SHOUT_AI_QUALITY, pezConfig->serverQuality) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_audio_info(AI_QUALITY): %s\n",
|
printf("%s: shout_set_audio_info(AI_QUALITY): %s\n",
|
||||||
__progname, shout_get_error(shout));
|
cfg_progname(), shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shout_set_public(shout, (unsigned int)pezConfig->serverPublic) != SHOUTERR_SUCCESS) {
|
if (shout_set_public(shout, (unsigned int)pezConfig->serverPublic) != SHOUTERR_SUCCESS) {
|
||||||
printf("%s: shout_set_public(): %s\n",
|
printf("%s: shout_set_public(): %s\n",
|
||||||
__progname, shout_get_error(shout));
|
cfg_progname(), shout_get_error(shout));
|
||||||
shout_free(shout);
|
shout_free(shout);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
@ -293,7 +292,7 @@ iconvert(const char *in_str, const char *from, const char *to, int mode)
|
|||||||
(cd = iconv_open("", from)) == (iconv_t)-1 &&
|
(cd = iconv_open("", from)) == (iconv_t)-1 &&
|
||||||
(cd = iconv_open(tocode, "")) == (iconv_t)-1) {
|
(cd = iconv_open(tocode, "")) == (iconv_t)-1) {
|
||||||
xfree(tocode);
|
xfree(tocode);
|
||||||
printf("%s: iconv_open(): %s\n", __progname, strerror(errno));
|
printf("%s: iconv_open(): %s\n", cfg_progname(), strerror(errno));
|
||||||
return (xstrdup(in_str));
|
return (xstrdup(in_str));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,7 +331,7 @@ iconvert(const char *in_str, const char *from, const char *to, int mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (iconv_close(cd) == -1) {
|
if (iconv_close(cd) == -1) {
|
||||||
printf("%s: iconv_close(): %s\n", __progname, strerror(errno));
|
printf("%s: iconv_close(): %s\n", cfg_progname(), strerror(errno));
|
||||||
xfree(output);
|
xfree(output);
|
||||||
xfree(tocode);
|
xfree(tocode);
|
||||||
return (xstrdup(in_str));
|
return (xstrdup(in_str));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user