* 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 for HTTP (descriptions, SOAP, media transfer) traffic
port=8200 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 #network_interface=eth0
# set this to the directory you want scanned. # 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"); DPRINTF(E_FATAL, L_SCANNER, "Could not find a processor for stream, bailing\n");
_ogg_free_stream_set(processors); _ogg_free_stream_set(processors);
fclose(file);
return -1; return -1;
} }

View File

@ -153,13 +153,12 @@ sendBeaconMessage(int fd, struct sockaddr_in * client, int len, int broadcast)
int mesg_len; int mesg_len;
mesg_len = asprintf(&mesg, "TiVoConnect=1\n" mesg_len = asprintf(&mesg, "TiVoConnect=1\n"
"swversion=%s\n" "swversion=1.0\n"
"method=%s\n" "method=%s\n"
"identity=%s\n" "identity=%s\n"
"machine=%s\n" "machine=%s\n"
"platform=pc/minidlna\n" "platform=pc/minidlna\n"
"services=TiVoMediaServer:%d/http\n", "services=TiVoMediaServer:%d/http\n",
"1.0",
broadcast ? "broadcast" : "connected", broadcast ? "broadcast" : "connected",
uuidvalue, friendly_name, runtime_vars.port); uuidvalue, friendly_name, runtime_vars.port);
DPRINTF(E_DEBUG, L_TIVO, "Sending TiVo beacon to %s\n", inet_ntoa(client->sin_addr)); 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 ) if( tivoConnect == NULL )
return 0; return 0;
/* It's pointless to respond to our own beacon */
if( strcmp(identity, uuidvalue) == 0)
return 0;
#ifdef DEBUG #ifdef DEBUG
static struct aBeacon* topBeacon = NULL; static struct aBeacon* topBeacon = NULL;
struct aBeacon * b; struct aBeacon * b;
@ -273,8 +268,18 @@ rcvBeaconMessage(char * beacon)
lastSummary = current; lastSummary = current;
} }
#endif #endif
/* It's pointless to respond to a non-TiVo beacon. */
if( strncmp(platform, "tcd/", 4) != 0 )
return 0;
if( strcasecmp(method, "broadcast") == 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 1;
}
return 0; 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], 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], *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]; *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; struct string_s *str = passed_args->str;
if( strncmp(class, "item", 4) == 0 ) 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 ) if( strncmp(mime, "audio", 5) == 0 )
{ {
flags |= FLAG_NO_PARAMS; flags |= FLAG_NO_PARAMS;
ret = strcatf(str, "<Item><Details>" strcatf(str, "<Item><Details>"
"<ContentType>audio/*</ContentType>" "<ContentType>audio/*</ContentType>"
"<SourceFormat>%s</SourceFormat>" "<SourceFormat>%s</SourceFormat>"
"<SourceSize>%s</SourceSize>" "<SourceSize>%s</SourceSize>"
"<SongTitle>%s</SongTitle>", mime, size, title); "<SongTitle>%s</SongTitle>", mime, size, title);
if( date ) if( date )
{ {
ret = strcatf(str, "<AlbumYear>%.*s</AlbumYear>", 4, date); strcatf(str, "<AlbumYear>%.*s</AlbumYear>", 4, date);
} }
} }
else if( strcmp(mime, "image/jpeg") == 0 ) else if( strcmp(mime, "image/jpeg") == 0 )
{ {
flags |= FLAG_SEND_RESIZED; flags |= FLAG_SEND_RESIZED;
ret = strcatf(str, "<Item><Details>" strcatf(str, "<Item><Details>"
"<ContentType>image/*</ContentType>" "<ContentType>image/*</ContentType>"
"<SourceFormat>image/jpeg</SourceFormat>" "<SourceFormat>image/jpeg</SourceFormat>"
"<SourceSize>%s</SourceSize>", size); "<SourceSize>%s</SourceSize>", size);
if( date ) if( date )
{ {
struct tm tm; struct tm tm;
memset(&tm, 0, sizeof(tm)); memset(&tm, 0, sizeof(tm));
tm.tm_isdst = -1; // Have libc figure out if DST is in effect or not tm.tm_isdst = -1; // Have libc figure out if DST is in effect or not
strptime(date, "%Y-%m-%dT%H:%M:%S", &tm); 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 ) if( comment )
{ {
ret = strcatf(str, "<Caption>%s</Caption>", comment); strcatf(str, "<Caption>%s</Caption>", comment);
} }
} }
else if( strncmp(mime, "video", 5) == 0 ) else if( strncmp(mime, "video", 5) == 0 )
@ -157,20 +156,20 @@ int callback(void *args, int argc, char **argv, char **azColName)
char *episode; char *episode;
flags |= FLAG_NO_PARAMS; flags |= FLAG_NO_PARAMS;
flags |= FLAG_VIDEO; flags |= FLAG_VIDEO;
ret = strcatf(str, "<Item><Details>" strcatf(str, "<Item><Details>"
"<ContentType>video/x-tivo-mpeg</ContentType>" "<ContentType>video/x-tivo-mpeg</ContentType>"
"<SourceFormat>%s</SourceFormat>" "<SourceFormat>%s</SourceFormat>"
"<SourceSize>%s</SourceSize>", mime, size); "<SourceSize>%s</SourceSize>", mime, size);
episode = strstr(title, " - "); episode = strstr(title, " - ");
if( episode ) if( episode )
{ {
ret = strcatf(str, "<Title>%.*s</Title>" strcatf(str, "<Title>%.*s</Title>"
"<EpisodeTitle>%s</EpisodeTitle>", "<EpisodeTitle>%s</EpisodeTitle>",
(int)(episode-title), title, episode+3); (int)(episode-title), title, episode+3);
} }
else else
{ {
ret = strcatf(str, "<Title>%s</Title>", title); strcatf(str, "<Title>%s</Title>", title);
} }
if( date ) if( date )
{ {
@ -178,64 +177,64 @@ int callback(void *args, int argc, char **argv, char **azColName)
memset(&tm, 0, sizeof(tm)); memset(&tm, 0, sizeof(tm));
tm.tm_isdst = -1; // Have libc figure out if DST is in effect or not tm.tm_isdst = -1; // Have libc figure out if DST is in effect or not
strptime(date, "%Y-%m-%dT%H:%M:%S", &tm); 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 ) if( comment )
{ {
ret = strcatf(str, "<Description>%s</Description>", comment); strcatf(str, "<Description>%s</Description>", comment);
} }
} }
else else
{ {
return 0; return 0;
} }
ret = strcatf(str, "<Title>%s</Title>", unescape_tag(title)); strcatf(str, "<Title>%s</Title>", unescape_tag(title));
if( artist ) { if( artist ) {
ret = strcatf(str, "<ArtistName>%s</ArtistName>", unescape_tag(artist)); strcatf(str, "<ArtistName>%s</ArtistName>", unescape_tag(artist));
} }
if( album ) { if( album ) {
ret = strcatf(str, "<AlbumTitle>%s</AlbumTitle>", unescape_tag(album)); strcatf(str, "<AlbumTitle>%s</AlbumTitle>", unescape_tag(album));
} }
if( genre ) { if( genre ) {
ret = strcatf(str, "<MusicGenre>%s</MusicGenre>", unescape_tag(genre)); strcatf(str, "<MusicGenre>%s</MusicGenre>", unescape_tag(genre));
} }
if( resolution ) { if( resolution ) {
char *width = strsep(&resolution, "x"); char *width = strsep(&resolution, "x");
ret = strcatf(str, "<SourceWidth>%s</SourceWidth>" strcatf(str, "<SourceWidth>%s</SourceWidth>"
"<SourceHeight>%s</SourceHeight>", "<SourceHeight>%s</SourceHeight>",
width, resolution); width, resolution);
} }
if( duration ) { if( duration ) {
ret = strcatf(str, "<Duration>%d</Duration>", strcatf(str, "<Duration>%d</Duration>",
atoi(strrchr(duration, '.')+1) + (1000*atoi(strrchr(duration, ':')+1)) atoi(strrchr(duration, '.')+1) + (1000*atoi(strrchr(duration, ':')+1))
+ (60000*atoi(strrchr(duration, ':')-2)) + (3600000*atoi(duration))); + (60000*atoi(strrchr(duration, ':')-2)) + (3600000*atoi(duration)));
} }
if( bitrate ) { if( bitrate ) {
ret = strcatf(str, "<SourceBitRate>%s</SourceBitRate>", bitrate); strcatf(str, "<SourceBitRate>%s</SourceBitRate>", bitrate);
} }
if( sampleFrequency ) { if( sampleFrequency ) {
ret = strcatf(str, "<SourceSampleRate>%s</SourceSampleRate>", sampleFrequency); strcatf(str, "<SourceSampleRate>%s</SourceSampleRate>", sampleFrequency);
} }
ret = strcatf(str, "</Details><Links><Content>" strcatf(str, "</Details><Links><Content>"
"<ContentType>%s</ContentType>" "<ContentType>%s</ContentType>"
"<Url>/%s/%s.dat</Url>%s</Content>", "<Url>/%s/%s.dat</Url>%s</Content>",
mime, mime,
(flags & FLAG_SEND_RESIZED)?"Resized":"MediaItems", detailID, (flags & FLAG_SEND_RESIZED)?"Resized":"MediaItems", detailID,
(flags & FLAG_NO_PARAMS)?"<AcceptsParams>No</AcceptsParams>":""); (flags & FLAG_NO_PARAMS)?"<AcceptsParams>No</AcceptsParams>":"");
if( flags & FLAG_VIDEO ) if( flags & FLAG_VIDEO )
{ {
char *esc_name = escape_tag(basename(path), 1); char *esc_name = escape_tag(basename(path), 1);
ret = strcatf(str, "<CustomIcon>" strcatf(str, "<CustomIcon>"
"<ContentType>video/*</ContentType>" "<ContentType>video/*</ContentType>"
"<Url>urn:tivo:image:save-until-i-delete-recording</Url>" "<Url>urn:tivo:image:save-until-i-delete-recording</Url>"
"</CustomIcon>" "</CustomIcon>"
"<Push><Container>Videos</Container></Push>" "<Push><Container>Videos</Container></Push>"
"<File>%s</File> </Links>", esc_name); "<File>%s</File> </Links>", esc_name);
free(esc_name); free(esc_name);
} }
else else
{ {
ret = strcatf(str, "</Links>"); strcatf(str, "</Links>");
} }
} }
else if( strncmp(class, "container", 9) == 0 ) 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')" " (MIME in ('image/jpeg', 'audio/mpeg', 'video/mpeg', 'video/x-tivo-mpeg')"
" or CLASS glob 'container*')", id); " or CLASS glob 'container*')", id);
#endif #endif
ret = strcatf(str, "<Item>" strcatf(str, "<Item>"
"<Details>" "<Details>"
"<ContentType>x-container/folder</ContentType>" "<ContentType>x-container/folder</ContentType>"
"<SourceFormat>x-container/folder</SourceFormat>" "<SourceFormat>x-container/folder</SourceFormat>"
"<Title>%s</Title>" "<Title>%s</Title>"
"<TotalItems>%d</TotalItems>" "<TotalItems>%d</TotalItems>"
"</Details>" "</Details>"
"<Links>" "<Links>"
"<Content>" "<Content>"
"<Url>/TiVoConnect?Command=QueryContainer&amp;Container=%s</Url>" "<Url>/TiVoConnect?Command=QueryContainer&amp;Container=%s</Url>"
"<ContentType>x-tivo-container/folder</ContentType>" "<ContentType>x-tivo-container/folder</ContentType>"
"</Content>" "</Content>"
"</Links>", "</Links>",
unescape_tag(title), count, id); unescape_tag(title), count, id);
} }
ret = strcatf(str, "</Item>"); strcatf(str, "</Item>");
passed_args->returned++; passed_args->returned++;