ReactOS  0.4.14-dev-608-gd495a4f
enummoniker.c
Go to the documentation of this file.
1 /*
2  * IEnumMoniker implementation
3  *
4  * Copyright 2003 Robert Shearman
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library 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 GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20 
21 #define COBJMACROS
22 
23 #include "quartz_private.h"
24 
25 #include "wine/debug.h"
26 
28 
29 typedef struct EnumMonikerImpl
30 {
32  LONG ref;
37 
38 static const IEnumMonikerVtbl EnumMonikerImpl_Vtbl;
39 
41 {
42  return CONTAINING_RECORD(iface, EnumMonikerImpl, IEnumMoniker_iface);
43 }
44 
46 
47 HRESULT EnumMonikerImpl_Create(IMoniker ** ppMoniker, ULONG nMonikerCount, IEnumMoniker ** ppEnum)
48 {
49  /* NOTE: assumes that array of IMonikers has already been AddRef'd
50  * I.e. this function does not AddRef the array of incoming
51  * IMonikers */
53 
54  TRACE("(%p, %d, %p)\n", ppMoniker, nMonikerCount, ppEnum);
55 
56  *ppEnum = NULL;
57 
58  if (!pemi)
59  return E_OUTOFMEMORY;
60 
62  pemi->ref = 1;
63  pemi->ppMoniker = CoTaskMemAlloc(nMonikerCount * sizeof(IMoniker*));
64  memcpy(pemi->ppMoniker, ppMoniker, nMonikerCount*sizeof(IMoniker*));
65  pemi->nMonikerCount = nMonikerCount;
66  pemi->index = 0;
67 
68  *ppEnum = &pemi->IEnumMoniker_iface;
69 
70  return S_OK;
71 }
72 
73 /**********************************************************************
74  * IEnumMoniker_QueryInterface (also IUnknown)
75  */
77  LPENUMMONIKER iface,
78  REFIID riid,
79  LPVOID *ppvObj)
80 {
82  TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
83 
84  if (This == NULL || ppvObj == NULL) return E_POINTER;
85 
86  if (IsEqualGUID(riid, &IID_IUnknown) ||
88  {
89  *ppvObj = iface;
91  return S_OK;
92  }
93 
94  *ppvObj = NULL;
95  FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
96  return E_NOINTERFACE;
97 }
98 
99 /**********************************************************************
100  * IEnumMoniker_AddRef (also IUnknown)
101  */
103 {
105  ULONG ref;
106 
107  if (This == NULL) return E_POINTER;
108 
109  ref = InterlockedIncrement(&This->ref);
110 
111  TRACE("(%p)->() AddRef from %d\n", iface, ref - 1);
112 
113  return ref;
114 }
115 
116 /**********************************************************************
117  * IEnumMoniker_Release (also IUnknown)
118  */
120 {
123 
124  TRACE("(%p)->() Release from %d\n", iface, ref + 1);
125 
126  if (!ref)
127  {
128  ULONG i;
129 
130  for (i = 0; i < This->nMonikerCount; i++)
131  IMoniker_Release(This->ppMoniker[i]);
132 
133  CoTaskMemFree(This->ppMoniker);
134  This->ppMoniker = NULL;
136  return 0;
137  }
138  return ref;
139 }
140 
141 static HRESULT WINAPI EnumMonikerImpl_Next(LPENUMMONIKER iface, ULONG celt, IMoniker ** rgelt, ULONG * pceltFetched)
142 {
143  ULONG fetched;
145 
146  TRACE("(%p)->(%d, %p, %p)\n", iface, celt, rgelt, pceltFetched);
147 
148  for (fetched = 0; (This->index + fetched < This->nMonikerCount) && (fetched < celt); fetched++)
149  {
150  rgelt[fetched] = This->ppMoniker[This->index + fetched];
151  IMoniker_AddRef(rgelt[fetched]);
152  }
153 
154  This->index += fetched;
155 
156  TRACE("-- fetched %d\n", fetched);
157 
158  if (pceltFetched)
159  *pceltFetched = fetched;
160 
161  if (fetched != celt)
162  return S_FALSE;
163  else
164  return S_OK;
165 }
166 
168 {
170 
171  TRACE("(%p)->(%d)\n", iface, celt);
172 
173  This->index += celt;
174 
175  return S_OK;
176 }
177 
179 {
181 
182  TRACE("(%p)->()\n", iface);
183 
184  This->index = 0;
185 
186  return S_OK;
187 }
188 
190 {
191  FIXME("(%p)->(%p): stub\n", iface, ppenum);
192 
193  return E_NOTIMPL;
194 }
195 
196 /**********************************************************************
197  * IEnumMoniker_Vtbl
198  */
199 static const IEnumMonikerVtbl EnumMonikerImpl_Vtbl =
200 {
208 };
#define REFIID
Definition: guiddef.h:118
ULONG nMonikerCount
Definition: enummoniker.c:34
#define E_NOINTERFACE
Definition: winerror.h:2364
IMoniker ** ppMoniker
Definition: enummoniker.c:33
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:420
REFIID riid
Definition: precomp.h:44
static HRESULT WINAPI EnumMonikerImpl_Next(LPENUMMONIKER iface, ULONG celt, IMoniker **rgelt, ULONG *pceltFetched)
Definition: enummoniker.c:141
static HRESULT WINAPI EnumMonikerImpl_Skip(LPENUMMONIKER iface, ULONG celt)
Definition: enummoniker.c:167
const GUID IID_IEnumMoniker
Definition: send.c:47
IEnumMoniker IEnumMoniker_iface
Definition: mediacatenum.c:36
static HRESULT WINAPI EnumMonikerImpl_Reset(LPENUMMONIKER iface)
Definition: enummoniker.c:178
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
long LONG
Definition: pedump.c:60
GLenum GLint ref
Definition: glext.h:6028
#define FIXME(fmt,...)
Definition: debug.h:110
interface IEnumMoniker * LPENUMMONIKER
Definition: objfwd.h:23
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
static HRESULT WINAPI EnumMonikerImpl_Clone(LPENUMMONIKER iface, IEnumMoniker **ppenum)
Definition: enummoniker.c:189
static EnumMonikerImpl * impl_from_IEnumMoniker(IEnumMoniker *iface)
Definition: enummoniker.c:40
#define debugstr_guid
Definition: kernel32.h:35
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
static ULONG WINAPI EnumMonikerImpl_AddRef(LPENUMMONIKER iface)
Definition: enummoniker.c:102
struct EnumMonikerImpl EnumMonikerImpl
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
static HRESULT WINAPI EnumMonikerImpl_QueryInterface(LPENUMMONIKER iface, REFIID riid, LPVOID *ppvObj)
Definition: enummoniker.c:76
HRESULT EnumMonikerImpl_Create(IMoniker **ppMoniker, ULONG nMonikerCount, IEnumMoniker **ppEnum)
Definition: enummoniker.c:47
#define WINAPI
Definition: msvc.h:6
#define InterlockedDecrement
Definition: armddk.h:52
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static ULONG WINAPI EnumMonikerImpl_Release(LPENUMMONIKER iface)
Definition: enummoniker.c:119
#define S_OK
Definition: intsafe.h:59
#define InterlockedIncrement
Definition: armddk.h:53
#define E_NOTIMPL
Definition: ddrawi.h:99
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
unsigned int ULONG
Definition: retypes.h:1
static const IEnumMonikerVtbl EnumMonikerImpl_Vtbl
Definition: enummoniker.c:38
WINE_DEFAULT_DEBUG_CHANNEL(quartz)
#define E_POINTER
Definition: winerror.h:2365
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:404