diff options
author | David Phillips <dbphillipsnz@gmail.com> | 2015-07-07 00:06:56 +1200 |
---|---|---|
committer | David Phillips <dbphillipsnz@gmail.com> | 2015-07-07 00:06:56 +1200 |
commit | 9f82f60fd2c41572168dc3546a76aa53dff2029e (patch) | |
tree | f0c2be467192ba5ba6edd7f966947ddbad150359 /misc.c | |
parent | 9ed2b91c9de4b621e932e4f8added796e3a79dca (diff) | |
download | cue-bin-split-9f82f60fd2c41572168dc3546a76aa53dff2029e.tar.xz |
Shifted seconds conversion etc into own function, whitespace fixes
Diffstat (limited to 'misc.c')
-rw-r--r-- | misc.c | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -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 |