From cc5896b1a07a529a11a82fb0bd499e05df3d1314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Mangano-Tarumi?= Date: Tue, 6 Nov 2018 21:07:43 -0500 Subject: [PATCH] move print_tags in the main module That's where it belongs. The other modules are not supposed to write anything to the console. --- src/opus.cc | 8 -------- src/opustags.cc | 19 ++++++++++++++++++- src/opustags.h | 1 - 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/opus.cc b/src/opus.cc index 90d6559..3a498fc 100644 --- a/src/opus.cc +++ b/src/opus.cc @@ -134,11 +134,3 @@ int ot::add_tags(opus_tags *tags, const char **tags_to_add, uint32_t count) tags->comments.emplace_back(tags_to_add[i]); return 0; } - -void ot::print_tags(opus_tags *tags) -{ - for (const string_view &comment : tags->comments) { - fwrite(comment.data(), 1, comment.size(), stdout); - puts(""); - } -} diff --git a/src/opustags.cc b/src/opustags.cc index 666c09c..dccff47 100644 --- a/src/opustags.cc +++ b/src/opustags.cc @@ -43,6 +43,23 @@ struct option options[] = { {NULL, 0, 0, 0} }; +/** + * Display the tags on stdout. + * + * Print all the comments, separated by line breaks. Since a comment may + * contain line breaks, this output is not completely reliable, but it fits + * most cases. + * + * Only the comments are displayed. + */ +static void print_tags(ot::opus_tags &tags) +{ + for (const ot::string_view &comment : tags.comments) { + fwrite(comment.data(), 1, comment.size(), stdout); + puts(""); + } +} + int main(int argc, char **argv){ if(argc == 1){ fputs(version, stdout); @@ -299,7 +316,7 @@ int main(int argc, char **argv){ free(packet.packet); } else - ot::print_tags(&tags); + print_tags(tags); if(raw_tags) free(raw_tags); if(error || !out) diff --git a/src/opustags.h b/src/opustags.h index 7152e75..ee3f3fa 100644 --- a/src/opustags.h +++ b/src/opustags.h @@ -87,7 +87,6 @@ int parse_tags(const char *data, long len, opus_tags *tags); int render_tags(opus_tags *tags, ogg_packet *op); void delete_tags(opus_tags *tags, const char *field); int add_tags(opus_tags *tags, const char **tags_to_add, uint32_t count); -void print_tags(opus_tags *tags); /** \} */