/*
* Copyright (C) 2014 Eric Biggers
*
- * This file is part of wimlib, a library for working with WIM files.
+ * This file 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 3 of the License, or (at your option) any
+ * later version.
*
- * wimlib is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * 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 General Public License for more
+ * This file 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 General Public License
- * along with wimlib; if not, see http://www.gnu.org/licenses/.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this file; if not, see http://www.gnu.org/licenses/.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
-#include "wimlib/assert.h"
-#include "wimlib/encoding.h"
-#include "wimlib/error.h"
-#include "wimlib/file_io.h"
-#include "wimlib/textfile.h"
-#include "wimlib/util.h"
-
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
+#include "wimlib/encoding.h"
+#include "wimlib/error.h"
+#include "wimlib/file_io.h"
+#include "wimlib/textfile.h"
+#include "wimlib/util.h"
+
static int
read_file_contents(const tchar *path, void **buf_ret, size_t *bufsize_ret)
{
bufsize_raw - offset_raw,
&buf_tstr, &bufsize_tstr);
} else {
- #if TCHAR_IS_UTF16LE
- bufsize_tstr = bufsize_raw - offset_raw;
- buf_tstr = MALLOC(bufsize_tstr + 2);
- if (buf_tstr) {
- memcpy(buf_tstr, buf_raw + offset_raw, bufsize_tstr);
- ((u8*)buf_tstr)[bufsize_tstr + 0] = 0;
- ((u8*)buf_tstr)[bufsize_tstr + 1] = 0;
- ret = 0;
- } else {
- ret = WIMLIB_ERR_NOMEM;
- }
- #else
ret = utf16le_to_tstr((const utf16lechar *)(buf_raw + offset_raw),
bufsize_raw - offset_raw,
&buf_tstr, &bufsize_tstr);
- #endif
}
if (ret)
return ret;
}
static int
-string_set_append(struct string_set *set, tchar *str)
+string_list_append(struct string_list *list, tchar *str)
{
- size_t num_alloc_strings = set->num_alloc_strings;
+ size_t num_alloc_strings = list->num_alloc_strings;
- if (set->num_strings == num_alloc_strings) {
+ if (list->num_strings == num_alloc_strings) {
tchar **new_strings;
num_alloc_strings = max(num_alloc_strings * 3 / 2,
num_alloc_strings + 4);
- new_strings = REALLOC(set->strings,
- sizeof(set->strings[0]) * num_alloc_strings);
+ new_strings = REALLOC(list->strings,
+ sizeof(list->strings[0]) * num_alloc_strings);
if (!new_strings)
return WIMLIB_ERR_NOMEM;
- set->strings = new_strings;
- set->num_alloc_strings = num_alloc_strings;
+ list->strings = new_strings;
+ list->num_alloc_strings = num_alloc_strings;
}
- set->strings[set->num_strings++] = str;
+ list->strings[list->num_strings++] = str;
return 0;
}
return ret;
}
- ret = string_set_append(pos_sections[current_section].strings,
- line_begin);
+ ret = string_list_append(pos_sections[current_section].strings,
+ line_begin);
if (ret)
return ret;
}
* consists of the name of the section (e.g. [ExclusionList], like in the
* INI file format), along with a pointer to the list of lines parsed for
* that section. Use an empty name to indicate the destination of lines
- * not in any section. Each list must be initialized to an empty string
- * set.
+ * not in any section. Each list must be initialized to empty.
* @num_pos_sections
* Number of entries in the @pos_sections array.
* @flags