Avoid going past the end of the relocation section. Skip sanity checks
[wine/multimedia.git] / dlls / mpr / wnet.c
blob66c534ccbbb15ed608e918de4a621d5441f4694c
1 /*
2 * MPR WNet functions
3 */
5 #include <ctype.h>
6 #include <string.h>
7 #include <sys/types.h>
8 #include <pwd.h>
9 #include <unistd.h>
11 #include "winbase.h"
12 #include "winnetwk.h"
13 #include "drive.h"
14 #include "heap.h"
15 #include "debugtools.h"
17 DEFAULT_DEBUG_CHANNEL(mpr)
21 * Browsing Functions
24 /*********************************************************************
25 * WNetOpenEnumA [MPR.92]
27 DWORD WINAPI WNetOpenEnumA( DWORD dwScope, DWORD dwType, DWORD dwUsage,
28 LPNETRESOURCEA lpNet, LPHANDLE lphEnum )
30 FIXME( "(%08lX, %08lX, %08lX, %p, %p): stub\n",
31 dwScope, dwType, dwUsage, lpNet, lphEnum );
33 SetLastError(WN_NO_NETWORK);
34 return WN_NO_NETWORK;
37 /*********************************************************************
38 * WNetOpenEnumW [MPR.93]
40 DWORD WINAPI WNetOpenEnumW( DWORD dwScope, DWORD dwType, DWORD dwUsage,
41 LPNETRESOURCEW lpNet, LPHANDLE lphEnum )
43 FIXME( "(%08lX, %08lX, %08lX, %p, %p): stub\n",
44 dwScope, dwType, dwUsage, lpNet, lphEnum );
46 SetLastError(WN_NO_NETWORK);
47 return WN_NO_NETWORK;
50 /*********************************************************************
51 * WNetEnumResourceA [MPR.66]
53 DWORD WINAPI WNetEnumResourceA( HANDLE hEnum, LPDWORD lpcCount,
54 LPVOID lpBuffer, LPDWORD lpBufferSize )
56 FIXME( "(%04X, %p, %p, %p): stub\n",
57 hEnum, lpcCount, lpBuffer, lpBufferSize );
59 SetLastError(WN_NO_NETWORK);
60 return WN_NO_NETWORK;
63 /*********************************************************************
64 * WNetEnumResourceW [MPR.67]
66 DWORD WINAPI WNetEnumResourceW( HANDLE hEnum, LPDWORD lpcCount,
67 LPVOID lpBuffer, LPDWORD lpBufferSize )
69 FIXME( "(%04X, %p, %p, %p): stub\n",
70 hEnum, lpcCount, lpBuffer, lpBufferSize );
72 SetLastError(WN_NO_NETWORK);
73 return WN_NO_NETWORK;
76 /*********************************************************************
77 * WNetCloseEnum [MPR.58]
79 DWORD WINAPI WNetCloseEnum( HANDLE hEnum )
81 FIXME( "(%04X): stub\n", hEnum );
83 SetLastError(WN_NO_NETWORK);
84 return WN_NO_NETWORK;
87 /*********************************************************************
88 * WNetGetResourceInformationA [MPR.80]
90 DWORD WINAPI WNetGetResourceInformationA( LPNETRESOURCEA lpNetResource,
91 LPVOID lpBuffer, LPDWORD cbBuffer,
92 LPSTR *lplpSystem )
94 FIXME( "(%p, %p, %p, %p): stub\n",
95 lpNetResource, lpBuffer, cbBuffer, lplpSystem );
97 SetLastError(WN_NO_NETWORK);
98 return WN_NO_NETWORK;
101 /*********************************************************************
102 * WNetGetResourceInformationW [MPR.80]
104 DWORD WINAPI WNetGetResourceInformationW( LPNETRESOURCEW lpNetResource,
105 LPVOID lpBuffer, LPDWORD cbBuffer,
106 LPWSTR *lplpSystem )
108 FIXME( "(%p, %p, %p, %p): stub\n",
109 lpNetResource, lpBuffer, cbBuffer, lplpSystem );
111 SetLastError(WN_NO_NETWORK);
112 return WN_NO_NETWORK;
115 /*********************************************************************
116 * WNetGetResourceParentA [MPR.83]
118 DWORD WINAPI WNetGetResourceParentA( LPNETRESOURCEA lpNetResource,
119 LPVOID lpBuffer, LPDWORD lpBufferSize )
121 FIXME( "(%p, %p, %p): stub\n",
122 lpNetResource, lpBuffer, lpBufferSize );
124 SetLastError(WN_NO_NETWORK);
125 return WN_NO_NETWORK;
128 /*********************************************************************
129 * WNetGetResourceParentW [MPR.84]
131 DWORD WINAPI WNetGetResourceParentW( LPNETRESOURCEW lpNetResource,
132 LPVOID lpBuffer, LPDWORD lpBufferSize )
134 FIXME( "(%p, %p, %p): stub\n",
135 lpNetResource, lpBuffer, lpBufferSize );
137 SetLastError(WN_NO_NETWORK);
138 return WN_NO_NETWORK;
144 * Connection Functions
147 /*********************************************************************
148 * WNetAddConnectionA [MPR.50]
150 DWORD WINAPI WNetAddConnectionA( LPCSTR lpRemoteName, LPCSTR lpPassword,
151 LPCSTR lpLocalName )
153 FIXME( "(%s, %p, %s): stub\n",
154 debugstr_a(lpRemoteName), lpPassword, debugstr_a(lpLocalName) );
156 SetLastError(WN_NO_NETWORK);
157 return WN_NO_NETWORK;
160 /*********************************************************************
161 * WNetAddConnectionW [MPR.51]
163 DWORD WINAPI WNetAddConnectionW( LPCWSTR lpRemoteName, LPCWSTR lpPassword,
164 LPCWSTR lpLocalName )
166 FIXME( "(%s, %p, %s): stub\n",
167 debugstr_w(lpRemoteName), lpPassword, debugstr_w(lpLocalName) );
169 SetLastError(WN_NO_NETWORK);
170 return WN_NO_NETWORK;
173 /*********************************************************************
174 * WNetAddConnection2A [MPR.46]
176 DWORD WINAPI WNetAddConnection2A( LPNETRESOURCEA lpNetResource,
177 LPCSTR lpPassword, LPCSTR lpUserID,
178 DWORD dwFlags )
180 FIXME( "(%p, %p, %s, 0x%08lX): stub\n",
181 lpNetResource, lpPassword, debugstr_a(lpUserID), dwFlags );
183 SetLastError(WN_NO_NETWORK);
184 return WN_NO_NETWORK;
187 /*********************************************************************
188 * WNetAddConnection2W [MPR.47]
190 DWORD WINAPI WNetAddConnection2W( LPNETRESOURCEW lpNetResource,
191 LPCWSTR lpPassword, LPCWSTR lpUserID,
192 DWORD dwFlags )
194 FIXME( "(%p, %p, %s, 0x%08lX): stub\n",
195 lpNetResource, lpPassword, debugstr_w(lpUserID), dwFlags );
197 SetLastError(WN_NO_NETWORK);
198 return WN_NO_NETWORK;
201 /*********************************************************************
202 * WNetAddConnection3A [MPR.48]
204 DWORD WINAPI WNetAddConnection3A( HWND hwndOwner, LPNETRESOURCEA lpNetResource,
205 LPCSTR lpPassword, LPCSTR lpUserID,
206 DWORD dwFlags )
208 FIXME( "(%04x, %p, %p, %s, 0x%08lX), stub\n",
209 hwndOwner, lpNetResource, lpPassword, debugstr_a(lpUserID), dwFlags );
211 SetLastError(WN_NO_NETWORK);
212 return WN_NO_NETWORK;
215 /*********************************************************************
216 * WNetAddConnection3W [MPR.49]
218 DWORD WINAPI WNetAddConnection3W( HWND hwndOwner, LPNETRESOURCEW lpNetResource,
219 LPCWSTR lpPassword, LPCWSTR lpUserID,
220 DWORD dwFlags )
222 FIXME( "(%04x, %p, %p, %s, 0x%08lX), stub\n",
223 hwndOwner, lpNetResource, lpPassword, debugstr_w(lpUserID), dwFlags );
225 SetLastError(WN_NO_NETWORK);
226 return WN_NO_NETWORK;
229 /*****************************************************************
230 * WNetUseConnectionA [MPR.100]
232 DWORD WINAPI WNetUseConnectionA( HWND hwndOwner, LPNETRESOURCEA lpNetResource,
233 LPCSTR lpPassword, LPCSTR lpUserID, DWORD dwFlags,
234 LPSTR lpAccessName, LPDWORD lpBufferSize,
235 LPDWORD lpResult )
237 FIXME( "(%04x, %p, %p, %s, 0x%08lX, %s, %p, %p), stub\n",
238 hwndOwner, lpNetResource, lpPassword, debugstr_a(lpUserID), dwFlags,
239 debugstr_a(lpAccessName), lpBufferSize, lpResult );
241 SetLastError(WN_NO_NETWORK);
242 return WN_NO_NETWORK;
245 /*****************************************************************
246 * WNetUseConnectionW [MPR.101]
248 DWORD WINAPI WNetUseConnectionW( HWND hwndOwner, LPNETRESOURCEW lpNetResource,
249 LPCWSTR lpPassword, LPCWSTR lpUserID, DWORD dwFlags,
250 LPWSTR lpAccessName, LPDWORD lpBufferSize,
251 LPDWORD lpResult )
253 FIXME( "(%04x, %p, %p, %s, 0x%08lX, %s, %p, %p), stub\n",
254 hwndOwner, lpNetResource, lpPassword, debugstr_w(lpUserID), dwFlags,
255 debugstr_w(lpAccessName), lpBufferSize, lpResult );
257 SetLastError(WN_NO_NETWORK);
258 return WN_NO_NETWORK;
261 /*********************************************************************
262 * WNetCancelConnectionA [MPR.55]
264 DWORD WINAPI WNetCancelConnectionA( LPCSTR lpName, BOOL fForce )
266 FIXME( "(%s, %d), stub\n", debugstr_a(lpName), fForce );
268 return WN_SUCCESS;
271 /*********************************************************************
272 * WNetCancelConnectionW [MPR.56]
274 DWORD WINAPI WNetCancelConnectionW( LPCWSTR lpName, BOOL fForce )
276 FIXME( "(%s, %d), stub\n", debugstr_w(lpName), fForce );
278 return WN_SUCCESS;
281 /*********************************************************************
282 * WNetCancelConnection2A [MPR.53]
284 DWORD WINAPI WNetCancelConnection2A( LPCSTR lpName, DWORD dwFlags, BOOL fForce )
286 FIXME( "(%s, %08lX, %d), stub\n", debugstr_a(lpName), dwFlags, fForce );
288 return WN_SUCCESS;
291 /*********************************************************************
292 * WNetCancelConnection2W [MPR.54]
294 DWORD WINAPI WNetCancelConnection2W( LPCWSTR lpName, DWORD dwFlags, BOOL fForce )
296 FIXME( "(%s, %08lX, %d), stub\n", debugstr_w(lpName), dwFlags, fForce );
298 return WN_SUCCESS;
301 /*****************************************************************
302 * WNetRestoreConnectionA [MPR.96]
304 DWORD WINAPI WNetRestoreConnectionA( HWND hwndOwner, LPSTR lpszDevice )
306 FIXME( "(%04X, %s), stub\n", hwndOwner, debugstr_a(lpszDevice) );
308 SetLastError(WN_NO_NETWORK);
309 return WN_NO_NETWORK;
312 /*****************************************************************
313 * WNetRestoreConnectionW [MPR.97]
315 DWORD WINAPI WNetRestoreConnectionW( HWND hwndOwner, LPWSTR lpszDevice )
317 FIXME( "(%04X, %s), stub\n", hwndOwner, debugstr_w(lpszDevice) );
319 SetLastError(WN_NO_NETWORK);
320 return WN_NO_NETWORK;
323 /**************************************************************************
324 * WNetGetConnectionA [MPR.71]
326 * RETURNS
327 * - WN_BAD_LOCALNAME lpLocalName makes no sense
328 * - WN_NOT_CONNECTED drive is a local drive
329 * - WN_MORE_DATA buffer isn't big enough
330 * - WN_SUCCESS success (net path in buffer)
333 DWORD WINAPI WNetGetConnectionA( LPCSTR lpLocalName,
334 LPSTR lpRemoteName, LPDWORD lpBufferSize )
336 const char *path;
338 TRACE( "local %s\n", lpLocalName );
339 if (lpLocalName[1] == ':')
341 int drive = toupper(lpLocalName[0]) - 'A';
342 switch(DRIVE_GetType(drive))
344 case TYPE_INVALID:
345 return WN_BAD_LOCALNAME;
346 case TYPE_NETWORK:
347 path = DRIVE_GetLabel(drive);
348 if (strlen(path) + 1 > *lpBufferSize)
350 *lpBufferSize = strlen(path) + 1;
351 return WN_MORE_DATA;
353 strcpy( lpRemoteName, path );
354 *lpBufferSize = strlen(lpRemoteName) + 1;
355 return WN_SUCCESS;
356 case TYPE_FLOPPY:
357 case TYPE_HD:
358 case TYPE_CDROM:
359 TRACE("file is local\n");
360 return WN_NOT_CONNECTED;
361 default:
362 return WN_BAD_LOCALNAME;
365 return WN_BAD_LOCALNAME;
368 /**************************************************************************
369 * WNetGetConnectionW [MPR.72]
371 DWORD WINAPI WNetGetConnectionW( LPCWSTR lpLocalName,
372 LPWSTR lpRemoteName, LPDWORD lpBufferSize )
374 DWORD x;
375 CHAR buf[200];
376 LPSTR lnA = HEAP_strdupWtoA( GetProcessHeap(), 0, lpLocalName );
377 DWORD ret = WNetGetConnectionA( lnA, buf, &x );
379 lstrcpyAtoW( lpRemoteName, buf );
380 *lpBufferSize=lstrlenW( lpRemoteName );
381 HeapFree( GetProcessHeap(), 0, lnA );
382 return ret;
385 /**************************************************************************
386 * WNetSetConnectionA [MPR.72]
388 DWORD WINAPI WNetSetConnectionA( LPCSTR lpName, DWORD dwProperty,
389 LPVOID pvValue )
391 FIXME( "(%s, %08lX, %p): stub\n", debugstr_a(lpName), dwProperty, pvValue );
393 SetLastError(WN_NO_NETWORK);
394 return WN_NO_NETWORK;
397 /**************************************************************************
398 * WNetSetConnectionW [MPR.72]
400 DWORD WINAPI WNetSetConnectionW( LPCWSTR lpName, DWORD dwProperty,
401 LPVOID pvValue )
403 FIXME( "(%s, %08lX, %p): stub\n", debugstr_w(lpName), dwProperty, pvValue );
405 SetLastError(WN_NO_NETWORK);
406 return WN_NO_NETWORK;
409 /*****************************************************************
410 * WNetGetUniversalNameA [MPR.85]
412 DWORD WINAPI WNetGetUniversalNameA ( LPCSTR lpLocalPath, DWORD dwInfoLevel,
413 LPVOID lpBuffer, LPDWORD lpBufferSize )
415 FIXME( "(%s, 0x%08lX, %p, %p): stub\n",
416 debugstr_a(lpLocalPath), dwInfoLevel, lpBuffer, lpBufferSize);
418 SetLastError(WN_NO_NETWORK);
419 return WN_NO_NETWORK;
422 /*****************************************************************
423 * WNetGetUniversalNameW [MPR.86]
425 DWORD WINAPI WNetGetUniversalNameW ( LPCWSTR lpLocalPath, DWORD dwInfoLevel,
426 LPVOID lpBuffer, LPDWORD lpBufferSize )
428 FIXME( "(%s, 0x%08lX, %p, %p): stub\n",
429 debugstr_w(lpLocalPath), dwInfoLevel, lpBuffer, lpBufferSize);
431 SetLastError(WN_NO_NETWORK);
432 return WN_NO_NETWORK;
438 * Other Functions
441 /**************************************************************************
442 * WNetGetUserA [MPR.86]
444 * FIXME: we should not return ourselves, but the owner of the drive lpName
446 DWORD WINAPI WNetGetUserA( LPCSTR lpName, LPSTR lpUserID, LPDWORD lpBufferSize )
448 struct passwd *pwd = getpwuid(getuid());
450 FIXME( "(%s, %p, %p): mostly stub\n",
451 debugstr_a(lpName), lpUserID, lpBufferSize );
453 if (pwd)
455 if ( strlen(pwd->pw_name) + 1 > *lpBufferSize )
457 *lpBufferSize = strlen(pwd->pw_name) + 1;
459 SetLastError(ERROR_MORE_DATA);
460 return ERROR_MORE_DATA;
463 strcpy( lpUserID, pwd->pw_name );
464 *lpBufferSize = strlen(pwd->pw_name) + 1;
465 return WN_SUCCESS;
468 /* FIXME: wrong return value */
469 SetLastError(ERROR_NO_NETWORK);
470 return ERROR_NO_NETWORK;
473 /*****************************************************************
474 * WNetGetUserW [MPR.87]
476 DWORD WINAPI WNetGetUserW( LPCWSTR lpName, LPWSTR lpUserID, LPDWORD lpBufferSize )
478 FIXME( "(%s, %p, %p): mostly stub\n",
479 debugstr_w(lpName), lpUserID, lpBufferSize );
481 SetLastError(WN_NO_NETWORK);
482 return WN_NO_NETWORK;
485 /*********************************************************************
486 * WNetConnectionDialog [MPR.61]
488 DWORD WINAPI WNetConnectionDialog( HWND hwnd, DWORD dwType )
490 FIXME( "(%04x, %08lX): stub\n", hwnd, dwType );
492 SetLastError(WN_NO_NETWORK);
493 return ERROR_NO_NETWORK;
496 /*********************************************************************
497 * WNetConnectionDialog1A [MPR.59]
499 DWORD WINAPI WNetConnectionDialog1A( LPCONNECTDLGSTRUCTA lpConnDlgStruct )
501 FIXME( "(%p): stub\n", lpConnDlgStruct );
503 SetLastError(WN_NO_NETWORK);
504 return ERROR_NO_NETWORK;
507 /*********************************************************************
508 * WNetConnectionDialog1W [MPR.60]
510 DWORD WINAPI WNetConnectionDialog1W( LPCONNECTDLGSTRUCTW lpConnDlgStruct )
512 FIXME( "(%p): stub\n", lpConnDlgStruct );
514 SetLastError(WN_NO_NETWORK);
515 return ERROR_NO_NETWORK;
518 /*********************************************************************
519 * WNetDisconnectDialog [MPR.64]
521 DWORD WINAPI WNetDisconnectDialog( HWND hwnd, DWORD dwType )
523 FIXME( "(%04x, %08lX): stub\n", hwnd, dwType );
525 SetLastError(WN_NO_NETWORK);
526 return ERROR_NO_NETWORK;
529 /*********************************************************************
530 * WNetDisconnectDialog1A [MPR.62]
532 DWORD WINAPI WNetDisconnectDialog1A( LPDISCDLGSTRUCTA lpConnDlgStruct )
534 FIXME( "(%p): stub\n", lpConnDlgStruct );
536 SetLastError(WN_NO_NETWORK);
537 return ERROR_NO_NETWORK;
540 /*********************************************************************
541 * WNetDisconnectDialog1W [MPR.63]
543 DWORD WINAPI WNetDisconnectDialog1W( LPDISCDLGSTRUCTW lpConnDlgStruct )
545 FIXME( "(%p): stub\n", lpConnDlgStruct );
547 SetLastError(WN_NO_NETWORK);
548 return ERROR_NO_NETWORK;
551 /*********************************************************************
552 * WNetGetLastErrorA [MPR.75]
554 DWORD WINAPI WNetGetLastErrorA( LPDWORD lpError,
555 LPSTR lpErrorBuf, DWORD nErrorBufSize,
556 LPSTR lpNameBuf, DWORD nNameBufSize )
558 FIXME( "(%p, %p, %ld, %p, %ld): stub\n",
559 lpError, lpErrorBuf, nErrorBufSize, lpNameBuf, nNameBufSize );
561 SetLastError(WN_NO_NETWORK);
562 return ERROR_NO_NETWORK;
565 /*********************************************************************
566 * WNetGetLastErrorW [MPR.76]
568 DWORD WINAPI WNetGetLastErrorW( LPDWORD lpError,
569 LPWSTR lpErrorBuf, DWORD nErrorBufSize,
570 LPWSTR lpNameBuf, DWORD nNameBufSize )
572 FIXME( "(%p, %p, %ld, %p, %ld): stub\n",
573 lpError, lpErrorBuf, nErrorBufSize, lpNameBuf, nNameBufSize );
575 SetLastError(WN_NO_NETWORK);
576 return ERROR_NO_NETWORK;
579 /*********************************************************************
580 * WNetGetNetworkInformationA [MPR.77]
582 DWORD WINAPI WNetGetNetworkInformationA( LPCSTR lpProvider,
583 LPNETINFOSTRUCT lpNetInfoStruct )
585 FIXME( "(%s, %p): stub\n", debugstr_a(lpProvider), lpNetInfoStruct );
587 SetLastError(WN_NO_NETWORK);
588 return ERROR_NO_NETWORK;
591 /*********************************************************************
592 * WNetGetNetworkInformationW [MPR.77]
594 DWORD WINAPI WNetGetNetworkInformationW( LPCWSTR lpProvider,
595 LPNETINFOSTRUCT lpNetInfoStruct )
597 FIXME( "(%s, %p): stub\n", debugstr_w(lpProvider), lpNetInfoStruct );
599 SetLastError(WN_NO_NETWORK);
600 return ERROR_NO_NETWORK;
603 /*****************************************************************
604 * WNetGetProviderNameA [MPR.79]
606 DWORD WINAPI WNetGetProviderNameA( DWORD dwNetType,
607 LPSTR lpProvider, LPDWORD lpBufferSize )
609 FIXME( "(%ld, %p, %p): stub\n", dwNetType, lpProvider, lpBufferSize );
611 SetLastError(WN_NO_NETWORK);
612 return WN_NO_NETWORK;
615 /*****************************************************************
616 * WNetGetProviderNameW [MPR.80]
618 DWORD WINAPI WNetGetProviderNameW( DWORD dwNetType,
619 LPWSTR lpProvider, LPDWORD lpBufferSize )
621 FIXME( "(%ld, %p, %p): stub\n", dwNetType, lpProvider, lpBufferSize );
623 SetLastError(WN_NO_NETWORK);
624 return WN_NO_NETWORK;