ReactOS 0.4.15-dev-7942-gd23573b
epmp.c
Go to the documentation of this file.
1/*
2 * Endpoint Mapper
3 *
4 * Copyright (C) 2007 Robert Shearman for CodeWeavers
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#include "epm_s.h"
22
23#include "wine/debug.h"
24#include "wine/list.h"
25
27
29{
30 struct list entry;
34 char *protseq;
35 char *endpoint;
36 char *address;
37 char annotation[ept_max_annotation_size];
38};
39
41
44{
45 0, 0, &csEpm,
47 0, 0, { (DWORD_PTR)(__FILE__ ": csEpm") }
48};
49static CRITICAL_SECTION csEpm = { &critsect_debug, -1, 0, 0, 0, 0 };
50
51static const UUID nil_object;
52
53/* must be called inside csEpm */
55{
56 I_RpcFree(entry->protseq);
57 I_RpcFree(entry->endpoint);
58 I_RpcFree(entry->address);
59 list_remove(&entry->entry);
61}
62
65 const char *protseq, const char *endpoint, const char *address,
66 const UUID *object)
67{
70 {
71 if (memcmp(&entry->iface, iface, sizeof(RPC_SYNTAX_IDENTIFIER))) continue;
72 if (memcmp(&entry->syntax, syntax, sizeof(RPC_SYNTAX_IDENTIFIER))) continue;
73 if (strcmp(entry->protseq, protseq)) continue;
74 if (memcmp(&entry->object, object, sizeof(UUID))) continue;
75 WINE_TRACE("found entry with iface %d.%d %s, syntax %d.%d %s, protseq %s, object %s\n",
76 entry->iface.SyntaxVersion.MajorVersion, entry->iface.SyntaxVersion.MinorVersion,
77 wine_dbgstr_guid(&entry->iface.SyntaxGUID),
78 entry->syntax.SyntaxVersion.MajorVersion, entry->syntax.SyntaxVersion.MinorVersion,
79 wine_dbgstr_guid(&entry->syntax.SyntaxGUID), protseq,
80 wine_dbgstr_guid(&entry->object));
81 return entry;
82 }
83 WINE_TRACE("not found\n");
84 return NULL;
85}
86
87void __RPC_USER ept_lookup_handle_t_rundown(ept_lookup_handle_t entry_handle)
88{
89 WINE_FIXME("%p\n", entry_handle);
90}
91
93 unsigned32 num_ents,
94 ept_entry_t entries[],
97{
99 RPC_STATUS rpc_status;
100
101 WINE_TRACE("(%p, %u, %p, %u, %p)\n", h, num_ents, entries, replace, status);
102
103 *status = RPC_S_OK;
104
106
107 for (i = 0; i < num_ents; i++)
108 {
109 struct registered_ept_entry *entry = HeapAlloc(GetProcessHeap(), 0, sizeof(*entry));
110 if (!entry)
111 {
112 /* FIXME: cleanup code to delete added entries */
114 break;
115 }
116 memcpy(entry->annotation, entries[i].annotation, sizeof(entries[i].annotation));
117 rpc_status = TowerExplode(entries[i].tower, &entry->iface, &entry->syntax,
118 &entry->protseq, &entry->endpoint,
119 &entry->address);
120 if (rpc_status != RPC_S_OK)
121 {
122 WINE_WARN("TowerExplode failed %u\n", rpc_status);
123 *status = rpc_status;
125 break; /* FIXME: more cleanup? */
126 }
127
128 entry->object = entries[i].object;
129
130 if (replace)
131 {
132 /* FIXME: correct find algorithm */
133 struct registered_ept_entry *old_entry = find_ept_entry(&entry->iface, &entry->syntax, entry->protseq, entry->endpoint, entry->address, &entry->object);
134 if (old_entry) delete_registered_ept_entry(old_entry);
135 }
137 }
138
140}
141
143 unsigned32 num_ents,
144 ept_entry_t entries[],
146{
148 RPC_STATUS rpc_status;
149
150 *status = RPC_S_OK;
151
152 WINE_TRACE("(%p, %u, %p, %p)\n", h, num_ents, entries, status);
153
155
156 for (i = 0; i < num_ents; i++)
157 {
160 char *protseq;
161 char *endpoint;
162 char *address;
163 rpc_status = TowerExplode(entries[i].tower, &iface, &syntax, &protseq,
164 &endpoint, &address);
165 if (rpc_status != RPC_S_OK)
166 break;
167 entry = find_ept_entry(&iface, &syntax, protseq, endpoint, address, &entries[i].object);
168
172
173 if (entry)
175 else
176 {
178 break;
179 }
180 }
181
183}
184
186 unsigned32 inquiry_type,
187 uuid_p_t object,
188 rpc_if_id_p_t interface_id,
189 unsigned32 vers_option,
190 ept_lookup_handle_t *entry_handle,
191 unsigned32 max_ents,
192 unsigned32 *num_ents,
193 ept_entry_t entries[],
195{
196 WINE_FIXME("(%p, %p, %p): stub\n", h, entry_handle, status);
197
199}
200
202 uuid_p_t object,
203 twr_p_t map_tower,
204 ept_lookup_handle_t *entry_handle,
205 unsigned32 max_towers,
206 unsigned32 *num_towers,
207 twr_p_t *towers,
209{
210 RPC_STATUS rpc_status;
212 char *protseq;
214
215 *status = RPC_S_OK;
216 *num_towers = 0;
217
218 WINE_TRACE("(%p, %p, %p, %p, %u, %p, %p, %p)\n", h, object, map_tower,
219 entry_handle, max_towers, num_towers, towers, status);
220
221 rpc_status = TowerExplode(map_tower, &iface, &syntax, &protseq,
222 NULL, NULL);
223 if (rpc_status != RPC_S_OK)
224 {
225 *status = rpc_status;
226 return;
227 }
228
230
232 {
233 if (IsEqualGUID(&entry->iface.SyntaxGUID, &iface.SyntaxGUID) &&
234 (entry->iface.SyntaxVersion.MajorVersion == iface.SyntaxVersion.MajorVersion) &&
235 (entry->iface.SyntaxVersion.MinorVersion >= iface.SyntaxVersion.MinorVersion) &&
236 !memcmp(&entry->syntax, &syntax, sizeof(syntax)) &&
237 !strcmp(entry->protseq, protseq) &&
238 ((!object && IsEqualGUID(&entry->object, &nil_object)) || IsEqualGUID(object, &entry->object)))
239 {
240 if (*num_towers < max_towers)
241 {
242 rpc_status = TowerConstruct(&entry->iface, &entry->syntax,
243 entry->protseq, entry->endpoint,
244 entry->address,
245 &towers[*num_towers]);
246 if (rpc_status != RPC_S_OK)
247 {
248 *status = rpc_status;
249 break; /* FIXME: more cleanup? */
250 }
251 }
252 (*num_towers)++;
253 }
254 }
255
257
259}
260
262 ept_lookup_handle_t *entry_handle,
264{
265 WINE_FIXME("(%p, %p, %p): stub\n", h, entry_handle, status);
266
268}
269
271 GUID *ept_object,
273{
274 WINE_FIXME("(%p, %p, %p): stub\n", h, ept_object, status);
275
277}
278
280 boolean32 object_speced,
281 uuid_p_t object,
282 twr_p_t tower,
284{
285 WINE_FIXME("(%p, %d, %p, %p, %p): stub\n", h, object_speced, object, tower, status);
286
288}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define __cdecl
Definition: accygwin.h:79
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
static void list_remove(struct list_entry *entry)
Definition: list.h:90
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
unsigned long error_status_t
Definition: basetyps.h:83
Definition: list.h:37
unsigned32 boolean32
Definition: dcetypes.idl:30
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
static struct registered_ept_entry * find_ept_entry(const RPC_SYNTAX_IDENTIFIER *iface, const RPC_SYNTAX_IDENTIFIER *syntax, const char *protseq, const char *endpoint, const char *address, const UUID *object)
Definition: epmp.c:63
void __cdecl ept_delete(handle_t h, unsigned32 num_ents, ept_entry_t entries[], error_status_t *status)
Definition: epmp.c:142
void __cdecl ept_lookup(handle_t h, unsigned32 inquiry_type, uuid_p_t object, rpc_if_id_p_t interface_id, unsigned32 vers_option, ept_lookup_handle_t *entry_handle, unsigned32 max_ents, unsigned32 *num_ents, ept_entry_t entries[], error_status_t *status)
Definition: epmp.c:185
void __cdecl ept_insert(handle_t h, unsigned32 num_ents, ept_entry_t entries[], boolean32 replace, error_status_t *status)
Definition: epmp.c:92
static CRITICAL_SECTION_DEBUG critsect_debug
Definition: epmp.c:43
void __cdecl ept_mgmt_delete(handle_t h, boolean32 object_speced, uuid_p_t object, twr_p_t tower, error_status_t *status)
Definition: epmp.c:279
void __cdecl ept_inq_object(handle_t h, GUID *ept_object, error_status_t *status)
Definition: epmp.c:270
static const UUID nil_object
Definition: epmp.c:51
void __cdecl ept_lookup_handle_free(handle_t h, ept_lookup_handle_t *entry_handle, error_status_t *status)
Definition: epmp.c:261
void __RPC_USER ept_lookup_handle_t_rundown(ept_lookup_handle_t entry_handle)
Definition: epmp.c:87
static void delete_registered_ept_entry(struct registered_ept_entry *entry)
Definition: epmp.c:54
static CRITICAL_SECTION csEpm
Definition: epmp.c:42
static struct list registered_ept_entry_list
Definition: epmp.c:40
void __cdecl ept_map(handle_t h, uuid_p_t object, twr_p_t map_tower, ept_lookup_handle_t *entry_handle, unsigned32 max_towers, unsigned32 *num_towers, twr_p_t *towers, error_status_t *status)
Definition: epmp.c:201
GLuint address
Definition: glext.h:9393
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
uint32_t entry
Definition: isohybrid.c:63
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned int unsigned32
Definition: rpc.c:43
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
INT replace(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], DWORD dwFlags, BOOL *doMore)
Definition: replace.c:47
RPC_STATUS WINAPI TowerExplode(const twr_t *tower, PRPC_SYNTAX_IDENTIFIER object, PRPC_SYNTAX_IDENTIFIER syntax, char **protseq, char **endpoint, char **address)
Definition: rpc_epmap.c:524
RPC_STATUS WINAPI TowerConstruct(const RPC_SYNTAX_IDENTIFIER *object, const RPC_SYNTAX_IDENTIFIER *syntax, const char *protseq, const char *endpoint, const char *address, twr_t **tower)
Definition: rpc_epmap.c:596
#define RPC_S_OK
Definition: rpcnterr.h:22
void WINAPI I_RpcFree(void *Object)
Definition: rpcrt4_main.c:724
long RPC_STATUS
Definition: rpc.h:52
#define __RPC_USER
Definition: rpc.h:65
#define WINE_TRACE
Definition: debug.h:354
#define WINE_WARN
Definition: debug.h:360
#define WINE_FIXME
Definition: debug.h:366
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:197
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
LIST_ENTRY ProcessLocksList
Definition: winbase.h:883
RPC_VERSION SyntaxVersion
Definition: rpcdcep.h:33
unsigned short MajorVersion
Definition: rpcdcep.h:27
unsigned short MinorVersion
Definition: rpcdcep.h:28
Definition: nis.h:10
Definition: epmp.c:29
char annotation[ept_max_annotation_size]
Definition: epmp.c:37
RPC_SYNTAX_IDENTIFIER iface
Definition: epmp.c:32
char * protseq
Definition: epmp.c:34
struct list entry
Definition: epmp.c:30
GUID object
Definition: epmp.c:31
char * endpoint
Definition: epmp.c:35
char * address
Definition: epmp.c:36
RPC_SYNTAX_IDENTIFIER syntax
Definition: epmp.c:33
Definition: ps.c:97
Definition: rpc.c:45
#define LIST_INIT(head)
Definition: queue.h:197
#define DWORD_PTR
Definition: treelist.c:76
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define EPT_S_NOT_REGISTERED
Definition: winerror.h:1061
#define EPT_S_CANT_PERFORM_OP
Definition: winerror.h:1060