+stdin_get_contents(void **buf_ret, size_t *bufsize_ret)
+{
+ char *buf = NULL;
+ size_t filled = 0;
+ size_t capacity = 0;
+
+ do {
+ size_t new_capacity = (capacity * 2) + 256;
+ char *new_buf;
+
+ if (new_capacity <= capacity ||
+ !(new_buf = REALLOC(buf, new_capacity))) {
+ ERROR("Too much data sent on stdin!");
+ FREE(buf);
+ return WIMLIB_ERR_INVALID_PARAM;
+ }
+ buf = new_buf;
+ capacity = new_capacity;
+ filled += fread(&buf[filled], 1, capacity - filled, stdin);
+ } while (filled == capacity);
+
+ if (!feof(stdin)) {
+ ERROR_WITH_ERRNO("Error reading stdin");
+ FREE(buf);
+ return WIMLIB_ERR_READ;
+ }
+ *buf_ret = buf;
+ *bufsize_ret = filled;
+ return 0;
+}
+
+static int
+read_file_contents(const tchar *path, void **buf_ret, size_t *bufsize_ret)