Commit 586b2913 authored by cRTrn13's avatar cRTrn13

fixed logging

parent fba8d177
......@@ -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;
}
......@@ -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_ */
#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);
}
}
......@@ -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_ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment