diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | cli_classic.c | 3 | ||||
-rw-r--r-- | cli_output.c | 13 | ||||
-rw-r--r-- | flash.h | 2 |
4 files changed, 12 insertions, 8 deletions
@@ -519,7 +519,7 @@ CHIP_OBJS = jedec.o stm50.o w39.o w29ee011.o \ ############################################################################### # Library code. -LIB_OBJS = layout.o flashrom.o udelay.o programmer.o helpers.o +LIB_OBJS = libflashrom.o layout.o flashrom.o udelay.o programmer.o helpers.o ############################################################################### # Frontend related stuff. diff --git a/cli_classic.c b/cli_classic.c index a2c20141..984a4dac 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) { @@ -135,6 +136,8 @@ int main(int argc, char *argv[]) char *tempstr = NULL; char *pparam = NULL; + flashrom_set_log_callback((flashrom_log_callback *)&flashrom_print_cb); + print_version(); print_banner(); diff --git a/cli_output.c b/cli_output.c index feafbd20..e6979850 100644 --- a/cli_output.c +++ b/cli_output.c @@ -71,19 +71,19 @@ 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 flashrom_print_cb(enum msglevel level, const char *fmt, va_list ap) { - va_list ap; int ret = 0; FILE *output_type = stdout; + va_list logfile_args; + va_copy(logfile_args, ap); + if (level < MSG_INFO) output_type = stderr; if (level <= verbose_screen) { - va_start(ap, fmt); ret = vfprintf(output_type, fmt, ap); - va_end(ap); /* msg_*spew often happens inside chip accessors in possibly * time-critical operations. Don't slow them down by flushing. */ if (level != MSG_SPEW) @@ -91,12 +91,11 @@ 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); + ret = vfprintf(logfile, fmt, logfile_args); if (level != MSG_SPEW) fflush(logfile); } #endif /* !STANDALONE */ + va_end(logfile_args); return ret; } @@ -30,6 +30,7 @@ #include <stdio.h> #include <stdint.h> #include <stddef.h> +#include <stdarg.h> #include <stdbool.h> #if IS_WINDOWS #include <windows.h> @@ -321,6 +322,7 @@ enum msglevel { MSG_DEBUG2 = 4, MSG_SPEW = 5, }; +int flashrom_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, ...) #ifdef __MINGW32__ |