root/source4/lib/com/classes/simple.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. simple_IUnknown_QueryInterface
  2. simple_IUnknown_AddRef
  3. simple_IUnknown_Release
  4. simple_IStream_Read
  5. simple_IStream_Write
  6. simpleclass_IUnknown_QueryInterface
  7. simpleclass_IClassFactory_CreateInstance
  8. simpleclass_IUnknown_AddRef
  9. simpleclass_IUnknown_Release
  10. com_simple_init

   1 /*
   2    Unix SMB/CIFS implementation.
   3    Simple class
   4    Copyright (C) 2004-2005 Jelmer Vernooij <jelmer@samba.org>
   5 
   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.
  10 
  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.
  15 
  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.
  19 */
  20 
  21 #include "includes.h"
  22 #include "lib/com/com.h"
  23 #include "librpc/gen_ndr/com_dcom.h"
  24 
  25 static struct IClassFactory_vtable simple_classobject_vtable;
  26 static struct IStream_vtable simple_IStream_vtable;
  27 
  28 static WERROR simple_IUnknown_QueryInterface (struct IUnknown *d, TALLOC_CTX *mem_ctx, struct GUID *iid, struct IUnknown **iun)
     /* [<][>][^][v][top][bottom][index][help] */
  29 {
  30         *iun = d;
  31         return WERR_OK;
  32 }
  33 
  34 static uint32_t simple_IUnknown_AddRef (struct IUnknown *d, TALLOC_CTX *mem_ctx)
     /* [<][>][^][v][top][bottom][index][help] */
  35 {
  36         return 1;
  37 }
  38 
  39 static uint32_t simple_IUnknown_Release (struct IUnknown *d, TALLOC_CTX *mem_ctx)
     /* [<][>][^][v][top][bottom][index][help] */
  40 {
  41         return 1;
  42 }
  43 
  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)
     /* [<][>][^][v][top][bottom][index][help] */
  45 {
  46         printf("%d bytes are being read\n", num_read);
  47         return WERR_OK;
  48 }
  49 
  50 static WERROR simple_IStream_Write (struct IStream *d, TALLOC_CTX *mem_ctx, uint8_t *data, uint32_t num_requested, uint32_t num_written)
     /* [<][>][^][v][top][bottom][index][help] */
  51 {
  52         printf("%d bytes are being written\n", num_requested);
  53         return WERR_OK;
  54 }
  55 
  56 static WERROR simpleclass_IUnknown_QueryInterface (struct IUnknown *d, TALLOC_CTX *mem_ctx, struct GUID *iid, struct IUnknown **iun)
     /* [<][>][^][v][top][bottom][index][help] */
  57 {
  58         /* FIXME: Return WERR_IFACE_NOT_SUPPORTED if IID != IID_IUNKNOWN and IID != IID_CLASSFACTORY */
  59         *iun = d;
  60         return WERR_OK;
  61 }
  62 
  63 static WERROR simpleclass_IClassFactory_CreateInstance (struct IClassFactory *d, TALLOC_CTX *mem_ctx, struct IUnknown *iunk, struct GUID *iid, struct IUnknown **ppv)
     /* [<][>][^][v][top][bottom][index][help] */
  64 {
  65         struct IStream *ret;
  66         /* FIXME: Check whether IID == ISTREAM_IID */
  67         ret = talloc(mem_ctx, struct IStream);
  68         ret->ctx = NULL;
  69         ret->vtable = &simple_IStream_vtable;
  70         ret->object_data = NULL;
  71 
  72         *ppv = (struct IUnknown *)ret;
  73         
  74         return WERR_OK;
  75 }
  76 
  77 static uint32_t simpleclass_IUnknown_AddRef (struct IUnknown *d, TALLOC_CTX *mem_ctx)
     /* [<][>][^][v][top][bottom][index][help] */
  78 {
  79         return 1;
  80 }
  81 
  82 static uint32_t simpleclass_IUnknown_Release (struct IUnknown *d, TALLOC_CTX *mem_ctx)
     /* [<][>][^][v][top][bottom][index][help] */
  83 {
  84         return 1;
  85 }
  86 
  87 /* Everything below this line should be autogenerated later on */
  88 static struct IClassFactory_vtable simple_classobject_vtable = {
  89         { 0, 0, 0, { 0, 0 }, { 0, 0, 0, 0, 0, 0 } },
  90         simpleclass_IUnknown_QueryInterface, 
  91         simpleclass_IUnknown_AddRef, 
  92         simpleclass_IUnknown_Release,
  93         simpleclass_IClassFactory_CreateInstance,
  94         NULL,
  95         NULL,
  96         NULL
  97 };
  98 
  99 static struct IStream_vtable simple_IStream_vtable = {
 100         { 0, 0, 0, { 0, 0 }, { 0, 0, 0, 0, 0, 0 } },
 101         simple_IUnknown_QueryInterface,
 102         simple_IUnknown_AddRef, 
 103         simple_IUnknown_Release,
 104         simple_IStream_Read,
 105         simple_IStream_Write
 106 };
 107 
 108 NTSTATUS com_simple_init(void)
     /* [<][>][^][v][top][bottom][index][help] */
 109 {
 110         struct GUID clsid;
 111         struct IUnknown *class_object = talloc(talloc_autofree_context(), struct IUnknown);
 112 
 113         class_object->ctx = NULL;
 114         class_object->object_data = NULL;
 115         class_object->vtable = (struct IUnknown_vtable *)&simple_classobject_vtable;
 116 
 117         GUID_from_string(CLSID_SIMPLE, &clsid);
 118         GUID_from_string(COM_ICLASSFACTORY_UUID, &simple_classobject_vtable.iid);
 119         GUID_from_string(COM_ISTREAM_UUID, &simple_IStream_vtable.iid);
 120 
 121         return com_register_running_class(&clsid, PROGID_SIMPLE, class_object);
 122 }

/* [<][>][^][v][top][bottom][index][help] */