Commit b7930f4a authored by conrad's avatar conrad

add a FILE* parameter to internal ot_print_bytes()


git-svn-id: http://svn.annodex.net/liboggz/trunk@1181 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent 7c38040d
......@@ -32,6 +32,7 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <oggz/oggz.h>
......@@ -234,21 +235,21 @@ ot_page_identify (const ogg_page * og, char ** info)
* using standard abbreviations (GB, MB, kB, byte[s])
*/
int
ot_print_bytes (long nr_bytes)
ot_fprint_bytes (FILE * stream, long nr_bytes)
{
if (nr_bytes > (1L<<30)) {
return printf ("%0.3f GB",
return fprintf (stream, "%0.3f GB",
(double)nr_bytes / (1024.0 * 1024.0 * 1024.0));
} else if (nr_bytes > (1L<<20)) {
return printf ("%0.3f MB",
return fprintf (stream, "%0.3f MB",
(double)nr_bytes / (1024.0 * 1024.0));
} else if (nr_bytes > (1L<<10)) {
return printf ("%0.3f kB",
return fprintf (stream, "%0.3f kB",
(double)nr_bytes / (1024.0));
} else if (nr_bytes == 1) {
return printf ("1 byte");
return fprintf (stream, "1 byte");
} else {
return printf ("%ld bytes", nr_bytes);
return fprintf (stream, "%ld bytes", nr_bytes);
}
}
......
......@@ -42,7 +42,7 @@ ot_page_identify (const ogg_page * og, char ** info);
* Print a number of bytes to 3 significant figures
* using standard abbreviations (GB, MB, kB, byte[s])
*/
int ot_print_bytes (long nr_bytes);
int ot_fprint_bytes (FILE * stream, long nr_bytes);
/*
* Print a bitrate to 3 significant figures
......
......@@ -168,11 +168,11 @@ static void
oi_stats_print (OI_Info * info, OI_Stats * stats, char * label)
{
printf ("\t%s-Length-Maximum: ", label);
ot_print_bytes (stats->length_max);
ot_fprint_bytes (stdout, stats->length_max);
putchar ('\n');
printf ("\t%s-Length-StdDev: ", label);
ot_print_bytes (stats->length_stddev);
ot_fprint_bytes (stdout, stats->length_stddev);
putchar ('\n');
#if 0
......@@ -197,7 +197,7 @@ oit_print (OI_Info * info, OI_TrackInfo * oit, long serialno)
if (show_length) {
fputs("\tContent-Length: ", stdout);
ot_print_bytes (oit->pages.length_total);
ot_fprint_bytes (stdout, oit->pages.length_total);
putchar ('\n');
}
......@@ -506,7 +506,7 @@ main (int argc, char ** argv)
if (show_length) {
fputs ("Content-Length: ", stdout);
ot_print_bytes (info.length_total);
ot_fprint_bytes (stdout, info.length_total);
putchar ('\n');
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment