kinetic-c  v0.12.0
Seagate Kinetic Protocol Client Library for C
Data Structures | Macros | Functions
byte_array.h File Reference
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>

Go to the source code of this file.

Data Structures

struct  ByteArray
 Structure for handling generic arrays of bytes. More...
 
struct  ByteBuffer
 Structure for an embedded ByteArray as a buffer. More...
 
struct  ByteBufferArray
 

Macros

#define BYTE_ARRAY_NONE   (ByteArray){.len = 0, .data = NULL}
 Convenience macro to represent an empty array with no data. More...
 
#define BYTE_BUFFER_NONE   (ByteBuffer){.array = BYTE_ARRAY_NONE, .bytesUsed = 0}
 Convenience macro to represent an empty buffer with no data. More...
 

Functions

ByteArray ByteArray_Create (void *data, size_t len)
 
ByteArray ByteArray_CreateWithCString (const char *str)
 
ByteArray ByteArray_GetSlice (const ByteArray array, size_t start, size_t len)
 
void ByteArray_FillWithDummyData (const ByteArray array)
 
ByteBuffer ByteBuffer_Create (void *data, size_t max_len, size_t used)
 
ByteBuffer ByteBuffer_CreateWithArray (ByteArray array)
 
ByteBuffer ByteBuffer_CreateAndAppend (void *data, size_t max_len, const void *value, size_t value_len)
 
ByteBuffer ByteBuffer_CreateAndAppendArray (void *data, size_t max_len, const ByteArray value)
 
ByteBuffer ByteBuffer_CreateAndAppendCString (void *data, size_t max_len, const char *value)
 
ByteBuffer ByteBuffer_CreateAndAppendFormattedCString (void *data, size_t max_len, const char *format,...)
 
ByteBuffer ByteBuffer_CreateAndAppendDummyData (void *data, size_t max_len, size_t len)
 
void ByteBuffer_Reset (ByteBuffer *buffer)
 
long ByteBuffer_BytesRemaining (const ByteBuffer buffer)
 
ByteArray ByteBuffer_Consume (ByteBuffer *buffer, size_t max_len)
 
ByteBufferByteBuffer_Append (ByteBuffer *buffer, const void *data, size_t len)
 
ByteBufferByteBuffer_AppendArray (ByteBuffer *buffer, const ByteArray array)
 
ByteBufferByteBuffer_AppendBuffer (ByteBuffer *buffer, const ByteBuffer bufferToAppend)
 
ByteBufferByteBuffer_AppendCString (ByteBuffer *buffer, const char *data)
 
ByteBufferByteBuffer_AppendFormattedCString (ByteBuffer *buffer, const char *format,...)
 
ByteBufferByteBuffer_AppendDummyData (ByteBuffer *buffer, size_t len)
 
bool ByteBuffer_IsNull (ByteBuffer const buffer)
 
ByteBuffer ByteBuffer_Malloc (size_t size)
 
ByteBuffer ByteBuffer_MallocAndAppend (const void *data, size_t len)
 
void ByteBuffer_Free (ByteBuffer buffer)
 

Macro Definition Documentation

#define BYTE_ARRAY_NONE   (ByteArray){.len = 0, .data = NULL}

Convenience macro to represent an empty array with no data.

Definition at line 40 of file byte_array.h.

#define BYTE_BUFFER_NONE   (ByteBuffer){.array = BYTE_ARRAY_NONE, .bytesUsed = 0}

Convenience macro to represent an empty buffer with no data.

Definition at line 65 of file byte_array.h.

Function Documentation

ByteArray ByteArray_Create ( void *  data,
size_t  len 
)

Definition at line 31 of file byte_array.c.

References ByteArray::data.

ByteArray ByteArray_CreateWithCString ( const char *  str)

Definition at line 38 of file byte_array.c.

References ByteArray::data.

ByteArray ByteArray_GetSlice ( const ByteArray  array,
size_t  start,
size_t  len 
)

Definition at line 52 of file byte_array.c.

References ByteArray::data, and ByteArray::len.

void ByteArray_FillWithDummyData ( const ByteArray  array)

Definition at line 45 of file byte_array.c.

References ByteArray::data, and ByteArray::len.

ByteBuffer ByteBuffer_Create ( void *  data,
size_t  max_len,
size_t  used 
)

Definition at line 68 of file byte_array.c.

ByteBuffer ByteBuffer_CreateWithArray ( ByteArray  array)

Definition at line 78 of file byte_array.c.

References ByteBuffer::array.

ByteBuffer ByteBuffer_CreateAndAppend ( void *  data,
size_t  max_len,
const void *  value,
size_t  value_len 
)

Definition at line 83 of file byte_array.c.

References ByteBuffer_Append(), and ByteBuffer_Create().

ByteBuffer ByteBuffer_CreateAndAppendArray ( void *  data,
size_t  max_len,
const ByteArray  value 
)

Definition at line 90 of file byte_array.c.

References ByteBuffer_AppendArray(), and ByteBuffer_Create().

ByteBuffer ByteBuffer_CreateAndAppendCString ( void *  data,
size_t  max_len,
const char *  value 
)

Definition at line 97 of file byte_array.c.

References ByteBuffer_AppendCString(), and ByteBuffer_Create().

ByteBuffer ByteBuffer_CreateAndAppendFormattedCString ( void *  data,
size_t  max_len,
const char *  format,
  ... 
)

Definition at line 221 of file byte_array.c.

References append_formatted_cstring_va_list(), and ByteBuffer_Create().

ByteBuffer ByteBuffer_CreateAndAppendDummyData ( void *  data,
size_t  max_len,
size_t  len 
)

Definition at line 104 of file byte_array.c.

References ByteBuffer_AppendDummyData(), and ByteBuffer_Create().

void ByteBuffer_Reset ( ByteBuffer buffer)

Definition at line 62 of file byte_array.c.

References ByteBuffer::bytesUsed.

long ByteBuffer_BytesRemaining ( const ByteBuffer  buffer)
ByteArray ByteBuffer_Consume ( ByteBuffer buffer,
size_t  max_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 
)
bool ByteBuffer_IsNull ( ByteBuffer const  buffer)

Definition at line 249 of file byte_array.c.

References ByteBuffer::array, and ByteArray::data.

ByteBuffer ByteBuffer_Malloc ( size_t  size)

Definition at line 254 of file byte_array.c.

References ByteBuffer_Create().

ByteBuffer ByteBuffer_MallocAndAppend ( const void *  data,
size_t  len 
)

Definition at line 262 of file byte_array.c.

References ByteBuffer_Append(), ByteBuffer_IsNull(), and ByteBuffer_Malloc().

void ByteBuffer_Free ( ByteBuffer  buffer)

Definition at line 272 of file byte_array.c.

References ByteBuffer::array, and ByteArray::data.