KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > 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 jcifs.smb;
21
22 import java.io.InputStream JavaDoc;
23 import java.io.IOException JavaDoc;
24 import jcifs.util.Hexdump;
25
26 class NetServerEnum2Response extends SmbComTransactionResponse {
27
28     class ServerInfo1 implements FileEntry {
29         String JavaDoc name;
30         int versionMajor;
31         int versionMinor;
32         int type;
33         String JavaDoc commentOrMasterBrowser;
34
35         public String JavaDoc getName() {
36             return name;
37         }
38         public int getType() {
39             return (type & 0x80000000) != 0 ? SmbFile.TYPE_WORKGROUP : SmbFile.TYPE_SERVER;
40         }
41         public int getAttributes() {
42             return SmbFile.ATTR_READONLY | SmbFile.ATTR_DIRECTORY;
43         }
44         public long createTime() {
45             return 0L;
46         }
47         public long lastModified() {
48             return 0L;
49         }
50         public long length() {
51             return 0L;
52         }
53
54         public String JavaDoc toString() {
55             return new String JavaDoc( "ServerInfo1[" +
56                     "name=" + name +
57                     ",versionMajor=" + versionMajor +
58                     ",versionMinor=" + versionMinor +
59                     ",type=0x" + Hexdump.toHexString( type, 8 ) +
60                     ",commentOrMasterBrowser=" + commentOrMasterBrowser + "]" );
61         }
62     }
63
64     private int converter, totalAvailableEntries;
65
66     String JavaDoc lastName;
67
68     NetServerEnum2Response() {
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         ServerInfo1 e = null;
100
101         results = new ServerInfo1[numEntries];
102         for( int i = 0; i < numEntries; i++ ) {
103             results[i] = e = new ServerInfo1();
104             e.name = readString( buffer, bufferIndex, 16, false );
105             bufferIndex += 16;
106             e.versionMajor = (int)( buffer[bufferIndex++] & 0xFF );
107             e.versionMinor = (int)( buffer[bufferIndex++] & 0xFF );
108             e.type = readInt4( buffer, bufferIndex );
109             bufferIndex += 4;
110             int off = readInt4( buffer, bufferIndex );
111             bufferIndex += 4;
112             off = ( off & 0xFFFF ) - converter;
113             off = start + off;
114             e.commentOrMasterBrowser = readString( buffer, off, 48, false );
115
116             if( log.level > 3 )
117                 log.println( e );
118         }
119         lastName = numEntries == 0 ? null : e.name;
120
121         return bufferIndex - start;
122     }
123     public String JavaDoc toString() {
124         return new String JavaDoc( "NetServerEnum2Response[" +
125                 super.toString() +
126                 ",status=" + status +
127                 ",converter=" + converter +
128                 ",entriesReturned=" + numEntries +
129                 ",totalAvailableEntries=" + totalAvailableEntries +
130                 ",lastName=" + lastName + "]" );
131     }
132 }
133
Popular Tags