]> wimlib.net Git - wimlib/blobdiff - examples/applywim.c
wimlib.h: remove old ADD_IMAGE_FLAG aliases
[wimlib] / examples / applywim.c
index a92b26376a8b50ab29df13e56ba5519c730ba417..824752b0e349b566e3df6bbaca407ee25f742056 100644 (file)
@@ -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 <wimlib.h>
@@ -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.  */