ReactOS 0.4.16-dev-737-g3368adc
propertybag.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "objbase.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 22 of file propertybag.c.

Typedef Documentation

◆ PropertyBag

Function Documentation

◆ copy_propbag2()

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

Definition at line 213 of file propertybag.c.

214{
215 dest->cfType = src->cfType;
216 dest->clsid = src->clsid;
217 dest->dwHint = src->dwHint;
218 dest->dwType = src->dwType;
219 dest->vt = src->vt;
220 dest->pstrName = CoTaskMemAlloc((lstrlenW(src->pstrName)+1) * sizeof(WCHAR));
221 if(!dest->pstrName)
222 return E_OUTOFMEMORY;
223
224 lstrcpyW(dest->pstrName, src->pstrName);
225
226 return S_OK;
227}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define lstrcpyW
Definition: compat.h:749
#define lstrlenW
Definition: compat.h:750
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
__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 278 of file propertybag.c.

280{
281 UINT i;
282 HRESULT res = S_OK;
284
285 This = malloc(sizeof(PropertyBag));
286 if (!This) return E_OUTOFMEMORY;
287
288 This->IPropertyBag2_iface.lpVtbl = &PropertyBag_Vtbl;
289 This->ref = 1;
290 This->prop_count = count;
291
292 if (count == 0)
293 {
294 This->properties = NULL;
295 This->values = NULL;
296 }
297 else
298 {
299 This->properties = calloc(count, sizeof(PROPBAG2));
300 This->values = calloc(count, sizeof(VARIANT));
301
302 if (!This->properties || !This->values)
304 else
305 for (i=0; i < count; i++)
306 {
307 res = copy_propbag2(This->properties+i, options+i);
308 if (FAILED(res))
309 break;
310 This->properties[i].dwHint = i+1; /* 0 means unset, so we start with 1 */
311 }
312 }
313
314 if (FAILED(res))
315 {
316 PropertyBag_Release(&This->IPropertyBag2_iface);
317 *ppPropertyBag2 = NULL;
318 }
319 else
320 *ppPropertyBag2 = &This->IPropertyBag2_iface;
321
322 return res;
323}
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
static ULONG WINAPI PropertyBag_Release(IPropertyBag2 *iface)
Definition: propertybag.c:80
static const IPropertyBag2Vtbl PropertyBag_Vtbl
Definition: propertybag.c:267
static HRESULT copy_propbag2(PROPBAG2 *dest, const PROPBAG2 *src)
Definition: propertybag.c:213
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
#define calloc
Definition: rosglue.h:14

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

◆ find_item()

static LONG find_item ( PropertyBag This,
LPCOLESTR  name 
)
static

Definition at line 107 of file propertybag.c.

108{
109 LONG i;
110 if (!This->properties)
111 return -1;
112 if (!name)
113 return -1;
114
115 for (i=0; i < This->prop_count; i++)
116 {
117 if (wcscmp(name, This->properties[i].pstrName) == 0)
118 return i;
119 }
120
121 return -1;
122}
long LONG
Definition: pedump.c:60
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
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 42 of file propertybag.c.

43{
44 return CONTAINING_RECORD(iface, PropertyBag, IPropertyBag2_iface);
45}
#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 70 of file propertybag.c.

71{
74
75 TRACE("(%p) refcount=%lu\n", iface, ref);
76
77 return ref;
78}
#define InterlockedIncrement
Definition: armddk.h:53
static PropertyBag * impl_from_IPropertyBag2(IPropertyBag2 *iface)
Definition: propertybag.c:42
#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 199 of file propertybag.c.

200{
202
203 TRACE("(%p,%p)\n", iface, pcProperties);
204
205 if (!pcProperties)
206 return E_INVALIDARG;
207
208 *pcProperties = This->prop_count;
209
210 return S_OK;
211}
#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 229 of file propertybag.c.

231{
232 HRESULT res = S_OK;
233 ULONG i;
235
236 TRACE("(%p,%lu,%lu,%p,%p)\n", iface, iProperty, cProperties, pPropBag, pcProperties);
237
238 if (iProperty >= This->prop_count && iProperty > 0)
240 if (iProperty+cProperties > This->prop_count )
242
243 *pcProperties = min(cProperties, This->prop_count-iProperty);
244
245 for (i=0; i < *pcProperties; i++)
246 {
247 res = copy_propbag2(pPropBag+i, This->properties+iProperty+i);
248 if (FAILED(res))
249 {
250 do {
251 CoTaskMemFree( pPropBag[--i].pstrName );
252 } while (i);
253 break;
254 }
255 }
256
257 return res;
258}
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 260 of file propertybag.c.

262{
263 FIXME("(%p,%s,%lu,%p,%p): stub\n", iface, debugstr_w(pstrName), dwHint, pUnkObject, pErrLog);
264 return E_NOTIMPL;
265}
#define FIXME(fmt,...)
Definition: precomp.h:53
#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 47 of file propertybag.c.

49{
51 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
52
53 if (!ppv) return E_INVALIDARG;
54
55 if (IsEqualIID(&IID_IUnknown, iid) ||
56 IsEqualIID(&IID_IPropertyBag2, iid))
57 {
58 *ppv = &This->IPropertyBag2_iface;
59 }
60 else
61 {
62 *ppv = NULL;
63 return E_NOINTERFACE;
64 }
65
66 IUnknown_AddRef((IUnknown*)*ppv);
67 return S_OK;
68}
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 124 of file propertybag.c.

126{
127 HRESULT res = S_OK;
128 ULONG i;
130
131 TRACE("(%p,%lu,%p,%p,%p,%p)\n", iface, cProperties, pPropBag, pErrLog, pvarValue, phrError);
132
133 for (i=0; i < cProperties; i++)
134 {
135 LONG idx;
136 if (pPropBag[i].dwHint && pPropBag[i].dwHint <= This->prop_count)
137 idx = pPropBag[i].dwHint-1;
138 else
139 idx = find_item(This, pPropBag[i].pstrName);
140
141 if (idx > -1)
142 {
143 VariantInit(pvarValue+i);
144 res = VariantCopy(pvarValue+i, This->values+idx);
145 if (FAILED(res))
146 break;
147 phrError[i] = res;
148 }
149 else
150 {
151 res = E_FAIL;
152 break;
153 }
154 }
155
156 return res;
157}
#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:107
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 80 of file propertybag.c.

81{
84
85 TRACE("(%p) refcount=%lu\n", iface, ref);
86
87 if (ref == 0)
88 {
89 ULONG i;
90 if (This->properties && This->values)
91 {
92 for (i=0; i < This->prop_count; i++)
93 {
94 CoTaskMemFree(This->properties[i].pstrName);
95 VariantClear( This->values+i );
96 }
97 }
98
99 free(This->properties);
100 free(This->values);
101 free(This);
102 }
103
104 return ref;
105}
#define InterlockedDecrement
Definition: armddk.h:52
#define free
Definition: debug_ros.c:5
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 159 of file propertybag.c.

161{
162 HRESULT res = S_OK;
163 ULONG i;
165
166 TRACE("(%p,%lu,%p,%p)\n", iface, cProperties, pPropBag, pvarValue);
167
168 for (i=0; i < cProperties; i++)
169 {
170 LONG idx;
171 if (pPropBag[i].dwHint && pPropBag[i].dwHint <= This->prop_count)
172 idx = pPropBag[i].dwHint-1;
173 else
174 idx = find_item(This, pPropBag[i].pstrName);
175
176 if (idx > -1)
177 {
178 if (This->properties[idx].vt != V_VT(pvarValue+i))
180 res = VariantCopy(This->values+idx, pvarValue+i);
181 if (FAILED(res))
182 return E_FAIL;
183 }
184 else
185 {
186 if (pPropBag[i].pstrName)
187 FIXME("Application tried to set the unknown option %s.\n",
188 debugstr_w(pPropBag[i].pstrName));
189
190 /* FIXME: Function is not atomar on error, but MSDN does not say anything about it
191 * (no reset of items between 0 and i-1) */
192 return E_FAIL;
193 }
194 }
195
196 return res;
197}
#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:260
static HRESULT WINAPI PropertyBag_CountProperties(IPropertyBag2 *iface, ULONG *pcProperties)
Definition: propertybag.c:199
static HRESULT WINAPI PropertyBag_QueryInterface(IPropertyBag2 *iface, REFIID iid, void **ppv)
Definition: propertybag.c:47
static HRESULT WINAPI PropertyBag_GetPropertyInfo(IPropertyBag2 *iface, ULONG iProperty, ULONG cProperties, PROPBAG2 *pPropBag, ULONG *pcProperties)
Definition: propertybag.c:229
static HRESULT WINAPI PropertyBag_Read(IPropertyBag2 *iface, ULONG cProperties, PROPBAG2 *pPropBag, IErrorLog *pErrLog, VARIANT *pvarValue, HRESULT *phrError)
Definition: propertybag.c:124
static HRESULT WINAPI PropertyBag_Write(IPropertyBag2 *iface, ULONG cProperties, PROPBAG2 *pPropBag, VARIANT *pvarValue)
Definition: propertybag.c:159
static ULONG WINAPI PropertyBag_AddRef(IPropertyBag2 *iface)
Definition: propertybag.c:70

Definition at line 267 of file propertybag.c.

Referenced by CreatePropertyBag2().