001: /* jcifs smb client library in Java
002: * Copyright (C) 2000 "Michael B. Allen" <jcifs at samba dot org>
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2.1 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: */
018:
019: package jcifs.smb;
020:
021: import java.io.InputStream;
022: import java.io.IOException;
023: import jcifs.util.Hexdump;
024:
025: class NetShareEnumResponse extends SmbComTransactionResponse {
026:
027: class ShareInfo1 implements FileEntry {
028: String netName;
029: int type;
030: String remark;
031:
032: public String getName() {
033: return netName;
034: }
035:
036: public int getType() {
037: switch (type) {
038: case 1:
039: return SmbFile.TYPE_PRINTER;
040: case 3:
041: return SmbFile.TYPE_NAMED_PIPE;
042: }
043: return SmbFile.TYPE_SHARE;
044: }
045:
046: public int getAttributes() {
047: return SmbFile.ATTR_READONLY | SmbFile.ATTR_DIRECTORY;
048: }
049:
050: public long createTime() {
051: return 0L;
052: }
053:
054: public long lastModified() {
055: return 0L;
056: }
057:
058: public long length() {
059: return 0L;
060: }
061:
062: public String toString() {
063: return new String("ShareInfo1[" + "netName=" + netName
064: + ",type=0x" + Hexdump.toHexString(type, 4)
065: + ",remark=" + remark + "]");
066: }
067: }
068:
069: private int converter, totalAvailableEntries;
070:
071: NetShareEnumResponse() {
072: }
073:
074: int writeSetupWireFormat(byte[] dst, int dstIndex) {
075: return 0;
076: }
077:
078: int writeParametersWireFormat(byte[] dst, int dstIndex) {
079: return 0;
080: }
081:
082: int writeDataWireFormat(byte[] dst, int dstIndex) {
083: return 0;
084: }
085:
086: int readSetupWireFormat(byte[] buffer, int bufferIndex, int len) {
087: return 0;
088: }
089:
090: int readParametersWireFormat(byte[] buffer, int bufferIndex, int len) {
091: int start = bufferIndex;
092:
093: status = readInt2(buffer, bufferIndex);
094: bufferIndex += 2;
095: converter = readInt2(buffer, bufferIndex);
096: bufferIndex += 2;
097: numEntries = readInt2(buffer, bufferIndex);
098: bufferIndex += 2;
099: totalAvailableEntries = readInt2(buffer, bufferIndex);
100: bufferIndex += 2;
101:
102: return bufferIndex - start;
103: }
104:
105: int readDataWireFormat(byte[] buffer, int bufferIndex, int len) {
106: int start = bufferIndex;
107: ShareInfo1 e;
108:
109: useUnicode = false;
110:
111: results = new ShareInfo1[numEntries];
112: for (int i = 0; i < numEntries; i++) {
113: results[i] = e = new ShareInfo1();
114: e.netName = readString(buffer, bufferIndex, 13, false);
115: bufferIndex += 14;
116: e.type = readInt2(buffer, bufferIndex);
117: bufferIndex += 2;
118: int off = readInt4(buffer, bufferIndex);
119: bufferIndex += 4;
120: off = (off & 0xFFFF) - converter;
121: off = start + off;
122: e.remark = readString(buffer, off, 128, false);
123:
124: if (log.level > 2)
125: log.println(e);
126: }
127:
128: return bufferIndex - start;
129: }
130:
131: public String toString() {
132: return new String("NetShareEnumResponse[" + super .toString()
133: + ",status=" + status + ",converter=" + converter
134: + ",entriesReturned=" + numEntries
135: + ",totalAvailableEntries=" + totalAvailableEntries
136: + "]");
137: }
138: }
|