- correct ConvertStringSidToSidW and ConvertSidToStringSidW, with
[wine/hacks.git] / dlls / user / network.c
blob21f79f5f9893065a03ed5a9bb934400bf7473acf
1 /*
2 * USER Windows Network functions
4 * Copyright 1995 Martin von Loewis
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "config.h"
23 #include <ctype.h>
24 #include <stdarg.h>
25 #include <string.h>
26 #include <sys/types.h>
27 #ifdef HAVE_UNISTD_H
28 # include <unistd.h>
29 #endif
31 #include "windef.h"
32 #include "winbase.h"
33 #include "wine/winnet16.h"
34 #include "winnetwk.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(wnet);
40 * Remote printing
43 /**************************************************************************
44 * WNetOpenJob [USER.501]
46 WORD WINAPI WNetOpenJob16( LPSTR szQueue, LPSTR szJobTitle, WORD nCopies, LPINT16 pfh )
48 FIXME( "(%s, %s, %d, %p): stub\n",
49 debugstr_a(szQueue), debugstr_a(szJobTitle), nCopies, pfh );
50 return WN16_NET_ERROR;
53 /**************************************************************************
54 * WNetCloseJob [USER.502]
56 WORD WINAPI WNetCloseJob16( WORD fh, LPINT16 pidJob, LPSTR szQueue )
58 FIXME( "(%d, %p, %s): stub\n", fh, pidJob, debugstr_a(szQueue) );
59 return WN16_NET_ERROR;
62 /**************************************************************************
63 * WNetWriteJob [USER.524]
65 WORD WINAPI WNetWriteJob16( HANDLE16 hJob, LPSTR lpData, LPINT16 lpcbData )
67 FIXME( "(%04x, %p, %p): stub\n", hJob, lpData, lpcbData );
68 return WN16_NET_ERROR;
71 /**************************************************************************
72 * WNetAbortJob [USER.503]
74 WORD WINAPI WNetAbortJob16( LPSTR szQueue, WORD wJobId )
76 FIXME( "(%s, %d): stub\n", debugstr_a(szQueue), wJobId );
77 return WN16_NET_ERROR;
80 /**************************************************************************
81 * WNetHoldJob [USER.504]
83 WORD WINAPI WNetHoldJob16( LPSTR szQueue, WORD wJobId )
85 FIXME( "(%s, %d): stub\n", debugstr_a(szQueue), wJobId );
86 return WN16_NET_ERROR;
89 /**************************************************************************
90 * WNetReleaseJob [USER.505]
92 WORD WINAPI WNetReleaseJob16( LPSTR szQueue, WORD wJobId )
94 FIXME( "(%s, %d): stub\n", debugstr_a(szQueue), wJobId );
95 return WN16_NET_ERROR;
98 /**************************************************************************
99 * WNetCancelJob [USER.506]
101 WORD WINAPI WNetCancelJob16( LPSTR szQueue, WORD wJobId )
103 FIXME( "(%s, %d): stub\n", debugstr_a(szQueue), wJobId );
104 return WN16_NET_ERROR;
107 /**************************************************************************
108 * WNetSetJobCopies [USER.507]
110 WORD WINAPI WNetSetJobCopies16( LPSTR szQueue, WORD wJobId, WORD nCopies )
112 FIXME( "(%s, %d, %d): stub\n", debugstr_a(szQueue), wJobId, nCopies );
113 return WN16_NET_ERROR;
116 /**************************************************************************
117 * WNetWatchQueue [USER.508]
119 WORD WINAPI WNetWatchQueue16( HWND16 hWnd, LPSTR szLocal, LPSTR szUser, WORD nQueue )
121 FIXME( "(%04x, %s, %s, %d): stub\n",
122 hWnd, debugstr_a(szLocal), debugstr_a(szUser), nQueue );
123 return WN16_NET_ERROR;
126 /**************************************************************************
127 * WNetUnwatchQueue [USER.509]
129 WORD WINAPI WNetUnwatchQueue16( LPSTR szQueue )
131 FIXME( "(%s): stub\n", debugstr_a(szQueue) );
132 return WN16_NET_ERROR;
135 /**************************************************************************
136 * WNetLockQueueData [USER.510]
138 WORD WINAPI WNetLockQueueData16( LPSTR szQueue, LPSTR szUser,
139 LPQUEUESTRUCT16 *lplpQueueStruct )
141 FIXME( "(%s, %s, %p): stub\n",
142 debugstr_a(szQueue), debugstr_a(szUser), lplpQueueStruct );
143 return WN16_NET_ERROR;
146 /**************************************************************************
147 * WNetUnlockQueueData [USER.511]
149 WORD WINAPI WNetUnlockQueueData16( LPSTR szQueue )
151 FIXME( "(%s): stub\n", debugstr_a(szQueue) );
152 return WN16_NET_ERROR;
157 * Connections
160 /********************************************************************
161 * WNetAddConnection [USER.517] Directs a local device to net
163 * Redirects a local device (either a disk drive or printer port)
164 * to a shared device on a remote server.
166 WORD WINAPI WNetAddConnection16( LPSTR lpNetPath, LPSTR lpPassWord,
167 LPSTR lpLocalName )
169 FIXME( "(%s, %p, %s): stub\n",
170 debugstr_a(lpNetPath), lpPassWord, debugstr_a(lpLocalName) );
171 return WN16_NET_ERROR;
174 /********************************************************************
175 * WNetCancelConnection [USER.518] undirects a local device
177 WORD WINAPI WNetCancelConnection16( LPSTR lpName, BOOL16 bForce )
179 FIXME( "(%s, %04X): stub\n", debugstr_a(lpName), bForce);
180 return WN16_NOT_SUPPORTED;
183 /********************************************************************
184 * WNetGetConnection [USER.512] reverse-resolves a local device
186 WORD WINAPI WNetGetConnection16( LPSTR lpLocalName,
187 LPSTR lpRemoteName, UINT16 *cbRemoteName )
189 char label[32];
191 TRACE( "local %s\n", lpLocalName );
192 switch(GetDriveTypeA(lpLocalName))
194 case DRIVE_REMOTE:
195 GetVolumeInformationA( lpLocalName, label, sizeof(label), NULL, NULL, NULL, NULL, 0 );
196 if (strlen(label) + 1 > *cbRemoteName)
198 *cbRemoteName = strlen(label) + 1;
199 return WN16_MORE_DATA;
201 strcpy( lpRemoteName, label );
202 *cbRemoteName = strlen(lpRemoteName) + 1;
203 return WN16_SUCCESS;
204 case DRIVE_REMOVABLE:
205 case DRIVE_FIXED:
206 case DRIVE_CDROM:
207 TRACE("file is local\n");
208 return WN16_NOT_CONNECTED;
209 default:
210 return WN16_BAD_LOCALNAME;
214 /**************************************************************************
215 * WNetRestoreConnection [USER.523]
217 WORD WINAPI WNetRestoreConnection16( HWND16 hwndOwner, LPSTR lpszDevice )
219 FIXME( "(%04x, %s): stub\n", hwndOwner, debugstr_a(lpszDevice) );
220 return WN16_NOT_SUPPORTED;
225 * Capabilities
228 /**************************************************************************
229 * WNetGetCaps [USER.513]
231 WORD WINAPI WNetGetCaps16( WORD capability )
233 switch (capability)
235 case WNNC16_SPEC_VERSION:
236 return 0x30a; /* WfW 3.11 (and apparently other 3.1x) */
238 case WNNC16_NET_TYPE:
239 /* hi byte = network type,
240 lo byte = network vendor (Netware = 0x03) [15 types] */
241 return WNNC16_NET_MultiNet | WNNC16_SUBNET_WinWorkgroups;
243 case WNNC16_DRIVER_VERSION:
244 /* driver version of vendor */
245 return 0x100; /* WfW 3.11 */
247 case WNNC16_USER:
248 /* 1 = WNetGetUser is supported */
249 return 1;
251 case WNNC16_CONNECTION:
252 /* returns mask of the supported connection functions */
253 return WNNC16_CON_AddConnection | WNNC16_CON_CancelConnection
254 | WNNC16_CON_GetConnections /* | WNNC16_CON_AutoConnect */
255 | WNNC16_CON_BrowseDialog | WNNC16_CON_RestoreConnection;
257 case WNNC16_PRINTING:
258 /* returns mask of the supported printing functions */
259 return WNNC16_PRT_OpenJob | WNNC16_PRT_CloseJob | WNNC16_PRT_HoldJob
260 | WNNC16_PRT_ReleaseJob | WNNC16_PRT_CancelJob
261 | WNNC16_PRT_SetJobCopies | WNNC16_PRT_WatchQueue
262 | WNNC16_PRT_UnwatchQueue | WNNC16_PRT_LockQueueData
263 | WNNC16_PRT_UnlockQueueData | WNNC16_PRT_AbortJob
264 | WNNC16_PRT_WriteJob;
266 case WNNC16_DIALOG:
267 /* returns mask of the supported dialog functions */
268 return WNNC16_DLG_DeviceMode | WNNC16_DLG_BrowseDialog
269 | WNNC16_DLG_ConnectDialog | WNNC16_DLG_DisconnectDialog
270 | WNNC16_DLG_ViewQueueDialog | WNNC16_DLG_PropertyDialog
271 | WNNC16_DLG_ConnectionDialog
272 /* | WNNC16_DLG_PrinterConnectDialog
273 | WNNC16_DLG_SharesDialog | WNNC16_DLG_ShareAsDialog */;
275 case WNNC16_ADMIN:
276 /* returns mask of the supported administration functions */
277 /* not sure if long file names is a good idea */
278 return WNNC16_ADM_GetDirectoryType
279 /* | WNNC16_ADM_DirectoryNotify */ /*not yet supported*/
280 | WNNC16_ADM_LongNames /* | WNNC16_ADM_SetDefaultDrive */;
282 case WNNC16_ERROR:
283 /* returns mask of the supported error functions */
284 return WNNC16_ERR_GetError | WNNC16_ERR_GetErrorText;
286 case WNNC16_PRINTMGREXT:
287 /* returns the Print Manager version in major and
288 minor format if Print Manager functions are available */
289 return 0x30e; /* printman version of WfW 3.11 */
291 case 0xffff:
292 /* Win 3.11 returns HMODULE of network driver here
293 FIXME: what should we return ?
294 logonoff.exe needs it, msmail crashes with wrong value */
295 return 0;
297 default:
298 return 0;
304 * Get User
307 /**************************************************************************
308 * WNetGetUser [USER.516]
310 WORD WINAPI WNetGetUser16( LPCSTR lpName, LPSTR szUser, LPINT16 nBufferSize )
312 FIXME( "(%p, %p, %p): stub\n", lpName, szUser, nBufferSize );
313 return WN16_NOT_SUPPORTED;
318 * Browsing
321 /**************************************************************************
322 * WNetDeviceMode [USER.514]
324 WORD WINAPI WNetDeviceMode16( HWND16 hWndOwner )
326 FIXME( "(%04x): stub\n", hWndOwner );
327 return WN16_NOT_SUPPORTED;
330 /**************************************************************************
331 * WNetBrowseDialog [USER.515]
333 WORD WINAPI WNetBrowseDialog16( HWND16 hParent, WORD nType, LPSTR szPath )
335 FIXME( "(%04x, %x, %s): stub\n", hParent, nType, szPath );
336 return WN16_NOT_SUPPORTED;
339 /********************************************************************
340 * WNetConnectDialog [USER.525]
342 WORD WINAPI WNetConnectDialog( HWND16 hWndParent, WORD iType )
344 FIXME( "(%04x, %x): stub\n", hWndParent, iType );
345 return WN16_SUCCESS;
348 /**************************************************************************
349 * WNetDisconnectDialog [USER.526]
351 WORD WINAPI WNetDisconnectDialog16( HWND16 hwndOwner, WORD iType )
353 FIXME( "(%04x, %x): stub\n", hwndOwner, iType );
354 return WN16_NOT_SUPPORTED;
357 /**************************************************************************
358 * WNetConnectionDialog [USER.527]
360 WORD WINAPI WNetConnectionDialog16( HWND16 hWndParent, WORD iType )
362 FIXME( "(%04x, %x): stub\n", hWndParent, iType );
363 return WN16_SUCCESS;
366 /**************************************************************************
367 * WNetViewQueueDialog [USER.528]
369 WORD WINAPI WNetViewQueueDialog16( HWND16 hwndOwner, LPSTR lpszQueue )
371 FIXME(" (%04x, %s): stub\n", hwndOwner, debugstr_a(lpszQueue) );
372 return WN16_NOT_SUPPORTED;
375 /**************************************************************************
376 * WNetPropertyDialog [USER.529]
378 WORD WINAPI WNetPropertyDialog16( HWND16 hwndParent, WORD iButton,
379 WORD nPropSel, LPSTR lpszName, WORD nType )
381 FIXME( "(%04x, %x, %x, %s, %x ): stub\n",
382 hwndParent, iButton, nPropSel, debugstr_a(lpszName), nType );
383 return WN16_NOT_SUPPORTED;
386 /**************************************************************************
387 * WNetGetPropertyText [USER.532]
389 WORD WINAPI WNetGetPropertyText16( WORD iButton, WORD nPropSel, LPSTR lpszName,
390 LPSTR lpszButtonName, WORD cbButtonName, WORD nType )
392 FIXME( "(%04x, %04x, %s, %s, %04x): stub\n",
393 iButton, nPropSel, debugstr_a(lpszName), debugstr_a(lpszButtonName), nType);
394 return WN16_NOT_SUPPORTED;
399 * Admin
402 /*********************************************************************
403 * WNetGetDirectoryType [USER.530] Decides whether resource is local
405 * RETURNS
406 * on success, puts one of the following in *lpType:
407 * - WNDT_NETWORK on a network
408 * - WNDT_LOCAL local
410 WORD WINAPI WNetGetDirectoryType16( LPSTR lpName, LPINT16 lpType )
412 UINT type = GetDriveTypeA(lpName);
413 if ( type == DRIVE_NO_ROOT_DIR )
414 type = GetDriveTypeA(NULL);
416 *lpType = (type == DRIVE_REMOTE)? WNDT_NETWORK : WNDT_NORMAL;
418 TRACE( "%s is %s\n", debugstr_a(lpName),
419 (*lpType == WNDT_NETWORK)? "WNDT_NETWORK" : "WNDT_NORMAL" );
420 return WN16_SUCCESS;
423 /**************************************************************************
424 * WNetDirectoryNotify [USER.531]
426 WORD WINAPI WNetDirectoryNotify16( HWND16 hwndOwner, LPSTR lpDir, WORD wOper )
428 FIXME( "(%04x, %s, %s): stub\n", hwndOwner, debugstr_a(lpDir),
429 (wOper == WNDN_MKDIR)? "WNDN_MKDIR" :
430 (wOper == WNDN_MVDIR)? "WNDN_MVDIR" :
431 (wOper == WNDN_RMDIR)? "WNDN_RMDIR" : "unknown" );
432 return WN16_NOT_SUPPORTED;
437 * Error handling
440 /**************************************************************************
441 * WNetGetError [USER.519]
443 WORD WINAPI WNetGetError16( LPINT16 nError )
445 FIXME( "(%p): stub\n", nError );
446 return WN16_NOT_SUPPORTED;
449 /**************************************************************************
450 * WNetGetErrorText [USER.520]
452 WORD WINAPI WNetGetErrorText16( WORD nError, LPSTR lpBuffer, LPINT16 nBufferSize )
454 FIXME( "(%x, %p, %p): stub\n", nError, lpBuffer, nBufferSize );
455 return WN16_NET_ERROR;
458 /**************************************************************************
459 * WNetErrorText [USER.499]
461 WORD WINAPI WNetErrorText16( WORD nError, LPSTR lpszText, WORD cbText )
463 FIXME("(%x, %p, %x): stub\n", nError, lpszText, cbText );
464 return FALSE;