blob: fb4468f6950577c901983027efcde80049528bc1 [file] [log] [blame]
Juan Lange7fd6fd2003-11-29 00:19:19 +00001/* Copyright 2001 Mike McCormack
2 * Copyright 2003 Juan Lang
Alexandre Julliard0799c1a2002-03-09 23:29:33 +00003 *
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
Jonathan Ernst360a3f92006-05-18 14:49:52 +020016 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
Mike McCormack2e40b962001-11-06 17:52:36 +000017 */
18
François Gouget2663b802001-11-06 19:01:05 +000019#include "config.h"
20
Alexandre Julliard0799c1a2002-03-09 23:29:33 +000021#include "wine/debug.h"
Vincent Béron74a4e592005-11-30 12:04:18 +010022#include "lm.h"
Juan Lange7fd6fd2003-11-29 00:19:19 +000023#include "netbios.h"
Mike McCormack2e40b962001-11-06 17:52:36 +000024
Alexandre Julliard0799c1a2002-03-09 23:29:33 +000025WINE_DEFAULT_DEBUG_CHANNEL(netbios);
Mike McCormack2e40b962001-11-06 17:52:36 +000026
Andrew Talbot9d70a6e2007-01-16 21:11:37 +000027static HMODULE NETAPI32_hModule;
Mike McCormack2e40b962001-11-06 17:52:36 +000028
Jason Edmeadesc6be6a42010-01-16 14:55:20 -080029BOOL NETAPI_IsLocalComputer(LMCSTR ServerName);
30
Alexandre Julliard1e1313d2002-11-04 23:53:41 +000031BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
Mike McCormack2e40b962001-11-06 17:52:36 +000032{
Hans Leidekker9f71ae82006-10-12 20:56:59 +020033 TRACE("%p,%x,%p\n", hinstDLL, fdwReason, lpvReserved);
Mike McCormack2e40b962001-11-06 17:52:36 +000034
35 switch (fdwReason) {
Juan Lange7fd6fd2003-11-29 00:19:19 +000036 case DLL_PROCESS_ATTACH:
37 {
Dmitry Timoshkov4e1ef0c2003-06-30 20:53:48 +000038 DisableThreadLibraryCalls(hinstDLL);
Mike McCormack2e40b962001-11-06 17:52:36 +000039 NETAPI32_hModule = hinstDLL;
Juan Lange7fd6fd2003-11-29 00:19:19 +000040 NetBIOSInit();
41 NetBTInit();
42 break;
43 }
44 case DLL_PROCESS_DETACH:
45 {
46 NetBIOSShutdown();
47 break;
48 }
Mike McCormack2e40b962001-11-06 17:52:36 +000049 }
50
51 return TRUE;
52}
53
Robert Reif65dd8742006-06-07 07:42:24 -040054/************************************************************
55 * NetServerEnum (NETAPI32.@)
56 */
Aric Stewart3e53d112003-05-19 23:06:35 +000057NET_API_STATUS WINAPI NetServerEnum(
Francois Gouget9fae03b2007-08-08 10:41:51 +020058 LMCSTR servername,
Aric Stewart3e53d112003-05-19 23:06:35 +000059 DWORD level,
60 LPBYTE* bufptr,
61 DWORD prefmaxlen,
62 LPDWORD entriesread,
63 LPDWORD totalentries,
64 DWORD servertype,
Francois Gouget9fae03b2007-08-08 10:41:51 +020065 LMCSTR domain,
Aric Stewart3e53d112003-05-19 23:06:35 +000066 LPDWORD resume_handle
67)
68{
Hans Leidekker9f71ae82006-10-12 20:56:59 +020069 FIXME("Stub (%s %d %p %d %p %p %d %s %p)\n", debugstr_w(servername),
Juan Lang1ad81802004-04-05 20:17:45 +000070 level, bufptr, prefmaxlen, entriesread, totalentries, servertype,
71 debugstr_w(domain), resume_handle);
Aric Stewart3e53d112003-05-19 23:06:35 +000072
73 return ERROR_NO_BROWSER_SERVERS_FOUND;
74}
Geoff Thorpe23609d22003-09-11 03:09:19 +000075
Robert Reif65dd8742006-06-07 07:42:24 -040076/************************************************************
77 * NetServerEnumEx (NETAPI32.@)
78 */
79NET_API_STATUS WINAPI NetServerEnumEx(
Francois Gouget9fae03b2007-08-08 10:41:51 +020080 LMCSTR ServerName,
Robert Reif65dd8742006-06-07 07:42:24 -040081 DWORD Level,
82 LPBYTE *Bufptr,
83 DWORD PrefMaxlen,
84 LPDWORD EntriesRead,
85 LPDWORD totalentries,
86 DWORD servertype,
Francois Gouget9fae03b2007-08-08 10:41:51 +020087 LMCSTR domain,
88 LMCSTR FirstNameToReturn)
Robert Reif65dd8742006-06-07 07:42:24 -040089{
Hans Leidekker9f71ae82006-10-12 20:56:59 +020090 FIXME("Stub (%s %d %p %d %p %p %d %s %p)\n", debugstr_w(ServerName),
Robert Reif65dd8742006-06-07 07:42:24 -040091 Level, Bufptr, PrefMaxlen, EntriesRead, totalentries, servertype,
92 debugstr_w(domain), debugstr_w(FirstNameToReturn));
93
94 return ERROR_NO_BROWSER_SERVERS_FOUND;
95}
Geoff Thorpe23609d22003-09-11 03:09:19 +000096
97/************************************************************
Hans Leidekker7e8e1242004-04-02 19:17:42 +000098 * NetServerGetInfo (NETAPI32.@)
99 */
Ge van Geldorp2f57b9f2005-11-21 11:59:27 +0000100NET_API_STATUS WINAPI NetServerGetInfo(LMSTR servername, DWORD level, LPBYTE* bufptr)
Hans Leidekker7e8e1242004-04-02 19:17:42 +0000101{
Jason Edmeadesc6be6a42010-01-16 14:55:20 -0800102 NET_API_STATUS ret;
103
104 TRACE("%s %d %p\n", debugstr_w( servername ), level, bufptr );
105 if (servername)
106 {
107 if (!NETAPI_IsLocalComputer(servername))
108 {
109 FIXME("remote computers not supported\n");
110 return ERROR_INVALID_LEVEL;
111 }
112 }
113 if (!bufptr) return ERROR_INVALID_PARAMETER;
114
115 switch (level)
116 {
117 case 100:
118 case 101:
119 {
120 DWORD computerNameLen, size;
121 WCHAR computerName[MAX_COMPUTERNAME_LENGTH + 1];
122
123 computerNameLen = MAX_COMPUTERNAME_LENGTH + 1;
124 GetComputerNameW(computerName, &computerNameLen);
125 computerNameLen++; /* include NULL terminator */
126
127 size = sizeof(SERVER_INFO_101) + computerNameLen * sizeof(WCHAR);
128 ret = NetApiBufferAllocate(size, (LPVOID *)bufptr);
129 if (ret == NERR_Success)
130 {
131 /* INFO_100 structure is a subset of INFO_101 */
132 PSERVER_INFO_101 info = (PSERVER_INFO_101)*bufptr;
133 OSVERSIONINFOW verInfo;
134
135 info->sv101_platform_id = PLATFORM_ID_NT;
136 info->sv101_name = (LMSTR)(*bufptr + sizeof(SERVER_INFO_101));
137 memcpy(info->sv101_name, computerName,
138 computerNameLen * sizeof(WCHAR));
139 verInfo.dwOSVersionInfoSize = sizeof(verInfo);
140 GetVersionExW(&verInfo);
141 info->sv101_version_major = verInfo.dwMajorVersion;
142 info->sv101_version_minor = verInfo.dwMinorVersion;
143 /* Use generic type as no wine equivalent of DC / Server */
144 info->sv101_type = SV_TYPE_NT;
145 info->sv101_comment = NULL;
146 }
147 break;
148 }
149
150 default:
151 FIXME("level %d unimplemented\n", level);
152 ret = ERROR_INVALID_LEVEL;
153 }
154 return ret;
Hans Leidekker7e8e1242004-04-02 19:17:42 +0000155}
156
157
158/************************************************************
Geoff Thorpe23609d22003-09-11 03:09:19 +0000159 * NetStatisticsGet (NETAPI32.@)
160 */
Francois Gouget9fae03b2007-08-08 10:41:51 +0200161NET_API_STATUS WINAPI NetStatisticsGet(LMSTR server, LMSTR service,
Geoff Thorpe23609d22003-09-11 03:09:19 +0000162 DWORD level, DWORD options,
163 LPBYTE *bufptr)
164{
Hans Leidekker9f71ae82006-10-12 20:56:59 +0200165 TRACE("(%p, %p, %d, %d, %p)\n", server, service, level, options, bufptr);
Geoff Thorpe23609d22003-09-11 03:09:19 +0000166 return NERR_InternalError;
167}
Juan Lang93e268e2004-03-01 21:23:51 +0000168
169DWORD WINAPI NetpNetBiosStatusToApiStatus(DWORD nrc)
170{
171 DWORD ret;
172
173 switch (nrc)
174 {
175 case NRC_GOODRET:
176 ret = NO_ERROR;
177 break;
178 case NRC_NORES:
179 ret = NERR_NoNetworkResource;
180 break;
181 case NRC_DUPNAME:
182 ret = NERR_AlreadyExists;
183 break;
184 case NRC_NAMTFUL:
185 ret = NERR_TooManyNames;
186 break;
187 case NRC_ACTSES:
188 ret = NERR_DeleteLater;
189 break;
190 case NRC_REMTFUL:
191 ret = ERROR_REM_NOT_LIST;
192 break;
193 case NRC_NOCALL:
194 ret = NERR_NameNotFound;
195 break;
196 case NRC_NOWILD:
197 ret = ERROR_INVALID_PARAMETER;
198 break;
199 case NRC_INUSE:
200 ret = NERR_DuplicateName;
201 break;
202 case NRC_NAMERR:
203 ret = ERROR_INVALID_PARAMETER;
204 break;
205 case NRC_NAMCONF:
206 ret = NERR_DuplicateName;
207 break;
208 default:
209 ret = NERR_NetworkError;
210 }
211 return ret;
212}
Tim Schwartzdb994bf2007-10-30 15:34:48 -0500213
214NET_API_STATUS WINAPI NetUseEnum(LMSTR server, DWORD level, LPBYTE* bufptr, DWORD prefmaxsize,
215 LPDWORD entriesread, LPDWORD totalentries, LPDWORD resumehandle)
216{
217 FIXME("stub (%p, %d, %p, %d, %p, %p, %p)\n", server, level, bufptr, prefmaxsize,
218 entriesread, totalentries, resumehandle);
219 return ERROR_NOT_SUPPORTED;
220}