001: /* jcifs smb client library in Java
002: * Copyright (C) 2000 "Michael B. Allen" <jcifs at samba dot org>
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2.1 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: */
018:
019: package com.knowgate.jcifs.smb;
020:
021: import com.knowgate.jcifs.Config;
022: import java.io.InputStream;
023: import java.io.IOException;
024:
025: class SmbComReadAndX extends AndXServerMessageBlock {
026:
027: private static final int BATCH_LIMIT = Config.getInt(
028: "jcifs.smb.client.ReadAndX.Close", 1);
029:
030: private long offset;
031: private int fid, maxCount, minCount, openTimeout, remaining;
032:
033: SmbComReadAndX() {
034: super (null);
035: command = SMB_COM_READ_ANDX;
036: openTimeout = 0xFFFFFFFF;
037: }
038:
039: SmbComReadAndX(int fid, long offset, int maxCount,
040: ServerMessageBlock andx) {
041: super (andx);
042: this .fid = fid;
043: this .offset = offset;
044: this .maxCount = minCount = maxCount;
045: command = SMB_COM_READ_ANDX;
046: openTimeout = 0xFFFFFFFF;
047: }
048:
049: void setParam(int fid, long offset, int maxCount) {
050: this .fid = fid;
051: this .offset = offset;
052: this .maxCount = minCount = maxCount;
053: }
054:
055: int getBatchLimit(byte command) {
056: return command == SMB_COM_CLOSE ? BATCH_LIMIT : 0;
057: }
058:
059: int writeParameterWordsWireFormat(byte[] dst, int dstIndex) {
060: int start = dstIndex;
061:
062: writeInt2(fid, dst, dstIndex);
063: dstIndex += 2;
064: writeInt4(offset, dst, dstIndex);
065: dstIndex += 4;
066: writeInt2(maxCount, dst, dstIndex);
067: dstIndex += 2;
068: writeInt2(minCount, dst, dstIndex);
069: dstIndex += 2;
070: writeInt4(openTimeout, dst, dstIndex);
071: dstIndex += 4;
072: writeInt2(remaining, dst, dstIndex);
073: dstIndex += 2;
074: writeInt4(offset >> 32, dst, dstIndex);
075: dstIndex += 4;
076:
077: return dstIndex - start;
078: }
079:
080: int writeBytesWireFormat(byte[] dst, int dstIndex) {
081: return 0;
082: }
083:
084: int readParameterWordsWireFormat(byte[] buffer, int bufferIndex) {
085: return 0;
086: }
087:
088: int readBytesWireFormat(byte[] buffer, int bufferIndex) {
089: return 0;
090: }
091:
092: int readBytesDirectWireFormat(InputStream in, int byteCount,
093: byte[] buffer, int bufferIndex) throws IOException {
094: return 0;
095: }
096:
097: public String toString() {
098: return new String("SmbComReadAndX[" + super .toString()
099: + ",fid=" + fid + ",offset=" + offset + ",maxCount="
100: + maxCount + ",minCount=" + minCount + ",openTimeout="
101: + openTimeout + ",remaining=" + remaining + ",offset="
102: + maxCount + "]");
103: }
104: }
|