]> wimlib.net Git - wimlib/blobdiff - src/wim.c
Use WIM_LINK_TYPE_NONE as default, as documented
[wimlib] / src / wim.c
index eb33bd399a36fe8dd79d5dd90499699ea4a38546..99a8c70072e89c1f1a6b563bc88ba229f09ed7cf 100644 (file)
--- a/src/wim.c
+++ b/src/wim.c
@@ -1,24 +1,27 @@
 /*
  * wim.c
- *
- *
+ */
+
+/*
  * Copyright (C) 2010 Carl Thijssen
  * Copyright (C) 2012 Eric Biggers
  *
  * wimlib - Library for working with WIM files 
  *
- * This library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or (at your option) any
- * later version.
+ * This file is part of wimlib, a library for working with WIM files.
+ *
+ * wimlib is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
  *
- * This library is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * wimlib is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
  *
- * You should have received a copy of the GNU Lesser General Public License along
- * with this library; if not, write to the Free Software Foundation, Inc., 59
- * Temple Place, Suite 330, Boston, MA 02111-1307 USA 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with wimlib; if not, see http://www.gnu.org/licenses/.
  */
 
 #include "wimlib_internal.h"
@@ -29,7 +32,7 @@
 
 static int print_metadata(WIMStruct *w)
 {
-#if 0
+#ifdef ENABLE_SECURITY_DATA
        print_security_data(wim_security_data(w));
 #endif
        return for_dentry_in_tree(wim_root_dentry(w), print_dentry, 
@@ -50,8 +53,8 @@ WIMStruct *new_wim_struct()
        w = CALLOC(1, sizeof(WIMStruct));
        if (!w)
                return NULL;
-       w->link_type      = WIM_LINK_TYPE_HARD;
-       w->current_image  = WIM_NO_IMAGE;
+       w->link_type     = WIM_LINK_TYPE_NONE;
+       w->current_image = WIM_NO_IMAGE;
        return w;
 }
 
@@ -63,7 +66,7 @@ WIMStruct *new_wim_struct()
  */
 int for_image(WIMStruct *w, int image, int (*visitor)(WIMStruct *))
 {
-       int ret;
+       int ret = 0;
        int i;
        int image_count;
 
@@ -220,10 +223,11 @@ int wimlib_select_image(WIMStruct *w, int image)
                DEBUG("Freeing image %u\n", w->current_image);
                imd = wim_get_current_image_metadata(w);
                free_dentry_tree(imd->root_dentry, NULL, false);
-#if 0
-               destroy_security_data(&imd->security_data);
-#endif
                imd->root_dentry = NULL;
+#ifdef ENABLE_SECURITY_DATA
+               free_security_data(imd->security_data);
+               imd->security_data = NULL;
+#endif
        }
 
        w->current_image = image;
@@ -239,8 +243,7 @@ int wimlib_select_image(WIMStruct *w, int image)
                return read_metadata_resource(w->fp, 
                                wim_metadata_resource_entry(w),
                                wimlib_get_compression_type(w), 
-                               /*wim_security_data(w), */
-                               wim_root_dentry_p(w));
+                               wim_get_current_image_metadata(w));
        }
 }
 
@@ -579,9 +582,13 @@ WIMLIBAPI void wimlib_free(WIMStruct *w)
        FREE(w->xml_data);
        free_wim_info(w->wim_info);
        if (w->image_metadata) {
-               for (i = 0; i < w->hdr.image_count; i++)
+               for (i = 0; i < w->hdr.image_count; i++) {
                        free_dentry_tree(w->image_metadata[i].root_dentry, 
                                         NULL, false);
+                       #ifdef ENABLE_SECURITY_DATA
+                       free_security_data(w->image_metadata[i].security_data);
+                       #endif
+               }
                FREE(w->image_metadata);
        }
        FREE(w);