summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeppia <seppia@seppia.net>2018-07-04 09:40:30 +0200
committerSeppia <seppia@seppia.net>2018-07-04 09:40:30 +0200
commite1da443c111a766720d5e1dd94b9c88be64eff69 (patch)
treed3396b78bece9241e5d36128cfd328a499753897
parente394bf500ca25af51abfe6bf46360236c59d623a (diff)
downloadonetimebluh-e1da443c111a766720d5e1dd94b9c88be64eff69.tar.gz
onetimebluh-e1da443c111a766720d5e1dd94b9c88be64eff69.tar.bz2
onetimebluh-e1da443c111a766720d5e1dd94b9c88be64eff69.zip
Messages update
This commit updates the messages targetd to the user to be more consistent and adds message types such as INFO, WARNING and ERROR.
-rw-r--r--src/onetimebluh.c49
1 files changed, 24 insertions, 25 deletions
diff --git a/src/onetimebluh.c b/src/onetimebluh.c
index f19137b..0760036 100644
--- a/src/onetimebluh.c
+++ b/src/onetimebluh.c
@@ -74,7 +74,7 @@ int main (int argc, char* argv[]) {
break;
case 'c':
if (strlen (argv[optind - 1]) != 2){
- printf ("Too much or too many characters inserted!");
+ printf ("ERROR: too much or too many characters inserted! You must insert exactly two characters.");
exit (EXIT_FAILURE);
}
opzioni.chars = argv[optind - 1];
@@ -117,7 +117,7 @@ int main (int argc, char* argv[]) {
} else if (sip[0] == 'T') {
opzioni.nbytes = opzioni.nbytes*1024*1024*1024*1024;
} else if (sip[0] != '\0') {
- printf ("You must specify the size in KiB, MiB, GiB or TiB, respectively using K, M, G or T, or nothing for single bytes.");
+ printf ("ERROR: you must specify the size in KiB, MiB, GiB or TiB, respectively using K, M, G or T, or nothing for just bytes.");
exit (EXIT_FAILURE);
}
break;
@@ -148,16 +148,16 @@ int main (int argc, char* argv[]) {
/* Next section performs some input checks */
if (!command) {
- printf ("%s: No command called\n", argv[0]);
+ printf ("ERROR: no command called\n");
exit (EXIT_FAILURE);
} else if (command > 1) {
- printf ("Multiple commands called\n");
+ printf ("ERROR: multiple commands called\n");
printf ("%s [COMMAND] [OPTIONS] ...\n", argv[0]);
exit (EXIT_FAILURE);
}
if (optind < argc) {
- printf ("%s: Too many arguments\n", argv[0]);
+ printf ("ERROR: too many arguments\n");
exit (EXIT_FAILURE);
}
@@ -165,7 +165,7 @@ int main (int argc, char* argv[]) {
if (opzioni.comm == 'e' || opzioni.comm == 'd') {
if (opzioni.keyfile == NULL) {
- printf ("%s: No key specified: exit!\n", argv[0]);
+ printf ("ERROR: no key specified\n");
exit (EXIT_FAILURE);
}
xor (&opzioni);
@@ -188,12 +188,12 @@ void xor (Opts* opzioni) {
if (opzioni->output == NULL) {
if (opzioni->comm == 'e') {
if (!opzioni->quiet) {
- printf ("WARNING no output name specified using default value 'critt' \n");
+ printf ("WARNING: no output name specified using default value 'critt'\n");
}
opzioni->output = defenout;
} else if (opzioni->comm == 'd') {
if (!opzioni->quiet) {
- printf ("WARNING no output name specified usign default value 'decritt' \n");
+ printf ("WARNING: no output name specified usign default value 'decritt'\n");
}
opzioni->output = defdeout;
}
@@ -231,8 +231,8 @@ void xor (Opts* opzioni) {
fseek (keyx, 0L, SEEK_END);
int64_t new_pad_size = ftell (keyx);
if (!opzioni->quiet) {
- printf ("Your pad is now %li bytes shorter \n", mess_size);
- printf ("You now have %li bytes left \n", new_pad_size);
+ printf ("INFO: your pad is now %li bytes shorter\n", mess_size);
+ printf ("INFO: you now have %li bytes left\n", new_pad_size);
}
}
@@ -244,11 +244,11 @@ void xor (Opts* opzioni) {
if (opzioni->comm == 'e') {
if (!opzioni->quiet) {
- printf ("Message successfully encrypted \n");
+ printf ("INFO: message successfully encrypted\n");
}
} else if (opzioni->comm == 'd') {
if (!opzioni->quiet) {
- printf ("Message successfully decrypted \n");
+ printf ("INFO: message successfully decrypted\n");
}
}
@@ -263,19 +263,18 @@ void keyrand (Opts* opzioni) {
if((opzioni->nbytes == -1) && (opzioni->output == NULL)) {
if (!opzioni->quiet) {
- printf ("WARNING no option specified usign default values... \n");
+ printf ("WARNING: no option specified using default values\n");
}
opzioni->nbytes = 1048576;
opzioni->output = defout;
}
if (opzioni->nbytes < -1) { // orribile
- printf ("Negative byte value inserted! \n");
- printf ("Exiting... \n");
+ printf ("ERROR: negative byte value inserted!\n");
exit (EXIT_FAILURE);
} else if (opzioni->nbytes) {
if(opzioni->nbytes == -1) {
if (!opzioni->quiet) {
- printf ("No byte number specified... using default value: 1MB \n");
+ printf ("WARNING: no byte number specified, using default value: 1MB\n");
}
opzioni->nbytes = 1048576;
}
@@ -283,12 +282,12 @@ void keyrand (Opts* opzioni) {
if (opzioni->output == NULL) {
opzioni->output = defout;
if (!opzioni->quiet) {
- printf ("No output name specified... using default value: default.key \n");
+ printf ("WARNING: no output name specified, using default value: default.key\n");
}
}
if (!opzioni->quiet) {
- printf ("Generating pad...\n");
+ printf ("INFO: generating pad...\n");
}
unsigned char* key = malloc (opzioni->nbytes);
RAND_bytes (key, opzioni->nbytes);
@@ -298,11 +297,11 @@ void keyrand (Opts* opzioni) {
fclose (file);
free (key);
if (!opzioni->quiet) {
- printf ("Created key file %s of %ld bytes \n", opzioni->output, opzioni->nbytes);
+ printf ("INFO: created key file %s of %ld bytes\n", opzioni->output, opzioni->nbytes);
}
} else {
- printf ("Byte number specified is 0. \n");
- printf ("Doing nothing! \n");
+ printf ("WARNING: byte number specified is 0.\n");
+ printf ("WARNING: doing nothing!\n");
}
return;
@@ -320,12 +319,12 @@ void bluh (Opts* opzioni) {
if (opzioni->output == NULL) {
if (opzioni->comm == 'b') {
if (!opzioni->quiet) {
- printf ("WARNING no output name specified using default value 'bluhed' \n");
+ printf ("WARNING: no output name specified, using default value 'bluhed'\n");
}
opzioni->output = defbluh;
} else if (opzioni->comm == 'u') {
if (!opzioni->quiet) {
- printf ("WARNING no output name specified usign default value 'unbluhed' \n");
+ printf ("WARNING: no output name specified, using default value 'unbluhed'\n");
}
opzioni->output = defunbluh;
}
@@ -359,7 +358,7 @@ void bluh (Opts* opzioni) {
free (bits);
if (!opzioni->quiet) {
- printf ("Message successfully bluhed!\n");
+ printf ("INFO: message successfully bluhed!\n");
}
} else if (opzioni->comm == 'u') {
@@ -384,7 +383,7 @@ void bluh (Opts* opzioni) {
free (bits);
if (!opzioni->quiet) {
- printf ("Message successfully unbluhed!\n");
+ printf ("INFO: message successfully unbluhed!\n");
}
}