KickJava   Java API By Example, From Geeks To Geeks.

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


1 /* jcifs smb client library in Java
2  * Copyright (C) 2000 "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.InputStream JavaDoc;
23 import java.io.IOException JavaDoc;
24
25 class SmbComReadAndX extends AndXServerMessageBlock {
26
27     private static final int BATCH_LIMIT = Config.getInt( "jcifs.smb.client.ReadAndX.Close", 1 );
28
29     private long offset;
30     private int fid,
31         maxCount,
32         minCount,
33         openTimeout,
34         remaining;
35
36     SmbComReadAndX() {
37         super( null );
38         command = SMB_COM_READ_ANDX;
39         openTimeout = 0xFFFFFFFF;
40     }
41     SmbComReadAndX( int fid, long offset, int maxCount, ServerMessageBlock andx ) {
42         super( andx );
43         this.fid = fid;
44         this.offset = offset;
45         this.maxCount = minCount = maxCount;
46         command = SMB_COM_READ_ANDX;
47         openTimeout = 0xFFFFFFFF;
48     }
49
50     void setParam( int fid, long offset, int maxCount ) {
51         this.fid = fid;
52         this.offset = offset;
53         this.maxCount = minCount = maxCount;
54     }
55     int getBatchLimit( byte command ) {
56         return command == SMB_COM_CLOSE ? BATCH_LIMIT : 0;
57     }
58     int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) {
59         int start = dstIndex;
60
61         writeInt2( fid, dst, dstIndex );
62         dstIndex += 2;
63         writeInt4( offset, dst, dstIndex );
64         dstIndex += 4;
65         writeInt2( maxCount, dst, dstIndex );
66         dstIndex += 2;
67         writeInt2( minCount, dst, dstIndex );
68         dstIndex += 2;
69         writeInt4( openTimeout, dst, dstIndex );
70         dstIndex += 4;
71         writeInt2( remaining, dst, dstIndex );
72         dstIndex += 2;
73         writeInt4( offset >> 32, dst, dstIndex );
74         dstIndex += 4;
75
76         return dstIndex - start;
77     }
78     int writeBytesWireFormat( byte[] dst, int dstIndex ) {
79         return 0;
80     }
81     int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) {
82         return 0;
83     }
84     int readBytesWireFormat( byte[] buffer, int bufferIndex ) {
85         return 0;
86     }
87     int readBytesDirectWireFormat( InputStream JavaDoc in, int byteCount,
88                 byte[] buffer, int bufferIndex ) throws IOException JavaDoc {
89         return 0;
90     }
91     public String JavaDoc toString() {
92         return new String JavaDoc( "SmbComReadAndX[" +
93             super.toString() +
94             ",fid=" + fid +
95             ",offset=" + offset +
96             ",maxCount=" + maxCount +
97             ",minCount=" + minCount +
98             ",openTimeout=" + openTimeout +
99             ",remaining=" + remaining +
100             ",offset=" + maxCount +
101              "]" );
102     }
103 }
104
Popular Tags