From 586b2913988869fe401b70389801ee18d3b1d022 Mon Sep 17 00:00:00 2001 From: cRTrn13 Date: Mon, 19 Oct 2009 09:12:08 +0000 Subject: [PATCH] fixed logging --- src/bluray.c | 23 +++++++++++++++++++++++ src/bluray.h | 3 +-- src/util/logging.c | 34 ++++++++++++++++++++++++++++++++++ src/util/logging.h | 33 --------------------------------- 4 files changed, 58 insertions(+), 35 deletions(-) create mode 100644 src/util/logging.c diff --git a/src/bluray.c b/src/bluray.c index 63cd706d..dc6a73fa 100644 --- a/src/bluray.c +++ b/src/bluray.c @@ -13,6 +13,7 @@ BLURAY *bd_open(const char* device_path, const char* keyfile_path) bd->aacs = NULL; bd->h_libaacs = NULL; bd->fp = NULL; + strncpy(bd->device_path, device_path, 100); // open aacs decryptor if present if ((bd->h_libaacs = dlopen("libaacs.so", RTLD_LAZY))) { @@ -83,3 +84,25 @@ int bd_read(BLURAY *bd, unsigned char *buf, int len) return 0; } + +int bd_select_title(BLURAY *bd, uint64_t title) +{ + char f_name[100]; + + memset(f_name, 0, sizeof(f_name)); + snprintf(f_name, 100, "%s/BDMV/STREAM/%05ld.m2ts", bd->device_path, title); + + bd->s_size = 0; + bd->s_pos = 0; + + if ((bd->fp = file_open(f_name, "rb"))) { + file_seek(bd->fp, 0, SEEK_END); + if ((bd->s_size = file_tell(bd->fp))) { + file_seek(bd->fp, 0, SEEK_SET); + + return 1; + } + } + + return 0; +} diff --git a/src/bluray.h b/src/bluray.h index 8a2168cc..66ec0ff4 100644 --- a/src/bluray.h +++ b/src/bluray.h @@ -14,7 +14,6 @@ typedef struct bluray BLURAY; struct bluray { char device_path[100]; FILE_H *fp; - uint64_t title; uint64_t s_size; off_t s_pos; AACS_KEYS *aacs; @@ -24,8 +23,8 @@ struct bluray { BLURAY *bd_open(const char* device_path, const char* keyfile_path); void bd_close(BLURAY *bd); -void bd_select_title(BLURAY *bd, uint64_t title); off_t bd_seek(BLURAY *bd, uint64_t pos); int bd_read(BLURAY *bd, unsigned char *buf, int len); +int bd_select_title(BLURAY *bd, uint64_t title); #endif /* BLURAY_H_ */ diff --git a/src/util/logging.c b/src/util/logging.c new file mode 100644 index 00000000..efa86323 --- /dev/null +++ b/src/util/logging.c @@ -0,0 +1,34 @@ + +#include "logging.h" + +const uint32_t master_mask = 0xffff; // this is only temporary +char out[512]; + +char *print_hex(uint8_t *buf, int count) +{ + memset(out, 0, count); + + int zz; + for(zz = 0; zz < count; zz++) { + sprintf(out + (zz * 2), "%02X", buf[zz]); + } + + return out; +} + +void debug(char *file, int line, uint32_t mask, const char *format, ...) +{ + uint32_t type = (mask & master_mask) & 0xfffe, + verbose = !((!(master_mask & 1)) & (mask & 1)); + + if (type && verbose) { + char buffer[512]; + va_list args; + + va_start(args, format); + vsprintf(buffer, format, args); + va_end(args); + + fprintf(stderr, "%s:%d: %s", file, line, buffer); + } +} diff --git a/src/util/logging.h b/src/util/logging.h index 390944ff..9c6d138d 100644 --- a/src/util/logging.h +++ b/src/util/logging.h @@ -18,40 +18,7 @@ enum { DBG_BLURAY = 64 } debug_mask; -const uint32_t master_mask = 0xffff; // this is only temporary -char out[512]; - char *print_hex(uint8_t *str, int count); void debug(char *file, int line, uint32_t mask, const char *format, ...); - -char *print_hex(uint8_t *buf, int count) -{ - memset(out, 0, count); - - int zz; - for(zz = 0; zz < count; zz++) { - sprintf(out + (zz * 2), "%02X", buf[zz]); - } - - return out; -} - -void debug(char *file, int line, uint32_t mask, const char *format, ...) -{ - uint32_t type = (mask & master_mask) & 0xfffe, - verbose = !((!(master_mask & 1)) & (mask & 1)); - - if (type && verbose) { - char buffer[512]; - va_list args; - - va_start(args, format); - vsprintf(buffer, format, args); - va_end(args); - - fprintf(stderr, "%s:%d: %s", file, line, buffer); - } -} - #endif /* LOGGING_H_ */ -- GitLab