Release 980517
[wine/multimedia.git] / misc / network.c
blob2c17dcbdf9508b1dcdc5b9545046a5005f8b8c73
1 /*
2 * Network functions
4 * This is the MPR.DLL stuff from Win32, as well as the USER
5 * stuff by the same names in Win 3.x.
7 */
9 #include <ctype.h>
10 #include <stdio.h>
12 #include "windows.h"
13 #include "winerror.h"
14 #include "drive.h"
15 #include "wnet.h"
16 #include "debug.h"
17 #include "win.h"
19 /********************************************************************
20 * WNetAddConnection16 [USER.517] Directs a local device to net
22 * Redirects a local device (either a disk drive or printer port)
23 * to a shared device on a remote server.
25 UINT16 WINAPI WNetAddConnection16(LPSTR lpNetPath, LPSTR lpPassWord,
26 LPSTR lpLocalName)
28 return WNetAddConnection32A(lpNetPath, lpPassWord, lpLocalName);
31 /* [MPR.50] */
33 UINT32 WNetAddConnection32A(LPSTR NetPath, LPSTR PassWord,
34 LPSTR LocalName)
36 FIXME(wnet, "('%s', %p, '%s'): stub\n",
37 NetPath, PassWord, LocalName);
38 return WN_NO_NETWORK;
41 /* [MPR.51] */
43 UINT32 WNetAddConnection32W(LPWSTR NetPath,
44 LPWSTR PassWord,
45 LPWSTR LocalName)
47 FIXME(wnet, " stub!\n");
48 return WN_NO_NETWORK;
51 /* ****************************************************************
52 * WNetAddConnection2_32A [MPR.46]
55 UINT32
56 WNetAddConnection2_32A(LPNETRESOURCE32A netresource, /* [in] */
57 LPCSTR password, /* [in] */
58 LPCSTR username, /* [in] */
59 DWORD flags /* [in] */ )
61 FIXME(wnet, "(%p,%s,%s,0x%08lx), stub!\n", netresource,
62 password, username, (unsigned long) flags);
63 SetLastError(WN_NO_NETWORK);
64 return WN_NO_NETWORK;
67 /* ****************************************************************
68 * WNetAddConnection2W [MPR.47]
71 UINT32
72 WNetAddConnection2_32W(LPNETRESOURCE32W netresource, /* [in] */
73 LPCWSTR password, /* [in] */
74 LPCWSTR username, /* [in] */
75 DWORD flags /* [in] */ )
77 FIXME(wnet, ", stub!\n");
78 SetLastError(WN_NO_NETWORK);
79 return WN_NO_NETWORK;
82 /* ****************************************************************
83 * WNetAddConnection3_32A [MPR.48]
86 UINT32 WNetAddConnection3_32A(HWND32 owner,
87 LPNETRESOURCE32A netresource,
88 LPCSTR password,
89 LPCSTR username,
90 DWORD flags)
92 TRACE(wnet, "owner = 0x%x\n", owner);
93 return WNetAddConnection2_32A(netresource,
94 password, username, flags);
97 /* ****************************************************************
98 * WNetAddConnection3W [MPR.49]
101 UINT32 WNetAddConnection3_32W(HWND32 owner,
102 LPNETRESOURCE32W netresource,
103 LPCWSTR username,
104 LPCWSTR password,
105 DWORD flags)
107 TRACE(wnet,"owner = 0x%x\n", owner);
108 return WNetAddConnection2_32W(netresource, username, password,
109 flags);
113 /********************************************************************
114 * WNetCancelConnection [USER.518] undirects a local device
116 UINT16 WINAPI WNetCancelConnection(LPSTR lpName, BOOL16 bForce)
118 FIXME(wnet, "('%s', %04X): stub\n", lpName, bForce);
119 return WN_NO_NETWORK;
123 /**************************************************************************
124 * WNetErrorText16 [USER.499]
126 int WINAPI WNetErrorText(WORD nError,LPSTR lpszText,WORD cbText)
128 FIXME(wnet, "(%x,%p,%x): stub\n",nError,lpszText,cbText);
129 return FALSE;
132 /**************************************************************************
133 * WNetOpenJob16 [USER.501]
135 int WINAPI WNetOpenJob(LPSTR szQueue,LPSTR szJobTitle,WORD nCopies,LPWORD pfh)
137 FIXME(wnet, "('%s','%s',%x,%p): stub\n",
138 szQueue,szJobTitle,nCopies,pfh);
139 return WN_NET_ERROR;
142 /**************************************************************************
143 * WNetCloseJob [USER.502]
145 int WINAPI WNetCloseJob(WORD fh,LPWORD pidJob,LPSTR szQueue)
147 FIXME(wnet, "(%x,%p,'%s'): stub\n",fh,pidJob,szQueue);
148 return WN_NET_ERROR;
151 /**************************************************************************
152 * WNetAbortJob [USER.503]
154 int WINAPI WNetAbortJob(LPSTR szQueue,WORD wJobId)
156 FIXME(wnet, "('%s',%x): stub\n",szQueue,wJobId);
157 return WN_NET_ERROR;
160 /**************************************************************************
161 * WNetHoldJob [USER.504]
163 int WINAPI WNetHoldJob(LPSTR szQueue,WORD wJobId)
165 FIXME(wnet, "('%s',%x): stub\n",szQueue,wJobId);
166 return WN_NET_ERROR;
169 /**************************************************************************
170 * WNetReleaseJob [USER.505]
172 int WINAPI WNetReleaseJob(LPSTR szQueue,WORD wJobId)
174 FIXME(wnet, "('%s',%x): stub\n",szQueue,wJobId);
175 return WN_NET_ERROR;
178 /**************************************************************************
179 * WNetCancelJob [USER.506]
181 int WINAPI WNetCancelJob(LPSTR szQueue,WORD wJobId)
183 FIXME(wnet, "('%s',%x): stub\n",szQueue,wJobId);
184 return WN_NET_ERROR;
187 /**************************************************************************
188 * WNetSetJobCopies [USER.507]
190 int WINAPI WNetSetJobCopies(LPSTR szQueue,WORD wJobId,WORD nCopies)
192 FIXME(wnet, "('%s',%x,%x): stub\n",szQueue,wJobId,nCopies);
193 return WN_NET_ERROR;
196 /**************************************************************************
197 * WNetWatchQueue [USER.508]
199 int WINAPI WNetWatchQueue(HWND16 hWnd,LPSTR szLocal,LPSTR szUser,WORD nQueue)
201 FIXME(wnet, "(%04x,'%s','%s',%x): stub\n",hWnd,szLocal,szUser,nQueue);
202 return WN_NET_ERROR;
205 /**************************************************************************
206 * WNetUnwatchQueue [USER.509]
208 int WINAPI WNetUnwatchQueue(LPSTR szQueue)
210 FIXME(wnet, "('%s'): stub\n", szQueue);
211 return WN_NET_ERROR;
214 /**************************************************************************
215 * WNetLockQueueData [USER.510]
217 int WINAPI WNetLockQueueData(LPSTR szQueue,LPSTR szUser,void *lplpQueueStruct)
219 FIXME(wnet, "('%s','%s',%p): stub\n",szQueue,szUser,lplpQueueStruct);
220 return WN_NET_ERROR;
223 /**************************************************************************
224 * WNetUnlockQueueData [USER.511]
226 int WINAPI WNetUnlockQueueData(LPSTR szQueue)
228 FIXME(wnet, "('%s'): stub\n",szQueue);
229 return WN_NET_ERROR;
233 /********************************************************************
234 * WNetGetConnection16 [USER.512] reverse-resolves a local device
236 * RETURNS
237 * - WN_BAD_LOCALNAME lpLocalName makes no sense
238 * - WN_NOT_CONNECTED drive is a local drive
239 * - WN_MORE_DATA buffer isn't big enough
240 * - WN_SUCCESS success (net path in buffer)
242 int WINAPI WNetGetConnection16(LPCSTR lpLocalName,
243 LPSTR lpRemoteName, UINT16 *cbRemoteName)
245 const char *path;
247 if (lpLocalName[1] == ':')
249 int drive = toupper(lpLocalName[0]) - 'A';
250 switch(GetDriveType16(drive))
252 case DRIVE_CANNOTDETERMINE:
253 case DRIVE_DOESNOTEXIST:
254 return WN_BAD_LOCALNAME;
255 case DRIVE_REMOVABLE:
256 case DRIVE_FIXED:
257 return WN_NOT_CONNECTED;
258 case DRIVE_REMOTE:
259 path = DRIVE_GetLabel(drive);
260 if (strlen(path) + 1 > *cbRemoteName)
262 *cbRemoteName = strlen(path) + 1;
263 return WN_MORE_DATA;
265 strcpy( lpRemoteName, path );
266 *cbRemoteName = strlen(lpRemoteName) + 1;
267 return WN_SUCCESS;
270 return WN_BAD_LOCALNAME;
273 /**************************************************************************
274 * WNetGetConnectionA [MPR.70]
276 DWORD WINAPI
277 WNetGetConnection32A(LPCSTR localname,LPSTR remotename,LPDWORD buflen)
279 UINT16 x;
280 DWORD ret = WNetGetConnection16(localname,remotename,&x);
281 *buflen = x;
282 return ret;
286 /**************************************************************************
287 * WNetGetCaps [USER.513]
289 int WINAPI WNetGetCaps(WORD capability)
291 switch (capability) {
292 case WNNC_SPEC_VERSION:
294 return 0x30a; /* WfW 3.11(and apparently other 3.1x) */
296 case WNNC_NET_TYPE:
297 /* hi byte = network type,
298 lo byte = network vendor (Netware = 0x03) [15 types] */
299 return WNNC_NET_MultiNet | WNNC_SUBNET_WinWorkgroups;
301 case WNNC_DRIVER_VERSION:
302 /* driver version of vendor */
303 return 0x100; /* WfW 3.11 */
305 case WNNC_USER:
306 /* 1 = WNetGetUser is supported */
307 return 1;
309 case WNNC_CONNECTION:
310 /* returns mask of the supported connection functions */
311 return WNNC_CON_AddConnection|WNNC_CON_CancelConnection
312 |WNNC_CON_GetConnections/*|WNNC_CON_AutoConnect*/
313 |WNNC_CON_BrowseDialog|WNNC_CON_RestoreConnection;
315 case WNNC_PRINTING:
316 /* returns mask of the supported printing functions */
317 return WNNC_PRT_OpenJob|WNNC_PRT_CloseJob|WNNC_PRT_HoldJob
318 |WNNC_PRT_ReleaseJob|WNNC_PRT_CancelJob
319 |WNNC_PRT_SetJobCopies|WNNC_PRT_WatchQueue
320 |WNNC_PRT_UnwatchQueue|WNNC_PRT_LockQueueData
321 |WNNC_PRT_UnlockQueueData|WNNC_PRT_AbortJob
322 |WNNC_PRT_WriteJob;
324 case WNNC_DIALOG:
325 /* returns mask of the supported dialog functions */
326 return WNNC_DLG_DeviceMode|WNNC_DLG_BrowseDialog
327 |WNNC_DLG_ConnectDialog|WNNC_DLG_DisconnectDialog
328 |WNNC_DLG_ViewQueueDialog|WNNC_DLG_PropertyDialog
329 |WNNC_DLG_ConnectionDialog
330 /*|WNNC_DLG_PrinterConnectDialog
331 |WNNC_DLG_SharesDialog|WNNC_DLG_ShareAsDialog*/;
333 case WNNC_ADMIN:
334 /* returns mask of the supported administration functions */
335 /* not sure if long file names is a good idea */
336 return WNNC_ADM_GetDirectoryType|WNNC_ADM_DirectoryNotify
337 |WNNC_ADM_LongNames/*|WNNC_ADM_SetDefaultDrive*/;
339 case WNNC_ERROR:
340 /* returns mask of the supported error functions */
341 return WNNC_ERR_GetError|WNNC_ERR_GetErrorText;
343 case WNNC_PRINTMGREXT:
344 /* returns the Print Manager version in major and
345 minor format if Print Manager functions are available */
346 return 0x30e; /* printman version of WfW 3.11 */
348 case 0xffff:
349 /* Win 3.11 returns HMODULE of network driver here
350 FIXME: what should we return ?
351 logonoff.exe needs it, msmail crashes with wrong value */
352 return 0;
354 default:
355 return 0;
359 /**************************************************************************
360 * WNetDeviceMode [USER.514]
362 int WINAPI WNetDeviceMode(HWND16 hWndOwner)
364 FIXME(wnet, "(%04x): stub\n",hWndOwner);
365 return WN_NO_NETWORK;
368 /**************************************************************************
369 * WNetBrowseDialog [USER.515]
371 int WINAPI WNetBrowseDialog(HWND16 hParent,WORD nType,LPSTR szPath)
373 FIXME(wnet, "(%04x,%x,'%s'): stub\n",hParent,nType,szPath);
374 return WN_NO_NETWORK;
377 /**************************************************************************
378 * WNetGetUser [USER.516]
380 UINT16 WINAPI WNetGetUser(LPSTR lpLocalName, LPSTR lpUserName, DWORD *lpSize)
382 FIXME(wnet, "(%p, %p, %p): stub\n", lpLocalName, lpUserName, lpSize);
383 return WN_NO_NETWORK;
386 /**************************************************************************
387 * WNetGetError [USER.519]
389 int WINAPI WNetGetError(LPWORD nError)
391 FIXME(wnet, "(%p): stub\n",nError);
392 return WN_NO_NETWORK;
395 /**************************************************************************
396 * WNetGetErrorText [USER.520]
398 int WINAPI WNetGetErrorText(WORD nError, LPSTR lpBuffer, LPWORD nBufferSize)
400 FIXME(wnet, "(%x,%p,%p): stub\n",nError,lpBuffer,nBufferSize);
401 return WN_NET_ERROR;
404 /**************************************************************************
405 * WNetRestoreConnection [USER.523]
407 int WINAPI WNetRestoreConnection(HWND16 hwndOwner,LPSTR lpszDevice)
409 FIXME(wnet, "(%04x,'%s'): stub\n",hwndOwner,lpszDevice);
410 return WN_NO_NETWORK;
413 /**************************************************************************
414 * WNetWriteJob [USER.524]
416 int WINAPI WNetWriteJob(HANDLE16 hJob,void *lpData,LPWORD lpcbData)
418 FIXME(wnet, "(%04x,%p,%p): stub\n",hJob,lpData,lpcbData);
419 return WN_NO_NETWORK;
422 /********************************************************************
423 * WNetConnectDialog [USER.525]
425 UINT16 WINAPI WNetConnectDialog(HWND16 hWndParent, WORD iType)
427 FIXME(wnet, "(%04x, %4X): stub\n", hWndParent, iType);
428 return WN_SUCCESS;
431 /**************************************************************************
432 * WNetDisconnectDialog [USER.526]
434 int WINAPI WNetDisconnectDialog(HWND16 hwndOwner, WORD iType)
436 FIXME(wnet, "(%04x,%x): stub\n",hwndOwner,iType);
437 return WN_NO_NETWORK;
440 /**************************************************************************
441 * WnetConnectionDialog [USER.527]
443 UINT16 WINAPI WNetConnectionDialog(HWND16 hWndParent, WORD iType)
445 FIXME(wnet, "(%04x, %4X): stub\n", hWndParent, iType);
446 return WN_SUCCESS;
451 /**************************************************************************
452 * WNetViewQueueDialog [USER.528]
454 int WINAPI WNetViewQueueDialog(HWND16 hwndOwner,LPSTR lpszQueue)
456 FIXME(wnet, "(%04x,'%s'): stub\n",hwndOwner,lpszQueue);
457 return WN_NO_NETWORK;
460 /**************************************************************************
461 * WNetPropertyDialog [USER.529]
463 int WINAPI WNetPropertyDialog(HWND16 hwndParent,WORD iButton,
464 WORD nPropSel,LPSTR lpszName,WORD nType)
466 FIXME(wnet, "(%04x,%x,%x,'%s',%x): stub\n",
467 hwndParent,iButton,nPropSel,lpszName,nType);
468 return WN_NO_NETWORK;
471 /*********************************************************************
472 * WNetGetDirectoryType [USER.530] Decides whether resource is local
474 * RETURNS
475 * on success, puts one of the following in *lpType:
476 * - WNDT_NETWORK on a network
477 * - WNDT_LOCAL local
479 int WINAPI WNetGetDirectoryType16(LPSTR lpName, LPINT16 lpType)
481 UINT32 type = GetDriveType32A(lpName);
483 if (type == DRIVE_DOESNOTEXIST)
484 type = GetDriveType32A(NULL);
485 *lpType = (type==DRIVE_REMOTE)?WNDT_NETWORK:WNDT_NORMAL;
486 TRACE(wnet,"%s is %s\n",lpName,(*lpType==WNDT_NETWORK)?
487 "WNDT_NETWORK":"WNDT_NORMAL");
488 return WN_SUCCESS;
491 /*****************************************************************
492 * WNetGetDirectoryTypeA [MPR.109]
495 UINT32 WINAPI WNetGetDirectoryType32A(LPSTR lpName,void *lpType)
497 return WNetGetDirectoryType16(lpName, lpType);
500 /**************************************************************************
501 * WNetDirectoryNotify [USER.531]
503 int WINAPI WNetDirectoryNotify(HWND16 hwndOwner,void *lpDir,WORD wOper)
505 FIXME(wnet, "(%04x,%p,%x): stub\n",hwndOwner,lpDir,wOper);
506 return WN_NO_NETWORK;
509 /**************************************************************************
510 * WNetGetPropertyText [USER.532]
512 int WINAPI WNetGetPropertyText(HWND16 hwndParent,WORD iButton,WORD nPropSel,
513 LPSTR lpszName,WORD nType)
515 FIXME(wnet, "(%04x,%x,%x,'%s',%x): stub\n",
516 hwndParent,iButton,nPropSel,lpszName,nType);
517 return WN_NO_NETWORK;
521 /**************************************************************************
522 * WNetCloseEnum [USER.???]
524 UINT16 WINAPI WNetCloseEnum(HANDLE16 hEnum)
526 FIXME(wnet, "(%04x): stub\n", hEnum);
527 return WN_NO_NETWORK;
530 /**************************************************************************
531 * WNetEnumResource [USER.???]
533 UINT16 WINAPI WNetEnumResource(HANDLE16 hEnum, DWORD cRequ,
534 DWORD *lpCount, LPVOID lpBuf)
536 FIXME(wnet, "(%04x, %08lX, %p, %p): stub\n",
537 hEnum, cRequ, lpCount, lpBuf);
538 return WN_NO_NETWORK;
541 /**************************************************************************
542 * WNetOpenEnum [USER.???]
544 UINT16 WINAPI WNetOpenEnum16(DWORD dwScope, DWORD dwType,
545 LPNETRESOURCE16 lpNet, HANDLE16 *lphEnum)
547 FIXME(wnet, "(%08lX, %08lX, %p, %p): stub\n",
548 dwScope, dwType, lpNet, lphEnum);
549 return WN_NO_NETWORK;
552 /**************************************************************************
553 * WNetOpenEnumA [MPR.92]
555 UINT32 WINAPI WNetOpenEnum32A(DWORD dwScope, DWORD dwType,
556 LPNETRESOURCE32A lpNet, HANDLE32 *lphEnum)
558 FIXME(wnet, "(%08lX, %08lX, %p, %p): stub\n",
559 dwScope, dwType, lpNet, lphEnum);
560 return WN_NO_NETWORK;
563 /* ****************************************************************
564 * WNetGetResourceInformationA [MPR.80]
565 * */
567 DWORD WINAPI
568 WNetGetResourceInformation32A(
569 LPNETRESOURCE32A netres,LPVOID buf,LPDWORD buflen,LPSTR systemstr
571 FIXME(wnet,"(%p,%p,%p,%p): stub!\n",netres,buf,buflen,systemstr);
572 return WN_NO_NETWORK;
575 /**************************************************************************
576 * WNetCachePassword [MPR.52] Saves password in cache
578 * RETURNS
579 * Success: WN_SUCCESS
580 * Failure: WNACCESS_DENIED, WN_BAD_PASSWORD, WN_BADVALUE, WN_NET_ERROR,
581 * WN_NOT_SUPPORTED, WN_OUT_OF_MEMORY
583 DWORD WINAPI WNetCachePassword(
584 LPSTR pbResource, /* [in] Name of workgroup, computer, or resource */
585 WORD cbResource, /* [in] Size of name */
586 LPSTR pbPassword, /* [in] Buffer containing password */
587 WORD cbPassword, /* [in] Size of password */
588 BYTE nType) /* [in] Type of password to cache */
590 FIXME(mpr,"(%s,%d,%s,%d,%d): stub\n", pbResource,cbResource,
591 pbPassword,cbPassword,nType);
592 return WN_SUCCESS;
597 /*****************************************************************
598 * WNetGetCachedPassword [MPR.69] Retrieves password from cache
600 * RETURNS
601 * Success: WN_SUCCESS
602 * Failure: WNACCESS_DENIED, WN_BAD_PASSWORD, WN_BAD_VALUE,
603 * WN_NET_ERROR, WN_NOT_SUPPORTED, WN_OUT_OF_MEMORY
605 DWORD WINAPI WNetGetCachedPassword(
606 LPSTR pbResource, /* [in] Name of workgroup, computer, or resource */
607 WORD cbResource, /* [in] Size of name */
608 LPSTR pbPassword, /* [out] Buffer to receive password */
609 LPWORD pcbPassword, /* [out] Receives size of password */
610 BYTE nType) /* [in] Type of password to retrieve */
612 FIXME(mpr,"(%s,%d,%p,%d,%d): stub\n",
613 pbResource,cbResource,pbPassword,*pcbPassword,nType);
614 return WN_ACCESS_DENIED;
617 /* ****************************************************************
618 * MultinetGetConnectionPerformanceA [MPR.25]
620 * RETURNS
621 * Success: NO_ERROR
622 * Failure: ERROR_NOT_SUPPORTED, ERROR_NOT_CONNECTED,
623 * ERROR_NO_NET_OR_BAD_PATH, ERROR_BAD_DEVICE,
624 * ERROR_BAD_NET_NAME, ERROR_INVALID_PARAMETER,
625 * ERROR_NO_NETWORK, ERROR_EXTENDED_ERROR
627 DWORD WINAPI MultinetGetConnectionPerformance32A(
628 LPNETRESOURCE32A lpNetResource,
629 LPNETCONNECTINFOSTRUCT lpNetConnectInfoStruct
631 FIXME(mpr,"(%p,%p): stub\n",lpNetResource,lpNetConnectInfoStruct);
632 return 1;