ReactOS  0.4.13-dev-479-gec9c8fd
propvar.c
Go to the documentation of this file.
1 /*
2  * PropVariant implementation
3  *
4  * Copyright 2008 James Hawkins for CodeWeavers
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 "config.h"
22 #include "wine/port.h"
23 
24 #include <stdarg.h>
25 #include <stdio.h>
26 #include <stdlib.h>
27 
28 #define NONAMELESSUNION
29 
30 #include "windef.h"
31 #include "winbase.h"
32 #include "winerror.h"
33 #include "winreg.h"
34 #include "winuser.h"
35 #include "shlobj.h"
36 #include "propvarutil.h"
37 
38 #include "wine/debug.h"
39 #include "wine/unicode.h"
40 
42 
43 static HRESULT PROPVAR_ConvertFILETIME(const FILETIME *ft, PROPVARIANT *ppropvarDest, VARTYPE vt)
44 {
46 
48 
49  switch (vt)
50  {
51  case VT_LPSTR:
52  ppropvarDest->u.pszVal = HeapAlloc(GetProcessHeap(), 0, 64);
53  if (!ppropvarDest->u.pszVal)
54  return E_OUTOFMEMORY;
55 
56  sprintf( ppropvarDest->u.pszVal, "%04d/%02d/%02d:%02d:%02d:%02d.%03d",
57  time.wYear, time.wMonth, time.wDay,
58  time.wHour, time.wMinute, time.wSecond,
59  time.wMilliseconds );
60 
61  return S_OK;
62 
63  default:
64  FIXME("Unhandled target type: %d\n", vt);
65  }
66 
67  return E_FAIL;
68 }
69 
70 static HRESULT PROPVAR_ConvertNumber(REFPROPVARIANT pv, int dest_bits,
71  BOOL dest_signed, LONGLONG *res)
72 {
73  BOOL src_signed;
74 
75  switch (pv->vt)
76  {
77  case VT_I1:
78  src_signed = TRUE;
79  *res = pv->u.cVal;
80  break;
81  case VT_UI1:
82  src_signed = FALSE;
83  *res = pv->u.bVal;
84  break;
85  case VT_I2:
86  src_signed = TRUE;
87  *res = pv->u.iVal;
88  break;
89  case VT_UI2:
90  src_signed = FALSE;
91  *res = pv->u.uiVal;
92  break;
93  case VT_I4:
94  src_signed = TRUE;
95  *res = pv->u.lVal;
96  break;
97  case VT_UI4:
98  src_signed = FALSE;
99  *res = pv->u.ulVal;
100  break;
101  case VT_I8:
102  src_signed = TRUE;
103  *res = pv->u.hVal.QuadPart;
104  break;
105  case VT_UI8:
106  src_signed = FALSE;
107  *res = pv->u.uhVal.QuadPart;
108  break;
109  case VT_EMPTY:
110  src_signed = FALSE;
111  *res = 0;
112  break;
113  case VT_LPSTR:
114  {
115  char *end;
116  *res = _strtoi64(pv->u.pszVal, &end, 0);
117  if (pv->u.pszVal == end)
118  return DISP_E_TYPEMISMATCH;
119  src_signed = *res < 0;
120  break;
121  }
122  case VT_LPWSTR:
123  case VT_BSTR:
124  {
125  WCHAR *end;
126  *res = strtolW(pv->u.pwszVal, &end, 0);
127  if (pv->u.pwszVal == end)
128  return DISP_E_TYPEMISMATCH;
129  src_signed = *res < 0;
130  break;
131  }
132  default:
133  FIXME("unhandled vt %d\n", pv->vt);
134  return E_NOTIMPL;
135  }
136 
137  if (*res < 0 && src_signed != dest_signed)
139 
140  if (dest_bits < 64)
141  {
142  if (dest_signed)
143  {
144  if (*res >= ((LONGLONG)1 << (dest_bits-1)) ||
145  *res < ((LONGLONG)-1 << (dest_bits-1)))
147  }
148  else
149  {
150  if ((ULONGLONG)(*res) >= ((ULONGLONG)1 << dest_bits))
152  }
153  }
154 
155  return S_OK;
156 }
157 
158 HRESULT WINAPI PropVariantToInt16(REFPROPVARIANT propvarIn, SHORT *ret)
159 {
160  LONGLONG res;
161  HRESULT hr;
162 
163  TRACE("%p,%p\n", propvarIn, ret);
164 
165  hr = PROPVAR_ConvertNumber(propvarIn, 16, TRUE, &res);
166  if (SUCCEEDED(hr)) *ret = (SHORT)res;
167  return hr;
168 }
169 
170 HRESULT WINAPI PropVariantToInt32(REFPROPVARIANT propvarIn, LONG *ret)
171 {
172  LONGLONG res;
173  HRESULT hr;
174 
175  TRACE("%p,%p\n", propvarIn, ret);
176 
177  hr = PROPVAR_ConvertNumber(propvarIn, 32, TRUE, &res);
178  if (SUCCEEDED(hr)) *ret = (LONG)res;
179  return hr;
180 }
181 
182 HRESULT WINAPI PropVariantToInt64(REFPROPVARIANT propvarIn, LONGLONG *ret)
183 {
184  LONGLONG res;
185  HRESULT hr;
186 
187  TRACE("%p,%p\n", propvarIn, ret);
188 
189  hr = PROPVAR_ConvertNumber(propvarIn, 64, TRUE, &res);
190  if (SUCCEEDED(hr)) *ret = (LONGLONG)res;
191  return hr;
192 }
193 
194 HRESULT WINAPI PropVariantToUInt16(REFPROPVARIANT propvarIn, USHORT *ret)
195 {
196  LONGLONG res;
197  HRESULT hr;
198 
199  TRACE("%p,%p\n", propvarIn, ret);
200 
201  hr = PROPVAR_ConvertNumber(propvarIn, 16, FALSE, &res);
202  if (SUCCEEDED(hr)) *ret = (USHORT)res;
203  return hr;
204 }
205 
206 HRESULT WINAPI PropVariantToUInt32(REFPROPVARIANT propvarIn, ULONG *ret)
207 {
208  LONGLONG res;
209  HRESULT hr;
210 
211  TRACE("%p,%p\n", propvarIn, ret);
212 
213  hr = PROPVAR_ConvertNumber(propvarIn, 32, FALSE, &res);
214  if (SUCCEEDED(hr)) *ret = (ULONG)res;
215  return hr;
216 }
217 
218 HRESULT WINAPI PropVariantToUInt64(REFPROPVARIANT propvarIn, ULONGLONG *ret)
219 {
220  LONGLONG res;
221  HRESULT hr;
222 
223  TRACE("%p,%p\n", propvarIn, ret);
224 
225  hr = PROPVAR_ConvertNumber(propvarIn, 64, FALSE, &res);
226  if (SUCCEEDED(hr)) *ret = (ULONGLONG)res;
227  return hr;
228 }
229 
230 HRESULT WINAPI PropVariantToBoolean(REFPROPVARIANT propvarIn, BOOL *ret)
231 {
232  static const WCHAR trueW[] = {'t','r','u','e',0};
233  static const WCHAR falseW[] = {'f','a','l','s','e',0};
234  static const WCHAR true2W[] = {'#','T','R','U','E','#',0};
235  static const WCHAR false2W[] = {'#','F','A','L','S','E','#',0};
236  LONGLONG res;
237  HRESULT hr;
238 
239  TRACE("%p,%p\n", propvarIn, ret);
240 
241  *ret = FALSE;
242 
243  switch (propvarIn->vt)
244  {
245  case VT_BOOL:
246  *ret = propvarIn->u.boolVal == VARIANT_TRUE;
247  return S_OK;
248 
249  case VT_LPWSTR:
250  case VT_BSTR:
251  if (!propvarIn->u.pwszVal)
252  return DISP_E_TYPEMISMATCH;
253 
254  if (!lstrcmpiW(propvarIn->u.pwszVal, trueW) || !lstrcmpW(propvarIn->u.pwszVal, true2W))
255  {
256  *ret = TRUE;
257  return S_OK;
258  }
259 
260  if (!lstrcmpiW(propvarIn->u.pwszVal, falseW) || !lstrcmpW(propvarIn->u.pwszVal, false2W))
261  {
262  *ret = FALSE;
263  return S_OK;
264  }
265  break;
266 
267  case VT_LPSTR:
268  if (!propvarIn->u.pszVal)
269  return DISP_E_TYPEMISMATCH;
270 
271  if (!lstrcmpiA(propvarIn->u.pszVal, "true") || !lstrcmpA(propvarIn->u.pszVal, "#TRUE#"))
272  {
273  *ret = TRUE;
274  return S_OK;
275  }
276 
277  if (!lstrcmpiA(propvarIn->u.pszVal, "false") || !lstrcmpA(propvarIn->u.pszVal, "#FALSE#"))
278  {
279  *ret = FALSE;
280  return S_OK;
281  }
282  break;
283  }
284 
285  hr = PROPVAR_ConvertNumber(propvarIn, 64, TRUE, &res);
286  *ret = !!res;
287  return hr;
288 }
289 
290 HRESULT WINAPI PropVariantToStringAlloc(REFPROPVARIANT propvarIn, WCHAR **ret)
291 {
292  WCHAR *res = NULL;
293  HRESULT hr = S_OK;
294 
295  TRACE("%p,%p semi-stub\n", propvarIn, ret);
296 
297  switch(propvarIn->vt)
298  {
299  case VT_NULL:
300  res = CoTaskMemAlloc(1*sizeof(WCHAR));
301  res[0] = '\0';
302  break;
303 
304  case VT_LPSTR:
305  if(propvarIn->u.pszVal)
306  {
307  DWORD len;
308 
309  len = MultiByteToWideChar(CP_ACP, 0, propvarIn->u.pszVal, -1, NULL, 0);
310  res = CoTaskMemAlloc(len*sizeof(WCHAR));
311  if(!res)
312  return E_OUTOFMEMORY;
313 
314  MultiByteToWideChar(CP_ACP, 0, propvarIn->u.pszVal, -1, res, len);
315  }
316  break;
317 
318  case VT_LPWSTR:
319  case VT_BSTR:
320  if (propvarIn->u.pwszVal)
321  {
322  DWORD size = (lstrlenW(propvarIn->u.pwszVal) + 1) * sizeof(WCHAR);
324  if(!res) return E_OUTOFMEMORY;
325  memcpy(res, propvarIn->u.pwszVal, size);
326  }
327  break;
328 
329  default:
330  FIXME("Unsupported conversion (%d)\n", propvarIn->vt);
331  hr = E_FAIL;
332  break;
333  }
334 
335  *ret = res;
336 
337  return hr;
338 }
339 
340 PCWSTR WINAPI PropVariantToStringWithDefault(REFPROPVARIANT propvarIn, LPCWSTR pszDefault)
341 {
342  static const WCHAR str_empty[] = {0};
343  if (propvarIn->vt == VT_BSTR)
344  {
345  if (propvarIn->u.bstrVal == NULL)
346  return str_empty;
347 
348  return propvarIn->u.bstrVal;
349  }
350 
351  if (propvarIn->vt == VT_LPWSTR && propvarIn->u.pwszVal != NULL)
352  return propvarIn->u.pwszVal;
353 
354  return pszDefault;
355 }
356 
357 
358 /******************************************************************
359  * PropVariantChangeType (PROPSYS.@)
360  */
361 HRESULT WINAPI PropVariantChangeType(PROPVARIANT *ppropvarDest, REFPROPVARIANT propvarSrc,
363 {
364  HRESULT hr;
365 
366  FIXME("(%p, %p, %d, %d, %d): semi-stub!\n", ppropvarDest, propvarSrc,
367  propvarSrc->vt, flags, vt);
368 
369  if (vt == propvarSrc->vt)
370  return PropVariantCopy(ppropvarDest, propvarSrc);
371 
372  if (propvarSrc->vt == VT_FILETIME)
373  return PROPVAR_ConvertFILETIME(&propvarSrc->u.filetime, ppropvarDest, vt);
374 
375  switch (vt)
376  {
377  case VT_I1:
378  {
379  LONGLONG res;
380 
382  if (SUCCEEDED(hr))
383  {
384  ppropvarDest->vt = VT_I1;
385  ppropvarDest->u.cVal = (char)res;
386  }
387  return hr;
388  }
389 
390  case VT_UI1:
391  {
392  LONGLONG res;
393 
395  if (SUCCEEDED(hr))
396  {
397  ppropvarDest->vt = VT_UI1;
398  ppropvarDest->u.bVal = (UCHAR)res;
399  }
400  return hr;
401  }
402 
403  case VT_I2:
404  {
405  SHORT res;
407  if (SUCCEEDED(hr))
408  {
409  ppropvarDest->vt = VT_I2;
410  ppropvarDest->u.iVal = res;
411  }
412  return hr;
413  }
414  case VT_UI2:
415  {
416  USHORT res;
418  if (SUCCEEDED(hr))
419  {
420  ppropvarDest->vt = VT_UI2;
421  ppropvarDest->u.uiVal = res;
422  }
423  return hr;
424  }
425  case VT_I4:
426  {
427  LONG res;
429  if (SUCCEEDED(hr))
430  {
431  ppropvarDest->vt = VT_I4;
432  ppropvarDest->u.lVal = res;
433  }
434  return hr;
435  }
436  case VT_UI4:
437  {
438  ULONG res;
440  if (SUCCEEDED(hr))
441  {
442  ppropvarDest->vt = VT_UI4;
443  ppropvarDest->u.ulVal = res;
444  }
445  return hr;
446  }
447  case VT_I8:
448  {
449  LONGLONG res;
451  if (SUCCEEDED(hr))
452  {
453  ppropvarDest->vt = VT_I8;
454  ppropvarDest->u.hVal.QuadPart = res;
455  }
456  return hr;
457  }
458  case VT_UI8:
459  {
460  ULONGLONG res;
462  if (SUCCEEDED(hr))
463  {
464  ppropvarDest->vt = VT_UI8;
465  ppropvarDest->u.uhVal.QuadPart = res;
466  }
467  return hr;
468  }
469 
470  case VT_LPWSTR:
471  case VT_BSTR:
472  {
473  WCHAR *res;
475  if (SUCCEEDED(hr))
476  {
477  ppropvarDest->vt = VT_LPWSTR;
478  ppropvarDest->u.pwszVal = res;
479  }
480  return hr;
481  }
482 
483  case VT_LPSTR:
484  {
485  WCHAR *resW;
487  if (SUCCEEDED(hr))
488  {
489  char *res;
490  DWORD len;
491 
492  len = WideCharToMultiByte(CP_ACP, 0, resW, -1, NULL, 0, NULL, NULL);
494  if (res)
495  {
496  WideCharToMultiByte(CP_ACP, 0, resW, -1, res, len, NULL, NULL);
497  ppropvarDest->vt = VT_LPSTR;
498  ppropvarDest->u.pszVal = res;
499  }
500  else
501  hr = E_OUTOFMEMORY;
502 
503  CoTaskMemFree(resW);
504  }
505  return hr;
506  }
507 
508  default:
509  FIXME("Unhandled dest type: %d\n", vt);
510  return E_FAIL;
511  }
512 }
513 
515 {
516  static const WCHAR format[] = {'{','%','0','8','X','-','%','0','4','X','-','%','0','4','X',
517  '-','%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X','%','0','2','X',
518  '%','0','2','X','%','0','2','X','%','0','2','X','}',0};
519 
520  sprintfW(str, format, guid->Data1, guid->Data2, guid->Data3,
521  guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
522  guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]);
523 }
524 
526 {
527  TRACE("(%p %p)\n", guid, ppropvar);
528 
529  if(!guid)
530  return E_FAIL;
531 
532  ppropvar->vt = VT_LPWSTR;
533  ppropvar->u.pwszVal = CoTaskMemAlloc(39*sizeof(WCHAR));
534  if(!ppropvar->u.pwszVal)
535  return E_OUTOFMEMORY;
536 
537  PROPVAR_GUIDToWSTR(guid, ppropvar->u.pwszVal);
538  return S_OK;
539 }
540 
542 {
543  TRACE("(%p %p)\n", guid, pvar);
544 
545  if(!guid) {
546  FIXME("guid == NULL\n");
547  return E_FAIL;
548  }
549 
550  V_VT(pvar) = VT_BSTR;
551  V_BSTR(pvar) = SysAllocStringLen(NULL, 38);
552  if(!V_BSTR(pvar))
553  return E_OUTOFMEMORY;
554 
556  return S_OK;
557 }
558 
559 HRESULT WINAPI InitPropVariantFromBuffer(const VOID *pv, UINT cb, PROPVARIANT *ppropvar)
560 {
561  TRACE("(%p %u %p)\n", pv, cb, ppropvar);
562 
563  ppropvar->u.caub.pElems = CoTaskMemAlloc(cb);
564  if(!ppropvar->u.caub.pElems)
565  return E_OUTOFMEMORY;
566 
567  ppropvar->vt = VT_VECTOR|VT_UI1;
568  ppropvar->u.caub.cElems = cb;
569  memcpy(ppropvar->u.caub.pElems, pv, cb);
570  return S_OK;
571 }
572 
574 {
575  TRACE("(%s %p)\n", debugstr_guid(clsid), ppropvar);
576 
577  ppropvar->u.puuid = CoTaskMemAlloc(sizeof(*ppropvar->u.puuid));
578  if(!ppropvar->u.puuid)
579  return E_OUTOFMEMORY;
580 
581  ppropvar->vt = VT_CLSID;
582  memcpy(ppropvar->u.puuid, clsid, sizeof(*ppropvar->u.puuid));
583  return S_OK;
584 }
585 
587 {
588  SAFEARRAY *arr;
589  void *data;
590  HRESULT hres;
591 
592  TRACE("(%p %u %p)\n", pv, cb, pvar);
593 
594  arr = SafeArrayCreateVector(VT_UI1, 0, cb);
595  if(!arr)
596  return E_OUTOFMEMORY;
597 
598  hres = SafeArrayAccessData(arr, &data);
599  if(FAILED(hres)) {
600  SafeArrayDestroy(arr);
601  return hres;
602  }
603 
604  memcpy(data, pv, cb);
605 
607  if(FAILED(hres)) {
608  SafeArrayDestroy(arr);
609  return hres;
610  }
611 
612  V_VT(pvar) = VT_ARRAY|VT_UI1;
613  V_ARRAY(pvar) = arr;
614  return S_OK;
615 }
616 
617 static inline DWORD PROPVAR_HexToNum(const WCHAR *hex)
618 {
619  DWORD ret;
620 
621  if(hex[0]>='0' && hex[0]<='9')
622  ret = hex[0]-'0';
623  else if(hex[0]>='a' && hex[0]<='f')
624  ret = hex[0]-'a'+10;
625  else if(hex[0]>='A' && hex[0]<='F')
626  ret = hex[0]-'A'+10;
627  else
628  return -1;
629 
630  ret <<= 4;
631  if(hex[1]>='0' && hex[1]<='9')
632  return ret + hex[1]-'0';
633  else if(hex[1]>='a' && hex[1]<='f')
634  return ret + hex[1]-'a'+10;
635  else if(hex[1]>='A' && hex[1]<='F')
636  return ret + hex[1]-'A'+10;
637  else
638  return -1;
639 }
640 
641 static inline HRESULT PROPVAR_WCHARToGUID(const WCHAR *str, int len, GUID *guid)
642 {
643  DWORD i, val=0;
644  const WCHAR *p;
645 
646  memset(guid, 0, sizeof(GUID));
647 
648  if(len!=38 || str[0]!='{' || str[9]!='-' || str[14]!='-'
649  || str[19]!='-' || str[24]!='-' || str[37]!='}') {
650  WARN("Error parsing %s\n", debugstr_w(str));
651  return E_INVALIDARG;
652  }
653 
654  p = str+1;
655  for(i=0; i<4 && val!=-1; i++) {
657  guid->Data1 = (guid->Data1<<8) + val;
658  p += 2;
659  }
660  p++;
661  for(i=0; i<2 && val!=-1; i++) {
663  guid->Data2 = (guid->Data2<<8) + val;
664  p += 2;
665  }
666  p++;
667  for(i=0; i<2 && val!=-1; i++) {
669  guid->Data3 = (guid->Data3<<8) + val;
670  p += 2;
671  }
672  p++;
673  for(i=0; i<8 && val!=-1; i++) {
674  if(i == 2)
675  p++;
676 
677  val = guid->Data4[i] = PROPVAR_HexToNum(p);
678  p += 2;
679  }
680 
681  if(val == -1) {
682  WARN("Error parsing %s\n", debugstr_w(str));
683  memset(guid, 0, sizeof(GUID));
684  return E_INVALIDARG;
685  }
686  return S_OK;
687 }
688 
689 HRESULT WINAPI PropVariantToGUID(const PROPVARIANT *ppropvar, GUID *guid)
690 {
691  TRACE("%p %p)\n", ppropvar, guid);
692 
693  switch(ppropvar->vt) {
694  case VT_BSTR:
695  return PROPVAR_WCHARToGUID(ppropvar->u.bstrVal, SysStringLen(ppropvar->u.bstrVal), guid);
696  case VT_LPWSTR:
697  return PROPVAR_WCHARToGUID(ppropvar->u.pwszVal, strlenW(ppropvar->u.pwszVal), guid);
698 
699  default:
700  FIXME("unsupported vt: %d\n", ppropvar->vt);
701  return E_NOTIMPL;
702  }
703 }
704 
706 {
707  TRACE("(%p %p)\n", pvar, guid);
708 
709  switch(V_VT(pvar)) {
710  case VT_BSTR: {
712  if(hres == E_INVALIDARG)
713  return E_FAIL;
714  return hres;
715  }
716 
717  default:
718  FIXME("unsupported vt: %d\n", V_VT(pvar));
719  return E_NOTIMPL;
720  }
721 }
722 
723 static BOOL isemptyornull(const PROPVARIANT *propvar)
724 {
725  if (propvar->vt == VT_EMPTY || propvar->vt == VT_NULL)
726  return TRUE;
727  if ((propvar->vt & VT_ARRAY) == VT_ARRAY)
728  {
729  int i;
730  for (i=0; i<propvar->u.parray->cDims; i++)
731  {
732  if (propvar->u.parray->rgsabound[i].cElements != 0)
733  break;
734  }
735  return i == propvar->u.parray->cDims;
736  }
737  /* FIXME: vectors, byrefs, errors? */
738  return FALSE;
739 }
740 
741 INT WINAPI PropVariantCompareEx(REFPROPVARIANT propvar1, REFPROPVARIANT propvar2,
743 {
744  const PROPVARIANT *propvar2_converted;
745  PROPVARIANT propvar2_static;
746  HRESULT hr;
747  INT res=-1;
748 
749  TRACE("%p,%p,%x,%x\n", propvar1, propvar2, unit, flags);
750 
751  if (isemptyornull(propvar1))
752  {
753  if (isemptyornull(propvar2))
754  return 0;
755  return (flags & PVCF_TREATEMPTYASGREATERTHAN) ? 1 : -1;
756  }
757 
758  if (isemptyornull(propvar2))
759  return (flags & PVCF_TREATEMPTYASGREATERTHAN) ? -1 : 1;
760 
761  if (propvar1->vt != propvar2->vt)
762  {
763  hr = PropVariantChangeType(&propvar2_static, propvar2, 0, propvar1->vt);
764 
765  if (FAILED(hr))
766  return -1;
767 
768  propvar2_converted = &propvar2_static;
769  }
770  else
771  propvar2_converted = propvar2;
772 
773 #define CMP_INT_VALUE(var) do { \
774  if (propvar1->u.var > propvar2_converted->u.var) \
775  res = 1; \
776  else if (propvar1->u.var < propvar2_converted->u.var) \
777  res = -1; \
778  else \
779  res = 0; \
780  } while (0)
781 
782  switch (propvar1->vt)
783  {
784  case VT_I1:
785  CMP_INT_VALUE(cVal);
786  break;
787  case VT_UI1:
788  CMP_INT_VALUE(bVal);
789  break;
790  case VT_I2:
791  CMP_INT_VALUE(iVal);
792  break;
793  case VT_UI2:
794  CMP_INT_VALUE(uiVal);
795  break;
796  case VT_I4:
797  CMP_INT_VALUE(lVal);
798  break;
799  case VT_UI4:
800  CMP_INT_VALUE(uiVal);
801  break;
802  case VT_I8:
803  CMP_INT_VALUE(hVal.QuadPart);
804  break;
805  case VT_UI8:
806  CMP_INT_VALUE(uhVal.QuadPart);
807  break;
808  case VT_BSTR:
809  case VT_LPWSTR:
810  /* FIXME: Use other string flags. */
812  res = lstrcmpiW(propvar1->u.bstrVal, propvar2_converted->u.bstrVal);
813  else
814  res = lstrcmpW(propvar1->u.bstrVal, propvar2_converted->u.bstrVal);
815  break;
816  case VT_LPSTR:
817  /* FIXME: Use other string flags. */
819  res = lstrcmpiA(propvar1->u.pszVal, propvar2_converted->u.pszVal);
820  else
821  res = lstrcmpA(propvar1->u.pszVal, propvar2_converted->u.pszVal);
822  break;
823  default:
824  FIXME("vartype %d not handled\n", propvar1->vt);
825  res = -1;
826  break;
827  }
828 
829  if (propvar2_converted == &propvar2_static)
830  PropVariantClear(&propvar2_static);
831 
832  return res;
833 }
HRESULT WINAPI PropVariantToUInt16(REFPROPVARIANT propvarIn, USHORT *ret)
Definition: propvar.c:194
const uint16_t * PCWSTR
Definition: typedefs.h:55
#define TRUE
Definition: types.h:120
Definition: compat.h:1939
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:422
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
int WINAPI lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:42
#define WideCharToMultiByte
Definition: compat.h:101
Definition: compat.h:1955
HRESULT hr
Definition: shlfolder.c:183
Definition: scsiwmi.h:51
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
Definition: oleaut.c:342
Definition: compat.h:1951
HRESULT WINAPI PropVariantClear(PROPVARIANT *pvar)
Definition: ole2.c:2952
int PROPVAR_COMPARE_FLAGS
Definition: propvarutil.h:60
#define REFCLSID
Definition: guiddef.h:112
#define CP_ACP
Definition: compat.h:99
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
static HRESULT PROPVAR_ConvertFILETIME(const FILETIME *ft, PROPVARIANT *ppropvarDest, VARTYPE vt)
Definition: propvar.c:43
int PROPVAR_COMPARE_UNIT
Definition: propvarutil.h:48
#define V_ARRAY(A)
Definition: oleauto.h:222
_Check_return_ __MINGW_EXTENSION _CRTIMP __int64 __cdecl _strtoi64(_In_z_ const char *_String, _Out_opt_ _Deref_post_z_ char **_EndPtr, _In_ int _Radix)
#define WARN(fmt,...)
Definition: debug.h:111
#define strtolW(s, e, b)
Definition: unicode.h:33
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
HRESULT WINAPI PropVariantChangeType(PROPVARIANT *ppropvarDest, REFPROPVARIANT propvarSrc, PROPVAR_CHANGE_FLAGS flags, VARTYPE vt)
Definition: propvar.c:361
GLuint GLuint end
Definition: gl.h:1545
__u16 time
Definition: mkdosfs.c:366
static const char hex[16]
Definition: profile.c:123
HRESULT WINAPI VariantToGUID(const VARIANT *pvar, GUID *guid)
Definition: propvar.c:705
#define lstrlenW
Definition: compat.h:407
#define E_FAIL
Definition: ddrawi.h:102
INT WINAPI PropVariantCompareEx(REFPROPVARIANT propvar1, REFPROPVARIANT propvar2, PROPVAR_COMPARE_UNIT unit, PROPVAR_COMPARE_FLAGS flags)
Definition: propvar.c:741
static REFPROPVARIANT propvarSrc
Definition: suminfo.c:85
int32_t INT
Definition: typedefs.h:56
int PROPVAR_CHANGE_FLAGS
Definition: propvarutil.h:35
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
HRESULT WINAPI PropVariantToInt32(REFPROPVARIANT propvarIn, LONG *ret)
Definition: propvar.c:170
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
#define sprintf(buf, format,...)
Definition: sprintf.c:55
PCWSTR WINAPI PropVariantToStringWithDefault(REFPROPVARIANT propvarIn, LPCWSTR pszDefault)
Definition: propvar.c:340
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
const GUID * guid
WINE_DEFAULT_DEBUG_CHANNEL(propsys)
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
HRESULT WINAPI SafeArrayAccessData(SAFEARRAY *psa, void **ppvData)
Definition: safearray.c:1139
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
static HRESULT PROPVAR_WCHARToGUID(const WCHAR *str, int len, GUID *guid)
Definition: propvar.c:641
short SHORT
Definition: pedump.c:59
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_INVALIDARG
Definition: ddrawi.h:101
png_const_structrp png_const_inforp int * unit
Definition: png.h:2161
const WCHAR * str
static HRESULT PROPVAR_ConvertNumber(REFPROPVARIANT pv, int dest_bits, BOOL dest_signed, LONGLONG *res)
Definition: propvar.c:70
smooth NULL
Definition: ftsmooth.c:416
unsigned char
Definition: typeof.h:29
static void PROPVAR_GUIDToWSTR(REFGUID guid, WCHAR *str)
Definition: propvar.c:514
HRESULT WINAPI PropVariantToStringAlloc(REFPROPVARIANT propvarIn, WCHAR **ret)
Definition: propvar.c:290
#define ERROR_ARITHMETIC_OVERFLOW
Definition: winerror.h:351
#define debugstr_guid
Definition: kernel32.h:35
GLuint GLfloat * val
Definition: glext.h:7180
HRESULT WINAPI PropVariantCopy(PROPVARIANT *pvarDest, const PROPVARIANT *pvarSrc)
Definition: ole2.c:3068
HRESULT WINAPI InitPropVariantFromGUIDAsString(REFGUID guid, PROPVARIANT *ppropvar)
Definition: propvar.c:525
int64_t LONGLONG
Definition: typedefs.h:66
HRESULT WINAPI InitPropVariantFromBuffer(const VOID *pv, UINT cb, PROPVARIANT *ppropvar)
Definition: propvar.c:559
#define DISP_E_TYPEMISMATCH
Definition: winerror.h:2514
#define TRACE(s)
Definition: solgame.cpp:4
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:178
HRESULT WINAPI PropVariantToGUID(const PROPVARIANT *ppropvar, GUID *guid)
Definition: propvar.c:689
GLsizeiptr size
Definition: glext.h:5919
HRESULT hres
Definition: protocol.c:465
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
uint64_t ULONGLONG
Definition: typedefs.h:65
static const WCHAR falseW[]
Definition: json.c:35
#define WINAPI
Definition: msvc.h:8
unsigned long DWORD
Definition: ntddk_ex.h:95
static REFPROPVARIANT PROPVAR_CHANGE_FLAGS VARTYPE vt
Definition: suminfo.c:85
static DWORD cb
Definition: integrity.c:41
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
HRESULT WINAPI SafeArrayDestroy(SAFEARRAY *psa)
Definition: safearray.c:1349
SAFEARRAY *WINAPI SafeArrayCreateVector(VARTYPE vt, LONG lLbound, ULONG cElements)
Definition: safearray.c:679
unsigned char UCHAR
Definition: xmlstorage.h:181
int ret
HRESULT WINAPI PropVariantToUInt64(REFPROPVARIANT propvarIn, ULONGLONG *ret)
Definition: propvar.c:218
REFCLSID clsid
Definition: msctf.c:84
#define V_VT(A)
Definition: oleauto.h:211
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
HRESULT WINAPI PropVariantToUInt32(REFPROPVARIANT propvarIn, ULONG *ret)
Definition: propvar.c:206
UINT WINAPI SysStringLen(BSTR str)
Definition: oleaut.c:199
HRESULT WINAPI InitPropVariantFromCLSID(REFCLSID clsid, PROPVARIANT *ppropvar)
Definition: propvar.c:573
static DWORD PROPVAR_HexToNum(const WCHAR *hex)
Definition: propvar.c:617
#define V_BSTR(A)
Definition: oleauto.h:226
#define S_OK
Definition: intsafe.h:59
HRESULT WINAPI InitVariantFromGUIDAsString(REFGUID guid, VARIANT *pvar)
Definition: propvar.c:541
unsigned short USHORT
Definition: pedump.c:61
static IPropertySystem propsys
Definition: propsys_main.c:238
#define E_NOTIMPL
Definition: ddrawi.h:99
#define sprintfW
Definition: unicode.h:58
unsigned short VARTYPE
Definition: compat.h:1895
#define CMP_INT_VALUE(var)
HRESULT WINAPI InitVariantFromBuffer(const VOID *pv, UINT cb, VARIANT *pvar)
Definition: propvar.c:586
unsigned int UINT
Definition: ndis.h:50
HRESULT WINAPI PropVariantToInt16(REFPROPVARIANT propvarIn, SHORT *ret)
Definition: propvar.c:158
#define MultiByteToWideChar
Definition: compat.h:100
HRESULT WINAPI PropVariantToBoolean(REFPROPVARIANT propvarIn, BOOL *ret)
Definition: propvar.c:230
static BOOL isemptyornull(const PROPVARIANT *propvar)
Definition: propvar.c:723
HRESULT WINAPI PropVariantToInt64(REFPROPVARIANT propvarIn, LONGLONG *ret)
Definition: propvar.c:182
GLuint res
Definition: glext.h:9613
unsigned int ULONG
Definition: retypes.h:1
GLfloat GLfloat p
Definition: glext.h:8902
static const WCHAR trueW[]
Definition: json.c:34
#define memset(x, y, z)
Definition: compat.h:39
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:406
HRESULT WINAPI SafeArrayUnaccessData(SAFEARRAY *psa)
Definition: safearray.c:1170
Definition: compat.h:1938
#define SUCCEEDED(hr)
Definition: intsafe.h:57