KickJava   Java API By Example, From Geeks To Geeks.

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