Blame src/error.c

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