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 com.knowgate.jcifs.smb;
020:
021: import java.io.InputStream;
022: import java.io.IOException;
023: import com.knowgate.misc.Gadgets;
024: import com.knowgate.debug.*;
025:
026: class NetShareEnumResponse extends SmbComTransactionResponse {
027:
028: class ShareInfo1 implements FileEntry {
029: String netName;
030: int type;
031: String remark;
032:
033: public String getName() {
034: return netName;
035: }
036:
037: public int getType() {
038: switch (type) {
039: case 1:
040: return SmbFile.TYPE_PRINTER;
041: case 3:
042: return SmbFile.TYPE_NAMED_PIPE;
043: }
044: return SmbFile.TYPE_SHARE;
045: }
046:
047: public int getAttributes() {
048: return SmbFile.ATTR_READONLY | SmbFile.ATTR_DIRECTORY;
049: }
050:
051: public long createTime() {
052: return 0L;
053: }
054:
055: public long lastModified() {
056: return 0L;
057: }
058:
059: public long length() {
060: return 0L;
061: }
062:
063: public String toString() {
064: return new String("ShareInfo1[" + "netName=" + netName
065: + ",type=0x" + Gadgets.toHexString(type, 4)
066: + ",remark=" + remark + "]");
067: }
068: }
069:
070: private int converter, totalAvailableEntries;
071:
072: NetShareEnumResponse() {
073: }
074:
075: int writeSetupWireFormat(byte[] dst, int dstIndex) {
076: return 0;
077: }
078:
079: int writeParametersWireFormat(byte[] dst, int dstIndex) {
080: return 0;
081: }
082:
083: int writeDataWireFormat(byte[] dst, int dstIndex) {
084: return 0;
085: }
086:
087: int readSetupWireFormat(byte[] buffer, int bufferIndex, int len) {
088: return 0;
089: }
090:
091: int readParametersWireFormat(byte[] buffer, int bufferIndex, int len) {
092: int start = bufferIndex;
093:
094: status = readInt2(buffer, bufferIndex);
095: bufferIndex += 2;
096: converter = readInt2(buffer, bufferIndex);
097: bufferIndex += 2;
098: numEntries = readInt2(buffer, bufferIndex);
099: bufferIndex += 2;
100: totalAvailableEntries = readInt2(buffer, bufferIndex);
101: bufferIndex += 2;
102:
103: return bufferIndex - start;
104: }
105:
106: int readDataWireFormat(byte[] buffer, int bufferIndex, int len) {
107: int start = bufferIndex;
108: ShareInfo1 e;
109:
110: useUnicode = false;
111:
112: results = new ShareInfo1[numEntries];
113: for (int i = 0; i < numEntries; i++) {
114: results[i] = e = new ShareInfo1();
115: e.netName = readString(buffer, bufferIndex, 13, false);
116: bufferIndex += 14;
117: e.type = readInt2(buffer, bufferIndex);
118: bufferIndex += 2;
119: int off = readInt4(buffer, bufferIndex);
120: bufferIndex += 4;
121: off = (off & 0xFFFF) - converter;
122: off = start + off;
123: e.remark = readString(buffer, off, 128, false);
124:
125: }
126:
127: return bufferIndex - start;
128: }
129:
130: public String toString() {
131: return new String("NetShareEnumResponse[" + super .toString()
132: + ",status=" + status + ",converter=" + converter
133: + ",entriesReturned=" + numEntries
134: + ",totalAvailableEntries=" + totalAvailableEntries
135: + "]");
136: }
137: }
|