Mercurial > pt1
comparison recpt1/recpt1.c @ 48:c8051f6da2ab
now recpt1 accepts formats like 1:20:05 (hh:mm:ss) or 1:20 (hh:mm).
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Sun, 19 Jul 2009 05:24:39 +0900 |
parents | edd904628e2f |
children | 6bcdd17c12f6 |
comparison
equal
deleted
inserted
replaced
47:edd904628e2f | 48:c8051f6da2ab |
---|---|
703 calc_cn(tfd, ptr->type); | 703 calc_cn(tfd, ptr->type); |
704 | 704 |
705 /* get recsec */ | 705 /* get recsec */ |
706 char *rectimestr = argv[optind + 1]; | 706 char *rectimestr = argv[optind + 1]; |
707 | 707 |
708 /* indefinite */ | |
708 if(!strcmp("-", rectimestr)) { | 709 if(!strcmp("-", rectimestr)) { |
709 indefinite = TRUE; | 710 indefinite = TRUE; |
710 recsec = -1; | 711 recsec = -1; |
711 } | 712 } |
713 /* colon */ | |
714 else if(strchr(rectimestr, ':')) { | |
715 int n1, n2, n3; | |
716 if(sscanf(rectimestr, "%d:%d:%d", &n1, &n2, &n3) == 3) | |
717 recsec = n1 * 3600 + n2 * 60 + n3; | |
718 else if(sscanf(rectimestr, "%d:%d", &n1, &n2) == 2) | |
719 recsec = n1 * 3600 + n2 * 60; | |
720 } | |
721 /* HMS */ | |
712 else { | 722 else { |
713 char *tmpstr; | 723 char *tmpstr; |
714 char *p1, *p2; | 724 char *p1, *p2; |
715 | 725 |
716 tmpstr = strdup(rectimestr); | 726 tmpstr = strdup(rectimestr); |
739 /* second */ | 749 /* second */ |
740 recsec += atoi(p1); | 750 recsec += atoi(p1); |
741 | 751 |
742 free(tmpstr); | 752 free(tmpstr); |
743 } | 753 } |
754 | |
755 /* fprintf(stderr, "recsec = %d\n", recsec); */ | |
744 | 756 |
745 /* open output file */ | 757 /* open output file */ |
746 char *destfile = argv[optind + 2]; | 758 char *destfile = argv[optind + 2]; |
747 if(destfile && !strcmp("-", destfile)) { | 759 if(destfile && !strcmp("-", destfile)) { |
748 use_stdout = TRUE; | 760 use_stdout = TRUE; |