示例#1
0
        static void Main(string[] args)
        {
            OBPConnect Dispatch = new OBPConnect ();

            try {
                if (args.Length == 0) {
                    throw new ParserException ("No command specified");
                    }

                if (IsFlag(args[0][0])) {

                    switch (args[0].Substring(1).ToLower()) {
                        case "server" : {
                            Handle_Server (Dispatch, args, 1);
                            break;
                            }
                        default: {
                            throw new ParserException("Unknown Command: " + args[0]);
                            }
                        }
                    }
                else {
                    Handle_Server (Dispatch, args, 0);
                    }
                }

            catch (System.Exception Exception) {
                if (Exception.GetType() == typeof (ParserException)) {
                    Usage ();
                    }
                else {
                   Console.WriteLine("Application: {0}", Exception.Message);
                    }
                }
        }
示例#2
0
        private static void Handle_Rollover(
					OBPConnect Dispatch, string[] args, int index)
        {
            Rollover		Options = new Rollover ();

            Registry Registry = new Registry ();

            #pragma warning disable 162
            for (int i = index; i< args.Length; i++) {
                if 	(!IsFlag (args [i][0] )) {
                    throw new Exception ("Unexpected parameter: " + args[i]);}
                string Rest = args [i].Substring (1);

                TagType_Rollover TagType = (TagType_Rollover) Registry.Find (Rest);

                // here have the cases for what to do with it.

                switch (TagType) {
                    default : throw new Exception ("Internal error");
                    }
                }

            #pragma warning restore 162
            Dispatch.Rollover (Options);
        }
示例#3
0
        private static void Handle_Server(
					OBPConnect Dispatch, string[] args, int index)
        {
            Server		Options = new Server ();

            Registry Registry = new Registry ();

            Options.Configuration.Register ("config", Registry, (int) TagType_Server.Configuration);
            Options.Log.Register ("log", Registry, (int) TagType_Server.Log);
            Options.Detach.Register ("detach", Registry, (int) TagType_Server.Detach);
            Options.WebService.Register ("ws", Registry, (int) TagType_Server.WebService);
            Options.UDP.Register ("udp", Registry, (int) TagType_Server.UDP);
            Options.DNS.Register ("dns", Registry, (int) TagType_Server.DNS);

            // looking for parameter Param.Name}
            if (index < args.Length && !IsFlag (args [index][0] )) {
                // Have got the parameter, call the parameter value method
                Options.Configuration.Parameter (args [index]);
                index++;
                }

            #pragma warning disable 162
            for (int i = index; i< args.Length; i++) {
                if 	(!IsFlag (args [i][0] )) {
                    throw new Exception ("Unexpected parameter: " + args[i]);}
                string Rest = args [i].Substring (1);

                TagType_Server TagType = (TagType_Server) Registry.Find (Rest);

                // here have the cases for what to do with it.

                switch (TagType) {
                    case TagType_Server.Log : {
                        int OptionParams = Options.Log.Tag (Rest);

                        if (OptionParams>0 && ((i+1) < args.Length)) {
                            if 	(!IsFlag (args [i+1][0] )) {
                                i++;
                                Options.Log.Parameter (args[i]);
                                }
                            }
                        break;
                        }
                    case TagType_Server.Detach : {
                        int OptionParams = Options.Detach.Tag (Rest);

                        if (OptionParams>0 && ((i+1) < args.Length)) {
                            if 	(!IsFlag (args [i+1][0] )) {
                                i++;
                                Options.Detach.Parameter (args[i]);
                                }
                            }
                        break;
                        }
                    case TagType_Server.WebService : {
                        int OptionParams = Options.WebService.Tag (Rest);

                        if (OptionParams>0 && ((i+1) < args.Length)) {
                            if 	(!IsFlag (args [i+1][0] )) {
                                i++;
                                Options.WebService.Parameter (args[i]);
                                }
                            }
                        break;
                        }
                    case TagType_Server.UDP : {
                        int OptionParams = Options.UDP.Tag (Rest);

                        if (OptionParams>0 && ((i+1) < args.Length)) {
                            if 	(!IsFlag (args [i+1][0] )) {
                                i++;
                                Options.UDP.Parameter (args[i]);
                                }
                            }
                        break;
                        }
                    case TagType_Server.DNS : {
                        int OptionParams = Options.DNS.Tag (Rest);

                        if (OptionParams>0 && ((i+1) < args.Length)) {
                            if 	(!IsFlag (args [i+1][0] )) {
                                i++;
                                Options.DNS.Parameter (args[i]);
                                }
                            }
                        break;
                        }
                    default : throw new Exception ("Internal error");
                    }
                }

            #pragma warning restore 162
            Dispatch.Server (Options);
        }
示例#4
0
        private static void Handle_PIN(
					OBPConnect Dispatch, string[] args, int index)
        {
            PIN		Options = new PIN ();

            Registry Registry = new Registry ();

            Options.Configuration.Register ("config", Registry, (int) TagType_PIN.Configuration);
            Options.Account.Register ("account", Registry, (int) TagType_PIN.Account);
            Options.Handle.Register ("id", Registry, (int) TagType_PIN.Handle);

            // looking for parameter Param.Name}
            if (index < args.Length && !IsFlag (args [index][0] )) {
                // Have got the parameter, call the parameter value method
                Options.Configuration.Parameter (args [index]);
                index++;
                }
            // looking for parameter Param.Name}
            if (index < args.Length && !IsFlag (args [index][0] )) {
                // Have got the parameter, call the parameter value method
                Options.Account.Parameter (args [index]);
                index++;
                }

            #pragma warning disable 162
            for (int i = index; i< args.Length; i++) {
                if 	(!IsFlag (args [i][0] )) {
                    throw new Exception ("Unexpected parameter: " + args[i]);}
                string Rest = args [i].Substring (1);

                TagType_PIN TagType = (TagType_PIN) Registry.Find (Rest);

                // here have the cases for what to do with it.

                switch (TagType) {
                    case TagType_PIN.Handle : {
                        int OptionParams = Options.Handle.Tag (Rest);

                        if (OptionParams>0 && ((i+1) < args.Length)) {
                            if 	(!IsFlag (args [i+1][0] )) {
                                i++;
                                Options.Handle.Parameter (args[i]);
                                }
                            }
                        break;
                        }
                    default : throw new Exception ("Internal error");
                    }
                }

            #pragma warning restore 162
            Dispatch.PIN (Options);
        }