001:
002:
003:
004:
005:
006:
007:
008: public class MainEntry {
009:
010: private static boolean FLG_BACKGROUND = false;
011: private static boolean FLG_ONCE = false;
012: private static boolean FLG_SETUP_CONFIGURATION = false;
013: private static boolean FLG_DISPLAY_OUTPUT = false;
014: private static boolean FLG_DISPLAY_HELP = false;
015: private static boolean FLG_SHOW_LICENSE = false;
016:
017:
018:
019:
020:
021:
022: public static void main( String args[ ] )
023: {
024:
025: char c;
026: byte char_position;
027: byte arg_position = 0;
028:
029:
030: do {
031: String parameter;
032: if( args.length == 0)
033: parameter ="-h";
034: else
035: parameter = args[ arg_position++ ];
036:
037: char_position = 0;
038: do {
039: c = parameter.charAt( char_position++ );
040:
041: if( c == '-' ) continue;
042:
043: switch( c ) {
044:
045: case 'w' : FLG_SHOW_LICENSE = true;
046: break;
047: case 'c' : FLG_SHOW_LICENSE = true;
048: break;
049:
050: case 'h' : FLG_DISPLAY_HELP = true;
051: break;
052: case '?' : FLG_DISPLAY_HELP = true;
053: break;
054:
055: case 's' : FLG_SETUP_CONFIGURATION = true;
056: break;
057: case 'o' : FLG_ONCE = true;
058:
059: case 'b': FLG_BACKGROUND = true;
060: break;
061:
062: case 'd' : FLG_DISPLAY_OUTPUT = true;
063: if( !FLG_BACKGROUND )
064: FLG_ONCE = true;
065: break;
066: default :
067: System.out.println( "ERROR: Wrong parameter - ' " + c +" '");
068: FLG_DISPLAY_HELP = true;
069: }
070: } while( char_position < parameter.length( ) );
071: }while( arg_position < args.length );
072:
073: if( FLG_SHOW_LICENSE ) display_license( );
074: else if( FLG_DISPLAY_HELP ) display_help( );
075: else if( FLG_ONCE ) run_once( FLG_DISPLAY_OUTPUT );
076: else if( FLG_BACKGROUND ) run_in_background( FLG_DISPLAY_OUTPUT );
077: else if( FLG_SETUP_CONFIGURATION ) run_configuration( );
078:
079: }
080:
081:
082:
083:
084:
085: public static void run_configuration( )
086: {
087: String user_name, user_pass;
088: System.out.println("\n\t\tLogMyIP Ayarlar:");
089: System.out.println("\t\t================\n");
090: System.out.println("Programı kullanabilmek için kullanıcı adı ve şifre almanız gerekmektedir.");
091: System.out.println("Bunun için, http://www.cagataycebi.com/projects/LogMyIP adresini ziyaret edin.");
092: System.out.println("Alacağınız kullanıcı adı ve şifreyi 's' parametresiyle, programa tanıtın.");
093: System.out.println("LogMyIP programını bu aşamadan sonra kullanabilirsiniz.");
094: System.out.println("Eğer daha önce kullanıcı adı ve şifre aldıysanız, bu uyarıyı dikkate almayın.\n\n");
095: System.out.print("Kullanıcı Adı> ");
096: user_name = SavitchIn.readLine( );
097: System.out.print("Şifre> ");
098: user_pass = SavitchIn.readLine( );
099: Configuration.write_configuration_file(user_name, user_pass);
100:
101: }
102:
103:
104:
105:
106:
107:
108: public static void run_in_background( boolean output_option )
109: {
110: LogService logger = new LogService( output_option );
111: logger.start( );
112: }
113:
114:
115:
116:
117:
118: public static void run_once( boolean output_option )
119: {
120: LogService logger = new LogService( output_option );
121: logger.run_once( );
122: logger = null;
123: }
124:
125:
126:
127:
128:
129: public static void display_license( )
130: {
131: System.out.println("\n\tLogMyIP 1.0, Copyright (C) 2006 Çağatay ÇEBİ"+
132: "\n\thttp://www.cagataycebi.com - cagataycebi@gmail.com" +
133: "\n\tLogMyIP, GPL lisansı altında dağıtılmaktadır. " +
134: "\n\tPaket içersinde bulunan, GPL lisansında " +
135: "\n\tdetayları bulabilirsiniz.\n" );
136: }
137:
138:
139:
140:
141: public static void display_help( )
142: {
143: System.out.println("\n\t\tLogMyIP Yardım:");
144: System.out.println("\t\t==============\n");
145: System.out.println("Programı kullanabilmek için kullanıcı adı ve şifre almanız gerekmektedir.");
146: System.out.println("Bunun için, http://www.cagataycebi.com/projects/LogMyIP adresini ziyaret edin.");
147: System.out.println("Alacağınız kullanıcı adı ve şifreyi 's' parametresiyle, programa tanıtın.");
148: System.out.println("LogMyIP programını bu aşamadan sonra kullanabilirsiniz.");
149: System.out.println("\nParametreler:\n");
150: System.out.println(" -h veya ?:\t Yardım dosyasını gösterir.");
151: System.out.println(" -s:\t\t Kullanıcı adı ve şifrenizi yapılandırmanızı sağlar.");
152: System.out.println(" -o:\t\t Programı yalnızca bir kere çalıştırır.");
153: System.out.println(" -b:\t\t Programı, arka planda sürekli çalıştırır. ");
154: System.out.println(" -d:\t\t Çalışma durumu ekrana çıktı olarak basar.\n");
155: System.out.println(" ÖRNEK: java -jar LogMyIP.jar -b\n");
156: }
157: }