diff options
author | Marcus Brinkmann <[email protected]> | 2003-06-01 21:11:40 +0000 |
---|---|---|
committer | Marcus Brinkmann <[email protected]> | 2003-06-01 21:11:40 +0000 |
commit | 85fee89a19a7e9657f9d76949bcdbf4b6c42d182 (patch) | |
tree | cd16f5ebef862ca1516f8baf6b359f602d0a0a39 /src/code-from-errno.c | |
parent | 2003-06-01 Marcus Brinkmann <[email protected]> (diff) | |
download | libgpg-error-85fee89a19a7e9657f9d76949bcdbf4b6c42d182.tar.gz libgpg-error-85fee89a19a7e9657f9d76949bcdbf4b6c42d182.zip |
2003-06-01 Marcus Brinkmann <[email protected]>
* src/mkerrcodes1.awk: New file.
* src/mkerrcodes2.awk: New file.
* src/mkerrnos.awk: New file.
* src/errnos.in: New file.
* src/code-from-errno.c: New file.
* src/code-to-errno.c: New file.
* src/Makefile.am (libgpg_error_la_SOURCES): Remove err-sources.h
and err-codes.h. Add code-to-errno.c and code-from-errno.c.
(code-to-errno.h): New target.
(code-from-errno.h): Likewise.
(EXTRA_DIST): Add mkerrnos.awk, errnos.in, and mkerrcodes1.awk.
(BUILT_SOURCES): Add code-to-errno.h and code-from-errno.h.
(CLEANFILES): Likewise.
* src/strerror.c (gpg_strerror): Use strerror for system errors.
* src/err-codes.h.in: Add 16382 (Unknown system error).
* src/gpg-error.h (gpg_err_code_t): Add system errors.
(GPG_ERR_CODE_DIM): Change to 32768.
(GPG_ERR_SYSTEM_ERROR): New macro.
(gpg_err_code_from_errno): New prototype.
(gpg_err_code_to_errno): Likewise.
Diffstat (limited to 'src/code-from-errno.c')
-rw-r--r-- | src/code-from-errno.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/code-from-errno.c b/src/code-from-errno.c new file mode 100644 index 0000000..5312389 --- /dev/null +++ b/src/code-from-errno.c @@ -0,0 +1,41 @@ +/* code-from-errno.c - Mapping errnos to error codes. + Copyright (C) 2003 g10 Code GmbH + + This file is part of libgpg-error. + + libgpg-error 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 2.1 of + the License, or (at your option) any later version. + + libgpg-error 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 libgpgme-error; if not, write to the Free + Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. */ + +#if HAVE_CONFIG_H +#include <config.h> +#endif + +#include <gpg-error.h> + +#include "code-from-errno.h" + +/* Retrieve the error code for the system error ERR. This returns + GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped (report + this). */ +gpg_err_code_t +gpg_err_code_from_errno (int err) +{ + int idx = errno_to_idx (err); + + if (idx < 0) + return GPG_ERR_UNKNOWN_ERRNO; + + return GPG_ERR_SYSTEM_ERROR | err_code_from_index[idx]; +} |