0b8c99b46d9d8c97d8b2ac6d87eb70e4651ddc11
[reactos.git] / reactos / dll / win32 / netapi32 / browser.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: NetAPI DLL
4 * FILE: dll/win32/netapi32/browser.c
5 * PURPOSE: Computer Browser service interface code
6 * PROGRAMMERS: Eric Kohl (eric.kohl@reactos.org)
7 */
8
9 /* INCLUDES ******************************************************************/
10
11 #include "netapi32.h"
12
13 #include <rpc.h>
14 #include <lmbrowsr.h>
15 #include "browser_c.h"
16
17
18 WINE_DEFAULT_DEBUG_CHANNEL(netapi32);
19
20 /* FUNCTIONS *****************************************************************/
21
22 handle_t __RPC_USER
23 BROWSER_IDENTIFY_HANDLE_bind(BROWSER_IDENTIFY_HANDLE pszSystemName)
24 {
25 handle_t hBinding = NULL;
26 LPWSTR pszStringBinding;
27 RPC_STATUS status;
28
29 TRACE("BROWSER_IDENTIFY_HANDLE_bind() called\n");
30
31 status = RpcStringBindingComposeW(NULL,
32 L"ncacn_np",
33 pszSystemName,
34 L"\\pipe\\browser",
35 NULL,
36 &pszStringBinding);
37 if (status)
38 {
39 TRACE("RpcStringBindingCompose returned 0x%x\n", status);
40 return NULL;
41 }
42
43 /* Set the binding handle that will be used to bind to the server. */
44 status = RpcBindingFromStringBindingW(pszStringBinding,
45 &hBinding);
46 if (status)
47 {
48 TRACE("RpcBindingFromStringBinding returned 0x%x\n", status);
49 }
50
51 status = RpcStringFreeW(&pszStringBinding);
52 if (status)
53 {
54 // TRACE("RpcStringFree returned 0x%x\n", status);
55 }
56
57 return hBinding;
58 }
59
60
61 void __RPC_USER
62 BROWSER_IDENTIFY_HANDLE_unbind(BROWSER_IDENTIFY_HANDLE pszSystemName,
63 handle_t hBinding)
64 {
65 RPC_STATUS status;
66
67 TRACE("BROWSER_IDENTIFY_HANDLE_unbind() called\n");
68
69 status = RpcBindingFree(&hBinding);
70 if (status)
71 {
72 TRACE("RpcBindingFree returned 0x%x\n", status);
73 }
74 }
75
76
77 NET_API_STATUS
78 WINAPI
79 I_BrowserQueryEmulatedDomains(
80 _In_opt_ LPWSTR ServerName,
81 _Out_ PBROWSER_EMULATED_DOMAIN *EmulatedDomains,
82 _Out_ LPDWORD EntriesRead)
83 {
84 BROWSER_EMULATED_DOMAIN_CONTAINER Container = {0, NULL};
85 NET_API_STATUS status;
86
87 TRACE("I_BrowserQueryEmulatedDomains(%s %p %p)\n",
88 debugstr_w(ServerName), EmulatedDomains, EntriesRead);
89
90 *EmulatedDomains = NULL;
91 *EntriesRead = 0;
92
93 RpcTryExcept
94 {
95 status = I_BrowserrQueryEmulatedDomains(ServerName,
96 &Container);
97
98 if (status == NERR_Success)
99 {
100 *EmulatedDomains = (PBROWSER_EMULATED_DOMAIN)Container.Buffer;
101 *EntriesRead = Container.EntriesRead;
102 }
103 }
104 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
105 {
106 status = I_RpcMapWin32Status(RpcExceptionCode());
107 }
108 RpcEndExcept;
109
110 return status;
111 }
112
113
114 NET_API_STATUS
115 WINAPI
116 I_BrowserResetStatistics(
117 _In_opt_ LPCWSTR ServerName)
118 {
119 NET_API_STATUS status;
120
121 TRACE("I_BrowserResetStatistics(%s)\n",
122 debugstr_w(ServerName));
123
124 RpcTryExcept
125 {
126 status = I_BrowserrResetStatistics((PWSTR)ServerName);
127 }
128 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
129 {
130 status = I_RpcMapWin32Status(RpcExceptionCode());
131 }
132 RpcEndExcept;
133
134 return status;
135 }
136
137
138 NET_API_STATUS
139 WINAPI
140 I_BrowserSetNetlogonState(
141 _In_ LPWSTR ServerName,
142 _In_ LPWSTR DomainName,
143 _In_ LPWSTR EmulatedServerName,
144 _In_ DWORD Role)
145 {
146 NET_API_STATUS status;
147
148 TRACE("I_BrowserSetNetlogonState(%s %s %s %lu)\n",
149 debugstr_w(ServerName), debugstr_w(ServerName),
150 debugstr_w(EmulatedServerName), Role);
151
152 RpcTryExcept
153 {
154 status = I_BrowserrSetNetlogonState(ServerName,
155 DomainName,
156 EmulatedServerName,
157 Role);
158 }
159 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
160 {
161 status = I_RpcMapWin32Status(RpcExceptionCode());
162 }
163 RpcEndExcept;
164
165 return status;
166 }
167
168
169 NET_API_STATUS
170 WINAPI
171 NetServerEnum(
172 _In_opt_ LMCSTR servername,
173 _In_ DWORD level,
174 _Out_ LPBYTE *bufptr,
175 _In_ DWORD prefmaxlen,
176 _Out_ LPDWORD entriesread,
177 _Out_ LPDWORD totalentries,
178 _In_ DWORD servertype,
179 _In_opt_ LMCSTR domain,
180 _Inout_opt_ LPDWORD resume_handle)
181 {
182 FIXME("NetServerEnum(%s %lu %p %lu %p %p %lu %s %p)\n",
183 debugstr_w(servername), level, bufptr, prefmaxlen, entriesread,
184 totalentries, servertype, debugstr_w(domain), resume_handle);
185
186 return ERROR_NO_BROWSER_SERVERS_FOUND;
187 }
188
189
190 NET_API_STATUS
191 WINAPI
192 NetServerEnumEx(
193 _In_opt_ LMCSTR ServerName,
194 _In_ DWORD Level,
195 _Out_ LPBYTE *Bufptr,
196 _In_ DWORD PrefMaxlen,
197 _Out_ LPDWORD EntriesRead,
198 _Out_ LPDWORD totalentries,
199 _In_ DWORD servertype,
200 _In_opt_ LMCSTR domain,
201 _In_opt_ LMCSTR FirstNameToReturn)
202 {
203 FIXME("NetServerEnumEx(%s %lu %p %lu %p %p %lu %s %s)\n",
204 debugstr_w(ServerName), Level, Bufptr, PrefMaxlen, EntriesRead, totalentries,
205 servertype, debugstr_w(domain), debugstr_w(FirstNameToReturn));
206
207 return ERROR_NO_BROWSER_SERVERS_FOUND;
208 }
209
210 /* EOF */