1 /***********************************************************************\
2 *                               lmshare.d                               *
3 *                                                                       *
4 *                       Windows API header module                       *
5 *                                                                       *
6 *                 Translated from MinGW Windows headers                 *
7 *                                                                       *
8 *                       Placed into public domain                       *
9 \***********************************************************************/
10 module win32.lmshare;
11 
12 import win32.lmcons;
13 private import win32.w32api, win32.windef;
14 
15 static if (_WIN32_WINNT_ONLY) {
16 	pragma(lib, "netapi.lib");
17 }
18 /* else {
19 // only for WinME, 98, 95.
20 	pragma(lib, "svrapi.lib")
21 }
22 */
23 
24 const SHARE_NETNAME_PARMNUM      = 1;
25 const SHARE_TYPE_PARMNUM         = 3;
26 const SHARE_REMARK_PARMNUM       = 4;
27 const SHARE_PERMISSIONS_PARMNUM  = 5;
28 const SHARE_MAX_USES_PARMNUM     = 6;
29 const SHARE_CURRENT_USES_PARMNUM = 7;
30 const SHARE_PATH_PARMNUM         = 8;
31 const SHARE_PASSWD_PARMNUM       = 9;
32 const SHARE_FILE_SD_PARMNUM      = 501;
33 const SHARE_REMARK_INFOLEVEL   = PARMNUM_BASE_INFOLEVEL + SHARE_REMARK_PARMNUM;
34 const SHARE_MAX_USES_INFOLEVEL = PARMNUM_BASE_INFOLEVEL + SHARE_MAX_USES_PARMNUM;
35 const SHARE_FILE_SD_INFOLEVEL  = PARMNUM_BASE_INFOLEVEL + SHARE_FILE_SD_PARMNUM;
36 
37 const SHI1_NUM_ELEMENTS = 4;
38 const SHI2_NUM_ELEMENTS = 10;
39 
40 const STYPE_DISKTREE = 0;
41 const STYPE_PRINTQ   = 1;
42 const STYPE_DEVICE   = 2;
43 const STYPE_IPC      = 3;
44 const STYPE_DFS      = 100;
45 const STYPE_SPECIAL  = 0x80000000;
46 
47 const DWORD SHI_USES_UNLIMITED = -1;
48 
49 const SESS_GUEST = 1;
50 const SESS_NOENCRYPTION = 2;
51 const SESI1_NUM_ELEMENTS = 8;
52 const SESI2_NUM_ELEMENTS = 9;
53 
54 const PERM_FILE_READ   = 1;
55 const PERM_FILE_WRITE  = 2;
56 const PERM_FILE_CREATE = 4;
57 
58 struct FILE_INFO_2 {
59 	DWORD fi2_id;
60 }
61 alias FILE_INFO_2* PFILE_INFO_2, LPFILE_INFO_2;
62 
63 struct FILE_INFO_3 {
64 	DWORD fi3_id;
65 	DWORD fi3_permissions;
66 	DWORD fi3_num_locks;
67 	LPTSTR fi3_pathname;
68 	LPTSTR fi3_username;
69 }
70 alias FILE_INFO_3* PFILE_INFO_3, LPFILE_INFO_3;
71 
72 struct SHARE_INFO_0 {
73 	LPTSTR shi0_netname;
74 }
75 alias SHARE_INFO_0* PSHARE_INFO_0, LPSHARE_INFO_0;
76 
77 struct SHARE_INFO_1 {
78 	LPTSTR shi1_netname;
79 	DWORD shi1_type;
80 	LPTSTR shi1_remark;
81 }
82 alias SHARE_INFO_1* PSHARE_INFO_1, LPSHARE_INFO_1;
83 
84 struct SHARE_INFO_2 {
85 	LPTSTR shi2_netname;
86 	DWORD shi2_type;
87 	LPTSTR shi2_remark;
88 	DWORD shi2_permissions;
89 	DWORD shi2_max_uses;
90 	DWORD shi2_current_uses;
91 	LPTSTR shi2_path;
92 	LPTSTR shi2_passwd;
93 }
94 alias SHARE_INFO_2* PSHARE_INFO_2, LPSHARE_INFO_2;
95 
96 struct SHARE_INFO_502 {
97 	LPTSTR shi502_netname;
98 	DWORD shi502_type;
99 	LPTSTR shi502_remark;
100 	DWORD shi502_permissions;
101 	DWORD shi502_max_uses;
102 	DWORD shi502_current_uses;
103 	LPTSTR shi502_path;
104 	LPTSTR shi502_passwd;
105 	DWORD shi502_reserved;
106 	PSECURITY_DESCRIPTOR shi502_security_descriptor;
107 }
108 alias SHARE_INFO_502* PSHARE_INFO_502, LPSHARE_INFO_502;
109 
110 struct SHARE_INFO_1004 {
111 	LPTSTR shi1004_remark;
112 }
113 alias SHARE_INFO_1004* PSHARE_INFO_1004, LPSHARE_INFO_1004;
114 
115 struct SHARE_INFO_1006 {
116 	DWORD shi1006_max_uses;
117 }
118 alias SHARE_INFO_1006* PSHARE_INFO_1006, LPSHARE_INFO_1006;
119 
120 struct SHARE_INFO_1501 {
121 	DWORD shi1501_reserved;
122 	PSECURITY_DESCRIPTOR shi1501_security_descriptor;
123 }
124 alias SHARE_INFO_1501* PSHARE_INFO_1501, LPSHARE_INFO_1501;
125 
126 struct SESSION_INFO_0 {
127 	LPWSTR sesi0_cname;
128 }
129 alias SESSION_INFO_0* PSESSION_INFO_0, LPSESSION_INFO_0;
130 
131 struct SESSION_INFO_1 {
132 	LPTSTR sesi1_cname;
133 	LPTSTR sesi1_username;
134 	DWORD sesi1_num_opens;
135 	DWORD sesi1_time;
136 	DWORD sesi1_idle_time;
137 	DWORD sesi1_user_flags;
138 }
139 alias SESSION_INFO_1* PSESSION_INFO_1, LPSESSION_INFO_1;
140 
141 struct SESSION_INFO_2 {
142 	LPTSTR sesi2_cname;
143 	LPTSTR sesi2_username;
144 	DWORD sesi2_num_opens;
145 	DWORD sesi2_time;
146 	DWORD sesi2_idle_time;
147 	DWORD sesi2_user_flags;
148 	LPWSTR sesi2_cltype_name;
149 }
150 alias SESSION_INFO_2* PSESSION_INFO_2, LPSESSION_INFO_2;
151 
152 struct SESSION_INFO_10 {
153 	LPWSTR sesi10_cname;
154 	LPWSTR sesi10_username;
155 	DWORD sesi10_time;
156 	DWORD sesi10_idle_time;
157 }
158 alias SESSION_INFO_10* PSESSION_INFO_10, LPSESSION_INFO_10;
159 
160 struct SESSION_INFO_502 {
161 	LPWSTR sesi502_cname;
162 	LPWSTR sesi502_username;
163 	DWORD sesi502_num_opens;
164 	DWORD sesi502_time;
165 	DWORD sesi502_idle_time;
166 	DWORD sesi502_user_flags;
167 	LPWSTR sesi502_cltype_name;
168 	LPWSTR sesi502_transport;
169 }
170 alias SESSION_INFO_502* PSESSION_INFO_502, LPSESSION_INFO_502;
171 
172 struct CONNECTION_INFO_0 {
173 	DWORD coni0_id;
174 }
175 alias CONNECTION_INFO_0* PCONNECTION_INFO_0, LPCONNECTION_INFO_0;
176 
177 struct CONNECTION_INFO_1 {
178 	DWORD coni1_id;
179 	DWORD coni1_type;
180 	DWORD coni1_num_opens;
181 	DWORD coni1_num_users;
182 	DWORD coni1_time;
183 	LPWSTR coni1_username;
184 	LPWSTR coni1_netname;
185 }
186 alias CONNECTION_INFO_1* PCONNECTION_INFO_1, LPCONNECTION_INFO_1;
187 
188 extern (Windows) {
189 NET_API_STATUS NetShareAdd(LPWSTR,DWORD,PBYTE,PDWORD);
190 NET_API_STATUS NetShareEnum(LPWSTR,DWORD,PBYTE*,DWORD,PDWORD,PDWORD,PDWORD);
191 NET_API_STATUS NetShareEnumSticky(LPWSTR,DWORD,PBYTE*,DWORD,PDWORD,PDWORD,PDWORD resume_handle);
192 NET_API_STATUS NetShareGetInfo(LPWSTR,LPWSTR,DWORD,PBYTE*);
193 NET_API_STATUS NetShareSetInfo(LPWSTR,LPWSTR,DWORD,PBYTE,PDWORD);
194 NET_API_STATUS NetShareDel(LPWSTR,LPWSTR,DWORD);
195 NET_API_STATUS NetShareDelSticky(LPWSTR,LPWSTR,DWORD);
196 NET_API_STATUS NetShareCheck(LPWSTR,LPWSTR,PDWORD);
197 NET_API_STATUS NetSessionEnum(LPWSTR,LPWSTR,LPWSTR,DWORD,PBYTE*,DWORD,PDWORD,PDWORD,PDWORD);
198 NET_API_STATUS NetSessionDel(LPWSTR,LPWSTR,LPWSTR);
199 NET_API_STATUS NetSessionGetInfo(LPWSTR,LPWSTR,LPWSTR,DWORD,PBYTE*);
200 NET_API_STATUS NetConnectionEnum(LPWSTR,LPWSTR,DWORD,PBYTE*,DWORD,PDWORD,PDWORD,PDWORD);
201 NET_API_STATUS NetFileClose(LPWSTR,DWORD);
202 NET_API_STATUS NetFileEnum(LPWSTR,LPWSTR,LPWSTR,DWORD,PBYTE*,DWORD,PDWORD,PDWORD,PDWORD);
203 NET_API_STATUS NetFileGetInfo(LPWSTR,DWORD,DWORD,PBYTE*);
204 }