summaryrefslogtreecommitdiff
path: root/vmeta_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'vmeta_lib.c')
-rw-r--r--vmeta_lib.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/vmeta_lib.c b/vmeta_lib.c
index f1f5a98..cfb4dcf 100644
--- a/vmeta_lib.c
+++ b/vmeta_lib.c
@@ -356,23 +356,31 @@ static int get_version(const char *filename)
return version;
}
-static UNSG32 get_file_unsg32(const char *filename)
+static UNSG32 get_file_unsg32(const char *fmt, ...)
{
+ char buf[80];
+ va_list ap;
FILE *file;
UNSG32 result;
int ret;
- file = fopen(filename, "r");
+ va_start(ap, fmt);
+ ret = vsnprintf(buf, sizeof(buf), fmt, ap);
+ va_end(ap);
+ if (ret >= sizeof(buf))
+ return -VDEC_OS_DRIVER_OPEN_FAIL;
+
+ file = fopen(buf, "r");
if(!file) {
dbg_printf(VDEC_DEBUG_ALL, "Error: %s: fopen %s failed\n",
- __FUNCTION__, filename);
+ __FUNCTION__, buf);
return -VDEC_OS_DRIVER_OPEN_FAIL;
}
ret = fscanf(file, "0x%x", &result);
if (ret != 1) {
dbg_printf(VDEC_DEBUG_ALL, "Error: %s: fscanf %s failed\n",
- __FUNCTION__, filename);
+ __FUNCTION__, buf);
result = 0;
}