aboutsummaryrefslogtreecommitdiffstats
path: root/tools/console.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/console.c
parentd206d6020c23420078a8b2579f0274723b1b470a (diff)
downloadserd-816a9532765b2184c5f127494b95bdb9103bc960.tar.gz
serd-816a9532765b2184c5f127494b95bdb9103bc960.tar.bz2
serd-816a9532765b2184c5f127494b95bdb9103bc960.zip
Factor out opening output files
Diffstat (limited to 'tools/console.c')
-rw-r--r--tools/console.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/tools/console.c b/tools/console.c
index c187f500..f07573fa 100644
--- a/tools/console.c
+++ b/tools/console.c
@@ -93,3 +93,17 @@ serd_open_tool_input(const char* const filename)
return serd_open_input_file(filename);
}
+
+SerdOutputStream
+serd_open_tool_output(const char* const filename)
+{
+ if (!filename || !strcmp(filename, "-")) {
+ serd_set_stream_utf8_mode(stdout);
+ return serd_open_output_stream((SerdWriteFunc)fwrite,
+ (SerdErrorFunc)ferror,
+ (SerdCloseFunc)fclose,
+ stdout);
+ }
+
+ return serd_open_output_file(filename);
+}