1 /* error.c - Error handling for GPGME.
2 Copyright (C) 2003, 2004 g10 Code GmbH
4 This file is part of GPGME.
6 GPGME is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of
9 the License, or (at your option) any later version.
11 GPGME is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 /* Return a pointer to a string containing a description of the error
28 code in the error value ERR. */
30 gpgme_strerror (gpgme_error_t err)
32 return gpg_strerror (err);
36 /* Return the error string for ERR in the user-supplied buffer BUF of
37 size BUFLEN. This function is, in contrast to gpg_strerror,
38 thread-safe if a thread-safe strerror_r() function is provided by
39 the system. If the function succeeds, 0 is returned and BUF
40 contains the string describing the error. If the buffer was not
41 large enough, ERANGE is returned and BUF contains as much of the
42 beginning of the error string as fits into the buffer. */
44 gpgme_strerror_r (gpg_error_t err, char *buf, size_t buflen)
46 return gpg_strerror_r (err, buf, buflen);
50 /* Return a pointer to a string containing a description of the error
51 source in the error value ERR. */
53 gpgme_strsource (gpgme_error_t err)
55 return gpg_strsource (err);
59 /* Retrieve the error code for the system error ERR. This returns
60 GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped (report
63 gpgme_err_code_from_errno (int err)
65 return gpg_err_code_from_errno (err);
69 /* Retrieve the system error for the error code CODE. This returns 0
70 if CODE is not a system error code. */
72 gpgme_err_code_to_errno (gpgme_err_code_t code)
74 return gpg_err_code_to_errno (code);
78 /* Retrieve the error code directly from the ERRNO variable. This
79 returns GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped
80 (report this) and GPG_ERR_MISSING_ERRNO if ERRNO has the value 0. */
82 gpgme_err_code_from_syserror (void)
84 return gpg_err_code_from_syserror ();
88 /* Set the ERRNO variable. This function is the preferred way to set
89 ERRNO due to peculiarities on WindowsCE. */
91 gpgme_err_set_errno (int err)
93 gpg_err_set_errno (err);
97 /* Return an error value with the error source SOURCE and the system
100 gpgme_err_make_from_errno (gpg_err_source_t source, int err)
102 return gpg_err_make_from_errno (source, err);
106 /* Return an error value with the system error ERR. */
108 gpgme_error_from_errno (int err)
110 return gpgme_error (gpg_err_code_from_errno (err));