Skip to content

Commit

Permalink
Declare avrdude_message*() in library header file
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dl8dtl committed Mar 10, 2024
1 parent e986f16 commit 65bf639
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
20 changes: 0 additions & 20 deletions src/avrdude.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
28 changes: 28 additions & 0 deletions src/libavrdude.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

/*----------------------------------------------------------------------
Expand Down

0 comments on commit 65bf639

Please sign in to comment.