I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit b7207fd2 authored by zzz's avatar zzz
Browse files

Use getopt lib in SU3File (ticket #1173)

parent 4dc1241d
No related branches found
No related tags found
No related merge requests found
...@@ -26,6 +26,8 @@ import java.util.Map; ...@@ -26,6 +26,8 @@ import java.util.Map;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.Properties; import java.util.Properties;
import gnu.getopt.Getopt;
import net.i2p.I2PAppContext; import net.i2p.I2PAppContext;
import net.i2p.data.DataFormatException; import net.i2p.data.DataFormatException;
import net.i2p.data.DataHelper; import net.i2p.data.DataHelper;
...@@ -437,27 +439,37 @@ public class SU3File { ...@@ -437,27 +439,37 @@ public class SU3File {
*/ */
public static void main(String[] args) { public static void main(String[] args) {
boolean ok = false; boolean ok = false;
List<String> a = new ArrayList<String>(Arrays.asList(args));
try { try {
// defaults // defaults
String stype = null; String stype = null;
String ctype = null; String ctype = null;
Iterator<String> iter = a.iterator(); boolean error = false;
String cmd = iter.next(); Getopt g = new Getopt("SU3File", args, "t:c:");
iter.remove(); int c;
for ( ; iter.hasNext(); ) { while ((c = g.getopt()) != -1) {
String arg = iter.next(); switch (c) {
if (arg.equals("-t")) { case 't':
iter.remove(); stype = g.getOptarg();
stype = iter.next(); break;
iter.remove();
} else if (arg.equals("-c")) { case 'c':
iter.remove(); ctype = g.getOptarg();
ctype = iter.next(); break;
iter.remove();
} case '?':
case ':':
default:
error = true;
}
} }
if ("showversion".equals(cmd)) {
int idx = g.getOptind();
String cmd = args[idx];
List<String> a = new ArrayList<String>(Arrays.asList(args).subList(idx + 1, args.length));
if (error) {
showUsageCLI();
} else if ("showversion".equals(cmd)) {
ok = showVersionCLI(a.get(0)); ok = showVersionCLI(a.get(0));
} else if ("sign".equals(cmd)) { } else if ("sign".equals(cmd)) {
// speed things up by specifying a small PRNG buffer size // speed things up by specifying a small PRNG buffer size
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment