mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-11 04:07:08 -06:00
Update to Fast LZMA2 1.0.0
This commit is contained in:
@@ -14,10 +14,8 @@
|
||||
/*-*************************************
|
||||
* Dependencies
|
||||
***************************************/
|
||||
#include <stdlib.h> /* malloc, calloc, free */
|
||||
#include <string.h> /* memset */
|
||||
#include "fast-lzma2.h"
|
||||
#include "fl2_error_private.h"
|
||||
#include "fl2_errors.h"
|
||||
#include "fl2_internal.h"
|
||||
|
||||
|
||||
@@ -29,6 +27,9 @@ FL2LIB_API unsigned FL2LIB_CALL FL2_versionNumber(void) { return FL2_VERSION_NUM
|
||||
FL2LIB_API const char* FL2LIB_CALL FL2_versionString(void) { return FL2_VERSION_STRING; }
|
||||
|
||||
|
||||
/*-****************************************
|
||||
* Compression helpers
|
||||
******************************************/
|
||||
FL2LIB_API size_t FL2LIB_CALL FL2_compressBound(size_t srcSize)
|
||||
{
|
||||
return FL2_COMPRESSBOUND(srcSize);
|
||||
@@ -37,21 +38,70 @@ FL2LIB_API size_t FL2LIB_CALL FL2_compressBound(size_t srcSize)
|
||||
/*-****************************************
|
||||
* FL2 Error Management
|
||||
******************************************/
|
||||
HINT_INLINE
|
||||
unsigned IsError(size_t code)
|
||||
{
|
||||
return (code > FL2_ERROR(maxCode));
|
||||
}
|
||||
|
||||
/*! FL2_isError() :
|
||||
* tells if a return value is an error code */
|
||||
FL2LIB_API unsigned FL2LIB_CALL FL2_isError(size_t code) { return ERR_isError(code); }
|
||||
FL2LIB_API unsigned FL2LIB_CALL FL2_isError(size_t code)
|
||||
{
|
||||
return IsError(code);
|
||||
}
|
||||
|
||||
/*! FL2_isTimedOut() :
|
||||
* tells if a return value is the timeout code */
|
||||
FL2LIB_API unsigned FL2LIB_CALL FL2_isTimedOut(size_t code)
|
||||
{
|
||||
return (code == FL2_ERROR(timedOut));
|
||||
}
|
||||
|
||||
/*! FL2_getErrorName() :
|
||||
* provides error code string from function result (useful for debugging) */
|
||||
FL2LIB_API const char* FL2LIB_CALL FL2_getErrorName(size_t code) { return ERR_getErrorName(code); }
|
||||
FL2LIB_API const char* FL2LIB_CALL FL2_getErrorName(size_t code)
|
||||
{
|
||||
return FL2_getErrorString(FL2_getErrorCode(code));
|
||||
}
|
||||
|
||||
/*! FL2_getError() :
|
||||
* convert a `size_t` function result into a proper FL2_errorCode enum */
|
||||
FL2LIB_API FL2_ErrorCode FL2LIB_CALL FL2_getErrorCode(size_t code) { return ERR_getErrorCode(code); }
|
||||
FL2LIB_API FL2_ErrorCode FL2LIB_CALL FL2_getErrorCode(size_t code)
|
||||
{
|
||||
if (!IsError(code))
|
||||
return (FL2_ErrorCode)0;
|
||||
|
||||
return (FL2_ErrorCode)(0 - code);
|
||||
}
|
||||
|
||||
/*! FL2_getErrorString() :
|
||||
* provides error code string from enum */
|
||||
FL2LIB_API const char* FL2LIB_CALL FL2_getErrorString(FL2_ErrorCode code) { return ERR_getFL2ErrorString(code); }
|
||||
FL2LIB_API const char* FL2LIB_CALL FL2_getErrorString(FL2_ErrorCode code)
|
||||
{
|
||||
static const char* const notErrorCode = "Unspecified error code";
|
||||
switch (code)
|
||||
{
|
||||
case PREFIX(no_error): return "No error detected";
|
||||
case PREFIX(GENERIC): return "Error (generic)";
|
||||
case PREFIX(corruption_detected): return "Corrupted block detected";
|
||||
case PREFIX(checksum_wrong): return "Restored data doesn't match checksum";
|
||||
case PREFIX(parameter_unsupported): return "Unsupported parameter";
|
||||
case PREFIX(parameter_outOfBound): return "Parameter is out of bound";
|
||||
case PREFIX(lclpMax_exceeded): return "Parameters lc+lp > 4";
|
||||
case PREFIX(stage_wrong): return "Not possible at this stage of encoding";
|
||||
case PREFIX(init_missing): return "Context should be init first";
|
||||
case PREFIX(memory_allocation): return "Allocation error : not enough memory";
|
||||
case PREFIX(dstSize_tooSmall): return "Destination buffer is too small";
|
||||
case PREFIX(srcSize_wrong): return "Src size is incorrect";
|
||||
case PREFIX(canceled): return "Processing was canceled by a call to FL2_cancelCStream() or FL2_cancelDStream()";
|
||||
case PREFIX(buffer): return "Streaming progress halted due to buffer(s) full/empty";
|
||||
case PREFIX(timedOut): return "Wait timed out. Timeouts should be handled before errors using FL2_isTimedOut()";
|
||||
/* following error codes are not stable and may be removed or changed in a future version */
|
||||
case PREFIX(maxCode):
|
||||
default: return notErrorCode;
|
||||
}
|
||||
}
|
||||
|
||||
/*! g_debuglog_enable :
|
||||
* turn on/off debug traces (global switch) */
|
||||
|
||||
Reference in New Issue
Block a user