Mercurial > pt1
changeset 14:cad940a903f5
- replace host option with addr option.
- adde help option.
- tweak help.
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Tue, 24 Feb 2009 22:26:07 +0900 |
parents | 003fe2470af8 |
children | 1b0883b02b4f |
files | recpt1/recpt1.c |
diffstat | 1 files changed, 48 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/recpt1/recpt1.c Tue Feb 24 17:22:06 2009 +0900 +++ b/recpt1/recpt1.c Tue Feb 24 22:26:07 2009 +0900 @@ -288,26 +288,44 @@ void show_usage(char *cmd) { - fprintf(stderr, "Usage: %s [--b25 [--round N] [--strip] [--EMM]] [--udp [--host hostname --port port]] channel recsec destfile\n", cmd); + fprintf(stderr, "\n"); + fprintf(stderr, "Usage: \n%s [--b25 [--round N] [--strip] [--EMM]] [--udp [--addr hostname --port portnumber]] channel recsec destfile\n", cmd); + fprintf(stderr, "\n"); } void +show_options(vod) +{ + fprintf(stderr, "Options:\n"); + fprintf(stderr, "--b25: Decrypt using BCAS card\n"); + fprintf(stderr, " --round N: Specify round number\n"); + fprintf(stderr, " --strip: Strip null stream\n"); + fprintf(stderr, " --EMM: Instruct EMM operation\n"); + fprintf(stderr, "--udp: Turn on udp broadcasting\n"); + fprintf(stderr, " --addr hostname: Hostname or address to connect\n"); + fprintf(stderr, " --port portnumber: Port number to connect\n"); + fprintf(stderr, "--help: Show this help\n"); + fprintf(stderr, "\n"); +} +void show_channels(void) { - printf("Channel List:\n"); - printf("151ch:BS Asahi\n"); - printf("161ch:BS-i\n"); - printf("191ch:WOWOW\n"); - printf("171ch:BS Japan\n"); - printf("200ch:Star Channel\n"); - printf("211ch:BS11 Digital\n"); - printf("222ch:TwellV\n"); - printf("141ch:BS Nittele\n"); - printf("181ch:BS Fuji\n"); - printf("101ch:NHK BS1\n"); - printf("102ch:NHK BS2\n"); - printf("103ch:NHK BShi\n"); - printf("CS2-CS24:CS Channels\n"); + fprintf(stderr, "Available Channels:\n"); + fprintf(stderr, "13-52:Terrestrial Channels\n"); + fprintf(stderr, "151ch:BS Asahi\n"); + fprintf(stderr, "161ch:BS-i\n"); + fprintf(stderr, "191ch:WOWOW\n"); + fprintf(stderr, "171ch:BS Japan\n"); + fprintf(stderr, "200ch:Star Channel\n"); + fprintf(stderr, "211ch:BS11 Digital\n"); + fprintf(stderr, "222ch:TwellV\n"); + fprintf(stderr, "141ch:BS Nittele\n"); + fprintf(stderr, "181ch:BS Fuji\n"); + fprintf(stderr, "101ch:NHK BS1\n"); + fprintf(stderr, "102ch:NHK BS2\n"); + fprintf(stderr, "103ch:NHK BShi\n"); + fprintf(stderr, "CS2-CS24:CS Channels\n"); + fprintf(stderr, "\n"); } float @@ -407,8 +425,9 @@ { "emm", 0, NULL, 'm'}, { "EMM", 0, NULL, 'm'}, { "udp", 0, NULL, 'u'}, - { "host", 1, NULL, 'h'}, + { "addr", 1, NULL, 'a'}, { "port", 1, NULL, 'p'}, + { "help", 0, NULL, 'h'}, {0, 0, 0, 0} /* terminate */ }; @@ -419,7 +438,8 @@ int port_to = 1234; sock_data *sdata = NULL; - while((result = getopt_long(argc, argv, "br:smuh:p:", long_options, &option_index)) != -1) { + while((result = getopt_long(argc, argv, "br:smua:p:h", + long_options, &option_index)) != -1) { switch(result) { case 'b': use_b25 = TRUE; @@ -438,22 +458,18 @@ host_to = "localhost"; fprintf(stderr, "enable UDP broadcasting\n"); break; -/* - case ':': - fprintf(stderr, "%c needs value\n", result); + case 'h': + show_usage(argv[0]); + show_options(); + show_channels(); + exit(0); break; -*/ - case '?': - show_usage(argv[0]); - break; - - /* following options require argument */ case 'r': dopt.round = atoi(optarg); fprintf(stderr, "set round %d\n", dopt.round); break; - case 'h': + case 'a': use_udp = TRUE; host_to = optarg; fprintf(stderr, "UDP destination address: %s\n", host_to); @@ -467,20 +483,20 @@ if(argc - optind < 3) { if(argc - optind == 2 && use_udp) { - fprintf(stderr, "fileless udp broadcasting\n"); + fprintf(stderr, "Fileless UDP broadcasting\n"); fileless = TRUE; wfd = -1; } else { - show_usage(argv[0]); - show_channels(); + fprintf(stderr, "Arguments are necessary!\n"); + fprintf(stderr, "Try '%s --help' for more information.\n", argv[0]); return 1; } } /* get channel */ ptr = searchrecoff(argv[optind]); - if(ptr == NULL){ + if(ptr == NULL) { fprintf(stderr, "Channel Select Error(%s)\n", argv[optind]); return 1; } @@ -514,7 +530,7 @@ /* get recsec */ recsec = atoi(argv[optind + 1]); - if(recsec == 0) + if(recsec <= 0) indefinite = TRUE; /* initialize decoder */