Mercurial > pt1.oyama
comparison recpt1/recpt1.c @ 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 |
comparison
equal
deleted
inserted
replaced
13:003fe2470af8 | 14:cad940a903f5 |
---|---|
286 } | 286 } |
287 | 287 |
288 void | 288 void |
289 show_usage(char *cmd) | 289 show_usage(char *cmd) |
290 { | 290 { |
291 fprintf(stderr, "Usage: %s [--b25 [--round N] [--strip] [--EMM]] [--udp [--host hostname --port port]] channel recsec destfile\n", cmd); | 291 fprintf(stderr, "\n"); |
292 } | 292 fprintf(stderr, "Usage: \n%s [--b25 [--round N] [--strip] [--EMM]] [--udp [--addr hostname --port portnumber]] channel recsec destfile\n", cmd); |
293 | 293 fprintf(stderr, "\n"); |
294 } | |
295 | |
296 void | |
297 show_options(vod) | |
298 { | |
299 fprintf(stderr, "Options:\n"); | |
300 fprintf(stderr, "--b25: Decrypt using BCAS card\n"); | |
301 fprintf(stderr, " --round N: Specify round number\n"); | |
302 fprintf(stderr, " --strip: Strip null stream\n"); | |
303 fprintf(stderr, " --EMM: Instruct EMM operation\n"); | |
304 fprintf(stderr, "--udp: Turn on udp broadcasting\n"); | |
305 fprintf(stderr, " --addr hostname: Hostname or address to connect\n"); | |
306 fprintf(stderr, " --port portnumber: Port number to connect\n"); | |
307 fprintf(stderr, "--help: Show this help\n"); | |
308 fprintf(stderr, "\n"); | |
309 } | |
294 void | 310 void |
295 show_channels(void) | 311 show_channels(void) |
296 { | 312 { |
297 printf("Channel List:\n"); | 313 fprintf(stderr, "Available Channels:\n"); |
298 printf("151ch:BS Asahi\n"); | 314 fprintf(stderr, "13-52:Terrestrial Channels\n"); |
299 printf("161ch:BS-i\n"); | 315 fprintf(stderr, "151ch:BS Asahi\n"); |
300 printf("191ch:WOWOW\n"); | 316 fprintf(stderr, "161ch:BS-i\n"); |
301 printf("171ch:BS Japan\n"); | 317 fprintf(stderr, "191ch:WOWOW\n"); |
302 printf("200ch:Star Channel\n"); | 318 fprintf(stderr, "171ch:BS Japan\n"); |
303 printf("211ch:BS11 Digital\n"); | 319 fprintf(stderr, "200ch:Star Channel\n"); |
304 printf("222ch:TwellV\n"); | 320 fprintf(stderr, "211ch:BS11 Digital\n"); |
305 printf("141ch:BS Nittele\n"); | 321 fprintf(stderr, "222ch:TwellV\n"); |
306 printf("181ch:BS Fuji\n"); | 322 fprintf(stderr, "141ch:BS Nittele\n"); |
307 printf("101ch:NHK BS1\n"); | 323 fprintf(stderr, "181ch:BS Fuji\n"); |
308 printf("102ch:NHK BS2\n"); | 324 fprintf(stderr, "101ch:NHK BS1\n"); |
309 printf("103ch:NHK BShi\n"); | 325 fprintf(stderr, "102ch:NHK BS2\n"); |
310 printf("CS2-CS24:CS Channels\n"); | 326 fprintf(stderr, "103ch:NHK BShi\n"); |
327 fprintf(stderr, "CS2-CS24:CS Channels\n"); | |
328 fprintf(stderr, "\n"); | |
311 } | 329 } |
312 | 330 |
313 float | 331 float |
314 getsignal_isdb_s(int signal) | 332 getsignal_isdb_s(int signal) |
315 { | 333 { |
405 { "round", 1, NULL, 'r'}, | 423 { "round", 1, NULL, 'r'}, |
406 { "strip", 0, NULL, 's'}, | 424 { "strip", 0, NULL, 's'}, |
407 { "emm", 0, NULL, 'm'}, | 425 { "emm", 0, NULL, 'm'}, |
408 { "EMM", 0, NULL, 'm'}, | 426 { "EMM", 0, NULL, 'm'}, |
409 { "udp", 0, NULL, 'u'}, | 427 { "udp", 0, NULL, 'u'}, |
410 { "host", 1, NULL, 'h'}, | 428 { "addr", 1, NULL, 'a'}, |
411 { "port", 1, NULL, 'p'}, | 429 { "port", 1, NULL, 'p'}, |
430 { "help", 0, NULL, 'h'}, | |
412 {0, 0, 0, 0} /* terminate */ | 431 {0, 0, 0, 0} /* terminate */ |
413 }; | 432 }; |
414 | 433 |
415 int use_b25 = FALSE; | 434 int use_b25 = FALSE; |
416 int use_udp = FALSE; | 435 int use_udp = FALSE; |
417 int fileless = FALSE; | 436 int fileless = FALSE; |
418 char *host_to = NULL; | 437 char *host_to = NULL; |
419 int port_to = 1234; | 438 int port_to = 1234; |
420 sock_data *sdata = NULL; | 439 sock_data *sdata = NULL; |
421 | 440 |
422 while((result = getopt_long(argc, argv, "br:smuh:p:", long_options, &option_index)) != -1) { | 441 while((result = getopt_long(argc, argv, "br:smua:p:h", |
442 long_options, &option_index)) != -1) { | |
423 switch(result) { | 443 switch(result) { |
424 case 'b': | 444 case 'b': |
425 use_b25 = TRUE; | 445 use_b25 = TRUE; |
426 fprintf(stderr, "using B25...\n"); | 446 fprintf(stderr, "using B25...\n"); |
427 break; | 447 break; |
436 case 'u': | 456 case 'u': |
437 use_udp = TRUE; | 457 use_udp = TRUE; |
438 host_to = "localhost"; | 458 host_to = "localhost"; |
439 fprintf(stderr, "enable UDP broadcasting\n"); | 459 fprintf(stderr, "enable UDP broadcasting\n"); |
440 break; | 460 break; |
441 /* | 461 case 'h': |
442 case ':': | |
443 fprintf(stderr, "%c needs value\n", result); | |
444 break; | |
445 */ | |
446 case '?': | |
447 show_usage(argv[0]); | 462 show_usage(argv[0]); |
448 break; | 463 show_options(); |
449 | 464 show_channels(); |
450 | 465 exit(0); |
466 break; | |
451 /* following options require argument */ | 467 /* following options require argument */ |
452 case 'r': | 468 case 'r': |
453 dopt.round = atoi(optarg); | 469 dopt.round = atoi(optarg); |
454 fprintf(stderr, "set round %d\n", dopt.round); | 470 fprintf(stderr, "set round %d\n", dopt.round); |
455 break; | 471 break; |
456 case 'h': | 472 case 'a': |
457 use_udp = TRUE; | 473 use_udp = TRUE; |
458 host_to = optarg; | 474 host_to = optarg; |
459 fprintf(stderr, "UDP destination address: %s\n", host_to); | 475 fprintf(stderr, "UDP destination address: %s\n", host_to); |
460 break; | 476 break; |
461 case 'p': | 477 case 'p': |
465 } | 481 } |
466 } | 482 } |
467 | 483 |
468 if(argc - optind < 3) { | 484 if(argc - optind < 3) { |
469 if(argc - optind == 2 && use_udp) { | 485 if(argc - optind == 2 && use_udp) { |
470 fprintf(stderr, "fileless udp broadcasting\n"); | 486 fprintf(stderr, "Fileless UDP broadcasting\n"); |
471 fileless = TRUE; | 487 fileless = TRUE; |
472 wfd = -1; | 488 wfd = -1; |
473 } | 489 } |
474 else { | 490 else { |
475 show_usage(argv[0]); | 491 fprintf(stderr, "Arguments are necessary!\n"); |
476 show_channels(); | 492 fprintf(stderr, "Try '%s --help' for more information.\n", argv[0]); |
477 return 1; | 493 return 1; |
478 } | 494 } |
479 } | 495 } |
480 | 496 |
481 /* get channel */ | 497 /* get channel */ |
482 ptr = searchrecoff(argv[optind]); | 498 ptr = searchrecoff(argv[optind]); |
483 if(ptr == NULL){ | 499 if(ptr == NULL) { |
484 fprintf(stderr, "Channel Select Error(%s)\n", argv[optind]); | 500 fprintf(stderr, "Channel Select Error(%s)\n", argv[optind]); |
485 return 1; | 501 return 1; |
486 } | 502 } |
487 | 503 |
488 freq.frequencyno = ptr->set_freq; | 504 freq.frequencyno = ptr->set_freq; |
512 } | 528 } |
513 } | 529 } |
514 | 530 |
515 /* get recsec */ | 531 /* get recsec */ |
516 recsec = atoi(argv[optind + 1]); | 532 recsec = atoi(argv[optind + 1]); |
517 if(recsec == 0) | 533 if(recsec <= 0) |
518 indefinite = TRUE; | 534 indefinite = TRUE; |
519 | 535 |
520 /* initialize decoder */ | 536 /* initialize decoder */ |
521 if(use_b25) { | 537 if(use_b25) { |
522 dec = b25_startup(&dopt); | 538 dec = b25_startup(&dopt); |