// This is the main class of Image2HTML. It handle the command line. public class Image2HTML { static Preferences prefs; public static void main(String args[]) { // Parse the command line prefs = new Preferences(); for (int i = 0; i < args.length; i++) { if (args[i].equals("-url")) { prefs.urlString = args[i+1]; i++; } else if (args[i].equals("-tofile")) { prefs.toFile = args[i+1]; i++; } else if (args[i].equals("-xscale")) { prefs.xscale = Integer.parseInt(args[i+1]); i++; } else if (args[i].equals("-yscale")) { prefs.yscale = Integer.parseInt(args[i+1]); i++; } else if (args[i].equals("-border")) { prefs.border = Integer.parseInt(args[i+1]); i++; } else if (args[i].equals("-cellspacing")) { prefs.cellspacing = Integer.parseInt(args[i+1]); i++; } else if (args[i].equals("-nospacers")) { prefs.spacers = false; } else if (args[i].equals("-tableonly")) { prefs.fullpage = false; } else if (args[i].equals("-compress")) { prefs.compress = true; } else if (args[i].equals("-cgi")) { prefs.cgi = true; } else { System.out.println("usage: java Image2HTML -url {URL}"); System.out.println(" [-tofile {pathname}]"); System.out.println(" [-xscale {integer}]"); System.out.println(" [-yscale {integer}]"); System.out.println(" [-compress]"); System.out.println(" [-border {integer}]"); System.out.println(" [-cellspacing {integer}]"); System.out.println(" [-nospacers]"); System.out.println(" [-tableonly]"); System.out.println(" [-cgi]"); System.out.println("invalid arg: " + args[i]); System.exit(0); } // usage error } // for args if (prefs.urlString == null) { System.out.println("You must specify an url; use -usage to see usage"); System.exit(-1); } // Get and process the image ImageFetcher imageFetched = new ImageFetcher(prefs); } // main() static public void ErrorExit(String errorMsg) { // In CGI mode, we send everything to stdout if (prefs.cgi) System.out.println("Error: " + errorMsg); else System.err.println("Error: " + errorMsg); System.exit(-1); } //==== ErrorExit() ====// } // class Image2HTML