--- wavsplit.c.orig 2003-12-28 20:38:14.000000000 -0600 +++ wavsplit.c 2004-01-04 18:01:49.000000000 -0600 @@ -91,95 +91,70 @@ basename[strlen (basename) - 4] = '\0'; for (i = 0; i < argc - (optind + 1); i++) { - splitpos[i].hr = 0; - splitpos[i].min = 0; - splitpos[i].sek = 0.0; - splitpos[i].seki = 0; - splitpos[i].frames = 0; + splitpos[i].hr = 0; + splitpos[i].min = 0; + splitpos[i].sek = 0.0; + splitpos[i].seki = 0; + splitpos[i].frames = 0; - if (UseSeconds) { - if (UseFrames) { - strtokPtr = strtok (argv[optind + 1 + i], ":"); - splitpos[i].seki = atoi (strtokPtr); - if (!TokenOK ("Frame Counter", strtokPtr)) - return 1; - splitpos[i].frames = atof (strtokPtr); - } - else { /* not using frames */ - splitpos[i].sek = atof (argv[optind + 1 + i]); - } /* end if useframes */ - } - else { /* not using seconds */ + char *timestring = argv[optind + 1 + i]; + strtokPtr = strtok(timestring, ":"); + /* hours */ if (UseHours) { - splitpos[i].hr = atoi (strtok (argv[optind + 1 + i], ":")); - if (!TokenOK ("Minutes", strtokPtr)) - return 1; - splitpos[i].min = atoi (strtokPtr); + splitpos[i].hr = atoi (strtokPtr); + strtokPtr = strtok(NULL, ":"); } - else { /* not usehours */ - splitpos[i].min = atoi (strtok (argv[optind + 1 + i], ":")); - } /* end if usehours */ + /* minutes */ + splitpos[i].min = atoi (strtokPtr); + /* seconds */ + strtokPtr = strtok(NULL, ""); + splitpos[i].sek = atof (strtokPtr); if (UseFrames) { - /* expect integer seconds followed by floating point frames */ - if (!TokenOK ("Seconds", strtokPtr)) - return 1; - splitpos[i].seki = atoi (strtokPtr); - - if (!TokenOK ("Frame Counter", strtokPtr)) - return 1; - splitpos[i].frames = atof (strtokPtr); - } /* not useframe */ - else { - /* expect floating point seconds and no frames */ - if (!TokenOK ("Seconds", strtokPtr)) - return 1; - - splitpos[i].sek = atof (strtokPtr); - } /* end if useframes */ - } /* end if useseconds */ - - /* Check that values are valid */ - if (UseFrames) { - if ((splitpos[i].frames < 0.0) || (splitpos[i].frames >= (float) fps)) { - Report("When using frames, minutes must be >= 0.0 and <= Frames Per Second","ERROR",verbose); + if (!TokenOK ("Frame Counter", strtokPtr)) return 1; + splitpos[i].frames = atof (strtokPtr); } - } - if (!UseSeconds) { - if (((splitpos[i].sek < 0.0) || (splitpos[i].sek >= 60.0))) { - Report("Seconds must be >= 0.0 and <= 60.0","ERROR",verbose); - } - if (((splitpos[i].seki < 0) || (splitpos[i].seki >= 60))) { - Report("Seconds must be >= 0 and <= 60","ERROR",verbose); - } - if ((splitpos[i].min < 0) || (splitpos[i].min >= 60)) { - Report("When using Hours, minutes must be >= 0 and <= 60","ERROR",verbose); + /* Check that values are valid */ + if (UseFrames) { + if ((splitpos[i].frames < 0.0) || (splitpos[i].frames >= (float) fps)) { + Report("When using frames, minutes must be >= 0.0 and <= Frames Per Second","ERROR",verbose); + } } - } /* end if !useseconds */ + if (!UseSeconds) { + if (((splitpos[i].sek < 0.0) || (splitpos[i].sek >= 60.0))) { + Report("Seconds must be >= 0.0 and <= 60.0","ERROR",verbose); + } + if (((splitpos[i].seki < 0) || (splitpos[i].seki >= 60))) { + Report("Seconds must be >= 0 and <= 60","ERROR",verbose); + } + if ((splitpos[i].min < 0) || (splitpos[i].min >= 60)) { + Report("When using Hours, minutes must be >= 0 and <= 60","ERROR",verbose); + } + } /* end if !useseconds */ - } /* end for */ + } splits = i; if (mkdir (basename, 0777) == -1) { - if (errno == EEXIST) { - //if (verbose) fprintf(stderr,"Directory already exists, not creating.\n"); - } - else { - fprintf (stderr, "Could not create output directory.\n"); - return 1; - } + if (errno == EEXIST) { + //if (verbose) fprintf(stderr,"Directory already exists, not creating.\n"); + } + else { + fprintf (stderr, "Could not create output directory.\n"); + return 1; + } } ifd = open (ifile, O_RDONLY); if (ifd == -1) { - fprintf (stderr, "Could not open file.\n"); - return 1; + fprintf (stderr, "Could not open file.\n"); + return 1; } if (readheader () > 0) - return 1; + return 1; if (split (UseHours, UseFrames, fps, splits, splitpos) > 0) - return 1; + return 1; close (ifd); return 0; @@ -519,16 +494,16 @@ pos = pos * waveformat.wBlockAlign; if (verbose) - printf ("[%02d]\tuntil %d:", splitnr + 1, split[splitnr].hr); + printf ("[%02d]\tuntil %02d:", splitnr + 1, split[splitnr].hr); if (UseFrames) - printf ("%d:%6.3f\t%09ld\t%3.2f%%\n", + printf ("%02d:%06.3f\t%09ld\t%3.2f%%\n", split[splitnr].min, (double) split[splitnr].seki + ((double) split[splitnr].frames / (double) fps), pos, (float) pos / (float) databytes * 100); else - printf ("%d:%6.3f\t%09ld\t%3.2f%%\n", + printf ("%02d:%06.3f\t%09ld\t%3.2f%%\n", split[splitnr].min, split[splitnr].sek, pos, (float) pos / (float) databytes * 100);