SmbComReadAndX.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 = Config.GetInt("jcifs.smb.client.ReadAndX.Close"
  22. , 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, long offset, int maxCount, ServerMessageBlock andx
  35. ) : base(andx)
  36. {
  37. this._fid = fid;
  38. this._offset = offset;
  39. this.MaxCount = MinCount = maxCount;
  40. Command = SmbComReadAndx;
  41. _openTimeout = unchecked((int)(0xFFFFFFFF));
  42. }
  43. internal virtual void SetParam(int fid, long offset, int maxCount)
  44. {
  45. this._fid = fid;
  46. this._offset = offset;
  47. this.MaxCount = MinCount = maxCount;
  48. }
  49. internal override int GetBatchLimit(byte command)
  50. {
  51. return command == SmbComClose ? BatchLimit : 0;
  52. }
  53. internal override int WriteParameterWordsWireFormat(byte[] dst, int dstIndex)
  54. {
  55. int start = dstIndex;
  56. WriteInt2(_fid, dst, dstIndex);
  57. dstIndex += 2;
  58. WriteInt4(_offset, dst, dstIndex);
  59. dstIndex += 4;
  60. WriteInt2(MaxCount, dst, dstIndex);
  61. dstIndex += 2;
  62. WriteInt2(MinCount, dst, dstIndex);
  63. dstIndex += 2;
  64. WriteInt4(_openTimeout, dst, dstIndex);
  65. dstIndex += 4;
  66. WriteInt2(Remaining, dst, dstIndex);
  67. dstIndex += 2;
  68. WriteInt4(_offset >> 32, dst, dstIndex);
  69. dstIndex += 4;
  70. return dstIndex - start;
  71. }
  72. internal override int WriteBytesWireFormat(byte[] dst, int dstIndex)
  73. {
  74. return 0;
  75. }
  76. internal override int ReadParameterWordsWireFormat(byte[] buffer, int bufferIndex
  77. )
  78. {
  79. return 0;
  80. }
  81. internal override int ReadBytesWireFormat(byte[] buffer, int bufferIndex)
  82. {
  83. return 0;
  84. }
  85. public override string ToString()
  86. {
  87. return "SmbComReadAndX[" + base.ToString() + ",fid=" + _fid + ",offset="
  88. + _offset + ",maxCount=" + MaxCount + ",minCount=" + MinCount + ",openTimeout="
  89. + _openTimeout + ",remaining=" + Remaining + ",offset=" + _offset + "]";
  90. }
  91. }
  92. }