mirror of
https://github.com/ckolivas/lrzip.git
synced 2025-12-06 07:12:00 +01:00
add info callback which provides percentage completion of operation
This commit is contained in:
parent
6e702f49c4
commit
223a1107ea
|
|
@ -517,3 +517,11 @@ void lrzip_pass_cb_set(Lrzip *lr, Lrzip_Password_Cb cb, void *data)
|
|||
lr->control->pass_cb = (void*)cb;
|
||||
lr->control->pass_data = data;
|
||||
}
|
||||
|
||||
void lrzip_info_cb_set(Lrzip *lr, Lrzip_Info_Cb cb, void *data)
|
||||
{
|
||||
if (!lr) return;
|
||||
lr->control->info_cb = (void*)cb;
|
||||
lr->control->info_data = data;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ typedef enum {
|
|||
LRZIP_FLAG_ENCRYPT = (1 << 6)
|
||||
} Lrzip_Flag;
|
||||
|
||||
typedef void (*Lrzip_Info_Cb)(void *data, int pct, int chunk_pct);
|
||||
typedef void (*Lrzip_Log_Cb)(void *data, unsigned int level, unsigned int line, const char *file, const char *format, va_list args);
|
||||
typedef void (*Lrzip_Password_Cb)(void *, char **, size_t);
|
||||
|
||||
|
|
@ -108,5 +109,6 @@ FILE *lrzip_log_stdout_get(Lrzip *lr);
|
|||
void lrzip_log_stderr_set(Lrzip *lr, FILE *err);
|
||||
FILE *lrzip_log_stderr_get(Lrzip *lr);
|
||||
void lrzip_pass_cb_set(Lrzip *lr, Lrzip_Password_Cb cb, void *data);
|
||||
void lrzip_info_cb_set(Lrzip *lr, Lrzip_Info_Cb cb, void *data);
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -345,6 +345,8 @@ struct rzip_control {
|
|||
FILE *outputfile;
|
||||
char library_mode : 1;
|
||||
int log_level;
|
||||
void (*info_cb)(void *data, int pct, int chunk_pct);
|
||||
void *info_data;
|
||||
void (*log_cb)(void *data, unsigned int level, unsigned int line, const char *file, const char *func, const char *format, va_list);
|
||||
void *log_data;
|
||||
};
|
||||
|
|
|
|||
3
rzip.c
3
rzip.c
|
|
@ -635,6 +635,9 @@ static bool hash_search(rzip_control *control, struct rzip_state *st, double pct
|
|||
if (!STDIN || st->stdin_eof)
|
||||
print_progress("Total: %2d%% ", pct);
|
||||
print_progress("Chunk: %2d%%\r", chunk_pct);
|
||||
if (control->info_cb)
|
||||
control->info_cb(control->info_data,
|
||||
(!STDIN || st->stdin_eof) ? pct : -1, chunk_pct);
|
||||
lastpct = pct;
|
||||
last_chunkpct = chunk_pct;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue