From 912b7bf0410a0ce98acbbded890c452ca7a7261a Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 28 Apr 1999 10:58:13 +0000 Subject: [PATCH] Use GlobalOptions. new flag syntax git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@676 379699f6-c40d-0410-875b-85095c16579e --- jode/jode/obfuscator/Main.java | 126 ++++++++++++++++++--------------- 1 file changed, 68 insertions(+), 58 deletions(-) diff --git a/jode/jode/obfuscator/Main.java b/jode/jode/obfuscator/Main.java index baea557..d7060f7 100644 --- a/jode/jode/obfuscator/Main.java +++ b/jode/jode/obfuscator/Main.java @@ -25,14 +25,10 @@ import java.lang.reflect.Modifier; import java.io.PrintStream; public class Obfuscator { - public static int verboseLevel = 0; - public static boolean isDebugging = false; - public static boolean shouldStrip = true; public static boolean swapOrder = false; public static boolean preserveSerial = true; - public static PrintStream err = System.err; public static final int PRESERVE_NONE = 0; public static final int PRESERVE_PUBLIC = Modifier.PUBLIC; public static final int PRESERVE_PROTECTED = @@ -44,46 +40,55 @@ public class Obfuscator { public static final int RENAME_WEAK = 1; public static final int RENAME_UNIQUE = 2; public static final int RENAME_NONE = 3; - public static final int RENAME_TABLE = 4; public static void usage() { + PrintStream err = GlobalOptions.err; err.println("usage: jode.Obfuscator flags* [class | package]*"); - err.println("\t[-v] "+ + err.println("\t-v "+ "Verbose output (allowed multiple times)."); - err.println("\t[-debug] "+"Debugging"); - err.println("\t[-nostrip] "+ + err.println("\t--nostrip "+ "Don't strip not needed methods"); - err.println("\t[-cp ] "+ + err.println("\t--cp "+ "The class path; should contain classes.zip"); - err.println("\t[-d ] "+ + err.println("\t-d,--dest "+ "Destination directory for output classes"); err.println("Preserve options: "); - err.println("\t[-package] "+ + err.println("\t--package "+ "Preserve all package members"); - err.println("\t[-protected] "+ + err.println("\t--protected "+ "Preserve all protected members"); - err.println("\t[-public] "+ + err.println("\t--public "+ "Preserve all public members"); - err.println("\t[-preserve ] "+ + err.println("\t--preserve "+ "Preserve only the given name (allowed multiple times)"); - err.println("\t[-breakserial] "+ + err.println("\t--breakserial "+ "Allow the serialized form to change"); err.println("Obfuscating options: "); - err.println("\t[-strong] "+ - "Rename identifiers to random unicode identifier"); - err.println("\t[-weak] "+ - "Rename to random, but legal java identifier"); - err.println("\t[-unique] "+ - "Rename to unique legal java identifier"); - err.println("\t[-none] "+ - "Don't rename any method."); - err.println("\t[-table ] "+ + err.println("\t--rename={strong|weak|unique|none} "+ + "Rename identifiers with given scheme"); + err.println("\t--table "+ "Read (some) translation table from file"); - err.println("\t[-revtable ] "+ + err.println("\t--revtable "+ "Write reversed translation table to file"); - err.println("\t[-swaporder] "+ + err.println("\t--swaporder "+ "Swap the order of fields and methods."); + err.println("\t--debug=... "+ + "use --debug=help for more information."); + } + + public static int parseRenameOption(String option) { + if (option.equals("strong")) + return RENAME_STRONG; + else if (option.equals("--weak")) + return RENAME_WEAK; + else if (option.equals("--unique")) + return RENAME_UNIQUE; + else if (option.equals("--none")) + return RENAME_NONE; + usage(); + System.exit(0); + return 0; } public static void main(String[] params) { @@ -100,86 +105,91 @@ public class Obfuscator { for (i=0; i