當前位置: 首頁>>代碼示例>>C#>>正文


C# Interp.hideUnsafeCommands方法代碼示例

本文整理匯總了C#中tcl.lang.Interp.hideUnsafeCommands方法的典型用法代碼示例。如果您正苦於以下問題:C# Interp.hideUnsafeCommands方法的具體用法?C# Interp.hideUnsafeCommands怎麽用?C# Interp.hideUnsafeCommands使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tcl.lang.Interp的用法示例。


在下文中一共展示了Interp.hideUnsafeCommands方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: makeSafe

    private static void makeSafe( Interp interp )
    {
      Channel chan; // Channel to remove from safe interpreter.

      interp.hideUnsafeCommands();

      interp.isSafe = true;

      //  Unsetting variables : (which should not have been set 
      //  in the first place, but...)

      // No env array in a safe slave.

      try
      {
        interp.unsetVar( "env", TCL.VarFlag.GLOBAL_ONLY );
      }
      catch ( TclException e )
      {
      }

      // Remove unsafe parts of tcl_platform

      try
      {
        interp.unsetVar( "tcl_platform", "os", TCL.VarFlag.GLOBAL_ONLY );
      }
      catch ( TclException e )
      {
      }
      try
      {
        interp.unsetVar( "tcl_platform", "osVersion", TCL.VarFlag.GLOBAL_ONLY );
      }
      catch ( TclException e )
      {
      }
      try
      {
        interp.unsetVar( "tcl_platform", "machine", TCL.VarFlag.GLOBAL_ONLY );
      }
      catch ( TclException e )
      {
      }
      try
      {
        interp.unsetVar( "tcl_platform", "user", TCL.VarFlag.GLOBAL_ONLY );
      }
      catch ( TclException e )
      {
      }

      // Unset path informations variables
      // (the only one remaining is [info nameofexecutable])

      try
      {
        interp.unsetVar( "tclDefaultLibrary", TCL.VarFlag.GLOBAL_ONLY );
      }
      catch ( TclException e )
      {
      }
      try
      {
        interp.unsetVar( "tcl_library", TCL.VarFlag.GLOBAL_ONLY );
      }
      catch ( TclException e )
      {
      }
      try
      {
        interp.unsetVar( "tcl_pkgPath", TCL.VarFlag.GLOBAL_ONLY );
      }
      catch ( TclException e )
      {
      }

      // Remove the standard channels from the interpreter; safe interpreters
      // do not ordinarily have access to stdin, stdout and stderr.
      //
      // NOTE: These channels are not added to the interpreter by the
      // Tcl_CreateInterp call, but may be added later, by another I/O
      // operation. We want to ensure that the interpreter does not have
      // these channels even if it is being made safe after being used for
      // some time..

      chan = TclIO.getStdChannel( StdChannel.STDIN );
      if ( chan != null )
      {
        TclIO.unregisterChannel( interp, chan );
      }
      chan = TclIO.getStdChannel( StdChannel.STDOUT );
      if ( chan != null )
      {
        TclIO.unregisterChannel( interp, chan );
      }
      chan = TclIO.getStdChannel( StdChannel.STDERR );
      if ( chan != null )
      {
        TclIO.unregisterChannel( interp, chan );
//.........這裏部分代碼省略.........
開發者ID:Jaden-J,項目名稱:csharp-sqlite,代碼行數:101,代碼來源:InterpSlaveCmd.cs


注:本文中的tcl.lang.Interp.hideUnsafeCommands方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。