KickJava   Java API By Example, From Geeks To Geeks.

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


1 /* jcifs smb client library in Java
2  * Copyright (C) 2000 "Michael B. Allen" <jcifs at samba dot org>
3  * Gary Rambo <grambo aventail.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

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