2018-07-19 16:04:20 -04:00
|
|
|
/***********************************************************************************************************************************
|
|
|
|
Buffer IO Write
|
|
|
|
***********************************************************************************************************************************/
|
2019-04-26 08:08:23 -04:00
|
|
|
#include "build.auto.h"
|
|
|
|
|
2018-07-19 16:04:20 -04:00
|
|
|
#include "common/debug.h"
|
|
|
|
#include "common/io/bufferWrite.h"
|
2021-04-13 14:37:02 -04:00
|
|
|
#include "common/io/write.h"
|
2018-07-19 16:04:20 -04:00
|
|
|
#include "common/log.h"
|
2020-03-30 20:52:57 -04:00
|
|
|
#include "common/type/object.h"
|
2018-07-19 16:04:20 -04:00
|
|
|
|
|
|
|
/***********************************************************************************************************************************
|
2019-01-05 18:10:30 +02:00
|
|
|
Object type
|
2018-07-19 16:04:20 -04:00
|
|
|
***********************************************************************************************************************************/
|
2019-05-02 17:52:24 -04:00
|
|
|
typedef struct IoBufferWrite
|
2018-07-19 16:04:20 -04:00
|
|
|
{
|
2018-08-14 14:21:53 -04:00
|
|
|
Buffer *write; // Buffer to write into
|
2019-05-02 17:52:24 -04:00
|
|
|
} IoBufferWrite;
|
2018-07-19 16:04:20 -04:00
|
|
|
|
|
|
|
/***********************************************************************************************************************************
|
2019-05-02 17:52:24 -04:00
|
|
|
Macros for function logging
|
2018-07-19 16:04:20 -04:00
|
|
|
***********************************************************************************************************************************/
|
2019-05-02 17:52:24 -04:00
|
|
|
#define FUNCTION_LOG_IO_BUFFER_WRITE_TYPE \
|
|
|
|
IoBufferWrite *
|
|
|
|
#define FUNCTION_LOG_IO_BUFFER_WRITE_FORMAT(value, buffer, bufferSize) \
|
|
|
|
objToLog(value, "IoBufferWrite", buffer, bufferSize)
|
2018-07-19 16:04:20 -04:00
|
|
|
|
2018-08-14 14:21:53 -04:00
|
|
|
/***********************************************************************************************************************************
|
|
|
|
Write to the buffer
|
|
|
|
***********************************************************************************************************************************/
|
2019-05-02 17:52:24 -04:00
|
|
|
static void
|
|
|
|
ioBufferWrite(THIS_VOID, const Buffer *buffer)
|
2018-08-14 14:21:53 -04:00
|
|
|
{
|
2019-05-02 17:52:24 -04:00
|
|
|
THIS(IoBufferWrite);
|
|
|
|
|
2019-01-21 17:41:59 +02:00
|
|
|
FUNCTION_LOG_BEGIN(logLevelTrace);
|
|
|
|
FUNCTION_LOG_PARAM(IO_BUFFER_WRITE, this);
|
|
|
|
FUNCTION_LOG_PARAM(BUFFER, buffer);
|
|
|
|
FUNCTION_LOG_END();
|
2018-08-14 14:21:53 -04:00
|
|
|
|
2019-01-21 17:41:59 +02:00
|
|
|
ASSERT(this != NULL);
|
|
|
|
ASSERT(buffer != NULL);
|
2018-08-14 14:21:53 -04:00
|
|
|
|
|
|
|
bufCat(this->write, buffer);
|
|
|
|
|
2019-01-21 17:41:59 +02:00
|
|
|
FUNCTION_LOG_RETURN_VOID();
|
2018-08-14 14:21:53 -04:00
|
|
|
}
|
|
|
|
|
2020-04-03 18:01:28 -04:00
|
|
|
/**********************************************************************************************************************************/
|
2018-07-19 16:04:20 -04:00
|
|
|
IoWrite *
|
2019-05-02 17:52:24 -04:00
|
|
|
ioBufferWriteNew(Buffer *buffer)
|
2018-07-19 16:04:20 -04:00
|
|
|
{
|
2019-05-02 17:52:24 -04:00
|
|
|
FUNCTION_LOG_BEGIN(logLevelTrace);
|
|
|
|
FUNCTION_LOG_PARAM(BUFFER, buffer);
|
|
|
|
FUNCTION_LOG_END();
|
2018-07-19 16:04:20 -04:00
|
|
|
|
2019-05-02 17:52:24 -04:00
|
|
|
ASSERT(buffer != NULL);
|
2019-01-21 17:41:59 +02:00
|
|
|
|
2019-05-02 17:52:24 -04:00
|
|
|
IoWrite *this = NULL;
|
2018-07-19 16:04:20 -04:00
|
|
|
|
2022-05-18 10:52:01 -04:00
|
|
|
OBJ_NEW_BEGIN(IoBufferWrite, .childQty = MEM_CONTEXT_QTY_MAX, .allocQty = MEM_CONTEXT_QTY_MAX)
|
2019-05-02 17:52:24 -04:00
|
|
|
{
|
2021-09-01 11:10:35 -04:00
|
|
|
IoBufferWrite *driver = OBJ_NEW_ALLOC();
|
2020-01-23 14:15:58 -07:00
|
|
|
|
|
|
|
*driver = (IoBufferWrite)
|
|
|
|
{
|
|
|
|
.write = buffer,
|
|
|
|
};
|
2018-07-19 16:04:20 -04:00
|
|
|
|
2019-05-02 17:52:24 -04:00
|
|
|
this = ioWriteNewP(driver, .write = ioBufferWrite);
|
|
|
|
}
|
2021-09-01 11:10:35 -04:00
|
|
|
OBJ_NEW_END();
|
2018-07-19 16:04:20 -04:00
|
|
|
|
2019-05-02 17:52:24 -04:00
|
|
|
FUNCTION_LOG_RETURN(IO_WRITE, this);
|
2018-07-19 16:04:20 -04:00
|
|
|
}
|