📄 prop.c
字号:
*
* PARAMS
* lpPropLeft [I] Left hand property to compare to lpPropRight
* ulOp [I] Comparison operator (RELOP_* enum from "mapidefs.h")
* lpPropRight [I] Right hand property to compare to lpPropLeft
*
* RETURNS
* TRUE, if the comparison is true, FALSE otherwise.
*/
BOOL WINAPI FPropCompareProp(LPSPropValue lpPropLeft, ULONG ulOp, LPSPropValue lpPropRight)
{
LONG iCmp;
TRACE("(%p,%d,%p)\n", lpPropLeft, ulOp, lpPropRight);
if (ulOp > RELOP_RE || FBadProp(lpPropLeft) || FBadProp(lpPropRight))
return FALSE;
if (ulOp == RELOP_RE)
{
FIXME("Comparison operator RELOP_RE not yet implemented!\n");
return FALSE;
}
iCmp = LPropCompareProp(lpPropLeft, lpPropRight);
switch (ulOp)
{
case RELOP_LT: return iCmp < 0 ? TRUE : FALSE;
case RELOP_LE: return iCmp <= 0 ? TRUE : FALSE;
case RELOP_GT: return iCmp > 0 ? TRUE : FALSE;
case RELOP_GE: return iCmp >= 0 ? TRUE : FALSE;
case RELOP_EQ: return iCmp == 0 ? TRUE : FALSE;
case RELOP_NE: return iCmp != 0 ? TRUE : FALSE;
}
return FALSE;
}
/*************************************************************************
* LPropCompareProp@8 (MAPI32.80)
*
* Compare two properties.
*
* PARAMS
* lpPropLeft [I] Left hand property to compare to lpPropRight
* lpPropRight [I] Right hand property to compare to lpPropLeft
*
* RETURNS
* An integer less than, equal to or greater than 0, indicating that
* lpszStr is less than, the same, or greater than lpszComp.
*/
LONG WINAPI LPropCompareProp(LPSPropValue lpPropLeft, LPSPropValue lpPropRight)
{
LONG iRet;
TRACE("(%p->0x%08x,%p->0x%08x)\n", lpPropLeft, lpPropLeft->ulPropTag,
lpPropRight, lpPropRight->ulPropTag);
/* If the properties are not the same, sort by property type */
if (PROP_TYPE(lpPropLeft->ulPropTag) != PROP_TYPE(lpPropRight->ulPropTag))
return (LONG)PROP_TYPE(lpPropLeft->ulPropTag) - (LONG)PROP_TYPE(lpPropRight->ulPropTag);
switch (PROP_TYPE(lpPropLeft->ulPropTag))
{
case PT_UNSPECIFIED:
case PT_NULL:
return 0; /* NULLs are equal */
case PT_I2:
return lpPropLeft->Value.i - lpPropRight->Value.i;
case PT_I4:
return lpPropLeft->Value.l - lpPropRight->Value.l;
case PT_I8:
if (lpPropLeft->Value.li.QuadPart > lpPropRight->Value.li.QuadPart)
return 1;
if (lpPropLeft->Value.li.QuadPart == lpPropRight->Value.li.QuadPart)
return 0;
return -1;
case PT_R4:
if (lpPropLeft->Value.flt > lpPropRight->Value.flt)
return 1;
if (lpPropLeft->Value.flt == lpPropRight->Value.flt)
return 0;
return -1;
case PT_APPTIME:
case PT_R8:
if (lpPropLeft->Value.dbl > lpPropRight->Value.dbl)
return 1;
if (lpPropLeft->Value.dbl == lpPropRight->Value.dbl)
return 0;
return -1;
case PT_CURRENCY:
if (lpPropLeft->Value.cur.int64 > lpPropRight->Value.cur.int64)
return 1;
if (lpPropLeft->Value.cur.int64 == lpPropRight->Value.cur.int64)
return 0;
return -1;
case PT_SYSTIME:
return CompareFileTime(&lpPropLeft->Value.ft, &lpPropRight->Value.ft);
case PT_BOOLEAN:
return (lpPropLeft->Value.b ? 1 : 0) - (lpPropRight->Value.b ? 1 : 0);
case PT_BINARY:
if (lpPropLeft->Value.bin.cb == lpPropRight->Value.bin.cb)
iRet = memcmp(lpPropLeft->Value.bin.lpb, lpPropRight->Value.bin.lpb,
lpPropLeft->Value.bin.cb);
else
{
iRet = memcmp(lpPropLeft->Value.bin.lpb, lpPropRight->Value.bin.lpb,
min(lpPropLeft->Value.bin.cb, lpPropRight->Value.bin.cb));
if (!iRet)
iRet = lpPropLeft->Value.bin.cb - lpPropRight->Value.bin.cb;
}
return iRet;
case PT_STRING8:
return lstrcmpA(lpPropLeft->Value.lpszA, lpPropRight->Value.lpszA);
case PT_UNICODE:
return strcmpW(lpPropLeft->Value.lpszW, lpPropRight->Value.lpszW);
case PT_ERROR:
if (lpPropLeft->Value.err > lpPropRight->Value.err)
return 1;
if (lpPropLeft->Value.err == lpPropRight->Value.err)
return 0;
return -1;
case PT_CLSID:
return memcmp(lpPropLeft->Value.lpguid, lpPropRight->Value.lpguid,
sizeof(GUID));
}
FIXME("Unhandled property type %d\n", PROP_TYPE(lpPropLeft->ulPropTag));
return 0;
}
/*************************************************************************
* HrGetOneProp@8 (MAPI32.135)
*
* Get a property value from an IMAPIProp object.
*
* PARAMS
* lpIProp [I] IMAPIProp object to get the property value in
* ulPropTag [I] Property tag of the property to get
* lppProp [O] Destination for the returned property
*
* RETURNS
* Success: S_OK. *lppProp contains the property value requested.
* Failure: MAPI_E_NOT_FOUND, if no property value has the tag given by ulPropTag.
*/
HRESULT WINAPI HrGetOneProp(LPMAPIPROP lpIProp, ULONG ulPropTag, LPSPropValue *lppProp)
{
SPropTagArray pta;
ULONG ulCount;
HRESULT hRet;
TRACE("(%p,%d,%p)\n", lpIProp, ulPropTag, lppProp);
pta.cValues = 1u;
pta.aulPropTag[0] = ulPropTag;
hRet = IMAPIProp_GetProps(lpIProp, &pta, 0u, &ulCount, lppProp);
if (hRet == MAPI_W_ERRORS_RETURNED)
{
MAPIFreeBuffer(*lppProp);
*lppProp = NULL;
hRet = MAPI_E_NOT_FOUND;
}
return hRet;
}
/*************************************************************************
* HrSetOneProp@8 (MAPI32.136)
*
* Set a property value in an IMAPIProp object.
*
* PARAMS
* lpIProp [I] IMAPIProp object to set the property value in
* lpProp [I] Property value to set
*
* RETURNS
* Success: S_OK. The value in lpProp is set in lpIProp.
* Failure: An error result from IMAPIProp_SetProps().
*/
HRESULT WINAPI HrSetOneProp(LPMAPIPROP lpIProp, LPSPropValue lpProp)
{
TRACE("(%p,%p)\n", lpIProp, lpProp);
return IMAPIProp_SetProps(lpIProp, 1u, lpProp, NULL);
}
/*************************************************************************
* FPropExists@8 (MAPI32.137)
*
* Find a property with a given property tag in an IMAPIProp object.
*
* PARAMS
* lpIProp [I] IMAPIProp object to find the property tag in
* ulPropTag [I] Property tag to find
*
* RETURNS
* TRUE, if ulPropTag matches a property held in lpIProp,
* FALSE, otherwise.
*
* NOTES
* if ulPropTag has a property type of PT_UNSPECIFIED, then only the property
* Ids need to match for a successful match to occur.
*/
BOOL WINAPI FPropExists(LPMAPIPROP lpIProp, ULONG ulPropTag)
{
BOOL bRet = FALSE;
TRACE("(%p,%d)\n", lpIProp, ulPropTag);
if (lpIProp)
{
LPSPropTagArray lpTags;
ULONG i;
if (FAILED(IMAPIProp_GetPropList(lpIProp, 0u, &lpTags)))
return FALSE;
for (i = 0; i < lpTags->cValues; i++)
{
if (!FBadPropTag(lpTags->aulPropTag[i]) &&
(lpTags->aulPropTag[i] == ulPropTag ||
(PROP_TYPE(ulPropTag) == PT_UNSPECIFIED &&
PROP_ID(lpTags->aulPropTag[i]) == lpTags->aulPropTag[i])))
{
bRet = TRUE;
break;
}
}
MAPIFreeBuffer(lpTags);
}
return bRet;
}
/*************************************************************************
* PpropFindProp@12 (MAPI32.138)
*
* Find a property with a given property tag in a property array.
*
* PARAMS
* lpProps [I] Property array to search
* cValues [I] Number of properties in lpProps
* ulPropTag [I] Property tag to find
*
* RETURNS
* A pointer to the matching property, or NULL if none was found.
*
* NOTES
* if ulPropTag has a property type of PT_UNSPECIFIED, then only the property
* Ids need to match for a successful match to occur.
*/
LPSPropValue WINAPI PpropFindProp(LPSPropValue lpProps, ULONG cValues, ULONG ulPropTag)
{
TRACE("(%p,%d,%d)\n", lpProps, cValues, ulPropTag);
if (lpProps && cValues)
{
ULONG i;
for (i = 0; i < cValues; i++)
{
if (!FBadPropTag(lpProps[i].ulPropTag) &&
(lpProps[i].ulPropTag == ulPropTag ||
(PROP_TYPE(ulPropTag) == PT_UNSPECIFIED &&
PROP_ID(lpProps[i].ulPropTag) == PROP_ID(ulPropTag))))
return &lpProps[i];
}
}
return NULL;
}
/*************************************************************************
* FreePadrlist@4 (MAPI32.139)
*
* Free the memory used by an address book list.
*
* PARAMS
* lpAddrs [I] Address book list to free
*
* RETURNS
* Nothing.
*/
VOID WINAPI FreePadrlist(LPADRLIST lpAddrs)
{
TRACE("(%p)\n", lpAddrs);
/* Structures are binary compatible; use the same implementation */
return FreeProws((LPSRowSet)lpAddrs);
}
/*************************************************************************
* FreeProws@4 (MAPI32.140)
*
* Free the memory used by a row set.
*
* PARAMS
* lpRowSet [I] Row set to free
*
* RETURNS
* Nothing.
*/
VOID WINAPI FreeProws(LPSRowSet lpRowSet)
{
TRACE("(%p)\n", lpRowSet);
if (lpRowSet)
{
ULONG i;
for (i = 0; i < lpRowSet->cRows; i++)
MAPIFreeBuffer(lpRowSet->aRow[i].lpProps);
MAPIFreeBuffer(lpRowSet);
}
}
/*************************************************************************
* ScCountProps@12 (MAPI32.170)
*
* Validate and determine the length of an array of properties.
*
* PARAMS
* iCount [I] Length of the lpProps array
* lpProps [I] Array of properties to validate/size
* pcBytes [O] If non-NULL, destination for the size of the property array
*
* RETURNS
* Success: S_OK. If pcBytes is non-NULL, it contains the size of the propery array.
* Failure: MAPI_E_INVALID_PARAMETER, if any parameter is invalid or validation
* of the property array fails.
*/
SCODE WINAPI ScCountProps(INT iCount, LPSPropValue lpProps, ULONG *pcBytes)
{
ULONG i, ulCount = iCount, ulBytes = 0;
TRACE("(%d,%p,%p)\n", iCount, lpProps, pcBytes);
if (iCount <= 0 || !lpProps ||
IsBadReadPtr(lpProps, iCount * sizeof(SPropValue)))
return MAPI_E_INVALID_PARAMETER;
for (i = 0; i < ulCount; i++)
{
ULONG ulPropSize = 0;
if (FBadProp(&lpProps[i]) || lpProps[i].ulPropTag == PROP_ID_NULL ||
lpProps[i].ulPropTag == PROP_ID_INVALID)
return MAPI_E_INVALID_PARAMETER;
if (PROP_TYPE(lpProps[i].ulPropTag) != PT_OBJECT)
{
ulPropSize = UlPropSize(&lpProps[i]);
if (!ulPropSize)
return MAPI_E_INVALID_PARAMETER;
}
switch (PROP_TYPE(lpProps[i].ulPropTag))
{
case PT_STRING8:
case PT_UNICODE:
case PT_CLSID:
case PT_BINARY:
case PT_MV_I2:
case PT_MV_I4:
case PT_MV_I8:
case PT_MV_R4:
case PT_MV_R8:
case PT_MV_CURRENCY:
case PT_MV_SYSTIME:
case PT_MV_APPTIME:
ulPropSize += sizeof(SPropValue);
break;
case PT_MV_CLSID:
ulPropSize += lpProps[i].Value.MVszA.cValues * sizeof(char*) + sizeof(SPropValue);
break;
case PT_MV_STRING8:
case PT_MV_UNICODE:
ulPropSize += lpProps[i].Value.MVszA.cValues * sizeof(char*) + sizeof(SPropValue);
break;
case PT_MV_BINARY:
ulPropSize += lpProps[i].Value.MVbin.cValues * sizeof(SBinary) + sizeof(SPropValue);
break;
default:
ulPropSize = sizeof(SPropValue);
break;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -