aboutsummaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorDavid Phillips <dbphillipsnz@gmail.com>2015-07-07 00:06:56 +1200
committerDavid Phillips <dbphillipsnz@gmail.com>2015-07-07 00:06:56 +1200
commit9f82f60fd2c41572168dc3546a76aa53dff2029e (patch)
treef0c2be467192ba5ba6edd7f966947ddbad150359 /misc.c
parent9ed2b91c9de4b621e932e4f8added796e3a79dca (diff)
downloadcue-bin-split-9f82f60fd2c41572168dc3546a76aa53dff2029e.tar.xz
Shifted seconds conversion etc into own function, whitespace fixes
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/misc.c b/misc.c
index 3b78d4a..c3dc439 100644
--- a/misc.c
+++ b/misc.c
@@ -28,9 +28,25 @@
#include "misc.h"
/* Grabs a 'mm:ss:ff' stamp from stdin */
-int get_stamp(int *m, int *s, int *f)
+double get_sec()
{
- return fscanf(stdin, "%d:%d:%d\n", m, s, f);
+ int mm = 0;
+ int ss = 0;
+ int ff = 0;
+ int items = fscanf(stdin, "%d:%d:%d\n", &mm, &ss, &ff);
+
+ /* EOF means this is the last track; return invalid time */
+ if (items == EOF)
+ {
+ return -1;
+ }
+
+ if (items != 3)
+ {
+ fprintf(stderr, "Timestamp malformed\n");
+ exit(EXIT_FAILURE);
+ }
+ return SEC_FROM_TS(mm, ss, ff);
}
/* Constructs an output filename in the specified buffer based on the given format and track number