]> wimlib.net Git - wimlib/blobdiff - src/split.c
header.c, lookup_table.c: Read/write data from structures
[wimlib] / src / split.c
index 5b14b924771451fd7c683ff4176209a60857750a..78dc8ab74d0ec40d107a104bfb3d3e1e3cbdd778 100644 (file)
  * along with wimlib; if not, see http://www.gnu.org/licenses/.
  */
 
-#include "wimlib_internal.h"
-#include "lookup_table.h"
-#include "xml.h"
-#include "buffer_io.h"
-#include <unistd.h>
-#include <fcntl.h>
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include "wimlib.h"
+#include "wimlib/endianness.h"
+#include "wimlib/error.h"
+#include "wimlib/file_io.h"
+#include "wimlib/lookup_table.h"
+#include "wimlib/metadata.h"
+#include "wimlib/types.h"
+#include "wimlib/write.h"
+#include "wimlib/list.h"
+
+#include <fcntl.h> /* for open() */
+#include <unistd.h> /* for close() */
 
 struct split_args {
        WIMStruct *w;
@@ -60,9 +70,9 @@ finish_swm(WIMStruct *w, struct list_head *lte_list,
 }
 
 static int
-copy_resource_to_swm(struct wim_lookup_table_entry *lte, void *__args)
+copy_resource_to_swm(struct wim_lookup_table_entry *lte, void *_args)
 {
-       struct split_args *args = (struct split_args*)__args;
+       struct split_args *args = (struct split_args*)_args;
        WIMStruct *w = args->w;
        int ret;
 
@@ -214,7 +224,7 @@ wimlib_split(WIMStruct *w, const tchar *swm_name,
        for (int i = 1; i <= total_parts; i++) {
                const tchar *part_name;
                int part_fd;
-               u8 part_data_buf[4];
+               le16 part_data[2];
                size_t bytes_written;
 
                if (i == 1) {
@@ -231,13 +241,13 @@ wimlib_split(WIMStruct *w, const tchar *swm_name,
                        ret = WIMLIB_ERR_OPEN;
                        goto out;
                }
-               put_u16(&part_data_buf[0], i);
-               put_u16(&part_data_buf[2], total_parts);
+               part_data[0] = cpu_to_le16(i);
+               part_data[1] = cpu_to_le16(total_parts);
 
-               bytes_written = full_pwrite(part_fd, part_data_buf,
-                                           sizeof(part_data_buf), 40);
+               bytes_written = full_pwrite(part_fd, part_data,
+                                           sizeof(part_data), 40);
                ret = close(part_fd);
-               if (bytes_written != sizeof(part_data_buf) || ret != 0) {
+               if (bytes_written != sizeof(part_data) || ret != 0) {
                        ERROR_WITH_ERRNO("Error updating header of `%"TS"'",
                                         part_name);
                        ret = WIMLIB_ERR_WRITE;