Commit 67d80d2e authored by npzacs's avatar npzacs
Browse files

Cosmetics (move function)

parent 4e396e31
......@@ -397,6 +397,38 @@ static AACS_FILE_H *_file_open(AACS *aacs, const char *file)
return fp;
}
static size_t _read_file(AACS *aacs, const char *file, void **data)
{
AACS_FILE_H *fp = NULL;
int64_t f_size;
*data = NULL;
fp = _file_open(aacs, file);
if (!fp) {
BD_DEBUG(DBG_AACS | DBG_CRIT, "Unable to open %s\n", file);
return 0;
}
file_seek(fp, 0, SEEK_END);
f_size = file_tell(fp);
file_seek(fp, 0, SEEK_SET);
*data = malloc(f_size);
if (*data) {
if (file_read(fp, *data, f_size) != f_size) {
BD_DEBUG(DBG_AACS | DBG_CRIT, "Failed reading %s\n", file);
X_FREE(*data);
}
} else {
BD_DEBUG(DBG_AACS | DBG_CRIT, "Out of memory\n");
}
file_close(fp);
return *data ? f_size : 0;
}
static MKB *_mkb_open(AACS *aacs)
{
AACS_FILE_H *fp;
......@@ -847,38 +879,6 @@ static int _calc_title_hash(AACS *aacs)
return result;
}
static size_t _read_file(AACS *aacs, const char *file, void **data)
{
AACS_FILE_H *fp = NULL;
int64_t f_size;
*data = NULL;
fp = _file_open(aacs, file);
if (!fp) {
BD_DEBUG(DBG_AACS | DBG_CRIT, "Unable to open %s\n", file);
return 0;
}
file_seek(fp, 0, SEEK_END);
f_size = file_tell(fp);
file_seek(fp, 0, SEEK_SET);
*data = malloc(f_size);
if (*data) {
if (file_read(fp, *data, f_size) != f_size) {
BD_DEBUG(DBG_AACS | DBG_CRIT, "Failed reading %s\n", file);
X_FREE(*data);
}
} else {
BD_DEBUG(DBG_AACS | DBG_CRIT, "Out of memory\n");
}
file_close(fp);
return *data ? f_size : 0;
}
static CONTENT_CERT *_read_cc_any(AACS *aacs)
{
CONTENT_CERT *cc = NULL;
......
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