From 4297c45174964231ccd4177362864545adfdda1c Mon Sep 17 00:00:00 2001 From: David Phillips Date: Fri, 28 Aug 2015 23:10:16 +1200 Subject: Created wrapper to get integer from formatted filename --- common.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'common.c') diff --git a/common.c b/common.c index ca10543..46a3105 100644 --- a/common.c +++ b/common.c @@ -18,6 +18,30 @@ #include "paramano.h" +#include + + +int get_int_value_from_filef(const char* format, ...) +{ + int value = 0; + va_list a; + va_start(a, format); + value = vget_int_value_from_filef(format, a); + va_end(a); + + return value; +} + +int vget_int_value_from_filef(const char* format, va_list args) +{ + + char filename[1024]; + if (vsnprintf(filename, sizeof(filename), format, args) == sizeof(filename)) + fprintf(stderr, "WARN: filename buffer too small"); + return get_int_value_from_file(filename); +} + + /*********************************************************************** * Return integer value from first line in file **********************************************************************/ -- cgit v1.1