SmbComReadAndX.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. // This code is derived from jcifs smb client library <jcifs at samba dot org>
  2. // Ported by J. Arturo <webmaster at komodosoft dot net>
  3. //
  4. // This library is free software; you can redistribute it and/or
  5. // modify it under the terms of the GNU Lesser General Public
  6. // License as published by the Free Software Foundation; either
  7. // version 2.1 of the License, or (at your option) any later version.
  8. //
  9. // This library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. // Lesser General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Lesser General Public
  15. // License along with this library; if not, write to the Free Software
  16. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. namespace SharpCifs.Smb
  18. {
  19. internal class SmbComReadAndX : AndXServerMessageBlock
  20. {
  21. private static readonly int BatchLimit
  22. = Config.GetInt("jcifs.smb.client.ReadAndX.Close", 1);
  23. private long _offset;
  24. private int _fid;
  25. private int _openTimeout;
  26. internal int MaxCount;
  27. internal int MinCount;
  28. internal int Remaining;
  29. public SmbComReadAndX() : base(null)
  30. {
  31. Command = SmbComReadAndx;
  32. _openTimeout = unchecked((int)(0xFFFFFFFF));
  33. }
  34. internal SmbComReadAndX(int fid,
  35. long offset,
  36. int maxCount,
  37. ServerMessageBlock andx) : base(andx)
  38. {
  39. this._fid = fid;
  40. this._offset = offset;
  41. this.MaxCount = MinCount = maxCount;
  42. Command = SmbComReadAndx;
  43. _openTimeout = unchecked((int)(0xFFFFFFFF));
  44. }
  45. internal virtual void SetParam(int fid, long offset, int maxCount)
  46. {
  47. this._fid = fid;
  48. this._offset = offset;
  49. this.MaxCount = MinCount = maxCount;
  50. }
  51. internal override int GetBatchLimit(byte command)
  52. {
  53. return command == SmbComClose ? BatchLimit : 0;
  54. }
  55. internal override int WriteParameterWordsWireFormat(byte[] dst, int dstIndex)
  56. {
  57. int start = dstIndex;
  58. WriteInt2(_fid, dst, dstIndex);
  59. dstIndex += 2;
  60. WriteInt4(_offset, dst, dstIndex);
  61. dstIndex += 4;
  62. WriteInt2(MaxCount, dst, dstIndex);
  63. dstIndex += 2;
  64. WriteInt2(MinCount, dst, dstIndex);
  65. dstIndex += 2;
  66. WriteInt4(_openTimeout, dst, dstIndex);
  67. dstIndex += 4;
  68. WriteInt2(Remaining, dst, dstIndex);
  69. dstIndex += 2;
  70. WriteInt4(_offset >> 32, dst, dstIndex);
  71. dstIndex += 4;
  72. return dstIndex - start;
  73. }
  74. internal override int WriteBytesWireFormat(byte[] dst, int dstIndex)
  75. {
  76. return 0;
  77. }
  78. internal override int ReadParameterWordsWireFormat(byte[] buffer, int bufferIndex)
  79. {
  80. return 0;
  81. }
  82. internal override int ReadBytesWireFormat(byte[] buffer, int bufferIndex)
  83. {
  84. return 0;
  85. }
  86. public override string ToString()
  87. {
  88. return "SmbComReadAndX["
  89. + base.ToString()
  90. + ",fid=" + _fid
  91. + ",offset=" + _offset
  92. + ",maxCount=" + MaxCount
  93. + ",minCount=" + MinCount
  94. + ",openTimeout=" + _openTimeout
  95. + ",remaining=" + Remaining
  96. + ",offset=" + _offset + "]";
  97. }
  98. }
  99. }