]> wimlib.net Git - wimlib/blob - include/wimlib/progress.h
Update progress functions
[wimlib] / include / wimlib / progress.h
1 #ifndef _WIMLIB_PROGRESS_H
2 #define _WIMLIB_PROGRESS_H
3
4 #include "wimlib.h"
5
6 /* If specified, call the user-provided progress function and check its result.
7  */
8 static inline int
9 call_progress(wimlib_progress_func_t progfunc,
10               enum wimlib_progress_msg msg,
11               union wimlib_progress_info *info,
12               void *progctx)
13 {
14         if (progfunc) {
15                 enum wimlib_progress_status status;
16
17                 status = (*progfunc)(msg, info, progctx);
18
19                 switch (status) {
20                 case WIMLIB_PROGRESS_STATUS_CONTINUE:
21                         return 0;
22                 case WIMLIB_PROGRESS_STATUS_ABORT:
23                         return WIMLIB_ERR_ABORTED_BY_PROGRESS;
24                 default:
25                         return WIMLIB_ERR_UNKNOWN_PROGRESS_STATUS;
26                 }
27         }
28         return 0;
29 }
30
31 #endif