From 65bf6393daf8b7fd3c6f5e4ab878cd7c3816d1a1 Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Sun, 10 Mar 2024 22:50:24 +0100 Subject: [PATCH] Declare avrdude_message*() in library header file While these functions are *not* implemented by the library itself, they are supposed to be provided by whatever application is using the library. As such, they need to be declared in the public library header file, including the various constants for msglvl and msgmode. --- src/avrdude.h | 20 -------------------- src/libavrdude.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/avrdude.h b/src/avrdude.h index 3ab85e5a..522cd7c3 100644 --- a/src/avrdude.h +++ b/src/avrdude.h @@ -40,26 +40,6 @@ extern int quell_progress; // Quell progress report -q, reduce effective verbo extern const char *partdesc; // Part -p string extern const char *pgmid; // Programmer -c string -int avrdude_message(int msglvl, const char *format, ...); -int avrdude_message2(FILE *fp, int lno, const char *file, const char *func, int msgmode, int msglvl, const char *format, ...); - -#define MSG_EXT_ERROR (-3) // OS-type error, no -v option, can be suppressed with -qqqqq -#define MSG_ERROR (-2) // Avrdude error, no -v option, can be suppressed with -qqqq -#define MSG_WARNING (-1) // Warning, no -v option, can be suppressed with -qqq -#define MSG_INFO 0 // Commentary, no -v option, can be suppressed with -qq -#define MSG_NOTICE 1 // Displayed with -v -#define MSG_NOTICE2 2 // Displayed with -vv -#define MSG_DEBUG 3 // Displayed with -vvv -#define MSG_TRACE 4 // Displayed with -vvvv, show trace communication -#define MSG_TRACE2 5 // Displayed with -vvvvv - -#define MSG2_PROGNAME 1 // Start by printing progname -#define MSG2_FUNCTION 2 // Print calling function (1st arg) after progname if >= notice -#define MSG2_FILELINE 4 // Print source file and line number after function if >= debug -#define MSG2_TYPE 8 // Print message type after function or progname -#define MSG2_INDENT1 16 // Start by printing indentation of progname+1 blanks -#define MSG2_INDENT2 32 // Start by printing indentation of progname+2 blanks -#define MSG2_FLUSH 64 // Flush before and after printing // Shortcuts #define msg_ext_error(...) avrdude_message2(stderr, __LINE__, __FILE__, __func__, 0, MSG_EXT_ERROR, __VA_ARGS__) diff --git a/src/libavrdude.h b/src/libavrdude.h index 4b87a983..fbb9a698 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -60,6 +60,34 @@ typedef uint32_t pinmask_t; #define LIBAVRDUDE_SOFTFAIL (-3) // returned, eg, by avr_signature() if caller // might proceed with chip erase +/* Message system */ +/* These 2 functions are supposed to be supplied by the application */ + +int avrdude_message(int msglvl, const char *format, ...); +int avrdude_message2(FILE *fp, int lno, const char *file, const char *func, int msgmode, int msglvl, const char *format, ...); + +enum msglvl { + MSG_EXT_ERROR = (-3), // OS-type error, no -v option, can be suppressed with -qqqqq + MSG_ERROR = (-2), // Avrdude error, no -v option, can be suppressed with -qqqq + MSG_WARNING = (-1), // Warning, no -v option, can be suppressed with -qqq + MSG_INFO = 0, // Commentary, no -v option, can be suppressed with -qq + MSG_NOTICE = 1, // Displayed with -v + MSG_NOTICE2 = 2, // Displayed with -vv + MSG_DEBUG = 3, // Displayed with -vvv + MSG_TRACE = 4, // Displayed with -vvvv, show trace communication + MSG_TRACE2 = 5, // Displayed with -vvvvv +}; + +enum msgmode { + MSG2_PROGNAME = 1, // Start by printing progname + MSG2_FUNCTION = 2, // Print calling function (1st arg) after progname if >= notice + MSG2_FILELINE = 4, // Print source file and line number after function if >= debug + MSG2_TYPE = 8, // Print message type after function or progname + MSG2_INDENT1 = 16, // Start by printing indentation of progname+1 blanks + MSG2_INDENT2 = 32, // Start by printing indentation of progname+2 blanks + MSG2_FLUSH = 64, // Flush before and after printing +}; + /* formerly lists.h */ /*----------------------------------------------------------------------