|
Packit |
d7e8d0 |
/* error.c - Error handling for GPGME.
|
|
Packit Service |
30b792 |
* Copyright (C) 2003, 2004 g10 Code GmbH
|
|
Packit Service |
30b792 |
*
|
|
Packit Service |
30b792 |
* This file is part of GPGME.
|
|
Packit Service |
30b792 |
*
|
|
Packit Service |
30b792 |
* GPGME is free software; you can redistribute it and/or modify it
|
|
Packit Service |
30b792 |
* under the terms of the GNU Lesser General Public License as
|
|
Packit Service |
30b792 |
* published by the Free Software Foundation; either version 2.1 of
|
|
Packit Service |
30b792 |
* the License, or (at your option) any later version.
|
|
Packit Service |
30b792 |
*
|
|
Packit Service |
30b792 |
* GPGME is distributed in the hope that it will be useful, but
|
|
Packit Service |
30b792 |
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
30b792 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
30b792 |
* Lesser General Public License for more details.
|
|
Packit Service |
30b792 |
*
|
|
Packit Service |
30b792 |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
30b792 |
* License along with this program; if not, see <https://gnu.org/licenses/>.
|
|
Packit Service |
30b792 |
* SPDX-License-Identifier: LGPL-2.1-or-later
|
|
Packit Service |
30b792 |
*/
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
#if HAVE_CONFIG_H
|
|
Packit |
d7e8d0 |
#include <config.h>
|
|
Packit |
d7e8d0 |
#endif
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
#include <gpgme.h>
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
/* Return a pointer to a string containing a description of the error
|
|
Packit |
d7e8d0 |
code in the error value ERR. */
|
|
Packit |
d7e8d0 |
const char *
|
|
Packit |
d7e8d0 |
gpgme_strerror (gpgme_error_t err)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
return gpg_strerror (err);
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
/* Return the error string for ERR in the user-supplied buffer BUF of
|
|
Packit |
d7e8d0 |
size BUFLEN. This function is, in contrast to gpg_strerror,
|
|
Packit |
d7e8d0 |
thread-safe if a thread-safe strerror_r() function is provided by
|
|
Packit |
d7e8d0 |
the system. If the function succeeds, 0 is returned and BUF
|
|
Packit |
d7e8d0 |
contains the string describing the error. If the buffer was not
|
|
Packit |
d7e8d0 |
large enough, ERANGE is returned and BUF contains as much of the
|
|
Packit |
d7e8d0 |
beginning of the error string as fits into the buffer. */
|
|
Packit |
d7e8d0 |
int
|
|
Packit |
d7e8d0 |
gpgme_strerror_r (gpg_error_t err, char *buf, size_t buflen)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
return gpg_strerror_r (err, buf, buflen);
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
/* Return a pointer to a string containing a description of the error
|
|
Packit |
d7e8d0 |
source in the error value ERR. */
|
|
Packit |
d7e8d0 |
const char *
|
|
Packit |
d7e8d0 |
gpgme_strsource (gpgme_error_t err)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
return gpg_strsource (err);
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
/* Retrieve the error code for the system error ERR. This returns
|
|
Packit |
d7e8d0 |
GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped (report
|
|
Packit |
d7e8d0 |
this). */
|
|
Packit |
d7e8d0 |
gpgme_err_code_t
|
|
Packit |
d7e8d0 |
gpgme_err_code_from_errno (int err)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
return gpg_err_code_from_errno (err);
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
/* Retrieve the system error for the error code CODE. This returns 0
|
|
Packit |
d7e8d0 |
if CODE is not a system error code. */
|
|
Packit |
d7e8d0 |
int
|
|
Packit |
d7e8d0 |
gpgme_err_code_to_errno (gpgme_err_code_t code)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
return gpg_err_code_to_errno (code);
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
/* Retrieve the error code directly from the ERRNO variable. This
|
|
Packit |
d7e8d0 |
returns GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped
|
|
Packit |
d7e8d0 |
(report this) and GPG_ERR_MISSING_ERRNO if ERRNO has the value 0. */
|
|
Packit |
d7e8d0 |
gpgme_err_code_t
|
|
Packit |
d7e8d0 |
gpgme_err_code_from_syserror (void)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
return gpg_err_code_from_syserror ();
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
/* Set the ERRNO variable. This function is the preferred way to set
|
|
Packit |
d7e8d0 |
ERRNO due to peculiarities on WindowsCE. */
|
|
Packit |
d7e8d0 |
void
|
|
Packit |
d7e8d0 |
gpgme_err_set_errno (int err)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
gpg_err_set_errno (err);
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
/* Return an error value with the error source SOURCE and the system
|
|
Packit |
d7e8d0 |
error ERR. */
|
|
Packit |
d7e8d0 |
gpgme_error_t
|
|
Packit |
d7e8d0 |
gpgme_err_make_from_errno (gpg_err_source_t source, int err)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
return gpg_err_make_from_errno (source, err);
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
/* Return an error value with the system error ERR. */
|
|
Packit |
d7e8d0 |
gpgme_error_t
|
|
Packit |
d7e8d0 |
gpgme_error_from_errno (int err)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
return gpgme_error (gpg_err_code_from_errno (err));
|
|
Packit |
d7e8d0 |
}
|