KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > knowgate > jcifs > smb > SmbComWrite


1 /* jcifs smb client library in Java
2  * Copyright (C) 2003 "Michael B. Allen" <jcifs at samba dot org>
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  */

18
19 package com.knowgate.jcifs.smb;
20
21 import com.knowgate.jcifs.Config;
22 import java.io.IOException JavaDoc;
23 import java.io.InputStream JavaDoc;
24
25 class SmbComWrite extends ServerMessageBlock {
26
27     private int fid,
28         count,
29         offset,
30         remaining,
31         off;
32     private byte[] b;
33
34     SmbComWrite() {
35         super();
36         command = SMB_COM_WRITE;
37     }
38     SmbComWrite( int fid, int offset, int remaining, byte[] b, int off, int len ) {
39         this.fid = fid;
40         this.count = len;
41         this.offset = offset;
42         this.remaining = remaining;
43         this.b = b;
44         this.off = off;
45         command = SMB_COM_WRITE;
46     }
47
48     void setParam( int fid, long offset, int remaining,
49                     byte[] b, int off, int len ) {
50         this.fid = fid;
51         this.offset = (int)(offset & 0xFFFFFFFFL);
52         this.remaining = remaining;
53         this.b = b;
54         this.off = off;
55         count = len;
56     }
57     int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) {
58         int start = dstIndex;
59
60         writeInt2( fid, dst, dstIndex );
61         dstIndex += 2;
62         writeInt2( count, dst, dstIndex );
63         dstIndex += 2;
64         writeInt4( offset, dst, dstIndex );
65         dstIndex += 4;
66         writeInt2( remaining, dst, dstIndex );
67         dstIndex += 2;
68
69         return dstIndex - start;
70     }
71     int writeBytesWireFormat( byte[] dst, int dstIndex ) {
72         int start = dstIndex;
73
74         dst[dstIndex++] = (byte)0x01; /* BufferFormat */
75         writeInt2( count, dst, dstIndex ); /* DataLength? */
76         dstIndex += 2;
77         System.arraycopy( b, off, dst, dstIndex, count );
78         dstIndex += count;
79
80         return dstIndex - start;
81     }
82     int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) {
83         return 0;
84     }
85     int readBytesWireFormat( byte[] buffer, int bufferIndex ) {
86         return 0;
87     }
88     int readBytesDirectWireFormat( InputStream JavaDoc in, int byteCount ) throws IOException JavaDoc {
89         return 0;
90     }
91     public String JavaDoc toString() {
92         return new String JavaDoc( "SmbComWrite[" +
93             super.toString() +
94             ",fid=" + fid +
95             ",count=" + count +
96             ",offset=" + offset +
97             ",remaining=" + remaining + "]" );
98     }
99 }
100
Popular Tags