|
| 1 | +/* Copyright (c) 2015 Adam Marcionek, All Rights Reserved |
| 2 | + * |
| 3 | + * This library is free software; you can redistribute it and/or |
| 4 | + * modify it under the terms of the GNU Lesser General Public |
| 5 | + * License as published by the Free Software Foundation; either |
| 6 | + * version 2.1 of the License, or (at your option) any later version. |
| 7 | + * |
| 8 | + * This library is distributed in the hope that it will be useful, |
| 9 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 | + * Lesser General Public License for more details. |
| 12 | + */ |
| 13 | +package com.sun.jna.platform.win32; |
| 14 | + |
| 15 | +import java.util.Arrays; |
| 16 | +import java.util.List; |
| 17 | + |
| 18 | +import com.sun.jna.Pointer; |
| 19 | +import com.sun.jna.Structure; |
| 20 | +import com.sun.jna.WString; |
| 21 | +import com.sun.jna.win32.StdCallLibrary; |
| 22 | + |
| 23 | +/** |
| 24 | + * Ported from LMShare.h. |
| 25 | + * Windows SDK 7.1 |
| 26 | + * @author amarcionek[at]seven10storage.com |
| 27 | + */ |
| 28 | +public interface LMShare extends StdCallLibrary { |
| 29 | + |
| 30 | + // |
| 31 | + // Share types (shi1_type and shi2_type fields). |
| 32 | + // |
| 33 | + |
| 34 | + /** |
| 35 | + * Disk Drive. |
| 36 | + */ |
| 37 | + int STYPE_DISKTREE = 0; |
| 38 | + |
| 39 | + /** |
| 40 | + * Print Queue. |
| 41 | + */ |
| 42 | + int STYPE_PRINTQ = 1; |
| 43 | + |
| 44 | + /** |
| 45 | + * Communication device. |
| 46 | + */ |
| 47 | + int STYPE_DEVICE = 2; |
| 48 | + |
| 49 | + /** |
| 50 | + * Interprocess communication (IPC). |
| 51 | + */ |
| 52 | + int STYPE_IPC = 3; |
| 53 | + |
| 54 | + /** |
| 55 | + * A temporary share. |
| 56 | + */ |
| 57 | + int STYPE_TEMPORARY = 0x40000000; |
| 58 | + |
| 59 | + /** |
| 60 | + * Special share reserved for interprocess communication (IPC$) or remote administration of the server (ADMIN$). |
| 61 | + * Can also refer to administrative shares such as C$, D$, E$, and so forth. For more information, see the network share functions. |
| 62 | + */ |
| 63 | + int STYPE_SPECIAL = 0x80000000; |
| 64 | + |
| 65 | + /** |
| 66 | + * Contains information about the shared resource, including name of the resource, type and permissions, number of connections, and other pertinent information. |
| 67 | + */ |
| 68 | + public static class SHARE_INFO_2 extends Structure { |
| 69 | + public SHARE_INFO_2() { |
| 70 | + super(); |
| 71 | + } |
| 72 | + |
| 73 | + public SHARE_INFO_2(Pointer memory) { |
| 74 | + super(memory); |
| 75 | + read(); |
| 76 | + } |
| 77 | + |
| 78 | + /** |
| 79 | + * Pointer to a Unicode string specifying the name of a shared resource. Calls to the NetShareSetInfo function ignore this member. |
| 80 | + */ |
| 81 | + public WString shi2_netname; |
| 82 | + |
| 83 | + /** |
| 84 | + * A combination of values that specify the type of share. Calls to the NetShareSetInfo function ignore this member. |
| 85 | + * One of the following values may be specified. You can isolate these values by using the STYPE_MASK value. |
| 86 | + * STYPE_DISKTREE, STYPE_PRINTQ, STYPE_DEVICE, STYPE_IPC, STYPE_TEMPORARY, STYPE_SPECIAL |
| 87 | + */ |
| 88 | + public int shi2_type; |
| 89 | + |
| 90 | + /** |
| 91 | + * Pointer to a Unicode string specifying an optional comment about the shared resource. |
| 92 | + */ |
| 93 | + public WString shi2_remark; |
| 94 | + |
| 95 | + /** |
| 96 | + * Specifies a DWORD value that indicates the shared resource's permissions for servers running with share-level security. |
| 97 | + * This member is ignored on a server running user-level security. This member can be any of the following values. |
| 98 | + * Calls to the NetShareSetInfo function ignore this member. Note that Windows does not support share-level security. |
| 99 | + * For more information about controlling access to securable objects, see Access Control, Privileges, and Securable Objects. |
| 100 | + * NOTE: Bit masks are defined in LmAccess.Java |
| 101 | + */ |
| 102 | + public int shi2_permissions; |
| 103 | + |
| 104 | + /** |
| 105 | + * Specifies a DWORD value that indicates the maximum number of concurrent connections that the shared resource can accommodate. |
| 106 | + * The number of connections is unlimited if the value specified in this member is -1. |
| 107 | + */ |
| 108 | + public int shi2_max_uses; |
| 109 | + |
| 110 | + /** |
| 111 | + * Specifies a DWORD value that indicates the number of current connections to the resource. Calls to the NetShareSetInfo function ignore this member. |
| 112 | + */ |
| 113 | + public int shi2_current_uses; |
| 114 | + |
| 115 | + /** |
| 116 | + * Pointer to a Unicode string that contains the local path for the shared resource. For disks, this member is the path being shared. |
| 117 | + * For print queues, this member is the name of the print queue being shared. Calls to the NetShareSetInfo function ignore this member. |
| 118 | + */ |
| 119 | + public WString shi2_path; |
| 120 | + |
| 121 | + /** |
| 122 | + * Pointer to a Unicode string that specifies the share's password (when the server is running with share-level security). If the server is |
| 123 | + * running with user-level security, this member is ignored. Note that Windows does not support share-level security. |
| 124 | + * This member can be no longer than SHPWLEN+1 bytes (including a terminating null character). Calls to the NetShareSetInfo function ignore this member. |
| 125 | + */ |
| 126 | + public WString shi2_passwd; |
| 127 | + |
| 128 | + protected List getFieldOrder() { |
| 129 | + return Arrays.asList(new String[] { "shi2_netname", |
| 130 | + "shi2_type", |
| 131 | + "shi2_remark", |
| 132 | + "shi2_permissions", |
| 133 | + "shi2_max_uses", |
| 134 | + "shi2_current_uses", |
| 135 | + "shi2_path", |
| 136 | + "shi2_passwd" }); |
| 137 | + } |
| 138 | + } |
| 139 | + |
| 140 | + /** |
| 141 | + * Contains information about the shared resource, including name of the resource, type and permissions, number of connections, and other pertinent information. |
| 142 | + */ |
| 143 | + public static class SHARE_INFO_502 extends Structure { |
| 144 | + public SHARE_INFO_502() { |
| 145 | + super(); |
| 146 | + } |
| 147 | + |
| 148 | + public SHARE_INFO_502(Pointer memory) { |
| 149 | + super(memory); |
| 150 | + read(); |
| 151 | + } |
| 152 | + |
| 153 | + /** |
| 154 | + * Pointer to a Unicode string specifying the name of a shared resource. Calls to the NetShareSetInfo function ignore this member. |
| 155 | + */ |
| 156 | + public WString shi502_netname; |
| 157 | + |
| 158 | + /** |
| 159 | + * A combination of values that specify the type of share. Calls to the NetShareSetInfo function ignore this member. |
| 160 | + * One of the following values may be specified. You can isolate these values by using the STYPE_MASK value. |
| 161 | + * STYPE_DISKTREE, STYPE_PRINTQ, STYPE_DEVICE, STYPE_IPC, STYPE_TEMPORARY, STYPE_SPECIAL |
| 162 | + */ |
| 163 | + public int shi502_type; |
| 164 | + |
| 165 | + /** |
| 166 | + * Pointer to a Unicode string specifying an optional comment about the shared resource. |
| 167 | + */ |
| 168 | + public WString shi502_remark; |
| 169 | + |
| 170 | + /** |
| 171 | + * Specifies a DWORD value that indicates the shared resource's permissions for servers running with share-level security. |
| 172 | + * This member is ignored on a server running user-level security. This member can be any of the following values. |
| 173 | + * Calls to the NetShareSetInfo function ignore this member. Note that Windows does not support share-level security. |
| 174 | + * For more information about controlling access to securable objects, see Access Control, Privileges, and Securable Objects. |
| 175 | + * NOTE: Bit masks are defined in LmAccess.Java |
| 176 | + */ |
| 177 | + public int shi502_permissions; |
| 178 | + |
| 179 | + /** |
| 180 | + * Specifies a DWORD value that indicates the maximum number of concurrent connections that the shared resource can accommodate. |
| 181 | + * The number of connections is unlimited if the value specified in this member is -1. |
| 182 | + */ |
| 183 | + public int shi502_max_uses; |
| 184 | + |
| 185 | + /** |
| 186 | + * Specifies a DWORD value that indicates the number of current connections to the resource. Calls to the NetShareSetInfo function ignore this member. |
| 187 | + */ |
| 188 | + public int shi502_current_uses; |
| 189 | + |
| 190 | + /** |
| 191 | + * Pointer to a Unicode string that contains the local path for the shared resource. For disks, this member is the path being shared. |
| 192 | + * For print queues, this member is the name of the print queue being shared. Calls to the NetShareSetInfo function ignore this member. |
| 193 | + */ |
| 194 | + public WString shi502_path; |
| 195 | + |
| 196 | + /** |
| 197 | + * Pointer to a Unicode string that specifies the share's password (when the server is running with share-level security). If the server is |
| 198 | + * running with user-level security, this member is ignored. Note that Windows does not support share-level security. |
| 199 | + * This member can be no longer than SHPWLEN+1 bytes (including a terminating null character). Calls to the NetShareSetInfo function ignore this member. |
| 200 | + */ |
| 201 | + public WString shi502_passwd; |
| 202 | + |
| 203 | + /** |
| 204 | + * Reserved; must be zero. Calls to the NetShareSetInfo function ignore this member. |
| 205 | + */ |
| 206 | + public int shi502_reserved; |
| 207 | + |
| 208 | + /** |
| 209 | + * Specifies the SECURITY_DESCRIPTOR associated with this share. |
| 210 | + */ |
| 211 | + public Pointer shi502_security_descriptor; |
| 212 | + |
| 213 | + protected List getFieldOrder() { |
| 214 | + return Arrays.asList(new String[] { "shi502_netname", |
| 215 | + "shi502_type", |
| 216 | + "shi502_remark", |
| 217 | + "shi502_permissions", |
| 218 | + "shi502_max_uses", |
| 219 | + "shi502_current_uses", |
| 220 | + "shi502_path", |
| 221 | + "shi502_passwd", |
| 222 | + "shi502_reserved", |
| 223 | + "shi502_security_descriptor" }); |
| 224 | + } |
| 225 | + } |
| 226 | +} |
0 commit comments