Line data Source code
1 : /* error.c - Error handling for GPGME.
2 : Copyright (C) 2003, 2004 g10 Code GmbH
3 :
4 : This file is part of GPGME.
5 :
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.
10 :
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.
15 :
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
19 : 02111-1307, USA. */
20 :
21 : #if HAVE_CONFIG_H
22 : #include <config.h>
23 : #endif
24 :
25 : #include <gpgme.h>
26 :
27 : /* Return a pointer to a string containing a description of the error
28 : code in the error value ERR. */
29 : const char *
30 394 : gpgme_strerror (gpgme_error_t err)
31 : {
32 394 : return gpg_strerror (err);
33 : }
34 :
35 :
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. */
43 : int
44 25 : gpgme_strerror_r (gpg_error_t err, char *buf, size_t buflen)
45 : {
46 25 : return gpg_strerror_r (err, buf, buflen);
47 : }
48 :
49 :
50 : /* Return a pointer to a string containing a description of the error
51 : source in the error value ERR. */
52 : const char *
53 375 : gpgme_strsource (gpgme_error_t err)
54 : {
55 375 : return gpg_strsource (err);
56 : }
57 :
58 :
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
61 : this). */
62 : gpgme_err_code_t
63 0 : gpgme_err_code_from_errno (int err)
64 : {
65 0 : return gpg_err_code_from_errno (err);
66 : }
67 :
68 :
69 : /* Retrieve the system error for the error code CODE. This returns 0
70 : if CODE is not a system error code. */
71 : int
72 0 : gpgme_err_code_to_errno (gpgme_err_code_t code)
73 : {
74 0 : return gpg_err_code_to_errno (code);
75 : }
76 :
77 :
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. */
81 : gpgme_err_code_t
82 0 : gpgme_err_code_from_syserror (void)
83 : {
84 0 : return gpg_err_code_from_syserror ();
85 : }
86 :
87 :
88 : /* Set the ERRNO variable. This function is the preferred way to set
89 : ERRNO due to peculiarities on WindowsCE. */
90 : void
91 14 : gpgme_err_set_errno (int err)
92 : {
93 14 : gpg_err_set_errno (err);
94 14 : }
95 :
96 :
97 : /* Return an error value with the error source SOURCE and the system
98 : error ERR. */
99 : gpgme_error_t
100 0 : gpgme_err_make_from_errno (gpg_err_source_t source, int err)
101 : {
102 0 : return gpg_err_make_from_errno (source, err);
103 : }
104 :
105 :
106 : /* Return an error value with the system error ERR. */
107 : gpgme_error_t
108 0 : gpgme_error_from_errno (int err)
109 : {
110 0 : return gpgme_error (gpg_err_code_from_errno (err));
111 : }
|