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