8
8
#include "sha1.h"
9
9
10
10
11
- #define MSGMAXLEN 1024
11
+ #define MSGMAXLEN 4096
12
12
13
13
#define USAGE "USAGE: '%s' <message> [options]"
14
14
#define USAGE_HELP "See \"'%s' --help\" for more infos."
@@ -37,6 +37,7 @@ typedef enum hash_type {
37
37
38
38
// displays help page
39
39
void display_help (const char * command_argv0 );
40
+ void display_version (void );
40
41
int argparse (int argc , char * argv [], hash_type * htype , verbose * vblevel );
41
42
char * get_algorithm (hash_type hash );
42
43
void display_hash (word32 * H , hash_type htype , verbose vblevel );
@@ -54,6 +55,9 @@ int main(int argc, char *argv[]) {
54
55
} else if (strcmp (argv [1 ], "-h" )== 0 || strcmp (argv [1 ], "--help" )== 0 ) {
55
56
display_help (argv [0 ]);
56
57
return EXIT_SUCCESS ;
58
+ } else if (strcmp (argv [1 ], "--version" )== 0 ) {
59
+ display_version ();
60
+ return EXIT_SUCCESS ;
57
61
} else /* if (argc > 2)*/ { // If the command has arguments
58
62
int retval = argparse (argc ,argv ,& htype ,& vblevel );
59
63
if (retval != EXIT_SUCCESS ) {return EXIT_FAILURE ;}
@@ -242,9 +246,19 @@ char* get_algorithm(hash_type hash) {
242
246
return hashname ;
243
247
}
244
248
249
+ void display_version (void ) {
250
+ // printf("================================================================================\n");
251
+ printf ("shak version %s\n" ,SHAKVERSION );
252
+ printf ("Copyright (c) 2024 elfurioux\nMIT License, built with\n%s\n\n" ,GCCVERSION );
253
+ printf ("THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n" );
254
+ printf ("IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n" );
255
+ printf ("FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n" );
256
+ }
257
+
245
258
void display_help (const char * command_argv0 ) {
246
259
// printf("================================================================================\n");
247
260
printf (USAGE "\n\n" , command_argv0 );
261
+ printf (" --version Shows the version and copyright and exit.\n" );
248
262
printf (" --help Shows this help page then exit.\n" );
249
263
printf (" -h Equivalent of --help\n" );
250
264
printf (" --hash <hash> Specifies the type of hash to use. (default sha256)\n" );
@@ -267,8 +281,6 @@ void display_help(const char* command_argv0) {
267
281
printf (" gram does, display every computation step, might be a\n" );
268
282
printf (" bunch of informations.\n" );
269
283
printf (" --verbose=[0-2] equivalent of -v" );
270
-
271
- return ;
272
284
}
273
285
274
286
int argparse (int argc , char * argv [], hash_type * htype , verbose * vblevel ) {
0 commit comments