Loading include/byte_array.h +2 −0 Original line number Diff line number Diff line Loading @@ -51,7 +51,9 @@ long ByteBuffer_BytesRemaining(const ByteBuffer buffer); ByteArray ByteBuffer_Consume(ByteBuffer* buffer, size_t len); ByteBuffer* ByteBuffer_Append(ByteBuffer* buffer, const void* data, size_t len); ByteBuffer* ByteBuffer_AppendArray(ByteBuffer* buffer, const ByteArray array); ByteBuffer* ByteBuffer_AppendBuffer(ByteBuffer* buffer, const ByteBuffer bufferToAppend); ByteBuffer* ByteBuffer_AppendCString(ByteBuffer* buffer, const char* data); ByteBuffer* ByteBuffer_AppendFormattedCString(ByteBuffer* buffer, const char * format, ...); ByteBuffer* ByteBuffer_AppendDummyData(ByteBuffer* buffer, size_t len); #endif // _BYTE_ARRAY_H kinetic-c.sublime-project +1 −1 Original line number Diff line number Diff line Loading @@ -114,7 +114,7 @@ // "-I${folder:${project_path:kinetic-c.sublime-project}}/vendor/**", "-I${folder:${project_path:kinetic-c.sublime-project}}/vendor/protobuf-c", "-I${folder:${project_path:kinetic-c.sublime-project}}/vendor/socket99", "-I${folder:${project_path:kinetic-c.sublime-project}}/vendor/bundle/ruby/2.0.0/bundler/gems/ceedling-0.15.6/vendor/unity/src", "-I${folder:${project_path:kinetic-c.sublime-project}}/vendor/bundle/ruby/2.0.0/gems/ceedling-0.15.6/vendor/unity/src", "-I${folder:${project_path:kinetic-c.sublime-project}}/build/test/mocks", "-I${folder:${project_path:kinetic-c.sublime-project}}/test/support/stubs", "-I${folder:${project_path:kinetic-c.sublime-project}}/test/support" Loading src/lib/byte_array.c +36 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ #include <assert.h> #include <string.h> #include <stdio.h> #include <stdarg.h> ByteArray ByteArray_Create(void* data, size_t len) { Loading Loading @@ -103,6 +104,21 @@ ByteBuffer* ByteBuffer_AppendArray(ByteBuffer* buffer, const ByteArray array) return buffer; } ByteBuffer* ByteBuffer_AppendBuffer(ByteBuffer* buffer, const ByteBuffer bufferToAppend) { assert(buffer != NULL); assert(buffer->array.data != NULL); assert(bufferToAppend.array.data != NULL); assert(bufferToAppend.bytesUsed <= bufferToAppend.array.len); if ((buffer->bytesUsed + bufferToAppend.bytesUsed) > buffer->array.len) { return NULL; } memcpy(&buffer->array.data[buffer->bytesUsed], bufferToAppend.array.data, bufferToAppend.bytesUsed); buffer->bytesUsed += bufferToAppend.bytesUsed; return buffer; } ByteBuffer* ByteBuffer_AppendCString(ByteBuffer* buffer, const char* str) { assert(buffer != NULL); Loading @@ -117,6 +133,26 @@ ByteBuffer* ByteBuffer_AppendCString(ByteBuffer* buffer, const char* str) return buffer; } ByteBuffer* ByteBuffer_AppendFormattedCString(ByteBuffer* buffer, const char * format, ...) { assert(buffer != NULL); assert(buffer->array.data != NULL); va_list args; va_start(args,format); uint8_t tmp[256]; ByteBuffer tmpBuf = ByteBuffer_Create(tmp, sizeof(tmp), 0); int formattedSize = vsnprintf((void*)tmpBuf.array.data, tmpBuf.array.len, format, args); assert(formattedSize >= 0); tmpBuf.bytesUsed = (tmpBuf.array.len <= (size_t)formattedSize) ? formattedSize : tmpBuf.array.len; va_end(args); return ByteBuffer_AppendBuffer(buffer, tmpBuf); } ByteBuffer* ByteBuffer_AppendDummyData(ByteBuffer* buffer, size_t len) { assert(buffer != NULL); Loading src/lib/kinetic_controller.c +0 −2 Original line number Diff line number Diff line Loading @@ -112,8 +112,6 @@ KineticStatus KineticController_ExecuteOperation(KineticOperation* operation, Ki LOGF1(" Sending PDU (0x%0llX) w/o value", operation->request); } KineticOperation_SetTimeoutTime(operation, KINETIC_OPERATION_TIMEOUT_SECS); if (closure != NULL) { operation->closure = *closure; Loading src/lib/kinetic_operation.c +1 −0 Original line number Diff line number Diff line Loading @@ -115,6 +115,7 @@ KineticStatus KineticOperation_SendRequest(KineticOperation* const operation) request->headerNBO.valueLength = KineticNBO_FromHostU32(request->header.valueLength); pthread_mutex_lock(&operation->connection->writeMutex); KineticOperation_SetTimeoutTime(operation, KINETIC_OPERATION_TIMEOUT_SECS); KineticStatus status = WritePDU(operation); pthread_mutex_unlock(&operation->connection->writeMutex); return status; Loading Loading
include/byte_array.h +2 −0 Original line number Diff line number Diff line Loading @@ -51,7 +51,9 @@ long ByteBuffer_BytesRemaining(const ByteBuffer buffer); ByteArray ByteBuffer_Consume(ByteBuffer* buffer, size_t len); ByteBuffer* ByteBuffer_Append(ByteBuffer* buffer, const void* data, size_t len); ByteBuffer* ByteBuffer_AppendArray(ByteBuffer* buffer, const ByteArray array); ByteBuffer* ByteBuffer_AppendBuffer(ByteBuffer* buffer, const ByteBuffer bufferToAppend); ByteBuffer* ByteBuffer_AppendCString(ByteBuffer* buffer, const char* data); ByteBuffer* ByteBuffer_AppendFormattedCString(ByteBuffer* buffer, const char * format, ...); ByteBuffer* ByteBuffer_AppendDummyData(ByteBuffer* buffer, size_t len); #endif // _BYTE_ARRAY_H
kinetic-c.sublime-project +1 −1 Original line number Diff line number Diff line Loading @@ -114,7 +114,7 @@ // "-I${folder:${project_path:kinetic-c.sublime-project}}/vendor/**", "-I${folder:${project_path:kinetic-c.sublime-project}}/vendor/protobuf-c", "-I${folder:${project_path:kinetic-c.sublime-project}}/vendor/socket99", "-I${folder:${project_path:kinetic-c.sublime-project}}/vendor/bundle/ruby/2.0.0/bundler/gems/ceedling-0.15.6/vendor/unity/src", "-I${folder:${project_path:kinetic-c.sublime-project}}/vendor/bundle/ruby/2.0.0/gems/ceedling-0.15.6/vendor/unity/src", "-I${folder:${project_path:kinetic-c.sublime-project}}/build/test/mocks", "-I${folder:${project_path:kinetic-c.sublime-project}}/test/support/stubs", "-I${folder:${project_path:kinetic-c.sublime-project}}/test/support" Loading
src/lib/byte_array.c +36 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ #include <assert.h> #include <string.h> #include <stdio.h> #include <stdarg.h> ByteArray ByteArray_Create(void* data, size_t len) { Loading Loading @@ -103,6 +104,21 @@ ByteBuffer* ByteBuffer_AppendArray(ByteBuffer* buffer, const ByteArray array) return buffer; } ByteBuffer* ByteBuffer_AppendBuffer(ByteBuffer* buffer, const ByteBuffer bufferToAppend) { assert(buffer != NULL); assert(buffer->array.data != NULL); assert(bufferToAppend.array.data != NULL); assert(bufferToAppend.bytesUsed <= bufferToAppend.array.len); if ((buffer->bytesUsed + bufferToAppend.bytesUsed) > buffer->array.len) { return NULL; } memcpy(&buffer->array.data[buffer->bytesUsed], bufferToAppend.array.data, bufferToAppend.bytesUsed); buffer->bytesUsed += bufferToAppend.bytesUsed; return buffer; } ByteBuffer* ByteBuffer_AppendCString(ByteBuffer* buffer, const char* str) { assert(buffer != NULL); Loading @@ -117,6 +133,26 @@ ByteBuffer* ByteBuffer_AppendCString(ByteBuffer* buffer, const char* str) return buffer; } ByteBuffer* ByteBuffer_AppendFormattedCString(ByteBuffer* buffer, const char * format, ...) { assert(buffer != NULL); assert(buffer->array.data != NULL); va_list args; va_start(args,format); uint8_t tmp[256]; ByteBuffer tmpBuf = ByteBuffer_Create(tmp, sizeof(tmp), 0); int formattedSize = vsnprintf((void*)tmpBuf.array.data, tmpBuf.array.len, format, args); assert(formattedSize >= 0); tmpBuf.bytesUsed = (tmpBuf.array.len <= (size_t)formattedSize) ? formattedSize : tmpBuf.array.len; va_end(args); return ByteBuffer_AppendBuffer(buffer, tmpBuf); } ByteBuffer* ByteBuffer_AppendDummyData(ByteBuffer* buffer, size_t len) { assert(buffer != NULL); Loading
src/lib/kinetic_controller.c +0 −2 Original line number Diff line number Diff line Loading @@ -112,8 +112,6 @@ KineticStatus KineticController_ExecuteOperation(KineticOperation* operation, Ki LOGF1(" Sending PDU (0x%0llX) w/o value", operation->request); } KineticOperation_SetTimeoutTime(operation, KINETIC_OPERATION_TIMEOUT_SECS); if (closure != NULL) { operation->closure = *closure; Loading
src/lib/kinetic_operation.c +1 −0 Original line number Diff line number Diff line Loading @@ -115,6 +115,7 @@ KineticStatus KineticOperation_SendRequest(KineticOperation* const operation) request->headerNBO.valueLength = KineticNBO_FromHostU32(request->header.valueLength); pthread_mutex_lock(&operation->connection->writeMutex); KineticOperation_SetTimeoutTime(operation, KINETIC_OPERATION_TIMEOUT_SECS); KineticStatus status = WritePDU(operation); pthread_mutex_unlock(&operation->connection->writeMutex); return status; Loading