dsdb-acl: fix the order of special and system checks
[Samba/gebeck_regimport.git] / source4 / lib / com / classes / simple.c
blob367ce9d6319bc991fb92028bb3aa35e9c61a9829
1 /*
2 Unix SMB/CIFS implementation.
3 Simple class
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.
21 #include "includes.h"
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)
32 *iun = d;
33 return WERR_OK;
36 static uint32_t simple_IUnknown_AddRef (struct IUnknown *d, TALLOC_CTX *mem_ctx)
38 return 1;
41 static uint32_t simple_IUnknown_Release (struct IUnknown *d, TALLOC_CTX *mem_ctx)
43 return 1;
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);
49 return WERR_OK;
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);
55 return WERR_OK;
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 */
61 *iun = d;
62 return WERR_OK;
65 static WERROR simpleclass_IClassFactory_CreateInstance (struct IClassFactory *d, TALLOC_CTX *mem_ctx, struct IUnknown *iunk, struct GUID *iid, struct IUnknown **ppv)
67 struct IStream *ret;
68 /* FIXME: Check whether IID == ISTREAM_IID */
69 ret = talloc(mem_ctx, struct IStream);
70 ret->ctx = NULL;
71 ret->vtable = &simple_IStream_vtable;
72 ret->object_data = NULL;
74 *ppv = (struct IUnknown *)ret;
76 return WERR_OK;
79 static uint32_t simpleclass_IUnknown_AddRef (struct IUnknown *d, TALLOC_CTX *mem_ctx)
81 return 1;
84 static uint32_t simpleclass_IUnknown_Release (struct IUnknown *d, TALLOC_CTX *mem_ctx)
86 return 1;
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,
96 NULL,
97 NULL,
98 NULL
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,
106 simple_IStream_Read,
107 simple_IStream_Write
110 NTSTATUS com_simple_init(void)
112 struct GUID clsid;
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);