/* Copyright 2012 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, United States of America, and/or their licensors. In the event that you should download or otherwise use this software you hereby acknowledge and agree to the terms at http://www.my-channels.com/company/terms.html#legalnotices */ using System; namespace com.pcbsys.nirvana.apps { public class nP2PShell { private static nP2PShell mySelf; private static bool isServer; public static void Main(String[] args) { if(args.Length<1) { Usage(); Environment.Exit(2); } // Get the realm details String[] rproperties = new String[4]; int idx = 0; String RNAME = args[0]; if (RNAME == null) { Usage(); Environment.Exit(1); } String shell = null; if (args.Length > 1) { shell = args[1]; Console.WriteLine("***********************************************************"); Console.WriteLine("* *"); Console.WriteLine("* WARNING WARNING WARNING WARNING WARNING WARNING WARNING *"); Console.WriteLine("* This is a sample application demonstrating how to write *"); Console.WriteLine("* a simple nirvana P2P service. This sample is extremely *"); Console.WriteLine("* insecure and should NEVER be run on any production or *"); Console.WriteLine("* secure hosts. The author accepts no liability for any *"); Console.WriteLine("* damage caused *"); Console.WriteLine("* *"); Console.WriteLine("***********************************************************"); } String[] st = RNAME.Split(','); for (int x = 0; x < st.Length; x++) { String someRNAME = st[x]; rproperties[idx] = someRNAME; idx++; } // Trim the array String[] rpropertiesTrimmed = new String[idx]; Array.Copy(rproperties, 0, rpropertiesTrimmed, 0, idx); if (rpropertiesTrimmed.Length == 0) { Console.WriteLine("No realm information supplied"); Environment.Exit(1); } mySelf = new nP2PShell(rpropertiesTrimmed, shell); } public nP2PShell(String[] rprops, String shell) { try { if (rprops == null) return; if (shell != null) isServer = true; if (isServer) { new ShellServer(rprops, shell); } else { new Shell(rprops); } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } /** * Prints the usage string for this class */ private static void Usage() { Console.WriteLine("Usage ...\n"); Console.WriteLine("nP2PShell [shell] \n"); Console.WriteLine( " \n"); Console.WriteLine( " - the rname of the server to connect to"); Console.WriteLine( " \n"); Console.WriteLine( "[shell] - The type of shell you want to offer. For example cmd for win32 or bash for unix, leave out for client"); } } }