~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/ole32/enumx.c

Version: ~ [ wine-1.5.30 ] ~ [ wine-1.5.29 ] ~ [ wine-1.5.28 ] ~ [ wine-1.5.27 ] ~ [ wine-1.5.26 ] ~ [ wine-1.5.25 ] ~ [ wine-1.5.24 ] ~ [ wine-1.5.23 ] ~ [ wine-1.5.22 ] ~ [ wine-1.5.21 ] ~ [ wine-1.5.20 ] ~ [ wine-1.5.19 ] ~ [ wine-1.5.18 ] ~ [ wine-1.5.17 ] ~ [ wine-1.5.16 ] ~ [ wine-1.5.15 ] ~ [ wine-1.5.14 ] ~ [ wine-1.5.13 ] ~ [ wine-1.5.12 ] ~ [ wine-1.5.11 ] ~ [ wine-1.5.10 ] ~ [ wine-1.5.9 ] ~ [ wine-1.5.8 ] ~ [ wine-1.5.7 ] ~ [ wine-1.4.1 ] ~ [ wine-1.5.6 ] ~ [ wine-1.5.5 ] ~ [ wine-1.5.4 ] ~ [ wine-1.5.3 ] ~ [ wine-1.5.2 ] ~ [ wine-1.5.1 ] ~ [ wine-1.5.0 ] ~ [ wine-1.4 ] ~ [ wine-1.4-rc6 ] ~ [ wine-1.4-rc5 ] ~ [ wine-1.4-rc4 ] ~ [ wine-1.4-rc3 ] ~ [ wine-1.4-rc2 ] ~ [ wine-1.4-rc1 ] ~ [ wine-1.3.37 ] ~ [ wine-1.3.36 ] ~ [ wine-1.3.35 ] ~ [ wine-1.3.34 ] ~ [ wine-1.3.33 ] ~ [ wine-1.3.32 ] ~ [ wine-1.3.31 ] ~ [ wine-1.3.30 ] ~ [ wine-1.3.29 ] ~ [ wine-1.3.28 ] ~ [ wine-1.3.27 ] ~ [ wine-1.3.26 ] ~ [ wine-1.3.25 ] ~ [ wine-1.3.24 ] ~ [ wine-1.3.23 ] ~ [ wine-1.3.22 ] ~ [ wine-1.3.21 ] ~ [ wine-1.3.20 ] ~ [ wine-1.3.19 ] ~ [ wine-1.3.18 ] ~ [ wine-1.2.3 ] ~ [ wine-1.3.17 ] ~ [ wine-1.3.16 ] ~ [ wine-1.3.15 ] ~ [ wine-1.3.14 ] ~ [ wine-1.3.13 ] ~ [ wine-1.3.12 ] ~ [ wine-1.3.11 ] ~ [ wine-1.3.10 ] ~ [ wine-1.3.9 ] ~ [ wine-1.2.2 ] ~ [ wine-1.3.8 ] ~ [ wine-1.3.7 ] ~ [ wine-1.3.6 ] ~ [ wine-1.3.5 ] ~ [ wine-1.2.1 ] ~ [ wine-1.3.4 ] ~ [ wine-1.3.3 ] ~ [ wine-1.3.2 ] ~ [ wine-1.3.1 ] ~ [ wine-1.3.0 ] ~ [ wine-1.2 ] ~ [ wine-1.2-rc7 ] ~ [ wine-1.2-rc6 ] ~ [ wine-1.2-rc5 ] ~ [ wine-1.2-rc4 ] ~ [ wine-1.2-rc3 ] ~ [ wine-1.2-rc2 ] ~ [ wine-1.2-rc1 ] ~ [ wine-1.1.44 ] ~ [ wine-1.1.43 ] ~ [ wine-1.1.42 ] ~ [ wine-1.1.41 ] ~ [ wine-1.1.40 ] ~ [ wine-1.1.39 ] ~ [ wine-1.1.38 ] ~ [ wine-1.1.37 ] ~ [ wine-1.1.36 ] ~ [ wine-1.1.35 ] ~ [ wine-1.1.34 ] ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /*
  2  * IEnum* implementation
  3  *
  4  * Copyright 2006 Mike McCormack
  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 <stdarg.h>
 24 
 25 #include "windef.h"
 26 #include "winbase.h"
 27 #include "objbase.h"
 28 
 29 #include "enumx.h"
 30 
 31 #include "wine/list.h"
 32 #include "wine/debug.h"
 33 
 34 WINE_DEFAULT_DEBUG_CHANNEL(ole);
 35 
 36 struct tagEnumSTATPROPSETSTG_impl
 37 {
 38     const void *vtbl;
 39     LONG ref;
 40     struct list elements;
 41     struct list *current;
 42     ULONG elem_size;
 43     GUID riid;
 44 };
 45 
 46 /************************************************************************
 47  * enumx_QueryInterface
 48  */
 49 HRESULT WINAPI enumx_QueryInterface(
 50     enumx_impl *This,
 51     REFIID riid,
 52     void** ppvObject)
 53 {
 54     if ( (This==0) || (ppvObject==0) )
 55         return E_INVALIDARG;
 56 
 57     *ppvObject = 0;
 58 
 59     if (IsEqualGUID(&IID_IUnknown, riid) ||
 60         IsEqualGUID(&This->riid, riid))
 61     {
 62         IUnknown_AddRef(((IUnknown*)This));
 63         *ppvObject = This;
 64         return S_OK;
 65     }
 66 
 67     return E_NOINTERFACE;
 68 }
 69 
 70 /************************************************************************
 71  * enumx_AddRef
 72  */
 73 ULONG WINAPI enumx_AddRef(enumx_impl *This)
 74 {
 75     return InterlockedIncrement(&This->ref);
 76 }
 77 
 78 /************************************************************************
 79  * enumx_Release
 80  */
 81 ULONG WINAPI enumx_Release(enumx_impl *This)
 82 {
 83     ULONG ref;
 84 
 85     ref = InterlockedDecrement(&This->ref);
 86     if (ref == 0)
 87     {
 88         while (!list_empty(&This->elements))
 89         {
 90              struct list *x = list_head(&This->elements);
 91              list_remove(x);
 92              HeapFree(GetProcessHeap(), 0, x);
 93         }
 94         HeapFree(GetProcessHeap(), 0, This);
 95     }
 96     return ref;
 97 }
 98 
 99 /************************************************************************
100  * enumx_Next
101  */
102 HRESULT WINAPI enumx_Next(enumx_impl *This, ULONG celt,
103                                  void *rgelt, ULONG *pceltFetched)
104 {
105     unsigned char *p;
106     ULONG count = 0;
107 
108     TRACE("%p %u %p\n", This, celt, pceltFetched);
109 
110     if (This->current == NULL)
111         This->current = list_head(&This->elements);
112     p = rgelt;
113     while (count < celt && This->current && This->current != &This->elements)
114     {
115         memcpy(p, &This->current[1], This->elem_size);
116         p += This->elem_size;
117         This->current = This->current->next;
118         count++;
119     }
120     if (pceltFetched)
121         *pceltFetched = count;
122     if (count < celt)
123         return S_FALSE;
124     return S_OK;
125 }
126 
127 /************************************************************************
128  * enumx_Skip
129  */
130 HRESULT WINAPI enumx_Skip(enumx_impl *This, ULONG celt)
131 {
132     ULONG count = 0;
133 
134     TRACE("%p %u\n", This, celt);
135 
136     if (This->current == NULL)
137         This->current = list_head(&This->elements);
138 
139     while (count < celt && This->current && This->current != &This->elements)
140         count++;
141 
142     return S_OK;
143 }
144 
145 /************************************************************************
146  * enumx_Reset
147  */
148 HRESULT WINAPI enumx_Reset(enumx_impl *This)
149 {
150     TRACE("\n");
151 
152     This->current = NULL;
153     return S_OK;
154 }
155 
156 /************************************************************************
157  * enumx_fnClone
158  */
159 HRESULT WINAPI enumx_Clone(
160     enumx_impl *iface,
161     enumx_impl **ppenum)
162 {
163     FIXME("\n");
164     return E_NOTIMPL;
165 }
166 
167 /************************************************************************
168  * enumx_allocate
169  *
170  * Allocate a generic enumerator
171  */
172 enumx_impl *enumx_allocate(REFIID riid, const void *vtbl, ULONG elem_size)
173 {
174     enumx_impl *enumx;
175 
176     enumx = HeapAlloc(GetProcessHeap(), 0, sizeof *enumx);
177     if (enumx)
178     {
179         enumx->vtbl = vtbl;
180         enumx->ref = 1;
181         enumx->current = NULL;
182         enumx->elem_size = elem_size;
183         enumx->riid = *riid;
184         list_init(&enumx->elements);
185     }
186 
187     return enumx;
188 }
189 
190 /************************************************************************
191  * enumx_add_element
192  *
193  * Add an element to the enumeration.
194  */
195 void *enumx_add_element(enumx_impl *enumx, const void *data)
196 {
197     struct list *element;
198 
199     element = HeapAlloc(GetProcessHeap(), 0, sizeof *element + enumx->elem_size);
200     if (!element)
201         return NULL;
202     memcpy(&element[1], data, enumx->elem_size);
203     list_add_tail(&enumx->elements, element);
204     return &element[1];
205 }
206 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.