Cygwin接続時のパラメータを示すヘルパクラスです。 Helper class that shows parameter when Cygwin connecting.
Exemplo n.º 1
0
        protected static void PrepareEnv(ProcessStartInfo psi, ICygwinParameter p)
        {
            string cygdir = CygwinUtil.GuessRootDirectory(p.CygwinDir);
            string cygbin = System.IO.Path.Combine(cygdir, "bin");

            string path = psi.EnvironmentVariables["PATH"];

            psi.EnvironmentVariables.Remove("PATH");
            psi.EnvironmentVariables.Add("PATH", PathListAppend(cygbin, path));
        }
Exemplo n.º 2
0
        protected static void PrepareEnv(ProcessStartInfo psi, ICygwinParameter p)
        {
            string path      = psi.EnvironmentVariables["PATH"];
            string cygwinDir = p.CygwinDir;

            if (cygwinDir == null || cygwinDir.Length == 0)
            {
                cygwinDir = CygwinUtil.GuessRootDirectory();
            }
            if (path == null)
            {
                path = String.Empty;
            }
            else if (!path.EndsWith(";"))
            {
                path += ";";
            }
            path += cygwinDir + "\\bin";
            psi.EnvironmentVariables.Remove("PATH");
            psi.EnvironmentVariables.Add("PATH", path);
        }
Exemplo n.º 3
0
            public ITerminalConnection Connect()
            {
                lock (_lockObject) {
                    if (_localPort == 0)
                    {
                        PrepareListener();
                    }
                }

                //string cygtermPath = "cygterm\\"+(IsCygwin(_param)? "cygterm.exe" : "sfuterm.exe");
                //string connectionName = IsCygwin(_param)? "Cygwin" : "SFU";
                string cygtermPath = String.Format("{0}cygterm\\cygterm.exe", ProtocolUtil.ProtocolsPluginHomeDir);
                //string connectionName = "Cygwin";

                ITerminalParameter term = (ITerminalParameter)_param.GetAdapter(typeof(ITerminalParameter));

                //mwg: Construct args for cygterm.exe
                System.Text.StringBuilder args = new System.Text.StringBuilder();
                args.AppendFormat(" -p {0}", _localPort);
                args.AppendFormat(" -v HOME=\"{0}\"", _param.Home);
                args.AppendFormat(" -v TERM=\"{0}\"", term.TerminalType);
                args.AppendFormat(" -s \"{0}\"", _param.ShellName);
                args.AppendFormat(" -v ROSATERM=\"{0}\"", "rosaterm");

                ProcessStartInfo psi = new ProcessStartInfo(cygtermPath, args.ToString());

                PrepareEnv(psi, _param);
                psi.CreateNoWindow  = true;
                psi.ErrorDialog     = true;
                psi.UseShellExecute = false;
                psi.WindowStyle     = ProcessWindowStyle.Hidden;

                //mwg: Set working directory/mwg
                string wdir = _param.Home;

                if (wdir.StartsWith("/"))
                {
                    wdir = wdir.Substring(1);
                }
                wdir = System.IO.Path.Combine(CygwinUtil.GuessRootDirectory(_param.CygwinDir), wdir);
                psi.WorkingDirectory = wdir;

                try {
                    _process = Process.Start(psi);
                }catch (System.ComponentModel.Win32Exception ex) {
                    throw new LocalShellUtilException(PEnv.Strings.GetString("Message.CygwinUtil.FailedToRunCygterm") + ": " + cygtermPath, ex);
                }
                while (true)
                {
                    List <Socket> chk = new List <Socket>();
                    chk.Add(_listener);
                    Socket.Select(chk, null, null, 100);
                    if (_interrupted)
                    {
                        return(null);
                    }
                    if (chk.Count > 0)
                    {
                        break;
                    }
                }
                Socket sock = _listener.Accept();

                if (_interrupted)
                {
                    return(null);
                }

                TelnetNegotiator neg        = new TelnetNegotiator(term.TerminalType, term.InitialWidth, term.InitialHeight);
                TelnetParameter  shellparam = new TelnetParameter();

                shellparam.Destination = "localhost";
                shellparam.SetTerminalName(term.TerminalType);
                shellparam.SetTerminalSize(term.InitialWidth, term.InitialHeight);
                TelnetTerminalConnection r = new TelnetTerminalConnection(shellparam, neg, new PlainPoderosaSocket(sock));

                r.Destination = (ITerminalParameter)_param.GetAdapter(typeof(ITerminalParameter));                 //TelnetでなくオリジナルのCygwinParamで上書き
                r.UsingSocks  = false;
                return(r);
            }