2007-02-24 19:25:07 -05:00
|
|
|
/*
|
|
|
|
* ezstream - source client for Icecast with external en-/decoder support
|
|
|
|
* Copyright (C) 2003, 2004, 2005, 2006 Ed Zaleski <oddsock@oddsock.org>
|
|
|
|
* Copyright (C) 2007 Moritz Grimm <gtgbr@gmx.net>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2004-01-30 12:19:45 -05:00
|
|
|
|
2007-02-24 19:25:07 -05:00
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
|
|
# include <sys/types.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_TIME_H
|
|
|
|
# include <sys/time.h>
|
|
|
|
#endif
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#ifdef HAVE_PATHS_H
|
|
|
|
# include <paths.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SIGNAL_H
|
|
|
|
# include <signal.h>
|
|
|
|
#endif
|
2004-01-30 12:19:45 -05:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2007-02-24 19:25:07 -05:00
|
|
|
#include <limits.h>
|
2004-02-01 23:37:42 -05:00
|
|
|
#ifdef WIN32
|
2007-02-24 19:25:07 -05:00
|
|
|
# include <io.h>
|
|
|
|
# include <windows.h>
|
|
|
|
#else
|
|
|
|
# include <libgen.h>
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif /* WIN32 */
|
2004-01-30 12:19:45 -05:00
|
|
|
#include <shout/shout.h>
|
2007-02-24 19:25:07 -05:00
|
|
|
#include <vorbis/vorbisfile.h>
|
|
|
|
|
|
|
|
#ifndef HAVE_GETOPT
|
|
|
|
# include "getopt.h"
|
|
|
|
#endif
|
|
|
|
#if !defined(HAVE_STRLCAT) || !defined(HAVE_STRLCPY)
|
|
|
|
# include "strlfctns.h"
|
|
|
|
#endif
|
2004-01-30 12:19:45 -05:00
|
|
|
#include "configfile.h"
|
2007-02-24 19:25:07 -05:00
|
|
|
#include "playlist.h"
|
|
|
|
#include "util.h"
|
|
|
|
|
|
|
|
#ifndef PATH_MAX
|
|
|
|
# define PATH_MAX 256
|
2004-07-18 23:12:31 -04:00
|
|
|
#endif
|
2007-02-24 19:25:07 -05:00
|
|
|
|
|
|
|
/* For Solaris, possibly others (usually defined in <paths.h>.) */
|
|
|
|
#ifndef _PATH_DEVNULL
|
|
|
|
# define _PATH_DEVNULL "/dev/null"
|
|
|
|
#endif /* _PATH_DEVNULL */
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
# define STRNCASECMP strnicmp
|
|
|
|
# define popen _popen
|
|
|
|
# define pclose _pclose
|
|
|
|
# define snprintf _snprintf
|
|
|
|
# define stat _stat
|
|
|
|
#else
|
|
|
|
# define STRNCASECMP strncasecmp
|
|
|
|
#endif /* WIN32 */
|
|
|
|
|
|
|
|
#ifdef HAVE___PROGNAME
|
|
|
|
extern char *__progname;
|
|
|
|
#else
|
|
|
|
char *__progname;
|
|
|
|
#endif /* HAVE___PROGNAME */
|
|
|
|
|
|
|
|
int qFlag;
|
|
|
|
int vFlag;
|
2004-01-30 12:19:45 -05:00
|
|
|
|
|
|
|
EZCONFIG *pezConfig = NULL;
|
2004-07-18 23:12:31 -04:00
|
|
|
static char *blankString = "";
|
2007-02-24 19:25:07 -05:00
|
|
|
playlist_t *playlist = NULL;
|
|
|
|
int playlistMode = 0;
|
2004-04-21 09:48:22 -04:00
|
|
|
|
2007-02-24 19:25:07 -05:00
|
|
|
#ifdef HAVE_SIGNALS
|
|
|
|
volatile sig_atomic_t rereadPlaylist = 0;
|
|
|
|
volatile sig_atomic_t rereadPlaylist_notify = 0;
|
|
|
|
volatile sig_atomic_t skipTrack = 0;
|
2004-04-21 09:48:22 -04:00
|
|
|
|
2007-02-24 19:25:07 -05:00
|
|
|
void
|
|
|
|
sig_handler(int sig)
|
2004-04-21 09:48:22 -04:00
|
|
|
{
|
2007-02-24 19:25:07 -05:00
|
|
|
switch (sig) {
|
|
|
|
case SIGHUP:
|
|
|
|
rereadPlaylist = 1;
|
|
|
|
rereadPlaylist_notify = 1;
|
|
|
|
break;
|
|
|
|
case SIGUSR1:
|
|
|
|
skipTrack = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2004-04-21 09:48:22 -04:00
|
|
|
}
|
2004-07-18 23:12:31 -04:00
|
|
|
#else
|
2007-02-24 19:25:07 -05:00
|
|
|
int rereadPlaylist = 0;
|
|
|
|
int rereadPlaylist_notify = 0;
|
|
|
|
int skipTrack = 0;
|
|
|
|
#endif /* HAVE_SIGNALS */
|
2004-01-30 12:19:45 -05:00
|
|
|
|
|
|
|
typedef struct tag_ID3Tag {
|
|
|
|
char tag[3];
|
|
|
|
char trackName[30];
|
|
|
|
char artistName[30];
|
|
|
|
char albumName[30];
|
|
|
|
char year[3];
|
|
|
|
char comment[30];
|
|
|
|
char genre;
|
|
|
|
} ID3Tag;
|
|
|
|
|
2007-02-24 19:25:07 -05:00
|
|
|
#ifdef WIN32
|
|
|
|
char * basename(const char *);
|
|
|
|
#endif
|
|
|
|
int strrcmp(const char *, const char *);
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
int urlParse(const char *, char **, int *, char **);
|
2007-02-24 21:36:40 -05:00
|
|
|
void replaceString(const char *, char *, size_t, const char *, const char *);
|
|
|
|
void setMetadata(shout_t *, const char *);
|
|
|
|
char * buildCommandString(const char *, const char *, const char *);
|
2007-02-24 22:10:13 -05:00
|
|
|
char * processMetadata(shout_t *, const char *, const char *);
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
int streamPlaylist(shout_t *, const char *);
|
2007-02-24 19:25:07 -05:00
|
|
|
char * getProgname(const char *);
|
|
|
|
void usage(void);
|
|
|
|
void usageHelp(void);
|
2004-01-30 12:19:45 -05:00
|
|
|
|
2007-02-24 19:25:07 -05:00
|
|
|
#ifdef WIN32
|
|
|
|
char *
|
|
|
|
basename(const char *fileName)
|
2004-01-30 12:19:45 -05:00
|
|
|
{
|
2007-02-24 19:25:07 -05:00
|
|
|
char *pLast = strrchr(fileName, '\\');
|
2004-01-30 12:19:45 -05:00
|
|
|
|
2007-02-24 19:25:07 -05:00
|
|
|
if (pLast != NULL)
|
|
|
|
return (pLast + 1);
|
|
|
|
|
|
|
|
return (NULL);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
2007-02-24 19:25:07 -05:00
|
|
|
#endif /* WIN32 */
|
|
|
|
|
|
|
|
int
|
|
|
|
strrcmp(const char *s, const char *sub)
|
|
|
|
{
|
|
|
|
int slen = strlen(s);
|
|
|
|
int sublen = strlen(sub);
|
|
|
|
|
|
|
|
if (sublen > slen)
|
|
|
|
return (1);
|
2004-01-30 12:19:45 -05:00
|
|
|
|
2007-02-24 19:25:07 -05:00
|
|
|
return (memcmp(s + slen - sublen, sub, sublen));
|
|
|
|
}
|
2004-01-30 12:19:45 -05:00
|
|
|
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
int
|
|
|
|
urlParse(const char *url, char **hostname, int *port, char **mountname)
|
2004-01-30 12:19:45 -05:00
|
|
|
{
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
char *p1, *p2, *p3;
|
|
|
|
char tmpPort[25] = "";
|
|
|
|
size_t hostsiz, mountsiz;
|
2004-01-30 12:19:45 -05:00
|
|
|
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
if (hostname == NULL || port == NULL || mountname == NULL) {
|
|
|
|
printf("%s: urlParse(): Internal error: Bad arguments\n",
|
|
|
|
__progname);
|
|
|
|
exit(1);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
|
|
|
|
if (strncmp(url, "http://", strlen("http://")) != 0)
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
p1 = (char *)(url) + strlen("http://");
|
2004-01-30 12:19:45 -05:00
|
|
|
p2 = strchr(p1, ':');
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
if (p2 == NULL)
|
|
|
|
return (0);
|
|
|
|
hostsiz = (p2 - p1) + 1;
|
|
|
|
*hostname = xmalloc(hostsiz);
|
|
|
|
strlcpy(*hostname, p1, hostsiz);
|
|
|
|
|
2004-01-30 12:19:45 -05:00
|
|
|
p2++;
|
|
|
|
p3 = strchr(p2, '/');
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
if (p3 == NULL || p3 - p2 >= sizeof(tmpPort))
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
strlcpy(tmpPort, p2, (p3 - p2) + 1);
|
2004-01-30 12:19:45 -05:00
|
|
|
*port = atoi(tmpPort);
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
|
|
|
|
mountsiz = strlen(p3) + 1;
|
|
|
|
*mountname = xmalloc(mountsiz);
|
|
|
|
strlcpy(*mountname, p3, mountsiz);
|
|
|
|
|
|
|
|
return (1);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
|
|
|
|
2007-02-24 21:36:40 -05:00
|
|
|
void
|
|
|
|
replaceString(const char *source, char *dest, size_t size,
|
|
|
|
const char *from, const char *to)
|
2004-07-18 23:12:31 -04:00
|
|
|
{
|
2007-02-24 21:36:40 -05:00
|
|
|
char *p1 = (char *)source;
|
|
|
|
char *p2;
|
|
|
|
|
|
|
|
p2 = strstr(p1, from);
|
|
|
|
if (p2 != NULL) {
|
|
|
|
if (p2 - p1 >= size) {
|
|
|
|
printf("%s: replaceString(): Internal error: p2 - p1 >= size\n",
|
|
|
|
__progname);
|
|
|
|
abort();
|
2004-07-18 23:12:31 -04:00
|
|
|
}
|
2007-02-24 21:36:40 -05:00
|
|
|
strncat(dest, p1, p2 - p1);
|
|
|
|
strlcat(dest, to, size);
|
|
|
|
p1 = p2 + strlen(from);
|
2004-07-18 23:12:31 -04:00
|
|
|
}
|
2007-02-24 21:36:40 -05:00
|
|
|
strlcat(dest, p1, size);
|
2004-07-18 23:12:31 -04:00
|
|
|
}
|
|
|
|
|
2007-02-24 21:36:40 -05:00
|
|
|
void
|
|
|
|
setMetadata(shout_t *shout, const char *metadata)
|
2004-07-18 23:12:31 -04:00
|
|
|
{
|
|
|
|
shout_metadata_t *shoutMetadata = shout_metadata_new();
|
2007-02-24 21:36:40 -05:00
|
|
|
|
2004-07-18 23:12:31 -04:00
|
|
|
shout_metadata_add(shoutMetadata, "song", metadata);
|
|
|
|
shout_set_metadata(shout, shoutMetadata);
|
|
|
|
shout_metadata_free(shoutMetadata);
|
|
|
|
}
|
|
|
|
|
2007-02-24 21:36:40 -05:00
|
|
|
char*
|
|
|
|
buildCommandString(const char *extension, const char *fileName,
|
|
|
|
const char *metadata)
|
2004-07-18 23:12:31 -04:00
|
|
|
{
|
|
|
|
char *commandString = NULL;
|
2007-02-24 21:36:40 -05:00
|
|
|
size_t commandStringLen = 0;
|
|
|
|
char *encoder = NULL;
|
|
|
|
char *decoder = NULL;
|
|
|
|
char *newDecoder = NULL;
|
|
|
|
size_t newDecoderLen = 0;
|
|
|
|
char *newEncoder = NULL;
|
|
|
|
size_t newEncoderLen = 0;
|
|
|
|
|
|
|
|
decoder = xstrdup(getFormatDecoder(extension));
|
2004-07-18 23:12:31 -04:00
|
|
|
if (strlen(decoder) == 0) {
|
2007-02-24 21:36:40 -05:00
|
|
|
printf("%s: Unknown extension '%s', cannot decode '%s'.\n",
|
|
|
|
__progname, extension, fileName);
|
|
|
|
xfree(decoder);
|
|
|
|
return (NULL);
|
2004-07-18 23:12:31 -04:00
|
|
|
}
|
|
|
|
newDecoderLen = strlen(decoder) + strlen(fileName) + 1;
|
2007-02-24 21:36:40 -05:00
|
|
|
newDecoder = xcalloc(1, newDecoderLen);
|
|
|
|
replaceString(decoder, newDecoder, newDecoderLen, TRACK_PLACEHOLDER,
|
|
|
|
fileName);
|
|
|
|
if (strstr(decoder, METADATA_PLACEHOLDER) != NULL) {
|
|
|
|
size_t tmpLen = strlen(newDecoder) + strlen(metadata) + 1;
|
|
|
|
char *tmpStr = xcalloc(1, tmpLen);
|
|
|
|
replaceString(newDecoder, tmpStr, tmpLen, METADATA_PLACEHOLDER,
|
|
|
|
metadata);
|
|
|
|
xfree(newDecoder);
|
|
|
|
newDecoder = tmpStr;
|
|
|
|
}
|
2004-07-18 23:12:31 -04:00
|
|
|
|
2007-02-24 21:36:40 -05:00
|
|
|
encoder = xstrdup(getFormatEncoder(pezConfig->format));
|
2004-12-21 20:49:56 -05:00
|
|
|
if (strlen(encoder) == 0) {
|
2007-02-24 21:36:40 -05:00
|
|
|
if (vFlag)
|
|
|
|
printf("%s: Passing through%s%s data from the decoder\n",
|
|
|
|
__progname,
|
|
|
|
(strcmp(pezConfig->format, THEORA_FORMAT) != 0) ? " (unsupported) " : " ",
|
|
|
|
pezConfig->format);
|
2004-12-21 20:49:56 -05:00
|
|
|
commandStringLen = strlen(newDecoder) + 1;
|
2007-02-24 21:36:40 -05:00
|
|
|
commandString = xcalloc(1, commandStringLen);
|
|
|
|
strlcpy(commandString, newDecoder, commandStringLen);
|
|
|
|
xfree(decoder);
|
|
|
|
xfree(encoder);
|
|
|
|
xfree(newDecoder);
|
|
|
|
return (commandString);
|
2004-12-21 20:49:56 -05:00
|
|
|
}
|
|
|
|
|
2007-02-24 21:36:40 -05:00
|
|
|
newEncoderLen = strlen(encoder) + strlen(metadata) + 1;
|
|
|
|
newEncoder = xcalloc(1, newEncoderLen);
|
|
|
|
replaceString(encoder, newEncoder, newEncoderLen, METADATA_PLACEHOLDER,
|
|
|
|
metadata);
|
2004-07-18 23:12:31 -04:00
|
|
|
|
2007-02-24 21:36:40 -05:00
|
|
|
commandStringLen = strlen(newDecoder) + strlen(" | ") +
|
|
|
|
strlen(newEncoder) + 1;
|
|
|
|
commandString = xcalloc(1, commandStringLen);
|
|
|
|
snprintf(commandString, commandStringLen, "%s | %s", newDecoder,
|
|
|
|
newEncoder);
|
|
|
|
|
|
|
|
xfree(decoder);
|
|
|
|
xfree(encoder);
|
|
|
|
xfree(newDecoder);
|
|
|
|
xfree(newEncoder);
|
|
|
|
|
|
|
|
return (commandString);
|
2004-07-18 23:12:31 -04:00
|
|
|
}
|
2005-12-14 16:13:25 -05:00
|
|
|
|
2007-02-24 22:10:13 -05:00
|
|
|
char *
|
|
|
|
processMetadata(shout_t *shout, const char *extension, const char *fileName)
|
|
|
|
{
|
|
|
|
FILE *filepstream = NULL;
|
|
|
|
char *songInfo = NULL;
|
|
|
|
size_t songLen = 0;
|
|
|
|
ID3Tag id3tag;
|
|
|
|
shout_metadata_t *pmetadata = NULL;
|
|
|
|
|
|
|
|
if ((filepstream = fopen(fileName, "rb")) == NULL) {
|
|
|
|
printf("%s: processMetadata(): %s: %s\n",
|
|
|
|
__progname, fileName, strerror(errno));
|
|
|
|
return (xstrdup(blankString));
|
2004-07-18 23:12:31 -04:00
|
|
|
}
|
|
|
|
|
2007-02-24 22:10:13 -05:00
|
|
|
if (strcmp(extension, ".mp3") == 0) {
|
2004-07-18 23:12:31 -04:00
|
|
|
/* Look for the ID3 tag */
|
2007-02-24 22:10:13 -05:00
|
|
|
memset(&id3tag, '\000', sizeof(id3tag));
|
|
|
|
fseek(filepstream, -128L, SEEK_END);
|
|
|
|
fread(&id3tag, 1, 127, filepstream);
|
|
|
|
if (strncmp(id3tag.tag, "TAG", strlen("TAG")) == 0) {
|
|
|
|
char tempTrackName[31];
|
|
|
|
char tempArtistName[31];
|
|
|
|
|
|
|
|
snprintf(tempTrackName, sizeof(tempTrackName), "%s",
|
|
|
|
id3tag.trackName);
|
|
|
|
snprintf(tempArtistName, sizeof(tempArtistName), "%s",
|
|
|
|
id3tag.artistName);
|
|
|
|
|
|
|
|
if (strlen(tempTrackName) > 0 ||
|
|
|
|
strlen(tempArtistName) > 0) {
|
|
|
|
songLen = strlen(tempArtistName) +
|
|
|
|
strlen(" - ") + strlen(tempTrackName)
|
|
|
|
+ 1;
|
|
|
|
songInfo = xmalloc(songLen);
|
|
|
|
strlcpy(songInfo, tempArtistName, songLen);
|
|
|
|
if (strlen(songInfo) > 0 &&
|
|
|
|
strlen(tempTrackName) > 0)
|
|
|
|
strlcat(songInfo, " - ", songLen);
|
|
|
|
strlcat(songInfo, tempTrackName, songLen);
|
2004-07-18 23:12:31 -04:00
|
|
|
}
|
|
|
|
}
|
2007-02-24 22:10:13 -05:00
|
|
|
} else if (strcmp(extension, ".ogg") == 0) {
|
|
|
|
OggVorbis_File vf;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if ((ret = ov_open(filepstream, &vf, NULL, 0)) != 0) {
|
|
|
|
switch (ret) {
|
|
|
|
case OV_EREAD:
|
|
|
|
printf("%s: No metadata support: %s: Media read error.\n",
|
|
|
|
__progname, fileName);
|
|
|
|
break;
|
|
|
|
case OV_ENOTVORBIS:
|
|
|
|
printf("%s: No metadata support: %s: Invalid Vorbis bitstream.\n",
|
|
|
|
__progname, fileName);
|
|
|
|
break;
|
|
|
|
case OV_EVERSION:
|
|
|
|
printf("%s: No metadata support: %s: Vorbis version mismatch.\n",
|
|
|
|
__progname, fileName);
|
|
|
|
break;
|
|
|
|
case OV_EBADHEADER:
|
|
|
|
printf("%s: No metadata support: %s: Invalid Vorbis bitstream header.\n",
|
|
|
|
__progname, fileName);
|
|
|
|
break;
|
|
|
|
case OV_EFAULT:
|
|
|
|
printf("%s: Fatal: Internal libvorbisfile fault.\n",
|
|
|
|
__progname);
|
|
|
|
abort();
|
|
|
|
default:
|
|
|
|
printf("%s: No metadata support: %s: ov_read() returned unknown error.\n",
|
|
|
|
__progname, fileName);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
char **ptr = ov_comment(&vf, -1)->user_comments;
|
|
|
|
char *artist = NULL;
|
|
|
|
char *title = NULL;
|
|
|
|
|
2004-07-18 23:12:31 -04:00
|
|
|
while(*ptr){
|
2007-02-24 22:10:13 -05:00
|
|
|
if (artist == NULL &&
|
|
|
|
STRNCASECMP(*ptr, "ARTIST", strlen("ARTIST")) == 0)
|
|
|
|
artist = xstrdup(*ptr + strlen("ARTIST="));
|
|
|
|
if (title == NULL &&
|
|
|
|
STRNCASECMP(*ptr, "TITLE", strlen("TITLE")) == 0)
|
|
|
|
title = xstrdup(*ptr + strlen("TITLE="));
|
2004-07-18 23:12:31 -04:00
|
|
|
++ptr;
|
|
|
|
}
|
2007-02-24 22:10:13 -05:00
|
|
|
|
|
|
|
if (artist != NULL || title != NULL) {
|
|
|
|
songLen = 0;
|
|
|
|
if (artist != NULL)
|
|
|
|
songLen += strlen(artist);
|
|
|
|
if (title != NULL)
|
|
|
|
songLen += strlen(title);
|
|
|
|
songLen += strlen(" - ") + 1;
|
|
|
|
songInfo = xcalloc(1, songLen);
|
|
|
|
|
|
|
|
if (artist != NULL)
|
|
|
|
strlcpy(songInfo, artist, songLen);
|
|
|
|
if (title != NULL) {
|
|
|
|
if (artist != NULL)
|
|
|
|
strlcat(songInfo, " - ", songLen);
|
|
|
|
strlcat(songInfo, title, songLen);
|
|
|
|
xfree(title);
|
|
|
|
}
|
|
|
|
if (artist != NULL)
|
|
|
|
xfree(artist);
|
2004-07-18 23:12:31 -04:00
|
|
|
}
|
2007-02-24 22:10:13 -05:00
|
|
|
|
2004-07-18 23:12:31 -04:00
|
|
|
ov_clear(&vf);
|
|
|
|
filepstream = NULL;
|
|
|
|
}
|
|
|
|
}
|
2007-02-24 22:10:13 -05:00
|
|
|
|
|
|
|
if (filepstream != NULL)
|
|
|
|
fclose(filepstream);
|
|
|
|
|
|
|
|
if (songInfo == NULL) {
|
|
|
|
/*
|
|
|
|
* If we didn't get any song info via tags or comments, then
|
|
|
|
* let's just use the filename.
|
|
|
|
*/
|
|
|
|
char *p1 = NULL;
|
|
|
|
char *p2 = NULL;;
|
|
|
|
char *filename_copy = NULL;
|
|
|
|
|
|
|
|
filename_copy = xstrdup(fileName);
|
|
|
|
p2 = basename(filename_copy);
|
|
|
|
if (p2 == NULL) {
|
|
|
|
/* Assert that basename() cannot fail. */
|
|
|
|
printf("%s: Internal error: basename() failed with '%s'\n",
|
|
|
|
__progname, filename_copy);
|
|
|
|
exit(1);
|
2004-07-18 23:12:31 -04:00
|
|
|
}
|
2007-02-24 22:10:13 -05:00
|
|
|
songInfo = xstrdup(p2);
|
|
|
|
xfree(filename_copy);
|
|
|
|
p1 = strrchr(songInfo, '.');
|
|
|
|
if (p1 != NULL)
|
|
|
|
*p1 = '\000';
|
2004-07-18 23:12:31 -04:00
|
|
|
}
|
|
|
|
|
2007-02-24 22:10:13 -05:00
|
|
|
if ((pmetadata = shout_metadata_new()) == NULL) {
|
|
|
|
printf("%s: shout_metadata_new(): %s\n", __progname,
|
|
|
|
strerror(ENOMEM));
|
|
|
|
exit(1);
|
2004-07-18 23:12:31 -04:00
|
|
|
}
|
2007-02-24 22:10:13 -05:00
|
|
|
shout_metadata_add(pmetadata, "song", songInfo);
|
|
|
|
shout_set_metadata(shout, pmetadata);
|
|
|
|
shout_metadata_free(pmetadata);
|
|
|
|
|
|
|
|
return (songInfo);
|
2004-07-18 23:12:31 -04:00
|
|
|
}
|
|
|
|
|
2005-12-14 16:13:25 -05:00
|
|
|
FILE *openResource(shout_t *shout, char *fileName, int *popenFlag)
|
2004-07-18 23:12:31 -04:00
|
|
|
{
|
|
|
|
FILE *filep = NULL;
|
2005-12-14 16:13:25 -05:00
|
|
|
|
|
|
|
printf("Opening file (%s)\n", fileName);
|
2004-07-18 23:12:31 -04:00
|
|
|
if (!strcmp(fileName, "stdin")) {
|
2004-02-01 23:37:42 -05:00
|
|
|
#ifdef WIN32
|
|
|
|
_setmode(_fileno(stdin), _O_BINARY);
|
|
|
|
#endif
|
2004-07-18 23:12:31 -04:00
|
|
|
filep = stdin;
|
2004-12-21 20:49:56 -05:00
|
|
|
return filep;
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
|
|
|
else {
|
2004-07-18 23:12:31 -04:00
|
|
|
char extension[25];
|
|
|
|
char *p1 = NULL;
|
|
|
|
char *pMetadata = NULL;
|
|
|
|
char *pCommandString = NULL;
|
|
|
|
memset(extension, '\000', sizeof(extension));
|
|
|
|
p1 = strrchr(fileName, '.');
|
|
|
|
if (p1) {
|
|
|
|
strncpy(extension, p1, sizeof(extension)-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
pMetadata = processMetadata(shout, extension, fileName);
|
2005-12-14 16:13:25 -05:00
|
|
|
*popenFlag = 0;
|
2004-07-18 23:12:31 -04:00
|
|
|
if (pezConfig->reencode) {
|
|
|
|
/* Lets set the metadata first */
|
|
|
|
if (strlen(extension) > 0) {
|
|
|
|
pCommandString = buildCommandString(extension, fileName, pMetadata);
|
|
|
|
/* Open up the decode/encode loop using popen() */
|
2005-12-14 16:13:25 -05:00
|
|
|
filep = popen(pCommandString, "r");
|
|
|
|
*popenFlag = 1;
|
|
|
|
#ifdef WIN32
|
|
|
|
_setmode(_fileno(filep), _O_BINARY );
|
|
|
|
#endif
|
2004-07-18 23:12:31 -04:00
|
|
|
free(pMetadata);
|
|
|
|
free(pCommandString);
|
|
|
|
return filep;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("Cannot determine extension, don't know how to deal with (%s)\n", fileName);
|
|
|
|
free(pMetadata);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
free(pMetadata);
|
|
|
|
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
filep = fopen(fileName, "rb");
|
|
|
|
return filep;
|
|
|
|
}
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
2004-07-18 23:12:31 -04:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int streamFile(shout_t *shout, char *fileName) {
|
|
|
|
FILE *filepstream = NULL;
|
|
|
|
char buff[4096];
|
2005-12-14 16:13:25 -05:00
|
|
|
long read, ret = 0, total;
|
|
|
|
int popenFlag = 0;
|
2004-07-18 23:12:31 -04:00
|
|
|
|
|
|
|
|
|
|
|
printf("Streaming %s\n", fileName);
|
|
|
|
|
2005-12-14 16:13:25 -05:00
|
|
|
filepstream = openResource(shout, fileName, &popenFlag);
|
2004-01-30 12:19:45 -05:00
|
|
|
if (!filepstream) {
|
|
|
|
printf("Cannot open %s\n", fileName);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
total = 0;
|
|
|
|
while (!feof(filepstream)) {
|
|
|
|
read = fread(buff, 1, sizeof(buff), filepstream);
|
|
|
|
total = total + read;
|
|
|
|
|
|
|
|
if (read > 0) {
|
|
|
|
ret = shout_send(shout, buff, read);
|
2005-12-14 16:13:25 -05:00
|
|
|
if (ret != SHOUTERR_SUCCESS) {
|
2005-01-04 19:38:09 -05:00
|
|
|
int loop = 1;
|
2005-12-14 16:13:25 -05:00
|
|
|
printf("DEBUG: Send error: %s\n", shout_get_error(shout));
|
|
|
|
|
|
|
|
while (loop) {
|
|
|
|
printf("Disconnected from server, reconnecting....\n");
|
|
|
|
shout_close(shout);
|
|
|
|
if (shout_open(shout) == SHOUTERR_SUCCESS) {
|
|
|
|
printf("Successful reconnection....\n");
|
|
|
|
ret = shout_send(shout, buff, read);
|
|
|
|
loop = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("Reconnect failed..waiting 5 seconds.\n");
|
|
|
|
#ifdef WIN32
|
|
|
|
Sleep(5000);
|
|
|
|
#else
|
|
|
|
sleep(5);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
|
|
|
shout_delay(shout);
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
shout_sync(shout);
|
|
|
|
}
|
2005-12-14 16:13:25 -05:00
|
|
|
if (popenFlag) {
|
|
|
|
printf("Closing via pclose\n");
|
|
|
|
pclose(filepstream);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fclose(filepstream);
|
|
|
|
}
|
2004-01-30 12:19:45 -05:00
|
|
|
filepstream = NULL;
|
2005-01-04 19:38:09 -05:00
|
|
|
return ret;
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
2007-02-24 19:25:07 -05:00
|
|
|
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
int
|
|
|
|
streamPlaylist(shout_t *shout, const char *fileName)
|
|
|
|
{
|
|
|
|
const char *song;
|
|
|
|
char lastSong[PATH_MAX + 1];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX: This preserves traditional behavior, however, rereading the
|
|
|
|
* playlist after each walkthrough seems a bit more logical.
|
|
|
|
*/
|
|
|
|
if (playlist == NULL) {
|
|
|
|
if ((playlist = playlist_read(fileName)) == NULL)
|
|
|
|
return (0);
|
|
|
|
} else
|
|
|
|
playlist_rewind(playlist);
|
|
|
|
|
|
|
|
if (pezConfig->shuffle)
|
|
|
|
playlist_shuffle(playlist);
|
|
|
|
|
|
|
|
while ((song = playlist_get_next(playlist)) != NULL) {
|
|
|
|
strlcpy(lastSong, song, sizeof(lastSong));
|
|
|
|
if (!streamFile(shout, song))
|
|
|
|
return (0);
|
|
|
|
if (rereadPlaylist) {
|
|
|
|
rereadPlaylist = rereadPlaylist_notify = 0;
|
|
|
|
printf("%s: Rereading playlist\n", __progname);
|
|
|
|
if (!playlist_reread(&playlist))
|
|
|
|
return (0);
|
|
|
|
if (pezConfig->shuffle)
|
|
|
|
playlist_shuffle(playlist);
|
|
|
|
else {
|
|
|
|
playlist_goto_entry(playlist, lastSong);
|
|
|
|
playlist_skip_next(playlist);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
continue;
|
2004-07-18 23:12:31 -04:00
|
|
|
}
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
|
|
|
|
return (1);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
|
|
|
|
2007-02-24 19:25:07 -05:00
|
|
|
/* Borrowed from OpenNTPd-portable's compat-openbsd/bsd-misc.c */
|
|
|
|
char *
|
|
|
|
getProgname(const char *argv0)
|
|
|
|
{
|
|
|
|
#ifdef HAVE___PROGNAME
|
|
|
|
return (xstrdup(__progname));
|
|
|
|
#else
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
if (argv0 == NULL)
|
|
|
|
return ((char *)"ezstream");
|
|
|
|
p = strrchr(argv0, '/');
|
|
|
|
if (p == NULL)
|
|
|
|
p = argv0;
|
|
|
|
else
|
|
|
|
p++;
|
|
|
|
|
|
|
|
return (xstrdup(p));
|
|
|
|
#endif /* HAVE___PROGNAME */
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
usage(void)
|
|
|
|
{
|
|
|
|
printf("usage: %s [-hqv] [-c configfile]\n", __progname);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
usageHelp(void)
|
|
|
|
{
|
|
|
|
printf("\n");
|
|
|
|
printf(" -c configfile use XML configuration in configfile\n");
|
|
|
|
printf(" -h display this additional help and exit\n");
|
|
|
|
printf(" -q suppress STDERR output from external en-/decoders\n");
|
|
|
|
printf(" -v verbose output\n");
|
|
|
|
printf("\n");
|
|
|
|
printf("See the ezstream(1) manual for detailed information.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
main(int argc, char *argv[])
|
2004-01-30 12:19:45 -05:00
|
|
|
{
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
char c;
|
|
|
|
char *configFile = NULL;
|
|
|
|
char *host = NULL;
|
|
|
|
int port = 0;
|
|
|
|
char *mount = NULL;
|
|
|
|
shout_t *shout;
|
|
|
|
extern char *optarg;
|
|
|
|
extern int optind;
|
|
|
|
|
|
|
|
__progname = getProgname(argv[0]);
|
|
|
|
pezConfig = getEZConfig();
|
2004-01-30 12:19:45 -05:00
|
|
|
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
qFlag = 0;
|
|
|
|
vFlag = 0;
|
2004-01-30 12:19:45 -05:00
|
|
|
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
#ifdef HAVE_GETEUID
|
|
|
|
if (geteuid() == 0) {
|
|
|
|
printf("WARNING: You should not run %s as root. It can run other programs, which\n",
|
|
|
|
__progname);
|
|
|
|
printf(" may cause serious security problems.\n");
|
|
|
|
}
|
2004-04-21 09:48:22 -04:00
|
|
|
#endif
|
2004-01-30 12:19:45 -05:00
|
|
|
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
while ((c = getopt(argc, argv, "c:hqv")) != -1) {
|
2004-01-30 12:19:45 -05:00
|
|
|
switch (c) {
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
case 'c':
|
|
|
|
if (configFile != NULL) {
|
|
|
|
printf("Error: multiple -c arguments given.\n");
|
2004-01-30 12:19:45 -05:00
|
|
|
usage();
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
return (2);
|
|
|
|
}
|
|
|
|
configFile = xstrdup(optarg);
|
|
|
|
break;
|
|
|
|
case 'h':
|
|
|
|
usage();
|
|
|
|
usageHelp();
|
|
|
|
return (0);
|
|
|
|
case 'q':
|
|
|
|
qFlag = 1;
|
|
|
|
break;
|
|
|
|
case 'v':
|
|
|
|
vFlag++;
|
|
|
|
break;
|
|
|
|
case '?':
|
|
|
|
usage();
|
|
|
|
return (2);
|
|
|
|
default:
|
|
|
|
break;
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
|
|
|
}
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
argc -= optind;
|
|
|
|
argv += optind;
|
2004-01-30 12:19:45 -05:00
|
|
|
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
if (configFile == NULL) {
|
|
|
|
printf("You must supply a config file with the -c argument.\n");
|
2004-01-30 12:19:45 -05:00
|
|
|
usage();
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
return (2);
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Attempt to open configFile here for a more meaningful error
|
|
|
|
* message.
|
|
|
|
*/
|
|
|
|
FILE *tmp;
|
|
|
|
|
|
|
|
if ((tmp = fopen(configFile, "r")) == NULL) {
|
|
|
|
printf("%s: %s\n", configFile, strerror(errno));
|
|
|
|
usage();
|
|
|
|
return (2);
|
|
|
|
} else
|
|
|
|
fclose(tmp);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
2004-07-18 23:12:31 -04:00
|
|
|
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
if (!parseConfig(configFile))
|
|
|
|
return (2);
|
|
|
|
|
|
|
|
shout_init();
|
|
|
|
playlist_init();
|
|
|
|
|
|
|
|
if (pezConfig->URL == NULL) {
|
|
|
|
printf("%s: Error: Missing <url>\n", configFile);
|
|
|
|
return (2);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
if (!urlParse(pezConfig->URL, &host, &port, &mount)) {
|
|
|
|
printf("%s: Error: Invalid <url>:\n", configFile);
|
|
|
|
printf("Must be of the form ``http://server:port/mountpoint''.\n");
|
|
|
|
return (2);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
if ((host == NULL)) {
|
|
|
|
printf("%s: Error: Invalid <url>: Missing server:\n", configFile);
|
|
|
|
printf("Must be of the form ``http://server:port/mountpoint''.\n");
|
|
|
|
return (2);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
if ((port < 1 || port > 65535)) {
|
|
|
|
printf("%s: Error: Invalid <url>: Missing or invalid port:\n", configFile);
|
|
|
|
printf("Must be of the form ``http://server:port/mountpoint''.\n");
|
|
|
|
return (2);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
|
|
|
if ((mount == NULL)) {
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
printf("%s: Error: Invalid <url>: Missing mountpoint:\n", configFile);
|
|
|
|
printf("Must be of the form ``http://server:port/mountpoint''.\n");
|
|
|
|
return (2);
|
|
|
|
}
|
|
|
|
if ((pezConfig->password == NULL)) {
|
|
|
|
printf("%s: Error: Missing <sourcepassword>\n", configFile);
|
|
|
|
return (2);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
|
|
|
if ((pezConfig->fileName == NULL)) {
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
printf("%s: Error: Missing <filename>\n", configFile);
|
|
|
|
return (2);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
if (pezConfig->format == NULL) {
|
|
|
|
printf("%s: Warning: Missing <format>:\n", configFile);
|
|
|
|
printf("Specify a stream format of either MP3, VORBIS or THEORA.\n");
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
|
|
|
|
xfree(configFile);
|
|
|
|
|
|
|
|
if ((shout = shout_new()) == NULL) {
|
|
|
|
printf("%s: shout_new(): %s", __progname, strerror(ENOMEM));
|
|
|
|
return (1);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (shout_set_host(shout, host) != SHOUTERR_SUCCESS) {
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
printf("%s: shout_set_host(): %s\n", __progname,
|
|
|
|
shout_get_error(shout));
|
|
|
|
return (1);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
|
|
|
if (shout_set_protocol(shout, SHOUT_PROTOCOL_HTTP) != SHOUTERR_SUCCESS) {
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
printf("%s: shout_set_protocol(): %s\n", __progname,
|
|
|
|
shout_get_error(shout));
|
|
|
|
return (1);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
|
|
|
if (shout_set_port(shout, port) != SHOUTERR_SUCCESS) {
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
printf("%s: shout_set_port: %s\n", __progname,
|
|
|
|
shout_get_error(shout));
|
|
|
|
return (1);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
|
|
|
if (shout_set_password(shout, pezConfig->password) != SHOUTERR_SUCCESS) {
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
printf("%s: shout_set_password(): %s\n", __progname,
|
|
|
|
shout_get_error(shout));
|
|
|
|
return (1);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
|
|
|
if (shout_set_mount(shout, mount) != SHOUTERR_SUCCESS) {
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
printf("%s: shout_set_mount(): %s\n", __progname,
|
|
|
|
shout_get_error(shout));
|
|
|
|
return (1);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
|
|
|
if (shout_set_user(shout, "source") != SHOUTERR_SUCCESS) {
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
printf("%s: shout_set_user(): %s\n", __progname,
|
|
|
|
shout_get_error(shout));
|
|
|
|
return (1);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
|
|
|
|
2004-07-18 23:12:31 -04:00
|
|
|
if (!strcmp(pezConfig->format, MP3_FORMAT)) {
|
2004-01-30 12:19:45 -05:00
|
|
|
if (shout_set_format(shout, SHOUT_FORMAT_MP3) != SHOUTERR_SUCCESS) {
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
printf("%s: shout_set_format(MP3): %s\n",
|
|
|
|
__progname, shout_get_error(shout));
|
|
|
|
return (1);
|
2004-07-18 23:12:31 -04:00
|
|
|
}
|
|
|
|
}
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
if (!strcmp(pezConfig->format, VORBIS_FORMAT) ||
|
|
|
|
!strcmp(pezConfig->format, THEORA_FORMAT)) {
|
2004-07-12 15:13:14 -04:00
|
|
|
if (shout_set_format(shout, SHOUT_FORMAT_OGG) != SHOUTERR_SUCCESS) {
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
printf("%s: shout_set_format(OGG): %s\n",
|
|
|
|
__progname, shout_get_error(shout));
|
|
|
|
return (1);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pezConfig->serverName) {
|
|
|
|
if (shout_set_name(shout, pezConfig->serverName) != SHOUTERR_SUCCESS) {
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
printf("%s: shout_set_name(): %s\n",
|
|
|
|
__progname, shout_get_error(shout));
|
|
|
|
return (1);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (pezConfig->serverURL) {
|
|
|
|
if (shout_set_url(shout, pezConfig->serverURL) != SHOUTERR_SUCCESS) {
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
printf("%s: shout_set_url(): %s\n",
|
|
|
|
__progname, shout_get_error(shout));
|
|
|
|
return (1);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (pezConfig->serverGenre) {
|
|
|
|
if (shout_set_genre(shout, pezConfig->serverGenre) != SHOUTERR_SUCCESS) {
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
printf("%s: shout_set_genre(): %s\n",
|
|
|
|
__progname, shout_get_error(shout));
|
|
|
|
return (1);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (pezConfig->serverDescription) {
|
|
|
|
if (shout_set_description(shout, pezConfig->serverDescription) != SHOUTERR_SUCCESS) {
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
printf("%s: shout_set_description(): %s\n",
|
|
|
|
__progname, shout_get_error(shout));
|
|
|
|
return (1);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (pezConfig->serverBitrate) {
|
|
|
|
if (shout_set_audio_info(shout, SHOUT_AI_BITRATE, pezConfig->serverBitrate) != SHOUTERR_SUCCESS) {
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
printf("%s: shout_set_audio_info(AI_BITRATE): %s\n",
|
|
|
|
__progname, shout_get_error(shout));
|
|
|
|
return (1);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (pezConfig->serverChannels) {
|
|
|
|
if (shout_set_audio_info(shout, SHOUT_AI_CHANNELS, pezConfig->serverChannels) != SHOUTERR_SUCCESS) {
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
printf("%s: shout_set_audio_info(AI_CHANNELS): %s\n",
|
|
|
|
__progname, shout_get_error(shout));
|
|
|
|
return (1);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (pezConfig->serverSamplerate) {
|
|
|
|
if (shout_set_audio_info(shout, SHOUT_AI_SAMPLERATE, pezConfig->serverSamplerate) != SHOUTERR_SUCCESS) {
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
printf("%s: shout_set_audio_info(AI_SAMPLERATE): %s\n",
|
|
|
|
__progname, shout_get_error(shout));
|
|
|
|
return (1);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (pezConfig->serverQuality) {
|
|
|
|
if (shout_set_audio_info(shout, SHOUT_AI_QUALITY, pezConfig->serverQuality) != SHOUTERR_SUCCESS) {
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
printf("%s: shout_set_audio_info(AI_QUALITY): %s\n",
|
|
|
|
__progname, shout_get_error(shout));
|
|
|
|
return (1);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (shout_set_public(shout, pezConfig->serverPublic) != SHOUTERR_SUCCESS) {
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
printf("%s: shout_set_public(): %s\n",
|
|
|
|
__progname, shout_get_error(shout));
|
|
|
|
return (1);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
|
|
|
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
#ifdef HAVE_SIGNALS
|
|
|
|
signal(SIGHUP, sig_handler);
|
|
|
|
signal(SIGUSR1, sig_handler);
|
|
|
|
#endif /* HAVE_SIGNALS */
|
|
|
|
|
|
|
|
if (qFlag) {
|
|
|
|
int fd;
|
|
|
|
|
|
|
|
if ((fd = open(_PATH_DEVNULL, O_RDWR, 0)) == -1) {
|
|
|
|
printf("%s: Cannot open %s for redirecting STDERR output: %s\n",
|
|
|
|
__progname, _PATH_DEVNULL, strerror(errno));
|
|
|
|
return (1);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
|
|
|
|
dup2(fd, STDERR_FILENO);
|
|
|
|
if (fd > 2)
|
|
|
|
close(fd);
|
2004-01-30 12:19:45 -05:00
|
|
|
}
|
|
|
|
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
if (shout_open(shout) == SHOUTERR_SUCCESS) {
|
|
|
|
int ret;
|
|
|
|
char *tmpFileName, *p;
|
|
|
|
|
|
|
|
printf("%s: Connected to http://%s:%d%s\n", __progname,
|
|
|
|
host, port, mount);
|
|
|
|
|
|
|
|
tmpFileName = xstrdup(pezConfig->fileName);
|
|
|
|
for (p = tmpFileName; *p != '\0'; p++)
|
|
|
|
*p = tolower((int)*p);
|
|
|
|
if (strrcmp(tmpFileName, ".m3u") == 0 ||
|
|
|
|
strrcmp(tmpFileName, ".txt") == 0)
|
|
|
|
playlistMode = 1;
|
|
|
|
else
|
|
|
|
playlistMode = 0;
|
|
|
|
xfree(tmpFileName);
|
|
|
|
|
|
|
|
ret = 1;
|
|
|
|
do {
|
|
|
|
if (playlistMode)
|
|
|
|
ret = streamPlaylist(shout,
|
|
|
|
pezConfig->fileName);
|
|
|
|
else
|
|
|
|
ret = streamFile(shout, pezConfig->fileName);
|
|
|
|
} while (ret);
|
|
|
|
} else
|
|
|
|
printf("%s: Connection to http://%s:%d%s failed: %s\n", __progname,
|
|
|
|
host, port, mount, shout_get_error(shout));
|
|
|
|
|
2004-01-30 12:19:45 -05:00
|
|
|
shout_close(shout);
|
|
|
|
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
playlist_free(playlist);
|
|
|
|
playlist_shutdown();
|
|
|
|
|
2004-01-30 12:19:45 -05:00
|
|
|
shout_shutdown();
|
|
|
|
|
Merge changes to main(), urlParse() and streamPlaylist(). In main():
* Install the signal handler as late as possible.
* Add new command line options: -v (verbose, use twice for even more verbose
output) and -q (quiet, redirect standard error output from external de-/
encoders to /dev/null.)
* It is now an error to supply more than one -c parameter. This prevents
unexpected results.
* Add a stern warning when ezstream is running as root. Just Don't Do It.
Leaving the configfile writeable to others by accident could mean instant
root compromise.
* Before handing the config file over to libxml, try to open it ourselves
first. The error message from strerror() is a lot more helpful than the
cryption I/O error printed by libxml.
* Don't preallocate memory for urlParse().
* Fix command line error messages, they seem to be for a different program
than Ezstream.
* More terse libshout error messages, just print which function failed.
I consider these errors of questionable value for an end user, but at least
a knowledgeable one will know instantly what went wrong.
* Case insensitive matching of playlist file extensions.
* Print the address, port and mountpoint that Ezstream is actually trying to
connect to, instead of what the user supplied. That should make it easier
to spot reasons for connect failures (e.g. typos.)
Changes in urlParse():
* Let urlParse() allocate memory for hostname and mountpoint, as it knows
how much memory is actually required.
* Fix a buffer overflow of the tmpPort buffer by adding checks and using safe
string functions.
* Let the caller print an error message, instead of having the same printf()
twice in urlParse().
The streamPlaylist() function has been rewritten to use the new playlist_*()
routines. Apart from the added playlist shuffle feature no functional change.
git-svn-id: https://svn.xiph.org/trunk/ezstream@12552 0101bb08-14d6-0310-b084-bc0e0c8e3800
2007-02-24 20:14:36 -05:00
|
|
|
xfree(host);
|
|
|
|
xfree(mount);
|
2004-01-30 12:19:45 -05:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|