From 40efdd34d40100dc045c8e8ed9b9030a3cc2343c Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 5 Feb 2013 01:19:54 +0100 Subject: different commands for different output sizes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- java/sha3sum.java | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'java/sha3sum.java') diff --git a/java/sha3sum.java b/java/sha3sum.java index 6a122ff..ec00958 100644 --- a/java/sha3sum.java +++ b/java/sha3sum.java @@ -22,7 +22,7 @@ import java.util.*; /** - * SHA-3/Keccak chechsum calculator + * SHA-3/Keccak checksum calculator * * @author Mattias Andrée maandree@member.fsf.org */ @@ -31,12 +31,24 @@ public class sha3sum /** * This is the main entry point of the program * + * @param args Command line arguments + * @throws IOException On I/O error (such as broken pipes) + */ + public static void main(String[] args) throws IOException + { + run("sha3sum", args); + } + + + /** + * Run the program + * + * @param cmd The command * @param argv Command line arguments * @throws IOException On I/O error (such as broken pipes) */ - public static void main(String[] argv) throws IOException + public static void run(String cmd, String[] argv) throws IOException { - String cmd, _cmd = cmd = ""; //FIXME /proc/self/cmdline split ^@ [0] if (cmd.indexOf('/') >= 0) cmd = cmd.substring(cmd.lastIndexOf('/') + 1); if (cmd.endsWith(".jar")) @@ -138,7 +150,7 @@ public class sha3sum i = Integer.parseInt(linger[1]); else { - System.err.println(_cmd + ": unrecognised option: " + linger[0]); + System.err.println(cmd + ": unrecognised option: " + linger[0]); System.exit(1); } } @@ -183,7 +195,7 @@ public class sha3sum files[fptr++] = null; if (i < 1) { - System.err.println(_cmd + ": sorry, I will only do at least one iteration!\n"); + System.err.println(cmd + ": sorry, I will only do at least one iteration!\n"); System.exit(3); } @@ -237,7 +249,7 @@ public class sha3sum } } catch (final IOException err) - { System.err.println(_cmd + ": Cannot read file: " + filename + ": " + err); + { System.err.println(cmd + ": Cannot read file: " + filename + ": " + err); fail = true; } finally @@ -253,5 +265,6 @@ public class sha3sum if (fail) System.exit(5); } + } -- cgit v1.2.3-70-g09d2