r4479: added the function talloc_autofree_context() which returns a talloc context...
[Samba/gebeck_regimport.git] / source / lib / dcom / common / tables.c
blobfaf67710e08c365f42c95fd8594ebd8a8a98df74
1 /*
2 Unix SMB/CIFS implementation.
3 DCOM interface and class tables
4 Copyright (C) 2004 Jelmer Vernooij <jelmer@samba.org>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program 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
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "includes.h"
22 #include "dlinklist.h"
24 static struct class_list {
25 struct class_list *prev, *next;
26 struct dcom_class class;
27 } *classes = NULL;
29 static struct interface_list {
30 struct interface_list *prev, *next;
31 struct dcom_interface interface;
32 } *interfaces = NULL;
34 const struct dcom_interface *dcom_interface_by_iid(const struct GUID *iid)
36 struct interface_list *l = interfaces;
38 while(l) {
40 if (GUID_equal(iid, &l->interface.iid))
41 return &l->interface;
43 l = l->next;
46 return NULL;
49 const struct dcom_class *dcom_class_by_clsid(const struct GUID *clsid)
51 struct class_list *c = classes;
53 while(c) {
55 if (GUID_equal(clsid, &c->class.clsid)) {
56 return &c->class;
59 c = c->next;
62 return NULL;
65 const void *dcom_proxy_vtable_by_iid(const struct GUID *iid)
67 const struct dcom_interface *iface = dcom_interface_by_iid(iid);
69 if (!iface) {
70 return NULL;
73 return iface->proxy_vtable;
76 NTSTATUS dcom_register_interface(const void *_iface)
78 const struct dcom_interface *iface = _iface;
79 struct interface_list *l;
81 l = talloc_zero_p(interfaces?interfaces:talloc_autofree_context(),
82 struct interface_list);
84 l->interface = *iface;
86 DLIST_ADD(interfaces, l);
88 return NT_STATUS_OK;
91 NTSTATUS dcom_register_class(const void *_class)
93 const struct dcom_class *class = _class;
94 struct class_list *l = talloc_zero_p(classes?classes:talloc_autofree_context(),
95 struct class_list);
97 l->class = *class;
99 DLIST_ADD(classes, l);
101 return NT_STATUS_OK;