1
0
mirror of https://gitlab.xiph.org/xiph/ezstream.git synced 2024-11-03 04:17:18 -05:00

Assorted type fixes, unshadowing of variables, etc.

git-svn-id: https://svn.xiph.org/trunk/ezstream@15775 0101bb08-14d6-0310-b084-bc0e0c8e3800
This commit is contained in:
moritz 2009-03-15 17:18:56 +00:00
parent 49e77548c8
commit 4eab64df5d
6 changed files with 74 additions and 62 deletions

View File

@ -118,7 +118,7 @@ parseConfig(const char *fileName)
streamOnce_set = 0;
svrinfopublic_set = 0;
for (cur = cur->xmlChildrenNode; cur != NULL; cur = cur->next) {
if (!xmlStrcmp(cur->name, BAD_CAST "url")) {
if (!xmlStrcmp(cur->name, (const xmlChar *)"url")) {
if (ezConfig.URL != NULL) {
printf("%s[%ld]: Error: Cannot have multiple <url> elements\n",
fileName, xmlGetLineNo(cur));
@ -131,7 +131,7 @@ parseConfig(const char *fileName)
xmlFree(ls_xmlContentPtr);
}
}
if (!xmlStrcmp(cur->name, BAD_CAST "sourcepassword")) {
if (!xmlStrcmp(cur->name, (const xmlChar *)"sourcepassword")) {
if (ezConfig.password != NULL) {
printf("%s[%ld]: Error: Cannot have multiple <sourcepassword> elements\n",
fileName, xmlGetLineNo(cur));
@ -144,7 +144,7 @@ parseConfig(const char *fileName)
xmlFree(ls_xmlContentPtr);
}
}
if (!xmlStrcmp(cur->name, BAD_CAST "format")) {
if (!xmlStrcmp(cur->name, (const xmlChar *)"format")) {
if (ezConfig.format != NULL) {
printf("%s[%ld]: Error: Cannot have multiple <format> elements\n",
fileName, xmlGetLineNo(cur));
@ -161,7 +161,7 @@ parseConfig(const char *fileName)
*p = toupper((int)*p);
}
}
if (!xmlStrcmp(cur->name, BAD_CAST "filename")) {
if (!xmlStrcmp(cur->name, (const xmlChar *)"filename")) {
if (ezConfig.fileName != NULL) {
printf("%s[%ld]: Error: Cannot have multiple <filename> elements\n",
fileName, xmlGetLineNo(cur));
@ -180,7 +180,7 @@ parseConfig(const char *fileName)
xmlFree(ls_xmlContentPtr);
}
}
if (!xmlStrcmp(cur->name, BAD_CAST "metadata_progname")) {
if (!xmlStrcmp(cur->name, (const xmlChar *)"metadata_progname")) {
if (ezConfig.metadataProgram != NULL) {
printf("%s[%ld]: Error: Cannot have multiple <metadata_progname> elements\n",
fileName, xmlGetLineNo(cur));
@ -199,7 +199,7 @@ parseConfig(const char *fileName)
xmlFree(ls_xmlContentPtr);
}
}
if (!xmlStrcmp(cur->name, BAD_CAST "metadata_format")) {
if (!xmlStrcmp(cur->name, (const xmlChar *)"metadata_format")) {
if (ezConfig.metadataFormat != NULL) {
printf("%s[%ld]: Error: Cannot have multiple <metadata_format> elements\n",
fileName, xmlGetLineNo(cur));
@ -220,7 +220,7 @@ parseConfig(const char *fileName)
}
}
}
if (!xmlStrcmp(cur->name, BAD_CAST "playlist_program")) {
if (!xmlStrcmp(cur->name, (const xmlChar *)"playlist_program")) {
if (program_set) {
printf("%s[%ld]: Error: Cannot have multiple <playlist_program> elements\n",
fileName, xmlGetLineNo(cur));
@ -231,7 +231,7 @@ parseConfig(const char *fileName)
const char *errstr;
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
ezConfig.fileNameIsProgram = (int)strtonum(ls_xmlContentPtr, 0, 1, &errstr);
ezConfig.fileNameIsProgram = (int)strtonum(ls_xmlContentPtr, 0LL, 1LL, &errstr);
if (errstr) {
printf("%s[%ld]: Error: <playlist_program> may only contain 1 or 0\n",
fileName, xmlGetLineNo(cur));
@ -242,7 +242,7 @@ parseConfig(const char *fileName)
program_set = 1;
}
}
if (!xmlStrcmp(cur->name, BAD_CAST "shuffle")) {
if (!xmlStrcmp(cur->name, (const xmlChar *)"shuffle")) {
if (shuffle_set) {
printf("%s[%ld]: Error: Cannot have multiple <shuffle> elements\n",
fileName, xmlGetLineNo(cur));
@ -253,7 +253,7 @@ parseConfig(const char *fileName)
const char *errstr;
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
ezConfig.shuffle = (int)strtonum(ls_xmlContentPtr, 0, 1, &errstr);
ezConfig.shuffle = (int)strtonum(ls_xmlContentPtr, 0LL, 1LL, &errstr);
if (errstr) {
printf("%s[%ld]: Error: <shuffle> may only contain 1 or 0\n",
fileName, xmlGetLineNo(cur));
@ -264,7 +264,7 @@ parseConfig(const char *fileName)
shuffle_set = 1;
}
}
if (!xmlStrcmp(cur->name, BAD_CAST "stream_once")) {
if (!xmlStrcmp(cur->name, (const xmlChar *)"stream_once")) {
if (streamOnce_set) {
printf("%s[%ld]: Error: Cannot have multiple <stream_once> elements\n",
fileName, xmlGetLineNo(cur));
@ -275,7 +275,7 @@ parseConfig(const char *fileName)
const char *errstr;
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
ezConfig.streamOnce = (int)strtonum(ls_xmlContentPtr, 0, 1, &errstr);
ezConfig.streamOnce = (int)strtonum(ls_xmlContentPtr, 0LL, 1LL, &errstr);
if (errstr) {
printf("%s[%ld]: Error: <stream_once> may only contain 1 or 0\n",
fileName, xmlGetLineNo(cur));
@ -286,7 +286,7 @@ parseConfig(const char *fileName)
streamOnce_set = 1;
}
}
if (!xmlStrcmp(cur->name, BAD_CAST "reconnect_tries")) {
if (!xmlStrcmp(cur->name, (const xmlChar *)"reconnect_tries")) {
if (reconnect_set) {
printf("%s[%ld]: Error: Cannot have multiple <reconnect_tries> elements\n",
fileName, xmlGetLineNo(cur));
@ -297,7 +297,7 @@ parseConfig(const char *fileName)
const char *errstr;
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
ezConfig.reconnectAttempts = (unsigned int)strtonum(ls_xmlContentPtr, 0, UINT_MAX, &errstr);
ezConfig.reconnectAttempts = (unsigned int)strtonum(ls_xmlContentPtr, 0LL, (long long)UINT_MAX, &errstr);
if (errstr) {
printf("%s[%ld]: Error: In <reconnect_tries>: '%s' is %s\n",
fileName, xmlGetLineNo(cur), ls_xmlContentPtr, errstr);
@ -308,7 +308,7 @@ parseConfig(const char *fileName)
reconnect_set = 1;
}
}
if (!xmlStrcmp(cur->name, BAD_CAST "svrinfoname")) {
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfoname")) {
if (ezConfig.serverName != NULL) {
printf("%s[%ld]: Error: Cannot have multiple <svrinfoname> elements\n",
fileName, xmlGetLineNo(cur));
@ -321,7 +321,7 @@ parseConfig(const char *fileName)
xmlFree(ls_xmlContentPtr);
}
}
if (!xmlStrcmp(cur->name, BAD_CAST "svrinfourl")) {
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfourl")) {
if (ezConfig.serverURL != NULL) {
printf("%s[%ld]: Error: Cannot have multiple <svrinfourl> elements\n",
fileName, xmlGetLineNo(cur));
@ -334,7 +334,7 @@ parseConfig(const char *fileName)
xmlFree(ls_xmlContentPtr);
}
}
if (!xmlStrcmp(cur->name, BAD_CAST "svrinfogenre")) {
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfogenre")) {
if (ezConfig.serverGenre != NULL) {
printf("%s[%ld]: Error: Cannot have multiple <svrinfogenre> elements\n",
fileName, xmlGetLineNo(cur));
@ -347,7 +347,7 @@ parseConfig(const char *fileName)
xmlFree(ls_xmlContentPtr);
}
}
if (!xmlStrcmp(cur->name, BAD_CAST "svrinfodescription")) {
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfodescription")) {
if (ezConfig.serverDescription != NULL) {
printf("%s[%ld]: Error: Cannot have multiple <svrinfodescription> elements\n",
fileName, xmlGetLineNo(cur));
@ -360,7 +360,7 @@ parseConfig(const char *fileName)
xmlFree(ls_xmlContentPtr);
}
}
if (!xmlStrcmp(cur->name, BAD_CAST "svrinfobitrate")) {
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfobitrate")) {
if (ezConfig.serverBitrate != NULL) {
printf("%s[%ld]: Error: Cannot have multiple <svrinfobitrate> elements\n",
fileName, xmlGetLineNo(cur));
@ -374,7 +374,7 @@ parseConfig(const char *fileName)
}
}
if (!xmlStrcmp(cur->name, BAD_CAST "svrinfochannels")) {
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfochannels")) {
if (ezConfig.serverChannels != NULL) {
printf("%s[%ld]: Error: Cannot have multiple <svrinfochannels> elements\n",
fileName, xmlGetLineNo(cur));
@ -387,7 +387,7 @@ parseConfig(const char *fileName)
xmlFree(ls_xmlContentPtr);
}
}
if (!xmlStrcmp(cur->name, BAD_CAST "svrinfosamplerate")) {
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfosamplerate")) {
if (ezConfig.serverSamplerate != NULL) {
printf("%s[%ld]: Error: Cannot have multiple <svrinfosamplerate> elements\n",
fileName, xmlGetLineNo(cur));
@ -400,7 +400,7 @@ parseConfig(const char *fileName)
xmlFree(ls_xmlContentPtr);
}
}
if (!xmlStrcmp(cur->name, BAD_CAST "svrinfoquality")) {
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfoquality")) {
if (ezConfig.serverQuality != NULL) {
printf("%s[%ld]: Error: Cannot have multiple <svrinfoquality> elements\n",
fileName, xmlGetLineNo(cur));
@ -413,7 +413,7 @@ parseConfig(const char *fileName)
xmlFree(ls_xmlContentPtr);
}
}
if (!xmlStrcmp(cur->name, BAD_CAST "svrinfopublic")) {
if (!xmlStrcmp(cur->name, (const xmlChar *)"svrinfopublic")) {
if (svrinfopublic_set) {
printf("%s[%ld]: Error: Cannot have multiple <svrinfopublic> elements\n",
fileName, xmlGetLineNo(cur));
@ -424,7 +424,7 @@ parseConfig(const char *fileName)
const char *errstr;
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
ezConfig.serverPublic = (int)strtonum(ls_xmlContentPtr, 0, 1, &errstr);
ezConfig.serverPublic = (int)strtonum(ls_xmlContentPtr, 0LL, 1LL, &errstr);
if (errstr) {
printf("%s[%ld]: Error: <svrinfopublic> may only contain 1 or 0\n",
fileName, xmlGetLineNo(cur));
@ -435,14 +435,14 @@ parseConfig(const char *fileName)
svrinfopublic_set = 1;
}
}
if (!xmlStrcmp(cur->name, BAD_CAST "reencode")) {
if (!xmlStrcmp(cur->name, (const xmlChar *)"reencode")) {
xmlNodePtr cur2;
int enable_set;
enable_set = 0;
for (cur2 = cur->xmlChildrenNode; cur2 != NULL;
cur2 = cur2->next) {
if (!xmlStrcmp(cur2->name, BAD_CAST "enable")) {
if (!xmlStrcmp(cur2->name, (const xmlChar *)"enable")) {
if (enable_set) {
printf("%s[%ld]: Error: Cannot have multiple <enable> elements\n",
fileName, xmlGetLineNo(cur));
@ -453,7 +453,7 @@ parseConfig(const char *fileName)
const char *errstr;
ls_xmlContentPtr = (char *)xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1);
ezConfig.reencode = (int)strtonum(ls_xmlContentPtr, 0, 1, &errstr);
ezConfig.reencode = (int)strtonum(ls_xmlContentPtr, 0LL, 1LL, &errstr);
if (errstr) {
printf("%s[%ld]: Error: <enable> may only contain 1 or 0\n",
fileName, xmlGetLineNo(cur));
@ -464,7 +464,7 @@ parseConfig(const char *fileName)
enable_set = 1;
}
}
if (!xmlStrcmp(cur2->name, BAD_CAST "encdec")) {
if (!xmlStrcmp(cur2->name, (const xmlChar *)"encdec")) {
xmlNodePtr cur3;
FORMAT_ENCDEC *pformatEncDec;
@ -472,7 +472,7 @@ parseConfig(const char *fileName)
for (cur3 = cur2->xmlChildrenNode;
cur3 != NULL; cur3 = cur3->next) {
if (!xmlStrcmp(cur3->name, BAD_CAST "format")) {
if (!xmlStrcmp(cur3->name, (const xmlChar *)"format")) {
if (pformatEncDec->format != NULL) {
printf("%s[%ld]: Error: Cannot have multiple <format> elements\n",
fileName, xmlGetLineNo(cur3));
@ -489,7 +489,7 @@ parseConfig(const char *fileName)
*p = toupper((int)*p);
}
}
if (!xmlStrcmp(cur3->name, BAD_CAST "match")) {
if (!xmlStrcmp(cur3->name, (const xmlChar *)"match")) {
if (pformatEncDec->match != NULL) {
printf("%s[%ld]: Error: Cannot have multiple <match> elements\n",
fileName, xmlGetLineNo(cur3));
@ -506,7 +506,7 @@ parseConfig(const char *fileName)
*p = tolower((int)*p);
}
}
if (!xmlStrcmp(cur3->name, BAD_CAST "decode")) {
if (!xmlStrcmp(cur3->name, (const xmlChar *)"decode")) {
if (pformatEncDec->decoder != NULL) {
printf("%s[%ld]: Error: Cannot have multiple <decode> elements\n",
fileName, xmlGetLineNo(cur3));
@ -527,7 +527,7 @@ parseConfig(const char *fileName)
}
}
}
if (!xmlStrcmp(cur3->name, BAD_CAST "encode")) {
if (!xmlStrcmp(cur3->name, (const xmlChar *)"encode")) {
if (pformatEncDec->encoder != NULL) {
printf("%s[%ld]: Error: Cannot have multiple <encode> elements\n",
fileName, xmlGetLineNo(cur3));

View File

@ -111,7 +111,7 @@ typedef struct tag_ID3Tag {
char genre;
} ID3Tag;
int urlParse(const char *, char **, int *, char **);
int urlParse(const char *, char **, unsigned short *, char **);
void replaceString(const char *, char *, size_t, const char *,
const char *);
char * buildCommandString(const char *, const char *, metadata_t *);
@ -163,9 +163,10 @@ sig_handler(int sig)
#endif /* HAVE_SIGNALS */
int
urlParse(const char *url, char **hostname, int *port, char **mountname)
urlParse(const char *url, char **hostname, unsigned short *port,
char **mountname)
{
char *p1, *p2, *p3;
const char *p1, *p2, *p3;
char tmpPort[6] = "";
size_t hostsiz, mountsiz;
const char *errstr;
@ -182,7 +183,7 @@ urlParse(const char *url, char **hostname, int *port, char **mountname)
return (0);
}
p1 = (char *)(url) + strlen("http://");
p1 = url + strlen("http://");
p2 = strchr(p1, ':');
if (p2 == NULL) {
printf("%s: Error: Invalid <url>: Missing port\n",
@ -202,8 +203,8 @@ urlParse(const char *url, char **hostname, int *port, char **mountname)
return (0);
}
strlcpy(tmpPort, p2, (p3 - p2) + 1);
*port = (int)strtonum(tmpPort, 1, 65535, &errstr);
strlcpy(tmpPort, p2, (p3 - p2) + 1UL);
*port = (unsigned short)strtonum(tmpPort, 1LL, (long long)USHRT_MAX, &errstr);
if (errstr) {
printf("%s: Error: Invalid <url>: Port '%s' is %s\n",
__progname, tmpPort, errstr);
@ -222,8 +223,8 @@ void
replaceString(const char *source, char *dest, size_t size,
const char *from, const char *to)
{
char *p1 = (char *)source;
char *p2;
const char *p1 = source;
const char *p2;
p2 = strstr(p1, from);
if (p2 != NULL) {
@ -232,7 +233,7 @@ replaceString(const char *source, char *dest, size_t size,
__progname);
abort();
}
strncat(dest, p1, p2 - p1);
strncat(dest, p1, (size_t)(p2 - p1));
strlcat(dest, to, size);
p1 = p2 + strlen(from);
}
@ -768,7 +769,7 @@ sendStream(shout_t *shout, FILE *filepstream, const char *fileName,
int isStdin, const char *songLenStr, struct timeval *tv)
{
unsigned char buff[4096];
size_t read, total, oldTotal;
size_t bytes_read, total, oldTotal;
int ret;
double kbps = -1.0;
struct timeval timeStamp, *startTime = tv;
@ -784,7 +785,7 @@ sendStream(shout_t *shout, FILE *filepstream, const char *fileName,
total = oldTotal = 0;
ret = STREAM_DONE;
while ((read = fread(buff, 1, sizeof(buff), filepstream)) > 0) {
while ((bytes_read = fread(buff, 1, sizeof(buff), filepstream)) > 0) {
if (shout_get_connected(shout) != SHOUTERR_CONNECTED &&
reconnectServer(shout, 0) == 0) {
ret = STREAM_SERVERR;
@ -793,7 +794,7 @@ sendStream(shout_t *shout, FILE *filepstream, const char *fileName,
shout_sync(shout);
if (shout_send(shout, buff, read) != SHOUTERR_SUCCESS) {
if (shout_send(shout, buff, bytes_read) != SHOUTERR_SUCCESS) {
printf("%s: shout_send(): %s\n", __progname,
shout_get_error(shout));
if (reconnectServer(shout, 1))
@ -825,9 +826,9 @@ sendStream(shout_t *shout, FILE *filepstream, const char *fileName,
}
}
total += read;
total += bytes_read;
if (qFlag && vFlag) {
struct timeval tv;
struct timeval tval;
double oldTime, newTime;
if (!isStdin && playlistMode) {
@ -844,20 +845,20 @@ sendStream(shout_t *shout, FILE *filepstream, const char *fileName,
oldTime = (double)timeStamp.tv_sec
+ (double)timeStamp.tv_usec / 1000000.0;
ez_gettimeofday((void *)&tv);
newTime = (double)tv.tv_sec
+ (double)tv.tv_usec / 1000000.0;
ez_gettimeofday((void *)&tval);
newTime = (double)tval.tv_sec
+ (double)tval.tv_usec / 1000000.0;
if (songLenStr == NULL)
printf(" [ %s]",
getTimeString(tv.tv_sec - startTime->tv_sec));
getTimeString(tval.tv_sec - startTime->tv_sec));
else
printf(" [ %s/%s]",
getTimeString(tv.tv_sec - startTime->tv_sec),
getTimeString(tval.tv_sec - startTime->tv_sec),
songLenStr);
if (newTime - oldTime >= 1.0) {
kbps = (((double)(total - oldTotal) / (newTime - oldTime)) * 8.0) / 1000.0;
timeStamp.tv_sec = tv.tv_sec;
timeStamp.tv_usec = tv.tv_usec;
timeStamp.tv_sec = tval.tv_sec;
timeStamp.tv_usec = tval.tv_usec;
oldTotal = total;
}
if (kbps < 0)
@ -1060,6 +1061,7 @@ char *
getProgname(const char *argv0)
{
#ifdef HAVE___PROGNAME
(void)argv0;
return (strdup(__progname));
#else
char *p;
@ -1113,7 +1115,7 @@ main(int argc, char *argv[])
int c;
char *configFile = NULL;
char *host = NULL;
int port = 0;
unsigned short port = 0;
char *mount = NULL;
shout_t *shout;
extern char *optarg;
@ -1284,7 +1286,7 @@ main(int argc, char *argv[])
if (shout_open(shout) == SHOUTERR_SUCCESS) {
int ret;
printf("%s: Connected to http://%s:%d%s\n", __progname,
printf("%s: Connected to http://%s:%hu%s\n", __progname,
host, port, mount);
if (pezConfig->fileNameIsProgram ||
@ -1314,7 +1316,7 @@ main(int argc, char *argv[])
shout_close(shout);
} else
printf("%s: Connection to http://%s:%d%s failed: %s\n", __progname,
printf("%s: Connection to http://%s:%hu%s failed: %s\n", __progname,
host, port, mount, shout_get_error(shout));
if (quit)

View File

@ -150,6 +150,9 @@ metadata_use_taglib(metadata_t *md, FILE **filep)
}
#else
{
(void)md;
(void)filep;
printf("%s: Internal error: metadata_use_taglib() called without TagLib support\n",
__progname);
abort();
@ -160,6 +163,9 @@ void
metadata_use_self(metadata_t *md, FILE **filep)
#ifdef HAVE_TAGLIB
{
(void)md;
(void)filep;
printf("%s: Internal error: metadata_use_self() called with TagLib support\n",
__progname);
abort();

View File

@ -355,7 +355,7 @@ playlist_get_position(playlist_t *pl)
}
int
playlist_set_position(playlist_t *pl, unsigned long index)
playlist_set_position(playlist_t *pl, unsigned long idx)
{
if (pl == NULL) {
printf("%s: playlist_set_position(): Internal error: NULL argument\n",
@ -363,10 +363,10 @@ playlist_set_position(playlist_t *pl, unsigned long index)
exit(1);
}
if (pl->program || index > pl->num - 1)
if (pl->program || idx > pl->num - 1)
return (0);
pl->index = (size_t)index;
pl->index = (size_t)idx;
return (1);
}

View File

@ -100,7 +100,7 @@ strrcasecmp(const char *s, const char *sub)
}
shout_t *
stream_setup(const char *host, const int port, const char *mount)
stream_setup(const char *host, unsigned short port, const char *mount)
{
shout_t *shout = NULL;
@ -219,7 +219,7 @@ stream_setup(const char *host, const int port, const char *mount)
return (NULL);
}
if (shout_set_public(shout, pezConfig->serverPublic) != SHOUTERR_SUCCESS) {
if (shout_set_public(shout, (unsigned int)pezConfig->serverPublic) != SHOUTERR_SUCCESS) {
printf("%s: shout_set_public(): %s\n",
__progname, shout_get_error(shout));
shout_free(shout);
@ -365,6 +365,10 @@ iconvert(const char *in_str, const char *from, const char *to, int mode)
xfree(tocode);
return (output);
#else
(void)from;
(void)to;
(void)mode;
return (xstrdup(in_str));
#endif /* HAVE_ICONV */
}

View File

@ -28,7 +28,7 @@
int strrcmp(const char *, const char *);
int strrcasecmp(const char *, const char *);
shout_t * stream_setup(const char *, const int, const char *);
shout_t * stream_setup(const char *, unsigned short, const char *);
char * CHARtoUTF8(const char *, int);
char * UTF8toCHAR(const char *, int);
int ez_gettimeofday(void *);