/* Description: Call begin, check that the first field is returned, then * call next, and check that the first field is returned again, * then call next again, and ensure that the second field is * returned. * * Expected Result: First Check: fid - 101, value - 8 * Second Check: fid - 101, value - 8 * Third Check: fid - 102, value - "This is an iteration test." */ TEST_F (MsgNewIteratorTestC, IteratorBeginNext) { mama_fid_t fid = 0; mama_u8_t content = 0; const char* strContent; field = mamaMsgIterator_begin (iterator); mamaMsgField_getFid (field, &fid); mamaMsgField_getU8 (field, &content); /* Check the contents of the field: */ ASSERT_EQ (101, fid); ASSERT_EQ (8, content); field = mamaMsgIterator_next (iterator); mamaMsgField_getFid (field, &fid); mamaMsgField_getU8 (field, &content); /* Ensure we return the first field again: */ ASSERT_EQ (101, fid); ASSERT_EQ (8, content); field = mamaMsgIterator_next (iterator); mamaMsgField_getFid (field, &fid); mamaMsgField_getString (field, &strContent); /* Ensure we return the first field again: */ ASSERT_EQ (102, fid); ASSERT_STREQ ("This is an iteration test.", strContent); }
/* Description: Step into the message, determine if it has a next value, * retrieve and check the contents of that value. * * Expected Result: Non-zero return for hasNext */ TEST_F (MsgNewIteratorTestC, IteratorHasNext) { mama_fid_t fid = 0; mama_u64_t content = 0; mama_bool_t hasNext = 0; field = mamaMsgIterator_begin (iterator); mamaMsgField_getFid (field, &fid); mamaMsgField_getU64 (field, &content); /* Check the contents of the field: */ ASSERT_EQ(values[fid], content); field = mamaMsgIterator_next (iterator); /* Ensure we return the first field again: */ ASSERT_EQ(values[fid], content); /* Check if we have a next value: */ hasNext = mamaMsgIterator_hasNext (iterator); ASSERT_NE (0, hasNext); /* Get the next value */ field = mamaMsgIterator_next (iterator); mamaMsgField_getFid (field, &fid); mamaMsgField_getU64 (field, &content); /* Ensure we return the first field again: */ ASSERT_EQ(values[fid], content); }
void MAMACALLTYPE displayCb (const mamaMsg msg, const mamaMsgField field, void* closure) { char value[256] = ""; const char* typeName = "(null)"; const char* fieldName = "(null)"; uint16_t fid = 0; if (MAMA_STATUS_OK != mamaMsgField_getTypeName (field,&typeName)) { printf ("Failed to get type name\n"); return; } if (MAMA_STATUS_OK != mamaMsgField_getName (field,&fieldName)) { printf ("Failed to get name\n"); return; } if (MAMA_STATUS_OK != mamaMsgField_getFid (field,&fid)) { printf ("Failed to get Fid\n"); return; } if (MAMA_STATUS_OK != mamaMsgField_getAsString (field, value, 256)) { printf ("Failed to get field: %d:%s\n", fid, fieldName); return; } printf (" %20s %5u %20s %20s\n", fieldName, fid, typeName, value); }
/* Description: Step to the end of the message, check if it has a next, * expecting that it does not. * * Expected Result: Zero return for hasNext */ TEST_F (MsgNewIteratorTestC, IteratorHasNoNext) { mama_fid_t fid = 0; mama_u64_t content = 0; field = mamaMsgIterator_begin (iterator); mamaMsgField_getFid (field, &fid); mamaMsgField_getU64 (field, &content); /* Check the contents of the field: */ ASSERT_EQ(values[fid], content); field = mamaMsgIterator_next (iterator); /* Ensure we return the first field again: */ ASSERT_EQ(values[fid], content); /* Move to the last message: */ field = mamaMsgIterator_next (iterator); field = mamaMsgIterator_next (iterator); field = mamaMsgIterator_next (iterator); field = mamaMsgIterator_next (iterator); /* Move past last message - should not crash */ field = mamaMsgIterator_next (iterator); ASSERT_EQ(NULL, field); /* Check if we have a next value: */ ASSERT_EQ (0, mamaMsgIterator_hasNext (iterator)); }
/* Description: Step to the end of the message, check if it has a next, * expecting that it does not. * * Expected Result: Zero return for hasNext */ TEST_F (MsgNewIteratorTestC, IteratorHasNoNext) { mama_fid_t fid = 0; mama_u8_t content = 0; mama_bool_t hasNext = 0; field = mamaMsgIterator_begin (iterator); mamaMsgField_getFid (field, &fid); mamaMsgField_getU8 (field, &content); /* Check the contents of the field: */ ASSERT_EQ (101, fid); ASSERT_EQ (8, content); field = mamaMsgIterator_next (iterator); /* Ensure we return the first field again: */ ASSERT_EQ (101, fid); ASSERT_EQ (8, content); /* Move to the last message: */ field = mamaMsgIterator_next (iterator); field = mamaMsgIterator_next (iterator); field = mamaMsgIterator_next (iterator); field = mamaMsgIterator_next (iterator); /* Check if we have a next value: */ hasNext = mamaMsgIterator_hasNext (iterator); ASSERT_EQ (0, hasNext); }
static void msgOnField (const mamaMsg msg, const mamaMsgField field, void* closure) { mama_fid_t fid = 0; mamaFieldType type = MAMA_FIELD_TYPE_UNKNOWN; mamaMsgField_getFid (field, &fid); mamaMsgField_getType (field, &type); switch(type) { case MAMA_FIELD_TYPE_STRING: { char buffer[MAX_FIELD_STR_LEN]; ASSERT_EQ (101, fid); mamaMsgField_getAsString (field, buffer, MAX_FIELD_STR_LEN); ASSERT_STREQ ("This is an iteration test.", buffer); break; } case MAMA_FIELD_TYPE_U8: { mama_u8_t buffer = 0; ASSERT_EQ (102, fid); mamaMsgField_getU8 (field, &buffer); ASSERT_EQ (8, buffer); break; } case MAMA_FIELD_TYPE_U16: { mama_u16_t buffer = 0; ASSERT_EQ (103, fid); mamaMsgField_getU16 (field, &buffer); ASSERT_EQ (16, buffer); break; } case MAMA_FIELD_TYPE_U32: { mama_u32_t buffer = 0; ASSERT_EQ (104, fid); mamaMsgField_getU32 (field, &buffer); ASSERT_EQ (32, buffer); break; } case MAMA_FIELD_TYPE_U64: { mama_u64_t buffer = 0; ASSERT_EQ (105, fid); mamaMsgField_getU64 (field, &buffer); ASSERT_EQ (64, buffer); break; } default: break; } ASSERT_EQ ((void*)2, closure); }
/* Description: Call begin on the already associated mamaMsgIterator, and * check that the contents of the first field are returned. * * Expected Result: Fid should be 101, value should be 8. */ TEST_F (MsgNewIteratorTestC, IteratorBegin) { mama_fid_t fid = 0; mama_u64_t content = 0; field = mamaMsgIterator_begin (iterator); mamaMsgField_getFid (field, &fid); mamaMsgField_getU64 (field, &content); /* Check the contents of the field: */ ASSERT_EQ(values.at(fid), content); }
static void MAMACALLTYPE maxIterator(const mamaMsg msg, const mamaMsgField field, void* closure) { mamaDictionaryImpl* impl = (mamaDictionaryImpl*) closure; mama_fid_t fid = 0; if (MAMA_STATUS_OK == mamaMsgField_getFid(field, &fid)) { if (impl->mMaxFid < fid) impl->mMaxFid = fid; } }
/* Description: Call begin on the already associated mamaMsgIterator, and * check that the contents of the first field are returned. * * Expected Result: Fid should be 101, value should be 8. */ TEST_F (MsgNewIteratorTestC, IteratorBegin) { mama_fid_t fid = 0; mama_u8_t content = 0; field = mamaMsgIterator_begin (iterator); mamaMsgField_getFid (field, &fid); mamaMsgField_getU8 (field, &content); /* Check the contents of the field: */ ASSERT_EQ (101, fid); ASSERT_EQ (8, content); }
/* Description: Call begin, check that the first field is returned, then * call next, and check that the first field is returned again, * then call next again, until all fields are confirmed. */ TEST_F (MsgNewIteratorTestC, IteratorBeginNext) { mama_fid_t fid = 0; mama_u64_t content = 0; field = mamaMsgIterator_begin (iterator); mamaMsgField_getFid (field, &fid); mamaMsgField_getU64 (field, &content); /* Check the contents of the field match legal entry */ ASSERT_EQ(values.at(fid), content); field = mamaMsgIterator_next (iterator); mamaMsgField_getFid (field, &fid); /* Ensure we return the first field again: */ ASSERT_EQ(values[fid], content); /* Remove from reference map */ values.erase(fid); /* For the 4 remaining fields, check contents */ for (int i = 0; i < 4; i++) { field = mamaMsgIterator_next (iterator); mamaMsgField_getFid (field, &fid); mamaMsgField_getU64 (field, &content); ASSERT_EQ(values[fid], content); /* Remove from reference map */ values.erase(fid); } /* Gotta catch 'em all */ EXPECT_EQ(0, values.size()); }
mama_status mamaFieldCache_updateCacheFromMsgField(mamaFieldCache fieldCache, const mamaMsgField messageField) { mama_status ret; mama_fid_t fid; mamaFieldType type = MAMA_FIELD_TYPE_UNKNOWN; const char* name = NULL; mamaFieldDescriptor descriptor = NULL; mamaFieldCacheField field = NULL; ret = mamaMsgField_getFid(messageField, &fid); if (ret != MAMA_STATUS_OK) { return ret; } if (MAMA_STATUS_OK != mamaFieldCacheMap_find(fieldCache->mMap, fid, type, name, &field)) { ret = mamaMsgField_getType(messageField, &type); if (ret != MAMA_STATUS_OK) { return ret; } if (fieldCache->mUseFieldNames) { mamaMsgField_getName(messageField, &name); } mamaFieldCacheField_create(&field, fid, type, name); ret = mamaFieldCacheMap_add(fieldCache->mMap, field); if (ret != MAMA_STATUS_OK) { return ret; } fieldCache->mSize++; mamaMsgField_getDescriptor(messageField, &descriptor); if (descriptor) { mamaFieldCacheField_setDescriptor(field, descriptor); } } else { type = field->mType; } if (fieldCache->mTrackModified && field->mPublish && !field->mIsModified) { field->mIsModified = 1; mamaFieldCacheList_add(fieldCache->mModifiedFields, (void*)field); } switch (type) { case MAMA_FIELD_TYPE_BOOL: { mama_bool_t result; mamaMsgField_getBool(messageField, &result); mamaFieldCacheField_setBool(field, result); break; } case MAMA_FIELD_TYPE_CHAR: { char value; mamaMsgField_getChar(messageField, &value); mamaFieldCacheField_setChar(field, value); break; } case MAMA_FIELD_TYPE_I8: { mama_i8_t value; mamaMsgField_getI8(messageField, &value); mamaFieldCacheField_setI8(field, value); break; } case MAMA_FIELD_TYPE_U8: { mama_u8_t value; mamaMsgField_getU8(messageField, &value); mamaFieldCacheField_setU8(field, value); break; } case MAMA_FIELD_TYPE_I16: { mama_i16_t value; mamaMsgField_getI16(messageField, &value); mamaFieldCacheField_setI16(field, value); break; } case MAMA_FIELD_TYPE_U16: { mama_u16_t value; mamaMsgField_getU16(messageField, &value); mamaFieldCacheField_setU16(field, value); break; } case MAMA_FIELD_TYPE_I32: { mama_i32_t value; mamaMsgField_getI32(messageField, &value); mamaFieldCacheField_setI32(field, value); break; } case MAMA_FIELD_TYPE_U32: { mama_u32_t value; mamaMsgField_getU32(messageField, &value); mamaFieldCacheField_setU32(field, value); break; } case MAMA_FIELD_TYPE_I64: { mama_i64_t value; mamaMsgField_getI64(messageField, &value); mamaFieldCacheField_setI64(field, value); break; } case MAMA_FIELD_TYPE_U64: { mama_u64_t value; mamaMsgField_getU64(messageField, &value); mamaFieldCacheField_setU64(field, value); break; } case MAMA_FIELD_TYPE_F32: { mama_f32_t value; mamaMsgField_getF32(messageField, &value); mamaFieldCacheField_setF32(field, value); break; } case MAMA_FIELD_TYPE_QUANTITY: case MAMA_FIELD_TYPE_F64: { mama_f64_t value; mamaMsgField_getF64(messageField, &value); mamaFieldCacheField_setF64(field, value); break; } case MAMA_FIELD_TYPE_STRING: { const char* value = NULL; mamaMsgField_getString(messageField, &value); mamaFieldCacheField_setString(field, value, 0); break; } case MAMA_FIELD_TYPE_PRICE: { mamaMsgField_getPrice(messageField, fieldCache->mReusablePrice); mamaFieldCacheField_setPrice(field, fieldCache->mReusablePrice); break; } case MAMA_FIELD_TYPE_TIME: { mamaMsgField_getDateTime(messageField, fieldCache->mReusableDateTime); mamaFieldCacheField_setDateTime(field, fieldCache->mReusableDateTime); break; } case MAMA_FIELD_TYPE_VECTOR_I8: { const mama_i8_t* values = NULL; mama_size_t size = 0; mamaMsgField_getVectorI8(messageField, &values, &size); mamaFieldCacheField_setI8Vector(field, values, size); break; } case MAMA_FIELD_TYPE_VECTOR_U8: { const mama_u8_t* values = NULL; mama_size_t size = 0; mamaMsgField_getVectorU8(messageField, &values, &size); mamaFieldCacheField_setU8Vector(field, values, size); break; } case MAMA_FIELD_TYPE_VECTOR_I16: { const mama_i16_t* values = NULL; mama_size_t size = 0; mamaMsgField_getVectorI16(messageField, &values, &size); mamaFieldCacheField_setI16Vector(field, values, size); break; } case MAMA_FIELD_TYPE_VECTOR_U16: { const mama_u16_t* values = NULL; mama_size_t size = 0; mamaMsgField_getVectorU16(messageField, &values, &size); mamaFieldCacheField_setU16Vector(field, values, size); break; } case MAMA_FIELD_TYPE_VECTOR_I32: { const mama_i32_t* values = NULL; mama_size_t size = 0; mamaMsgField_getVectorI32(messageField, &values, &size); mamaFieldCacheField_setI32Vector(field, values, size); break; } case MAMA_FIELD_TYPE_VECTOR_U32: { const mama_u32_t* values = NULL; mama_size_t size = 0; mamaMsgField_getVectorU32(messageField, &values, &size); mamaFieldCacheField_setU32Vector(field, values, size); break; } case MAMA_FIELD_TYPE_VECTOR_I64: { const mama_i64_t* values = NULL; mama_size_t size = 0; mamaMsgField_getVectorI64(messageField, &values, &size); mamaFieldCacheField_setI64Vector(field, values, size); break; } case MAMA_FIELD_TYPE_VECTOR_U64: { const mama_u64_t* values = NULL; mama_size_t size = 0; mamaMsgField_getVectorU64(messageField, &values, &size); mamaFieldCacheField_setU64Vector(field, values, size); break; } case MAMA_FIELD_TYPE_VECTOR_F32: { const mama_f32_t* values = NULL; mama_size_t size = 0; mamaMsgField_getVectorF32(messageField, &values, &size); mamaFieldCacheField_setF32Vector(field, values, size); break; } case MAMA_FIELD_TYPE_VECTOR_F64: { const mama_f64_t* values = NULL; mama_size_t size = 0; mamaMsgField_getVectorF64(messageField, &values, &size); mamaFieldCacheField_setF64Vector(field, values, size); break; } case MAMA_FIELD_TYPE_VECTOR_STRING: { const char** values = NULL; mama_size_t size = 0; mamaMsgField_getVectorString(messageField, &values, &size); mamaFieldCacheField_setStringVector(field, values, size); break; } case MAMA_FIELD_TYPE_VECTOR_PRICE: { /* TODO: mamaMsgField does not provide methods to get price vector const mamaPrice* values = NULL; mama_size_t size; mamaMsgField_getVectorPrice(messageField, &values, &size); mamaFieldCacheField_setPriceVector(field, values, size); */ break; } case MAMA_FIELD_TYPE_VECTOR_TIME: { /* TODO: mamaMsgField does not provide methods to get time vector const mamaDateTime* values = NULL; mama_size_t size; mamaMsgField_getVectorDateTime(messageField, &values, &size); mamaFieldCacheField_setDateTimeVector(field, values, size); */ break; } default: break; } return ret; }
int main (int argc, const char **argv) { mamaPlaybackFileParser fileParser = NULL; mamaPlaybackCapture fileCapture = NULL; char* headerString = NULL; mamaMsg sourceMsg = NULL; mamaMsg targetMsg = NULL; mamaMsgField aField = NULL; mamaBridge gMamaBridge = NULL; mamaMsgIterator iterator = NULL; mamaFieldType fieldType = MAMA_FIELD_TYPE_UNKNOWN; parseCommandLine (argc, argv); mama_loadBridge (&gMamaBridge, "wmw"); mama_loadBridge (&gMamaBridge, "avis"); mama_open (); mamaPlaybackFileParser_allocate (&fileParser); mamaPlaybackFileParser_openFile(fileParser, (char*)gInputFilename); mamaCapture_allocate(&fileCapture); mamaCapture_openFile (&fileCapture, gOutputFilename); mamaMsgIterator_create(&iterator, NULL); mamaMsg_createForPayload(&targetMsg, 'A'); while (mamaPlaybackFileParser_getNextHeader(fileParser, &headerString)) { if (mamaPlaybackFileParser_getNextMsg (fileParser, &sourceMsg)) { char temp[64]; char* start = headerString; char* end = strchr (headerString,':'); strncpy (temp,start, end-start); temp[end-start]='\0'; mamaCapture_setFeedSource (&fileCapture, temp); end++; start=end; end = strchr (start,':'); strncpy (temp,start, end-start);temp[end-start]='\0'; mamaCapture_setTransportName (&fileCapture, temp); end++; start=end; end = strchr (start,'\0'); strncpy (temp,start, end-start);temp[end-start]='\0'; mamaCapture_setSymbol (&fileCapture, temp); mamaMsgIterator_associate(iterator, sourceMsg); mamaMsg_clear(targetMsg); while ((aField = mamaMsgIterator_next(iterator)) != NULL) { uint16_t fid = 0; mamaMsgField_getFid(aField, &fid); mamaMsgField_getType(aField, &fieldType); switch (fieldType) { case MAMA_FIELD_TYPE_BOOL: { mama_bool_t result; mamaMsgField_getBool (aField, &result); mamaMsg_addBool(targetMsg, NULL, fid, result); }break; case MAMA_FIELD_TYPE_CHAR: {char result; mamaMsgField_getChar (aField, &result); mamaMsg_addChar(targetMsg, NULL, fid, result); }break; case MAMA_FIELD_TYPE_I8: {mama_i8_t result; mamaMsgField_getI8 (aField, &result); mamaMsg_addI8(targetMsg, NULL, fid, result); }break; case MAMA_FIELD_TYPE_U8: {mama_u8_t result; mamaMsgField_getU8 (aField, &result); mamaMsg_addU8(targetMsg, NULL, fid, result); }break; case MAMA_FIELD_TYPE_I16: {mama_i16_t result; mamaMsgField_getI16 (aField, &result); mamaMsg_addI16(targetMsg, NULL, fid, result); }break; case MAMA_FIELD_TYPE_U16: {mama_u16_t result; mamaMsgField_getU16 (aField, &result); mamaMsg_addU16(targetMsg, NULL, fid, result); }break; case MAMA_FIELD_TYPE_I32: {mama_i32_t result; mamaMsgField_getI32 (aField, &result); mamaMsg_addI32(targetMsg, NULL, fid, result); }break; case MAMA_FIELD_TYPE_U32: {mama_u32_t result; mamaMsgField_getU32 (aField, &result); mamaMsg_addU32(targetMsg, NULL, fid, result); }break; case MAMA_FIELD_TYPE_I64: {mama_i64_t result; mamaMsgField_getI64 (aField, &result); mamaMsg_addI64(targetMsg, NULL, fid, result); }break; case MAMA_FIELD_TYPE_U64: {mama_u64_t result; mamaMsgField_getU64 (aField, &result); mamaMsg_addU64(targetMsg, NULL, fid, result); }break; case MAMA_FIELD_TYPE_F32: {mama_f32_t result; mamaMsgField_getF32 (aField, &result); mamaMsg_addF32(targetMsg, NULL, fid, result); }break; case MAMA_FIELD_TYPE_F64: {mama_f64_t result; mamaMsgField_getF64 (aField, &result); mamaMsg_addF64(targetMsg, NULL, fid, result); }break; case MAMA_FIELD_TYPE_STRING: {const char* result; mamaMsgField_getString (aField, &result); mamaMsg_addString(targetMsg, NULL, fid, result); }break; case MAMA_FIELD_TYPE_TIME: { mamaDateTime result; mamaMsgField_getDateTime (aField, result); mamaMsg_addDateTime(targetMsg, NULL, fid, result); }break; case MAMA_FIELD_TYPE_PRICE: { mamaPrice result; mamaMsgField_getPrice(aField, result); mamaMsg_addPrice(targetMsg, NULL, fid, result); }break; default: case MAMA_FIELD_TYPE_VECTOR_I8: case MAMA_FIELD_TYPE_VECTOR_U8: case MAMA_FIELD_TYPE_VECTOR_I16: case MAMA_FIELD_TYPE_VECTOR_U16: case MAMA_FIELD_TYPE_VECTOR_I32: case MAMA_FIELD_TYPE_VECTOR_U32: case MAMA_FIELD_TYPE_VECTOR_I64: case MAMA_FIELD_TYPE_VECTOR_U64: case MAMA_FIELD_TYPE_VECTOR_F32: case MAMA_FIELD_TYPE_VECTOR_F64: case MAMA_FIELD_TYPE_VECTOR_STRING: case MAMA_FIELD_TYPE_VECTOR_MSG: case MAMA_FIELD_TYPE_VECTOR_TIME: case MAMA_FIELD_TYPE_VECTOR_PRICE: case MAMA_FIELD_TYPE_QUANTITY: case MAMA_FIELD_TYPE_COLLECTION : case MAMA_FIELD_TYPE_UNKNOWN: case MAMA_FIELD_TYPE_OPAQUE: case MAMA_FIELD_TYPE_MSG: break; } } mamaCapture_saveMamaMsg (&fileCapture, &targetMsg); } } mamaMsgIterator_destroy(iterator); mamaCapture_closeFile(fileCapture); mamaCapture_deallocate (fileCapture); mamaPlaybackFileParser_closeFile(fileParser); mamaPlaybackFileParser_deallocate (fileParser); return (0); }
TEST_F (MsgIterateTestC, CreateIterator) { mama_fid_t fid = 0; mamaMsgIterator iterator = NULL; mamaMsgField field = NULL; mamaFieldType type = MAMA_FIELD_TYPE_UNKNOWN; /* Create a mama message. */ mamaMsg msg = NULL; mamaMsg_create (&msg); /* add a fields to the message. */ mamaMsg_addString (msg, "string", 101, "This is an iteration test."); mamaMsg_addU8 (msg, "u8", 102, 8); mamaMsg_addU16 (msg, "u16", 103, 16); mamaMsg_addU32 (msg, "u32", 104, 32); mamaMsg_addU64 (msg, "u64", 105, 64); /* Create iterator and message field required.*/ ASSERT_EQ (MAMA_STATUS_OK, mamaMsgIterator_create (&iterator,NULL)); mamaMsgIterator_associate (iterator,msg); while ((field = mamaMsgIterator_next(iterator)) != NULL) { /* Operate on contents of each field. */ mamaMsgField_getFid (field, &fid); mamaMsgField_getType (field, &type); switch(type) { case MAMA_FIELD_TYPE_STRING: { char buffer[MAX_FIELD_STR_LEN]; ASSERT_EQ (101, fid); mamaMsgField_getAsString (field, buffer, MAX_FIELD_STR_LEN); ASSERT_STREQ ("This is an iteration test.", buffer); break; } case MAMA_FIELD_TYPE_U8: { mama_u8_t buffer = 0; ASSERT_EQ (102, fid); mamaMsgField_getU8 (field, &buffer); ASSERT_EQ (8, buffer); break; } case MAMA_FIELD_TYPE_U16: { mama_u16_t buffer = 0; ASSERT_EQ (103, fid); mamaMsgField_getU16 (field, &buffer); ASSERT_EQ (16, buffer); break; } case MAMA_FIELD_TYPE_U32: { mama_u32_t buffer = 0; ASSERT_EQ (104, fid); mamaMsgField_getU32 (field, &buffer); ASSERT_EQ (32, buffer); break; } case MAMA_FIELD_TYPE_U64: { mama_u64_t buffer = 0; ASSERT_EQ (105, fid); mamaMsgField_getU64 (field, &buffer); ASSERT_EQ (64, buffer); break; } default: break; } } /* destroy the message. */ mamaMsg_destroy (msg); }
static void MAMACALLTYPE dictMsgIterator (const mamaMsg msg, const mamaMsgField field, void* closure) { mamaDictionaryImpl* impl = (mamaDictionaryImpl*) closure; const char* fieldName = NULL; mama_fid_t fid = 0; mamaFieldType type = 0; const char* val = NULL; mamaMsgField_getType(field,&type); mamaMsgField_getFid(field,&fid); mamaMsgField_getName(field,&fieldName); if (MamaFieldFeedName.mFid == fid) { if (MAMA_STATUS_OK == mamaMsg_getString (msg, fieldName, fid, &val)) { checkFree(&impl->mFeedName); impl->mFeedName = copyString(val); mama_log ( MAMA_LOG_LEVEL_FINE, "Dictionary source feed name: %s", val); } } else if (MamaFieldFeedHost.mFid == fid) { if (MAMA_STATUS_OK == mamaMsg_getString (msg, fieldName, fid, &val)) { checkFree(&impl->mFeedHost); impl->mFeedHost = copyString(val); mama_log ( MAMA_LOG_LEVEL_FINE, "Dictionary source hostname: %s", val); } } mamaDictionary_createFieldDescriptor (impl, fid, fieldName, type, NULL); }