LONGBOW_TEST_CASE(Global, ccnxKey_FromByteBuffer) { TestData *data = longBowTestCase_GetClipBoardData(testCase); PARCBuffer *hexBuf = parcBuffer_ParseHexString(data->hexString); CCNxKey *key = ccnxKey_Create(hexBuf); parcBuffer_Release(&hexBuf); ccnxKey_Release(&key); }
CCNxManifestHashGroup * ccnxManifestHashGroup_CreateFromJson(const PARCJSON *json) { CCNxManifestHashGroup *group = ccnxManifestHashGroup_Create(); PARCJSONValue *ptrListValue = parcJSON_GetValueByName(json, "HashGroup"); PARCJSONArray *ptrList = parcJSONValue_GetArray(ptrListValue); size_t numberOfPointers = parcJSONArray_GetLength(ptrList); for (size_t i = 0; i < numberOfPointers; i++) { PARCJSONValue *pointerValue = parcJSONArray_GetValue(ptrList, i); PARCJSON *typeJson = parcJSONValue_GetJSON(pointerValue); PARCJSONValue *typeValue = parcJSON_GetValueByName(typeJson, "type"); CCNxManifestHashGroupPointerType type; if (parcJSONValue_GetInteger(typeValue) == 0) { type = CCNxManifestHashGroupPointerType_Data; } else { type = CCNxManifestHashGroupPointerType_Manifest; } PARCJSON *digestJson = parcJSONValue_GetJSON(pointerValue); PARCJSONValue *digestValue = parcJSON_GetValueByName(digestJson, "digest"); PARCBuffer *digestHex = parcJSONValue_GetString(digestValue); char *hexString = parcBuffer_ToString(digestHex); PARCBuffer *digest = parcBuffer_Flip(parcBuffer_ParseHexString(hexString)); parcMemory_Deallocate(&hexString); ccnxManifestHashGroup_AppendPointer(group, type, digest); parcBuffer_Release(&digest); } if (parcJSON_GetPairByName(json, "overallDataDigest") != NULL) { PARCJSONValue *overallDataDigestValue = parcJSON_GetValueByName(json, "overallDataDigest"); PARCBuffer *digestHex = parcJSONValue_GetString(overallDataDigestValue); char *hexString = parcBuffer_ToString(digestHex); group->overallDataDigest = parcBuffer_Flip(parcBuffer_ParseHexString(hexString)); parcMemory_Deallocate(&hexString); } if (parcJSON_GetPairByName(json, "locator") != NULL) { PARCJSONValue *locatorValue = parcJSON_GetValueByName(json, "locator"); PARCBuffer *buffer = parcJSONValue_GetString(locatorValue); char *locator = parcBuffer_ToString(buffer); group->locator = ccnxName_CreateFromCString(locator); parcMemory_Deallocate(&locator); } if (parcJSON_GetPairByName(json, "entrySize") != NULL) { PARCJSONValue *childBlockNodeSizeValue = parcJSON_GetValueByName(json, "entrySize"); group->entrySize = parcJSONValue_GetInteger(childBlockNodeSizeValue); } if (parcJSON_GetPairByName(json, "dataSize") != NULL) { PARCJSONValue *totalSizeValue = parcJSON_GetValueByName(json, "dataSize"); group->dataSize = parcJSONValue_GetInteger(totalSizeValue); } if (parcJSON_GetPairByName(json, "blockSize") != NULL) { PARCJSONValue *blockSizeValue = parcJSON_GetValueByName(json, "blockSize"); group->blockSize = parcJSONValue_GetInteger(blockSizeValue); } if (parcJSON_GetPairByName(json, "treeHeight") != NULL) { PARCJSONValue *treeHeightValue = parcJSON_GetValueByName(json, "treeHeight"); group->treeHeight = parcJSONValue_GetInteger(treeHeightValue); } return group; }