diff --git a/metadata.c b/metadata.c
index 57f3abb..3ef0b36 100644
--- a/metadata.c
+++ b/metadata.c
@@ -210,26 +210,6 @@ dlna_timestamp_is_present(const char *filename, int *raw_packet_size)
return 0;
}
-#ifdef TIVO_SUPPORT
-int
-is_tivo_file(const char *path)
-{
- unsigned char buf[5];
- unsigned char hdr[5] = { 'T','i','V','o','\0' };
- int fd;
-
- /* read file header */
- fd = open(path, O_RDONLY);
- if( !fd )
- return 0;
- if( read(fd, buf, 5) < 0 )
- buf[0] = 'X';
- close(fd);
-
- return !memcmp(buf, hdr, 5);
-}
-#endif
-
void
check_for_captions(const char *path, int64_t detailID)
{
diff --git a/minidlna.c b/minidlna.c
index 9e9d4d9..255e5cf 100644
--- a/minidlna.c
+++ b/minidlna.c
@@ -90,10 +90,8 @@
#include "scanner.h"
#include "inotify.h"
#include "log.h"
-#ifdef TIVO_SUPPORT
#include "tivo_beacon.h"
#include "tivo_utils.h"
-#endif
#if SQLITE_VERSION_NUMBER < 3005001
# warning "Your SQLite3 library appears to be too old! Please use 3.5.1 or newer."
diff --git a/tivo_utils.c b/tivo_utils.c
index 13c32f8..f92e28f 100644
--- a/tivo_utils.c
+++ b/tivo_utils.c
@@ -140,4 +140,23 @@ TiVoRandomSeedFunc(sqlite3_context *context, int argc, sqlite3_value **argv)
seedRandomness(sizeof(r), &r, seed);
sqlite3_result_int64(context, r);
}
+
+int
+is_tivo_file(const char *path)
+{
+ unsigned char buf[5];
+ unsigned char hdr[5] = { 'T','i','V','o','\0' };
+ int fd;
+
+ /* read file header */
+ fd = open(path, O_RDONLY);
+ if( !fd )
+ return 0;
+ if( read(fd, buf, 5) < 0 )
+ buf[0] = 'X';
+ close(fd);
+
+ return !memcmp(buf, hdr, 5);
+}
+
#endif
diff --git a/tivo_utils.h b/tivo_utils.h
index d4d3462..d8756cf 100644
--- a/tivo_utils.h
+++ b/tivo_utils.h
@@ -22,6 +22,7 @@
* along with MiniDLNA. If not, see .
*/
#include "config.h"
+
#ifdef TIVO_SUPPORT
#include
@@ -37,4 +38,9 @@ decodeString(char *string, int inplace);
void
TiVoRandomSeedFunc(sqlite3_context *context, int argc, sqlite3_value **argv);
+int
+is_tivo_file(const char *path);
+
+#else
+#define decodeString(X, Y) ({})
#endif
diff --git a/upnphttp.c b/upnphttp.c
index 4165af7..6c5f7d3 100644
--- a/upnphttp.c
+++ b/upnphttp.c
@@ -75,10 +75,8 @@
#include "log.h"
#include "sql.h"
#include
-#ifdef TIVO_SUPPORT
#include "tivo_utils.h"
#include "tivo_commands.h"
-#endif
#include "sendfile.h"
@@ -1624,14 +1622,14 @@ SendResp_resizedimg(struct upnphttp * h, char * object)
int width=640, height=480, dstw, dsth, size;
int srcw, srch;
unsigned char * data = NULL;
- char *path, *file_path;
- char *resolution;
+ char *path, *file_path = NULL;
+ char *resolution = NULL;
char *key, *val;
- char *saveptr, *item=NULL;
+ char *saveptr, *item = NULL;
int rotate;
/* Not implemented yet *
char *pixelshape=NULL; */
- int64_t id;
+ long long id;
int rows=0, chunked, ret;
image_s *imsrc = NULL, *imdst = NULL;
int scale = 1;
@@ -1639,16 +1637,18 @@ SendResp_resizedimg(struct upnphttp * h, char * object)
id = strtoll(object, &saveptr, 10);
snprintf(buf, sizeof(buf), "SELECT PATH, RESOLUTION, ROTATION from DETAILS where ID = '%lld'", (long long)id);
ret = sql_get_table(db, buf, &result, &rows, NULL);
- if( (ret != SQLITE_OK) )
+ if( ret != SQLITE_OK )
{
- DPRINTF(E_ERROR, L_HTTP, "Didn't find valid file for %lld!\n", id);
Send500(h);
return;
}
- file_path = result[3];
- resolution = result[4];
- rotate = result[5] ? atoi(result[5]) : 0;
- if( !rows || !file_path || !resolution || (access(file_path, F_OK) != 0) )
+ if( rows )
+ {
+ file_path = result[3];
+ resolution = result[4];
+ rotate = result[5] ? atoi(result[5]) : 0;
+ }
+ if( !file_path || !resolution || (access(file_path, F_OK) != 0) )
{
DPRINTF(E_WARN, L_HTTP, "%s not found, responding ERROR 404\n", object);
sqlite3_free_table(result);
@@ -1661,9 +1661,7 @@ SendResp_resizedimg(struct upnphttp * h, char * object)
path = saveptr ? saveptr + 1 : object;
for( item = strtok_r(path, "&,", &saveptr); item != NULL; item = strtok_r(NULL, "&,", &saveptr) )
{
-#ifdef TIVO_SUPPORT
decodeString(item, 1);
-#endif
val = item;
key = strsep(&val, "=");
if( !val )