* Fix up some minor quibbles from cppcheck.

This commit is contained in:
Justin Maggard 2011-07-01 18:18:33 +00:00
parent 018a0651c0
commit 741d4f7e99
4 changed files with 71 additions and 66 deletions

View File

@ -1,7 +1,7 @@
# port for HTTP (descriptions, SOAP, media transfer) traffic
port=8200
# network interface to bind to (this is the only interface that will serve files)
# network interfaces to serve, comma delimited
#network_interface=eth0
# set this to the directory you want scanned.

View File

@ -450,6 +450,7 @@ _get_oggfileinfo(char *filename, struct song_metadata *psong)
{
DPRINTF(E_FATAL, L_SCANNER, "Could not find a processor for stream, bailing\n");
_ogg_free_stream_set(processors);
fclose(file);
return -1;
}

View File

@ -153,13 +153,12 @@ sendBeaconMessage(int fd, struct sockaddr_in * client, int len, int broadcast)
int mesg_len;
mesg_len = asprintf(&mesg, "TiVoConnect=1\n"
"swversion=%s\n"
"swversion=1.0\n"
"method=%s\n"
"identity=%s\n"
"machine=%s\n"
"platform=pc/minidlna\n"
"services=TiVoMediaServer:%d/http\n",
"1.0",
broadcast ? "broadcast" : "connected",
uuidvalue, friendly_name, runtime_vars.port);
DPRINTF(E_DEBUG, L_TIVO, "Sending TiVo beacon to %s\n", inet_ntoa(client->sin_addr));
@ -209,10 +208,6 @@ rcvBeaconMessage(char * beacon)
if( tivoConnect == NULL )
return 0;
/* It's pointless to respond to our own beacon */
if( strcmp(identity, uuidvalue) == 0)
return 0;
#ifdef DEBUG
static struct aBeacon* topBeacon = NULL;
struct aBeacon * b;
@ -273,8 +268,18 @@ rcvBeaconMessage(char * beacon)
lastSummary = current;
}
#endif
/* It's pointless to respond to a non-TiVo beacon. */
if( strncmp(platform, "tcd/", 4) != 0 )
return 0;
if( strcasecmp(method, "broadcast") == 0 )
{
DPRINTF(E_DEBUG, L_TIVO, "Received new beacon: machine(%s) platform(%s) services(%s)\n",
machine ? machine : "-",
platform ? platform : "-",
services ? services : "-" );
return 1;
}
return 0;
}

View File

@ -112,7 +112,6 @@ int callback(void *args, int argc, char **argv, char **azColName)
char *id = argv[0], *class = argv[1], *detailID = argv[2], *size = argv[3], *title = argv[4], *duration = argv[5],
*bitrate = argv[6], *sampleFrequency = argv[7], *artist = argv[8], *album = argv[9], *genre = argv[10],
*comment = argv[11], *date = argv[12], *resolution = argv[13], *mime = argv[14], *path = argv[15];
int ret = 0;
struct string_s *str = passed_args->str;
if( strncmp(class, "item", 4) == 0 )
@ -122,34 +121,34 @@ int callback(void *args, int argc, char **argv, char **azColName)
if( strncmp(mime, "audio", 5) == 0 )
{
flags |= FLAG_NO_PARAMS;
ret = strcatf(str, "<Item><Details>"
"<ContentType>audio/*</ContentType>"
"<SourceFormat>%s</SourceFormat>"
"<SourceSize>%s</SourceSize>"
"<SongTitle>%s</SongTitle>", mime, size, title);
strcatf(str, "<Item><Details>"
"<ContentType>audio/*</ContentType>"
"<SourceFormat>%s</SourceFormat>"
"<SourceSize>%s</SourceSize>"
"<SongTitle>%s</SongTitle>", mime, size, title);
if( date )
{
ret = strcatf(str, "<AlbumYear>%.*s</AlbumYear>", 4, date);
strcatf(str, "<AlbumYear>%.*s</AlbumYear>", 4, date);
}
}
else if( strcmp(mime, "image/jpeg") == 0 )
{
flags |= FLAG_SEND_RESIZED;
ret = strcatf(str, "<Item><Details>"
"<ContentType>image/*</ContentType>"
"<SourceFormat>image/jpeg</SourceFormat>"
"<SourceSize>%s</SourceSize>", size);
strcatf(str, "<Item><Details>"
"<ContentType>image/*</ContentType>"
"<SourceFormat>image/jpeg</SourceFormat>"
"<SourceSize>%s</SourceSize>", size);
if( date )
{
struct tm tm;
memset(&tm, 0, sizeof(tm));
tm.tm_isdst = -1; // Have libc figure out if DST is in effect or not
strptime(date, "%Y-%m-%dT%H:%M:%S", &tm);
ret = strcatf(str, "<CaptureDate>0x%X</CaptureDate>", (unsigned int)mktime(&tm));
strcatf(str, "<CaptureDate>0x%X</CaptureDate>", (unsigned int)mktime(&tm));
}
if( comment )
{
ret = strcatf(str, "<Caption>%s</Caption>", comment);
strcatf(str, "<Caption>%s</Caption>", comment);
}
}
else if( strncmp(mime, "video", 5) == 0 )
@ -157,20 +156,20 @@ int callback(void *args, int argc, char **argv, char **azColName)
char *episode;
flags |= FLAG_NO_PARAMS;
flags |= FLAG_VIDEO;
ret = strcatf(str, "<Item><Details>"
"<ContentType>video/x-tivo-mpeg</ContentType>"
"<SourceFormat>%s</SourceFormat>"
"<SourceSize>%s</SourceSize>", mime, size);
strcatf(str, "<Item><Details>"
"<ContentType>video/x-tivo-mpeg</ContentType>"
"<SourceFormat>%s</SourceFormat>"
"<SourceSize>%s</SourceSize>", mime, size);
episode = strstr(title, " - ");
if( episode )
{
ret = strcatf(str, "<Title>%.*s</Title>"
"<EpisodeTitle>%s</EpisodeTitle>",
(int)(episode-title), title, episode+3);
strcatf(str, "<Title>%.*s</Title>"
"<EpisodeTitle>%s</EpisodeTitle>",
(int)(episode-title), title, episode+3);
}
else
{
ret = strcatf(str, "<Title>%s</Title>", title);
strcatf(str, "<Title>%s</Title>", title);
}
if( date )
{
@ -178,64 +177,64 @@ int callback(void *args, int argc, char **argv, char **azColName)
memset(&tm, 0, sizeof(tm));
tm.tm_isdst = -1; // Have libc figure out if DST is in effect or not
strptime(date, "%Y-%m-%dT%H:%M:%S", &tm);
ret = strcatf(str, "<CaptureDate>0x%X</CaptureDate>", (unsigned int)mktime(&tm));
strcatf(str, "<CaptureDate>0x%X</CaptureDate>", (unsigned int)mktime(&tm));
}
if( comment )
{
ret = strcatf(str, "<Description>%s</Description>", comment);
strcatf(str, "<Description>%s</Description>", comment);
}
}
else
{
return 0;
}
ret = strcatf(str, "<Title>%s</Title>", unescape_tag(title));
strcatf(str, "<Title>%s</Title>", unescape_tag(title));
if( artist ) {
ret = strcatf(str, "<ArtistName>%s</ArtistName>", unescape_tag(artist));
strcatf(str, "<ArtistName>%s</ArtistName>", unescape_tag(artist));
}
if( album ) {
ret = strcatf(str, "<AlbumTitle>%s</AlbumTitle>", unescape_tag(album));
strcatf(str, "<AlbumTitle>%s</AlbumTitle>", unescape_tag(album));
}
if( genre ) {
ret = strcatf(str, "<MusicGenre>%s</MusicGenre>", unescape_tag(genre));
strcatf(str, "<MusicGenre>%s</MusicGenre>", unescape_tag(genre));
}
if( resolution ) {
char *width = strsep(&resolution, "x");
ret = strcatf(str, "<SourceWidth>%s</SourceWidth>"
strcatf(str, "<SourceWidth>%s</SourceWidth>"
"<SourceHeight>%s</SourceHeight>",
width, resolution);
}
if( duration ) {
ret = strcatf(str, "<Duration>%d</Duration>",
strcatf(str, "<Duration>%d</Duration>",
atoi(strrchr(duration, '.')+1) + (1000*atoi(strrchr(duration, ':')+1))
+ (60000*atoi(strrchr(duration, ':')-2)) + (3600000*atoi(duration)));
}
if( bitrate ) {
ret = strcatf(str, "<SourceBitRate>%s</SourceBitRate>", bitrate);
strcatf(str, "<SourceBitRate>%s</SourceBitRate>", bitrate);
}
if( sampleFrequency ) {
ret = strcatf(str, "<SourceSampleRate>%s</SourceSampleRate>", sampleFrequency);
strcatf(str, "<SourceSampleRate>%s</SourceSampleRate>", sampleFrequency);
}
ret = strcatf(str, "</Details><Links><Content>"
"<ContentType>%s</ContentType>"
"<Url>/%s/%s.dat</Url>%s</Content>",
mime,
(flags & FLAG_SEND_RESIZED)?"Resized":"MediaItems", detailID,
(flags & FLAG_NO_PARAMS)?"<AcceptsParams>No</AcceptsParams>":"");
strcatf(str, "</Details><Links><Content>"
"<ContentType>%s</ContentType>"
"<Url>/%s/%s.dat</Url>%s</Content>",
mime,
(flags & FLAG_SEND_RESIZED)?"Resized":"MediaItems", detailID,
(flags & FLAG_NO_PARAMS)?"<AcceptsParams>No</AcceptsParams>":"");
if( flags & FLAG_VIDEO )
{
char *esc_name = escape_tag(basename(path), 1);
ret = strcatf(str, "<CustomIcon>"
"<ContentType>video/*</ContentType>"
"<Url>urn:tivo:image:save-until-i-delete-recording</Url>"
"</CustomIcon>"
"<Push><Container>Videos</Container></Push>"
"<File>%s</File> </Links>", esc_name);
strcatf(str, "<CustomIcon>"
"<ContentType>video/*</ContentType>"
"<Url>urn:tivo:image:save-until-i-delete-recording</Url>"
"</CustomIcon>"
"<Push><Container>Videos</Container></Push>"
"<File>%s</File> </Links>", esc_name);
free(esc_name);
}
else
{
ret = strcatf(str, "</Links>");
strcatf(str, "</Links>");
}
}
else if( strncmp(class, "container", 9) == 0 )
@ -249,22 +248,22 @@ int callback(void *args, int argc, char **argv, char **azColName)
" (MIME in ('image/jpeg', 'audio/mpeg', 'video/mpeg', 'video/x-tivo-mpeg')"
" or CLASS glob 'container*')", id);
#endif
ret = strcatf(str, "<Item>"
"<Details>"
"<ContentType>x-container/folder</ContentType>"
"<SourceFormat>x-container/folder</SourceFormat>"
"<Title>%s</Title>"
"<TotalItems>%d</TotalItems>"
"</Details>"
"<Links>"
"<Content>"
"<Url>/TiVoConnect?Command=QueryContainer&amp;Container=%s</Url>"
"<ContentType>x-tivo-container/folder</ContentType>"
"</Content>"
"</Links>",
unescape_tag(title), count, id);
strcatf(str, "<Item>"
"<Details>"
"<ContentType>x-container/folder</ContentType>"
"<SourceFormat>x-container/folder</SourceFormat>"
"<Title>%s</Title>"
"<TotalItems>%d</TotalItems>"
"</Details>"
"<Links>"
"<Content>"
"<Url>/TiVoConnect?Command=QueryContainer&amp;Container=%s</Url>"
"<ContentType>x-tivo-container/folder</ContentType>"
"</Content>"
"</Links>",
unescape_tag(title), count, id);
}
ret = strcatf(str, "</Item>");
strcatf(str, "</Item>");
passed_args->returned++;