示例#1
0
文件: expression.c 项目: jff/mathspad
static int typelisteq(Type *l1, Type *l2)
{
    if (!l1 || !l2) return 0;
    while (*l1 && (TypeMatch(*l1,*l2))) {
	l1++;l2++;
    }
    return (!*l1 && !*l2);
}
示例#2
0
BOOL CTwain::GetCapCurrent(unsigned Cap, unsigned ItemType, void FAR *pVal)
{
	TW_CAPABILITY 	cap;
	void far *		pv = NULL;
	BOOL			   bSuccess = FALSE;

	if (nState < SOURCE_OPEN) {
		ATLTRACE_ERROR(TWERR_NOT_4);
		return FALSE;
	}

	// Fill in capability structure
	cap.Cap = (TW_UINT16)Cap;		// capability id
	cap.ConType = TWON_ONEVALUE;	// favorite type of container (should be ignored...)
	cap.hContainer = NULL;

	if (DS(DG_CONTROL, DAT_CAPABILITY, MSG_GETCURRENT, (TW_MEMREF)&cap) &&
		cap.hContainer &&
		(pv = GlobalLock(cap.hContainer))) {

			if (cap.ConType == TWON_ENUMERATION) {
				TW_ENUMERATION far *pcon = (TW_ENUMERATION far *)pv;
				TW_UINT32 index = pcon->CurrentIndex;
				if (index < pcon->NumItems && TypeMatch(pcon->ItemType, ItemType)) {
					LPSTR pitem = (LPSTR)pcon->ItemList + index*nTypeSize[ItemType];
					memcpy(pVal, pitem, nTypeSize[ItemType]);
					bSuccess = TRUE;
				}
			} else if (cap.ConType == TWON_ONEVALUE) {
				TW_ONEVALUE far *pcon = (TW_ONEVALUE far *)pv;
				if (TypeMatch(pcon->ItemType, ItemType)) {
					memcpy(pVal, &pcon->Item, nTypeSize[ItemType]);
					bSuccess = TRUE;
				}
			}
		}

		if (pv) GlobalUnlock(cap.hContainer);
		if (cap.hContainer) GlobalFree(cap.hContainer);

		return bSuccess;
}