Add ZDICT_getHeaderSize()
This commit is contained in:
parent
2ed5344e84
commit
3c36a7f13a
@ -48,6 +48,7 @@
|
|||||||
# define ZDICT_STATIC_LINKING_ONLY
|
# define ZDICT_STATIC_LINKING_ONLY
|
||||||
#endif
|
#endif
|
||||||
#include "zdict.h"
|
#include "zdict.h"
|
||||||
|
#include "decompress/zstd_decompress_internal.h" /* ZSTD_entropyDTables_t */
|
||||||
|
|
||||||
|
|
||||||
/*-*************************************
|
/*-*************************************
|
||||||
@ -99,6 +100,17 @@ unsigned ZDICT_getDictID(const void* dictBuffer, size_t dictSize)
|
|||||||
return MEM_readLE32((const char*)dictBuffer + 4);
|
return MEM_readLE32((const char*)dictBuffer + 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t ZDICT_getDictHeaderSize(const void* dictBuffer, size_t dictSize)
|
||||||
|
{
|
||||||
|
if (dictSize <= 8 || MEM_readLE32(dictBuffer) != ZSTD_MAGIC_DICTIONARY) return 0;
|
||||||
|
|
||||||
|
{ ZSTD_entropyDTables_t dummyEntropyTables;
|
||||||
|
size_t headerSize;
|
||||||
|
dummyEntropyTables.hufTable[0] = (HUF_DTable)((HufLog)*0x1000001);
|
||||||
|
headerSize = ZSTD_loadDEntropy(&dummyEntropyTables, dictBuffer, dictSize);
|
||||||
|
return ZSTD_isError(headerSize) ? 0 : headerSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*-********************************************************
|
/*-********************************************************
|
||||||
* Dictionary training functions
|
* Dictionary training functions
|
||||||
|
@ -64,6 +64,7 @@ ZDICTLIB_API size_t ZDICT_trainFromBuffer(void* dictBuffer, size_t dictBufferCap
|
|||||||
|
|
||||||
/*====== Helper functions ======*/
|
/*====== Helper functions ======*/
|
||||||
ZDICTLIB_API unsigned ZDICT_getDictID(const void* dictBuffer, size_t dictSize); /**< extracts dictID; @return zero if error (not a valid dictionary) */
|
ZDICTLIB_API unsigned ZDICT_getDictID(const void* dictBuffer, size_t dictSize); /**< extracts dictID; @return zero if error (not a valid dictionary) */
|
||||||
|
ZDICTLIB_API size_t ZDICT_getDictHeaderSize(const void* dictBuffer, size_t dictSize); /* returns dict header size; returns zero if error (not a valid dictionary) */
|
||||||
ZDICTLIB_API unsigned ZDICT_isError(size_t errorCode);
|
ZDICTLIB_API unsigned ZDICT_isError(size_t errorCode);
|
||||||
ZDICTLIB_API const char* ZDICT_getErrorName(size_t errorCode);
|
ZDICTLIB_API const char* ZDICT_getErrorName(size_t errorCode);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user