5 bool writing_to_stdout;
6} default_writer_user_args_t;
8static bool default_writer_setup(
void *instance,
bool writing_to_stdout,
wchar_t *full_output_dir) {
9 writer_t *writer = (writer_t *)instance;
10 default_writer_user_args_t *args = malloc(
sizeof(default_writer_user_args_t));
14 memset(args, 0,
sizeof(default_writer_user_args_t));
15 args->writing_to_stdout = writing_to_stdout;
16 args->out_fp = !writing_to_stdout ? CreateFile(full_output_dir,
17 GENERIC_READ | GENERIC_WRITE,
21 FILE_ATTRIBUTE_NORMAL,
23 GetStdHandle(STD_OUTPUT_HANDLE);
24 if (args->out_fp == INVALID_HANDLE_VALUE) {
27 writer->user_args = args;
34static bool default_writer_write_output(
void *instance,
37 long unsigned int *written) {
38 writer_t *writer = (writer_t *)instance;
39 default_writer_user_args_t *args = (default_writer_user_args_t *)writer->user_args;
40 return WriteFile(args->out_fp, mb_out, (DWORD)total_size, (LPDWORD)written,
nullptr);
43static void default_writer_teardown(
void *instance) {
44 writer_t *writer = (writer_t *)instance;
45 default_writer_user_args_t *args = (default_writer_user_args_t *)writer->user_args;
46 if (!args->writing_to_stdout) {
47 CloseHandle(args->out_fp);
49 free(writer->user_args);
52writer_t *get_default_writer() {
53 writer_t *out = malloc(
sizeof(writer_t));
57 out->setup = default_writer_setup;
58 out->write_output = default_writer_write_output;
59 out->teardown = default_writer_teardown;