コード例 #1
0
// -----------------------------------------------------------------------------
// CMPXClientList::IsMsgSubscribedL
// -----------------------------------------------------------------------------
//
TBool CMPXClientList::IsMsgSubscribedL(TInt aIndex, const CMPXMessage* aMsg)
    {
    // check the subscriptions
    TBool IsSubScribed(EFalse);
    TInt subCount(iClients[aIndex]->iSubscriptions.Count());

    if (subCount)
        {
        const CMPXMediaArray* subscriptionItems =
                                 iClients[aIndex]->iSubscriptions[0]->ItemsL();
        if (1==subCount && (0== subscriptionItems->Count()))
            {// one empty subscription - send everything
            IsSubScribed = ETrue;
            }
        else
            {// have to check the message against the subscriptions.
            MPX_ASSERT(aMsg);
            const TArray<TMPXAttribute> msgAttrs = aMsg->Attributes();
            TInt msgAttrCount(msgAttrs.Count());
            // iterate subscriptions
            for (TInt subIndex = 0; subIndex<subCount && !IsSubScribed; ++subIndex)
                {
                // iterate items for the current subscription
                subscriptionItems =
                            iClients[aIndex]->iSubscriptions[subIndex]->ItemsL();
                TInt itemCount(subscriptionItems->Count());
                for (TInt itemIndex = 0; itemIndex < itemCount; ++itemIndex)
                    {
                    // check the message attributes for the current subscription item
                    TBool subMatch(ETrue);
                    TInt attrMatchCount(0);
                    CMPXSubscriptionItem* subItem(subscriptionItems->AtL(itemIndex));

                    for (TInt msgAttrIndex = 0; msgAttrIndex < msgAttrCount; ++msgAttrIndex)
                        {
                        TBool attrExists(EFalse);
                        TBool attrMatch(EFalse);
                        const TMPXAttribute& msgAttr( msgAttrs[msgAttrIndex] );

                        if ( subItem->IsSupported(msgAttr))
                            {
                            attrExists = ETrue;

                            if ( subItem->Match( *aMsg, msgAttr ))
                                {
                                attrMatch = ETrue;
                                attrMatchCount++;
                                }
                            }

                        if (attrExists && !attrMatch)
                            {
                            subMatch = EFalse;
                            break;
                            }
                        }

                    // send the message if all attributes that exist in both the message and the subscription
                    // have the same values and all subscription attributes match
                    if ( subMatch && ( attrMatchCount == subItem->Count()) )
                        {
                        IsSubScribed = ETrue;
                        break;
                        }
                    }
                }
            }
        } // else subCount = 0, IsSubScribed = EFalse (default)
    return IsSubScribed;
    }
コード例 #2
0
ファイル: wildcmp.c プロジェクト: AidanJones/osm2pgsql
int wildMatch(char *wildCard, char *string)
/* does a case sensitive wild card match with a string.
 * * matches any string or no character.
 * ? matches any single character.
 * anything else etc must match the character exactly.

returns NO_MATCH, FULL_MATCH or WC_MATCH defined in wildcmp.h
 
*/
{
int matchStar = 0;
int starMatchSize;
int wildmatch=0;

for(;;)
    {
NEXT_WILD:
    switch(*wildCard)
	{
	case 0: /* end of wildcard */
	    {
	    if(matchStar)
		{
		while(*string++)
                    ;
		return wildmatch ? WC_MATCH : FULL_MATCH;
                }
            else if(*string)
		return NO_MATCH;
            else {
                return wildmatch ? WC_MATCH : FULL_MATCH;
                }
	    }
	case '*':
	    wildmatch = 1;
	    matchStar = 1;
	    break;
	case '?': /* anything will do */
	    wildmatch = 1;
	    {
	    if(*string == 0)
	        return NO_MATCH; /* out of string, no match for ? */
	    ++string;
	    break;
	    }
	default:
	    {
	    if(matchStar)
    	        {
		for(;;)
		    {
		    if(*string == 0) /* if out of string no match */
		        return NO_MATCH;

		    /* note matchStar is re-used here for substring
		     * after star match length */
		    if((starMatchSize = subMatch(string,wildCard)) != 0)
		        {
			string += starMatchSize;
			wildCard += starMatchSize;
			matchStar = 0;
			goto NEXT_WILD;
		        }
		    ++string;
		    }
	        }

	    /* default: they must be equal or no match */
	    if(toupper(*string) != toupper(*wildCard))
		return NO_MATCH;
	    ++string;
	    break;
	    }
	}
    ++wildCard;
    }
}
コード例 #3
0
ファイル: wildcmp.c プロジェクト: Puneet-Shivanand/zinba
boolean wildMatch(char *wildCard, char *string)
/* does a case sensitive wild card match with a string.
 * * matches any string or no character.
 * ? matches any single character.
 * anything else etc must match the character exactly. */
{
boolean matchStar = 0;
int starMatchSize;

for(;;)
    {
NEXT_WILD:
    switch(*wildCard)
	{
	case 0: /* end of wildcard */
	    {
	    if(matchStar)
		{
		while(*string++)
                    ;
		return TRUE;
                }
            else if(*string)
		return FALSE;
            else
                return TRUE;
	    }
	case '*':
	    matchStar = TRUE;
	    break;
	case '?': /* anything will do */
	    {
	    if(*string == 0)
	        return FALSE; /* out of string, no match for ? */
	    ++string;
	    break;
	    }
	default:
	    {
	    if(matchStar)
    	        {
		for(;;)
		    {
		    if(*string == 0) /* if out of string no match */
		        return FALSE;

		    /* note matchStar is re-used here for substring
		     * after star match length */
		    if((starMatchSize = subMatch(string,wildCard)) != 0)
		        {
			string += starMatchSize;
			wildCard += starMatchSize;
			matchStar = FALSE;
			goto NEXT_WILD;
		        }
		    ++string;
		    }
	        }

	    /* default: they must be equal or no match */
	    if(toupper(*string) != toupper(*wildCard))
		return FALSE;
	    ++string;
	    break;
	    }
	}
    ++wildCard;
    }
}