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