ReactOS 0.4.15-dev-7961-gdcf9eb0
propertybag.c File Reference
#include "config.h"
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "objbase.h"
#include "wine/unicode.h"
#include "wincodecs_private.h"
#include "wine/debug.h"
Include dependency graph for propertybag.c:

Go to the source code of this file.

Classes

struct  PropertyBag
 

Macros

#define COBJMACROS
 

Typedefs

typedef struct PropertyBag PropertyBag
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (wincodecs)
 
static PropertyBagimpl_from_IPropertyBag2 (IPropertyBag2 *iface)
 
static HRESULT WINAPI PropertyBag_QueryInterface (IPropertyBag2 *iface, REFIID iid, void **ppv)
 
static ULONG WINAPI PropertyBag_AddRef (IPropertyBag2 *iface)
 
static ULONG WINAPI PropertyBag_Release (IPropertyBag2 *iface)
 
static LONG find_item (PropertyBag *This, LPCOLESTR name)
 
static HRESULT WINAPI PropertyBag_Read (IPropertyBag2 *iface, ULONG cProperties, PROPBAG2 *pPropBag, IErrorLog *pErrLog, VARIANT *pvarValue, HRESULT *phrError)
 
static HRESULT WINAPI PropertyBag_Write (IPropertyBag2 *iface, ULONG cProperties, PROPBAG2 *pPropBag, VARIANT *pvarValue)
 
static HRESULT WINAPI PropertyBag_CountProperties (IPropertyBag2 *iface, ULONG *pcProperties)
 
static HRESULT copy_propbag2 (PROPBAG2 *dest, const PROPBAG2 *src)
 
static HRESULT WINAPI PropertyBag_GetPropertyInfo (IPropertyBag2 *iface, ULONG iProperty, ULONG cProperties, PROPBAG2 *pPropBag, ULONG *pcProperties)
 
static HRESULT WINAPI PropertyBag_LoadObject (IPropertyBag2 *iface, LPCOLESTR pstrName, DWORD dwHint, IUnknown *pUnkObject, IErrorLog *pErrLog)
 
HRESULT CreatePropertyBag2 (const PROPBAG2 *options, UINT count, IPropertyBag2 **ppPropertyBag2)
 

Variables

static const IPropertyBag2Vtbl PropertyBag_Vtbl
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 24 of file propertybag.c.

Typedef Documentation

◆ PropertyBag

Function Documentation

◆ copy_propbag2()

static HRESULT copy_propbag2 ( PROPBAG2 *  dest,
const PROPBAG2 *  src 
)
static

Definition at line 216 of file propertybag.c.

217{
218 dest->cfType = src->cfType;
219 dest->clsid = src->clsid;
220 dest->dwHint = src->dwHint;
221 dest->dwType = src->dwType;
222 dest->vt = src->vt;
223 dest->pstrName = CoTaskMemAlloc((strlenW(src->pstrName)+1) * sizeof(WCHAR));
224 if(!dest->pstrName)
225 return E_OUTOFMEMORY;
226
227 strcpyW(dest->pstrName, src->pstrName);
228
229 return S_OK;
230}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
GLenum src
Definition: glext.h:6340
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
#define S_OK
Definition: intsafe.h:52
static char * dest
Definition: rtl.c:135
#define strlenW(s)
Definition: unicode.h:28
#define strcpyW(d, s)
Definition: unicode.h:29
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by CreatePropertyBag2(), and PropertyBag_GetPropertyInfo().

◆ CreatePropertyBag2()

HRESULT CreatePropertyBag2 ( const PROPBAG2 *  options,
UINT  count,
IPropertyBag2 **  ppPropertyBag2 
)

Definition at line 281 of file propertybag.c.

283{
284 UINT i;
285 HRESULT res = S_OK;
287
288 This = HeapAlloc(GetProcessHeap(), 0, sizeof(PropertyBag));
289 if (!This) return E_OUTOFMEMORY;
290
291 This->IPropertyBag2_iface.lpVtbl = &PropertyBag_Vtbl;
292 This->ref = 1;
293 This->prop_count = count;
294
295 if (count == 0)
296 {
297 This->properties = NULL;
298 This->values = NULL;
299 }
300 else
301 {
302 This->properties = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(PROPBAG2)*count);
304
305 if (!This->properties || !This->values)
307 else
308 for (i=0; i < count; i++)
309 {
310 res = copy_propbag2(This->properties+i, options+i);
311 if (FAILED(res))
312 break;
313 This->properties[i].dwHint = i+1; /* 0 means unset, so we start with 1 */
314 }
315 }
316
317 if (FAILED(res))
318 {
319 PropertyBag_Release(&This->IPropertyBag2_iface);
320 *ppPropertyBag2 = NULL;
321 }
322 else
323 *ppPropertyBag2 = &This->IPropertyBag2_iface;
324
325 return res;
326}
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static ULONG WINAPI PropertyBag_Release(IPropertyBag2 *iface)
Definition: propertybag.c:83
static const IPropertyBag2Vtbl PropertyBag_Vtbl
Definition: propertybag.c:270
static HRESULT copy_propbag2(PROPBAG2 *dest, const PROPBAG2 *src)
Definition: propertybag.c:216
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint res
Definition: glext.h:9613
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 FAILED(hr)
Definition: intsafe.h:51
unsigned int UINT
Definition: ndis.h:50

Referenced by BmpEncoder_CreateNewFrame(), ComponentFactory_CreateEncoderPropertyBag(), and GifEncoder_CreateNewFrame().

◆ find_item()

static LONG find_item ( PropertyBag This,
LPCOLESTR  name 
)
static

Definition at line 110 of file propertybag.c.

111{
112 LONG i;
113 if (!This->properties)
114 return -1;
115 if (!name)
116 return -1;
117
118 for (i=0; i < This->prop_count; i++)
119 {
120 if (strcmpW(name, This->properties[i].pstrName) == 0)
121 return i;
122 }
123
124 return -1;
125}
long LONG
Definition: pedump.c:60
#define strcmpW(s1, s2)
Definition: unicode.h:38
Definition: name.c:39

Referenced by __attribute__(), _Function_class_(), add_balance_item(), add_checksum_entry(), add_device(), add_metadata_reloc_parent(), add_parents(), add_root_item_to_cache(), add_root_ref(), allocate_cache_chunk(), balance_data_chunk(), balance_metadata_chunk(), check_for_orphans_root(), check_inode_used(), clear_free_space_cache(), convert_old_extent(), create_stream(), create_subvol(), data_reloc_add_tree_edr(), decrease_extent_refcount(), delete_root_ref(), do_create_snapshot(), do_splits(), do_write2(), drop_chunk(), drop_root(), find_chunk_usage(), find_default_subvol(), find_disk_holes(), find_extent_data_refcount(), find_extent_shared_data_refcount(), find_extent_shared_tree_refcount(), find_send_dir(), find_subvol(), finish_removing_device(), flush_changed_dev_stats(), flush_changed_extent(), flush_fcb(), flush_subvol(), get_dir_last_child(), get_extent_flags(), get_extent_refcount(), get_last_inode(), get_orphan_name(), increase_extent_refcount(), is_extent_unique(), is_tree_unique(), load_chunk_root(), load_csum(), load_dir_children(), load_free_space_cache(), load_stored_free_space_cache(), load_stored_free_space_tree(), log_file_checksum_error(), log_unrecoverable_error(), look_for_balance_item(), look_for_collision(), look_for_roots(), mount_vol(), open_fcb(), open_fcb_stream(), open_fileref_by_inode(), PropertyBag_Read(), PropertyBag_Write(), query_dir_item(), remove_balance_item(), scrub_chunk(), scrub_chunk_raid56(), scrub_chunk_raid56_stripe_run(), send_add_tlv_clone_path(), send_read_symlink(), shared_tree_is_unique(), trim_unalloc_space(), try_clone(), try_clone_edr(), update_backup_superblock(), update_changed_extent_ref(), update_chunk_cache(), update_chunk_cache_tree(), update_chunk_usage(), update_dev_item(), update_extent_flags(), update_extent_level(), update_root_backref(), update_root_root(), wait_for_flush(), write_metadata_items(), and write_trees().

◆ impl_from_IPropertyBag2()

static PropertyBag * impl_from_IPropertyBag2 ( IPropertyBag2 iface)
inlinestatic

Definition at line 45 of file propertybag.c.

46{
47 return CONTAINING_RECORD(iface, PropertyBag, IPropertyBag2_iface);
48}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by PropertyBag_AddRef(), PropertyBag_CountProperties(), PropertyBag_GetPropertyInfo(), PropertyBag_QueryInterface(), PropertyBag_Read(), PropertyBag_Release(), and PropertyBag_Write().

◆ PropertyBag_AddRef()

static ULONG WINAPI PropertyBag_AddRef ( IPropertyBag2 iface)
static

Definition at line 73 of file propertybag.c.

74{
77
78 TRACE("(%p) refcount=%u\n", iface, ref);
79
80 return ref;
81}
#define InterlockedIncrement
Definition: armddk.h:53
static PropertyBag * impl_from_IPropertyBag2(IPropertyBag2 *iface)
Definition: propertybag.c:45
#define TRACE(s)
Definition: solgame.cpp:4
Definition: send.c:48
uint32_t ULONG
Definition: typedefs.h:59

◆ PropertyBag_CountProperties()

static HRESULT WINAPI PropertyBag_CountProperties ( IPropertyBag2 iface,
ULONG pcProperties 
)
static

Definition at line 202 of file propertybag.c.

203{
205
206 TRACE("(%p,%p)\n", iface, pcProperties);
207
208 if (!pcProperties)
209 return E_INVALIDARG;
210
211 *pcProperties = This->prop_count;
212
213 return S_OK;
214}
#define E_INVALIDARG
Definition: ddrawi.h:101

◆ PropertyBag_GetPropertyInfo()

static HRESULT WINAPI PropertyBag_GetPropertyInfo ( IPropertyBag2 iface,
ULONG  iProperty,
ULONG  cProperties,
PROPBAG2 *  pPropBag,
ULONG pcProperties 
)
static

Definition at line 232 of file propertybag.c.

234{
235 HRESULT res = S_OK;
236 ULONG i;
238
239 TRACE("(%p,%u,%u,%p,%p)\n", iface, iProperty, cProperties, pPropBag, pcProperties);
240
241 if (iProperty >= This->prop_count && iProperty > 0)
243 if (iProperty+cProperties > This->prop_count )
245
246 *pcProperties = min(cProperties, This->prop_count-iProperty);
247
248 for (i=0; i < *pcProperties; i++)
249 {
250 res = copy_propbag2(pPropBag+i, This->properties+iProperty+i);
251 if (FAILED(res))
252 {
253 do {
254 CoTaskMemFree( pPropBag[--i].pstrName );
255 } while (i);
256 break;
257 }
258 }
259
260 return res;
261}
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define min(a, b)
Definition: monoChain.cc:55
#define WINCODEC_ERR_VALUEOUTOFRANGE
Definition: winerror.h:3282

◆ PropertyBag_LoadObject()

static HRESULT WINAPI PropertyBag_LoadObject ( IPropertyBag2 iface,
LPCOLESTR  pstrName,
DWORD  dwHint,
IUnknown pUnkObject,
IErrorLog pErrLog 
)
static

Definition at line 263 of file propertybag.c.

265{
266 FIXME("(%p,%s,%u,%p,%p): stub\n", iface, debugstr_w(pstrName), dwHint, pUnkObject, pErrLog);
267 return E_NOTIMPL;
268}
#define FIXME(fmt,...)
Definition: debug.h:111
#define E_NOTIMPL
Definition: ddrawi.h:99
#define debugstr_w
Definition: kernel32.h:32

◆ PropertyBag_QueryInterface()

static HRESULT WINAPI PropertyBag_QueryInterface ( IPropertyBag2 iface,
REFIID  iid,
void **  ppv 
)
static

Definition at line 50 of file propertybag.c.

52{
54 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
55
56 if (!ppv) return E_INVALIDARG;
57
58 if (IsEqualIID(&IID_IUnknown, iid) ||
59 IsEqualIID(&IID_IPropertyBag2, iid))
60 {
61 *ppv = &This->IPropertyBag2_iface;
62 }
63 else
64 {
65 *ppv = NULL;
66 return E_NOINTERFACE;
67 }
68
69 IUnknown_AddRef((IUnknown*)*ppv);
70 return S_OK;
71}
const GUID IID_IUnknown
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define debugstr_guid
Definition: kernel32.h:35
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ PropertyBag_Read()

static HRESULT WINAPI PropertyBag_Read ( IPropertyBag2 iface,
ULONG  cProperties,
PROPBAG2 *  pPropBag,
IErrorLog pErrLog,
VARIANT pvarValue,
HRESULT phrError 
)
static

Definition at line 127 of file propertybag.c.

129{
130 HRESULT res = S_OK;
131 ULONG i;
133
134 TRACE("(%p,%u,%p,%p,%p,%p)\n", iface, cProperties, pPropBag, pErrLog, pvarValue, phrError);
135
136 for (i=0; i < cProperties; i++)
137 {
138 LONG idx;
139 if (pPropBag[i].dwHint && pPropBag[i].dwHint <= This->prop_count)
140 idx = pPropBag[i].dwHint-1;
141 else
142 idx = find_item(This, pPropBag[i].pstrName);
143
144 if (idx > -1)
145 {
146 VariantInit(pvarValue+i);
147 res = VariantCopy(pvarValue+i, This->values+idx);
148 if (FAILED(res))
149 break;
150 phrError[i] = res;
151 }
152 else
153 {
154 res = E_FAIL;
155 break;
156 }
157 }
158
159 return res;
160}
#define E_FAIL
Definition: ddrawi.h:102
unsigned int idx
Definition: utils.c:41
static LONG find_item(PropertyBag *This, LPCOLESTR name)
Definition: propertybag.c:110
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:568
HRESULT WINAPI VariantCopy(VARIANTARG *pvargDest, VARIANTARG *pvargSrc)
Definition: variant.c:748

◆ PropertyBag_Release()

static ULONG WINAPI PropertyBag_Release ( IPropertyBag2 iface)
static

Definition at line 83 of file propertybag.c.

84{
87
88 TRACE("(%p) refcount=%u\n", iface, ref);
89
90 if (ref == 0)
91 {
92 ULONG i;
93 if (This->properties && This->values)
94 {
95 for (i=0; i < This->prop_count; i++)
96 {
97 CoTaskMemFree(This->properties[i].pstrName);
98 VariantClear( This->values+i );
99 }
100 }
101
102 HeapFree(GetProcessHeap(), 0, This->properties);
103 HeapFree(GetProcessHeap(), 0, This->values);
105 }
106
107 return ref;
108}
#define InterlockedDecrement
Definition: armddk.h:52
#define HeapFree(x, y, z)
Definition: compat.h:735
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:648

Referenced by CreatePropertyBag2().

◆ PropertyBag_Write()

static HRESULT WINAPI PropertyBag_Write ( IPropertyBag2 iface,
ULONG  cProperties,
PROPBAG2 *  pPropBag,
VARIANT pvarValue 
)
static

Definition at line 162 of file propertybag.c.

164{
165 HRESULT res = S_OK;
166 ULONG i;
168
169 TRACE("(%p,%u,%p,%p)\n", iface, cProperties, pPropBag, pvarValue);
170
171 for (i=0; i < cProperties; i++)
172 {
173 LONG idx;
174 if (pPropBag[i].dwHint && pPropBag[i].dwHint <= This->prop_count)
175 idx = pPropBag[i].dwHint-1;
176 else
177 idx = find_item(This, pPropBag[i].pstrName);
178
179 if (idx > -1)
180 {
181 if (This->properties[idx].vt != V_VT(pvarValue+i))
183 res = VariantCopy(This->values+idx, pvarValue+i);
184 if (FAILED(res))
185 return E_FAIL;
186 }
187 else
188 {
189 if (pPropBag[i].pstrName)
190 FIXME("Application tried to set the unknown option %s.\n",
191 debugstr_w(pPropBag[i].pstrName));
192
193 /* FIXME: Function is not atomar on error, but MSDN does not say anything about it
194 * (no reset of items between 0 and i-1) */
195 return E_FAIL;
196 }
197 }
198
199 return res;
200}
#define V_VT(A)
Definition: oleauto.h:211
#define WINCODEC_ERR_PROPERTYUNEXPECTEDTYPE
Definition: winerror.h:3313

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( wincodecs  )

Variable Documentation

◆ PropertyBag_Vtbl

const IPropertyBag2Vtbl PropertyBag_Vtbl
static
Initial value:
= {
}
static HRESULT WINAPI PropertyBag_LoadObject(IPropertyBag2 *iface, LPCOLESTR pstrName, DWORD dwHint, IUnknown *pUnkObject, IErrorLog *pErrLog)
Definition: propertybag.c:263
static HRESULT WINAPI PropertyBag_CountProperties(IPropertyBag2 *iface, ULONG *pcProperties)
Definition: propertybag.c:202
static HRESULT WINAPI PropertyBag_QueryInterface(IPropertyBag2 *iface, REFIID iid, void **ppv)
Definition: propertybag.c:50
static HRESULT WINAPI PropertyBag_GetPropertyInfo(IPropertyBag2 *iface, ULONG iProperty, ULONG cProperties, PROPBAG2 *pPropBag, ULONG *pcProperties)
Definition: propertybag.c:232
static HRESULT WINAPI PropertyBag_Read(IPropertyBag2 *iface, ULONG cProperties, PROPBAG2 *pPropBag, IErrorLog *pErrLog, VARIANT *pvarValue, HRESULT *phrError)
Definition: propertybag.c:127
static HRESULT WINAPI PropertyBag_Write(IPropertyBag2 *iface, ULONG cProperties, PROPBAG2 *pPropBag, VARIANT *pvarValue)
Definition: propertybag.c:162
static ULONG WINAPI PropertyBag_AddRef(IPropertyBag2 *iface)
Definition: propertybag.c:73

Definition at line 270 of file propertybag.c.

Referenced by CreatePropertyBag2().