static inline PARCBuffer * _parcBuffer_getInstance(void) { PARCBuffer *result = parcObject_CreateInstance(PARCBuffer); return result; }
PARCLog * parcLog_Create(const char *hostName, const char *applicationName, const char *processId, PARCLogReporter *reporter) { if (applicationName == NULL) { applicationName = _nilvalue; } if (hostName == NULL) { hostName = _nilvalue; } if (processId == NULL) { processId = _nilvalue; } PARCLog *result = parcObject_CreateInstance(PARCLog); if (result == NULL) { trapOutOfMemory("Creating an instance of PARCLog."); } result->hostName = parcMemory_StringDuplicate(hostName, strlen(hostName)); result->applicationName = parcMemory_StringDuplicate(applicationName, strlen(applicationName)); result->processId = parcMemory_StringDuplicate(processId, strlen(processId)); result->messageId = 0; result->level = PARCLogLevel_Off; result->reporter = parcLogReporter_Acquire(reporter); return result; }
RtaCommandCloseConnection * rtaCommandCloseConnection_Create(int apiNotifierFd) { RtaCommandCloseConnection *closeConnection = parcObject_CreateInstance(RtaCommandCloseConnection); closeConnection->apiNotifierFd = apiNotifierFd; return closeConnection; }
CCNxInterestPayloadId * ccnxInterestPayloadId_CreateAsSHA256Hash(const PARCBuffer *data) { CCNxInterestPayloadId *result = parcObject_CreateInstance(CCNxInterestPayloadId); PARCCryptoHasher *hasher = parcCryptoHasher_Create(PARCCryptoHashType_SHA256); parcCryptoHasher_Init(hasher); parcCryptoHasher_UpdateBuffer(hasher, data); PARCCryptoHash *hash = parcCryptoHasher_Finalize(hasher); parcCryptoHasher_Release(&hasher); PARCBuffer *hashData = parcCryptoHash_GetDigest(hash); PARCBuffer *codedHash = parcBuffer_Allocate(parcBuffer_Capacity(hashData) + 1); parcBuffer_PutUint8(codedHash, CCNxInterestPayloadId_TypeCode_RFC6920_SHA256); parcBuffer_PutBuffer(codedHash, hashData); parcBuffer_Flip(codedHash); result->nameSegment = ccnxNameSegment_CreateTypeValue(CCNxNameLabelType_PAYLOADID, codedHash); parcBuffer_Release(&codedHash); parcCryptoHash_Release(&hash); return result; }
PARCJSONParser * parcJSONParser_Create(PARCBuffer *buffer) { PARCJSONParser *result = parcObject_CreateInstance(PARCJSONParser); result->ignore = " \t\n"; result->buffer = parcBuffer_Acquire(buffer); return result; }
RtaCommandCreateProtocolStack * rtaCommandCreateProtocolStack_Create(int stackId, CCNxStackConfig *config) { RtaCommandCreateProtocolStack *createStack = parcObject_CreateInstance(RtaCommandCreateProtocolStack); createStack->stackId = stackId; createStack->config = ccnxStackConfig_Copy(config); return createStack; }
PARCURISegment * parcURISegment_CreateFromBuffer(PARCBuffer *buffer) { PARCURISegment *result = parcObject_CreateInstance(PARCURISegment); if (result != NULL) { result->buffer = parcBuffer_Acquire(buffer); } return result; }
PARCSortedList * parcSortedList_Copy(const PARCSortedList *original) { PARCSortedList *result = parcObject_CreateInstance(PARCSortedList); if (result != NULL) { result->list = parcLinkedList_Copy(original->list); } return result; }
CCNxNameSegment * ccnxNameSegment_CreateLabelValue(const CCNxNameLabel *label, const PARCBuffer *value) { CCNxNameSegment *result = parcObject_CreateInstance(CCNxNameSegment); if (result != NULL) { result->label = ccnxNameLabel_Acquire(label); result->type = ccnxNameLabel_GetType(label); result->value = parcBuffer_Acquire(value); } return result; }
CCNxChunker * ccnxChunker_Create(void *instance, CCNxChunkerInterface *interface) { CCNxChunker *chunker = parcObject_CreateInstance(CCNxChunker); if (chunker != NULL) { chunker->instance = instance; chunker->interface = interface; } return chunker; }
PARCChunker * parcChunker_Create(PARCObject *instance, PARCChunkerInterface *interface) { PARCChunker *chunker = parcObject_CreateInstance(PARCChunker); if (chunker != NULL) { chunker->instance = parcObject_Acquire(instance); chunker->interface = interface; } return chunker; }
PARCScheduledTask * parcScheduledTask_Create(PARCFutureTask *task, uint64_t executionTime) { PARCScheduledTask *result = parcObject_CreateInstance(PARCScheduledTask); if (result != NULL) { result->task = parcFutureTask_Acquire(task); result->executionTime = executionTime; } return result; }
PARCKeyStore * parcKeyStore_Create(PARCObject *instance, const PARCKeyStoreInterface *interface) { PARCKeyStore *keyStore = parcObject_CreateInstance(PARCKeyStore); if (keyStore != NULL) { keyStore->instance = parcObject_Acquire(instance); keyStore->interface = interface; } return keyStore; }
PARCSortedList * parcSortedList_CreateCompare(PARCSortedListEntryCompareFunction compare) { PARCSortedList *result = parcObject_CreateInstance(PARCSortedList); if (result != NULL) { result->list = parcLinkedList_Create(); result->compare = compare; } return result; }
CCNxPortalAnchor * ccnxPortalAnchor_Create(const CCNxName *name, time_t expireTime) { CCNxPortalAnchor *result = parcObject_CreateInstance(CCNxPortalAnchor); if (result != NULL) { result->prefix = ccnxName_Acquire(name); result->expireTime = expireTime; } return result; }
MetisGenericEther * metisGenericEther_Create(MetisForwarder *metis, const char *deviceName, uint16_t etherType) { assertNotNull(metis, "Parameter metis must be non-null"); // The Darwin generic ether allows a NULL device name, it is used in the unit tests. MetisGenericEther *ether = NULL; if (metisEthernet_IsValidEthertype(etherType)) { ether = parcObject_CreateInstance(MetisGenericEther); ether->ethertype = etherType; ether->logger = metisLogger_Acquire(metisForwarder_GetLogger(metis)); ether->etherSocket = -1; // invalid valid ether->workBuffer = parcEventBuffer_Create(); ether->macAddress = NULL; ether->mtu = metisSystem_InterfaceMtu(metis, deviceName); _darwinEthernet_SetInterfaceAddress(ether, deviceName); bool success = _darwinEthernet_SetupReceive(ether, deviceName); if (success) { if (metisLogger_IsLoggable(ether->logger, MetisLoggerFacility_IO, PARCLogLevel_Info)) { char *str = parcBuffer_ToHexString(ether->macAddress); metisLogger_Log(ether->logger, MetisLoggerFacility_IO, PARCLogLevel_Info, __func__, "GenericEther %p created on device %s (%s) for ethertype 0x%04x fd %d bufferLength %u mtu %u", (void *) ether, deviceName, str, etherType, ether->etherSocket, ether->etherBufferLength, ether->mtu); parcMemory_Deallocate((void **) &str); } } else { if (metisLogger_IsLoggable(ether->logger, MetisLoggerFacility_IO, PARCLogLevel_Error)) { metisLogger_Log(ether->logger, MetisLoggerFacility_IO, PARCLogLevel_Error, __func__, "GenericEther failed to created on device %s for ethertype 0x%04x", deviceName, etherType); } // this will also null ether metisGenericEther_Release(ðer); } assertTrue(ether->etherBufferLength < 65536, "Buffer length way too big, expected less than 65536 got %u", ether->etherBufferLength); } else { if (metisLogger_IsLoggable(metisForwarder_GetLogger(metis), MetisLoggerFacility_IO, PARCLogLevel_Error)) { metisLogger_Log(metisForwarder_GetLogger(metis), MetisLoggerFacility_IO, PARCLogLevel_Error, __func__, "GenericEther failed to created on device %s for ethertype 0x%04x, invalid ethertype", deviceName, etherType); } } return ether; }
static _PARCHashMapEntry * _parcHashMapEntry_Create(const PARCObject *key, const PARCObject *value) { parcObject_OptionalAssertValid(key); parcObject_OptionalAssertValid(value); _PARCHashMapEntry *result = parcObject_CreateInstance(_PARCHashMapEntry); result->key = parcObject_Copy(key); result->value = parcObject_Acquire(value); return result; }
PARCSynchronizer * parcSynchronizer_Create(void) { PARCSynchronizer *result = parcObject_CreateInstance(PARCSynchronizer); #ifdef PARCLibrary_DISABLE_ATOMICS pthread_mutex_init(&result->mutex, NULL); #else result->mutex = _PARCSynchronizer_Unlocked; #endif return result; }
PARCBufferChunker * parcBufferChunker_Create(PARCBuffer *data, size_t chunkSize) { PARCBufferChunker *chunker = parcObject_CreateInstance(PARCBufferChunker); if (chunker != NULL) { chunker->chunkSize = chunkSize; chunker->data = parcBuffer_Acquire(data); chunker->currentElement = NULL; } return chunker; }
static CCNxInterestPayloadId * _ccnxInterestPayloadId_CreateFromNameSegment(const CCNxNameSegment *nameSegment) { ccnxNameSegment_AssertValid(nameSegment); assertTrue(ccnxNameSegment_GetType(nameSegment) == CCNxNameLabelType_PAYLOADID, "ccnxInterestPayloadId_CreateFromNameSegment: supplied nameSegment is not a PayloadId"); if (ccnxNameSegment_GetType(nameSegment) != CCNxNameLabelType_PAYLOADID) { return NULL; } CCNxInterestPayloadId *result = parcObject_CreateInstance(CCNxInterestPayloadId); result->nameSegment = ccnxNameSegment_Acquire(nameSegment); return result; }
PARCFileChunker * parcFileChunker_Create(PARCFile *file, size_t chunkSize) { PARCFileChunker *chunker = parcObject_CreateInstance(PARCFileChunker); if (chunker != NULL) { chunker->chunkSize = chunkSize; chunker->file = parcFile_Acquire(file); chunker->fhandle = parcRandomAccessFile_Open(chunker->file); chunker->currentElement = NULL; } return chunker; }
CCNxPortalAnchor * ccnxPortalAnchor_CreateFromJSON(const PARCJSON *json) { CCNxPortalAnchor *result = parcObject_CreateInstance(CCNxPortalAnchor); if (result != NULL) { result->prefix = ccnxName_CreateFromURI(parcBuffer_Overlay(parcJSONValue_GetString(parcJSON_GetByPath(json, "/namePrefix")), 0)); result->expireTime = parcJSONValue_GetInteger(parcJSON_GetByPath(json, "/expireTime")); ccnxPortalAnchor_OptionalAssertValid(result); } return result; }
PARCPublicKeySigner * parcPublicKeySigner_Create(PARCKeyStore *keyStore, PARCSigningAlgorithm signingAlgorithm, PARCCryptoHashType hashType) { PARCPublicKeySigner *result = parcObject_CreateInstance(PARCPublicKeySigner); if (result != NULL) { result->keyStore = parcKeyStore_Acquire(keyStore); result->signingAlgorithm = signingAlgorithm; result->hashType = hashType; result->hasher = parcCryptoHasher_Create(hashType); } return result; }
PARCStopwatch * parcStopwatch_Create(void) { PARCStopwatch *result = parcObject_CreateInstance(PARCStopwatch); if (result != NULL) { result->start.tv_sec = 0; result->start.tv_usec = 0; result->stop.tv_sec = 0; result->stop.tv_usec = 0; } return result; }
PARCBasicStats * parcBasicStats_Create(void) { PARCBasicStats *result = parcObject_CreateInstance(PARCBasicStats); if (result != NULL) { result->count = 0; result->mean = 0; result->variance = 0; result->maximum = 0; result->minimum = 0; } return result; }
PARCTimer * parcTimer_Create(void) { PARCTimer *result = parcObject_CreateInstance(PARCTimer); if (result != NULL) { result->start.tv_sec = 0; result->start.tv_usec = 0; result->stop.tv_sec = 0; result->stop.tv_usec = 0; } return result; }
static _MockSigner * _createSigner() { _MockSigner *signer = parcObject_CreateInstance(_MockSigner); signer->hasher = parcCryptoHasher_Create(PARCCryptoHashType_SHA256); PARCPkcs12KeyStore *publicKeyStore = parcPkcs12KeyStore_Open("test_rsa.p12", "blueberry", PARCCryptoHashType_SHA256); assertNotNull(publicKeyStore, "Got null result from opening openssl pkcs12 file"); signer->keyStore = parcKeyStore_Create(publicKeyStore, PARCPkcs12KeyStoreAsKeyStore); parcPkcs12KeyStore_Release(&publicKeyStore); return signer; }
PARCLock * parcLock_Create(void) { PARCLock *result = parcObject_CreateInstance(PARCLock); pthread_mutexattr_init(&result->lockAttributes); pthread_mutexattr_settype(&result->lockAttributes, PTHREAD_MUTEX_ERRORCHECK); pthread_mutex_init(&result->lock, &result->lockAttributes); result->locked = false; pthread_cond_init(&result->notification, NULL); result->notified = false; return result; }
PARCFile * parcFile_CreateChild(const PARCFile *parent, char *fileName) { PARCFile *result = NULL; PARCPathName *childPath = parcPathName_Append(parcPathName_Copy(parent->pathName), fileName); if (childPath != NULL) { result = parcObject_CreateInstance(PARCFile); if (result != NULL) { result->pathName = childPath; } } return result; }
static PARCRingBuffer1x1 * _create(uint32_t elements, RingBufferEntryDestroyer *destroyer) { PARCRingBuffer1x1 *ring = parcObject_CreateInstance(PARCRingBuffer1x1); assertNotNull(ring, "parcObject_Create returned NULL"); ring->buffer = parcMemory_AllocateAndClear(sizeof(void *) * elements); assertNotNull((ring->buffer), "parcMemory_AllocateAndClear() failed to allocate array of %u pointers", elements); ring->writer_head = 0; ring->reader_tail = 0; ring->elements = elements; ring->destroyer = destroyer; ring->ring_mask = elements - 1; return ring; }