diff --git a/include/util/tbuffer.h b/include/util/tbuffer.h index e2b9f192a7a09cfa9d1d63cf4c84a3e8d311d5f7..6bb7f67e3d52549bac2a381bc4d65ad1b6263bf5 100644 --- a/include/util/tbuffer.h +++ b/include/util/tbuffer.h @@ -93,58 +93,26 @@ typedef struct SBufferWriter { #define tbufTell(buf) ((buf)->pos) //////////////////////////////////////////////////////////////////////////////// -// reader functions & macros - -// *Endian*, if true, reader functions of primitive types will do 'ntoh' automatically -#define tbufInitReader(Data, Size, Endian) \ - { .endian = (Endian), .data = (Data), .pos = 0, .size = ((Data) == NULL ? 0 : (Size)) } - -size_t tbufSkip(SBufferReader* buf, size_t size); - -const char* tbufRead(SBufferReader* buf, size_t size); -void tbufReadToBuffer(SBufferReader* buf, void* dst, size_t size); -const char* tbufReadString(SBufferReader* buf, size_t* len); -size_t tbufReadToString(SBufferReader* buf, char* dst, size_t size); -const char* tbufReadBinary(SBufferReader* buf, size_t* len); -size_t tbufReadToBinary(SBufferReader* buf, void* dst, size_t size); - -bool tbufReadBool(SBufferReader* buf); -char tbufReadChar(SBufferReader* buf); -int8_t tbufReadInt8(SBufferReader* buf); -uint8_t tbufReadUint8(SBufferReader* buf); -int16_t tbufReadInt16(SBufferReader* buf); -uint16_t tbufReadUint16(SBufferReader* buf); -int32_t tbufReadInt32(SBufferReader* buf); -uint32_t tbufReadUint32(SBufferReader* buf); -int64_t tbufReadInt64(SBufferReader* buf); -uint64_t tbufReadUint64(SBufferReader* buf); -float tbufReadFloat(SBufferReader* buf); -double tbufReadDouble(SBufferReader* buf); - -//////////////////////////////////////////////////////////////////////////////// -// writer functions & macros - +/* ------------------------ BUFFER WRITER FUNCTIONS AND MACROS ------------------------ */ // *Allocator*, function to allocate memory, will use 'realloc' if NULL // *Endian*, if true, writer functions of primitive types will do 'hton' automatically #define tbufInitWriter(Allocator, Endian) \ { .endian = (Endian), .data = NULL, .pos = 0, .size = 0, .allocator = ((Allocator) == NULL ? realloc : (Allocator)) } -void tbufCloseWriter(SBufferWriter* buf); +void tbufCloseWriter(SBufferWriter* buf); void tbufEnsureCapacity(SBufferWriter* buf, size_t size); size_t tbufReserve(SBufferWriter* buf, size_t size); char* tbufGetData(SBufferWriter* buf, bool takeOver); - -void tbufWrite(SBufferWriter* buf, const void* data, size_t size); -void tbufWriteAt(SBufferWriter* buf, size_t pos, const void* data, size_t size); -void tbufWriteStringLen(SBufferWriter* buf, const char* str, size_t len); -void tbufWriteString(SBufferWriter* buf, const char* str); +void tbufWrite(SBufferWriter* buf, const void* data, size_t size); +void tbufWriteAt(SBufferWriter* buf, size_t pos, const void* data, size_t size); +void tbufWriteStringLen(SBufferWriter* buf, const char* str, size_t len); +void tbufWriteString(SBufferWriter* buf, const char* str); // the prototype of tbufWriteBinary and tbufWrite are identical // the difference is: tbufWriteBinary writes the length of the data to the buffer // first, then the actual data, which means the reader don't need to know data // size before read. Write only write the data itself, which means the reader // need to know data size before read. void tbufWriteBinary(SBufferWriter* buf, const void* data, size_t len); - void tbufWriteBool(SBufferWriter* buf, bool data); void tbufWriteBoolAt(SBufferWriter* buf, size_t pos, bool data); void tbufWriteChar(SBufferWriter* buf, char data); @@ -170,6 +138,31 @@ void tbufWriteFloatAt(SBufferWriter* buf, size_t pos, float data); void tbufWriteDouble(SBufferWriter* buf, double data); void tbufWriteDoubleAt(SBufferWriter* buf, size_t pos, double data); +/* ------------------------ BUFFER READER FUNCTIONS AND MACROS ------------------------ */ +// *Endian*, if true, reader functions of primitive types will do 'ntoh' automatically +#define tbufInitReader(Data, Size, Endian) \ + { .endian = (Endian), .data = (Data), .pos = 0, .size = ((Data) == NULL ? 0 : (Size)) } + +size_t tbufSkip(SBufferReader* buf, size_t size); +const char* tbufRead(SBufferReader* buf, size_t size); +void tbufReadToBuffer(SBufferReader* buf, void* dst, size_t size); +const char* tbufReadString(SBufferReader* buf, size_t* len); +size_t tbufReadToString(SBufferReader* buf, char* dst, size_t size); +const char* tbufReadBinary(SBufferReader* buf, size_t* len); +size_t tbufReadToBinary(SBufferReader* buf, void* dst, size_t size); +bool tbufReadBool(SBufferReader* buf); +char tbufReadChar(SBufferReader* buf); +int8_t tbufReadInt8(SBufferReader* buf); +uint8_t tbufReadUint8(SBufferReader* buf); +int16_t tbufReadInt16(SBufferReader* buf); +uint16_t tbufReadUint16(SBufferReader* buf); +int32_t tbufReadInt32(SBufferReader* buf); +uint32_t tbufReadUint32(SBufferReader* buf); +int64_t tbufReadInt64(SBufferReader* buf); +uint64_t tbufReadUint64(SBufferReader* buf); +float tbufReadFloat(SBufferReader* buf); +double tbufReadDouble(SBufferReader* buf); + #ifdef __cplusplus } #endif diff --git a/source/dnode/vnode/impl/inc/vnodeRequest.h b/source/dnode/vnode/impl/inc/vnodeRequest.h index d70fc84cabe23acc0219bb037a180b528c9de105..93b4589bad78153a3853a5d6c759a639d5f5540e 100644 --- a/source/dnode/vnode/impl/inc/vnodeRequest.h +++ b/source/dnode/vnode/impl/inc/vnodeRequest.h @@ -23,8 +23,8 @@ extern "C" { #endif // SVDropTableReq -int vnodeBuildDropTableReq(void **buf, const SVDropTableReq *pReq); -void *vnodeParseDropTableReq(void *buf, SVDropTableReq *pReq); +// int vnodeBuildDropTableReq(void **buf, const SVDropTableReq *pReq); +// void *vnodeParseDropTableReq(void *buf, SVDropTableReq *pReq); #ifdef __cplusplus } diff --git a/source/dnode/vnode/impl/src/vnodeRequest.c b/source/dnode/vnode/impl/src/vnodeRequest.c index afc43602d85f71b72761999f7a620a32789bc438..4b481bf3995af03e272253213b214ae12476fe30 100644 --- a/source/dnode/vnode/impl/src/vnodeRequest.c +++ b/source/dnode/vnode/impl/src/vnodeRequest.c @@ -15,6 +15,8 @@ #include "vnodeDef.h" +#if 0 + static int vnodeBuildCreateTableReq(void **buf, const SVCreateTableReq *pReq); static void *vnodeParseCreateTableReq(void *buf, SVCreateTableReq *pReq); @@ -113,4 +115,5 @@ int vnodeBuildDropTableReq(void **buf, const SVDropTableReq *pReq) { void *vnodeParseDropTableReq(void *buf, SVDropTableReq *pReq) { // TODO -} \ No newline at end of file +} +#endif \ No newline at end of file