This renames CLI's print() to fl_print_cb() and registers it through the new libflashrom interface.
Signed-off-by: Nico Huber nico.huber@secunet.com --- cli_classic.c | 3 +++ cli_output.c | 7 +------ flash.h | 2 ++ 3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/cli_classic.c b/cli_classic.c index 63565cb..073d95a 100644 --- a/cli_classic.c +++ b/cli_classic.c @@ -30,6 +30,7 @@ #include "flash.h" #include "flashchips.h" #include "programmer.h" +#include "libflashrom.h"
static void cli_classic_usage(const char *name) { @@ -134,6 +135,8 @@ int main(int argc, char *argv[]) char *tempstr = NULL; char *pparam = NULL;
+ fl_set_log_callback((fl_log_callback_t *)&fl_print_cb); + print_version(); print_banner();
diff --git a/cli_output.c b/cli_output.c index 57a0a05..b3d86b2 100644 --- a/cli_output.c +++ b/cli_output.c @@ -68,9 +68,8 @@ void start_logging(void) #endif /* !STANDALONE */
/* Please note that level is the verbosity, not the importance of the message. */ -int print(enum msglevel level, const char *fmt, ...) +int fl_print_cb(enum msglevel level, const char *fmt, va_list ap) { - va_list ap; int ret = 0; FILE *output_type = stdout;
@@ -78,9 +77,7 @@ int print(enum msglevel level, const char *fmt, ...) output_type = stderr;
if (level <= verbose_screen) { - va_start(ap, fmt); ret = vfprintf(output_type, fmt, ap); - va_end(ap); /* msg_*spew usually happens inside chip accessors in possibly * time-critical operations. Don't slow them down by flushing. */ @@ -89,9 +86,7 @@ int print(enum msglevel level, const char *fmt, ...) } #ifndef STANDALONE if ((level <= verbose_logfile) && logfile) { - va_start(ap, fmt); ret = vfprintf(logfile, fmt, ap); - va_end(ap); if (level != MSG_SPEW) fflush(logfile); } diff --git a/flash.h b/flash.h index a4cdde2..9a2ee29 100644 --- a/flash.h +++ b/flash.h @@ -26,6 +26,7 @@
#include <stdint.h> #include <stddef.h> +#include <stdarg.h> #ifdef _WIN32 #include <windows.h> #undef min @@ -275,6 +276,7 @@ enum msglevel { MSG_DEBUG2 = 3, MSG_SPEW = 4, }; +int fl_print_cb(enum msglevel level, const char *fmt, va_list ap); /* Let gcc and clang check for correct printf-style format strings. */ int print(enum msglevel level, const char *fmt, ...) __attribute__((format(printf, 2, 3))); #define msg_gerr(...) print(MSG_ERROR, __VA_ARGS__) /* general errors */