+static int
+set_compress_slow(void)
+{
+ int ret;
+ static const struct wimlib_lzx_compressor_params slow_params = {
+ .hdr = {
+ .size = sizeof(struct wimlib_lzx_compressor_params),
+ },
+ .algorithm = WIMLIB_LZX_ALGORITHM_SLOW,
+ .alg_params = {
+ .slow = {
+ .use_len2_matches = 1,
+ .num_fast_bytes = 96,
+ .num_optim_passes = 4,
+ .max_search_depth = 100,
+ .max_matches_per_pos = 10,
+ .main_nostat_cost = 15,
+ .len_nostat_cost = 15,
+ .aligned_nostat_cost = 7,
+ },
+ },
+ };
+ ret = wimlib_set_default_compressor_params(WIMLIB_COMPRESSION_TYPE_LZX,
+ &slow_params.hdr);
+ if (ret)
+ imagex_error(T("Couldn't set slow compression parameters.!"));
+ return ret;
+}
+
+struct string_set {
+ const tchar **strings;
+ unsigned num_strings;
+ unsigned num_alloc_strings;
+};
+
+#define STRING_SET_INITIALIZER \
+ { .strings = NULL, .num_strings = 0, .num_alloc_strings = 0, }
+
+#define STRING_SET(_strings) \
+ struct string_set _strings = STRING_SET_INITIALIZER
+
+static int
+string_set_append(struct string_set *set, const tchar *glob)
+{
+ unsigned num_alloc_strings = set->num_alloc_strings;
+
+ if (set->num_strings == num_alloc_strings) {
+ const tchar **new_strings;
+
+ num_alloc_strings += 4;
+ new_strings = realloc(set->strings,
+ sizeof(set->strings[0]) * num_alloc_strings);
+ if (!new_strings) {
+ imagex_error(T("Out of memory!"));
+ return -1;
+ }
+ set->strings = new_strings;
+ set->num_alloc_strings = num_alloc_strings;
+ }
+ set->strings[set->num_strings++] = glob;
+ return 0;
+}
+
+static void
+string_set_destroy(struct string_set *set)
+{
+ free(set->strings);
+}
+
+static int
+wim_reference_globs(WIMStruct *wim, struct string_set *set, int open_flags)
+{
+ return wimlib_reference_resource_files(wim, set->strings,
+ set->num_strings,
+ WIMLIB_REF_FLAG_GLOB_ENABLE,
+ open_flags,
+ imagex_progress_func);
+}
+
+static void
+do_resource_not_found_warning(const tchar *wimfile,
+ const struct wimlib_wim_info *info,
+ const struct string_set *refglobs)
+{
+ if (info->total_parts > 1) {
+ if (refglobs->num_strings == 0) {
+ imagex_error(T("\"%"TS"\" is part of a split WIM. "
+ "Use --ref to specify the other parts."),
+ wimfile);
+ } else {
+ imagex_error(T("Perhaps the '--ref' argument did not "
+ "specify all other parts of the split "
+ "WIM?"));
+ }
+ } else {
+ imagex_error(T("If this is a delta WIM, use the --ref argument "
+ "to specify the WIM(s) on which it is based."));
+ }
+}
+