]> wimlib.net Git - wimlib/commitdiff
wimlib.h: C++ compatibility
authorEric Biggers <ebiggers3@gmail.com>
Tue, 27 Aug 2013 17:34:01 +0000 (12:34 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Tue, 27 Aug 2013 17:34:01 +0000 (12:34 -0500)
include/wimlib.h
programs/imagex.c
src/update_image.c

index acc9c0c6e1dd41d519786772c7dccfb948b2535c..32482032149e7e43df140eef5a9b5b39d832693f 100644 (file)
 /** Patch version of the library (for example, the 5 in 1.2.5). */
 #define WIMLIB_PATCH_VERSION 0
 
 /** Patch version of the library (for example, the 5 in 1.2.5). */
 #define WIMLIB_PATCH_VERSION 0
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /**
  * Opaque structure that represents a WIM file.  This is an in-memory structure
  * and need not correspond to a specific on-disk file.  However, a ::WIMStruct
 /**
  * Opaque structure that represents a WIM file.  This is an in-memory structure
  * and need not correspond to a specific on-disk file.  However, a ::WIMStruct
@@ -1394,6 +1398,50 @@ typedef int (*wimlib_iterate_lookup_table_callback_t)(const struct wimlib_resour
  * @}
  */
 
  * @}
  */
 
+/** Data for a ::WIMLIB_UPDATE_OP_ADD operation. */
+struct wimlib_add_command {
+       /** Filesystem path to the file or directory tree to
+        * add. */
+       wimlib_tchar *fs_source_path;
+       /** Path, specified from the root of the WIM image, at
+        * which to add the file or directory tree within the
+        * WIM image. */
+       wimlib_tchar *wim_target_path;
+
+       /** Configuration for excluded files.  @c NULL means
+        * exclude no files (use no configuration), unless
+        * ::WIMLIB_ADD_FLAG_WINCONFIG is specified in @p
+        * add_flags.  */
+       struct wimlib_capture_config *config;
+
+       /** Bitwise OR of WIMLIB_ADD_FLAG_* flags. */
+       int add_flags;
+};
+
+/** Data for a ::WIMLIB_UPDATE_OP_DELETE operation. */
+struct wimlib_delete_command {
+       /** Path, specified from the root of the WIM image, for
+        * the file or directory tree within the WIM image to be
+        * deleted. */
+       wimlib_tchar *wim_path;
+       /** Bitwise OR of WIMLIB_DELETE_FLAG_* flags. */
+       int delete_flags;
+};
+
+/** Data for a ::WIMLIB_UPDATE_OP_RENAME operation. */
+struct wimlib_rename_command {
+       /** Path, specified from the root of the WIM image, for
+        * the source file or directory tree within the WIM
+        * image. */
+       wimlib_tchar *wim_source_path;
+       /** Path, specified from the root of the WIM image, for
+        * the destination file or directory tree within the WIM
+        * image. */
+       wimlib_tchar *wim_target_path;
+       /** Reserved; set to 0. */
+       int rename_flags;
+};
+
 /** Specification of an update to perform on a WIM image. */
 struct wimlib_update_command {
 
 /** Specification of an update to perform on a WIM image. */
 struct wimlib_update_command {
 
@@ -1410,47 +1458,10 @@ struct wimlib_update_command {
                WIMLIB_UPDATE_OP_RENAME,
        } op;
        union {
                WIMLIB_UPDATE_OP_RENAME,
        } op;
        union {
-               /** Data for a ::WIMLIB_UPDATE_OP_ADD operation. */
-               struct wimlib_add_command {
-                       /** Filesystem path to the file or directory tree to
-                        * add. */
-                       wimlib_tchar *fs_source_path;
-                       /** Path, specified from the root of the WIM image, at
-                        * which to add the file or directory tree within the
-                        * WIM image. */
-                       wimlib_tchar *wim_target_path;
-
-                       /** Configuration for excluded files.  @c NULL means
-                        * exclude no files (use no configuration), unless
-                        * ::WIMLIB_ADD_FLAG_WINCONFIG is specified in @p
-                        * add_flags.  */
-                       struct wimlib_capture_config *config;
-
-                       /** Bitwise OR of WIMLIB_ADD_FLAG_* flags. */
-                       int add_flags;
-               } add;
-               /** Data for a ::WIMLIB_UPDATE_OP_DELETE operation. */
-               struct wimlib_delete_command {
-                       /** Path, specified from the root of the WIM image, for
-                        * the file or directory tree within the WIM image to be
-                        * deleted. */
-                       wimlib_tchar *wim_path;
-                       /** Bitwise OR of WIMLIB_DELETE_FLAG_* flags. */
-                       int delete_flags;
-               } delete;
-               /** Data for a ::WIMLIB_UPDATE_OP_RENAME operation. */
-               struct wimlib_rename_command {
-                       /** Path, specified from the root of the WIM image, for
-                        * the source file or directory tree within the WIM
-                        * image. */
-                       wimlib_tchar *wim_source_path;
-                       /** Path, specified from the root of the WIM image, for
-                        * the destination file or directory tree within the WIM
-                        * image. */
-                       wimlib_tchar *wim_target_path;
-                       /** Reserved; set to 0. */
-                       int rename_flags;
-               } rename;
+               struct wimlib_add_command add;
+               struct wimlib_delete_command delete_; /* Underscore is for C++
+                                                        compatibility.  */
+               struct wimlib_rename_command rename;
        };
 };
 
        };
 };
 
@@ -3367,4 +3378,8 @@ extern int
 wimlib_xpress_decompress(const void *compressed_data, unsigned compressed_len,
                         void *uncompressed_data, unsigned uncompressed_len);
 
 wimlib_xpress_decompress(const void *compressed_data, unsigned compressed_len,
                         void *uncompressed_data, unsigned uncompressed_len);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _WIMLIB_H */
 #endif /* _WIMLIB_H */
index 370681a551daf0a27f806944d60f70dd061d6230..ae463ba170ee073f7e40d017da40263226c5b04c 100644 (file)
@@ -1204,7 +1204,7 @@ imagex_progress_func(enum wimlib_progress_msg msg,
                case WIMLIB_UPDATE_OP_DELETE:
                        imagex_printf(T("Deleted WIM path "
                                  "\""WIMLIB_WIM_PATH_SEPARATOR_STRING "%"TS"\"\n"),
                case WIMLIB_UPDATE_OP_DELETE:
                        imagex_printf(T("Deleted WIM path "
                                  "\""WIMLIB_WIM_PATH_SEPARATOR_STRING "%"TS"\"\n"),
-                               info->update.command->delete.wim_path);
+                               info->update.command->delete_.wim_path);
                        break;
                case WIMLIB_UPDATE_OP_RENAME:
                        imagex_printf(T("Renamed WIM path "
                        break;
                case WIMLIB_UPDATE_OP_RENAME:
                        imagex_printf(T("Renamed WIM path "
@@ -1273,9 +1273,9 @@ update_command_add_option(int op, const tchar *option,
                break;
        case WIMLIB_UPDATE_OP_DELETE:
                if (!tstrcmp(option, T("--force")))
                break;
        case WIMLIB_UPDATE_OP_DELETE:
                if (!tstrcmp(option, T("--force")))
-                       cmd->delete.delete_flags |= WIMLIB_DELETE_FLAG_FORCE;
+                       cmd->delete_.delete_flags |= WIMLIB_DELETE_FLAG_FORCE;
                else if (!tstrcmp(option, T("--recursive")))
                else if (!tstrcmp(option, T("--recursive")))
-                       cmd->delete.delete_flags |= WIMLIB_DELETE_FLAG_RECURSIVE;
+                       cmd->delete_.delete_flags |= WIMLIB_DELETE_FLAG_RECURSIVE;
                else
                        recognized = false;
                break;
                else
                        recognized = false;
                break;
@@ -1306,7 +1306,7 @@ update_command_add_nonoption(int op, const tchar *nonoption,
                        cmd->add.wim_target_path = (tchar*)nonoption;
                break;
        case WIMLIB_UPDATE_OP_DELETE:
                        cmd->add.wim_target_path = (tchar*)nonoption;
                break;
        case WIMLIB_UPDATE_OP_DELETE:
-               cmd->delete.wim_path = (tchar*)nonoption;
+               cmd->delete_.wim_path = (tchar*)nonoption;
                break;
        case WIMLIB_UPDATE_OP_RENAME:
                if (num_nonoptions == 0)
                break;
        case WIMLIB_UPDATE_OP_RENAME:
                if (num_nonoptions == 0)
@@ -3525,7 +3525,7 @@ imagex_update(int argc, tchar **argv, int cmd)
                        cmds[i].add.config = config;
                        break;
                case WIMLIB_UPDATE_OP_DELETE:
                        cmds[i].add.config = config;
                        break;
                case WIMLIB_UPDATE_OP_DELETE:
-                       cmds[i].delete.delete_flags |= default_delete_flags;
+                       cmds[i].delete_.delete_flags |= default_delete_flags;
                        break;
                default:
                        break;
                        break;
                default:
                        break;
index f2bdba382a7738858cef5ffe0bf54a4eaac26d3c..c043d892e46f4056b8ed007feec99bbff19e1ce3 100644 (file)
@@ -305,8 +305,8 @@ execute_delete_command(WIMStruct *wim,
        bool is_root;
 
        wimlib_assert(delete_cmd->op == WIMLIB_UPDATE_OP_DELETE);
        bool is_root;
 
        wimlib_assert(delete_cmd->op == WIMLIB_UPDATE_OP_DELETE);
-       flags = delete_cmd->delete.delete_flags;
-       wim_path = delete_cmd->delete.wim_path;
+       flags = delete_cmd->delete_.delete_flags;
+       wim_path = delete_cmd->delete_.wim_path;
 
        DEBUG("Deleting WIM path \"%"TS"\" (flags=%#x)", wim_path, flags);
 
 
        DEBUG("Deleting WIM path \"%"TS"\" (flags=%#x)", wim_path, flags);
 
@@ -644,7 +644,7 @@ free_update_commands(struct wimlib_update_command *cmds, size_t num_cmds)
                                free_capture_config(cmds[i].add.config);
                                break;
                        case WIMLIB_UPDATE_OP_DELETE:
                                free_capture_config(cmds[i].add.config);
                                break;
                        case WIMLIB_UPDATE_OP_DELETE:
-                               FREE(cmds[i].delete.wim_path);
+                               FREE(cmds[i].delete_.wim_path);
                                break;
                        case WIMLIB_UPDATE_OP_RENAME:
                                FREE(cmds[i].rename.wim_source_path);
                                break;
                        case WIMLIB_UPDATE_OP_RENAME:
                                FREE(cmds[i].rename.wim_source_path);
@@ -692,11 +692,11 @@ copy_update_commands(const struct wimlib_update_command *cmds,
                        cmds_copy[i].add.add_flags = cmds[i].add.add_flags;
                        break;
                case WIMLIB_UPDATE_OP_DELETE:
                        cmds_copy[i].add.add_flags = cmds[i].add.add_flags;
                        break;
                case WIMLIB_UPDATE_OP_DELETE:
-                       cmds_copy[i].delete.wim_path =
-                               canonicalize_wim_path(cmds[i].delete.wim_path);
-                       if (!cmds_copy[i].delete.wim_path)
+                       cmds_copy[i].delete_.wim_path =
+                               canonicalize_wim_path(cmds[i].delete_.wim_path);
+                       if (!cmds_copy[i].delete_.wim_path)
                                goto oom;
                                goto oom;
-                       cmds_copy[i].delete.delete_flags = cmds[i].delete.delete_flags;
+                       cmds_copy[i].delete_.delete_flags = cmds[i].delete_.delete_flags;
                        break;
                case WIMLIB_UPDATE_OP_RENAME:
                        cmds_copy[i].rename.wim_source_path =
                        break;
                case WIMLIB_UPDATE_OP_RENAME:
                        cmds_copy[i].rename.wim_source_path =