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