1818#include <stdlib.h>
1919#include <stdio.h>
2020#ifndef _WIN32
21+ # include <libgen.h>
2122# include <unistd.h>
2223#else
24+ # include "perflib/basename.h"
2325# include "perflib/getopt.h"
2426#endif /* _WIN32 */
2527
@@ -246,12 +248,13 @@ static void do_hash_evp_shared(size_t num)
246248
247249static void print_help ()
248250{
249- printf ("Usage: evp_hash [-h] [-t] [-o operation] [-u update-times] [-a algorithm] thread-count\n" );
251+ printf ("Usage: evp_hash [-h] [-t] [-o operation] [-u update-times] [-a algorithm] [-V] thread-count\n" );
250252 printf ("-h - print this help output\n" );
251253 printf ("-t - terse output\n" );
252254 printf ("-o operation - mode of operation. One of [deprecated, evp_isolated, evp_shared] (default: evp_shared)\n" );
253255 printf ("-u update-times - times to update digest. 1 for one-shot (default: 1)\n" );
254256 printf ("-a algorithm - One of: [SHA1, SHA224, SHA256, SHA384, SHA512] (default: SHA1)\n" );
257+ printf ("-V - print version information and exit\n" );
255258 printf ("thread-count - number of threads\n" );
256259}
257260
@@ -263,7 +266,7 @@ int main(int argc, char *argv[])
263266 int terse = 0 , operation = EVP_SHARED , hash_algorithm = SHA1_ALG ;
264267 int j , opt , rc = EXIT_FAILURE ;
265268
266- while ((opt = getopt (argc , argv , "hto:u:a:" )) != -1 ) {
269+ while ((opt = getopt (argc , argv , "hto:u:a:V " )) != -1 ) {
267270 switch (opt ) {
268271 case 't' :
269272 terse = 1 ;
@@ -305,6 +308,10 @@ int main(int argc, char *argv[])
305308 goto out ;
306309 }
307310 break ;
311+ case 'V' :
312+ perflib_print_version (basename (argv [0 ]));
313+ rc = EXIT_SUCCESS ;
314+ goto out ;
308315 case 'h' :
309316 default :
310317 print_help ();
0 commit comments