2 Unix SMB/CIFS implementation.
4 Copyright (C) 2004-2005 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.
22 #include "lib/com/com.h"
23 #include "librpc/gen_ndr/com_dcom.h"
25 extern const struct IClassFactory_vtable simple_classobject_vtable;
26 extern const struct IStream_vtable simple_IStream_vtable;
28 static WERROR simple_IUnknown_QueryInterface (struct IUnknown *d, TALLOC_CTX *mem_ctx, struct GUID *iid, struct IUnknown **iun)
34 static uint32_t simple_IUnknown_AddRef (struct IUnknown *d, TALLOC_CTX *mem_ctx)
39 static uint32_t simple_IUnknown_Release (struct IUnknown *d, TALLOC_CTX *mem_ctx)
44 static WERROR simple_IStream_Read (struct IStream *d, TALLOC_CTX *mem_ctx, uint8_t *pv, uint32_t num_requested, uint32_t *num_readx, uint32_t num_read)
46 printf("%d bytes are being read\n", num_read);
50 static WERROR simple_IStream_Write (struct IStream *d, TALLOC_CTX *mem_ctx, uint8_t *data, uint32_t num_requested, uint32_t num_written)
52 printf("%d bytes are being written\n", num_requested);
56 static WERROR simpleclass_IUnknown_QueryInterface (struct IUnknown *d, TALLOC_CTX *mem_ctx, struct GUID *iid, struct IUnknown **iun)
58 /* FIXME: Return WERR_IFACE_NOT_SUPPORTED if IID != IID_IUNKNOWN and IID != IID_CLASSFACTORY */
63 static WERROR simpleclass_IClassFactory_CreateInstance (struct IClassFactory *d, TALLOC_CTX *mem_ctx, struct IUnknown *iunk, struct GUID *iid, struct IUnknown **ppv)
66 /* FIXME: Check whether IID == ISTREAM_IID */
67 ret = talloc(mem_ctx, struct IStream);
69 ret->vtable = &simple_IStream_vtable;
70 ret->object_data = NULL;
77 static uint32_t simpleclass_IUnknown_AddRef (struct IUnknown *d, TALLOC_CTX *mem_ctx)
82 static uint32_t simpleclass_IUnknown_Release (struct IUnknown *d, TALLOC_CTX *mem_ctx)
87 /* Everything below this line should be autogenerated later on */
88 const struct IClassFactory_vtable simple_classobject_vtable = {
89 simpleclass_IUnknown_QueryInterface,
90 simpleclass_IUnknown_AddRef,
91 simpleclass_IUnknown_Release,
92 simpleclass_IClassFactory_CreateInstance,
98 const struct IStream_vtable simple_IStream_vtable = {
99 simple_IUnknown_QueryInterface,
100 simple_IUnknown_AddRef,
101 simple_IUnknown_Release,
106 NTSTATUS com_simple_init(void)
109 struct IUnknown *class_object = talloc(talloc_autofree_context(), struct IUnknown);
111 class_object->ctx = NULL;
112 class_object->object_data = NULL;
113 class_object->vtable = (struct IUnknown_vtable *)&simple_classobject_vtable;
115 GUID_from_string(CLSID_SIMPLE, &clsid);
117 return com_register_running_class(&clsid, PROGID_SIMPLE, class_object);