X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=examples%2Fapplywim.c;h=824752b0e349b566e3df6bbaca407ee25f742056;hp=a92b26376a8b50ab29df13e56ba5519c730ba417;hb=de58d5f57732df8129fbfd71d46ae5968ac59646;hpb=c3a1bd96026fd5a1d43c5f6178f9f0165afdd098 diff --git a/examples/applywim.c b/examples/applywim.c index a92b2637..824752b0 100644 --- a/examples/applywim.c +++ b/examples/applywim.c @@ -1,5 +1,8 @@ /* * applywim.c - A program to extract the first image from a WIM file. + * + * The author dedicates this file to the public domain. + * You can do whatever you want with this file. */ #include @@ -8,9 +11,9 @@ #define TO_PERCENT(numerator, denominator) \ ((float)(((denominator) == 0) ? 0 : ((numerator) * 100 / (float)(denominator)))) -static int +static enum wimlib_progress_status extract_progress(enum wimlib_progress_msg msg, - const union wimlib_progress_info *info) + union wimlib_progress_info *info, void *progctx) { switch (msg) { case WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS: @@ -21,7 +24,7 @@ extract_progress(enum wimlib_progress_msg msg, default: break; } - return 0; + return WIMLIB_PROGRESS_STATUS_CONTINUE; } int main(int argc, char **argv) @@ -43,17 +46,18 @@ int main(int argc, char **argv) /* Open the WIM file as a WIMStruct. */ ret = wimlib_open_wim(wimpath, /* Path of WIM file to open */ 0, /* WIMLIB_OPEN_FLAG_* flags (0 means all defaults) */ - &wim, /* Return the WIMStruct pointer in this location */ - NULL); /* Progress function (NULL means none) */ + &wim); /* Return the WIMStruct pointer in this location */ if (ret != 0) /* Always should check the error codes. */ goto out; + /* Register our progress function. */ + wimlib_register_progress_function(wim, extract_progress, NULL); + /* Extract the first image. */ ret = wimlib_extract_image(wim, /* WIMStruct from which to extract the image */ 1, /* Image to extract */ destdir, /* Directory to extract the image to */ - 0, /* WIMLIB_EXTRACT_FLAG_* flags (0 means all defaults) */ - extract_progress); /* Progress function */ + 0); /* WIMLIB_EXTRACT_FLAG_* flags (0 means all defaults) */ out: /* Free the WIMStruct. Has no effect if the pointer to it is NULL. */