hhctrl.ocx: Add support for specifying window names with HH_HELP_CONTEXT.
[wine] / dlls / netapi32 / netapi32.c
1 /* Copyright 2001 Mike McCormack
2  * Copyright 2003 Juan Lang
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #include "config.h"
20
21 #include "wine/debug.h"
22 #include "lm.h"
23 #include "lmat.h"
24 #include "netbios.h"
25
26 WINE_DEFAULT_DEBUG_CHANNEL(netbios);
27
28 static HMODULE NETAPI32_hModule;
29
30 BOOL NETAPI_IsLocalComputer(LMCSTR ServerName);
31
32 BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
33 {
34     TRACE("%p,%x,%p\n", hinstDLL, fdwReason, lpvReserved);
35
36     switch (fdwReason) {
37         case DLL_PROCESS_ATTACH:
38         {
39             DisableThreadLibraryCalls(hinstDLL);
40             NETAPI32_hModule = hinstDLL;
41             NetBIOSInit();
42             NetBTInit();
43             break;
44         }
45         case DLL_PROCESS_DETACH:
46         {
47             NetBIOSShutdown();
48             break;
49         }
50     }
51
52     return TRUE;
53 }
54
55 /************************************************************
56  *                NetServerEnum (NETAPI32.@)
57  */
58 NET_API_STATUS  WINAPI NetServerEnum(
59   LMCSTR servername,
60   DWORD level,
61   LPBYTE* bufptr,
62   DWORD prefmaxlen,
63   LPDWORD entriesread,
64   LPDWORD totalentries,
65   DWORD servertype,
66   LMCSTR domain,
67   LPDWORD resume_handle
68 )
69 {
70     FIXME("Stub (%s %d %p %d %p %p %d %s %p)\n", debugstr_w(servername),
71      level, bufptr, prefmaxlen, entriesread, totalentries, servertype,
72      debugstr_w(domain), resume_handle);
73
74     return ERROR_NO_BROWSER_SERVERS_FOUND;
75 }
76
77 /************************************************************
78  *                NetServerEnumEx (NETAPI32.@)
79  */
80 NET_API_STATUS WINAPI NetServerEnumEx(
81     LMCSTR ServerName,
82     DWORD Level,
83     LPBYTE *Bufptr,
84     DWORD PrefMaxlen,
85     LPDWORD EntriesRead,
86     LPDWORD totalentries,
87     DWORD servertype,
88     LMCSTR domain,
89     LMCSTR FirstNameToReturn)
90 {
91     FIXME("Stub (%s %d %p %d %p %p %d %s %s)\n",
92            debugstr_w(ServerName), Level, Bufptr, PrefMaxlen, EntriesRead, totalentries,
93            servertype, debugstr_w(domain), debugstr_w(FirstNameToReturn));
94
95     return ERROR_NO_BROWSER_SERVERS_FOUND;
96 }
97
98 /************************************************************
99  *                NetServerDiskEnum (NETAPI32.@)
100  */
101 NET_API_STATUS WINAPI NetServerDiskEnum(
102     LMCSTR ServerName,
103     DWORD Level,
104     LPBYTE *Bufptr,
105     DWORD PrefMaxlen,
106     LPDWORD EntriesRead,
107     LPDWORD totalentries,
108     LPDWORD Resume_Handle)
109 {
110     FIXME("Stub (%s %d %p %d %p %p %p)\n", debugstr_w(ServerName),
111      Level, Bufptr, PrefMaxlen, EntriesRead, totalentries, Resume_Handle);
112
113     return ERROR_NO_BROWSER_SERVERS_FOUND;
114 }
115
116 /************************************************************
117  *                NetServerGetInfo  (NETAPI32.@)
118  */
119 NET_API_STATUS WINAPI NetServerGetInfo(LMSTR servername, DWORD level, LPBYTE* bufptr)
120 {
121     NET_API_STATUS ret;
122
123     TRACE("%s %d %p\n", debugstr_w( servername ), level, bufptr );
124     if (servername)
125     {
126         if (!NETAPI_IsLocalComputer(servername))
127         {
128             FIXME("remote computers not supported\n");
129             return ERROR_INVALID_LEVEL;
130         }
131     }
132     if (!bufptr) return ERROR_INVALID_PARAMETER;
133
134     switch (level)
135     {
136         case 100:
137         case 101:
138         {
139             DWORD computerNameLen, size;
140             WCHAR computerName[MAX_COMPUTERNAME_LENGTH + 1];
141
142             computerNameLen = MAX_COMPUTERNAME_LENGTH + 1;
143             GetComputerNameW(computerName, &computerNameLen);
144             computerNameLen++; /* include NULL terminator */
145
146             size = sizeof(SERVER_INFO_101) + computerNameLen * sizeof(WCHAR);
147             ret = NetApiBufferAllocate(size, (LPVOID *)bufptr);
148             if (ret == NERR_Success)
149             {
150                 /* INFO_100 structure is a subset of INFO_101 */
151                 PSERVER_INFO_101 info = (PSERVER_INFO_101)*bufptr;
152                 OSVERSIONINFOW verInfo;
153
154                 info->sv101_platform_id = PLATFORM_ID_NT;
155                 info->sv101_name = (LMSTR)(*bufptr + sizeof(SERVER_INFO_101));
156                 memcpy(info->sv101_name, computerName,
157                        computerNameLen * sizeof(WCHAR));
158                 verInfo.dwOSVersionInfoSize = sizeof(verInfo);
159                 GetVersionExW(&verInfo);
160                 info->sv101_version_major = verInfo.dwMajorVersion;
161                 info->sv101_version_minor = verInfo.dwMinorVersion;
162                  /* Use generic type as no wine equivalent of DC / Server */
163                 info->sv101_type = SV_TYPE_NT;
164                 info->sv101_comment = NULL;
165             }
166             break;
167         }
168
169         default:
170             FIXME("level %d unimplemented\n", level);
171             ret = ERROR_INVALID_LEVEL;
172     }
173     return ret;
174 }
175
176
177 /************************************************************
178  *                NetStatisticsGet  (NETAPI32.@)
179  */
180 NET_API_STATUS WINAPI NetStatisticsGet(LMSTR server, LMSTR service,
181                                        DWORD level, DWORD options,
182                                        LPBYTE *bufptr)
183 {
184     TRACE("(%p, %p, %d, %d, %p)\n", server, service, level, options, bufptr);
185     return NERR_InternalError;
186 }
187
188 DWORD WINAPI NetpNetBiosStatusToApiStatus(DWORD nrc)
189 {
190     DWORD ret;
191
192     switch (nrc)
193     {
194         case NRC_GOODRET:
195             ret = NO_ERROR;
196             break;
197         case NRC_NORES:
198             ret = NERR_NoNetworkResource;
199             break;
200         case NRC_DUPNAME:
201             ret = NERR_AlreadyExists;
202             break;
203         case NRC_NAMTFUL:
204             ret = NERR_TooManyNames;
205             break;
206         case NRC_ACTSES:
207             ret = NERR_DeleteLater;
208             break;
209         case NRC_REMTFUL:
210             ret = ERROR_REM_NOT_LIST;
211             break;
212         case NRC_NOCALL:
213             ret = NERR_NameNotFound;
214             break;
215         case NRC_NOWILD:
216             ret = ERROR_INVALID_PARAMETER;
217             break;
218         case NRC_INUSE:
219             ret = NERR_DuplicateName;
220             break;
221         case NRC_NAMERR:
222             ret = ERROR_INVALID_PARAMETER;
223             break;
224         case NRC_NAMCONF:
225             ret = NERR_DuplicateName;
226             break;
227         default:
228             ret = NERR_NetworkError;
229     }
230     return ret;
231 }
232
233 NET_API_STATUS WINAPI NetUseEnum(LMSTR server, DWORD level, LPBYTE* bufptr, DWORD prefmaxsize,
234                           LPDWORD entriesread, LPDWORD totalentries, LPDWORD resumehandle)
235 {
236     FIXME("stub (%p, %d, %p, %d, %p, %p, %p)\n", server, level, bufptr, prefmaxsize,
237            entriesread, totalentries, resumehandle);
238     return ERROR_NOT_SUPPORTED;
239 }
240
241 NET_API_STATUS WINAPI NetScheduleJobAdd(LPCWSTR server, LPBYTE bufptr, LPDWORD jobid)
242 {
243     FIXME("stub (%s, %p, %p)\n", debugstr_w(server), bufptr, jobid);
244     return NERR_Success;
245 }
246
247 NET_API_STATUS WINAPI NetScheduleJobEnum(LPCWSTR server, LPBYTE* bufptr, DWORD prefmaxsize, LPDWORD entriesread,
248                                          LPDWORD totalentries, LPDWORD resumehandle)
249 {
250     FIXME("stub (%s, %p, %d, %p, %p, %p)\n", debugstr_w(server), bufptr, prefmaxsize, entriesread, totalentries, resumehandle);
251     *entriesread = 0;
252     *totalentries = 0;
253     return NERR_Success;
254 }
255
256 NET_API_STATUS WINAPI NetUseGetInfo(LMSTR server, LMSTR name, DWORD level, LPBYTE *bufptr)
257 {
258     FIXME("stub (%p, %p, %d, %p)\n", server, name, level, bufptr);
259     return ERROR_NOT_SUPPORTED;
260
261 }