/*
 * hextodec.java
 *
 * Created 23 Feb 2003 17:00
 */

/*
 * Copyright (C) s0gno
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

/**
 * Title:		HEX IP to DEC IP Converter
 * Description:	This simple proggy helps you figure out the
 *				DEC correspondant of an IP represented in
 *				HEX format. This is useful when trying to
 *				figure out the ip of a user connected to a
 *				Java IRC Chat such as the one on www.ircnet.com.
 *				Code is OpenSource under the terms of the GNU
 *				General Public Licence. I will not be held
 *				responsable for any appropriate use you make
 *				with this code (ie: you get an ip and then start
 *				a DDoS attack towards it etc.)
 * Copyright:	Copyright (c) 2003 s0gno
 * @author		s0gno
 * @version		0.1
 */
public class hextodec{

	public final static void usage(){
		System.out.println("HEX IP to DEC IP (hextodec.java) by s0gno");
		System.out.println("Usage:");
		System.out.println("java hextodec <hexip>");
		System.out.println("Ex:");
		System.out.println("java hextodec aabbccdd\n");
		System.out.println("|--------------------------GNU----------------------------|");
		System.out.println("|HexToDec version 0.1, Copyright (C) 2003 s0gno           |");
		System.out.println("|HexToDec comes with ABSOLUTELY NO WARRANTY               |");
		System.out.println("|This is free software, and you are welcome to            |");
		System.out.println("|redistribute it under certain conditions;                |");
		System.out.println("|for details go to http://www.gnu.org/copyleft/gpl.html   |");
		System.out.println("|---------------------------------------------------------|");
	}//usage

	public static void main(String args[]){
		
		String ip = "";
		
		try{
			if(args[0].length() == 8){
				
				for(int i = 0;i < args[0].length();i+=2){
					ip += Integer.parseInt(args[0].substring(i, i+2),16);
					if(i!=6)
						ip += ".";
					
				}//for
				System.out.println("IP : " + ip);
			}//if
			else
				usage();
			
		}catch(IndexOutOfBoundsException e){
			usage();
		}
		catch(NumberFormatException e){
			System.out.println("String HEX errata");	
		}
	}//main
}//class