static d_instance d_groupInfoLookupInstance ( d_groupInfo _this, const v_groupAction action) { c_long i, nrOfKeys; c_value keyValues[32]; d_instance instance; c_array messageKeyList; assert(C_TYPECHECK(action->message,v_message)); messageKeyList = v_topicMessageKeyList(action->group->topic); nrOfKeys = c_arraySize(messageKeyList); if (nrOfKeys > 32) { OS_REPORT_1(OS_ERROR, "d_groupInfoGetInstance",0, "too many keys %d exceeds limit of 32", nrOfKeys); instance = NULL; } else { for (i=0;i<nrOfKeys;i++) { keyValues[i] = c_fieldValue(messageKeyList[i],action->message); } instance = c_tableFind(_this->instances, &keyValues[0]); c_keep(instance); for (i=0;i<nrOfKeys;i++) { c_valueFreeRef(keyValues[i]); } } return instance; }
static in_result in_ddsiStreamReaderImplDerializePayloadByKeyHash( in_ddsiStreamReaderImpl _this, in_ddsiSubmessageData submessage, in_connectivityPeerWriter peerWriter, v_topic topic, v_message *messageObject, c_octet* keyHash) { in_result result; c_long nrOfKeys, i, bytesCopied; c_array messageKeyList; c_value value; c_base base; assert(_this); assert(submessage); assert(peerWriter); assert(topic); assert(*messageObject); messageKeyList = v_topicMessageKeyList(topic); nrOfKeys = c_arraySize(messageKeyList); bytesCopied = 0; base = c_getBase(topic); result = IN_RESULT_OK; /*TODO: In case key is larger then 16 bytes, MD5 must be used*/ for (i=0;(i<nrOfKeys) && (result == IN_RESULT_OK);i++) { switch(c_fieldValueKind(messageKeyList[i])) { case V_BOOLEAN: value = c_boolValue(*((c_bool*)&(keyHash[bytesCopied]))); bytesCopied += sizeof(c_bool); break; case V_OCTET: value = c_octetValue(*((c_octet*)&(keyHash[bytesCopied]))); bytesCopied += sizeof(c_octet); break; case V_SHORT: #ifdef PA_BIG_ENDIAN value = c_shortValue(*((c_short*)&(keyHash[bytesCopied]))); #else value = c_shortValue(IN_UINT16_SWAP_LE_BE(*((c_short*)&(keyHash[bytesCopied])))); #endif bytesCopied += sizeof(c_short); break; case V_USHORT: #ifdef PA_BIG_ENDIAN value = c_ushortValue(*((c_ushort*)&(keyHash[bytesCopied]))); #else value = c_ushortValue(IN_UINT16_SWAP_LE_BE(*((c_ushort*)&(keyHash[bytesCopied])))); #endif bytesCopied += sizeof(c_ushort); break; case V_LONG: #ifdef PA_BIG_ENDIAN value = c_longValue(*((c_long*)&(keyHash[bytesCopied]))); #else value = c_longValue(IN_UINT32_SWAP_LE_BE(*((c_long*)&(keyHash[bytesCopied])))); #endif bytesCopied += sizeof(c_long); break; case V_ULONG: #ifdef PA_BIG_ENDIAN value = c_ulongValue(*((c_ulong*)&(keyHash[bytesCopied]))); #else value = c_ulongValue(IN_UINT32_SWAP_LE_BE(*((c_ulong*)&(keyHash[bytesCopied])))); #endif bytesCopied += sizeof(c_long); break; case V_CHAR: value = c_charValue(*((c_char*)&(keyHash[bytesCopied]))); bytesCopied += sizeof(c_char); break; case V_STRING: #ifdef PA_BIG_ENDIAN value = c_ulongValue(*((c_ulong*)&(keyHash[bytesCopied]))); #else value = c_ulongValue(IN_UINT32_SWAP_LE_BE(*((c_ulong*)&(keyHash[bytesCopied])))); #endif bytesCopied += 4; /*TODO: validate the string copy algorithm*/ if(value.is.ULong != 0) { value = c_stringValue( c_stringNew(base,((c_string)(&(keyHash[bytesCopied]))))); bytesCopied += strlen(value.is.String) + 1; } else { value = c_stringValue(c_stringNew(base, "")); bytesCopied += 1; } break; case V_DOUBLE: value = c_undefinedValue(); bytesCopied += sizeof(c_double); result = IN_RESULT_PRECONDITION_NOT_MET; break; case V_FLOAT: value = c_undefinedValue(); bytesCopied += sizeof(c_float); result = IN_RESULT_PRECONDITION_NOT_MET; break; case V_ULONGLONG: value = c_undefinedValue(); bytesCopied += sizeof(c_ulonglong); result = IN_RESULT_PRECONDITION_NOT_MET; break; case V_LONGLONG: value = c_undefinedValue(); bytesCopied += sizeof(c_longlong); result = IN_RESULT_PRECONDITION_NOT_MET; break; default: value = c_undefinedValue(); assert(FALSE); result = IN_RESULT_ERROR; break; } c_fieldAssign(messageKeyList[i],*messageObject, value); c_valueFreeRef(value); } return result; }