ReactOS 0.4.16-dev-297-gc569aee
propvarutil.h File Reference
#include <shtypes.h>
#include <shlwapi.h>
Include dependency graph for propvarutil.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef int PROPVAR_CHANGE_FLAGS
 
typedef int PROPVAR_COMPARE_UNIT
 
typedef int PROPVAR_COMPARE_FLAGS
 

Enumerations

enum  tagPROPVAR_CHANGE_FLAGS {
  PVCHF_DEFAULT = 0x00000000 , PVCHF_NOVALUEPROP = 0x00000001 , PVCHF_ALPHABOOL = 0x00000002 , PVCHF_NOUSEROVERRIDE = 0x00000004 ,
  PVCHF_LOCALBOOL = 0x00000008 , PVCHF_NOHEXSTRING = 0x00000010
}
 
enum  tagPROPVAR_COMPARE_UNIT {
  PVCU_DEFAULT = 0x00000000 , PVCU_SECOND = 0x00000001 , PVCU_MINUTE = 0x00000002 , PVCU_HOUR = 0x00000003 ,
  PVCU_DAY = 0x00000004 , PVCU_MONTH = 0x00000005 , PVCU_YEAR = 0x00000006
}
 
enum  tagPROPVAR_COMPARE_FLAGS {
  PVCF_DEFAULT = 0x00000000 , PVCF_TREATEMPTYASGREATERTHAN = 0x00000001 , PVCF_USESTRCMP = 0x00000002 , PVCF_USESTRCMPC = 0x00000004 ,
  PVCF_USESTRCMPI = 0x00000008 , PVCF_USESTRCMPIC = 0x00000010
}
 

Functions

HRESULT WINAPI PropVariantChangeType (PROPVARIANT *ppropvarDest, REFPROPVARIANT propvarSrc, PROPVAR_CHANGE_FLAGS flags, VARTYPE vt)
 
HRESULT WINAPI InitPropVariantFromGUIDAsString (REFGUID guid, PROPVARIANT *ppropvar)
 
HRESULT WINAPI InitVariantFromGUIDAsString (REFGUID guid, VARIANT *pvar)
 
HRESULT WINAPI InitPropVariantFromBuffer (const VOID *pv, UINT cb, PROPVARIANT *ppropvar)
 
HRESULT WINAPI InitPropVariantFromCLSID (REFCLSID clsid, PROPVARIANT *ppropvar)
 
HRESULT WINAPI InitVariantFromBuffer (const VOID *pv, UINT cb, VARIANT *pvar)
 
HRESULT WINAPI PropVariantToGUID (const PROPVARIANT *ppropvar, GUID *guid)
 
HRESULT WINAPI VariantToGUID (const VARIANT *pvar, GUID *guid)
 
INT WINAPI PropVariantCompareEx (REFPROPVARIANT propvar1, REFPROPVARIANT propvar2, PROPVAR_COMPARE_UNIT uint, PROPVAR_COMPARE_FLAGS flags)
 
HRESULT WINAPI PropVariantToDouble (REFPROPVARIANT propvarIn, double *ret)
 
HRESULT WINAPI PropVariantToInt16 (REFPROPVARIANT propvarIn, SHORT *ret)
 
HRESULT WINAPI PropVariantToInt32 (REFPROPVARIANT propvarIn, LONG *ret)
 
HRESULT WINAPI PropVariantToInt64 (REFPROPVARIANT propvarIn, LONGLONG *ret)
 
HRESULT WINAPI PropVariantToUInt16 (REFPROPVARIANT propvarIn, USHORT *ret)
 
HRESULT WINAPI PropVariantToUInt32 (REFPROPVARIANT propvarIn, ULONG *ret)
 
HRESULT WINAPI PropVariantToUInt64 (REFPROPVARIANT propvarIn, ULONGLONG *ret)
 
HRESULT WINAPI PropVariantToBoolean (REFPROPVARIANT propvarIn, BOOL *ret)
 
HRESULT WINAPI PropVariantToBuffer (REFPROPVARIANT propvarIn, void *ret, UINT cb)
 
HRESULT WINAPI PropVariantToString (REFPROPVARIANT propvarIn, PWSTR ret, UINT cch)
 
PCWSTR WINAPI PropVariantToStringWithDefault (REFPROPVARIANT propvarIn, LPCWSTR pszDefault)
 
HRESULT WINAPI PropVariantToStringAlloc (REFPROPVARIANT propvarIn, WCHAR **ret)
 

Typedef Documentation

◆ PROPVAR_CHANGE_FLAGS

Definition at line 39 of file propvarutil.h.

◆ PROPVAR_COMPARE_FLAGS

Definition at line 64 of file propvarutil.h.

◆ PROPVAR_COMPARE_UNIT

Definition at line 52 of file propvarutil.h.

Enumeration Type Documentation

◆ tagPROPVAR_CHANGE_FLAGS

Enumerator
PVCHF_DEFAULT 
PVCHF_NOVALUEPROP 
PVCHF_ALPHABOOL 
PVCHF_NOUSEROVERRIDE 
PVCHF_LOCALBOOL 
PVCHF_NOHEXSTRING 

Definition at line 29 of file propvarutil.h.

30{
31 PVCHF_DEFAULT = 0x00000000,
32 PVCHF_NOVALUEPROP = 0x00000001,
33 PVCHF_ALPHABOOL = 0x00000002,
34 PVCHF_NOUSEROVERRIDE = 0x00000004,
35 PVCHF_LOCALBOOL = 0x00000008,
36 PVCHF_NOHEXSTRING = 0x00000010,
37};
@ PVCHF_NOUSEROVERRIDE
Definition: propvarutil.h:34
@ PVCHF_DEFAULT
Definition: propvarutil.h:31
@ PVCHF_LOCALBOOL
Definition: propvarutil.h:35
@ PVCHF_ALPHABOOL
Definition: propvarutil.h:33
@ PVCHF_NOVALUEPROP
Definition: propvarutil.h:32
@ PVCHF_NOHEXSTRING
Definition: propvarutil.h:36

◆ tagPROPVAR_COMPARE_FLAGS

Enumerator
PVCF_DEFAULT 
PVCF_TREATEMPTYASGREATERTHAN 
PVCF_USESTRCMP 
PVCF_USESTRCMPC 
PVCF_USESTRCMPI 
PVCF_USESTRCMPIC 

Definition at line 54 of file propvarutil.h.

55{
56 PVCF_DEFAULT = 0x00000000,
58 PVCF_USESTRCMP = 0x00000002,
59 PVCF_USESTRCMPC = 0x00000004,
60 PVCF_USESTRCMPI = 0x00000008,
61 PVCF_USESTRCMPIC = 0x00000010,
62};
@ PVCF_USESTRCMPC
Definition: propvarutil.h:59
@ PVCF_USESTRCMPI
Definition: propvarutil.h:60
@ PVCF_USESTRCMPIC
Definition: propvarutil.h:61
@ PVCF_DEFAULT
Definition: propvarutil.h:56
@ PVCF_TREATEMPTYASGREATERTHAN
Definition: propvarutil.h:57
@ PVCF_USESTRCMP
Definition: propvarutil.h:58

◆ tagPROPVAR_COMPARE_UNIT

Enumerator
PVCU_DEFAULT 
PVCU_SECOND 
PVCU_MINUTE 
PVCU_HOUR 
PVCU_DAY 
PVCU_MONTH 
PVCU_YEAR 

Definition at line 41 of file propvarutil.h.

42{
43 PVCU_DEFAULT = 0x00000000,
44 PVCU_SECOND = 0x00000001,
45 PVCU_MINUTE = 0x00000002,
46 PVCU_HOUR = 0x00000003,
47 PVCU_DAY = 0x00000004,
48 PVCU_MONTH = 0x00000005,
49 PVCU_YEAR = 0x00000006,
50};
@ PVCU_DEFAULT
Definition: propvarutil.h:43
@ PVCU_MONTH
Definition: propvarutil.h:48
@ PVCU_HOUR
Definition: propvarutil.h:46
@ PVCU_YEAR
Definition: propvarutil.h:49
@ PVCU_MINUTE
Definition: propvarutil.h:45
@ PVCU_SECOND
Definition: propvarutil.h:44
@ PVCU_DAY
Definition: propvarutil.h:47

Function Documentation

◆ InitPropVariantFromBuffer()

HRESULT WINAPI InitPropVariantFromBuffer ( const VOID pv,
UINT  cb,
PROPVARIANT *  ppropvar 
)

Definition at line 626 of file propvar.c.

627{
628 TRACE("(%p %u %p)\n", pv, cb, ppropvar);
629
630 ppropvar->u.caub.pElems = CoTaskMemAlloc(cb);
631 if(!ppropvar->u.caub.pElems)
632 return E_OUTOFMEMORY;
633
634 ppropvar->vt = VT_VECTOR|VT_UI1;
635 ppropvar->u.caub.cElems = cb;
636 memcpy(ppropvar->u.caub.pElems, pv, cb);
637 return S_OK;
638}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
@ VT_VECTOR
Definition: compat.h:2340
@ VT_UI1
Definition: compat.h:2311
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
#define S_OK
Definition: intsafe.h:52
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by test_InitPropVariantFromBuffer(), and test_PropVariantToBuffer().

◆ InitPropVariantFromCLSID()

HRESULT WINAPI InitPropVariantFromCLSID ( REFCLSID  clsid,
PROPVARIANT *  ppropvar 
)

Definition at line 640 of file propvar.c.

641{
642 TRACE("(%s %p)\n", debugstr_guid(clsid), ppropvar);
643
644 ppropvar->u.puuid = CoTaskMemAlloc(sizeof(*ppropvar->u.puuid));
645 if(!ppropvar->u.puuid)
646 return E_OUTOFMEMORY;
647
648 ppropvar->vt = VT_CLSID;
649 memcpy(ppropvar->u.puuid, clsid, sizeof(*ppropvar->u.puuid));
650 return S_OK;
651}
@ VT_CLSID
Definition: compat.h:2337
#define debugstr_guid
Definition: kernel32.h:35
REFCLSID clsid
Definition: msctf.c:82

Referenced by test_InitPropVariantFromCLSID(), and test_PropVariantToGUID().

◆ InitPropVariantFromGUIDAsString()

HRESULT WINAPI InitPropVariantFromGUIDAsString ( REFGUID  guid,
PROPVARIANT *  ppropvar 
)

Definition at line 592 of file propvar.c.

593{
594 TRACE("(%p %p)\n", guid, ppropvar);
595
596 if(!guid)
597 return E_FAIL;
598
599 ppropvar->vt = VT_LPWSTR;
600 ppropvar->u.pwszVal = CoTaskMemAlloc(39*sizeof(WCHAR));
601 if(!ppropvar->u.pwszVal)
602 return E_OUTOFMEMORY;
603
604 PROPVAR_GUIDToWSTR(guid, ppropvar->u.pwszVal);
605 return S_OK;
606}
#define E_FAIL
Definition: ddrawi.h:102
@ VT_LPWSTR
Definition: compat.h:2325
static void PROPVAR_GUIDToWSTR(REFGUID guid, WCHAR *str)
Definition: propvar.c:581
const GUID * guid
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by test_InitPropVariantFromGUIDAsString(), and test_PropVariantToGUID().

◆ InitVariantFromBuffer()

HRESULT WINAPI InitVariantFromBuffer ( const VOID pv,
UINT  cb,
VARIANT pvar 
)

Definition at line 653 of file propvar.c.

654{
655 SAFEARRAY *arr;
656 void *data;
658
659 TRACE("(%p %u %p)\n", pv, cb, pvar);
660
662 if(!arr)
663 return E_OUTOFMEMORY;
664
666 if(FAILED(hres)) {
667 SafeArrayDestroy(arr);
668 return hres;
669 }
670
671 memcpy(data, pv, cb);
672
674 if(FAILED(hres)) {
675 SafeArrayDestroy(arr);
676 return hres;
677 }
678
679 V_VT(pvar) = VT_ARRAY|VT_UI1;
680 V_ARRAY(pvar) = arr;
681 return S_OK;
682}
@ VT_ARRAY
Definition: compat.h:2341
HRESULT WINAPI SafeArrayAccessData(SAFEARRAY *psa, void **ppvData)
Definition: safearray.c:1137
HRESULT WINAPI SafeArrayUnaccessData(SAFEARRAY *psa)
Definition: safearray.c:1168
SAFEARRAY *WINAPI SafeArrayCreateVector(VARTYPE vt, LONG lLbound, ULONG cElements)
Definition: safearray.c:677
HRESULT WINAPI SafeArrayDestroy(SAFEARRAY *psa)
Definition: safearray.c:1347
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define FAILED(hr)
Definition: intsafe.h:51
HRESULT hres
Definition: protocol.c:465
#define V_ARRAY(A)
Definition: oleauto.h:222
#define V_VT(A)
Definition: oleauto.h:211

Referenced by test_InitPropVariantFromBuffer().

◆ InitVariantFromGUIDAsString()

HRESULT WINAPI InitVariantFromGUIDAsString ( REFGUID  guid,
VARIANT pvar 
)

Definition at line 608 of file propvar.c.

609{
610 TRACE("(%p %p)\n", guid, pvar);
611
612 if(!guid) {
613 FIXME("guid == NULL\n");
614 return E_FAIL;
615 }
616
617 V_VT(pvar) = VT_BSTR;
618 V_BSTR(pvar) = SysAllocStringLen(NULL, 38);
619 if(!V_BSTR(pvar))
620 return E_OUTOFMEMORY;
621
623 return S_OK;
624}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define NULL
Definition: types.h:112
@ VT_BSTR
Definition: compat.h:2303
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
Definition: oleaut.c:339
#define V_BSTR(A)
Definition: oleauto.h:226

Referenced by test_InitPropVariantFromGUIDAsString(), and test_PropVariantToGUID().

◆ PropVariantChangeType()

HRESULT WINAPI PropVariantChangeType ( PROPVARIANT *  ppropvarDest,
REFPROPVARIANT  propvarSrc,
PROPVAR_CHANGE_FLAGS  flags,
VARTYPE  vt 
)

Definition at line 428 of file propvar.c.

430{
431 HRESULT hr;
432
433 FIXME("(%p, %p, %d, %d, %d): semi-stub!\n", ppropvarDest, propvarSrc,
434 propvarSrc->vt, flags, vt);
435
436 if (vt == propvarSrc->vt)
437 return PropVariantCopy(ppropvarDest, propvarSrc);
438
439 if (propvarSrc->vt == VT_FILETIME)
440 return PROPVAR_ConvertFILETIME(&propvarSrc->u.filetime, ppropvarDest, vt);
441
442 switch (vt)
443 {
444 case VT_I1:
445 {
447
449 if (SUCCEEDED(hr))
450 {
451 ppropvarDest->vt = VT_I1;
452 ppropvarDest->u.cVal = (char)res;
453 }
454 return hr;
455 }
456
457 case VT_UI1:
458 {
460
462 if (SUCCEEDED(hr))
463 {
464 ppropvarDest->vt = VT_UI1;
465 ppropvarDest->u.bVal = (UCHAR)res;
466 }
467 return hr;
468 }
469
470 case VT_I2:
471 {
472 SHORT res;
474 if (SUCCEEDED(hr))
475 {
476 ppropvarDest->vt = VT_I2;
477 ppropvarDest->u.iVal = res;
478 }
479 return hr;
480 }
481 case VT_UI2:
482 {
483 USHORT res;
485 if (SUCCEEDED(hr))
486 {
487 ppropvarDest->vt = VT_UI2;
488 ppropvarDest->u.uiVal = res;
489 }
490 return hr;
491 }
492 case VT_I4:
493 {
494 LONG res;
496 if (SUCCEEDED(hr))
497 {
498 ppropvarDest->vt = VT_I4;
499 ppropvarDest->u.lVal = res;
500 }
501 return hr;
502 }
503 case VT_UI4:
504 {
505 ULONG res;
507 if (SUCCEEDED(hr))
508 {
509 ppropvarDest->vt = VT_UI4;
510 ppropvarDest->u.ulVal = res;
511 }
512 return hr;
513 }
514 case VT_I8:
515 {
518 if (SUCCEEDED(hr))
519 {
520 ppropvarDest->vt = VT_I8;
521 ppropvarDest->u.hVal.QuadPart = res;
522 }
523 return hr;
524 }
525 case VT_UI8:
526 {
529 if (SUCCEEDED(hr))
530 {
531 ppropvarDest->vt = VT_UI8;
532 ppropvarDest->u.uhVal.QuadPart = res;
533 }
534 return hr;
535 }
536
537 case VT_LPWSTR:
538 case VT_BSTR:
539 {
540 WCHAR *res;
542 if (SUCCEEDED(hr))
543 {
544 ppropvarDest->vt = VT_LPWSTR;
545 ppropvarDest->u.pwszVal = res;
546 }
547 return hr;
548 }
549
550 case VT_LPSTR:
551 {
552 WCHAR *resW;
554 if (SUCCEEDED(hr))
555 {
556 char *res;
557 DWORD len;
558
559 len = WideCharToMultiByte(CP_ACP, 0, resW, -1, NULL, 0, NULL, NULL);
561 if (res)
562 {
563 WideCharToMultiByte(CP_ACP, 0, resW, -1, res, len, NULL, NULL);
564 ppropvarDest->vt = VT_LPSTR;
565 ppropvarDest->u.pszVal = res;
566 }
567 else
569
570 CoTaskMemFree(resW);
571 }
572 return hr;
573 }
574
575 default:
576 FIXME("Unhandled dest type: %d\n", vt);
577 return E_FAIL;
578 }
579}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111
@ VT_UI8
Definition: compat.h:2315
@ VT_LPSTR
Definition: compat.h:2324
@ VT_UI2
Definition: compat.h:2312
@ VT_I8
Definition: compat.h:2314
@ VT_I1
Definition: compat.h:2310
@ VT_I4
Definition: compat.h:2298
@ VT_FILETIME
Definition: compat.h:2329
@ VT_I2
Definition: compat.h:2297
@ VT_UI4
Definition: compat.h:2313
static REFPROPVARIANT propvarSrc
Definition: suminfo.c:90
static REFPROPVARIANT PROPVAR_CHANGE_FLAGS VARTYPE vt
Definition: suminfo.c:91
HRESULT WINAPI PropVariantCopy(PROPVARIANT *pvarDest, const PROPVARIANT *pvarSrc)
Definition: ole2.c:3086
HRESULT WINAPI PropVariantToInt32(REFPROPVARIANT propvarIn, LONG *ret)
Definition: propvar.c:186
static HRESULT PROPVAR_ConvertFILETIME(const FILETIME *ft, PROPVARIANT *ppropvarDest, VARTYPE vt)
Definition: propvar.c:41
HRESULT WINAPI PropVariantToUInt16(REFPROPVARIANT propvarIn, USHORT *ret)
Definition: propvar.c:210
HRESULT WINAPI PropVariantToStringAlloc(REFPROPVARIANT propvarIn, WCHAR **ret)
Definition: propvar.c:356
static HRESULT PROPVAR_ConvertNumber(REFPROPVARIANT pv, int dest_bits, BOOL dest_signed, LONGLONG *res)
Definition: propvar.c:68
HRESULT WINAPI PropVariantToInt64(REFPROPVARIANT propvarIn, LONGLONG *ret)
Definition: propvar.c:198
HRESULT WINAPI PropVariantToUInt64(REFPROPVARIANT propvarIn, ULONGLONG *ret)
Definition: propvar.c:234
HRESULT WINAPI PropVariantToUInt32(REFPROPVARIANT propvarIn, ULONG *ret)
Definition: propvar.c:222
HRESULT WINAPI PropVariantToInt16(REFPROPVARIANT propvarIn, SHORT *ret)
Definition: propvar.c:174
unsigned char
Definition: typeof.h:29
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint res
Definition: glext.h:9613
GLbitfield flags
Definition: glext.h:7161
GLenum GLsizei len
Definition: glext.h:6722
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define SUCCEEDED(hr)
Definition: intsafe.h:50
short SHORT
Definition: pedump.c:59
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
HRESULT hr
Definition: shlfolder.c:183
int64_t LONGLONG
Definition: typedefs.h:68
uint32_t ULONG
Definition: typedefs.h:59
uint64_t ULONGLONG
Definition: typedefs.h:67
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by get_token(), MimeBody_GetProp(), PropVariantCompareEx(), and test_PropVariantChangeType_LPWSTR().

◆ PropVariantCompareEx()

INT WINAPI PropVariantCompareEx ( REFPROPVARIANT  propvar1,
REFPROPVARIANT  propvar2,
PROPVAR_COMPARE_UNIT  uint,
PROPVAR_COMPARE_FLAGS  flags 
)

Definition at line 814 of file propvar.c.

816{
817 const PROPVARIANT *propvar2_converted;
818 PROPVARIANT propvar2_static;
819 HRESULT hr;
820 INT res=-1;
821
822 TRACE("%p,%p,%x,%x\n", propvar1, propvar2, unit, flags);
823
824 if (isemptyornull(propvar1))
825 {
826 if (isemptyornull(propvar2))
827 return 0;
828 return (flags & PVCF_TREATEMPTYASGREATERTHAN) ? 1 : -1;
829 }
830
831 if (isemptyornull(propvar2))
832 return (flags & PVCF_TREATEMPTYASGREATERTHAN) ? -1 : 1;
833
834 if (propvar1->vt != propvar2->vt)
835 {
836 hr = PropVariantChangeType(&propvar2_static, propvar2, 0, propvar1->vt);
837
838 if (FAILED(hr))
839 return -1;
840
841 propvar2_converted = &propvar2_static;
842 }
843 else
844 propvar2_converted = propvar2;
845
846#define CMP_NUM_VALUE(var) do { \
847 if (propvar1->u.var > propvar2_converted->u.var) \
848 res = 1; \
849 else if (propvar1->u.var < propvar2_converted->u.var) \
850 res = -1; \
851 else \
852 res = 0; \
853 } while (0)
854
855 switch (propvar1->vt)
856 {
857 case VT_I1:
858 CMP_NUM_VALUE(cVal);
859 break;
860 case VT_UI1:
861 CMP_NUM_VALUE(bVal);
862 break;
863 case VT_I2:
864 CMP_NUM_VALUE(iVal);
865 break;
866 case VT_UI2:
867 CMP_NUM_VALUE(uiVal);
868 break;
869 case VT_I4:
870 CMP_NUM_VALUE(lVal);
871 break;
872 case VT_UI4:
873 CMP_NUM_VALUE(uiVal);
874 break;
875 case VT_I8:
876 CMP_NUM_VALUE(hVal.QuadPart);
877 break;
878 case VT_UI8:
879 CMP_NUM_VALUE(uhVal.QuadPart);
880 break;
881 case VT_R4:
882 CMP_NUM_VALUE(fltVal);
883 break;
884 case VT_R8:
885 CMP_NUM_VALUE(dblVal);
886 break;
887 case VT_BSTR:
888 case VT_LPWSTR:
889 /* FIXME: Use other string flags. */
891 res = lstrcmpiW(propvar1->u.bstrVal, propvar2_converted->u.bstrVal);
892 else
893 res = lstrcmpW(propvar1->u.bstrVal, propvar2_converted->u.bstrVal);
894 break;
895 case VT_LPSTR:
896 /* FIXME: Use other string flags. */
898 res = lstrcmpiA(propvar1->u.pszVal, propvar2_converted->u.pszVal);
899 else
900 res = lstrcmpA(propvar1->u.pszVal, propvar2_converted->u.pszVal);
901 break;
902 case VT_CLSID:
903 res = memcmp(propvar1->u.puuid, propvar2->u.puuid, sizeof(*propvar1->u.puuid));
904 if (res) res = res > 0 ? 1 : -1;
905 break;
906 default:
907 FIXME("vartype %#x not handled\n", propvar1->vt);
908 res = -1;
909 break;
910 }
911
912 if (propvar2_converted == &propvar2_static)
913 PropVariantClear(&propvar2_static);
914
915 return res;
916}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
@ VT_R4
Definition: compat.h:2299
@ VT_R8
Definition: compat.h:2300
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4243
int WINAPI lstrcmpA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4195
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4262
int WINAPI lstrcmpiA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4224
HRESULT WINAPI PropVariantClear(PROPVARIANT *pvar)
Definition: ole2.c:2968
#define CMP_NUM_VALUE(var)
static BOOL isemptyornull(const PROPVARIANT *propvar)
Definition: propvar.c:793
HRESULT WINAPI PropVariantChangeType(PROPVARIANT *ppropvarDest, REFPROPVARIANT propvarSrc, PROPVAR_CHANGE_FLAGS flags, VARTYPE vt)
Definition: propvar.c:428
png_const_structrp png_const_inforp int * unit
Definition: png.h:2159
int32_t INT
Definition: typedefs.h:58

Referenced by MetadataHandler_GetValue(), and test_PropVariantCompare().

◆ PropVariantToBoolean()

HRESULT WINAPI PropVariantToBoolean ( REFPROPVARIANT  propvarIn,
BOOL ret 
)

Definition at line 246 of file propvar.c.

247{
248 static const WCHAR trueW[] = {'t','r','u','e',0};
249 static const WCHAR falseW[] = {'f','a','l','s','e',0};
250 static const WCHAR true2W[] = {'#','T','R','U','E','#',0};
251 static const WCHAR false2W[] = {'#','F','A','L','S','E','#',0};
253 HRESULT hr;
254
255 TRACE("%p,%p\n", propvarIn, ret);
256
257 *ret = FALSE;
258
259 switch (propvarIn->vt)
260 {
261 case VT_BOOL:
262 *ret = propvarIn->u.boolVal == VARIANT_TRUE;
263 return S_OK;
264
265 case VT_LPWSTR:
266 case VT_BSTR:
267 if (!propvarIn->u.pwszVal)
268 return DISP_E_TYPEMISMATCH;
269
270 if (!lstrcmpiW(propvarIn->u.pwszVal, trueW) || !lstrcmpW(propvarIn->u.pwszVal, true2W))
271 {
272 *ret = TRUE;
273 return S_OK;
274 }
275
276 if (!lstrcmpiW(propvarIn->u.pwszVal, falseW) || !lstrcmpW(propvarIn->u.pwszVal, false2W))
277 {
278 *ret = FALSE;
279 return S_OK;
280 }
281 break;
282
283 case VT_LPSTR:
284 if (!propvarIn->u.pszVal)
285 return DISP_E_TYPEMISMATCH;
286
287 if (!lstrcmpiA(propvarIn->u.pszVal, "true") || !lstrcmpA(propvarIn->u.pszVal, "#TRUE#"))
288 {
289 *ret = TRUE;
290 return S_OK;
291 }
292
293 if (!lstrcmpiA(propvarIn->u.pszVal, "false") || !lstrcmpA(propvarIn->u.pszVal, "#FALSE#"))
294 {
295 *ret = FALSE;
296 return S_OK;
297 }
298 break;
299 }
300
301 hr = PROPVAR_ConvertNumber(propvarIn, 64, TRUE, &res);
302 *ret = !!res;
303 return hr;
304}
@ VT_BOOL
Definition: compat.h:2306
static const WCHAR falseW[]
Definition: json.c:34
static const WCHAR trueW[]
Definition: json.c:33
int ret
#define DISP_E_TYPEMISMATCH
Definition: winerror.h:2514

Referenced by test_PropVariantToBoolean().

◆ PropVariantToBuffer()

HRESULT WINAPI PropVariantToBuffer ( REFPROPVARIANT  propvarIn,
void ret,
UINT  cb 
)

Definition at line 306 of file propvar.c.

307{
308 HRESULT hr = S_OK;
309
310 TRACE("(%p, %p, %d)\n", propvarIn, ret, cb);
311
312 switch(propvarIn->vt)
313 {
314 case VT_VECTOR|VT_UI1:
315 if(cb > propvarIn->u.caub.cElems)
316 return E_FAIL;
317 memcpy(ret, propvarIn->u.caub.pElems, cb);
318 break;
319 case VT_ARRAY|VT_UI1:
320 FIXME("Unsupported type: VT_ARRAY|VT_UI1\n");
321 hr = E_NOTIMPL;
322 break;
323 default:
324 WARN("Unexpected type: %x\n", propvarIn->vt);
326 }
327
328 return hr;
329}
#define WARN(fmt,...)
Definition: precomp.h:61
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99

Referenced by test_PropVariantToBuffer().

◆ PropVariantToDouble()

HRESULT WINAPI PropVariantToDouble ( REFPROPVARIANT  propvarIn,
double ret 
)

Definition at line 162 of file propvar.c.

163{
165 HRESULT hr;
166
167 TRACE("(%p, %p)\n", propvarIn, ret);
168
169 hr = PROPVAR_ConvertNumber(propvarIn, 64, TRUE, &res);
170 if (SUCCEEDED(hr)) *ret = (double)res;
171 return hr;
172}
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80

Referenced by test_PropVariantToDouble().

◆ PropVariantToGUID()

HRESULT WINAPI PropVariantToGUID ( const PROPVARIANT *  ppropvar,
GUID guid 
)

Definition at line 756 of file propvar.c.

757{
758 TRACE("%p %p)\n", ppropvar, guid);
759
760 switch(ppropvar->vt) {
761 case VT_BSTR:
762 return PROPVAR_WCHARToGUID(ppropvar->u.bstrVal, SysStringLen(ppropvar->u.bstrVal), guid);
763 case VT_LPWSTR:
764 return PROPVAR_WCHARToGUID(ppropvar->u.pwszVal, lstrlenW(ppropvar->u.pwszVal), guid);
765 case VT_CLSID:
766 memcpy(guid, ppropvar->u.puuid, sizeof(*ppropvar->u.puuid));
767 return S_OK;
768
769 default:
770 FIXME("unsupported vt: %d\n", ppropvar->vt);
771 return E_NOTIMPL;
772 }
773}
#define lstrlenW
Definition: compat.h:750
static HRESULT PROPVAR_WCHARToGUID(const WCHAR *str, int len, GUID *guid)
Definition: propvar.c:708
UINT WINAPI SysStringLen(BSTR str)
Definition: oleaut.c:196

Referenced by test_PropVariantToGUID().

◆ PropVariantToInt16()

HRESULT WINAPI PropVariantToInt16 ( REFPROPVARIANT  propvarIn,
SHORT ret 
)

Definition at line 174 of file propvar.c.

175{
177 HRESULT hr;
178
179 TRACE("%p,%p\n", propvarIn, ret);
180
181 hr = PROPVAR_ConvertNumber(propvarIn, 16, TRUE, &res);
182 if (SUCCEEDED(hr)) *ret = (SHORT)res;
183 return hr;
184}

Referenced by PropVariantChangeType(), and test_intconversions().

◆ PropVariantToInt32()

HRESULT WINAPI PropVariantToInt32 ( REFPROPVARIANT  propvarIn,
LONG ret 
)

Definition at line 186 of file propvar.c.

187{
189 HRESULT hr;
190
191 TRACE("%p,%p\n", propvarIn, ret);
192
193 hr = PROPVAR_ConvertNumber(propvarIn, 32, TRUE, &res);
194 if (SUCCEEDED(hr)) *ret = (LONG)res;
195 return hr;
196}

Referenced by PropVariantChangeType(), and test_intconversions().

◆ PropVariantToInt64()

HRESULT WINAPI PropVariantToInt64 ( REFPROPVARIANT  propvarIn,
LONGLONG ret 
)

Definition at line 198 of file propvar.c.

199{
201 HRESULT hr;
202
203 TRACE("%p,%p\n", propvarIn, ret);
204
205 hr = PROPVAR_ConvertNumber(propvarIn, 64, TRUE, &res);
206 if (SUCCEEDED(hr)) *ret = res;
207 return hr;
208}

Referenced by propvar_cmp(), PropVariantChangeType(), and test_intconversions().

◆ PropVariantToString()

HRESULT WINAPI PropVariantToString ( REFPROPVARIANT  propvarIn,
PWSTR  ret,
UINT  cch 
)

Definition at line 332 of file propvar.c.

333{
334 HRESULT hr;
335 WCHAR *stringW = NULL;
336
337 TRACE("(%p, %p, %d)\n", propvarIn, ret, cch);
338
339 ret[0] = '\0';
340
341 if(!cch)
342 return E_INVALIDARG;
343
344 hr = PropVariantToStringAlloc(propvarIn, &stringW);
345 if(SUCCEEDED(hr))
346 {
347 if(lstrlenW(stringW) >= cch)
351 }
352
353 return hr;
354}
#define lstrcpynW
Definition: compat.h:738
static const WCHAR stringW[]
Definition: engine.c:38
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:202
#define STRSAFE_E_INSUFFICIENT_BUFFER
Definition: strsafe.h:103

Referenced by test_PropVariantToString().

◆ PropVariantToStringAlloc()

HRESULT WINAPI PropVariantToStringAlloc ( REFPROPVARIANT  propvarIn,
WCHAR **  ret 
)

Definition at line 356 of file propvar.c.

357{
358 WCHAR *res = NULL;
359 HRESULT hr = S_OK;
360
361 TRACE("%p,%p semi-stub\n", propvarIn, ret);
362
363 switch(propvarIn->vt)
364 {
365 case VT_EMPTY:
366 case VT_NULL:
367 res = CoTaskMemAlloc(1*sizeof(WCHAR));
368 res[0] = '\0';
369 break;
370
371 case VT_LPSTR:
372 if(propvarIn->u.pszVal)
373 {
374 DWORD len;
375
376 len = MultiByteToWideChar(CP_ACP, 0, propvarIn->u.pszVal, -1, NULL, 0);
377 res = CoTaskMemAlloc(len*sizeof(WCHAR));
378 if(!res)
379 return E_OUTOFMEMORY;
380
381 MultiByteToWideChar(CP_ACP, 0, propvarIn->u.pszVal, -1, res, len);
382 }
383 break;
384
385 case VT_LPWSTR:
386 case VT_BSTR:
387 if (propvarIn->u.pwszVal)
388 {
389 DWORD size = (lstrlenW(propvarIn->u.pwszVal) + 1) * sizeof(WCHAR);
391 if(!res) return E_OUTOFMEMORY;
392 memcpy(res, propvarIn->u.pwszVal, size);
393 }
394 break;
395
396 default:
397 FIXME("Unsupported conversion (%d)\n", propvarIn->vt);
398 hr = E_FAIL;
399 break;
400 }
401
402 *ret = res;
403
404 return hr;
405}
#define MultiByteToWideChar
Definition: compat.h:110
@ VT_NULL
Definition: compat.h:2296
@ VT_EMPTY
Definition: compat.h:2295
GLsizeiptr size
Definition: glext.h:5919

Referenced by PropVariantChangeType(), PropVariantToString(), and test_PropVariantToStringAlloc().

◆ PropVariantToStringWithDefault()

PCWSTR WINAPI PropVariantToStringWithDefault ( REFPROPVARIANT  propvarIn,
LPCWSTR  pszDefault 
)

Definition at line 407 of file propvar.c.

408{
409 static const WCHAR str_empty[] = {0};
410 if (propvarIn->vt == VT_BSTR)
411 {
412 if (propvarIn->u.bstrVal == NULL)
413 return str_empty;
414
415 return propvarIn->u.bstrVal;
416 }
417
418 if (propvarIn->vt == VT_LPWSTR && propvarIn->u.pwszVal != NULL)
419 return propvarIn->u.pwszVal;
420
421 return pszDefault;
422}

Referenced by test_PropVariantToStringWithDefault().

◆ PropVariantToUInt16()

HRESULT WINAPI PropVariantToUInt16 ( REFPROPVARIANT  propvarIn,
USHORT ret 
)

Definition at line 210 of file propvar.c.

211{
213 HRESULT hr;
214
215 TRACE("%p,%p\n", propvarIn, ret);
216
217 hr = PROPVAR_ConvertNumber(propvarIn, 16, FALSE, &res);
218 if (SUCCEEDED(hr)) *ret = (USHORT)res;
219 return hr;
220}

Referenced by PropVariantChangeType(), and test_intconversions().

◆ PropVariantToUInt32()

HRESULT WINAPI PropVariantToUInt32 ( REFPROPVARIANT  propvarIn,
ULONG ret 
)

Definition at line 222 of file propvar.c.

223{
225 HRESULT hr;
226
227 TRACE("%p,%p\n", propvarIn, ret);
228
229 hr = PROPVAR_ConvertNumber(propvarIn, 32, FALSE, &res);
230 if (SUCCEEDED(hr)) *ret = (ULONG)res;
231 return hr;
232}

Referenced by PropVariantChangeType(), and test_intconversions().

◆ PropVariantToUInt64()

HRESULT WINAPI PropVariantToUInt64 ( REFPROPVARIANT  propvarIn,
ULONGLONG ret 
)

Definition at line 234 of file propvar.c.

235{
237 HRESULT hr;
238
239 TRACE("%p,%p\n", propvarIn, ret);
240
241 hr = PROPVAR_ConvertNumber(propvarIn, 64, FALSE, &res);
242 if (SUCCEEDED(hr)) *ret = (ULONGLONG)res;
243 return hr;
244}

Referenced by PropVariantChangeType(), and test_intconversions().

◆ VariantToGUID()

HRESULT WINAPI VariantToGUID ( const VARIANT pvar,
GUID guid 
)

Definition at line 775 of file propvar.c.

776{
777 TRACE("(%p %p)\n", pvar, guid);
778
779 switch(V_VT(pvar)) {
780 case VT_BSTR: {
782 if(hres == E_INVALIDARG)
783 return E_FAIL;
784 return hres;
785 }
786
787 default:
788 FIXME("unsupported vt: %d\n", V_VT(pvar));
789 return E_NOTIMPL;
790 }
791}

Referenced by test_PropVariantToGUID().