KickJava   Java API By Example, From Geeks To Geeks.

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