001: /* jcifs smb client library in Java
002: * Copyright (C) 2003 "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 jcifs.smb;
020:
021: import jcifs.Config;
022: import java.io.IOException;
023: import java.io.InputStream;
024:
025: class SmbComWrite extends ServerMessageBlock {
026:
027: private int fid, count, offset, remaining, off;
028: private byte[] b;
029:
030: SmbComWrite() {
031: super ();
032: command = SMB_COM_WRITE;
033: }
034:
035: SmbComWrite(int fid, int offset, int remaining, byte[] b, int off,
036: int len) {
037: this .fid = fid;
038: this .count = len;
039: this .offset = offset;
040: this .remaining = remaining;
041: this .b = b;
042: this .off = off;
043: command = SMB_COM_WRITE;
044: }
045:
046: void setParam(int fid, long offset, int remaining, byte[] b,
047: int off, int len) {
048: this .fid = fid;
049: this .offset = (int) (offset & 0xFFFFFFFFL);
050: this .remaining = remaining;
051: this .b = b;
052: this .off = off;
053: count = len;
054: }
055:
056: int writeParameterWordsWireFormat(byte[] dst, int dstIndex) {
057: int start = dstIndex;
058:
059: writeInt2(fid, dst, dstIndex);
060: dstIndex += 2;
061: writeInt2(count, dst, dstIndex);
062: dstIndex += 2;
063: writeInt4(offset, dst, dstIndex);
064: dstIndex += 4;
065: writeInt2(remaining, dst, dstIndex);
066: dstIndex += 2;
067:
068: return dstIndex - start;
069: }
070:
071: int writeBytesWireFormat(byte[] dst, int dstIndex) {
072: int start = dstIndex;
073:
074: dst[dstIndex++] = (byte) 0x01; /* BufferFormat */
075: writeInt2(count, dst, dstIndex); /* DataLength? */
076: dstIndex += 2;
077: System.arraycopy(b, off, dst, dstIndex, count);
078: dstIndex += count;
079:
080: return dstIndex - start;
081: }
082:
083: int readParameterWordsWireFormat(byte[] buffer, int bufferIndex) {
084: return 0;
085: }
086:
087: int readBytesWireFormat(byte[] buffer, int bufferIndex) {
088: return 0;
089: }
090:
091: int readBytesDirectWireFormat(InputStream in, int byteCount)
092: throws IOException {
093: return 0;
094: }
095:
096: public String toString() {
097: return new String("SmbComWrite[" + super .toString() + ",fid="
098: + fid + ",count=" + count + ",offset=" + offset
099: + ",remaining=" + remaining + "]");
100: }
101: }
|