KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.io.InputStream JavaDoc;
22 import java.io.IOException JavaDoc;
23 import com.knowgate.misc.Gadgets;
24 import com.knowgate.debug.*;
25
26 class NetShareEnumResponse extends SmbComTransactionResponse {
27
28     class ShareInfo1 implements FileEntry {
29         String JavaDoc netName;
30         int type;
31         String JavaDoc remark;
32
33         public String JavaDoc getName() {
34             return netName;
35         }
36         public int getType() {
37             switch( type ) {
38                 case 1:
39                     return SmbFile.TYPE_PRINTER;
40                 case 3:
41                     return SmbFile.TYPE_NAMED_PIPE;
42             }
43             return SmbFile.TYPE_SHARE;
44         }
45         public int getAttributes() {
46             return SmbFile.ATTR_READONLY | SmbFile.ATTR_DIRECTORY;
47         }
48         public long createTime() {
49             return 0L;
50         }
51         public long lastModified() {
52             return 0L;
53         }
54         public long length() {
55             return 0L;
56         }
57
58         public String JavaDoc toString() {
59             return new String JavaDoc( "ShareInfo1[" +
60                     "netName=" + netName +
61                     ",type=0x" + Gadgets.toHexString( type, 4 ) +
62                     ",remark=" + remark + "]" );
63         }
64     }
65
66     private int converter, totalAvailableEntries;
67
68     NetShareEnumResponse() {
69     }
70
71     int writeSetupWireFormat( byte[] dst, int dstIndex ) {
72         return 0;
73     }
74     int writeParametersWireFormat( byte[] dst, int dstIndex ) {
75         return 0;
76     }
77     int writeDataWireFormat( byte[] dst, int dstIndex ) {
78         return 0;
79     }
80     int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) {
81         return 0;
82     }
83     int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) {
84         int start = bufferIndex;
85
86         status = readInt2( buffer, bufferIndex );
87         bufferIndex += 2;
88         converter = readInt2( buffer, bufferIndex );
89         bufferIndex += 2;
90         numEntries = readInt2( buffer, bufferIndex );
91         bufferIndex += 2;
92         totalAvailableEntries = readInt2( buffer, bufferIndex );
93         bufferIndex += 2;
94
95         return bufferIndex - start;
96     }
97     int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) {
98         int start = bufferIndex;
99         ShareInfo1 e;
100
101         useUnicode = false;
102
103         results = new ShareInfo1[numEntries];
104         for( int i = 0; i < numEntries; i++ ) {
105             results[i] = e = new ShareInfo1();
106             e.netName = readString( buffer, bufferIndex, 13, false );
107             bufferIndex += 14;
108             e.type = readInt2( buffer, bufferIndex );
109             bufferIndex += 2;
110             int off = readInt4( buffer, bufferIndex );
111             bufferIndex += 4;
112             off = ( off & 0xFFFF ) - converter;
113             off = start + off;
114             e.remark = readString( buffer, off, 128, false );
115
116         }
117
118         return bufferIndex - start;
119     }
120     public String JavaDoc toString() {
121         return new String JavaDoc( "NetShareEnumResponse[" +
122                 super.toString() +
123                 ",status=" + status +
124                 ",converter=" + converter +
125                 ",entriesReturned=" + numEntries +
126                 ",totalAvailableEntries=" + totalAvailableEntries + "]" );
127     }
128 }
129
Popular Tags