Added an unknown VxD error code.
[wine] / dlls / user / network.c
1 /*
2  * USER Windows Network functions
3  */
4
5 #include <ctype.h>
6 #include <string.h>
7 #include <sys/types.h>
8 #include <pwd.h>
9 #include <unistd.h>
10
11 #include "winbase.h"
12 #include "wine/winnet16.h"
13 #include "winnetwk.h"
14 #include "debugtools.h"
15 #include "heap.h"
16
17 DEFAULT_DEBUG_CHANNEL(wnet);
18
19 /*
20  * Remote printing 
21  */
22
23 /**************************************************************************
24  *              WNetOpenJob16       [USER.501]
25  */
26 WORD WINAPI WNetOpenJob16( LPSTR szQueue, LPSTR szJobTitle, WORD nCopies, LPINT16 pfh )
27 {
28     FIXME( "(%s, %s, %d, %p): stub\n",
29            debugstr_a(szQueue), debugstr_a(szJobTitle), nCopies, pfh );
30     return WN16_NET_ERROR;
31 }
32
33 /**************************************************************************
34  *              WNetCloseJob16      [USER.502]
35  */
36 WORD WINAPI WNetCloseJob16( WORD fh, LPINT16 pidJob, LPSTR szQueue )
37 {
38     FIXME( "(%d, %p, %s): stub\n", fh, pidJob, debugstr_a(szQueue) );
39     return WN16_NET_ERROR;
40 }
41
42 /**************************************************************************
43  *              WNetWriteJob16      [USER.524]
44  */
45 WORD WINAPI WNetWriteJob16( HANDLE16 hJob, LPSTR lpData, LPINT16 lpcbData )
46 {
47     FIXME( "(%04x, %p, %p): stub\n", hJob, lpData, lpcbData );
48     return WN16_NET_ERROR;
49 }
50
51 /**************************************************************************
52  *              WNetAbortJob16       [USER.503]
53  */
54 WORD WINAPI WNetAbortJob16( LPSTR szQueue, WORD wJobId )
55 {
56     FIXME( "(%s, %d): stub\n", debugstr_a(szQueue), wJobId );
57     return WN16_NET_ERROR;
58 }
59
60 /**************************************************************************
61  *              WNetHoldJob16       [USER.504]
62  */
63 WORD WINAPI WNetHoldJob16( LPSTR szQueue, WORD wJobId )
64 {
65     FIXME( "(%s, %d): stub\n", debugstr_a(szQueue), wJobId );
66     return WN16_NET_ERROR;
67 }
68
69 /**************************************************************************
70  *              WNetReleaseJob16       [USER.505]
71  */
72 WORD WINAPI WNetReleaseJob16( LPSTR szQueue, WORD wJobId )
73 {
74     FIXME( "(%s, %d): stub\n", debugstr_a(szQueue), wJobId );
75     return WN16_NET_ERROR;
76 }
77
78 /**************************************************************************
79  *              WNetCancelJob16       [USER.506]
80  */
81 WORD WINAPI WNetCancelJob16( LPSTR szQueue, WORD wJobId )
82 {
83     FIXME( "(%s, %d): stub\n", debugstr_a(szQueue), wJobId );
84     return WN16_NET_ERROR;
85 }
86
87 /**************************************************************************
88  *              WNetSetJobCopies16     [USER.507]
89  */
90 WORD WINAPI WNetSetJobCopies16( LPSTR szQueue, WORD wJobId, WORD nCopies )
91 {
92     FIXME( "(%s, %d, %d): stub\n", debugstr_a(szQueue), wJobId, nCopies );
93     return WN16_NET_ERROR;
94 }
95
96 /**************************************************************************
97  *              WNetWatchQueue16       [USER.508]
98  */
99 WORD WINAPI WNetWatchQueue16( HWND16 hWnd, LPSTR szLocal, LPSTR szUser, WORD nQueue )
100 {
101     FIXME( "(%04x, %s, %s, %d): stub\n", 
102            hWnd, debugstr_a(szLocal), debugstr_a(szUser), nQueue );
103     return WN16_NET_ERROR;
104 }
105
106 /**************************************************************************
107  *              WNetUnwatchQueue16     [USER.509]
108  */
109 WORD WINAPI WNetUnwatchQueue16( LPSTR szQueue )
110 {
111     FIXME( "(%s): stub\n", debugstr_a(szQueue) );
112     return WN16_NET_ERROR;
113 }
114
115 /**************************************************************************
116  *              WNetLockQueueData16       [USER.510]
117  */
118 WORD WINAPI WNetLockQueueData16( LPSTR szQueue, LPSTR szUser, 
119                                  LPQUEUESTRUCT16 *lplpQueueStruct )
120 {
121     FIXME( "(%s, %s, %p): stub\n", 
122            debugstr_a(szQueue), debugstr_a(szUser), lplpQueueStruct );
123     return WN16_NET_ERROR;
124 }
125
126 /**************************************************************************
127  *              WNetUnlockQueueData16       [USER.511]
128  */
129 WORD WINAPI WNetUnlockQueueData16( LPSTR szQueue )
130 {
131     FIXME( "(%s): stub\n", debugstr_a(szQueue) );
132     return WN16_NET_ERROR;
133 }
134
135
136 /*
137  * Connections
138  */
139
140 /********************************************************************
141  *  WNetAddConnection16 [USER.517]  Directs a local device to net
142  * 
143  * Redirects a local device (either a disk drive or printer port)
144  * to a shared device on a remote server.
145  */
146 WORD WINAPI WNetAddConnection16( LPSTR lpNetPath, LPSTR lpPassWord,
147                                  LPSTR lpLocalName )
148 {       
149     FIXME( "(%s, %p, %s): stub\n", 
150            debugstr_a(lpNetPath), lpPassWord, debugstr_a(lpLocalName) );
151     return WN16_NET_ERROR;
152 }
153
154 /********************************************************************
155  *   WNetCancelConnection16 [USER.518]  undirects a local device
156  */
157 WORD WINAPI WNetCancelConnection16( LPSTR lpName, BOOL16 bForce )
158 {
159     FIXME( "(%s, %04X): stub\n", debugstr_a(lpName), bForce);
160     return WN16_NOT_SUPPORTED;
161 }
162
163 /********************************************************************
164  * WNetGetConnection16 [USER.512] reverse-resolves a local device
165  */
166 WORD WINAPI WNetGetConnection16( LPSTR lpLocalName, 
167                                  LPSTR lpRemoteName, UINT16 *cbRemoteName )
168 {
169     char label[32];
170
171     TRACE( "local %s\n", lpLocalName );
172     switch(GetDriveTypeA(lpLocalName))
173     {
174     case DRIVE_REMOTE:
175         GetVolumeInformationA( lpLocalName, label, sizeof(label), NULL, NULL, NULL, NULL, 0 );
176         if (strlen(label) + 1 > *cbRemoteName)
177         {
178             *cbRemoteName = strlen(label) + 1;
179             return WN16_MORE_DATA;
180         }
181         strcpy( lpRemoteName, label );
182         *cbRemoteName = strlen(lpRemoteName) + 1;
183         return WN16_SUCCESS;
184     case DRIVE_REMOVABLE:
185     case DRIVE_FIXED:
186     case DRIVE_CDROM:
187         TRACE("file is local\n");
188         return WN16_NOT_CONNECTED;
189     default:
190         return WN16_BAD_LOCALNAME;
191     }
192 }
193
194 /**************************************************************************
195  *              WNetRestoreConnection16       [USER.523]
196  */
197 WORD WINAPI WNetRestoreConnection16( HWND16 hwndOwner, LPSTR lpszDevice )
198 {
199     FIXME( "(%04x, %s): stub\n", hwndOwner, debugstr_a(lpszDevice) );
200     return WN16_NOT_SUPPORTED;
201 }
202
203
204 /*
205  * Capabilities
206  */
207
208 /**************************************************************************
209  *              WNetGetCaps16           [USER.513]
210  */
211 WORD WINAPI WNetGetCaps16( WORD capability )
212 {
213     switch (capability) 
214     {
215     case WNNC16_SPEC_VERSION:
216         return 0x30a; /* WfW 3.11 (and apparently other 3.1x) */
217
218     case WNNC16_NET_TYPE:
219         /* hi byte = network type, 
220            lo byte = network vendor (Netware = 0x03) [15 types] */
221         return WNNC16_NET_MultiNet | WNNC16_SUBNET_WinWorkgroups;
222
223     case WNNC16_DRIVER_VERSION:
224         /* driver version of vendor */
225         return 0x100; /* WfW 3.11 */
226
227     case WNNC16_USER:
228         /* 1 = WNetGetUser is supported */
229         return 1;
230
231     case WNNC16_CONNECTION:
232         /* returns mask of the supported connection functions */
233         return   WNNC16_CON_AddConnection | WNNC16_CON_CancelConnection
234                | WNNC16_CON_GetConnections /* | WNNC16_CON_AutoConnect */
235                | WNNC16_CON_BrowseDialog | WNNC16_CON_RestoreConnection;
236
237     case WNNC16_PRINTING:
238         /* returns mask of the supported printing functions */
239         return   WNNC16_PRT_OpenJob | WNNC16_PRT_CloseJob | WNNC16_PRT_HoldJob
240                | WNNC16_PRT_ReleaseJob | WNNC16_PRT_CancelJob
241                | WNNC16_PRT_SetJobCopies | WNNC16_PRT_WatchQueue
242                | WNNC16_PRT_UnwatchQueue | WNNC16_PRT_LockQueueData
243                | WNNC16_PRT_UnlockQueueData | WNNC16_PRT_AbortJob
244                | WNNC16_PRT_WriteJob;
245
246     case WNNC16_DIALOG:
247         /* returns mask of the supported dialog functions */
248         return   WNNC16_DLG_DeviceMode | WNNC16_DLG_BrowseDialog
249                | WNNC16_DLG_ConnectDialog | WNNC16_DLG_DisconnectDialog
250                | WNNC16_DLG_ViewQueueDialog | WNNC16_DLG_PropertyDialog
251                | WNNC16_DLG_ConnectionDialog
252             /* | WNNC16_DLG_PrinterConnectDialog
253                | WNNC16_DLG_SharesDialog | WNNC16_DLG_ShareAsDialog */;
254
255     case WNNC16_ADMIN:
256         /* returns mask of the supported administration functions */
257         /* not sure if long file names is a good idea */
258         return   WNNC16_ADM_GetDirectoryType
259             /* | WNNC16_ADM_DirectoryNotify */ /*not yet supported*/
260                | WNNC16_ADM_LongNames /* | WNNC16_ADM_SetDefaultDrive */;
261
262     case WNNC16_ERROR:
263         /* returns mask of the supported error functions */
264         return   WNNC16_ERR_GetError | WNNC16_ERR_GetErrorText;
265
266     case WNNC16_PRINTMGREXT:
267         /* returns the Print Manager version in major and 
268            minor format if Print Manager functions are available */
269         return 0x30e; /* printman version of WfW 3.11 */
270
271     case 0xffff:
272         /* Win 3.11 returns HMODULE of network driver here
273            FIXME: what should we return ?
274            logonoff.exe needs it, msmail crashes with wrong value */
275         return 0;
276
277     default:
278         return 0;
279     }
280 }
281
282
283 /*
284  * Get User
285  */
286
287 /**************************************************************************
288  *              WNetGetUser16                   [USER.516]
289  */
290 WORD WINAPI WNetGetUser16( LPCSTR lpName, LPSTR szUser, LPINT16 nBufferSize )
291 {
292     FIXME( "(%p, %p, %p): stub\n", lpName, szUser, nBufferSize );
293     return WN16_NOT_SUPPORTED;
294 }
295
296
297 /*
298  * Browsing
299  */
300
301 /**************************************************************************
302  *              WNetDeviceMode16       [USER.514]
303  */
304 WORD WINAPI WNetDeviceMode16( HWND16 hWndOwner )
305 {
306     FIXME( "(%04x): stub\n", hWndOwner );
307     return WN16_NOT_SUPPORTED;
308 }
309
310 /**************************************************************************
311  *              WNetBrowseDialog16       [USER.515]
312  */
313 WORD WINAPI WNetBrowseDialog16( HWND16 hParent, WORD nType, LPSTR szPath )
314 {
315     FIXME( "(%04x, %x, %s): stub\n", hParent, nType, szPath );
316     return WN16_NOT_SUPPORTED;
317 }
318
319 /********************************************************************
320  *              WNetConnectDialog       [USER.525]
321  */
322 WORD WINAPI WNetConnectDialog( HWND16 hWndParent, WORD iType )
323 {
324     FIXME( "(%04x, %x): stub\n", hWndParent, iType );
325     return WN16_SUCCESS;
326 }
327
328 /**************************************************************************
329  *              WNetDisconnectDialog16       [USER.526]
330  */
331 WORD WINAPI WNetDisconnectDialog16( HWND16 hwndOwner, WORD iType )
332 {
333     FIXME( "(%04x, %x): stub\n", hwndOwner, iType );
334     return WN16_NOT_SUPPORTED;
335 }
336
337 /**************************************************************************
338  *              WNetConnectionDialog16     [USER.527]
339  */
340 WORD WINAPI WNetConnectionDialog16( HWND16 hWndParent, WORD iType )
341 {
342     FIXME( "(%04x, %x): stub\n", hWndParent, iType );
343     return WN16_SUCCESS;
344 }
345
346 /**************************************************************************
347  *              WNetViewQueueDialog16       [USER.528]
348  */
349 WORD WINAPI WNetViewQueueDialog16( HWND16 hwndOwner, LPSTR lpszQueue )
350 {
351     FIXME(" (%04x, %s): stub\n", hwndOwner, debugstr_a(lpszQueue) );
352     return WN16_NOT_SUPPORTED;
353 }
354
355 /**************************************************************************
356  *              WNetPropertyDialog16       [USER.529]
357  */
358 WORD WINAPI WNetPropertyDialog16( HWND16 hwndParent, WORD iButton,
359                                   WORD nPropSel, LPSTR lpszName, WORD nType )
360 {
361     FIXME( "(%04x, %x, %x, %s, %x ): stub\n",
362           hwndParent, iButton, nPropSel, debugstr_a(lpszName), nType );
363     return WN16_NOT_SUPPORTED;
364 }
365
366 /**************************************************************************
367  *              WNetGetPropertyText16       [USER.532]
368  */
369 WORD WINAPI WNetGetPropertyText16( WORD iButton, WORD nPropSel, LPSTR lpszName,
370                                    LPSTR lpszButtonName, WORD cbButtonName, WORD nType )
371 {
372     FIXME( "(%04x, %04x, %s, %s, %04x): stub\n",
373            iButton, nPropSel, debugstr_a(lpszName), debugstr_a(lpszButtonName), nType);
374     return WN16_NOT_SUPPORTED;
375 }
376
377
378 /*
379  * Admin
380  */
381
382 /*********************************************************************
383  *  WNetGetDirectoryType16 [USER.530]  Decides whether resource is local
384  *
385  * RETURNS
386  *    on success,  puts one of the following in *lpType:
387  * - WNDT_NETWORK   on a network
388  * - WNDT_LOCAL     local
389  */
390 WORD WINAPI WNetGetDirectoryType16( LPSTR lpName, LPINT16 lpType )
391 {
392     UINT type = GetDriveTypeA(lpName);
393     if ( type == DRIVE_NO_ROOT_DIR )
394         type = GetDriveTypeA(NULL);
395
396     *lpType = (type == DRIVE_REMOTE)? WNDT_NETWORK : WNDT_NORMAL;
397
398     TRACE( "%s is %s\n", debugstr_a(lpName), 
399            (*lpType == WNDT_NETWORK)? "WNDT_NETWORK" : "WNDT_NORMAL" );
400     return WN16_SUCCESS;
401 }
402
403 /**************************************************************************
404  *              WNetDirectoryNotify16       [USER.531]
405  */
406 WORD WINAPI WNetDirectoryNotify16( HWND16 hwndOwner, LPSTR lpDir, WORD wOper )
407 {
408     FIXME( "(%04x, %s, %s): stub\n", hwndOwner, debugstr_a(lpDir),
409            (wOper == WNDN_MKDIR)? "WNDN_MKDIR" :
410            (wOper == WNDN_MVDIR)? "WNDN_MVDIR" :
411            (wOper == WNDN_RMDIR)? "WNDN_RMDIR" : "unknown" );
412     return WN16_NOT_SUPPORTED;
413 }
414
415
416 /*
417  * Error handling
418  */
419
420 /**************************************************************************
421  *              WNetGetError16       [USER.519]
422  */
423 WORD WINAPI WNetGetError16( LPINT16 nError )
424 {
425     FIXME( "(%p): stub\n", nError );
426     return WN16_NOT_SUPPORTED;
427 }
428
429 /**************************************************************************
430  *              WNetGetErrorText16       [USER.520]
431  */
432 WORD WINAPI WNetGetErrorText16( WORD nError, LPSTR lpBuffer, LPINT16 nBufferSize )
433 {
434     FIXME( "(%x, %p, %p): stub\n", nError, lpBuffer, nBufferSize );
435     return WN16_NET_ERROR;
436 }
437
438 /**************************************************************************
439  *              WNetErrorText16       [USER.499]
440  */
441 WORD WINAPI WNetErrorText16( WORD nError, LPSTR lpszText, WORD cbText )
442 {
443     FIXME("(%x, %p, %x): stub\n", nError, lpszText, cbText );
444     return FALSE;
445 }
446