1902c8ce7SBaptiste Daroussin /* 2b3392d84SAllan Jude * Copyright (c) Yann Collet, Facebook, Inc. 3a19eddc3SBaptiste Daroussin * All rights reserved. 4a19eddc3SBaptiste Daroussin * 5902c8ce7SBaptiste Daroussin * This source code is licensed under both the BSD-style license (found in the 6902c8ce7SBaptiste Daroussin * LICENSE file in the root directory of this source tree) and the GPLv2 (found 7902c8ce7SBaptiste Daroussin * in the COPYING file in the root directory of this source tree). 8653667f9SBaptiste Daroussin * You may select, at your option, one of the above-listed licenses. 9a19eddc3SBaptiste Daroussin */ 10a19eddc3SBaptiste Daroussin 11a19eddc3SBaptiste Daroussin #ifndef ZSTD_ERRORS_H_398273423 12a19eddc3SBaptiste Daroussin #define ZSTD_ERRORS_H_398273423 13a19eddc3SBaptiste Daroussin 14a19eddc3SBaptiste Daroussin #if defined (__cplusplus) 15a19eddc3SBaptiste Daroussin extern "C" { 16a19eddc3SBaptiste Daroussin #endif 17a19eddc3SBaptiste Daroussin 18a19eddc3SBaptiste Daroussin /*===== dependency =====*/ 19a19eddc3SBaptiste Daroussin #include <stddef.h> /* size_t */ 20a19eddc3SBaptiste Daroussin 21a19eddc3SBaptiste Daroussin 22a19eddc3SBaptiste Daroussin /* ===== ZSTDERRORLIB_API : control library symbols visibility ===== */ 23affe9eafSBaptiste Daroussin #ifndef ZSTDERRORLIB_VISIBILITY 24a19eddc3SBaptiste Daroussin # if defined(__GNUC__) && (__GNUC__ >= 4) 25a19eddc3SBaptiste Daroussin # define ZSTDERRORLIB_VISIBILITY __attribute__ ((visibility ("default"))) 26a19eddc3SBaptiste Daroussin # else 27a19eddc3SBaptiste Daroussin # define ZSTDERRORLIB_VISIBILITY 28a19eddc3SBaptiste Daroussin # endif 29affe9eafSBaptiste Daroussin #endif 30a19eddc3SBaptiste Daroussin #if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1) 31a19eddc3SBaptiste Daroussin # define ZSTDERRORLIB_API __declspec(dllexport) ZSTDERRORLIB_VISIBILITY 32a19eddc3SBaptiste Daroussin #elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1) 33a19eddc3SBaptiste Daroussin # 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.*/ 34a19eddc3SBaptiste Daroussin #else 35a19eddc3SBaptiste Daroussin # define ZSTDERRORLIB_API ZSTDERRORLIB_VISIBILITY 36a19eddc3SBaptiste Daroussin #endif 37a19eddc3SBaptiste Daroussin 3842239e68SConrad Meyer /*-********************************************* 3942239e68SConrad Meyer * Error codes list 4042239e68SConrad Meyer *-********************************************* 4142239e68SConrad Meyer * Error codes _values_ are pinned down since v1.3.1 only. 4242239e68SConrad Meyer * Therefore, don't rely on values if you may link to any version < v1.3.1. 4342239e68SConrad Meyer * 4442239e68SConrad Meyer * Only values < 100 are considered stable. 4542239e68SConrad Meyer * 4642239e68SConrad Meyer * note 1 : this API shall be used with static linking only. 4742239e68SConrad Meyer * dynamic linking is not yet officially supported. 4842239e68SConrad Meyer * note 2 : Prefer relying on the enum than on its value whenever possible 4942239e68SConrad Meyer * This is the only supported way to use the error list < v1.3.1 5042239e68SConrad Meyer * note 3 : ZSTD_isError() is always correct, whatever the library version. 5142239e68SConrad Meyer **********************************************/ 52a19eddc3SBaptiste Daroussin typedef enum { 53902c8ce7SBaptiste Daroussin ZSTD_error_no_error = 0, 54902c8ce7SBaptiste Daroussin ZSTD_error_GENERIC = 1, 55902c8ce7SBaptiste Daroussin ZSTD_error_prefix_unknown = 10, 56902c8ce7SBaptiste Daroussin ZSTD_error_version_unsupported = 12, 57902c8ce7SBaptiste Daroussin ZSTD_error_frameParameter_unsupported = 14, 58902c8ce7SBaptiste Daroussin ZSTD_error_frameParameter_windowTooLarge = 16, 59902c8ce7SBaptiste Daroussin ZSTD_error_corruption_detected = 20, 60902c8ce7SBaptiste Daroussin ZSTD_error_checksum_wrong = 22, 61902c8ce7SBaptiste Daroussin ZSTD_error_dictionary_corrupted = 30, 62902c8ce7SBaptiste Daroussin ZSTD_error_dictionary_wrong = 32, 63902c8ce7SBaptiste Daroussin ZSTD_error_dictionaryCreation_failed = 34, 64902c8ce7SBaptiste Daroussin ZSTD_error_parameter_unsupported = 40, 65902c8ce7SBaptiste Daroussin ZSTD_error_parameter_outOfBound = 42, 66902c8ce7SBaptiste Daroussin ZSTD_error_tableLog_tooLarge = 44, 67902c8ce7SBaptiste Daroussin ZSTD_error_maxSymbolValue_tooLarge = 46, 68902c8ce7SBaptiste Daroussin ZSTD_error_maxSymbolValue_tooSmall = 48, 69902c8ce7SBaptiste Daroussin ZSTD_error_stage_wrong = 60, 70902c8ce7SBaptiste Daroussin ZSTD_error_init_missing = 62, 71902c8ce7SBaptiste Daroussin ZSTD_error_memory_allocation = 64, 7242239e68SConrad Meyer ZSTD_error_workSpace_tooSmall= 66, 73902c8ce7SBaptiste Daroussin ZSTD_error_dstSize_tooSmall = 70, 74902c8ce7SBaptiste Daroussin ZSTD_error_srcSize_wrong = 72, 75af73257bSConrad Meyer ZSTD_error_dstBuffer_null = 74, 7642239e68SConrad Meyer /* following error codes are __NOT STABLE__, they can be removed or changed in future versions */ 77902c8ce7SBaptiste Daroussin ZSTD_error_frameIndex_tooLarge = 100, 78902c8ce7SBaptiste Daroussin ZSTD_error_seekableIO = 102, 79bc64b5ceSConrad Meyer ZSTD_error_dstBuffer_wrong = 104, 80f6ae9767SConrad Meyer ZSTD_error_srcBuffer_wrong = 105, 81653667f9SBaptiste Daroussin ZSTD_error_maxCode = 120 /* never EVER use this value directly, it can change in future versions! Use ZSTD_isError() instead */ 82a19eddc3SBaptiste Daroussin } ZSTD_ErrorCode; 83a19eddc3SBaptiste Daroussin 84a19eddc3SBaptiste Daroussin /*! ZSTD_getErrorCode() : 85a19eddc3SBaptiste Daroussin convert a `size_t` function result into a `ZSTD_ErrorCode` enum type, 86affe9eafSBaptiste Daroussin which can be used to compare with enum list published above */ 87a19eddc3SBaptiste Daroussin ZSTDERRORLIB_API ZSTD_ErrorCode ZSTD_getErrorCode(size_t functionResult); 88902c8ce7SBaptiste Daroussin ZSTDERRORLIB_API const char* ZSTD_getErrorString(ZSTD_ErrorCode code); /**< Same as ZSTD_getErrorName, but using a `ZSTD_ErrorCode` enum argument */ 89a19eddc3SBaptiste Daroussin 90a19eddc3SBaptiste Daroussin 91a19eddc3SBaptiste Daroussin #if defined (__cplusplus) 92a19eddc3SBaptiste Daroussin } 93a19eddc3SBaptiste Daroussin #endif 94a19eddc3SBaptiste Daroussin 95a19eddc3SBaptiste Daroussin #endif /* ZSTD_ERRORS_H_398273423 */ 96