119 lines
4.3 KiB
C
119 lines
4.3 KiB
C
/* ****************************************************************************
|
|
* errors.c -- error strings.
|
|
* Copyright (C) 2017 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
|
|
*
|
|
* This file is part of libcasio.
|
|
* libcasio is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU Lesser General Public License as published by
|
|
* the Free Software Foundation; either version 3.0 of the License,
|
|
* or (at your option) any later version.
|
|
*
|
|
* libcasio is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
* See the GNU Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
* along with libcasio; if not, see <http://www.gnu.org/licenses/>.
|
|
* ************************************************************************* */
|
|
#define LIBCASIO_NO_STRERROR
|
|
#include "internals.h"
|
|
|
|
#define ARR_SIZE 0x74
|
|
#define UNKNOWN NULL, NULL
|
|
|
|
const char* CASIO_EXPORT casio_error_strings[128] = {
|
|
/* Miscallaneous errors. */
|
|
|
|
"casio_error_none", "no error has occured",
|
|
"casio_error_unknown", "an unknown error has occured",
|
|
"casio_error_alloc", "a memory allocation has failed",
|
|
"casio_error_op", "this operation is unsupported",
|
|
"casio_error_arg", "an argument was invalid",
|
|
"casio_error_lock", "mutex is locked",
|
|
"casio_error_iter", "no more elements in the iterator",
|
|
|
|
UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN,
|
|
UNKNOWN, UNKNOWN, UNKNOWN,
|
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
/* Stream errors. */
|
|
|
|
"casio_error_stream", "the stream is invalid/no (more) stream",
|
|
"casio_error_read", "a read operation on the stream has failed",
|
|
"casio_error_write", "a write operation on the stream has failed",
|
|
"casio_error_seek", "a seek operation on the stream has failed",
|
|
"casio_error_timeout", "a timeout has occurred",
|
|
"casio_error_access", "could not get access to the device",
|
|
"casio_error_eof", "an end of file event has occured",
|
|
"casio_error_scsi", "a SCSI operation on the stream has failed",
|
|
"casio_error_usb", "a USB operation on the stream has failed",
|
|
|
|
UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN,
|
|
UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN,
|
|
UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN,
|
|
UNKNOWN, UNKNOWN,
|
|
|
|
/* Link errors. */
|
|
|
|
"casio_error_init", "the link was uninitialized",
|
|
"casio_error_shift", "illegal double shifting",
|
|
"casio_error_damned", "irrecoverable link error",
|
|
"casio_error_int", "interrupted by user",
|
|
"casio_error_active", "not in active/passive mode",
|
|
"casio_error_noow", "denied overwrite",
|
|
"casio_error_command", "unsupported command",
|
|
|
|
UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN,
|
|
UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN,
|
|
UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN,
|
|
UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN,
|
|
|
|
/* Filesystem errors. */
|
|
|
|
"casio_error_device", "unsupported storage device",
|
|
"casio_error_fullmem", "full memory",
|
|
"casio_error_notfound", "file not found",
|
|
"casio_error_empty", "empty files aren't allowed",
|
|
|
|
UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN,
|
|
UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN,
|
|
UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN,
|
|
UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN,
|
|
|
|
/* Decoding errors. */
|
|
|
|
"casio_error_magic", "corrupted or unknown file format",
|
|
"casio_error_csum", "invalid checksum",
|
|
"casio_error_wrong", "not one of the allowed file types",
|
|
"casio_error_seq", "sequence error",
|
|
"casio_error_noeq", "character does not translate"
|
|
};
|
|
|
|
/* ---
|
|
* Public functions.
|
|
* --- */
|
|
|
|
/* `casio_error_name()`: get the error name. */
|
|
|
|
CASIO_EXTERN(char const *) casio_error_name(int code)
|
|
{
|
|
char const *nm;
|
|
|
|
if (code >= ARR_SIZE || !(nm = errors[code + code]))
|
|
return ("(unknown libcasio error)");
|
|
return (nm);
|
|
}
|
|
|
|
/* `casio_error_desc()`: get the error description. */
|
|
|
|
CASIO_EXTERN(char const *) casio_error_desc(int code)
|
|
{
|
|
char const *ds;
|
|
|
|
if (code >= ARR_SIZE || !(ds = errors[code + code + 1]))
|
|
return ("(unknown libcasio error)");
|
|
return (ds);
|
|
}
|