Mercurial > pt1
comparison recpt1/recpt1.c @ 47:edd904628e2f
a bit improved support for time format. now recpt1 recognize string such as 1h05m10s.
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Sun, 19 Jul 2009 04:55:44 +0900 |
parents | 9b36fdf7d5d0 |
children | c8051f6da2ab |
comparison
equal
deleted
inserted
replaced
46:33c899c6cc9d | 47:edd904628e2f |
---|---|
10 #include <unistd.h> | 10 #include <unistd.h> |
11 #include <getopt.h> | 11 #include <getopt.h> |
12 #include <signal.h> | 12 #include <signal.h> |
13 #include <errno.h> | 13 #include <errno.h> |
14 #include <sys/time.h> | 14 #include <sys/time.h> |
15 #include <ctype.h> | |
15 | 16 |
16 #include <netdb.h> | 17 #include <netdb.h> |
17 #include <arpa/inet.h> | 18 #include <arpa/inet.h> |
18 #include <netinet/in.h> | 19 #include <netinet/in.h> |
19 | 20 |
508 int | 509 int |
509 main(int argc, char **argv) | 510 main(int argc, char **argv) |
510 { | 511 { |
511 int tfd, wfd; | 512 int tfd, wfd; |
512 int lp; | 513 int lp; |
513 int recsec; | 514 int recsec = 0; |
514 int indefinite = FALSE; | 515 int indefinite = FALSE; |
515 time_t start_time, cur_time; | 516 time_t start_time, cur_time; |
516 FREQUENCY freq; | 517 FREQUENCY freq; |
517 ISDB_T_FREQ_CONV_TABLE *ptr; | 518 ISDB_T_FREQ_CONV_TABLE *ptr; |
518 pthread_t reader_thread; | 519 pthread_t reader_thread; |
701 /* show signal strength */ | 702 /* show signal strength */ |
702 calc_cn(tfd, ptr->type); | 703 calc_cn(tfd, ptr->type); |
703 | 704 |
704 /* get recsec */ | 705 /* get recsec */ |
705 char *rectimestr = argv[optind + 1]; | 706 char *rectimestr = argv[optind + 1]; |
707 | |
706 if(!strcmp("-", rectimestr)) { | 708 if(!strcmp("-", rectimestr)) { |
707 indefinite = TRUE; | 709 indefinite = TRUE; |
708 recsec = -1; | 710 recsec = -1; |
709 } | 711 } |
710 else if(strrchr(rectimestr, 'H') || strrchr(rectimestr, 'h')) | 712 else { |
711 recsec = atoi(rectimestr) * 3600; | 713 char *tmpstr; |
712 else if(strrchr(rectimestr, 'M') || strrchr(rectimestr, 'm')) | 714 char *p1, *p2; |
713 recsec = atoi(rectimestr) * 60; | 715 |
714 else | 716 tmpstr = strdup(rectimestr); |
715 recsec = atoi(rectimestr); | 717 p1 = tmpstr; |
718 while(!isdigit(*p1)) | |
719 p1++; | |
720 | |
721 /* hour */ | |
722 if((p2 = strchr(p1, 'H')) || (p2 = strchr(p1, 'h'))) { | |
723 *p2 = '\0'; | |
724 recsec += atoi(p1) * 3600; | |
725 p1 = p2 + 1; | |
726 while(!isdigit(*p1)) | |
727 p1++; | |
728 } | |
729 | |
730 /* minute */ | |
731 if((p2 = strchr(p1, 'M')) || (p2 = strchr(p1, 'm'))) { | |
732 *p2 = '\0'; | |
733 recsec += atoi(p1) * 60; | |
734 p1 = p2 + 1; | |
735 while(!isdigit(*p1)) | |
736 p1++; | |
737 } | |
738 | |
739 /* second */ | |
740 recsec += atoi(p1); | |
741 | |
742 free(tmpstr); | |
743 } | |
716 | 744 |
717 /* open output file */ | 745 /* open output file */ |
718 char *destfile = argv[optind + 2]; | 746 char *destfile = argv[optind + 2]; |
719 if(destfile && !strcmp("-", destfile)) { | 747 if(destfile && !strcmp("-", destfile)) { |
720 use_stdout = TRUE; | 748 use_stdout = TRUE; |