+static int
+append_image_property_argument(struct string_list *image_properties)
+{
+ if (!tstrchr(optarg, '=')) {
+ imagex_error(T("'--image-property' argument "
+ "must be in the form NAME=VALUE"));
+ return -1;
+ }
+ return string_list_append(image_properties, optarg);
+}
+
+static int
+apply_image_properties(struct string_list *image_properties,
+ WIMStruct *wim, int image, bool *any_changes_ret)
+{
+ bool any_changes = false;
+ for (unsigned i = 0; i < image_properties->num_strings; i++) {
+ tchar *name, *value;
+ const tchar *current_value;
+ int ret;
+
+ name = image_properties->strings[i];
+ value = tstrchr(name, '=');
+ *value++ = '\0';
+
+ current_value = wimlib_get_image_property(wim, image, name);
+ if (current_value && !tstrcmp(current_value, value)) {
+ imagex_printf(T("The %"TS" property of image %d "
+ "already has value \"%"TS"\".\n"),
+ name, image, value);
+ } else {
+ imagex_printf(T("Setting the %"TS" property of image "
+ "%d to \"%"TS"\".\n"),
+ name, image, value);
+ ret = wimlib_set_image_property(wim, image, name, value);
+ if (ret)
+ return ret;
+ any_changes = true;
+ }
+ }
+ if (any_changes_ret)
+ *any_changes_ret = any_changes;
+ return 0;
+}
+