View | Details | Raw Unified | Return to bug 5387
Collapse All | Expand All

(-)md5/md5.1 (-2 / +2 lines)
Lines 9-15 Link Here
9
.Op Fl p
9
.Op Fl p
10
.Op Fl t
10
.Op Fl t
11
.Op Fl x
11
.Op Fl x
12
.Op Fl s Ns Ar string
12
.Op Fl s Ar string
13
.Op Ar filename Ns Pq s
13
.Op Ar filename Ns Pq s
14
.Sh DESCRIPTION
14
.Sh DESCRIPTION
15
.Nm
15
.Nm
Lines 34-40 Link Here
34
.Ar filename Ns Pq s
34
.Ar filename Ns Pq s
35
must be the last objects on the command line.
35
must be the last objects on the command line.
36
.Bl -tag -width Fl
36
.Bl -tag -width Fl
37
.It Fl s Ns Ar string
37
.It Fl s Ar string
38
prints a checksum of the given
38
prints a checksum of the given
39
.Dq string .
39
.Dq string .
40
.It Fl p
40
.It Fl p
(-)md5/md5.c (-14 / +40 lines)
Lines 40-45 Link Here
40
static void MDTimeTrial PROTO_LIST((void));
40
static void MDTimeTrial PROTO_LIST((void));
41
static void MDTestSuite PROTO_LIST((void));
41
static void MDTestSuite PROTO_LIST((void));
42
static void MDFilter PROTO_LIST((int));
42
static void MDFilter PROTO_LIST((int));
43
static void usage PROTO_LIST((void));
43
44
44
/* Main driver.
45
/* Main driver.
45
46
Lines 58-82 Link Here
58
	int     i;
59
	int     i;
59
	char   *p;
60
	char   *p;
60
	char	buf[33];
61
	char	buf[33];
62
	extern char 	*optarg;
63
	extern int	optind;
61
64
62
	if (argc > 1)
65
	if (argc > 1) {
63
		for (i = 1; i < argc; i++)
66
		while ((i = getopt(argc, argv, "s:tpx")) != EOF) {
64
			if (argv[i][0] == '-' && argv[i][1] == 's')
67
			switch(i) {
65
				MDString(argv[i] + 2);
68
			case 's':
66
			else if (strcmp(argv[i], "-t") == 0)
69
				MDString(optarg);
70
				break;
71
			case 't':
67
				MDTimeTrial();
72
				MDTimeTrial();
68
			else if (strcmp(argv[i], "-p") == 0)
73
				break;
74
			case 'p':
69
				MDFilter(1);
75
				MDFilter(1);
70
			else if (strcmp(argv[i], "-x") == 0)
76
				break;
77
			case 'x':
71
				MDTestSuite();
78
				MDTestSuite();
72
			else {
79
				break;
73
				p = MD5File(argv[i],buf);
80
			default:
74
				if (!p)
81
				usage();
75
					perror(argv[i]);
76
				else
77
					printf("MD5 (%s) = %s\n", argv[i], p);
78
			}
82
			}
79
	else
83
		}
84
85
		while (optind < argc) {
86
			p = MD5File(argv[optind],buf);
87
			if (!p)
88
				perror(argv[optind]);
89
			else
90
				printf("MD5 (%s) = %s\n", argv[optind], p);
91
			optind++;
92
		}
93
	} else
80
		MDFilter(0);
94
		MDFilter(0);
81
95
82
	return (0);
96
	return (0);
Lines 174-177 Link Here
174
		MD5Update(&context, buffer, len);
188
		MD5Update(&context, buffer, len);
175
	}
189
	}
176
	printf("%s\n", MD5End(&context,buf));
190
	printf("%s\n", MD5End(&context,buf));
191
}
192
193
/*
194
 * Displays a usage summary.
195
 */
196
197
static void
198
usage(void)
199
{
200
	(void)fprintf(stderr,
201
		"usage: md5 [-p] [-t] [-x] [-s string] [filename(s)]\n");
202
	exit(1);
177
}
203
}

Return to bug 5387