- if (strcmp(*argv, "-h") == 0) {
- argc--, argv++;
- if (argc < 1) {
- printf("-h: missing host #\n");
- exit(2);
- }
- host = atoi(*argv);
- argv++, argc--;
- continue;
- }
- if (strcmp(*argv, "-i") == 0) {
- argc--, argv++;
- if (argc < 1) {
- printf("-i: missing imp #\n");
- exit(2);
- }
- imp = atoi(*argv);
- argv++, argc--;
- continue;
- }
- if (strcmp(*argv, "-t") == 0) {
- argc--, argv++;;
- if (argc < 1) {
- printf("-t: missing packet type\n");
- exit(2);
- }
- packettype = atoi(*argv);
- argv++, argc--;;
- continue;
- }
- printf("usage: implog [ -D ] [ -c ] [ -f ] [ -r ] [-h #] [-i #] [ -t # ] [-l [#]] [logfile]\n");
- exit(2);
- }
- if (argc > 0)
- logfile = argv[0];
- log = open(logfile, 0);
- if (log < 0) {
- perror(logfile);
+ argc -= optind;
+ argv += optind;
+
+ logfile = argc ? *argv : _PATH_IMPLOG;
+ log = open(logfile, O_RDONLY, 0);
+ if (log < 0 || fstat(log, &b)) {
+ fprintf(stderr, "implog: %s: %s\n", logfile, strerror(errno));