1 /* 2 * The error code definitions for libfwsi 3 * 4 * Copyright (C) 2010-2021, Joachim Metz <joachim.metz@gmail.com> 5 * 6 * Refer to AUTHORS for acknowledgements. 7 * 8 * This program is free software: you can redistribute it and/or modify 9 * it under the terms of the GNU Lesser General Public License as published by 10 * the Free Software Foundation, either version 3 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public License 19 * along with this program. If not, see <https://www.gnu.org/licenses/>. 20 */ 21 22 #if !defined( _LIBFWSI_ERROR_H ) 23 #define _LIBFWSI_ERROR_H 24 25 #include <libfwsi/types.h> 26 27 /* External error type definition hides internal structure 28 */ 29 typedef intptr_t libfwsi_error_t; 30 31 /* The error domains 32 */ 33 enum LIBFWSI_ERROR_DOMAINS 34 { 35 LIBFWSI_ERROR_DOMAIN_ARGUMENTS = (int) 'a', 36 LIBFWSI_ERROR_DOMAIN_CONVERSION = (int) 'c', 37 LIBFWSI_ERROR_DOMAIN_COMPRESSION = (int) 'C', 38 LIBFWSI_ERROR_DOMAIN_IO = (int) 'I', 39 LIBFWSI_ERROR_DOMAIN_INPUT = (int) 'i', 40 LIBFWSI_ERROR_DOMAIN_MEMORY = (int) 'm', 41 LIBFWSI_ERROR_DOMAIN_OUTPUT = (int) 'o', 42 LIBFWSI_ERROR_DOMAIN_RUNTIME = (int) 'r' 43 }; 44 45 /* The argument error codes 46 * to signify errors regarding arguments passed to a function 47 */ 48 enum LIBFWSI_ARGUMENT_ERROR 49 { 50 LIBFWSI_ARGUMENT_ERROR_GENERIC = 0, 51 52 /* The argument contains an invalid value 53 */ 54 LIBFWSI_ARGUMENT_ERROR_INVALID_VALUE = 1, 55 56 /* The argument contains a value less than zero 57 */ 58 LIBFWSI_ARGUMENT_ERROR_VALUE_LESS_THAN_ZERO = 2, 59 60 /* The argument contains a value zero or less 61 */ 62 LIBFWSI_ARGUMENT_ERROR_VALUE_ZERO_OR_LESS = 3, 63 64 /* The argument contains a value that exceeds the maximum 65 * for the specific type 66 */ 67 LIBFWSI_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM = 4, 68 69 /* The argument contains a value that is too small 70 */ 71 LIBFWSI_ARGUMENT_ERROR_VALUE_TOO_SMALL = 5, 72 73 /* The argument contains a value that is too large 74 */ 75 LIBFWSI_ARGUMENT_ERROR_VALUE_TOO_LARGE = 6, 76 77 /* The argument contains a value that is out of bounds 78 */ 79 LIBFWSI_ARGUMENT_ERROR_VALUE_OUT_OF_BOUNDS = 7, 80 81 /* The argument contains a value that is not supported 82 */ 83 LIBFWSI_ARGUMENT_ERROR_UNSUPPORTED_VALUE = 8, 84 85 /* The argument contains a value that conficts with another argument 86 */ 87 LIBFWSI_ARGUMENT_ERROR_CONFLICTING_VALUE = 9 88 }; 89 90 /* The conversion error codes 91 * to signify errors regarding conversions 92 */ 93 enum LIBFWSI_CONVERSION_ERROR 94 { 95 LIBFWSI_CONVERSION_ERROR_GENERIC = 0, 96 97 /* The conversion failed on the input 98 */ 99 LIBFWSI_CONVERSION_ERROR_INPUT_FAILED = 1, 100 101 /* The conversion failed on the output 102 */ 103 LIBFWSI_CONVERSION_ERROR_OUTPUT_FAILED = 2 104 }; 105 106 /* The compression error codes 107 * to signify errors regarding compression 108 */ 109 enum LIBFWSI_COMPRESSION_ERROR 110 { 111 LIBFWSI_COMPRESSION_ERROR_GENERIC = 0, 112 113 /* The compression failed 114 */ 115 LIBFWSI_COMPRESSION_ERROR_COMPRESS_FAILED = 1, 116 117 /* The decompression failed 118 */ 119 LIBFWSI_COMPRESSION_ERROR_DECOMPRESS_FAILED = 2 120 }; 121 122 /* The input/output error codes 123 * to signify errors regarding input/output 124 */ 125 enum LIBFWSI_IO_ERROR 126 { 127 LIBFWSI_IO_ERROR_GENERIC = 0, 128 129 /* The open failed 130 */ 131 LIBFWSI_IO_ERROR_OPEN_FAILED = 1, 132 133 /* The close failed 134 */ 135 LIBFWSI_IO_ERROR_CLOSE_FAILED = 2, 136 137 /* The seek failed 138 */ 139 LIBFWSI_IO_ERROR_SEEK_FAILED = 3, 140 141 /* The read failed 142 */ 143 LIBFWSI_IO_ERROR_READ_FAILED = 4, 144 145 /* The write failed 146 */ 147 LIBFWSI_IO_ERROR_WRITE_FAILED = 5, 148 149 /* Access denied 150 */ 151 LIBFWSI_IO_ERROR_ACCESS_DENIED = 6, 152 153 /* The resource is invalid i.e. a missing file 154 */ 155 LIBFWSI_IO_ERROR_INVALID_RESOURCE = 7, 156 157 /* The ioctl failed 158 */ 159 LIBFWSI_IO_ERROR_IOCTL_FAILED = 8, 160 161 /* The unlink failed 162 */ 163 LIBFWSI_IO_ERROR_UNLINK_FAILED = 9 164 }; 165 166 /* The input error codes 167 * to signify errors regarding handing input data 168 */ 169 enum LIBFWSI_INPUT_ERROR 170 { 171 LIBFWSI_INPUT_ERROR_GENERIC = 0, 172 173 /* The input contains invalid data 174 */ 175 LIBFWSI_INPUT_ERROR_INVALID_DATA = 1, 176 177 /* The input contains an unsupported signature 178 */ 179 LIBFWSI_INPUT_ERROR_SIGNATURE_MISMATCH = 2, 180 181 /* A checksum in the input did not match 182 */ 183 LIBFWSI_INPUT_ERROR_CHECKSUM_MISMATCH = 3, 184 185 /* A value in the input did not match a previously 186 * read value or calculated value 187 */ 188 LIBFWSI_INPUT_ERROR_VALUE_MISMATCH = 4 189 }; 190 191 /* The memory error codes 192 * to signify errors regarding memory 193 */ 194 enum LIBFWSI_MEMORY_ERROR 195 { 196 LIBFWSI_MEMORY_ERROR_GENERIC = 0, 197 198 /* There is insufficient memory available 199 */ 200 LIBFWSI_MEMORY_ERROR_INSUFFICIENT = 1, 201 202 /* The memory failed to be copied 203 */ 204 LIBFWSI_MEMORY_ERROR_COPY_FAILED = 2, 205 206 /* The memory failed to be set 207 */ 208 LIBFWSI_MEMORY_ERROR_SET_FAILED = 3 209 }; 210 211 /* The output error codes 212 */ 213 enum LIBFWSI_OUTPUT_ERROR 214 { 215 LIBFWSI_OUTPUT_ERROR_GENERIC = 0, 216 217 /* There is insuficient space to write the output 218 */ 219 LIBFWSI_OUTPUT_ERROR_INSUFFICIENT_SPACE = 1 220 }; 221 222 /* The runtime error codes 223 * to signify errors regarding runtime processing 224 */ 225 enum LIBFWSI_RUNTIME_ERROR 226 { 227 LIBFWSI_RUNTIME_ERROR_GENERIC = 0, 228 229 /* The value is missing 230 */ 231 LIBFWSI_RUNTIME_ERROR_VALUE_MISSING = 1, 232 233 /* The value was already set 234 */ 235 LIBFWSI_RUNTIME_ERROR_VALUE_ALREADY_SET = 2, 236 237 /* The creation and/or initialization of an internal structure failed 238 */ 239 LIBFWSI_RUNTIME_ERROR_INITIALIZE_FAILED = 3, 240 241 /* The resize of an internal structure failed 242 */ 243 LIBFWSI_RUNTIME_ERROR_RESIZE_FAILED = 4, 244 245 /* The free and/or finalization of an internal structure failed 246 */ 247 LIBFWSI_RUNTIME_ERROR_FINALIZE_FAILED = 5, 248 249 /* The value could not be determined 250 */ 251 LIBFWSI_RUNTIME_ERROR_GET_FAILED = 6, 252 253 /* The value could not be set 254 */ 255 LIBFWSI_RUNTIME_ERROR_SET_FAILED = 7, 256 257 /* The value could not be appended/prepended 258 */ 259 LIBFWSI_RUNTIME_ERROR_APPEND_FAILED = 8, 260 261 /* The value could not be copied 262 */ 263 LIBFWSI_RUNTIME_ERROR_COPY_FAILED = 9, 264 265 /* The value could not be removed 266 */ 267 LIBFWSI_RUNTIME_ERROR_REMOVE_FAILED = 10, 268 269 /* The value could not be printed 270 */ 271 LIBFWSI_RUNTIME_ERROR_PRINT_FAILED = 11, 272 273 /* The value was out of bounds 274 */ 275 LIBFWSI_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS = 12, 276 277 /* The value exceeds the maximum for its specific type 278 */ 279 LIBFWSI_RUNTIME_ERROR_VALUE_EXCEEDS_MAXIMUM = 13, 280 281 /* The value is unsupported 282 */ 283 LIBFWSI_RUNTIME_ERROR_UNSUPPORTED_VALUE = 14, 284 285 /* An abort was requested 286 */ 287 LIBFWSI_RUNTIME_ERROR_ABORT_REQUESTED = 15 288 }; 289 290 #endif /* !defined( _LIBFWSI_ERROR_H ) */ 291 292