1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-28 07:23:43 +02:00

Adapt CLI to use new libflashrom interface' print callback

This renames CLI's print() to flashrom_print_cb() and registers it
through the new libflashrom interface.

v2: Add libflashrom.o to LIB_OBJS now that everything can be linked
    together.

Change-Id: Idf19978eb8e340d258199193d2978f37409e9983
Signed-off-by: Nico Huber <nico.huber@secunet.com>
Reviewed-on: https://review.coreboot.org/17948
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: David Hendricks <david.hendricks@gmail.com>
This commit is contained in:
Nico Huber 2012-12-10 13:34:12 +00:00 committed by David Hendricks
parent a9fc4f4ebf
commit 1878110848
4 changed files with 12 additions and 8 deletions

View File

@ -519,7 +519,7 @@ CHIP_OBJS = jedec.o stm50.o w39.o w29ee011.o \
############################################################################### ###############################################################################
# Library code. # 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. # Frontend related stuff.

View File

@ -30,6 +30,7 @@
#include "flash.h" #include "flash.h"
#include "flashchips.h" #include "flashchips.h"
#include "programmer.h" #include "programmer.h"
#include "libflashrom.h"
static void cli_classic_usage(const char *name) static void cli_classic_usage(const char *name)
{ {
@ -135,6 +136,8 @@ int main(int argc, char *argv[])
char *tempstr = NULL; char *tempstr = NULL;
char *pparam = NULL; char *pparam = NULL;
flashrom_set_log_callback((flashrom_log_callback *)&flashrom_print_cb);
print_version(); print_version();
print_banner(); print_banner();

View File

@ -71,19 +71,19 @@ void start_logging(void)
#endif /* !STANDALONE */ #endif /* !STANDALONE */
/* Please note that level is the verbosity, not the importance of the message. */ /* 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; int ret = 0;
FILE *output_type = stdout; FILE *output_type = stdout;
va_list logfile_args;
va_copy(logfile_args, ap);
if (level < MSG_INFO) if (level < MSG_INFO)
output_type = stderr; output_type = stderr;
if (level <= verbose_screen) { if (level <= verbose_screen) {
va_start(ap, fmt);
ret = vfprintf(output_type, fmt, ap); ret = vfprintf(output_type, fmt, ap);
va_end(ap);
/* msg_*spew often happens inside chip accessors in possibly /* msg_*spew often happens inside chip accessors in possibly
* time-critical operations. Don't slow them down by flushing. */ * time-critical operations. Don't slow them down by flushing. */
if (level != MSG_SPEW) if (level != MSG_SPEW)
@ -91,12 +91,11 @@ int print(enum msglevel level, const char *fmt, ...)
} }
#ifndef STANDALONE #ifndef STANDALONE
if ((level <= verbose_logfile) && logfile) { if ((level <= verbose_logfile) && logfile) {
va_start(ap, fmt); ret = vfprintf(logfile, fmt, logfile_args);
ret = vfprintf(logfile, fmt, ap);
va_end(ap);
if (level != MSG_SPEW) if (level != MSG_SPEW)
fflush(logfile); fflush(logfile);
} }
#endif /* !STANDALONE */ #endif /* !STANDALONE */
va_end(logfile_args);
return ret; return ret;
} }

View File

@ -30,6 +30,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdint.h> #include <stdint.h>
#include <stddef.h> #include <stddef.h>
#include <stdarg.h>
#include <stdbool.h> #include <stdbool.h>
#if IS_WINDOWS #if IS_WINDOWS
#include <windows.h> #include <windows.h>
@ -321,6 +322,7 @@ enum msglevel {
MSG_DEBUG2 = 4, MSG_DEBUG2 = 4,
MSG_SPEW = 5, 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. */ /* Let gcc and clang check for correct printf-style format strings. */
int print(enum msglevel level, const char *fmt, ...) int print(enum msglevel level, const char *fmt, ...)
#ifdef __MINGW32__ #ifdef __MINGW32__