PseudoTerminalInfo.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. namespace Renci.SshNet.Messages.Connection
  2. {
  3. /// <summary>
  4. /// Represents "pty-req" type channel request information
  5. /// </summary>
  6. internal class PseudoTerminalRequestInfo : RequestInfo
  7. {
  8. /// <summary>
  9. /// Channel request name
  10. /// </summary>
  11. public const string NAME = "pty-req";
  12. /// <summary>
  13. /// Gets the name of the request.
  14. /// </summary>
  15. /// <value>
  16. /// The name of the request.
  17. /// </value>
  18. public override string RequestName
  19. {
  20. get { return PseudoTerminalRequestInfo.NAME; }
  21. }
  22. /// <summary>
  23. /// Gets or sets the environment variable.
  24. /// </summary>
  25. /// <value>
  26. /// The environment variable.
  27. /// </value>
  28. public string EnvironmentVariable { get; set; }
  29. /// <summary>
  30. /// Gets or sets the columns.
  31. /// </summary>
  32. /// <value>
  33. /// The columns.
  34. /// </value>
  35. public uint Columns { get; set; }
  36. /// <summary>
  37. /// Gets or sets the rows.
  38. /// </summary>
  39. /// <value>
  40. /// The rows.
  41. /// </value>
  42. public uint Rows { get; set; }
  43. /// <summary>
  44. /// Gets or sets the width of the pixel.
  45. /// </summary>
  46. /// <value>
  47. /// The width of the pixel.
  48. /// </value>
  49. public uint PixelWidth { get; set; }
  50. /// <summary>
  51. /// Gets or sets the height of the pixel.
  52. /// </summary>
  53. /// <value>
  54. /// The height of the pixel.
  55. /// </value>
  56. public uint PixelHeight { get; set; }
  57. /// <summary>
  58. /// Gets or sets the terminal mode.
  59. /// </summary>
  60. /// <value>
  61. /// The terminal mode.
  62. /// </value>
  63. public string TerminalMode { get; set; }
  64. /// <summary>
  65. /// Initializes a new instance of the <see cref="PseudoTerminalRequestInfo"/> class.
  66. /// </summary>
  67. public PseudoTerminalRequestInfo()
  68. {
  69. this.WantReply = true;
  70. }
  71. /// <summary>
  72. /// Initializes a new instance of the <see cref="PseudoTerminalRequestInfo"/> class.
  73. /// </summary>
  74. /// <param name="environmentVariable">The environment variable.</param>
  75. /// <param name="columns">The columns.</param>
  76. /// <param name="rows">The rows.</param>
  77. /// <param name="width">The width.</param>
  78. /// <param name="height">The height.</param>
  79. /// <param name="terminalMode">The terminal mode.</param>
  80. public PseudoTerminalRequestInfo(string environmentVariable, uint columns, uint rows, uint width, uint height, string terminalMode)
  81. : this()
  82. {
  83. this.EnvironmentVariable = environmentVariable;
  84. this.Columns = columns;
  85. this.Rows = rows;
  86. this.PixelWidth = width;
  87. this.PixelHeight = height;
  88. this.TerminalMode = terminalMode;
  89. }
  90. /// <summary>
  91. /// Called when type specific data need to be loaded.
  92. /// </summary>
  93. protected override void LoadData()
  94. {
  95. base.LoadData();
  96. this.EnvironmentVariable = this.ReadString();
  97. this.Columns = this.ReadUInt32();
  98. this.Rows = this.ReadUInt32();
  99. this.PixelWidth = this.ReadUInt32();
  100. this.PixelHeight = this.ReadUInt32();
  101. this.TerminalMode = this.ReadAsciiString();
  102. }
  103. /// <summary>
  104. /// Called when type specific data need to be saved.
  105. /// </summary>
  106. protected override void SaveData()
  107. {
  108. base.SaveData();
  109. this.Write(this.EnvironmentVariable);
  110. this.Write(this.Columns);
  111. this.Write(this.Rows);
  112. this.Write(this.Rows);
  113. this.Write(this.PixelHeight);
  114. this.WriteAscii(this.TerminalMode);
  115. }
  116. }
  117. }