diff options
Diffstat (limited to 'libflashrom.c')
-rw-r--r-- | libflashrom.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libflashrom.c b/libflashrom.c index e70c1d1a..0c6613e9 100644 --- a/libflashrom.c +++ b/libflashrom.c @@ -65,6 +65,25 @@ int print(const enum flashrom_log_level level, const char *const fmt, ...) return 0; } +void flashrom_set_progress_callback(struct flashrom_flashctx *flashctx, flashrom_progress_callback *progress_callback, struct flashrom_progress *progress_state) +{ + flashctx->progress_callback = progress_callback; + flashctx->progress_state = progress_state; +} +/** @private */ +void update_progress(struct flashrom_flashctx *flashctx, enum flashrom_progress_stage stage, size_t current, size_t total) +{ + if (flashctx->progress_callback == NULL) + return; + if (current > total) + current = total; + + flashctx->progress_state->stage = stage; + flashctx->progress_state->current = current; + flashctx->progress_state->total = total; + flashctx->progress_callback(flashctx); +} + const char *flashrom_version_info(void) { return flashrom_version; |