size_t ccnxManifest_GetNumberOfHashGroups(const CCNxManifest *manifest) { CCNxManifestInterface *impl = ccnxManifestInterface_GetInterface(manifest); size_t result = 0; if (impl->getNumberOfHashGroups != NULL) { result = (impl->getNumberOfHashGroups)(manifest); } return result; }
const CCNxName * ccnxManifest_GetName(const CCNxManifest *manifest) { CCNxManifestInterface *impl = ccnxManifestInterface_GetInterface(manifest); const CCNxName *result = NULL; if (impl->getName != NULL) { result = impl->getName(manifest); } else { trapNotImplemented("ccnxManifest_GetName"); } return result; }
bool ccnxManifest_Equals(const CCNxManifest *objectA, const CCNxManifest *objectB) { if (objectA == objectB) { return true; } if (objectA == NULL || objectB == NULL) { return false; } CCNxManifestInterface *impl = ccnxManifestInterface_GetInterface(objectA); return (impl->equals)(objectA, objectB); return false; }
ssize_t ccnxCodecSchemaV1ManifestEncoder_Encode(CCNxCodecTlvEncoder *encoder, CCNxTlvDictionary *packetDictionary) { ssize_t length = 0; ssize_t numHashGroups = ccnxTlvDictionary_ListSize(packetDictionary, CCNxCodecSchemaV1TlvDictionary_Lists_HASH_GROUP_LIST); for (size_t i = 0; i < numHashGroups; i++) { // Skip past the TL of the hash group to append the pointers inside ssize_t groupLength = 0; ccnxCodecTlvEncoder_AppendContainer(encoder, CCNxCodecSchemaV1Types_CCNxMessage_HashGroup, groupLength); CCNxManifestInterface *interface = ccnxManifestInterface_GetInterface(packetDictionary); CCNxManifestHashGroup *group = interface->getHashGroup(packetDictionary, i); // Encode any metadata, if present. if (ccnxManifestHashGroup_HasMetadata(group)) { groupLength += _appendMetadata(encoder, group); } // Append the HashGroup pointers size_t numPointers = ccnxManifestHashGroup_GetNumberOfPointers(group); for (size_t p = 0; p < numPointers; p++) { CCNxManifestHashGroupPointer *ptr = ccnxManifestHashGroup_GetPointerAtIndex(group, p); ssize_t ptrLength = _appendPointer(encoder, ptr); if (ptrLength < 0) { return ptrLength; } groupLength += ptrLength; } // Now that we know the overall length, rewind back to the start and append the TL // part of the container. size_t endPosition = ccnxCodecTlvEncoder_Position(encoder); ssize_t offset = endPosition - groupLength - 4; ccnxCodecTlvEncoder_PutUint16(encoder, offset, CCNxCodecSchemaV1Types_CCNxMessage_HashGroup); ccnxCodecTlvEncoder_PutUint16(encoder, offset + 2, groupLength); ccnxCodecTlvEncoder_SetPosition(encoder, endPosition); length += groupLength + 4; ccnxManifestHashGroup_Release(&group); } return length; }
CCNxManifestHashGroup * ccnxManifest_GetHashGroupByIndex(const CCNxManifest *manifest, size_t index) { CCNxManifestInterface *interface = ccnxManifestInterface_GetInterface(manifest); return interface->getHashGroup(manifest, index); }
void ccnxManifest_AddHashGroup(CCNxManifest *manifest, const CCNxManifestHashGroup *group) { CCNxManifestInterface *interface = ccnxManifestInterface_GetInterface(manifest); interface->addHashGroup(manifest, group); }