# HG changeset patch # User Yoshiki Yazawa # Date 1247946944 -32400 # Node ID edd904628e2f9ac95e883b68b851c7d8495d58ea # Parent 33c899c6cc9d4d99b4d968244f31de8f75398fd4 a bit improved support for time format. now recpt1 recognize string such as 1h05m10s. diff -r 33c899c6cc9d -r edd904628e2f recpt1/recpt1.c --- a/recpt1/recpt1.c Sun Jul 19 03:39:29 2009 +0900 +++ b/recpt1/recpt1.c Sun Jul 19 04:55:44 2009 +0900 @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -510,7 +511,7 @@ { int tfd, wfd; int lp; - int recsec; + int recsec = 0; int indefinite = FALSE; time_t start_time, cur_time; FREQUENCY freq; @@ -703,16 +704,43 @@ /* get recsec */ char *rectimestr = argv[optind + 1]; + if(!strcmp("-", rectimestr)) { indefinite = TRUE; recsec = -1; } - else if(strrchr(rectimestr, 'H') || strrchr(rectimestr, 'h')) - recsec = atoi(rectimestr) * 3600; - else if(strrchr(rectimestr, 'M') || strrchr(rectimestr, 'm')) - recsec = atoi(rectimestr) * 60; - else - recsec = atoi(rectimestr); + else { + char *tmpstr; + char *p1, *p2; + + tmpstr = strdup(rectimestr); + p1 = tmpstr; + while(!isdigit(*p1)) + p1++; + + /* hour */ + if((p2 = strchr(p1, 'H')) || (p2 = strchr(p1, 'h'))) { + *p2 = '\0'; + recsec += atoi(p1) * 3600; + p1 = p2 + 1; + while(!isdigit(*p1)) + p1++; + } + + /* minute */ + if((p2 = strchr(p1, 'M')) || (p2 = strchr(p1, 'm'))) { + *p2 = '\0'; + recsec += atoi(p1) * 60; + p1 = p2 + 1; + while(!isdigit(*p1)) + p1++; + } + + /* second */ + recsec += atoi(p1); + + free(tmpstr); + } /* open output file */ char *destfile = argv[optind + 2];