aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcus Brinkmann <[email protected]>2004-02-27 04:20:26 +0000
committerMarcus Brinkmann <[email protected]>2004-02-27 04:20:26 +0000
commitac0ec715597a9240871c6c7251f0927be042cb98 (patch)
tree0b772634b212db3a56c8aef7c888167bc36d1a2f
parentAdded GPG_ERR_NOT_LOCKED. (diff)
downloadlibgpg-error-ac0ec715597a9240871c6c7251f0927be042cb98.tar.gz
libgpg-error-ac0ec715597a9240871c6c7251f0927be042cb98.zip
2004-02-27 Marcus Brinkmann <[email protected]>
* src/Makefile.am (noinst_PROGRAMS): New variable. (gpg_error_LDADD): New variable. (gpg_error_SOURCES): New variable. (EXTRA_DIST): Add mkheader.awk and gpg-error.h.in. (BUILT_SOURCES): Add err-sources-sym.h, err-codes-sym.h and errnos-sym.h. (CLEANFILES): Add err-sources-sym.h, err-codes-sym.h, errnos-sym.h and gpg-error.h. (err-codes.h, err-sources.h): Add -v textidx=3 to mkstrtable.awk invocation. (err-codes-sym.h): New target. (err-sources-sym.h): New target. (gpg-error.h): New rule. * src/mkstrtable.awk: Skip the second field (which contains the error code symbol). (FS): Allow more than one tab as field separator. Allow to specify the field to be used as text with the variable textidx. Allow to suppress gettext markers in the output. Allow to specify a prefix to the messages. Allow to specify a namespace for the variable and macro names. * src/mkerrnos.awk (FS): Initialize. Understand variable errnoidx, which defaults to 2, to cope with the error names being in a different column than the first. * src/mkerrcodes1.awk: Likewise. Use \t as separator. * src/mkheader.awk: New file. * src/errnos.in: Add error code numbers (relativ to GPG_ERR_SYSTEM_ERROR). * src/strerror-sym.c: New file. * src/strsources-sym.c: New file. * src/err-codes.h.in: Add the error code symbol for every error code. (GPG_ERR_BUFFER_TOO_SHORT): Fix error code (it is 200, not 199). * src/err-sources.h.in: Likewise. * src/gpg-error.h.in: New file. * src/gpg-error.h: File removed. * src/gpg-error.c: New file.
-rw-r--r--ChangeLog40
-rw-r--r--NEWS3
-rw-r--r--src/Makefile.am41
-rw-r--r--src/err-codes.h.in430
-rw-r--r--src/err-sources.h.in54
-rw-r--r--src/errnos.in298
-rw-r--r--src/gpg-error.c260
-rw-r--r--src/gpg-error.h582
-rw-r--r--src/gpg-error.h.in200
-rw-r--r--src/mkerrcodes1.awk17
-rw-r--r--src/mkerrnos.awk17
-rw-r--r--src/mkheader.awk190
-rw-r--r--src/mkstrtable.awk47
-rw-r--r--src/strerror-sym.c56
-rw-r--r--src/strsource-sym.c43
15 files changed, 1291 insertions, 987 deletions
diff --git a/ChangeLog b/ChangeLog
index 6e26a9f..364a19b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,43 @@
+2004-02-27 Marcus Brinkmann <[email protected]>
+
+ * src/Makefile.am (noinst_PROGRAMS): New variable.
+ (gpg_error_LDADD): New variable.
+ (gpg_error_SOURCES): New variable.
+ (EXTRA_DIST): Add mkheader.awk and gpg-error.h.in.
+ (BUILT_SOURCES): Add err-sources-sym.h, err-codes-sym.h and
+ errnos-sym.h.
+ (CLEANFILES): Add err-sources-sym.h, err-codes-sym.h,
+ errnos-sym.h and gpg-error.h.
+ (err-codes.h, err-sources.h): Add -v textidx=3 to mkstrtable.awk
+ invocation.
+ (err-codes-sym.h): New target.
+ (err-sources-sym.h): New target.
+ (gpg-error.h): New rule.
+ * src/mkstrtable.awk: Skip the second field (which contains the
+ error code symbol).
+ (FS): Allow more than one tab as field separator.
+ Allow to specify the field to be used as text with the variable
+ textidx.
+ Allow to suppress gettext markers in the output.
+ Allow to specify a prefix to the messages.
+ Allow to specify a namespace for the variable and macro names.
+ * src/mkerrnos.awk (FS): Initialize. Understand variable
+ errnoidx, which defaults to 2, to cope with the error names being
+ in a different column than the first.
+ * src/mkerrcodes1.awk: Likewise. Use \t as separator.
+ * src/mkheader.awk: New file.
+ * src/errnos.in: Add error code numbers (relativ to
+ GPG_ERR_SYSTEM_ERROR).
+ * src/strerror-sym.c: New file.
+ * src/strsources-sym.c: New file.
+ * src/err-codes.h.in: Add the error code symbol for every error
+ code.
+ (GPG_ERR_BUFFER_TOO_SHORT): Fix error code (it is 200, not 199).
+ * src/err-sources.h.in: Likewise.
+ * src/gpg-error.h.in: New file.
+ * src/gpg-error.h: File removed.
+ * src/gpg-error.c: New file.
+
2004-02-03 Werner Koch <[email protected]>
* src/gpg-error.h: Added GPG_ERR_NOT_LOCKED.
diff --git a/NEWS b/NEWS
index 8215fe0..c4e3b03 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,9 @@
Noteworthy changes in version 0.7 (unreleased)
----------------------------------------------
+ * A new tool gpg-error to convert error numbers into symbols into
+ strings is provided. It is not installed by default, but can be
+ found in src/gpg-error.
* Interface changes relative to the 0.6 release:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/src/Makefile.am b/src/Makefile.am
index 8a8a56d..122a927 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,5 +1,5 @@
# Makefile.am for libgpg-error.
-# Copyright (C) 2003 g10 Code GmbH
+# Copyright (C) 2003, 2004 g10 Code GmbH
#
# This file is part of libgpg-error.
#
@@ -22,9 +22,13 @@
# depend on the configuration anyway.
EXTRA_DIST = mkstrtable.awk err-sources.h.in err-codes.h.in \
mkerrnos.awk errnos.in mkerrcodes1.awk mkerrcodes2.awk \
+ mkheader.awk gpg-error.h.in \
err-sources.h err-codes.h gpg-error-config.in gpg-error.m4
-BUILT_SOURCES = err-sources.h err-codes.h code-to-errno.h code-from-errno.h
-CLEANFILES = err-sources.h err-codes.h code-to-errno.h code-from-errno.h
+BUILT_SOURCES = err-sources.h err-codes.h code-to-errno.h code-from-errno.h \
+ err-sources-sym.h err-codes-sym.h errnos-sym.h
+CLEANFILES = err-sources.h err-codes.h code-to-errno.h code-from-errno.h \
+ gpg-error.h \
+ err-sources-sym.h err-codes-sym.h errnos-sym.h
bin_SCRIPTS = gpg-error-config
m4datadir = $(datadir)/aclocal
@@ -42,11 +46,25 @@ libgpg_error_la_SOURCES = gpg-error.h gettext.h \
libgpg_error_la_LIBADD = @LTLIBINTL@
+noinst_PROGRAMS = gpg-error
+gpg_error_SOURCES = strsource-sym.c strerror-sym.c gpg-error.c
+gpg_error_LDADD = ./libgpg-error.la
+
err-sources.h: Makefile mkstrtable.awk err-sources.h.in
- $(AWK) -f $(srcdir)/mkstrtable.awk $(srcdir)/err-sources.h.in >$@
+ $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=3 \
+ $(srcdir)/err-sources.h.in >$@
+
+err-sources-sym.h: Makefile mkstrtable.awk err-sources.h.in
+ $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=2 -v nogettext=1 \
+ $(srcdir)/err-sources.h.in >$@
err-codes.h: Makefile mkstrtable.awk err-codes.h.in
- $(AWK) -f $(srcdir)/mkstrtable.awk $(srcdir)/err-codes.h.in >$@
+ $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=3 \
+ $(srcdir)/err-codes.h.in >$@
+
+err-codes-sym.h: Makefile mkstrtable.awk err-codes.h.in
+ $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=2 -v nogettext=1 \
+ $(srcdir)/err-codes.h.in >$@
code-to-errno.h: Makefile mkerrnos.awk errnos.in
$(AWK) -f $(srcdir)/mkerrnos.awk $(srcdir)/errnos.in >$@
@@ -55,3 +73,16 @@ code-from-errno.h: Makefile mkerrcodes1.awk errnos.in
$(AWK) -f $(srcdir)/mkerrcodes1.awk $(srcdir)/errnos.in \
| $(CPP) - | grep GPG_ERR_ | sort -n \
| $(AWK) -f $(srcdir)/mkerrcodes2.awk >$@
+
+errnos-sym.h: Makefile mkstrtable.awk errnos.in
+ $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=2 -v nogettext=1 \
+ -v prefix=GPG_ERR_ -v namespace=errnos_ \
+ $(srcdir)/errnos.in >$@
+
+gpg-error.h: Makefile mkheader.awk \
+ err-sources.h.in err-codes.h.in errnos.in gpg-error.h.in
+ $(AWK) -f $(srcdir)/mkheader.awk \
+ $(srcdir)/err-sources.h.in \
+ $(srcdir)/err-codes.h.in \
+ $(srcdir)/errnos.in \
+ $(srcdir)/gpg-error.h.in > $@
diff --git a/src/err-codes.h.in b/src/err-codes.h.in
index 0e28f55..b70faea 100644
--- a/src/err-codes.h.in
+++ b/src/err-codes.h.in
@@ -1,6 +1,6 @@
# err-codes.h.in - List of error codes and their description input file.
/* err-codes.h - List of error codes and their description.
- Copyright (C) 2003 g10 Code GmbH
+ Copyright (C) 2003, 2004 g10 Code GmbH
This file is part of libgpg-error.
@@ -22,209 +22,229 @@
# Everything up to the first line that starts with a number in the
# first column is copied into the output verbatim. Then, empty lines
# are ignored. Other lines must have an error code number, followed
-# by exactly one <tab>, followed by the error message. Trailing
-# whitespace is removed. The error codes should be sorted. The last
-# line should not have a number, but only a <tab>, followed by a
+# by one or more <tab> characters, followed by the error code symbol,
+# followed by one or more <tab> characters, followed by the error
+# message. Trailing whitespace is removed. The error codes should be
+# sorted. The last line should not have a number, but only a <tab>,
+# followed by a dummy field, followed by a <tab>, followed by a
# description for error codes that are not in the list.
-0 Success
-1 General error
-2 Unknown packet
-3 Unknown version in packet
-4 Invalid public key algorithm
-5 Invalid digest algorithm
-6 Bad public key
-7 Bad secret key
-8 Bad signature
-9 No public key
-10 Checksum error
-11 Bad passphrase
-12 Invalid cipher algorithm
-13 Keyring open
-14 Invalid packet
-15 Invalid armor
-16 No user ID
-17 No secret key
-18 Wrong secret key used
-19 Bad session key
-20 Unknown compression algorithm
-21 Number is not prime
-22 Invalid encoding method
-23 Invalid encryption scheme
-24 Invalid signature scheme
-25 Invalid attribute
-26 No value
-27 Not found
-28 Value not found
-29 Syntax error
-30 Bad MPI value
-31 Invalid passphrase
-32 Invalid signature class
-33 Resources exhausted
-34 Invalid keyring
-35 Trust DB error
-36 Bad certificate
-37 Invalid user ID
-38 Unexpected error
-39 Time conflict
-40 Keyserver error
-41 Wrong public key algorithm
-42 Tribute to D. A.
-43 Weak encryption key
-44 Invalid key length
-45 Invalid argument
-46 Syntax error in URI
-47 Invalid URI
-48 Network error
-49 Unknown host
-50 Selftest failed
-51 Data not encrypted
-52 Data not processed
-53 Unusable public key
-54 Unusable secret key
-55 Invalid value
-56 Bad certificate chain
-57 Missing certificate
-58 No data
-59 Bug
-60 Not supported
-61 Invalid operation code
-62 Timeout
-63 Internal error
-64 EOF (gcrypt)
-65 Invalid object
-66 Provided object is too short
-67 Provided object is too large
-68 Missing item in object
-69 Not implemented
-70 Conflicting use
-71 Invalid cipher mode
-72 Invalid flag
-73 Invalid handle
-74 Result truncated
-75 Incomplete line
-76 Invalid response
-77 No agent running
-78 agent error
-79 Invalid data
-80 Assuan server fault
-81 Assuan error
-82 Invalid session key
-83 Invalid S-expression
-84 Unsupported algorithm
-85 No pinentry
-86 pinentry error
-87 Bad PIN
-88 Invalid name
-89 Bad data
-90 Invalid parameter
-91 Wrong card
-92 No dirmngr
-93 dirmngr error
-94 Certificate revoked
-95 No CRL known
-96 CRL too old
-97 Line too long
-98 Not trusted
-99 Operation cancelled
-100 Bad CA certificate
-101 Certificate expired
-102 Certificate too young
-103 Unsupported certificate
-104 Unknown S-expression
-105 Unsupported protection
-106 Corrupted protection
-107 Ambiguous name
-108 Card error
-109 Card reset
-110 Card removed
-111 Invalid card
-112 Card not present
-113 No PKCS15 application
-114 Not confirmed
-115 Configuration error
-116 No policy match
-117 Invalid index
-118 Invalid ID
-119 No SmartCard daemon
-120 SmartCard daemon error
-121 Unsupported protocol
-122 Bad PIN method
-123 Card not initialized
-124 Unsupported operation
-125 Wrong key usage
-126 Nothing found
-127 Wrong blob type
-128 Missing value
-129 Hardware problem
-130 PIN blocked
-131 Conditions of use not satisfied
-132 PINs are not synced
-133 Invalid CRL
-134 BER error
-135 Invalid BER
-136 Element not found
-137 Identifier not found
-138 Invalid tag
-139 Invalid length
-140 Invalid key info
-141 Unexpected tag
-142 Not DER encoded
-143 No CMS object
-144 Invalid CMS object
-145 Unknown CMS object
-146 Unsupported CMS object
-147 Unsupported encoding
-148 Unsupported CMS version
-149 Unknown algorithm
-150 Invalid crypto engine
-151 Public key not trusted
-152 Decryption failed
-153 Key expired
-154 Signature expired
-155 Encoding problem
-156 Invalid state
-157 Duplicated value
-158 Missing action
-159 ASN.1 module not found
-160 Invalid OID string
-161 Invalid time
-162 Invalid CRL object
-163 Unsupported CRL version
-164 Invalid certificate object
-165 Unknown name
-166 A locale function failed
-167 Not locked
-199 Buffer too short
-201 Invalid length specifier in S-expression
-202 String too long in S-expression
-203 Unmatched parentheses in S-expression
-204 S-expression not canonical
-205 Bad character in S-expression
-206 Bad quotation in S-expression
-207 Zero prefix in S-expression
-208 Nested display hints in S-expression
-209 Unmatched display hints
-210 Unexpected reserved punctuation in S-expression
-211 Bad hexadecimal character in S-expression
-212 Odd hexadecimal numbers in S-expression
-213 Bad octadecimal character in S-expression
-1024 User defined error code 1
-1025 User defined error code 2
-1026 User defined error code 3
-1027 User defined error code 4
-1028 User defined error code 5
-1029 User defined error code 6
-1030 User defined error code 7
-1031 User defined error code 8
-1032 User defined error code 9
-1033 User defined error code 10
-1034 User defined error code 11
-1035 User defined error code 12
-1036 User defined error code 13
-1037 User defined error code 14
-1038 User defined error code 15
-1039 User defined error code 16
-16382 Unknown system error
-16383 End of file
- Unknown error code
+0 GPG_ERR_NO_ERROR Success
+1 GPG_ERR_GENERAL General error
+2 GPG_ERR_UNKNOWN_PACKET Unknown packet
+3 GPG_ERR_UNKNOWN_VERSION Unknown version in packet
+4 GPG_ERR_PUBKEY_ALGO Invalid public key algorithm
+5 GPG_ERR_DIGEST_ALGO Invalid digest algorithm
+6 GPG_ERR_BAD_PUBKEY Bad public key
+7 GPG_ERR_BAD_SECKEY Bad secret key
+8 GPG_ERR_BAD_SIGNATURE Bad signature
+9 GPG_ERR_NO_PUBKEY No public key
+10 GPG_ERR_CHECKSUM Checksum error
+11 GPG_ERR_BAD_PASSPHRASE Bad passphrase
+12 GPG_ERR_CIPHER_ALGO Invalid cipher algorithm
+13 GPG_ERR_KEYRING_OPEN Keyring open
+14 GPG_ERR_INV_PACKET Invalid packet
+15 GPG_ERR_INV_ARMOR Invalid armor
+16 GPG_ERR_NO_USER_ID No user ID
+17 GPG_ERR_NO_SECKEY No secret key
+18 GPG_ERR_WRONG_SECKEY Wrong secret key used
+19 GPG_ERR_BAD_KEY Bad session key
+20 GPG_ERR_COMPR_ALGO Unknown compression algorithm
+21 GPG_ERR_NO_PRIME Number is not prime
+22 GPG_ERR_NO_ENCODING_METHOD Invalid encoding method
+23 GPG_ERR_NO_ENCRYPTION_SCHEME Invalid encryption scheme
+24 GPG_ERR_NO_SIGNATURE_SCHEME Invalid signature scheme
+25 GPG_ERR_INV_ATTR Invalid attribute
+26 GPG_ERR_NO_VALUE No value
+27 GPG_ERR_NOT_FOUND Not found
+28 GPG_ERR_VALUE_NOT_FOUND Value not found
+29 GPG_ERR_SYNTAX Syntax error
+30 GPG_ERR_BAD_MPI Bad MPI value
+31 GPG_ERR_INV_PASSPHRASE Invalid passphrase
+32 GPG_ERR_SIG_CLASS Invalid signature class
+33 GPG_ERR_RESOURCE_LIMIT Resources exhausted
+34 GPG_ERR_INV_KEYRING Invalid keyring
+35 GPG_ERR_TRUSTDB Trust DB error
+36 GPG_ERR_BAD_CERT Bad certificate
+37 GPG_ERR_INV_USER_ID Invalid user ID
+38 GPG_ERR_UNEXPECTED Unexpected error
+39 GPG_ERR_TIME_CONFLICT Time conflict
+40 GPG_ERR_KEYSERVER Keyserver error
+41 GPG_ERR_WRONG_PUBKEY_ALGO Wrong public key algorithm
+42 GPG_ERR_TRIBUTE_TO_D_A Tribute to D. A.
+43 GPG_ERR_WEAK_KEY Weak encryption key
+44 GPG_ERR_INV_KEYLEN Invalid key length
+45 GPG_ERR_INV_ARG Invalid argument
+46 GPG_ERR_BAD_URI Syntax error in URI
+47 GPG_ERR_INV_URI Invalid URI
+48 GPG_ERR_NETWORK Network error
+49 GPG_ERR_UNKNOWN_HOST Unknown host
+50 GPG_ERR_SELFTEST_FAILED Selftest failed
+51 GPG_ERR_NOT_ENCRYPTED Data not encrypted
+52 GPG_ERR_NOT_PROCESSED Data not processed
+53 GPG_ERR_UNUSABLE_PUBKEY Unusable public key
+54 GPG_ERR_UNUSABLE_SECKEY Unusable secret key
+55 GPG_ERR_INV_VALUE Invalid value
+56 GPG_ERR_BAD_CERT_CHAIN Bad certificate chain
+57 GPG_ERR_MISSING_CERT Missing certificate
+58 GPG_ERR_NO_DATA No data
+59 GPG_ERR_BUG Bug
+60 GPG_ERR_NOT_SUPPORTED Not supported
+61 GPG_ERR_INV_OP Invalid operation code
+62 GPG_ERR_TIMEOUT Timeout
+63 GPG_ERR_INTERNAL Internal error
+64 GPG_ERR_EOF_GCRYPT EOF (gcrypt)
+65 GPG_ERR_INV_OBJ Invalid object
+66 GPG_ERR_TOO_SHORT Provided object is too short
+67 GPG_ERR_TOO_LARGE Provided object is too large
+68 GPG_ERR_NO_OBJ Missing item in object
+69 GPG_ERR_NOT_IMPLEMENTED Not implemented
+70 GPG_ERR_CONFLICT Conflicting use
+71 GPG_ERR_INV_CIPHER_MODE Invalid cipher mode
+72 GPG_ERR_INV_FLAG Invalid flag
+73 GPG_ERR_INV_HANDLE Invalid handle
+74 GPG_ERR_TRUNCATED Result truncated
+75 GPG_ERR_INCOMPLETE_LINE Incomplete line
+76 GPG_ERR_INV_RESPONSE Invalid response
+77 GPG_ERR_NO_AGENT No agent running
+78 GPG_ERR_AGENT agent error
+79 GPG_ERR_INV_DATA Invalid data
+80 GPG_ERR_ASSUAN_SERVER_FAULT Assuan server fault
+81 GPG_ERR_ASSUAN Assuan error
+82 GPG_ERR_INV_SESSION_KEY Invalid session key
+83 GPG_ERR_INV_SEXP Invalid S-expression
+84 GPG_ERR_UNSUPPORTED_ALGORITHM Unsupported algorithm
+85 GPG_ERR_NO_PIN_ENTRY No pinentry
+86 GPG_ERR_PIN_ENTRY pinentry error
+87 GPG_ERR_BAD_PIN Bad PIN
+88 GPG_ERR_INV_NAME Invalid name
+89 GPG_ERR_BAD_DATA Bad data
+90 GPG_ERR_INV_PARAMETER Invalid parameter
+91 GPG_ERR_WRONG_CARD Wrong card
+92 GPG_ERR_NO_DIRMNGR No dirmngr
+93 GPG_ERR_DIRMNGR dirmngr error
+94 GPG_ERR_CERT_REVOKED Certificate revoked
+95 GPG_ERR_NO_CRL_KNOWN No CRL known
+96 GPG_ERR_CRL_TOO_OLD CRL too old
+97 GPG_ERR_LINE_TOO_LONG Line too long
+98 GPG_ERR_NOT_TRUSTED Not trusted
+99 GPG_ERR_CANCELED Operation cancelled
+100 GPG_ERR_BAD_CA_CERT Bad CA certificate
+101 GPG_ERR_CERT_EXPIRED Certificate expired
+102 GPG_ERR_CERT_TOO_YOUNG Certificate too young
+103 GPG_ERR_UNSUPPORTED_CERT Unsupported certificate
+104 GPG_ERR_UNKNOWN_SEXP Unknown S-expression
+105 GPG_ERR_UNSUPPORTED_PROTECTION Unsupported protection
+106 GPG_ERR_CORRUPTED_PROTECTION Corrupted protection
+107 GPG_ERR_AMBIGUOUS_NAME Ambiguous name
+108 GPG_ERR_CARD Card error
+109 GPG_ERR_CARD_RESET Card reset
+110 GPG_ERR_CARD_REMOVED Card removed
+111 GPG_ERR_INV_CARD Invalid card
+112 GPG_ERR_CARD_NOT_PRESENT Card not present
+113 GPG_ERR_NO_PKCS15_APP No PKCS15 application
+114 GPG_ERR_NOT_CONFIRMED Not confirmed
+115 GPG_ERR_CONFIGURATION Configuration error
+116 GPG_ERR_NO_POLICY_MATCH No policy match
+117 GPG_ERR_INV_INDEX Invalid index
+118 GPG_ERR_INV_ID Invalid ID
+119 GPG_ERR_NO_SCDAEMON No SmartCard daemon
+120 GPG_ERR_SCDAEMON SmartCard daemon error
+121 GPG_ERR_UNSUPPORTED_PROTOCOL Unsupported protocol
+122 GPG_ERR_BAD_PIN_METHOD Bad PIN method
+123 GPG_ERR_CARD_NOT_INITIALIZED Card not initialized
+124 GPG_ERR_UNSUPPORTED_OPERATION Unsupported operation
+125 GPG_ERR_WRONG_KEY_USAGE Wrong key usage
+126 GPG_ERR_NOTHING_FOUND Nothing found
+127 GPG_ERR_WRONG_BLOB_TYPE Wrong blob type
+128 GPG_ERR_MISSING_VALUE Missing value
+129 GPG_ERR_HARDWARE Hardware problem
+130 GPG_ERR_PIN_BLOCKED PIN blocked
+131 GPG_ERR_USE_CONDITIONS Conditions of use not satisfied
+132 GPG_ERR_PIN_NOT_SYNCED PINs are not synced
+133 GPG_ERR_INV_CRL Invalid CRL
+134 GPG_ERR_BAD_BER BER error
+135 GPG_ERR_INV_BER Invalid BER
+136 GPG_ERR_ELEMENT_NOT_FOUND Element not found
+137 GPG_ERR_IDENTIFIER_NOT_FOUND Identifier not found
+138 GPG_ERR_INV_TAG Invalid tag
+139 GPG_ERR_INV_LENGTH Invalid length
+140 GPG_ERR_INV_KEYINFO Invalid key info
+141 GPG_ERR_UNEXPECTED_TAG Unexpected tag
+142 GPG_ERR_NOT_DER_ENCODED Not DER encoded
+143 GPG_ERR_NO_CMS_OBJ No CMS object
+144 GPG_ERR_INV_CMS_OBJ Invalid CMS object
+145 GPG_ERR_UNKNOWN_CMS_OBJ Unknown CMS object
+146 GPG_ERR_UNSUPPORTED_CMS_OBJ Unsupported CMS object
+147 GPG_ERR_UNSUPPORTED_ENCODING Unsupported encoding
+148 GPG_ERR_UNSUPPORTED_CMS_VERSION Unsupported CMS version
+149 GPG_ERR_UNKNOWN_ALGORITHM Unknown algorithm
+150 GPG_ERR_INV_ENGINE Invalid crypto engine
+151 GPG_ERR_PUBKEY_NOT_TRUSTED Public key not trusted
+152 GPG_ERR_DECRYPT_FAILED Decryption failed
+153 GPG_ERR_KEY_EXPIRED Key expired
+154 GPG_ERR_SIG_EXPIRED Signature expired
+155 GPG_ERR_ENCODING_PROBLEM Encoding problem
+156 GPG_ERR_INV_STATE Invalid state
+157 GPG_ERR_DUP_VALUE Duplicated value
+158 GPG_ERR_MISSING_ACTION Missing action
+159 GPG_ERR_MODULE_NOT_FOUND ASN.1 module not found
+160 GPG_ERR_INV_OID_STRING Invalid OID string
+161 GPG_ERR_INV_TIME Invalid time
+162 GPG_ERR_INV_CRL_OBJ Invalid CRL object
+163 GPG_ERR_UNSUPPORTED_CRL_VERSION Unsupported CRL version
+164 GPG_ERR_INV_CERT_OBJ Invalid certificate object
+165 GPG_ERR_UNKNOWN_NAME Unknown name
+166 GPG_ERR_LOCALE_PROBLEM A locale function failed
+167 GPG_ERR_NOT_LOCKED Not locked
+
+# 168 to 199 are free to be used.
+
+200 GPG_ERR_BUFFER_TOO_SHORT Buffer too short
+
+# Error codes pertaining to S-expressions.
+
+201 GPG_ERR_SEXP_INV_LEN_SPEC Invalid length specifier in S-expression
+202 GPG_ERR_SEXP_STRING_TOO_LONG String too long in S-expression
+203 GPG_ERR_SEXP_UNMATCHED_PAREN Unmatched parentheses in S-expression
+204 GPG_ERR_SEXP_NOT_CANONICAL S-expression not canonical
+205 GPG_ERR_SEXP_BAD_CHARACTER Bad character in S-expression
+206 GPG_ERR_SEXP_BAD_QUOTATION Bad quotation in S-expression
+207 GPG_ERR_SEXP_ZERO_PREFIX Zero prefix in S-expression
+208 GPG_ERR_SEXP_NESTED_DH Nested display hints in S-expression
+209 GPG_ERR_SEXP_UNMATCHED_DH Unmatched display hints
+210 GPG_ERR_SEXP_UNEXPECTED_PUNC Unexpected reserved punctuation in S-expression
+211 GPG_ERR_SEXP_BAD_HEX_CHAR Bad hexadecimal character in S-expression
+212 GPG_ERR_SEXP_ODD_HEX_NUMBERS Odd hexadecimal numbers in S-expression
+213 GPG_ERR_SEXP_BAD_OCT_CHAR Bad octadecimal character in S-expression
+
+# 214 to 1023 are free to be used.
+
+# For free use by non-GnuPG components.
+1024 GPG_ERR_USER_1 User defined error code 1
+1025 GPG_ERR_USER_2 User defined error code 2
+1026 GPG_ERR_USER_3 User defined error code 3
+1027 GPG_ERR_USER_4 User defined error code 4
+1028 GPG_ERR_USER_5 User defined error code 5
+1029 GPG_ERR_USER_6 User defined error code 6
+1030 GPG_ERR_USER_7 User defined error code 7
+1031 GPG_ERR_USER_8 User defined error code 8
+1032 GPG_ERR_USER_9 User defined error code 9
+1033 GPG_ERR_USER_10 User defined error code 10
+1034 GPG_ERR_USER_11 User defined error code 11
+1035 GPG_ERR_USER_12 User defined error code 12
+1036 GPG_ERR_USER_13 User defined error code 13
+1037 GPG_ERR_USER_14 User defined error code 14
+1038 GPG_ERR_USER_15 User defined error code 15
+1039 GPG_ERR_USER_16 User defined error code 16
+
+# 1040 to 16381 are free to be used.
+
+16382 GPG_ERR_UNKNOWN_ERRNO Unknown system error
+16383 GPG_ERR_EOF End of file
+
+# 16384 - 32767 are reserved for future extensions.
+
+# GPG_SYSTEM_ERROR | (141 to 32767) are to be used for system errors.
+
+ GPG_ERR_CODE_DIM Unknown error code
diff --git a/src/err-sources.h.in b/src/err-sources.h.in
index 25a3f86..af072bd 100644
--- a/src/err-sources.h.in
+++ b/src/err-sources.h.in
@@ -1,6 +1,6 @@
# err-sources.h.in - List of error sources and their description input file.
/* err-sources.h - List of error sources and their description.
- Copyright (C) 2003 g10 Code GmbH
+ Copyright (C) 2003, 2004 g10 Code GmbH
This file is part of libgpg-error.
@@ -21,25 +21,33 @@
# Everything up to the first line that starts with a number in the
# first column is copied into the output verbatim. Then, empty lines
-# are ignored. Other lines must have an error code number, followed
-# by exactly one <tab>, followed by the error message. Trailing
-# whitespace is removed. The error sources should be sorted. The
-# last line should not have a number, but only a <tab>, followed by a
-# description for error sources that are not in the list.
-
-0 Unspecified source
-1 gcrypt
-2 GnuPG
-3 GpgSM
-4 GPG Agent
-5 Pinentry
-6 SCD
-7 GPGME
-8 Keybox
-9 KSBA
-10 Dirmngr
-32 User defined source 1
-33 User defined source 2
-34 User defined source 3
-35 User defined source 4
- Unknown source
+# are ignored. Other lines must have an error source number, followed
+# by one or more <tab> characters, followed by the error source
+# symbol, followed by one or more <tab> characters, followed by the
+# error source name. Trailing whitespace is removed. The error
+# sources should be sorted. The last line should not have a number,
+# but only a <tab>, followed by a description for error sources that
+# are not in the list.
+
+0 GPG_ERR_SOURCE_UNKNOWN Unspecified source
+1 GPG_ERR_SOURCE_GCRYPT gcrypt
+2 GPG_ERR_SOURCE_GPG GnuPG
+3 GPG_ERR_SOURCE_GPGSM GpgSM
+4 GPG_ERR_SOURCE_GPGAGENT GPG Agent
+5 GPG_ERR_SOURCE_PINENTRY Pinentry
+6 GPG_ERR_SOURCE_SCD SCD
+7 GPG_ERR_SOURCE_GPGME GPGME
+8 GPG_ERR_SOURCE_KEYBOX Keybox
+9 GPG_ERR_SOURCE_KSBA KSBA
+10 GPG_ERR_SOURCE_DIRMNGR Dirmngr
+
+# 11 to 31 are free to be used.
+
+32 GPG_ERR_SOURCE_USER_1 User defined source 1
+33 GPG_ERR_SOURCE_USER_2 User defined source 2
+34 GPG_ERR_SOURCE_USER_3 User defined source 3
+35 GPG_ERR_SOURCE_USER_4 User defined source 4
+
+# 36 to 255 are free to be used.
+
+ GPG_ERR_SOURCE_DIM Unknown source
diff --git a/src/errnos.in b/src/errnos.in
index 7b2b17b..322ec05 100644
--- a/src/errnos.in
+++ b/src/errnos.in
@@ -1,6 +1,6 @@
# errnos.h.in - List of system error values input file.
/* errnos.h - List of system error values.
- Copyright (C) 2003 g10 Code GmbH
+ Copyright (C) 2003, 2004 g10 Code GmbH
This file is part of libgpg-error.
@@ -21,150 +21,154 @@
#include <errno.h>
-# Everything up to the first line that starts with an "E" in the first
-# column is copied into the output verbatim. Then, empty lines are
-# ignored. Other lines must have an error name, like EINT. Please
-# note that the order must be the same as the corresponding macros in
-# the gpg_err_code_t type.
+# Everything up to the first line that starts with a number in the
+# first column is copied into the output verbatim. Then, empty lines
+# are ignored. Other lines must have an error code number, followed
+# by one or more <tab> characters, followed by the error name.
+#
+# IMPORTANT: For now, the numbering must be consecutive. Some of the
+# scripts (notably mkerrnos.h) do not deal correctly with a numbering
+# that is out of order or has gaps.
-E2BIG
-EACCES
-EADDRINUSE
-EADDRNOTAVAIL
-EADV
-EAFNOSUPPORT
-EAGAIN
-EALREADY
-EAUTH
-EBACKGROUND
-EBADE
-EBADF
-EBADFD
-EBADMSG
-EBADR
-EBADRPC
-EBADRQC
-EBADSLT
-EBFONT
-EBUSY
-ECANCELED
-ECHILD
-ECHRNG
-ECOMM
-ECONNABORTED
-ECONNREFUSED
-ECONNRESET
-ED
-EDEADLK
-EDEADLOCK
-EDESTADDRREQ
-EDIED
-EDOM
-EDOTDOT
-EDQUOT
-EEXIST
-EFAULT
-EFBIG
-EFTYPE
-EGRATUITOUS
-EGREGIOUS
-EHOSTDOWN
-EHOSTUNREACH
-EIDRM
-EIEIO
-EILSEQ
-EINPROGRESS
-EINTR
-EINVAL
-EIO
-EISCONN
-EISDIR
-EISNAM
-EL2HLT
-EL2NSYNC
-EL3HLT
-EL3RST
-ELIBACC
-ELIBBAD
-ELIBEXEC
-ELIBMAX
-ELIBSCN
-ELNRNG
-ELOOP
-EMEDIUMTYPE
-EMFILE
-EMLINK
-EMSGSIZE
-EMULTIHOP
-ENAMETOOLONG
-ENAVAIL
-ENEEDAUTH
-ENETDOWN
-ENETRESET
-ENETUNREACH
-ENFILE
-ENOANO
-ENOBUFS
-ENOCSI
-ENODATA
-ENODEV
-ENOENT
-ENOEXEC
-ENOLCK
-ENOLINK
-ENOMEDIUM
-ENOMEM
-ENOMSG
-ENONET
-ENOPKG
-ENOPROTOOPT
-ENOSPC
-ENOSR
-ENOSTR
-ENOSYS
-ENOTBLK
-ENOTCONN
-ENOTDIR
-ENOTEMPTY
-ENOTNAM
-ENOTSOCK
-ENOTSUP
-ENOTTY
-ENOTUNIQ
-ENXIO
-EOPNOTSUPP
-EOVERFLOW
-EPERM
-EPFNOSUPPORT
-EPIPE
-EPROCLIM
-EPROCUNAVAIL
-EPROGMISMATCH
-EPROGUNAVAIL
-EPROTO
-EPROTONOSUPPORT
-EPROTOTYPE
-ERANGE
-EREMCHG
-EREMOTE
-EREMOTEIO
-ERESTART
-EROFS
-ERPCMISMATCH
-ESHUTDOWN
-ESOCKTNOSUPPORT
-ESPIPE
-ESRCH
-ESRMNT
-ESTALE
-ESTRPIPE
-ETIME
-ETIMEDOUT
-ETOOMANYREFS
-ETXTBSY
-EUCLEAN
-EUNATCH
-EUSERS
-EWOULDBLOCK
-EXDEV
-EXFULL
+
+0 E2BIG
+1 EACCES
+2 EADDRINUSE
+3 EADDRNOTAVAIL
+4 EADV
+5 EAFNOSUPPORT
+6 EAGAIN
+7 EALREADY
+8 EAUTH
+9 EBACKGROUND
+10 EBADE
+11 EBADF
+12 EBADFD
+13 EBADMSG
+14 EBADR
+15 EBADRPC
+16 EBADRQC
+17 EBADSLT
+18 EBFONT
+19 EBUSY
+20 ECANCELED
+21 ECHILD
+22 ECHRNG
+23 ECOMM
+24 ECONNABORTED
+25 ECONNREFUSED
+26 ECONNRESET
+27 ED
+28 EDEADLK
+29 EDEADLOCK
+30 EDESTADDRREQ
+31 EDIED
+32 EDOM
+33 EDOTDOT
+34 EDQUOT
+35 EEXIST
+36 EFAULT
+37 EFBIG
+38 EFTYPE
+39 EGRATUITOUS
+40 EGREGIOUS
+41 EHOSTDOWN
+42 EHOSTUNREACH
+43 EIDRM
+44 EIEIO
+45 EILSEQ
+46 EINPROGRESS
+47 EINTR
+48 EINVAL
+49 EIO
+50 EISCONN
+51 EISDIR
+52 EISNAM
+53 EL2HLT
+54 EL2NSYNC
+55 EL3HLT
+56 EL3RST
+57 ELIBACC
+58 ELIBBAD
+59 ELIBEXEC
+60 ELIBMAX
+61 ELIBSCN
+62 ELNRNG
+63 ELOOP
+64 EMEDIUMTYPE
+65 EMFILE
+66 EMLINK
+67 EMSGSIZE
+68 EMULTIHOP
+69 ENAMETOOLONG
+70 ENAVAIL
+71 ENEEDAUTH
+72 ENETDOWN
+73 ENETRESET
+74 ENETUNREACH
+75 ENFILE
+76 ENOANO
+77 ENOBUFS
+78 ENOCSI
+79 ENODATA
+80 ENODEV
+81 ENOENT
+82 ENOEXEC
+83 ENOLCK
+84 ENOLINK
+85 ENOMEDIUM
+86 ENOMEM
+87 ENOMSG
+88 ENONET
+89 ENOPKG
+90 ENOPROTOOPT
+91 ENOSPC
+92 ENOSR
+93 ENOSTR
+94 ENOSYS
+95 ENOTBLK
+96 ENOTCONN
+97 ENOTDIR
+98 ENOTEMPTY
+99 ENOTNAM
+100 ENOTSOCK
+101 ENOTSUP
+102 ENOTTY
+103 ENOTUNIQ
+104 ENXIO
+105 EOPNOTSUPP
+106 EOVERFLOW
+107 EPERM
+108 EPFNOSUPPORT
+109 EPIPE
+110 EPROCLIM
+111 EPROCUNAVAIL
+112 EPROGMISMATCH
+113 EPROGUNAVAIL
+114 EPROTO
+115 EPROTONOSUPPORT
+116 EPROTOTYPE
+117 ERANGE
+118 EREMCHG
+119 EREMOTE
+120 EREMOTEIO
+121 ERESTART
+122 EROFS
+123 ERPCMISMATCH
+124 ESHUTDOWN
+125 ESOCKTNOSUPPORT
+126 ESPIPE
+127 ESRCH
+128 ESRMNT
+129 ESTALE
+130 ESTRPIPE
+131 ETIME
+132 ETIMEDOUT
+133 ETOOMANYREFS
+134 ETXTBSY
+135 EUCLEAN
+136 EUNATCH
+137 EUSERS
+138 EWOULDBLOCK
+139 EXDEV
+140 EXFULL
diff --git a/src/gpg-error.c b/src/gpg-error.c
new file mode 100644
index 0000000..519c523
--- /dev/null
+++ b/src/gpg-error.c
@@ -0,0 +1,260 @@
+/* gpg-error.c - Determining gpg-error 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 libgpg-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 <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+
+#include <gpg-error.h>
+
+
+const char *gpg_strerror_sym (gpg_error_t err);
+const char *gpg_strsource_sym (gpg_error_t err);
+
+
+static int
+get_err_from_number (char *str, gpg_error_t *err)
+{
+ unsigned long nr;
+ char *tail;
+
+ errno = 0;
+ nr = strtoul (str, &tail, 0);
+ if (errno || *tail)
+ return 0;
+
+ if (nr > UINT_MAX)
+ return 0;
+
+ *err = (unsigned int) nr;
+ return 1;
+}
+
+
+static int
+get_err_from_symbol_one (char *str, gpg_error_t *err,
+ int *have_source, int *have_code)
+{
+ static const char src_prefix[] = "GPG_ERR_SOURCE_";
+ static const char code_prefix[] = "GPG_ERR_";
+
+ if (!strncasecmp (src_prefix, str, sizeof (src_prefix) - 1))
+ {
+ gpg_err_source_t src;
+
+ if (*have_source)
+ return 0;
+ *have_source = 1;
+ str += sizeof (src_prefix) - 1;
+
+ for (src = 0; src < GPG_ERR_SOURCE_DIM; src++)
+ {
+ const char *src_sym = gpg_strsource_sym (src << GPG_ERR_SOURCE_SHIFT);
+ if (src_sym && !strcasecmp (str, src_sym + sizeof (src_prefix) - 1))
+ {
+ *err |= src << GPG_ERR_SOURCE_SHIFT;
+ return 1;
+ }
+ }
+ }
+ else if (!strncasecmp (code_prefix, str, sizeof (code_prefix) - 1))
+ {
+ gpg_err_code_t code;
+
+ if (*have_code)
+ return 0;
+ *have_code = 1;
+ str += sizeof (code_prefix) - 1;
+
+ for (code = 0; code < GPG_ERR_CODE_DIM; code++)
+ {
+ const char *code_sym = gpg_strerror_sym (code);
+ if (code_sym
+ && !strcasecmp (str, code_sym + sizeof (code_prefix) - 1))
+ {
+ *err |= code;
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
+
+static int
+get_err_from_symbol (char *str, gpg_error_t *err)
+{
+ char *str2 = str;
+ int have_source = 0;
+ int have_code = 0;
+ int ret;
+ char *saved_pos = NULL;
+ char saved_char;
+
+ *err = 0;
+ while (*str2 && ((*str2 >= 'A' && *str2 <= 'Z')
+ || (*str2 >= '0' && *str2 <= '9')
+ || *str2 == '_'))
+ str2++;
+ if (*str2)
+ {
+ saved_pos = str2;
+ saved_char = *str2;
+ *str2 = '\0';
+ str2++;
+ }
+ else
+ str2 = NULL;
+
+ ret = get_err_from_symbol_one (str, err, &have_source, &have_code);
+ if (ret && str2)
+ ret = get_err_from_symbol_one (str2, err, &have_source, &have_code);
+
+ if (saved_pos)
+ *saved_pos = saved_char;
+ return ret;
+}
+
+
+static int
+get_err_from_str_one (char *str, gpg_error_t *err,
+ int *have_source, int *have_code)
+{
+ gpg_err_source_t src;
+ gpg_err_code_t code;
+
+ for (src = 0; src < GPG_ERR_SOURCE_DIM; src++)
+ {
+ const char *src_str = gpg_strsource (src << GPG_ERR_SOURCE_SHIFT);
+ if (src_str && !strcasecmp (str, src_str))
+ {
+ if (*have_source)
+ return 0;
+
+ *have_source = 1;
+ *err |= src << GPG_ERR_SOURCE_SHIFT;
+ return 1;
+ }
+ }
+
+ for (code = 0; code < GPG_ERR_CODE_DIM; code++)
+ {
+ const char *code_str = gpg_strerror (code);
+ if (code_str && !strcasecmp (str, code_str))
+ {
+ if (*have_code)
+ return 0;
+
+ *have_code = 1;
+ *err |= code;
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+
+static int
+get_err_from_str (char *str, gpg_error_t *err)
+{
+ char *str2 = str;
+ int have_source = 0;
+ int have_code = 0;
+ int ret;
+ char *saved_pos = NULL;
+ char saved_char;
+
+ *err = 0;
+ ret = get_err_from_str_one (str, err, &have_source, &have_code);
+ if (ret)
+ return ret;
+
+ while (*str2 && ((*str2 >= 'A' && *str2 <= 'Z')
+ || (*str2 >= 'a' && *str2 <= 'z')
+ || (*str2 >= '0' && *str2 <= '9')
+ || *str2 == '_'))
+ str2++;
+ if (*str2)
+ {
+ saved_pos = str2;
+ saved_char = *str2;
+ *((char *) str2) = '\0';
+ str2++;
+ while (*str2 && !((*str2 >= 'A' && *str2 <= 'Z')
+ || (*str2 >= 'a' && *str2 <= 'z')
+ || (*str2 >= '0' && *str2 <= '9')
+ || *str2 == '_'))
+ str2++;
+ }
+ else
+ str2 = NULL;
+
+ ret = get_err_from_str_one (str, err, &have_source, &have_code);
+ if (ret && str2)
+ ret = get_err_from_str_one (str2, err, &have_source, &have_code);
+
+ if (saved_pos)
+ *saved_pos = saved_char;
+ return ret;
+}
+
+
+
+int
+main (int argc, char *argv[])
+{
+ int i = 1;
+
+ if (argc == 1)
+ {
+ fprintf (stderr, "Usage: %s GPG-ERROR [...]\n", argv[0]);
+ exit (1);
+ }
+
+ while (i < argc)
+ {
+ gpg_error_t err;
+
+ if (get_err_from_number (argv[i], &err)
+ || get_err_from_symbol (argv[i], &err)
+ || get_err_from_str (argv[i], &err))
+ {
+ const char *source_sym = gpg_strsource_sym (err);
+ const char *error_sym = gpg_strerror_sym (err);
+
+ printf ("%u = (%u, %u) = (%s, %s) = (%s, %s)\n",
+ err, gpg_err_source (err), gpg_err_code (err),
+ source_sym ? source_sym : "-", error_sym ? error_sym : "-",
+ gpg_strsource (err), gpg_strerror (err));
+ }
+ else
+ fprintf (stderr, "%s: warning: could not recognize %s\n",
+ argv[0], argv[i]);
+ i++;
+ }
+}
diff --git a/src/gpg-error.h b/src/gpg-error.h
deleted file mode 100644
index f5571d5..0000000
--- a/src/gpg-error.h
+++ /dev/null
@@ -1,582 +0,0 @@
-/* gpg-error.h - Public interface to libgpg-error.
- 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 libgpg-error; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA. */
-
-#ifndef GPG_ERROR_H
-#define GPG_ERROR_H 1
-
-#include <stddef.h>
-
-#ifdef __GNUC__
-#define GPG_ERR_INLINE __inline__
-#elif __STDC_VERSION__ >= 199901L
-#define GPG_ERR_INLINE inline
-#else
-#ifndef GPG_ERR_INLINE
-#define GPG_ERR_INLINE
-#endif
-#endif
-
-/* The GnuPG project consists of many components. Error codes are
- exchanged between all components. The common error codes and their
- user-presentable descriptions are kept into a shared library to
- allow adding new error codes and components without recompiling any
- of the other components. The interface will not change in a
- backward incompatible way.
-
- An error code together with an error source build up an error
- value. As the error value is been passed from one component to
- another, it preserver the information about the source and nature
- of the error.
-
- A component of the GnuPG project can define the following macro to
- tune the behaviour of the library:
-
- GPG_ERR_SOURCE_DEFAULT: Define to an error source of type
- gpg_err_source_t to make that source the default for gpg_error().
- Otherwise GPG_ERR_SOURCE_UNKNOWN is used as default. */
-
-
-/* The error source type gpg_err_source_t.
-
- Where as the Poo out of a welle small
- Taketh his firste springing and his sours.
- --Chaucer. */
-
-/* Only use free slots, never change or reorder the existing
- entries. */
-typedef enum
- {
- GPG_ERR_SOURCE_UNKNOWN = 0,
- GPG_ERR_SOURCE_GCRYPT = 1, /* Libgcrypt */
- GPG_ERR_SOURCE_GPG = 2, /* GnuPG */
- GPG_ERR_SOURCE_GPGSM = 3, /* GnuPG */
- GPG_ERR_SOURCE_GPGAGENT = 4, /* GnuPG */
- GPG_ERR_SOURCE_PINENTRY = 5, /* Pinentry */
- GPG_ERR_SOURCE_SCD = 6, /* GnuPG */
- GPG_ERR_SOURCE_GPGME = 7, /* GPGME */
- GPG_ERR_SOURCE_KEYBOX = 8, /* GnuPG */
- GPG_ERR_SOURCE_KSBA = 9, /* Libksba */
- GPG_ERR_SOURCE_DIRMNGR = 10, /* Dirmngr */
-
- /* 9 to 31 are free to be used. */
-
- /* Free for use by non-GnuPG components. */
- GPG_ERR_SOURCE_USER_1 = 32,
- GPG_ERR_SOURCE_USER_2 = 33,
- GPG_ERR_SOURCE_USER_3 = 34,
- GPG_ERR_SOURCE_USER_4 = 35,
-
- /* 36 to 255 are free to be used. */
-
- /* This is one more than the largest allowed entry. */
- GPG_ERR_SOURCE_DIM = 256
- } gpg_err_source_t;
-
-
-/* The error code type gpg_err_code_t. */
-
-/* Only use free slots, never change or reorder the existing
- entries. */
-typedef enum
- {
- GPG_ERR_NO_ERROR = 0, /* An error that is not an error. */
- GPG_ERR_GENERAL = 1,
- GPG_ERR_UNKNOWN_PACKET = 2,
- GPG_ERR_UNKNOWN_VERSION = 3, /* Unknown version (in packet). */
- GPG_ERR_PUBKEY_ALGO = 4, /* Invalid public key algorithm. */
- GPG_ERR_DIGEST_ALGO = 5, /* Invalid digest algorithm. */
- GPG_ERR_BAD_PUBKEY = 6, /* Bad public key. */
- GPG_ERR_BAD_SECKEY = 7, /* Bad secret key. */
- GPG_ERR_BAD_SIGNATURE = 8, /* Bad signature. */
- GPG_ERR_NO_PUBKEY = 9, /* Public key not found. */
- GPG_ERR_CHECKSUM = 10, /* Checksum error. */
- GPG_ERR_BAD_PASSPHRASE = 11, /* Bad passphrase. */
- GPG_ERR_CIPHER_ALGO = 12, /* Invalid cipher algorithm. */
- GPG_ERR_KEYRING_OPEN = 13,
- GPG_ERR_INV_PACKET = 14,
- GPG_ERR_INV_ARMOR = 15,
- GPG_ERR_NO_USER_ID = 16,
- GPG_ERR_NO_SECKEY = 17, /* Secret key not available. */
- GPG_ERR_WRONG_SECKEY = 18, /* Wrong secret key used. */
- GPG_ERR_BAD_KEY = 19, /* Bad (session) key. */
- GPG_ERR_COMPR_ALGO = 20, /* Unknown compress algorithm. */
- GPG_ERR_NO_PRIME = 21, /* Number is not prime. */
- GPG_ERR_NO_ENCODING_METHOD = 22, /* Invalid encoding method. */
- GPG_ERR_NO_ENCRYPTION_SCHEME = 23, /* Invalid encryption scheme. */
- GPG_ERR_NO_SIGNATURE_SCHEME = 24, /* Invalid signature scheme. */
- GPG_ERR_INV_ATTR = 25, /* Invalid attribute. */
- GPG_ERR_NO_VALUE = 26,
- GPG_ERR_NOT_FOUND = 27,
- GPG_ERR_VALUE_NOT_FOUND = 28,
- GPG_ERR_SYNTAX = 29,
- GPG_ERR_BAD_MPI = 30, /* Problem with an MPI's value. */
- GPG_ERR_INV_PASSPHRASE = 31, /* Invalid passphrase. */
- GPG_ERR_SIG_CLASS = 32,
- GPG_ERR_RESOURCE_LIMIT = 33,
- GPG_ERR_INV_KEYRING = 34,
- GPG_ERR_TRUSTDB = 35, /* A problem with the trustdb. */
- GPG_ERR_BAD_CERT = 36, /* Bad certificate. */
- GPG_ERR_INV_USER_ID = 37,
- GPG_ERR_UNEXPECTED = 38,
- GPG_ERR_TIME_CONFLICT = 39,
- GPG_ERR_KEYSERVER = 40,
- GPG_ERR_WRONG_PUBKEY_ALGO = 41, /* Wrong public key algorithm. */
- GPG_ERR_TRIBUTE_TO_D_A = 42,
- GPG_ERR_WEAK_KEY = 43, /* Weak encryption key. */
- GPG_ERR_INV_KEYLEN = 44, /* Invalid length of a key. */
- GPG_ERR_INV_ARG = 45, /* Invalid argument. */
- GPG_ERR_BAD_URI = 46, /* Syntax error in URI. */
- GPG_ERR_INV_URI = 47, /* Unsupported scheme and similar. */
- GPG_ERR_NETWORK = 48, /* General network error. */
- GPG_ERR_UNKNOWN_HOST = 49,
- GPG_ERR_SELFTEST_FAILED = 50,
- GPG_ERR_NOT_ENCRYPTED = 51,
- GPG_ERR_NOT_PROCESSED = 52,
- GPG_ERR_UNUSABLE_PUBKEY = 53,
- GPG_ERR_UNUSABLE_SECKEY = 54,
- GPG_ERR_INV_VALUE = 55,
- GPG_ERR_BAD_CERT_CHAIN = 56,
- GPG_ERR_MISSING_CERT = 57,
- GPG_ERR_NO_DATA = 58,
- GPG_ERR_BUG = 59,
- GPG_ERR_NOT_SUPPORTED = 60,
- GPG_ERR_INV_OP = 61, /* Invalid operation code. */
- GPG_ERR_TIMEOUT = 62, /* Something timed out. */
- GPG_ERR_INTERNAL = 63, /* Internal error. */
- GPG_ERR_EOF_GCRYPT = 64, /* Compatibility for gcrypt. */
- GPG_ERR_INV_OBJ = 65, /* An object is not valid. */
- GPG_ERR_TOO_SHORT = 66, /* Provided object is too short. */
- GPG_ERR_TOO_LARGE = 67, /* Provided object is too large. */
- GPG_ERR_NO_OBJ = 68, /* Missing item in an object. */
- GPG_ERR_NOT_IMPLEMENTED = 69, /* Not implemented. */
- GPG_ERR_CONFLICT = 70, /* Conflicting use. */
- GPG_ERR_INV_CIPHER_MODE = 71, /* Invalid cipher mode. */
- GPG_ERR_INV_FLAG = 72, /* Invalid flag. */
- GPG_ERR_INV_HANDLE = 73, /* Invalid handle. */
-
- GPG_ERR_TRUNCATED = 74, /* Result runcated. */
-
- GPG_ERR_INCOMPLETE_LINE = 75,
- GPG_ERR_INV_RESPONSE = 76,
- GPG_ERR_NO_AGENT = 77,
- GPG_ERR_AGENT = 78,
- GPG_ERR_INV_DATA = 79,
- GPG_ERR_ASSUAN_SERVER_FAULT = 80,
- GPG_ERR_ASSUAN = 81, /* Catch all assuan error. */
- GPG_ERR_INV_SESSION_KEY = 82,
- GPG_ERR_INV_SEXP = 83,
- GPG_ERR_UNSUPPORTED_ALGORITHM = 84,
- GPG_ERR_NO_PIN_ENTRY = 85,
- GPG_ERR_PIN_ENTRY = 86,
- GPG_ERR_BAD_PIN = 87,
- GPG_ERR_INV_NAME = 88,
- GPG_ERR_BAD_DATA = 89,
- GPG_ERR_INV_PARAMETER = 90,
-
- GPG_ERR_WRONG_CARD = 91,
-
- GPG_ERR_NO_DIRMNGR = 92,
- GPG_ERR_DIRMNGR = 93,
- GPG_ERR_CERT_REVOKED = 94,
- GPG_ERR_NO_CRL_KNOWN = 95,
- GPG_ERR_CRL_TOO_OLD = 96,
- GPG_ERR_LINE_TOO_LONG = 97,
- GPG_ERR_NOT_TRUSTED = 98,
- GPG_ERR_CANCELED = 99, /* Canceled by user. */
- GPG_ERR_BAD_CA_CERT = 100,
- GPG_ERR_CERT_EXPIRED = 101, /* Key signature expired. */
- GPG_ERR_CERT_TOO_YOUNG = 102,
- GPG_ERR_UNSUPPORTED_CERT = 103,
- GPG_ERR_UNKNOWN_SEXP = 104,
- GPG_ERR_UNSUPPORTED_PROTECTION = 105,
- GPG_ERR_CORRUPTED_PROTECTION = 106,
- GPG_ERR_AMBIGUOUS_NAME = 107,
- GPG_ERR_CARD = 108,
- GPG_ERR_CARD_RESET = 109,
- GPG_ERR_CARD_REMOVED = 110,
- GPG_ERR_INV_CARD = 111,
- GPG_ERR_CARD_NOT_PRESENT = 112,
- GPG_ERR_NO_PKCS15_APP = 113,
- GPG_ERR_NOT_CONFIRMED = 114,
- GPG_ERR_CONFIGURATION = 115,
- GPG_ERR_NO_POLICY_MATCH = 116,
- GPG_ERR_INV_INDEX = 117,
- GPG_ERR_INV_ID = 118,
- GPG_ERR_NO_SCDAEMON = 119,
- GPG_ERR_SCDAEMON = 120,
- GPG_ERR_UNSUPPORTED_PROTOCOL = 121,
- GPG_ERR_BAD_PIN_METHOD = 122,
- GPG_ERR_CARD_NOT_INITIALIZED = 123,
- GPG_ERR_UNSUPPORTED_OPERATION = 124,
- GPG_ERR_WRONG_KEY_USAGE = 125,
- GPG_ERR_NOTHING_FOUND = 126, /* Operation failed due to an
- unsuccessful find operation. */
- GPG_ERR_WRONG_BLOB_TYPE = 127, /* Keybox BLOB of wrong type. */
- GPG_ERR_MISSING_VALUE = 128, /* A required value is missing. */
-
- GPG_ERR_HARDWARE = 129, /* e.g. EEPROM error of a smartcard. */
- GPG_ERR_PIN_BLOCKED = 130,
- GPG_ERR_USE_CONDITIONS = 131, /* e.g. used with smartcards. */
- GPG_ERR_PIN_NOT_SYNCED = 132, /* e.g. for OpenPGP card: CHV1 != CHV2. */
- GPG_ERR_INV_CRL = 133, /* e.g. not signed. */
- GPG_ERR_BAD_BER = 134, /* Basic Encoding Rules (ASN.1) error. */
- GPG_ERR_INV_BER = 135,
- GPG_ERR_ELEMENT_NOT_FOUND = 136,
- GPG_ERR_IDENTIFIER_NOT_FOUND = 137,
- GPG_ERR_INV_TAG = 138,
- GPG_ERR_INV_LENGTH = 139,
- GPG_ERR_INV_KEYINFO = 140,
- GPG_ERR_UNEXPECTED_TAG = 141,
- GPG_ERR_NOT_DER_ENCODED = 142,
- GPG_ERR_NO_CMS_OBJ = 143,
- GPG_ERR_INV_CMS_OBJ = 144,
- GPG_ERR_UNKNOWN_CMS_OBJ = 145,
- GPG_ERR_UNSUPPORTED_CMS_OBJ = 146,
- GPG_ERR_UNSUPPORTED_ENCODING = 147,
- GPG_ERR_UNSUPPORTED_CMS_VERSION = 148,
- GPG_ERR_UNKNOWN_ALGORITHM = 149,
- GPG_ERR_INV_ENGINE = 150,
- GPG_ERR_PUBKEY_NOT_TRUSTED = 151,
- GPG_ERR_DECRYPT_FAILED = 152,
- GPG_ERR_KEY_EXPIRED = 153,
- GPG_ERR_SIG_EXPIRED = 154, /* Data signature expired. */
- GPG_ERR_ENCODING_PROBLEM = 155,
- GPG_ERR_INV_STATE = 156,
- GPG_ERR_DUP_VALUE = 157,
- GPG_ERR_MISSING_ACTION = 158,
- GPG_ERR_MODULE_NOT_FOUND = 159, /* ASN.1 mpodule not found. */
- GPG_ERR_INV_OID_STRING = 160,
- GPG_ERR_INV_TIME = 161,
- GPG_ERR_INV_CRL_OBJ = 162,
- GPG_ERR_UNSUPPORTED_CRL_VERSION = 163,
- GPG_ERR_INV_CERT_OBJ = 164,
- GPG_ERR_UNKNOWN_NAME = 165,
- GPG_ERR_LOCALE_PROBLEM = 166, /* A problem with the locale occured. */
- GPG_ERR_NOT_LOCKED = 167, /* Expected lock not held. */
-
- /* 168 to 199 are free to be used. */
-
- GPG_ERR_BUFFER_TOO_SHORT = 200,
-
- /* Error codes pertaining to S-expressions. */
- GPG_ERR_SEXP_INV_LEN_SPEC = 201,
- GPG_ERR_SEXP_STRING_TOO_LONG = 202,
- GPG_ERR_SEXP_UNMATCHED_PAREN = 203,
- GPG_ERR_SEXP_NOT_CANONICAL = 204,
- GPG_ERR_SEXP_BAD_CHARACTER = 205,
- GPG_ERR_SEXP_BAD_QUOTATION = 206, /* Or invalid hex or octal value. */
- GPG_ERR_SEXP_ZERO_PREFIX = 207, /* First character of length is 0. */
- GPG_ERR_SEXP_NESTED_DH = 208, /* Nested display hints. */
- GPG_ERR_SEXP_UNMATCHED_DH = 209, /* Unmatched display hint. */
- GPG_ERR_SEXP_UNEXPECTED_PUNC = 210, /* Unexpected reserved punctuation. */
- GPG_ERR_SEXP_BAD_HEX_CHAR = 211,
- GPG_ERR_SEXP_ODD_HEX_NUMBERS = 212,
- GPG_ERR_SEXP_BAD_OCT_CHAR = 213,
-
- /* 213 to 1023 are free to be used. */
-
- /* For free use by non-GnuPG components. */
- GPG_ERR_USER_1 = 1024,
- GPG_ERR_USER_2 = 1025,
- GPG_ERR_USER_3 = 1026,
- GPG_ERR_USER_4 = 1027,
- GPG_ERR_USER_5 = 1028,
- GPG_ERR_USER_6 = 1029,
- GPG_ERR_USER_7 = 1030,
- GPG_ERR_USER_8 = 1031,
- GPG_ERR_USER_9 = 1032,
- GPG_ERR_USER_10 = 1033,
- GPG_ERR_USER_11 = 1034,
- GPG_ERR_USER_12 = 1035,
- GPG_ERR_USER_13 = 1036,
- GPG_ERR_USER_14 = 1037,
- GPG_ERR_USER_15 = 1038,
- GPG_ERR_USER_16 = 1039,
-
- /* 1040 to 16381 are free to be used. */
-
- GPG_ERR_UNKNOWN_ERRNO = 16382,
- GPG_ERR_EOF = 16383, /* This was once a -1. Pity. */
-
- /* 16384 - 32767 are reserved for future extensions. */
-
- /* The following error codes are used to map system errors. */
-#define GPG_ERR_SYSTEM_ERROR (1 << 15)
- GPG_ERR_E2BIG = GPG_ERR_SYSTEM_ERROR | 0,
- GPG_ERR_EACCES = GPG_ERR_SYSTEM_ERROR | 1,
- GPG_ERR_EADDRINUSE = GPG_ERR_SYSTEM_ERROR | 2,
- GPG_ERR_EADDRNOTAVAIL = GPG_ERR_SYSTEM_ERROR | 3,
- GPG_ERR_EADV = GPG_ERR_SYSTEM_ERROR | 4,
- GPG_ERR_EAFNOSUPPORT = GPG_ERR_SYSTEM_ERROR | 5,
- GPG_ERR_EAGAIN = GPG_ERR_SYSTEM_ERROR | 6,
- GPG_ERR_EALREADY = GPG_ERR_SYSTEM_ERROR | 7,
- GPG_ERR_EAUTH = GPG_ERR_SYSTEM_ERROR | 8,
- GPG_ERR_EBACKGROUND = GPG_ERR_SYSTEM_ERROR | 9,
- GPG_ERR_EBADE = GPG_ERR_SYSTEM_ERROR | 10,
- GPG_ERR_EBADF = GPG_ERR_SYSTEM_ERROR | 11,
- GPG_ERR_EBADFD = GPG_ERR_SYSTEM_ERROR | 12,
- GPG_ERR_EBADMSG = GPG_ERR_SYSTEM_ERROR | 13,
- GPG_ERR_EBADR = GPG_ERR_SYSTEM_ERROR | 14,
- GPG_ERR_EBADRPC = GPG_ERR_SYSTEM_ERROR | 15,
- GPG_ERR_EBADRQC = GPG_ERR_SYSTEM_ERROR | 16,
- GPG_ERR_EBADSLT = GPG_ERR_SYSTEM_ERROR | 17,
- GPG_ERR_EBFONT = GPG_ERR_SYSTEM_ERROR | 18,
- GPG_ERR_EBUSY = GPG_ERR_SYSTEM_ERROR | 19,
- GPG_ERR_ECANCELED = GPG_ERR_SYSTEM_ERROR | 20, /* Async op. was canceled. */
- GPG_ERR_ECHILD = GPG_ERR_SYSTEM_ERROR | 21,
- GPG_ERR_ECHRNG = GPG_ERR_SYSTEM_ERROR | 22,
- GPG_ERR_ECOMM = GPG_ERR_SYSTEM_ERROR | 23,
- GPG_ERR_ECONNABORTED = GPG_ERR_SYSTEM_ERROR | 24,
- GPG_ERR_ECONNREFUSED = GPG_ERR_SYSTEM_ERROR | 25,
- GPG_ERR_ECONNRESET = GPG_ERR_SYSTEM_ERROR | 26,
- GPG_ERR_ED = GPG_ERR_SYSTEM_ERROR | 27,
- GPG_ERR_EDEADLK = GPG_ERR_SYSTEM_ERROR | 28,
- GPG_ERR_EDEADLOCK = GPG_ERR_SYSTEM_ERROR | 29,
- GPG_ERR_EDESTADDRREQ = GPG_ERR_SYSTEM_ERROR | 30,
- GPG_ERR_EDIED = GPG_ERR_SYSTEM_ERROR | 31,
- GPG_ERR_EDOM = GPG_ERR_SYSTEM_ERROR | 32,
- GPG_ERR_EDOTDOT = GPG_ERR_SYSTEM_ERROR | 33,
- GPG_ERR_EDQUOT = GPG_ERR_SYSTEM_ERROR | 34,
- GPG_ERR_EEXIST = GPG_ERR_SYSTEM_ERROR | 35,
- GPG_ERR_EFAULT = GPG_ERR_SYSTEM_ERROR | 36,
- GPG_ERR_EFBIG = GPG_ERR_SYSTEM_ERROR | 37,
- GPG_ERR_EFTYPE = GPG_ERR_SYSTEM_ERROR | 38,
- GPG_ERR_EGRATUITOUS = GPG_ERR_SYSTEM_ERROR | 39,
- GPG_ERR_EGREGIOUS = GPG_ERR_SYSTEM_ERROR | 40,
- GPG_ERR_EHOSTDOWN = GPG_ERR_SYSTEM_ERROR | 41,
- GPG_ERR_EHOSTUNREACH = GPG_ERR_SYSTEM_ERROR | 42,
- GPG_ERR_EIDRM = GPG_ERR_SYSTEM_ERROR | 43,
- GPG_ERR_EIEIO = GPG_ERR_SYSTEM_ERROR | 44,
- GPG_ERR_EILSEQ = GPG_ERR_SYSTEM_ERROR | 45,
- GPG_ERR_EINPROGRESS = GPG_ERR_SYSTEM_ERROR | 46,
- GPG_ERR_EINTR = GPG_ERR_SYSTEM_ERROR | 47,
- GPG_ERR_EINVAL = GPG_ERR_SYSTEM_ERROR | 48,
- GPG_ERR_EIO = GPG_ERR_SYSTEM_ERROR | 49,
- GPG_ERR_EISCONN = GPG_ERR_SYSTEM_ERROR | 50,
- GPG_ERR_EISDIR = GPG_ERR_SYSTEM_ERROR | 51,
- GPG_ERR_EISNAM = GPG_ERR_SYSTEM_ERROR | 52,
- GPG_ERR_EL2HLT = GPG_ERR_SYSTEM_ERROR | 53,
- GPG_ERR_EL2NSYNC = GPG_ERR_SYSTEM_ERROR | 54,
- GPG_ERR_EL3HLT = GPG_ERR_SYSTEM_ERROR | 55,
- GPG_ERR_EL3RST = GPG_ERR_SYSTEM_ERROR | 56,
- GPG_ERR_ELIBACC = GPG_ERR_SYSTEM_ERROR | 57,
- GPG_ERR_ELIBBAD = GPG_ERR_SYSTEM_ERROR | 58,
- GPG_ERR_ELIBEXEC = GPG_ERR_SYSTEM_ERROR | 59,
- GPG_ERR_ELIBMAX = GPG_ERR_SYSTEM_ERROR | 60,
- GPG_ERR_ELIBSCN = GPG_ERR_SYSTEM_ERROR | 61,
- GPG_ERR_ELNRNG = GPG_ERR_SYSTEM_ERROR | 62,
- GPG_ERR_ELOOP = GPG_ERR_SYSTEM_ERROR | 63,
- GPG_ERR_EMEDIUMTYPE = GPG_ERR_SYSTEM_ERROR | 64,
- GPG_ERR_EMFILE = GPG_ERR_SYSTEM_ERROR | 65,
- GPG_ERR_EMLINK = GPG_ERR_SYSTEM_ERROR | 66,
- GPG_ERR_EMSGSIZE = GPG_ERR_SYSTEM_ERROR | 67,
- GPG_ERR_EMULTIHOP = GPG_ERR_SYSTEM_ERROR | 68,
- GPG_ERR_ENAMETOOLONG = GPG_ERR_SYSTEM_ERROR | 69,
- GPG_ERR_ENAVAIL = GPG_ERR_SYSTEM_ERROR | 70,
- GPG_ERR_ENEEDAUTH = GPG_ERR_SYSTEM_ERROR | 71,
- GPG_ERR_ENETDOWN = GPG_ERR_SYSTEM_ERROR | 72,
- GPG_ERR_ENETRESET = GPG_ERR_SYSTEM_ERROR | 73,
- GPG_ERR_ENETUNREACH = GPG_ERR_SYSTEM_ERROR | 74,
- GPG_ERR_ENFILE = GPG_ERR_SYSTEM_ERROR | 75,
- GPG_ERR_ENOANO = GPG_ERR_SYSTEM_ERROR | 76,
- GPG_ERR_ENOBUFS = GPG_ERR_SYSTEM_ERROR | 77,
- GPG_ERR_ENOCSI = GPG_ERR_SYSTEM_ERROR | 78,
- GPG_ERR_ENODATA = GPG_ERR_SYSTEM_ERROR | 79,
- GPG_ERR_ENODEV = GPG_ERR_SYSTEM_ERROR | 80,
- GPG_ERR_ENOENT = GPG_ERR_SYSTEM_ERROR | 81,
- GPG_ERR_ENOEXEC = GPG_ERR_SYSTEM_ERROR | 82,
- GPG_ERR_ENOLCK = GPG_ERR_SYSTEM_ERROR | 83,
- GPG_ERR_ENOLINK = GPG_ERR_SYSTEM_ERROR | 84,
- GPG_ERR_ENOMEDIUM = GPG_ERR_SYSTEM_ERROR | 85,
- GPG_ERR_ENOMEM = GPG_ERR_SYSTEM_ERROR | 86,
- GPG_ERR_ENOMSG = GPG_ERR_SYSTEM_ERROR | 87,
- GPG_ERR_ENONET = GPG_ERR_SYSTEM_ERROR | 88,
- GPG_ERR_ENOPKG = GPG_ERR_SYSTEM_ERROR | 89,
- GPG_ERR_ENOPROTOOPT = GPG_ERR_SYSTEM_ERROR | 90,
- GPG_ERR_ENOSPC = GPG_ERR_SYSTEM_ERROR | 91,
- GPG_ERR_ENOSR = GPG_ERR_SYSTEM_ERROR | 92,
- GPG_ERR_ENOSTR = GPG_ERR_SYSTEM_ERROR | 93,
- GPG_ERR_ENOSYS = GPG_ERR_SYSTEM_ERROR | 94,
- GPG_ERR_ENOTBLK = GPG_ERR_SYSTEM_ERROR | 95,
- GPG_ERR_ENOTCONN = GPG_ERR_SYSTEM_ERROR | 96,
- GPG_ERR_ENOTDIR = GPG_ERR_SYSTEM_ERROR | 97,
- GPG_ERR_ENOTEMPTY = GPG_ERR_SYSTEM_ERROR | 98,
- GPG_ERR_ENOTNAM = GPG_ERR_SYSTEM_ERROR | 99,
- GPG_ERR_ENOTSOCK = GPG_ERR_SYSTEM_ERROR | 100,
- GPG_ERR_ENOTSUP = GPG_ERR_SYSTEM_ERROR | 101,
- GPG_ERR_ENOTTY = GPG_ERR_SYSTEM_ERROR | 102,
- GPG_ERR_ENOTUNIQ = GPG_ERR_SYSTEM_ERROR | 103,
- GPG_ERR_ENXIO = GPG_ERR_SYSTEM_ERROR | 104,
- GPG_ERR_EOPNOTSUPP = GPG_ERR_SYSTEM_ERROR | 105,
- GPG_ERR_EOVERFLOW = GPG_ERR_SYSTEM_ERROR | 106,
- GPG_ERR_EPERM = GPG_ERR_SYSTEM_ERROR | 107,
- GPG_ERR_EPFNOSUPPORT = GPG_ERR_SYSTEM_ERROR | 108,
- GPG_ERR_EPIPE = GPG_ERR_SYSTEM_ERROR | 109,
- GPG_ERR_EPROCLIM = GPG_ERR_SYSTEM_ERROR | 110,
- GPG_ERR_EPROCUNAVAIL = GPG_ERR_SYSTEM_ERROR | 111,
- GPG_ERR_EPROGMISMATCH = GPG_ERR_SYSTEM_ERROR | 112,
- GPG_ERR_EPROGUNAVAIL = GPG_ERR_SYSTEM_ERROR | 113,
- GPG_ERR_EPROTO = GPG_ERR_SYSTEM_ERROR | 114,
- GPG_ERR_EPROTONOSUPPORT = GPG_ERR_SYSTEM_ERROR | 115,
- GPG_ERR_EPROTOTYPE = GPG_ERR_SYSTEM_ERROR | 116,
- GPG_ERR_ERANGE = GPG_ERR_SYSTEM_ERROR | 117,
- GPG_ERR_EREMCHG = GPG_ERR_SYSTEM_ERROR | 118,
- GPG_ERR_EREMOTE = GPG_ERR_SYSTEM_ERROR | 119,
- GPG_ERR_EREMOTEIO = GPG_ERR_SYSTEM_ERROR | 120,
- GPG_ERR_ERESTART = GPG_ERR_SYSTEM_ERROR | 121,
- GPG_ERR_EROFS = GPG_ERR_SYSTEM_ERROR | 122,
- GPG_ERR_ERPCMISMATCH = GPG_ERR_SYSTEM_ERROR | 123,
- GPG_ERR_ESHUTDOWN = GPG_ERR_SYSTEM_ERROR | 124,
- GPG_ERR_ESOCKTNOSUPPORT = GPG_ERR_SYSTEM_ERROR | 125,
- GPG_ERR_ESPIPE = GPG_ERR_SYSTEM_ERROR | 126,
- GPG_ERR_ESRCH = GPG_ERR_SYSTEM_ERROR | 127,
- GPG_ERR_ESRMNT = GPG_ERR_SYSTEM_ERROR | 128,
- GPG_ERR_ESTALE = GPG_ERR_SYSTEM_ERROR | 129,
- GPG_ERR_ESTRPIPE = GPG_ERR_SYSTEM_ERROR | 130,
- GPG_ERR_ETIME = GPG_ERR_SYSTEM_ERROR | 131,
- GPG_ERR_ETIMEDOUT = GPG_ERR_SYSTEM_ERROR | 132,
- GPG_ERR_ETOOMANYREFS = GPG_ERR_SYSTEM_ERROR | 133,
- GPG_ERR_ETXTBSY = GPG_ERR_SYSTEM_ERROR | 134,
- GPG_ERR_EUCLEAN = GPG_ERR_SYSTEM_ERROR | 135,
- GPG_ERR_EUNATCH = GPG_ERR_SYSTEM_ERROR | 136,
- GPG_ERR_EUSERS = GPG_ERR_SYSTEM_ERROR | 137,
- GPG_ERR_EWOULDBLOCK = GPG_ERR_SYSTEM_ERROR | 138,
- GPG_ERR_EXDEV = GPG_ERR_SYSTEM_ERROR | 139,
- GPG_ERR_EXFULL = GPG_ERR_SYSTEM_ERROR | 140,
-
- /* GPG_SYSTEM_ERROR | (141 to 32767) are free to be used for more
- system errors. */
-
- /* This is one more than the largest allowed entry. */
- GPG_ERR_CODE_DIM = 65536
- } gpg_err_code_t;
-
-
-/* The error value type gpg_error_t. */
-
-/* We would really like to use bit-fields in a struct, but using
- structs as return values can cause binary compatibility issues, in
- particular if you want to do it effeciently (also see
- -freg-struct-return option to GCC). */
-typedef unsigned int gpg_error_t;
-
-/* We use the lowest 16 bits of gpg_error_t for error codes. The 16th
- bit indicates system errors. */
-#define GPG_ERR_CODE_MASK (GPG_ERR_CODE_DIM - 1)
-
-/* Bits 17 to 24 are reserved. */
-
-/* We use the upper 8 bits of gpg_error_t for error sources. */
-#define GPG_ERR_SOURCE_MASK (GPG_ERR_SOURCE_DIM - 1)
-#define GPG_ERR_SOURCE_SHIFT 24
-
-
-/* Constructor and accessor functions. */
-
-/* Construct an error value from an error code and source. Within a
- subsystem, use gpg_error. */
-static GPG_ERR_INLINE gpg_error_t
-gpg_err_make (gpg_err_source_t source, gpg_err_code_t code)
-{
- return code == GPG_ERR_NO_ERROR ? GPG_ERR_NO_ERROR
- : (((source & GPG_ERR_SOURCE_MASK) << GPG_ERR_SOURCE_SHIFT)
- | (code & GPG_ERR_CODE_MASK));
-}
-
-
-/* The user should define GPG_ERR_SOURCE_DEFAULT before including this
- file to specify a default source for gpg_error. */
-#ifndef GPG_ERR_SOURCE_DEFAULT
-#define GPG_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_UNKNOWN
-#endif
-
-static GPG_ERR_INLINE gpg_error_t
-gpg_error (gpg_err_code_t code)
-{
- return gpg_err_make (GPG_ERR_SOURCE_DEFAULT, code);
-}
-
-
-/* Retrieve the error code from an error value. */
-static GPG_ERR_INLINE gpg_err_code_t
-gpg_err_code (gpg_error_t err)
-{
- return (gpg_err_code_t) (err & GPG_ERR_CODE_MASK);
-}
-
-
-/* Retrieve the error source from an error value. */
-static GPG_ERR_INLINE gpg_err_source_t
-gpg_err_source (gpg_error_t err)
-{
- return (gpg_err_source_t) ((err >> GPG_ERR_SOURCE_SHIFT)
- & GPG_ERR_SOURCE_MASK);
-}
-
-
-/* String functions. */
-
-/* Return a pointer to a string containing a description of the error
- code in the error value ERR. This function is not thread-safe. */
-const char *gpg_strerror (gpg_error_t err);
-
-/* Return the error string for ERR in the user-supplied buffer BUF of
- size BUFLEN. This function is, in contrast to gpg_strerror,
- thread-safe if a thread-safe strerror_r() function is provided by
- the system. If the function succeeds, 0 is returned and BUF
- contains the string describing the error. If the buffer was not
- large enough, ERANGE is returned and BUF contains as much of the
- beginning of the error string as fits into the buffer. */
-int gpg_strerror_r (gpg_error_t err, char *buf, size_t buflen);
-
-/* Return a pointer to a string containing a description of the error
- source in the error value ERR. */
-const char *gpg_strsource (gpg_error_t err);
-
-
-/* Mapping of system errors (errno). */
-
-/* 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);
-
-
-/* Retrieve the system error for the error code CODE. This returns 0
- if CODE is not a system error code. */
-int gpg_err_code_to_errno (gpg_err_code_t code);
-
-
-/* Self-documenting convenience functions. */
-
-static GPG_ERR_INLINE gpg_error_t
-gpg_err_make_from_errno (gpg_err_source_t source, int err)
-{
- return gpg_err_make (source, gpg_err_code_from_errno (err));
-}
-
-
-static GPG_ERR_INLINE gpg_error_t
-gpg_error_from_errno (int err)
-{
- return gpg_error (gpg_err_code_from_errno (err));
-}
-
-#endif /* GPG_ERROR_H */
diff --git a/src/gpg-error.h.in b/src/gpg-error.h.in
new file mode 100644
index 0000000..b97874d
--- /dev/null
+++ b/src/gpg-error.h.in
@@ -0,0 +1,200 @@
+/* gpg-error.h - Public interface to libgpg-error.
+ Copyright (C) 2003, 2004 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 libgpg-error; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+#ifndef GPG_ERROR_H
+#define GPG_ERROR_H 1
+
+#include <stddef.h>
+
+#ifdef __GNUC__
+#define GPG_ERR_INLINE __inline__
+#elif __STDC_VERSION__ >= 199901L
+#define GPG_ERR_INLINE inline
+#else
+#ifndef GPG_ERR_INLINE
+#define GPG_ERR_INLINE
+#endif
+#endif
+
+/* The GnuPG project consists of many components. Error codes are
+ exchanged between all components. The common error codes and their
+ user-presentable descriptions are kept into a shared library to
+ allow adding new error codes and components without recompiling any
+ of the other components. The interface will not change in a
+ backward incompatible way.
+
+ An error code together with an error source build up an error
+ value. As the error value is been passed from one component to
+ another, it preserver the information about the source and nature
+ of the error.
+
+ A component of the GnuPG project can define the following macro to
+ tune the behaviour of the library:
+
+ GPG_ERR_SOURCE_DEFAULT: Define to an error source of type
+ gpg_err_source_t to make that source the default for gpg_error().
+ Otherwise GPG_ERR_SOURCE_UNKNOWN is used as default. */
+
+
+/* The error source type gpg_err_source_t.
+
+ Where as the Poo out of a welle small
+ Taketh his firste springing and his sours.
+ --Chaucer. */
+
+/* Only use free slots, never change or reorder the existing
+ entries. */
+typedef enum
+ {
+@include err-sources.h.in
+
+ /* This is one more than the largest allowed entry. */
+ GPG_ERR_SOURCE_DIM = 256
+ } gpg_err_source_t;
+
+
+/* The error code type gpg_err_code_t. */
+
+/* Only use free slots, never change or reorder the existing
+ entries. */
+typedef enum
+ {
+@include err-codes.h.in
+
+ /* The following error codes are used to map system errors. */
+#define GPG_ERR_SYSTEM_ERROR (1 << 15)
+@include errnos.in
+
+ /* This is one more than the largest allowed entry. */
+ GPG_ERR_CODE_DIM = 65536
+ } gpg_err_code_t;
+
+
+/* The error value type gpg_error_t. */
+
+/* We would really like to use bit-fields in a struct, but using
+ structs as return values can cause binary compatibility issues, in
+ particular if you want to do it effeciently (also see
+ -freg-struct-return option to GCC). */
+typedef unsigned int gpg_error_t;
+
+/* We use the lowest 16 bits of gpg_error_t for error codes. The 16th
+ bit indicates system errors. */
+#define GPG_ERR_CODE_MASK (GPG_ERR_CODE_DIM - 1)
+
+/* Bits 17 to 24 are reserved. */
+
+/* We use the upper 8 bits of gpg_error_t for error sources. */
+#define GPG_ERR_SOURCE_MASK (GPG_ERR_SOURCE_DIM - 1)
+#define GPG_ERR_SOURCE_SHIFT 24
+
+
+/* Constructor and accessor functions. */
+
+/* Construct an error value from an error code and source. Within a
+ subsystem, use gpg_error. */
+static GPG_ERR_INLINE gpg_error_t
+gpg_err_make (gpg_err_source_t source, gpg_err_code_t code)
+{
+ return code == GPG_ERR_NO_ERROR ? GPG_ERR_NO_ERROR
+ : (((source & GPG_ERR_SOURCE_MASK) << GPG_ERR_SOURCE_SHIFT)
+ | (code & GPG_ERR_CODE_MASK));
+}
+
+
+/* The user should define GPG_ERR_SOURCE_DEFAULT before including this
+ file to specify a default source for gpg_error. */
+#ifndef GPG_ERR_SOURCE_DEFAULT
+#define GPG_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_UNKNOWN
+#endif
+
+static GPG_ERR_INLINE gpg_error_t
+gpg_error (gpg_err_code_t code)
+{
+ return gpg_err_make (GPG_ERR_SOURCE_DEFAULT, code);
+}
+
+
+/* Retrieve the error code from an error value. */
+static GPG_ERR_INLINE gpg_err_code_t
+gpg_err_code (gpg_error_t err)
+{
+ return (gpg_err_code_t) (err & GPG_ERR_CODE_MASK);
+}
+
+
+/* Retrieve the error source from an error value. */
+static GPG_ERR_INLINE gpg_err_source_t
+gpg_err_source (gpg_error_t err)
+{
+ return (gpg_err_source_t) ((err >> GPG_ERR_SOURCE_SHIFT)
+ & GPG_ERR_SOURCE_MASK);
+}
+
+
+/* String functions. */
+
+/* Return a pointer to a string containing a description of the error
+ code in the error value ERR. This function is not thread-safe. */
+const char *gpg_strerror (gpg_error_t err);
+
+/* Return the error string for ERR in the user-supplied buffer BUF of
+ size BUFLEN. This function is, in contrast to gpg_strerror,
+ thread-safe if a thread-safe strerror_r() function is provided by
+ the system. If the function succeeds, 0 is returned and BUF
+ contains the string describing the error. If the buffer was not
+ large enough, ERANGE is returned and BUF contains as much of the
+ beginning of the error string as fits into the buffer. */
+int gpg_strerror_r (gpg_error_t err, char *buf, size_t buflen);
+
+/* Return a pointer to a string containing a description of the error
+ source in the error value ERR. */
+const char *gpg_strsource (gpg_error_t err);
+
+
+/* Mapping of system errors (errno). */
+
+/* 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);
+
+
+/* Retrieve the system error for the error code CODE. This returns 0
+ if CODE is not a system error code. */
+int gpg_err_code_to_errno (gpg_err_code_t code);
+
+
+/* Self-documenting convenience functions. */
+
+static GPG_ERR_INLINE gpg_error_t
+gpg_err_make_from_errno (gpg_err_source_t source, int err)
+{
+ return gpg_err_make (source, gpg_err_code_from_errno (err));
+}
+
+
+static GPG_ERR_INLINE gpg_error_t
+gpg_error_from_errno (int err)
+{
+ return gpg_error (gpg_err_code_from_errno (err));
+}
+
+#endif /* GPG_ERROR_H */
diff --git a/src/mkerrcodes1.awk b/src/mkerrcodes1.awk
index 6248d24..3e92636 100644
--- a/src/mkerrcodes1.awk
+++ b/src/mkerrcodes1.awk
@@ -1,5 +1,5 @@
# mkerrcodes.awk
-# Copyright (C) 2003 g10 Code GmbH
+# Copyright (C) 2003, 2004 g10 Code GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
@@ -48,21 +48,26 @@
# EINVAL GPG_ERR_EINVAL
# #endif
#
-# The input file is a list of possible system errors.
+# The input file is a list of possible system errors in the column errnoidx
+# (defaults to 2).
#
# Comments (starting with # and ending at the end of the line) are removed,
# as is trailing whitespace.
BEGIN {
+ FS="[\t]+";
+ header = 1;
+ if (errnoidx == 0)
+ errnoidx = 2;
+
print "/* Output of mkerrcodes.awk. DO NOT EDIT. */";
print "";
- header = 1;
}
/^#/ { next; }
header {
- if ($1 ~ /^E/)
+ if ($1 ~ /^[0-9]/)
{
print "#include <errno.h>";
print "";
@@ -79,7 +84,7 @@ header {
if (/^$/)
next;
- print "#ifdef " $1;
- print $1 " GPG_ERR_" $1;
+ print "#ifdef " $errnoidx;
+ print $errnoidx "\tGPG_ERR_" $errnoidx;
print "#endif";
}
diff --git a/src/mkerrnos.awk b/src/mkerrnos.awk
index 16c23b1..c4bbf81 100644
--- a/src/mkerrnos.awk
+++ b/src/mkerrnos.awk
@@ -1,5 +1,5 @@
# mkerrnos.awk
-# Copyright (C) 2003 g10 Code GmbH
+# Copyright (C) 2003, 2004 g10 Code GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
@@ -49,21 +49,26 @@
# error code in the table can be obtained after removing the system error
# code indication bit.
#
-# The input file is a list of possible system errors.
+# The input file is a list of possible system errors in the column errnoidx
+# (defaults to 2).
#
# Comments (starting with # and ending at the end of the line) are removed,
# as is trailing whitespace.
BEGIN {
+ FS="[\t]+";
+ header = 1;
+ if (errnoidx == 0)
+ errnoidx = 2;
+
print "/* Output of mkerrnos.awk. DO NOT EDIT. */";
print "";
- header = 1;
}
/^#/ { next; }
header {
- if ($1 ~ /^E/)
+ if ($1 ~ /^[0-9]/)
{
print "#include <errno.h>";
print "";
@@ -81,8 +86,8 @@ header {
if (/^$/)
next;
- print "#ifdef " $1;
- print " " $1 ",";
+ print "#ifdef " $errnoidx;
+ print " " $errnoidx ",";
print "#else";
print " 0,";
print "#endif";
diff --git a/src/mkheader.awk b/src/mkheader.awk
new file mode 100644
index 0000000..67de05d
--- /dev/null
+++ b/src/mkheader.awk
@@ -0,0 +1,190 @@
+# mkheader.awk
+# Copyright (C) 2003, 2004 g10 Code GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program 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
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+#
+# As a special exception, g10 Code GmbH gives unlimited permission to
+# copy, distribute and modify the C source files that are the output
+# of mkheader.awk. You need not follow the terms of the GNU General
+# Public License when using or distributing such scripts, even though
+# portions of the text of mkheader.awk appear in them. The GNU
+# General Public License (GPL) does govern all other use of the material
+# that constitutes the mkheader.awk program.
+#
+# Certain portions of the mkheader.awk source text are designed to be
+# copied (in certain cases, depending on the input) into the output of
+# mkheader.awk. We call these the "data" portions. The rest of the
+# mkheader.awk source text consists of comments plus executable code
+# that decides which of the data portions to output in any given case.
+# We call these comments and executable code the "non-data" portions.
+# mkheader.h never copies any of the non-data portions into its output.
+#
+# This special exception to the GPL applies to versions of mkheader.awk
+# released by g10 Code GmbH. When you make and distribute a modified version
+# of mkheader.awk, you may extend this special exception to the GPL to
+# apply to your modified version as well, *unless* your modified version
+# has the potential to copy into its output some of the text that was the
+# non-data portion of the version that you started with. (In other words,
+# unless your change moves or copies text from the non-data portions to the
+# data portions.) If your modification has such potential, you must delete
+# any notice of this special exception to the GPL from your modified version.
+
+# This script processes gpg-error.h.in in an awful way.
+# Its input is, one after another, the content of the err-sources.h.in file,
+# the err-codes.h.in file, the errnos.in file, and then gpg-error.h.in.
+# There is nothing fancy about this.
+#
+# An alternative would be to use getline to get the content of the first three files,
+# but then we need to pre-process gpg-error.h.in with configure to get
+# at the full path of the files in @srcdir@.
+
+BEGIN {
+ FS = "[\t]+";
+# sources_nr holds the number of error sources.
+ sources_nr = 0;
+# codes_nr holds the number of error codes.
+ codes_nr = 0;
+# errnos_nr holds the number of system errors.
+ errnos_nr = 0;
+
+# These variables walk us through our input.
+ sources_header = 1;
+ sources_body = 0;
+ between_sources_and_codes = 0;
+ codes_body = 0;
+ between_codes_and_errnos = 0;
+ errnos_body = 0;
+ gpg_error_h = 0;
+
+ print "/* Output of mkheader.awk. DO NOT EDIT. */";
+ print "";
+
+}
+
+sources_header {
+ if ($1 ~ /^[0123456789]+$/)
+ {
+ sources_header = 0;
+ sources_body = 1;
+ }
+}
+
+sources_body {
+ sub (/\#.+/, "");
+ sub (/[ ]+$/, ""); # Strip trailing space and tab characters.
+
+ if (/^$/)
+ next;
+
+ if ($1 == "")
+ {
+ sources_body = 0;
+ between_sources_and_codes = 1;
+ }
+ else
+ {
+# Remember the error source number and symbol of each error source.
+ sources_idx[sources_nr] = $1;
+ sources_sym[sources_nr] = $2;
+ sources_nr++;
+ }
+}
+
+between_sources_and_codes {
+ if ($1 ~ /^[0123456789]+$/)
+ {
+ between_sources_and_codes = 0;
+ codes_body = 1;
+ }
+}
+
+codes_body {
+ sub (/\#.+/, "");
+ sub (/[ ]+$/, ""); # Strip trailing space and tab characters.
+
+ if (/^$/)
+ next;
+
+ if ($1 == "")
+ {
+ codes_body = 0;
+ between_codes_and_errnos = 1;
+ }
+ else
+ {
+# Remember the error code number and symbol of each error source.
+ codes_idx[codes_nr] = $1;
+ codes_sym[codes_nr] = $2;
+ codes_nr++;
+ }
+}
+
+between_codes_and_errnos {
+ if ($1 ~ /^[0-9]/)
+ {
+ between_codes_and_errnos = 0;
+ errnos_body = 1;
+ }
+}
+
+errnos_body {
+ sub (/\#.+/, "");
+ sub (/[ ]+$/, ""); # Strip trailing space and tab characters.
+
+ if (/^$/)
+ next;
+
+ if ($1 !~ /^[0-9]/)
+ {
+# Note that this assumes that gpg-error.h.in doesn't start with a digit.
+ errnos_body = 0;
+ gpg_error_h = 1;
+ }
+ else
+ {
+ errnos_idx[errnos_nr] = "GPG_ERR_SYSTEM_ERROR | " $1;
+ errnos_sym[errnos_nr] = "GPG_ERR_" $2;
+ errnos_nr++;
+ }
+}
+
+gpg_error_h {
+ if ($0 ~ /^@include err-sources/)
+ {
+ for (i = 0; i < sources_nr; i++)
+ {
+ print " " sources_sym[i] " = " sources_idx[i] ",";
+# print "#define " sources_sym[i] " (" sources_idx[i] ")";
+ }
+ }
+ else if ($0 ~ /^@include err-codes/)
+ {
+ for (i = 0; i < codes_nr; i++)
+ {
+ print " " codes_sym[i] " = " codes_idx[i] ",";
+# print "#define " codes_sym[i] " (" codes_idx[i] ")";
+ }
+ }
+ else if ($0 ~ /^@include errnos/)
+ {
+ for (i = 0; i < errnos_nr; i++)
+ {
+ print " " errnos_sym[i] " = " errnos_idx[i] ",";
+# print "#define " errnos_sym[i] " (" errnos_idx[i] ")";
+ }
+ }
+ else
+ print;
+}
diff --git a/src/mkstrtable.awk b/src/mkstrtable.awk
index 33098a0..31eb121 100644
--- a/src/mkstrtable.awk
+++ b/src/mkstrtable.awk
@@ -1,5 +1,5 @@
# mkstrtable.awk
-# Copyright (C) 2003 g10 Code GmbH
+# Copyright (C) 2003, 2004 g10 Code GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
@@ -59,19 +59,29 @@
# msgstr + msgidx[msgidxof (code)].
#
# The input file has the following format:
-# CODE1 MESSAGE1 (Code number, <tab>, message string)
-# CODE2 MESSAGE2 (Code number, <tab>, message string)
+# CODE1 ... MESSAGE1 (code nr, <tab>, something, <tab>, msg)
+# CODE2 ... MESSAGE2 (code nr, <tab>, something, <tab>, msg)
# ...
-# CODEn MESSAGEn (Code number, <tab>, message string)
-# DEFAULT MESSAGE (<tab>, fall-back message string)
+# CODEn ... MESSAGEn (code nr, <tab>, something, <tab>, msg)
+# ... DEFAULT-MESSAGE (<tab>, something, <tab>, fall-back msg)
#
# Comments (starting with # and ending at the end of the line) are removed,
# as is trailing whitespace. The last line is optional; if no DEFAULT
# MESSAGE is given, msgidxof will return the number -1 for unknown
# index numbers.
+#
+# The field to be used is specified with the variable "textidx" on
+# the command line. It defaults to 2.
+#
+# The variable nogettext can be set to 1 to suppress gettext markers.
+#
+# The variable prefix can be used to prepend a string to each message.
+#
+# The variable namespace can be used to prepend a string to each
+# variable and macro name.
BEGIN {
- FS = "\t";
+ FS = "[\t]+";
# cpos holds the current position in the message string.
cpos = 0;
# msg holds the number of messages.
@@ -79,6 +89,9 @@ BEGIN {
print "/* Output of mkstrtable.awk. DO NOT EDIT. */";
print "";
header = 1;
+ if (textidx == 0)
+ textidx = 2;
+# nogettext can be set to 1 to suppress gettext noop markers.
}
/^#/ { next; }
@@ -89,7 +102,7 @@ header {
print "/* The purpose of this complex string table is to produce";
print " optimal code with a minimum of relocations. */";
print "";
- print "static const char msgstr[] = ";
+ print "static const char " namespace "msgstr[] = ";
header = 0;
}
else
@@ -106,13 +119,18 @@ header {
# Print the string msgstr line by line. We delay output by one line to be able
# to treat the last line differently (see END).
if (last_msgstr)
- print " gettext_noop (\"" last_msgstr "\") \"\\0\"";
- last_msgstr = $2;
+ {
+ if (nogettext)
+ print " \"" last_msgstr "\" \"\\0\"";
+ else
+ print " gettext_noop (\"" last_msgstr "\") \"\\0\"";
+ }
+ last_msgstr = prefix $textidx;
# Remember the error code and msgidx of each error message.
code[msg] = $1;
pos[msg] = cpos;
- cpos += length ($2) + 1;
+ cpos += length (last_msgstr) + 1;
msg++;
if ($1 == "")
@@ -127,16 +145,19 @@ END {
else
coded_msgs = msg;
- print " gettext_noop (\"" last_msgstr "\");";
+ if (nogettext)
+ print " \"" prefix last_msgstr "\";";
+ else
+ print " gettext_noop (\"" prefix last_msgstr "\");";
print "";
- print "static const int msgidx[] =";
+ print "static const int " namespace "msgidx[] =";
print " {";
for (i = 0; i < coded_msgs; i++)
print " " pos[i] ",";
print " " pos[coded_msgs];
print " };";
print "";
- print "#define msgidxof(code) (0 ? -1 \\";
+ print "#define " namespace "msgidxof(code) (0 ? -1 \\";
# Gather the ranges.
skip = code[0];
diff --git a/src/strerror-sym.c b/src/strerror-sym.c
new file mode 100644
index 0000000..3d79f40
--- /dev/null
+++ b/src/strerror-sym.c
@@ -0,0 +1,56 @@
+/* strerror-sym.c - Describing an error code with its symbol name.
+ Copyright (C) 2003, 2004 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 libgpg-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 <stddef.h>
+
+#include <gpg-error.h>
+
+#include "err-codes-sym.h"
+#include "errnos-sym.h"
+
+/* Return a pointer to a string containing the name of the symbol of
+ the error code in the error value ERR. Returns NULL if the error
+ code is not known. */
+const char *
+gpg_strerror_sym (gpg_error_t err)
+{
+ gpg_err_code_t code = gpg_err_code (err);
+
+ if (code & GPG_ERR_SYSTEM_ERROR)
+ {
+ int idx;
+
+ code &= ~GPG_ERR_SYSTEM_ERROR;
+ idx = errnos_msgidxof (code);
+ if (idx >= 0)
+ return errnos_msgstr + errnos_msgidx[idx];
+ else
+ return NULL;
+ }
+
+ if (msgidxof (code) == msgidxof (GPG_ERR_CODE_DIM))
+ return NULL;
+
+ return msgstr + msgidx[msgidxof (code)];
+}
diff --git a/src/strsource-sym.c b/src/strsource-sym.c
new file mode 100644
index 0000000..a191310
--- /dev/null
+++ b/src/strsource-sym.c
@@ -0,0 +1,43 @@
+/* strsource-sym.c - Describing an error source with its symbol name.
+ Copyright (C) 2003, 2004 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 libgpg-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 <stddef.h>
+
+#include <gpg-error.h>
+
+#include "err-sources-sym.h"
+
+/* Return a pointer to a string containing the name of the symbol of
+ the error source in the error value ERR. Returns NULL if the error
+ code is not known. */
+const char *
+gpg_strsource_sym (gpg_error_t err)
+{
+ gpg_err_source_t source = gpg_err_source (err);
+
+ if (msgidxof (source) == msgidxof (GPG_ERR_SOURCE_DIM))
+ return NULL;
+
+ return msgstr + msgidx[msgidxof (source)];
+}