Example #1
0
void Arg::set_signature( std::string sig ) {
  DBus::Signature newSig( sig );
  signature = newSig;
}
Example #2
0
RBOOL
    obsLib_addPattern
    (
        HObs hObs,
        RPU8 pBytePattern,
        RU32 nBytePatternSize,
        RPVOID context
    )
{
    RBOOL isSuccess = FALSE;

    RU32 i = 0;
    PObsNode tmp = NULL;
    PObsNode next = NULL;
    PObsNode prev = NULL;
    PObsSig sig = NULL;
    _PHObs obs = (_PHObs)hObs;

    if( rpal_memory_isValid( hObs ) &&
        NULL != pBytePattern &&
        0 != nBytePatternSize &&
        NULL != obs->root )
    {
        tmp = obs->root;
        prev = NULL;
        isSuccess = TRUE;

        for( i = 0; i < nBytePatternSize; i++ )
        {
            if( NULL == ( next = getNextNode( tmp, pBytePattern[ i ] ) ) )
            {
                // We need to forge a new state and add a FSM transition to it
                if( NULL == ( next = newNode() ) ||
                    NULL == ( tmp = addTransition( prev, tmp, next, pBytePattern[ i ] ) ) )
                {
                    isSuccess = FALSE;
                    break;
                }

                // If this is the first node, we may need to update
                // the handle with the new root node pointer since
                // it could have gotten realloced.
                if( NULL == prev )
                {
                    obs->root = tmp;
                    obs->currentState = obs->root;
                }
            }

            // Follow on to the next state
            prev = tmp;
            tmp = next;
        }

        if( isSuccess )
        {
            // All went well, in the last state, record the hit
            if( NULL != ( sig = newSig( pBytePattern, nBytePatternSize, context ) ) )
            {
                if( !addHitToNode( tmp, sig ) )
                {
                    freeSig( sig );
                    isSuccess = FALSE;
                }
                else
                {
                    obs->nPatterns++;
                }
            }
            else
            {
                isSuccess = FALSE;
            }
        }
    }

    return isSuccess;
}