1*22ce4affSfengbojiang /* 2*22ce4affSfengbojiang * Copyright (c) 2016-2020, Yann Collet, Facebook, Inc. 3*22ce4affSfengbojiang * All rights reserved. 4*22ce4affSfengbojiang * 5*22ce4affSfengbojiang * This source code is licensed under both the BSD-style license (found in the 6*22ce4affSfengbojiang * LICENSE file in the root directory of this source tree) and the GPLv2 (found 7*22ce4affSfengbojiang * in the COPYING file in the root directory of this source tree). 8*22ce4affSfengbojiang * You may select, at your option, one of the above-listed licenses. 9*22ce4affSfengbojiang */ 10*22ce4affSfengbojiang 11*22ce4affSfengbojiang #ifndef ZSTD_ERRORS_H_398273423 12*22ce4affSfengbojiang #define ZSTD_ERRORS_H_398273423 13*22ce4affSfengbojiang 14*22ce4affSfengbojiang #if defined (__cplusplus) 15*22ce4affSfengbojiang extern "C" { 16*22ce4affSfengbojiang #endif 17*22ce4affSfengbojiang 18*22ce4affSfengbojiang /*===== dependency =====*/ 19*22ce4affSfengbojiang #include <stddef.h> /* size_t */ 20*22ce4affSfengbojiang 21*22ce4affSfengbojiang 22*22ce4affSfengbojiang /* ===== ZSTDERRORLIB_API : control library symbols visibility ===== */ 23*22ce4affSfengbojiang #ifndef ZSTDERRORLIB_VISIBILITY 24*22ce4affSfengbojiang # if defined(__GNUC__) && (__GNUC__ >= 4) 25*22ce4affSfengbojiang # define ZSTDERRORLIB_VISIBILITY __attribute__ ((visibility ("default"))) 26*22ce4affSfengbojiang # else 27*22ce4affSfengbojiang # define ZSTDERRORLIB_VISIBILITY 28*22ce4affSfengbojiang # endif 29*22ce4affSfengbojiang #endif 30*22ce4affSfengbojiang #if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1) 31*22ce4affSfengbojiang # define ZSTDERRORLIB_API __declspec(dllexport) ZSTDERRORLIB_VISIBILITY 32*22ce4affSfengbojiang #elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1) 33*22ce4affSfengbojiang # define ZSTDERRORLIB_API __declspec(dllimport) ZSTDERRORLIB_VISIBILITY /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/ 34*22ce4affSfengbojiang #else 35*22ce4affSfengbojiang # define ZSTDERRORLIB_API ZSTDERRORLIB_VISIBILITY 36*22ce4affSfengbojiang #endif 37*22ce4affSfengbojiang 38*22ce4affSfengbojiang /*-********************************************* 39*22ce4affSfengbojiang * Error codes list 40*22ce4affSfengbojiang *-********************************************* 41*22ce4affSfengbojiang * Error codes _values_ are pinned down since v1.3.1 only. 42*22ce4affSfengbojiang * Therefore, don't rely on values if you may link to any version < v1.3.1. 43*22ce4affSfengbojiang * 44*22ce4affSfengbojiang * Only values < 100 are considered stable. 45*22ce4affSfengbojiang * 46*22ce4affSfengbojiang * note 1 : this API shall be used with static linking only. 47*22ce4affSfengbojiang * dynamic linking is not yet officially supported. 48*22ce4affSfengbojiang * note 2 : Prefer relying on the enum than on its value whenever possible 49*22ce4affSfengbojiang * This is the only supported way to use the error list < v1.3.1 50*22ce4affSfengbojiang * note 3 : ZSTD_isError() is always correct, whatever the library version. 51*22ce4affSfengbojiang **********************************************/ 52*22ce4affSfengbojiang typedef enum { 53*22ce4affSfengbojiang ZSTD_error_no_error = 0, 54*22ce4affSfengbojiang ZSTD_error_GENERIC = 1, 55*22ce4affSfengbojiang ZSTD_error_prefix_unknown = 10, 56*22ce4affSfengbojiang ZSTD_error_version_unsupported = 12, 57*22ce4affSfengbojiang ZSTD_error_frameParameter_unsupported = 14, 58*22ce4affSfengbojiang ZSTD_error_frameParameter_windowTooLarge = 16, 59*22ce4affSfengbojiang ZSTD_error_corruption_detected = 20, 60*22ce4affSfengbojiang ZSTD_error_checksum_wrong = 22, 61*22ce4affSfengbojiang ZSTD_error_dictionary_corrupted = 30, 62*22ce4affSfengbojiang ZSTD_error_dictionary_wrong = 32, 63*22ce4affSfengbojiang ZSTD_error_dictionaryCreation_failed = 34, 64*22ce4affSfengbojiang ZSTD_error_parameter_unsupported = 40, 65*22ce4affSfengbojiang ZSTD_error_parameter_outOfBound = 42, 66*22ce4affSfengbojiang ZSTD_error_tableLog_tooLarge = 44, 67*22ce4affSfengbojiang ZSTD_error_maxSymbolValue_tooLarge = 46, 68*22ce4affSfengbojiang ZSTD_error_maxSymbolValue_tooSmall = 48, 69*22ce4affSfengbojiang ZSTD_error_stage_wrong = 60, 70*22ce4affSfengbojiang ZSTD_error_init_missing = 62, 71*22ce4affSfengbojiang ZSTD_error_memory_allocation = 64, 72*22ce4affSfengbojiang ZSTD_error_workSpace_tooSmall= 66, 73*22ce4affSfengbojiang ZSTD_error_dstSize_tooSmall = 70, 74*22ce4affSfengbojiang ZSTD_error_srcSize_wrong = 72, 75*22ce4affSfengbojiang ZSTD_error_dstBuffer_null = 74, 76*22ce4affSfengbojiang /* following error codes are __NOT STABLE__, they can be removed or changed in future versions */ 77*22ce4affSfengbojiang ZSTD_error_frameIndex_tooLarge = 100, 78*22ce4affSfengbojiang ZSTD_error_seekableIO = 102, 79*22ce4affSfengbojiang ZSTD_error_dstBuffer_wrong = 104, 80*22ce4affSfengbojiang ZSTD_error_srcBuffer_wrong = 105, 81*22ce4affSfengbojiang ZSTD_error_maxCode = 120 /* never EVER use this value directly, it can change in future versions! Use ZSTD_isError() instead */ 82*22ce4affSfengbojiang } ZSTD_ErrorCode; 83*22ce4affSfengbojiang 84*22ce4affSfengbojiang /*! ZSTD_getErrorCode() : 85*22ce4affSfengbojiang convert a `size_t` function result into a `ZSTD_ErrorCode` enum type, 86*22ce4affSfengbojiang which can be used to compare with enum list published above */ 87*22ce4affSfengbojiang ZSTDERRORLIB_API ZSTD_ErrorCode ZSTD_getErrorCode(size_t functionResult); 88*22ce4affSfengbojiang ZSTDERRORLIB_API const char* ZSTD_getErrorString(ZSTD_ErrorCode code); /**< Same as ZSTD_getErrorName, but using a `ZSTD_ErrorCode` enum argument */ 89*22ce4affSfengbojiang 90*22ce4affSfengbojiang 91*22ce4affSfengbojiang #if defined (__cplusplus) 92*22ce4affSfengbojiang } 93*22ce4affSfengbojiang #endif 94*22ce4affSfengbojiang 95*22ce4affSfengbojiang #endif /* ZSTD_ERRORS_H_398273423 */ 96