ReactOS  0.4.13-dev-92-gf251225
enumregfilters.c
Go to the documentation of this file.
1 /*
2  * Implementation of IEnumRegFilters Interface
3  *
4  * Copyright 2004 Christian Costa
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 #include "quartz_private.h"
22 
23 #include "wine/unicode.h"
24 
25 #include "wine/debug.h"
26 
28 
29 typedef struct IEnumRegFiltersImpl
30 {
37 
39 {
40  return CONTAINING_RECORD(iface, IEnumRegFiltersImpl, IEnumRegFilters_iface);
41 }
42 
43 static const struct IEnumRegFiltersVtbl IEnumRegFiltersImpl_Vtbl;
44 
46 {
47  IEnumRegFiltersImpl* pEnumRegFilters;
48  REGFILTER* pRegFilters = NULL;
49  unsigned int i;
50 
51  TRACE("(%p, %d, %p)\n", pInRegFilters, size, ppEnum);
52 
53  pEnumRegFilters = CoTaskMemAlloc(sizeof(IEnumRegFiltersImpl));
54  if (!pEnumRegFilters)
55  {
56  *ppEnum = NULL;
57  return E_OUTOFMEMORY;
58  }
59 
60  /* Accept size of 0 */
61  if (size)
62  {
63  pRegFilters = CoTaskMemAlloc(sizeof(REGFILTER)*size);
64  if (!pRegFilters)
65  {
66  CoTaskMemFree(pEnumRegFilters);
67  *ppEnum = NULL;
68  return E_OUTOFMEMORY;
69  }
70  }
71 
72  for(i = 0; i < size; i++)
73  {
74  pRegFilters[i].Clsid = pInRegFilters[i].Clsid;
75  pRegFilters[i].Name = CoTaskMemAlloc((strlenW(pInRegFilters[i].Name)+1)*sizeof(WCHAR));
76  if (!pRegFilters[i].Name)
77  {
78  while(i)
79  CoTaskMemFree(pRegFilters[--i].Name);
80  CoTaskMemFree(pRegFilters);
81  CoTaskMemFree(pEnumRegFilters);
82  return E_OUTOFMEMORY;
83  }
84  CopyMemory(pRegFilters[i].Name, pInRegFilters[i].Name, (strlenW(pInRegFilters[i].Name)+1)*sizeof(WCHAR));
85  }
86 
87  pEnumRegFilters->IEnumRegFilters_iface.lpVtbl = &IEnumRegFiltersImpl_Vtbl;
88  pEnumRegFilters->refCount = 1;
89  pEnumRegFilters->uIndex = 0;
90  pEnumRegFilters->RegFilters = pRegFilters;
91  pEnumRegFilters->size = size;
92 
93  *ppEnum = &pEnumRegFilters->IEnumRegFilters_iface;
94 
95  return S_OK;
96 }
97 
99 {
100  TRACE("(%p)->(%s, %p)\n", iface, qzdebugstr_guid(riid), ppv);
101 
102  *ppv = NULL;
103 
105  *ppv = iface;
106  else if (IsEqualIID(riid, &IID_IEnumRegFilters))
107  *ppv = iface;
108 
109  if (*ppv)
110  {
111  IUnknown_AddRef((IUnknown *)(*ppv));
112  return S_OK;
113  }
114 
115  FIXME("No interface for %s!\n", qzdebugstr_guid(riid));
116 
117  return E_NOINTERFACE;
118 }
119 
121 {
123  ULONG refCount = InterlockedIncrement(&This->refCount);
124 
125  TRACE("(%p)\n", iface);
126 
127  return refCount;
128 }
129 
131 {
133  ULONG refCount = InterlockedDecrement(&This->refCount);
134 
135  TRACE("(%p)\n", iface);
136 
137  if (!refCount)
138  {
139  ULONG i;
140 
141  for(i = 0; i < This->size; i++)
142  {
143  CoTaskMemFree(This->RegFilters[i].Name);
144  }
145  CoTaskMemFree(This->RegFilters);
147  return 0;
148  } else
149  return refCount;
150 }
151 
152 static HRESULT WINAPI IEnumRegFiltersImpl_Next(IEnumRegFilters * iface, ULONG cFilters, REGFILTER ** ppRegFilter, ULONG * pcFetched)
153 {
154  ULONG cFetched;
156  unsigned int i;
157 
158  cFetched = min(This->size, This->uIndex + cFilters) - This->uIndex;
159 
160  TRACE("(%p)->(%u, %p, %p)\n", iface, cFilters, ppRegFilter, pcFetched);
161 
162  if (cFetched > 0)
163  {
164  for(i = 0; i < cFetched; i++)
165  {
166  /* The string in the REGFILTER structure must be allocated in the same block as the REGFILTER structure itself */
167  ppRegFilter[i] = CoTaskMemAlloc(sizeof(REGFILTER)+(strlenW(This->RegFilters[This->uIndex + i].Name)+1)*sizeof(WCHAR));
168  if (!ppRegFilter[i])
169  {
170  while(i)
171  {
172  CoTaskMemFree(ppRegFilter[--i]);
173  ppRegFilter[i] = NULL;
174  }
175  return E_OUTOFMEMORY;
176  }
177  ppRegFilter[i]->Clsid = This->RegFilters[This->uIndex + i].Clsid;
178  ppRegFilter[i]->Name = (WCHAR*)((char*)ppRegFilter[i]+sizeof(REGFILTER));
179  CopyMemory(ppRegFilter[i]->Name, This->RegFilters[This->uIndex + i].Name,
180  (strlenW(This->RegFilters[This->uIndex + i].Name)+1)*sizeof(WCHAR));
181  }
182 
183  This->uIndex += cFetched;
184  if (pcFetched)
185  *pcFetched = cFetched;
186  return S_OK;
187  }
188 
189  return S_FALSE;
190 }
191 
193 {
194  TRACE("(%p)->(%u)\n", iface, n);
195 
196  return E_NOTIMPL;
197 }
198 
200 {
202 
203  TRACE("(%p)\n", iface);
204 
205  This->uIndex = 0;
206  return S_OK;
207 }
208 
210 {
211  TRACE("(%p)->(%p)\n", iface, ppEnum);
212 
213  return E_NOTIMPL;
214 }
215 
216 static const IEnumRegFiltersVtbl IEnumRegFiltersImpl_Vtbl =
217 {
225 };
struct IEnumRegFiltersImpl IEnumRegFiltersImpl
#define REFIID
Definition: guiddef.h:113
#define E_NOINTERFACE
Definition: winerror.h:2364
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:422
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
REFIID riid
Definition: precomp.h:44
const char * qzdebugstr_guid(const GUID *id)
Definition: main.c:279
REFIID LPVOID * ppv
Definition: atlbase.h:39
GLdouble n
Definition: glext.h:7729
HRESULT IEnumRegFiltersImpl_Construct(REGFILTER *pInRegFilters, const ULONG size, IEnumRegFilters **ppEnum)
CLSID Clsid
Definition: axextend.idl:76
static HRESULT WINAPI IEnumRegFiltersImpl_Clone(IEnumRegFilters *iface, IEnumRegFilters **ppEnum)
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
static HRESULT WINAPI IEnumRegFiltersImpl_QueryInterface(IEnumRegFilters *iface, REFIID riid, LPVOID *ppv)
#define FIXME(fmt,...)
Definition: debug.h:110
#define S_FALSE
Definition: winerror.h:2357
WINE_DEFAULT_DEBUG_CHANNEL(quartz)
smooth NULL
Definition: ftsmooth.c:416
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
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
static const struct IEnumRegFiltersVtbl IEnumRegFiltersImpl_Vtbl
#define WINAPI
Definition: msvc.h:8
#define CopyMemory
Definition: winbase.h:1633
static HRESULT WINAPI IEnumRegFiltersImpl_Next(IEnumRegFilters *iface, ULONG cFilters, REGFILTER **ppRegFilter, ULONG *pcFetched)
#define InterlockedDecrement
Definition: armddk.h:52
static IEnumRegFiltersImpl * impl_from_IEnumRegFilters(IEnumRegFilters *iface)
#define S_OK
Definition: intsafe.h:59
static ULONG WINAPI IEnumRegFiltersImpl_AddRef(IEnumRegFilters *iface)
#define InterlockedIncrement
Definition: armddk.h:53
REGFILTER * RegFilters
LPWSTR Name
Definition: axextend.idl:77
#define E_NOTIMPL
Definition: ddrawi.h:99
#define min(a, b)
Definition: monoChain.cc:55
static HRESULT WINAPI IEnumRegFiltersImpl_Skip(IEnumRegFilters *iface, ULONG n)
static ULONG WINAPI IEnumRegFiltersImpl_Release(IEnumRegFilters *iface)
unsigned int ULONG
Definition: retypes.h:1
IEnumRegFilters IEnumRegFilters_iface
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:406
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:90
static HRESULT WINAPI IEnumRegFiltersImpl_Reset(IEnumRegFilters *iface)