diff options
author | David Teirney <david@teirney.net> | 2012-04-16 23:05:46 +1200 |
---|---|---|
committer | David Teirney <david@teirney.net> | 2012-05-01 23:22:43 +1200 |
commit | f0d16e9bfdb97a3653e7efcecfe77c21ff73d827 (patch) | |
tree | aa7143480b38504e54cb580a819d1be8f303a20e /lib/cmyth/libcmyth/file.c | |
parent | 3eda5d30bff0917c01bbdb0f91c7868479bae6d1 (diff) |
Add support for myth protocol 66.
All 64 bit integers are now passed and received as a single 64 bit number rather than two 32 bit hi and lo integers.
Diffstat (limited to 'lib/cmyth/libcmyth/file.c')
-rw-r--r-- | lib/cmyth/libcmyth/file.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/lib/cmyth/libcmyth/file.c b/lib/cmyth/libcmyth/file.c index 74408ed0c9..640f29989a 100644 --- a/lib/cmyth/libcmyth/file.c +++ b/lib/cmyth/libcmyth/file.c @@ -20,6 +20,7 @@ #include <stdio.h> #include <stdlib.h> #include <errno.h> +#include <inttypes.h> #ifndef _MSC_VER #include <sys/socket.h> #endif @@ -449,14 +450,28 @@ cmyth_file_seek(cmyth_file_t file, long long offset, int whence) pthread_mutex_lock(&mutex); - snprintf(msg, sizeof(msg), - "QUERY_FILETRANSFER %ld[]:[]SEEK[]:[]%d[]:[]%d[]:[]%d[]:[]%d[]:[]%d", - file->file_id, - (int32_t)(offset >> 32), - (int32_t)(offset & 0xffffffff), - whence, - (int32_t)(file->file_pos >> 32), - (int32_t)(file->file_pos & 0xffffffff)); + if (file->file_control->conn_version >= 66) { + /* + * Since protocol 66 mythbackend expects to receive a single 64 bit integer rather than + * two 32 bit hi and lo integers. + */ + snprintf(msg, sizeof(msg), + "QUERY_FILETRANSFER %ld[]:[]SEEK[]:[]%"PRIu64"[]:[]%d[]:[]%"PRIu64, + file->file_id, + (int64_t)offset, + whence, + (int64_t)file->file_pos); + } + else { + snprintf(msg, sizeof(msg), + "QUERY_FILETRANSFER %ld[]:[]SEEK[]:[]%d[]:[]%d[]:[]%d[]:[]%d[]:[]%d", + file->file_id, + (int32_t)(offset >> 32), + (int32_t)(offset & 0xffffffff), + whence, + (int32_t)(file->file_pos >> 32), + (int32_t)(file->file_pos & 0xffffffff)); + } if ((err = cmyth_send_message(file->file_control, msg)) < 0) { cmyth_dbg(CMYTH_DBG_ERROR, |