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 NTSTATUS
com_simple_init(void);
27 static struct IClassFactory_vtable simple_classobject_vtable
;
28 static struct IStream_vtable simple_IStream_vtable
;
30 static WERROR
simple_IUnknown_QueryInterface (struct IUnknown
*d
, TALLOC_CTX
*mem_ctx
, struct GUID
*iid
, struct IUnknown
**iun
)
36 static uint32_t simple_IUnknown_AddRef (struct IUnknown
*d
, TALLOC_CTX
*mem_ctx
)
41 static uint32_t simple_IUnknown_Release (struct IUnknown
*d
, TALLOC_CTX
*mem_ctx
)
46 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
)
48 printf("%d bytes are being read\n", num_read
);
52 static WERROR
simple_IStream_Write (struct IStream
*d
, TALLOC_CTX
*mem_ctx
, uint8_t *data
, uint32_t num_requested
, uint32_t num_written
)
54 printf("%d bytes are being written\n", num_requested
);
58 static WERROR
simpleclass_IUnknown_QueryInterface (struct IUnknown
*d
, TALLOC_CTX
*mem_ctx
, struct GUID
*iid
, struct IUnknown
**iun
)
60 /* FIXME: Return WERR_IFACE_NOT_SUPPORTED if IID != IID_IUNKNOWN and IID != IID_CLASSFACTORY */
65 static WERROR
simpleclass_IClassFactory_CreateInstance (struct IClassFactory
*d
, TALLOC_CTX
*mem_ctx
, struct IUnknown
*iunk
, struct GUID
*iid
, struct IUnknown
**ppv
)
68 /* FIXME: Check whether IID == ISTREAM_IID */
69 ret
= talloc(mem_ctx
, struct IStream
);
71 ret
->vtable
= &simple_IStream_vtable
;
72 ret
->object_data
= NULL
;
74 *ppv
= (struct IUnknown
*)ret
;
79 static uint32_t simpleclass_IUnknown_AddRef (struct IUnknown
*d
, TALLOC_CTX
*mem_ctx
)
84 static uint32_t simpleclass_IUnknown_Release (struct IUnknown
*d
, TALLOC_CTX
*mem_ctx
)
89 /* Everything below this line should be autogenerated later on */
90 static struct IClassFactory_vtable simple_classobject_vtable
= {
91 { 0, 0, 0, { 0, 0 }, { 0, 0, 0, 0, 0, 0 } },
92 simpleclass_IUnknown_QueryInterface
,
93 simpleclass_IUnknown_AddRef
,
94 simpleclass_IUnknown_Release
,
95 simpleclass_IClassFactory_CreateInstance
,
101 static struct IStream_vtable simple_IStream_vtable
= {
102 { 0, 0, 0, { 0, 0 }, { 0, 0, 0, 0, 0, 0 } },
103 simple_IUnknown_QueryInterface
,
104 simple_IUnknown_AddRef
,
105 simple_IUnknown_Release
,
110 NTSTATUS
com_simple_init(void)
113 struct IUnknown
*class_object
= talloc(talloc_autofree_context(), struct IUnknown
);
115 class_object
->ctx
= NULL
;
116 class_object
->object_data
= NULL
;
117 class_object
->vtable
= (struct IUnknown_vtable
*)&simple_classobject_vtable
;
119 GUID_from_string(CLSID_SIMPLE
, &clsid
);
120 GUID_from_string(COM_ICLASSFACTORY_UUID
, &simple_classobject_vtable
.iid
);
121 GUID_from_string(COM_ISTREAM_UUID
, &simple_IStream_vtable
.iid
);
123 return com_register_running_class(&clsid
, PROGID_SIMPLE
, class_object
);