aboutsummaryrefslogtreecommitdiffstats
path: root/tools/serd-pipe.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-08-02 11:35:26 -0400
committerDavid Robillard <d@drobilla.net>2023-12-02 18:49:08 -0500
commit816a9532765b2184c5f127494b95bdb9103bc960 (patch)
tree81195ad74ee61a6123ffd64fd1a5d9f111503dc6 /tools/serd-pipe.c
parentd206d6020c23420078a8b2579f0274723b1b470a (diff)
downloadserd-816a9532765b2184c5f127494b95bdb9103bc960.tar.gz
serd-816a9532765b2184c5f127494b95bdb9103bc960.tar.bz2
serd-816a9532765b2184c5f127494b95bdb9103bc960.zip
Factor out opening output files
Diffstat (limited to 'tools/serd-pipe.c')
-rw-r--r--tools/serd-pipe.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/tools/serd-pipe.c b/tools/serd-pipe.c
index 1ad07719..7216445a 100644
--- a/tools/serd-pipe.c
+++ b/tools/serd-pipe.c
@@ -11,7 +11,6 @@
#include "serd/reader.h"
#include "serd/sink.h"
#include "serd/status.h"
-#include "serd/stream.h"
#include "serd/string_view.h"
#include "serd/syntax.h"
#include "serd/world.h"
@@ -255,7 +254,6 @@ main(int argc, char** argv)
}
serd_set_stream_utf8_mode(stdin);
- serd_set_stream_utf8_mode(stdout);
char* const* const inputs = argv + a;
const int n_inputs = argc - a;
@@ -283,7 +281,6 @@ main(int argc, char** argv)
zix_free(NULL, input_path);
}
- FILE* const out_fd = stdout;
SerdWorld* const world = serd_world_new();
const SerdLimits limits = {stack_size, MAX_DEPTH};
serd_world_set_limits(world, limits);
@@ -291,10 +288,11 @@ main(int argc, char** argv)
SerdEnv* const env =
serd_env_new(base ? serd_node_string_view(base) : serd_empty_string());
- SerdOutputStream out = serd_open_output_stream((SerdWriteFunc)fwrite,
- (SerdErrorFunc)ferror,
- (SerdCloseFunc)fclose,
- out_fd);
+ SerdOutputStream out = serd_open_tool_output("-");
+ if (!out.stream) {
+ perror("serdi: error opening output file");
+ return 1;
+ }
SerdWriter* const writer = serd_writer_new(
world, output_syntax, writer_flags, env, &out, bulk_write ? 4096U : 1U);