Release 980301
[wine] / misc / network.c
1 /*
2  * Network functions
3  */
4
5 #include <ctype.h>
6 #include <stdio.h>
7
8 #include "windows.h"
9 #include "winerror.h"
10 #include "drive.h"
11 #include "wnet.h"
12
13 /**************************************************************************
14  *              WNetErrorText       [USER.499]
15  */
16 int WINAPI WNetErrorText(WORD nError,LPSTR lpszText,WORD cbText)
17 {
18         printf("EMPTY STUB !!! WNetErrorText(%x,%p,%x)\n",
19                 nError,lpszText,cbText);
20         return FALSE;
21 }
22
23 /**************************************************************************
24  *              WNetOpenJob       [USER.501]
25  */
26 int WINAPI WNetOpenJob(LPSTR szQueue,LPSTR szJobTitle,WORD nCopies,LPWORD pfh)
27 {
28         printf("EMPTY STUB !!! WNetOpenJob('%s','%s',%x,%p)\n",
29                 szQueue,szJobTitle,nCopies,pfh);
30         return WN_NET_ERROR;
31 }
32
33 /**************************************************************************
34  *              WNetCloseJob       [USER.502]
35  */
36 int WINAPI WNetCloseJob(WORD fh,LPWORD pidJob,LPSTR szQueue)
37 {
38         printf("EMPTY STUB !!! WNetCloseJob(%x,%p,'%s')\n",
39                 fh,pidJob,szQueue);
40         return WN_NET_ERROR;
41 }
42
43 /**************************************************************************
44  *              WNetAbortJob       [USER.503]
45  */
46 int WINAPI WNetAbortJob(LPSTR szQueue,WORD wJobId)
47 {
48         printf("EMPTY STUB !!! WNetAbortJob('%s',%x)\n",
49                 szQueue,wJobId);
50         return WN_NET_ERROR;
51 }
52
53 /**************************************************************************
54  *              WNetHoldJob       [USER.504]
55  */
56 int WINAPI WNetHoldJob(LPSTR szQueue,WORD wJobId)
57 {
58         printf("EMPTY STUB !!! WNetHoldJob('%s',%x)\n",
59                 szQueue,wJobId);
60         return WN_NET_ERROR;
61 }
62
63 /**************************************************************************
64  *              WNetReleaseJob       [USER.505]
65  */
66 int WINAPI WNetReleaseJob(LPSTR szQueue,WORD wJobId)
67 {
68         printf("EMPTY STUB !!! WNetReleaseJob('%s',%x)\n",
69                 szQueue,wJobId);
70         return WN_NET_ERROR;
71 }
72
73 /**************************************************************************
74  *              WNetCancelJob       [USER.506]
75  */
76 int WINAPI WNetCancelJob(LPSTR szQueue,WORD wJobId)
77 {
78         printf("EMPTY STUB !!! WNetCancelJob('%s',%x)\n",
79                 szQueue,wJobId);
80         return WN_NET_ERROR;
81 }
82
83 /**************************************************************************
84  *              WNetSetJobCopies       [USER.507]
85  */
86 int WINAPI WNetSetJobCopies(LPSTR szQueue,WORD wJobId,WORD nCopies)
87 {
88         printf("EMPTY STUB !!! WNetSetJobCopies('%s',%x,%x)\n",
89                 szQueue,wJobId,nCopies);
90         return WN_NET_ERROR;
91 }
92
93 /**************************************************************************
94  *              WNetWatchQueue       [USER.508]
95  */
96 int WINAPI WNetWatchQueue(HWND16 hWnd,LPSTR szLocal,LPSTR szUser,WORD nQueue)
97 {
98         printf("EMPTY STUB !!! WNetWatchQueue(%04x,'%s','%s',%x)\n",
99                 hWnd,szLocal,szUser,nQueue);
100         return WN_NET_ERROR;
101 }
102
103 /**************************************************************************
104  *              WNetUnwatchQueue       [USER.509]
105  */
106 int WINAPI WNetUnwatchQueue(LPSTR szQueue)
107 {
108         printf("EMPTY STUB !!! WNetUnwatchQueue('%s')\n", szQueue);
109         return WN_NET_ERROR;
110 }
111
112 /**************************************************************************
113  *              WNetLockQueueData       [USER.510]
114  */
115 int WINAPI WNetLockQueueData(LPSTR szQueue,LPSTR szUser,void *lplpQueueStruct)
116 {
117         printf("EMPTY STUB !!! WNetLockQueueData('%s','%s',%p)\n",
118                 szQueue,szUser,lplpQueueStruct);
119         return WN_NET_ERROR;
120 }
121
122 /**************************************************************************
123  *              WNetUnlockQueueData       [USER.511]
124  */
125 int WINAPI WNetUnlockQueueData(LPSTR szQueue)
126 {
127         printf("EMPTY STUB !!! WNetUnlockQueueData('%s')\n",szQueue);
128         return WN_NET_ERROR;
129 }
130
131 /**************************************************************************
132  *                              WNetGetConnection       [USER.512]
133  */
134 int WINAPI WNetGetConnection16(LPCSTR lpLocalName, 
135                                LPSTR lpRemoteName, UINT16 *cbRemoteName)
136 {
137     const char *path;
138
139     if (lpLocalName[1] == ':')
140     {
141         int drive = toupper(lpLocalName[0]) - 'A';
142         switch(GetDriveType16(drive))
143         {
144         case DRIVE_CANNOTDETERMINE:
145         case DRIVE_DOESNOTEXIST:
146             return WN_BAD_LOCALNAME;
147         case DRIVE_REMOVABLE:
148         case DRIVE_FIXED:
149             return WN_NOT_CONNECTED;
150         case DRIVE_REMOTE:
151             path = DRIVE_GetLabel(drive);
152             if (strlen(path) + 1 > *cbRemoteName)
153             {
154                 *cbRemoteName = strlen(path) + 1;
155                 return WN_MORE_DATA;
156             }
157             strcpy( lpRemoteName, path );
158             *cbRemoteName = strlen(lpRemoteName) + 1;
159             return WN_SUCCESS;
160         }
161     }
162     return WN_BAD_LOCALNAME;
163 }
164
165 /**************************************************************************
166  *                              WNetGetCaps             [USER.513]
167  */
168 int WINAPI WNetGetCaps(WORD capability)
169 {
170         switch (capability) {
171                 case WNNC_SPEC_VERSION:
172                 {
173                         return 0x30a; /* WfW 3.11 (and apparently other 3.1x) */
174                 }
175                 case WNNC_NET_TYPE:
176                 /* hi byte = network type, lo byte = network vendor (Netware = 0x03) [15 types] */
177                 return WNNC_NET_MultiNet | WNNC_SUBNET_WinWorkgroups;
178
179                 case WNNC_DRIVER_VERSION:
180                 /* driver version of vendor */
181                 return 0x100; /* WfW 3.11 */
182
183                 case WNNC_USER:
184                 /* 1 = WNetGetUser is supported */
185                 return 1;
186
187                 case WNNC_CONNECTION:
188                 /* returns mask of the supported connection functions */
189                 return  WNNC_CON_AddConnection|WNNC_CON_CancelConnection
190                         |WNNC_CON_GetConnections/*|WNNC_CON_AutoConnect*/
191                         |WNNC_CON_BrowseDialog|WNNC_CON_RestoreConnection;
192
193                 case WNNC_PRINTING:
194                 /* returns mask of the supported printing functions */
195                 return  WNNC_PRT_OpenJob|WNNC_PRT_CloseJob|WNNC_PRT_HoldJob
196                         |WNNC_PRT_ReleaseJob|WNNC_PRT_CancelJob
197                         |WNNC_PRT_SetJobCopies|WNNC_PRT_WatchQueue
198                         |WNNC_PRT_UnwatchQueue|WNNC_PRT_LockQueueData
199                         |WNNC_PRT_UnlockQueueData|WNNC_PRT_AbortJob
200                         |WNNC_PRT_WriteJob;
201
202                 case WNNC_DIALOG:
203                 /* returns mask of the supported dialog functions */
204                 return  WNNC_DLG_DeviceMode|WNNC_DLG_BrowseDialog
205                         |WNNC_DLG_ConnectDialog|WNNC_DLG_DisconnectDialog
206                         |WNNC_DLG_ViewQueueDialog|WNNC_DLG_PropertyDialog
207                         |WNNC_DLG_ConnectionDialog
208                         /*|WNNC_DLG_PrinterConnectDialog
209                         |WNNC_DLG_SharesDialog|WNNC_DLG_ShareAsDialog*/;
210
211                 case WNNC_ADMIN:
212                 /* returns mask of the supported administration functions */
213                 /* not sure if long file names is a good idea */
214                 return  WNNC_ADM_GetDirectoryType|WNNC_ADM_DirectoryNotify
215                         |WNNC_ADM_LongNames/*|WNNC_ADM_SetDefaultDrive*/;
216
217                 case WNNC_ERROR:
218                 /* returns mask of the supported error functions */
219                 return  WNNC_ERR_GetError|WNNC_ERR_GetErrorText;
220
221                 case WNNC_PRINTMGREXT:
222                 /* returns the Print Manager version in major and minor format if Print Manager functions are available */
223                 return 0x30e; /* printman version of WfW 3.11 */
224
225                 case 0xffff:
226                 /* Win 3.11 returns HMODULE of network driver here
227                 FIXME: what should we return ?
228                 logonoff.exe needs it, msmail crashes with wrong value */
229                 return 0;
230
231         default:
232                 return 0;
233         }
234 }
235
236 /**************************************************************************
237  *              WNetDeviceMode       [USER.514]
238  */
239 int WINAPI WNetDeviceMode(HWND16 hWndOwner)
240 {
241         printf("EMPTY STUB !!! WNetDeviceMode(%04x)\n",hWndOwner);
242         return WN_NO_NETWORK;
243 }
244
245 /**************************************************************************
246  *              WNetBrowseDialog       [USER.515]
247  */
248 int WINAPI WNetBrowseDialog(HWND16 hParent,WORD nType,LPSTR szPath)
249 {
250         printf("EMPTY STUB !!! WNetBrowseDialog(%04x,%x,'%s')\n",
251                 hParent,nType,szPath);
252         return WN_NO_NETWORK;
253 }
254
255 /**************************************************************************
256  *                              WNetGetUser                     [USER.516]
257  */
258 UINT16 WINAPI WNetGetUser(LPSTR lpLocalName, LPSTR lpUserName, DWORD *lpSize)
259 {
260         printf("EMPTY STUB !!! WNetGetUser(%p, %p, %p);\n", 
261                                                         lpLocalName, lpUserName, lpSize);
262         return WN_NO_NETWORK;
263 }
264
265 /**************************************************************************
266  *                              WNetAddConnection       [USER.517]
267  */
268 UINT16 WINAPI WNetAddConnection(LPSTR lpNetPath, LPSTR lpPassWord,
269                                 LPSTR lpLocalName)
270 {
271         printf("EMPTY STUB !!! WNetAddConnection('%s', %p, '%s');\n",
272                                                         lpNetPath, lpPassWord, lpLocalName);
273         return WN_NO_NETWORK;
274 }
275
276
277 /**************************************************************************
278  *                              WNetCancelConnection    [USER.518]
279  */
280 UINT16 WINAPI WNetCancelConnection(LPSTR lpName, BOOL16 bForce)
281 {
282     printf("EMPTY STUB !!! WNetCancelConnection('%s', %04X);\n",
283            lpName, bForce);
284     return WN_NO_NETWORK;
285 }
286
287 /**************************************************************************
288  *              WNetGetError       [USER.519]
289  */
290 int WINAPI WNetGetError(LPWORD nError)
291 {
292         printf("EMPTY STUB !!! WNetGetError(%p)\n",nError);
293         return WN_NO_NETWORK;
294 }
295
296 /**************************************************************************
297  *              WNetGetErrorText       [USER.520]
298  */
299 int WINAPI WNetGetErrorText(WORD nError, LPSTR lpBuffer, LPWORD nBufferSize)
300 {
301         printf("EMPTY STUB !!! WNetGetErrorText(%x,%p,%p)\n",
302                 nError,lpBuffer,nBufferSize);
303         return WN_NET_ERROR;
304 }
305
306 /**************************************************************************
307  *              WNetRestoreConnection       [USER.523]
308  */
309 int WINAPI WNetRestoreConnection(HWND16 hwndOwner,LPSTR lpszDevice)
310 {
311         printf("EMPTY STUB !!! WNetRestoreConnection(%04x,'%s')\n",
312                 hwndOwner,lpszDevice);
313         return WN_NO_NETWORK;
314 }
315
316 /**************************************************************************
317  *              WNetWriteJob       [USER.524]
318  */
319 int WINAPI WNetWriteJob(HANDLE16 hJob,void *lpData,LPWORD lpcbData)
320 {
321         printf("EMPTY STUB !!! WNetWriteJob(%04x,%p,%p)\n",
322                 hJob,lpData,lpcbData);
323         return WN_NO_NETWORK;
324 }
325
326 /**************************************************************************
327  *              WnetConnectDialog       [USER.525]
328  */
329 UINT16 WINAPI WNetConnectDialog(HWND16 hWndParent, WORD iType)
330 {
331         printf("EMPTY STUB !!! WNetConnectDialog(%04x, %4X)\n", hWndParent, iType);
332         return WN_SUCCESS;
333 }
334
335 /**************************************************************************
336  *              WNetDisconnectDialog       [USER.526]
337  */
338 int WINAPI WNetDisconnectDialog(HWND16 hwndOwner, WORD iType)
339 {
340         printf("EMPTY STUB !!! WNetDisconnectDialog(%04x,%x)\n",
341                 hwndOwner,iType);
342         return WN_NO_NETWORK;
343 }
344
345 /**************************************************************************
346  *              WnetConnectionDialog     [USER.527]
347  */
348 UINT16 WINAPI WNetConnectionDialog(HWND16 hWndParent, WORD iType)
349 {
350         printf("EMPTY STUB !!! WNetConnectionDialog(%04x, %4X)\n", 
351                 hWndParent, iType);
352         return WN_SUCCESS;
353 }
354
355 /**************************************************************************
356  *              WNetViewQueueDialog       [USER.528]
357  */
358 int WINAPI WNetViewQueueDialog(HWND16 hwndOwner,LPSTR lpszQueue)
359 {
360         printf("EMPTY STUB !!! WNetViewQueueDialog(%04x,'%s')\n",
361                 hwndOwner,lpszQueue);
362         return WN_NO_NETWORK;
363 }
364
365 /**************************************************************************
366  *              WNetPropertyDialog       [USER.529]
367  */
368 int WINAPI WNetPropertyDialog(HWND16 hwndParent,WORD iButton,
369                               WORD nPropSel,LPSTR lpszName,WORD nType)
370 {
371         printf("EMPTY STUB !!! WNetPropertyDialog(%04x,%x,%x,'%s',%x)\n",
372                 hwndParent,iButton,nPropSel,lpszName,nType);
373         return WN_NO_NETWORK;
374 }
375
376 /**************************************************************************
377  *              WNetGetDirectoryType       [USER.530]
378  */
379 int WINAPI WNetGetDirectoryType(LPSTR lpName,void *lpType)
380 {
381         printf("EMPTY STUB !!! WNetGetDirectoryType('%s',%p)\n",
382                 lpName,lpType);
383         return WN_NO_NETWORK;
384 }
385
386 /**************************************************************************
387  *              WNetDirectoryNotify       [USER.531]
388  */
389 int WINAPI WNetDirectoryNotify(HWND16 hwndOwner,void *lpDir,WORD wOper)
390 {
391         printf("EMPTY STUB !!! WNetDirectoryNotify(%04x,%p,%x)\n",
392                 hwndOwner,lpDir,wOper);
393         return WN_NO_NETWORK;
394 }
395
396 /**************************************************************************
397  *              WNetGetPropertyText       [USER.532]
398  */
399 int WINAPI WNetGetPropertyText(HWND16 hwndParent,WORD iButton,WORD nPropSel,
400                                LPSTR lpszName,WORD nType)
401 {
402         printf("EMPTY STUB !!! WNetGetPropertyText(%04x,%x,%x,'%s',%x)\n",
403                 hwndParent,iButton,nPropSel,lpszName,nType);
404         return WN_NO_NETWORK;
405 }
406
407 /**************************************************************************
408  *                              WNetAddConnection2      [USER.???]
409  */
410 UINT16 WINAPI WNetAddConnection2(LPSTR lpNetPath, LPSTR lpPassWord, 
411                                  LPSTR lpLocalName, LPSTR lpUserName)
412 {
413         printf("EMPTY STUB !!! WNetAddConnection2('%s', %p, '%s', '%s');\n",
414                                         lpNetPath, lpPassWord, lpLocalName, lpUserName);
415         return WN_NO_NETWORK;
416 }
417
418 /**************************************************************************
419  *                              WNetCloseEnum           [USER.???]
420  */
421 UINT16 WINAPI WNetCloseEnum(HANDLE16 hEnum)
422 {
423         printf("EMPTY STUB !!! WNetCloseEnum(%04x);\n", hEnum);
424         return WN_NO_NETWORK;
425 }
426
427 /**************************************************************************
428  *                              WNetEnumResource        [USER.???]
429  */
430 UINT16 WINAPI WNetEnumResource(HANDLE16 hEnum, DWORD cRequ, 
431                                DWORD *lpCount, LPVOID lpBuf)
432 {
433         printf("EMPTY STUB !!! WNetEnumResource(%04x, %08lX, %p, %p);\n", 
434                                                         hEnum, cRequ, lpCount, lpBuf);
435         return WN_NO_NETWORK;
436 }
437
438 /**************************************************************************
439  *                              WNetOpenEnum            [USER.???]
440  */
441 UINT16 WINAPI WNetOpenEnum16(DWORD dwScope, DWORD dwType, 
442                              LPNETRESOURCE16 lpNet, HANDLE16 *lphEnum)
443 {
444         printf("EMPTY STUB !!! WNetOpenEnum(%08lX, %08lX, %p, %p);\n",
445                dwScope, dwType, lpNet, lphEnum);
446         return WN_NO_NETWORK;
447 }
448
449 /**************************************************************************
450  *                              WNetOpenEnumA           [MPR.92]
451  */
452 UINT32 WINAPI WNetOpenEnum32A(DWORD dwScope, DWORD dwType, 
453                               LPNETRESOURCE32A lpNet, HANDLE32 *lphEnum)
454 {
455         printf("EMPTY STUB !!! WNetOpenEnumA(%08lX, %08lX, %p, %p);\n",
456                dwScope, dwType, lpNet, lphEnum);
457         return WN_NO_NETWORK;
458 }
459
460 /**************************************************************************
461  *                              WNetGetConnectionA      [MPR.92]
462  */
463 DWORD WINAPI
464 WNetGetConnection32A(LPCSTR localname,LPSTR remotename,LPDWORD buflen)
465 {
466         UINT16  x;
467         DWORD   ret = WNetGetConnection16(localname,remotename,&x);
468         *buflen = x;
469         return ret;
470 }
471
472 DWORD WINAPI 
473 WNetGetResourceInformation32A(
474         LPNETRESOURCE32A netres,LPVOID buf,LPDWORD buflen,LPSTR systemstr
475 ) {
476         fprintf(stderr,"WNetGetResourceInformationA(%p,%p,%p,%p),stub!\n",
477                 netres,buf,buflen,systemstr
478         );
479         return WN_NO_NETWORK;
480 }