From 03aa193722cdebdd56b13b47db5e6adab7fb3976 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 2 Apr 2026 23:12:17 +0100 Subject: [PATCH] Introduce int (*updatehook)() --- src/libavrdude.h | 3 +++ src/pgm.c | 1 + src/update.c | 3 +++ 3 files changed, 7 insertions(+) diff --git a/src/libavrdude.h b/src/libavrdude.h index 9ba7ca23..358ad76c 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -981,6 +981,8 @@ typedef struct { unsigned long ms[LED_N]; // Time in ms after last physical change } Leds; +typedef struct update UPDATE; + /* * Any changes in PROGRAMMER, please also ensure changes are made in * - lexer.l @@ -1077,6 +1079,7 @@ typedef struct programmer { void (*teardown)(PROGRAMMER *pgm); int (*flash_readhook)(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *flm, const char *fname, int size); + int (*updatehook)(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, int flags); // Cached r/w API for terminal reads/writes int (*write_byte_cached)(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, diff --git a/src/pgm.c b/src/pgm.c index 72c5413e..c20703b6 100644 --- a/src/pgm.c +++ b/src/pgm.c @@ -119,6 +119,7 @@ void pgm_init_functions(PROGRAMMER *pgm) { pgm->parseextparams = NULL; pgm->readonly = NULL; pgm->flash_readhook = NULL; + pgm->updatehook = NULL; } PROGRAMMER *pgm_new(void) { diff --git a/src/update.c b/src/update.c index 0fb5ac2c..cf127615 100644 --- a/src/update.c +++ b/src/update.c @@ -640,6 +640,9 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, const UPDATE *upd, enum updat Filestats fs; const char *umstr = upd->memstr; + if(pgm->updatehook) + pgm->updatehook(pgm, p, upd, flags); + if(!(flags & UF_NOHEADING)) { char *heading = update_str(upd);