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 com.knowgate.jcifs.Config;
022: import com.knowgate.misc.Gadgets;
023:
024: class Trans2FindFirst2 extends SmbComTransaction {
025:
026: // flags
027:
028: private static final int FLAGS_CLOSE_AFTER_THIS_REQUEST = 0x01;
029: private static final int FLAGS_CLOSE_IF_END_REACHED = 0x02;
030: private static final int FLAGS_RETURN_RESUME_KEYS = 0x04;
031: private static final int FLAGS_RESUME_FROM_PREVIOUS_END = 0x08;
032: private static final int FLAGS_FIND_WITH_BACKUP_INTENT = 0x10;
033:
034: private static final int DEFAULT_LIST_SIZE = 65535;
035: private static final int DEFAULT_LIST_COUNT = 200;
036:
037: private int searchAttributes;
038: private int flags;
039: private int informationLevel;
040: private int searchStorageType = 0;
041: private String wildcard;
042:
043: // information levels
044:
045: static final int SMB_INFO_STANDARD = 1;
046: static final int SMB_INFO_QUERY_EA_SIZE = 2;
047: static final int SMB_INFO_QUERY_EAS_FROM_LIST = 3;
048: static final int SMB_FIND_FILE_DIRECTORY_INFO = 0x101;
049: static final int SMB_FIND_FILE_FULL_DIRECTORY_INFO = 0x102;
050: static final int SMB_FILE_NAMES_INFO = 0x103;
051: static final int SMB_FILE_BOTH_DIRECTORY_INFO = 0x104;
052:
053: static final int LIST_SIZE = Config.getInt(
054: "jcifs.smb.client.listSize", DEFAULT_LIST_SIZE);
055: static final int LIST_COUNT = Config.getInt(
056: "jcifs.smb.client.listCount", DEFAULT_LIST_COUNT);
057:
058: Trans2FindFirst2(String filename, String wildcard,
059: int searchAttributes) {
060: if (filename.equals("\\")) {
061: this .path = filename;
062: } else {
063: this .path = filename + "\\";
064: }
065: this .wildcard = wildcard;
066: this .searchAttributes = searchAttributes
067: & SmbFile.ATTR_GET_MASK;
068: command = SMB_COM_TRANSACTION2;
069: subCommand = TRANS2_FIND_FIRST2;
070:
071: flags = 0x00;
072: informationLevel = SMB_FILE_BOTH_DIRECTORY_INFO;
073:
074: totalDataCount = 0;
075: maxParameterCount = 10;
076: maxDataCount = LIST_SIZE;
077: maxSetupCount = 0;
078: }
079:
080: int writeSetupWireFormat(byte[] dst, int dstIndex) {
081: dst[dstIndex++] = subCommand;
082: dst[dstIndex++] = (byte) 0x00;
083: return 2;
084: }
085:
086: int writeParametersWireFormat(byte[] dst, int dstIndex) {
087: int start = dstIndex;
088:
089: writeInt2(searchAttributes, dst, dstIndex);
090: dstIndex += 2;
091: writeInt2(LIST_COUNT, dst, dstIndex);
092: dstIndex += 2;
093: writeInt2(flags, dst, dstIndex);
094: dstIndex += 2;
095: writeInt2(informationLevel, dst, dstIndex);
096: dstIndex += 2;
097: writeInt4(searchStorageType, dst, dstIndex);
098: dstIndex += 4;
099: dstIndex += writeString(path + wildcard, dst, dstIndex);
100:
101: return dstIndex - start;
102: }
103:
104: int writeDataWireFormat(byte[] dst, int dstIndex) {
105: return 0;
106: }
107:
108: int readSetupWireFormat(byte[] buffer, int bufferIndex, int len) {
109: return 0;
110: }
111:
112: int readParametersWireFormat(byte[] buffer, int bufferIndex, int len) {
113: return 0;
114: }
115:
116: int readDataWireFormat(byte[] buffer, int bufferIndex, int len) {
117: return 0;
118: }
119:
120: public String toString() {
121: return new String("Trans2FindFirst2[" + super .toString()
122: + ",searchAttributes=0x"
123: + Gadgets.toHexString(searchAttributes, 2)
124: + ",searchCount=" + LIST_COUNT + ",flags=0x"
125: + Gadgets.toHexString(flags, 2)
126: + ",informationLevel=0x"
127: + Gadgets.toHexString(informationLevel, 3)
128: + ",searchStorageType=" + searchStorageType
129: + ",filename=" + path + "]");
130: }
131: }
|