From 460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- libkdenetwork/libgpg-error-copy/Makefile.am | 87 +++++++ libkdenetwork/libgpg-error-copy/code-from-errno.c | 69 ++++++ libkdenetwork/libgpg-error-copy/code-to-errno.c | 42 ++++ libkdenetwork/libgpg-error-copy/err-codes.h.in | 289 ++++++++++++++++++++++ libkdenetwork/libgpg-error-copy/err-sources.h.in | 55 ++++ libkdenetwork/libgpg-error-copy/errnos.in | 172 +++++++++++++ libkdenetwork/libgpg-error-copy/gettext.h | 75 ++++++ libkdenetwork/libgpg-error-copy/gpg-error.h.in | 258 +++++++++++++++++++ libkdenetwork/libgpg-error-copy/mkerrcodes.awk | 99 ++++++++ libkdenetwork/libgpg-error-copy/mkerrcodes.c | 78 ++++++ libkdenetwork/libgpg-error-copy/mkerrcodes1.awk | 90 +++++++ libkdenetwork/libgpg-error-copy/mkerrcodes2.awk | 134 ++++++++++ libkdenetwork/libgpg-error-copy/mkerrnos.awk | 97 ++++++++ libkdenetwork/libgpg-error-copy/mkheader.awk | 190 ++++++++++++++ libkdenetwork/libgpg-error-copy/mkstrtable.awk | 186 ++++++++++++++ libkdenetwork/libgpg-error-copy/strerror.c | 169 +++++++++++++ libkdenetwork/libgpg-error-copy/strsource.c | 37 +++ 17 files changed, 2127 insertions(+) create mode 100644 libkdenetwork/libgpg-error-copy/Makefile.am create mode 100644 libkdenetwork/libgpg-error-copy/code-from-errno.c create mode 100644 libkdenetwork/libgpg-error-copy/code-to-errno.c create mode 100644 libkdenetwork/libgpg-error-copy/err-codes.h.in create mode 100644 libkdenetwork/libgpg-error-copy/err-sources.h.in create mode 100644 libkdenetwork/libgpg-error-copy/errnos.in create mode 100644 libkdenetwork/libgpg-error-copy/gettext.h create mode 100644 libkdenetwork/libgpg-error-copy/gpg-error.h.in create mode 100644 libkdenetwork/libgpg-error-copy/mkerrcodes.awk create mode 100644 libkdenetwork/libgpg-error-copy/mkerrcodes.c create mode 100644 libkdenetwork/libgpg-error-copy/mkerrcodes1.awk create mode 100644 libkdenetwork/libgpg-error-copy/mkerrcodes2.awk create mode 100644 libkdenetwork/libgpg-error-copy/mkerrnos.awk create mode 100644 libkdenetwork/libgpg-error-copy/mkheader.awk create mode 100644 libkdenetwork/libgpg-error-copy/mkstrtable.awk create mode 100644 libkdenetwork/libgpg-error-copy/strerror.c create mode 100644 libkdenetwork/libgpg-error-copy/strsource.c (limited to 'libkdenetwork/libgpg-error-copy') diff --git a/libkdenetwork/libgpg-error-copy/Makefile.am b/libkdenetwork/libgpg-error-copy/Makefile.am new file mode 100644 index 000000000..5f3ed9e6f --- /dev/null +++ b/libkdenetwork/libgpg-error-copy/Makefile.am @@ -0,0 +1,87 @@ +# Makefile.am for 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 this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +# We distribute the generated sources err-sources.h and err-codes.h, +# because they are needed to build the po directory, and they don't +# 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 \ +# err-sources.h err-codes.h 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 gpg-error.h mkerrcodes.h mkerrcodes + +#bin_SCRIPTS = gpg-error-config +#m4datadir = $(datadir)/aclocal +#m4data_DATA = gpg-error.m4 +# +#include_HEADERS = gpg-error.h + +noinst_LTLIBRARIES = libgpg-error.la + +#libgpg_error_la_LDFLAGS = -version-info @LIBGPG_ERROR_LT_CURRENT@:@LIBGPG_ERROR_LT_REVISION@:@LIBGPG_ERROR_LT_AGE@ + +libgpg_error_la_SOURCES = strsource.c strerror.c code-to-errno.c code-from-errno.c + +#libgpg_error_la_LIBADD = @LTLIBINTL@ + +#We don't need the gpg-error command-line tool + +# Dependencies on generated files. +strsource.lo: err-sources.h gpg-error.h +strerror.lo: err-codes.h gpg-error.h +code-to-errno.lo: code-to-errno.h gpg-error.h +code-from-errno.lo: code-from-errno.h gpg-error.h + +err-sources.h: $(srcdir)/mkstrtable.awk $(srcdir)/err-sources.h.in + $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=3 \ + $(srcdir)/err-sources.h.in >$@ + +#We don't need err-sources-sym.h, err-codes-sym.h, errnos-sym.h. +# since those are for the gpg-error binary + +err-codes.h: $(srcdir)/mkstrtable.awk err-codes.h.in + $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=3 \ + $(srcdir)/err-codes.h.in >$@ + +code-to-errno.h: mkerrnos.awk errnos.in + $(AWK) -f $(srcdir)/mkerrnos.awk $(srcdir)/errnos.in >$@ + +# It is correct to use $(CPP). We want the host's idea of the error codes. +mkerrcodes.h: mkerrcodes.awk + $(AWK) -f $(srcdir)/mkerrcodes1.awk $(srcdir)/errnos.in \ + | $(CPP) - | grep GPG_ERR_ | $(AWK) -f $(srcdir)/mkerrcodes.awk >$@ + +# It is correct to use $(CC_FOR_BUILD) here. We want to run the +# program at build time. +# DF: we have no such thing in KDE. Using $(CC) instead. +mkerrcodes: mkerrcodes.c mkerrcodes.h + $(CC) -I. -I$(srcdir) -o $@ $(srcdir)/mkerrcodes.c + +code-from-errno.h: mkerrcodes + ./mkerrcodes | $(AWK) -f $(srcdir)/mkerrcodes2.awk > $@ + +gpg-error.h: 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 > $@ + +# Removed all dependencies on Makefiles, since for us Makefile is in builddir. diff --git a/libkdenetwork/libgpg-error-copy/code-from-errno.c b/libkdenetwork/libgpg-error-copy/code-from-errno.c new file mode 100644 index 000000000..96fcf2086 --- /dev/null +++ b/libkdenetwork/libgpg-error-copy/code-from-errno.c @@ -0,0 +1,69 @@ +/* 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 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 +#endif + +#include + +#include + +#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; + + if (!err) + return GPG_ERR_NO_ERROR; + + idx = errno_to_idx (err); + + if (idx < 0) + return GPG_ERR_UNKNOWN_ERRNO; + + return GPG_ERR_SYSTEM_ERROR | err_code_from_index[idx]; +} + + +/* Retrieve the error code directly from the ERRNO variable. This + returns GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped + (report this) and GPG_ERR_MISSING_ERRNO if ERRNO has the value 0. */ +gpg_err_code_t +gpg_err_code_from_syserror (void) +{ + int err = errno; + int idx; + + if (!err) + return GPG_ERR_MISSING_ERRNO; + + idx = errno_to_idx (err); + + if (idx < 0) + return GPG_ERR_UNKNOWN_ERRNO; + + return GPG_ERR_SYSTEM_ERROR | err_code_from_index[idx]; +} diff --git a/libkdenetwork/libgpg-error-copy/code-to-errno.c b/libkdenetwork/libgpg-error-copy/code-to-errno.c new file mode 100644 index 000000000..5873aad63 --- /dev/null +++ b/libkdenetwork/libgpg-error-copy/code-to-errno.c @@ -0,0 +1,42 @@ +/* code-to-errno.c - Mapping error codes to errnos. + 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 +#endif + +#include + +#include "code-to-errno.h" + +/* 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) +{ + if (!(code & GPG_ERR_SYSTEM_ERROR)) + return 0; + code &= ~GPG_ERR_SYSTEM_ERROR; + + if (code < sizeof (err_code_to_errno) / sizeof (err_code_to_errno[0])) + return err_code_to_errno[code]; + else + return 0; +} diff --git a/libkdenetwork/libgpg-error-copy/err-codes.h.in b/libkdenetwork/libgpg-error-copy/err-codes.h.in new file mode 100644 index 000000000..5ccf0bc00 --- /dev/null +++ b/libkdenetwork/libgpg-error-copy/err-codes.h.in @@ -0,0 +1,289 @@ +# 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, 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. */ + +# 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 characters, followed by the error code symbol, +# followed by one or more 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 , +# followed by a dummy field, followed by a , followed by a +# description for error codes that are not in the list. + +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 Unspecific Assuan server fault +81 GPG_ERR_ASSUAN General 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 required +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 GPG_ERR_PROTOCOL_VIOLATION Protocol violation +169 GPG_ERR_INV_MAC Invalid MAC +170 GPG_ERR_INV_REQUEST Invalid request +171 GPG_ERR_UNKNOWN_EXTN Unknown extension +172 GPG_ERR_UNKNOWN_CRIT_EXTN Unknown critical extension +173 GPG_ERR_LOCKED Locked +174 GPG_ERR_UNKNOWN_OPTION Unknown option +175 GPG_ERR_UNKNOWN_COMMAND Unknown command +# 176 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 254 are free to be used. 255 and 256 are RFU. + +# Error codes pertaining to the Assuan IPC interface +257 GPG_ERR_ASS_GENERAL General IPC error +258 GPG_ERR_ASS_ACCEPT_FAILED IPC accept call failed +259 GPG_ERR_ASS_CONNECT_FAILED IPC connect call failed +260 GPG_ERR_ASS_INV_RESPONSE Invalid IPC response +261 GPG_ERR_ASS_INV_VALUE Invalid value passed to IPC +262 GPG_ERR_ASS_INCOMPLETE_LINE Incomplete line passed to IPC +263 GPG_ERR_ASS_LINE_TOO_LONG Line passed to IPC too long +264 GPG_ERR_ASS_NESTED_COMMANDS Nested IPC commands +265 GPG_ERR_ASS_NO_DATA_CB No data callback in IPC +266 GPG_ERR_ASS_NO_INQUIRE_CB No inquire callback in IPC +267 GPG_ERR_ASS_NOT_A_SERVER Not an IPC server +268 GPG_ERR_ASS_NOT_A_CLIENT Not an IPC client +269 GPG_ERR_ASS_SERVER_START Problem starting IPC server +270 GPG_ERR_ASS_READ_ERROR IPC read error +271 GPG_ERR_ASS_WRITE_ERROR IPC write error +# reserved +273 GPG_ERR_ASS_TOO_MUCH_DATA Too much data for IPC layer +274 GPG_ERR_ASS_UNEXPECTED_CMD Unexpected IPC command +275 GPG_ERR_ASS_UNKNOWN_CMD Unknown IPC command +276 GPG_ERR_ASS_SYNTAX IPC syntax error +277 GPG_ERR_ASS_CANCELED IPC call has been cancelled +278 GPG_ERR_ASS_NO_INPUT No input source for IPC +279 GPG_ERR_ASS_NO_OUTPUT No output source for IPC +280 GPG_ERR_ASS_PARAMETER IPC parameter error +281 GPG_ERR_ASS_UNKNOWN_INQUIRE Unknown IPC inquire + +# 282 to 299 are reserved for future assuan codes. + +# 300 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 16380 are free to be used. + +16381 GPG_ERR_MISSING_ERRNO System error w/o errno +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/libkdenetwork/libgpg-error-copy/err-sources.h.in b/libkdenetwork/libgpg-error-copy/err-sources.h.in new file mode 100644 index 000000000..d6182a50d --- /dev/null +++ b/libkdenetwork/libgpg-error-copy/err-sources.h.in @@ -0,0 +1,55 @@ +# 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, 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. */ + +# 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 source number, followed +# by one or more characters, followed by the error source +# symbol, followed by one or more 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 , 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 GPG_ERR_SOURCE_GSTI GSTI + +# 11 to 30 are free to be used. + +31 GPG_ERR_SOURCE_ANY Any source +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/libkdenetwork/libgpg-error-copy/errnos.in b/libkdenetwork/libgpg-error-copy/errnos.in new file mode 100644 index 000000000..1c703b86f --- /dev/null +++ b/libkdenetwork/libgpg-error-copy/errnos.in @@ -0,0 +1,172 @@ +# errnos.h.in - List of system error values input file. +/* errnos.h - List of system error values. + 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. */ + +# 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 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. + + +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/libkdenetwork/libgpg-error-copy/gettext.h b/libkdenetwork/libgpg-error-copy/gettext.h new file mode 100644 index 000000000..5adda4605 --- /dev/null +++ b/libkdenetwork/libgpg-error-copy/gettext.h @@ -0,0 +1,75 @@ +/* Convenience header for conditional use of GNU . + Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published + by the Free Software Foundation; either version 2, 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library 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. */ + +#ifndef _LIBGETTEXT_H +#define _LIBGETTEXT_H 1 + +/* NLS can be disabled through the configure --disable-nls option. */ +#if ENABLE_NLS + +#if HAVE_W32_SYSTEM +/* Redirect the gettext calls to an internal implementation on W32 + targets. */ +# include "w32-gettext.h" +#else +/* Get declarations of GNU message catalog functions. */ +# include +#endif + +#else + +/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which + chokes if dcgettext is defined as a macro. So include it now, to make + later inclusions of a NOP. We don't include + as well because people using "gettext.h" will not include , + and also including would fail on SunOS 4, whereas + is OK. */ +#if defined(__sun) +# include +#endif + +/* Disabled NLS. + The casts to 'const char *' serve the purpose of producing warnings + for invalid uses of the value returned from these functions. + On pre-ANSI systems without 'const', the config.h file is supposed to + contain "#define const". */ +# define gettext(Msgid) ((const char *) (Msgid)) +# define dgettext(Domainname, Msgid) ((const char *) (Msgid)) +# define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid)) +# define ngettext(Msgid1, Msgid2, N) \ + ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) +# define dngettext(Domainname, Msgid1, Msgid2, N) \ + ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) +# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \ + ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) +# define textdomain(Domainname) ((const char *) (Domainname)) +# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname)) +# define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset)) + +#endif + +/* A pseudo function call that serves as a marker for the automated + extraction of messages, but does not call gettext(). The run-time + translation is done at a different place in the code. + The argument, String, should be a literal string. Concatenated strings + and other string expressions won't work. + The macro's expansion is not parenthesized, so that it is suitable as + initializer for static 'char[]' or 'const char[]' variables. */ +#define gettext_noop(String) String + +#endif /* _LIBGETTEXT_H */ diff --git a/libkdenetwork/libgpg-error-copy/gpg-error.h.in b/libkdenetwork/libgpg-error-copy/gpg-error.h.in new file mode 100644 index 000000000..46325c5d3 --- /dev/null +++ b/libkdenetwork/libgpg-error-copy/gpg-error.h.in @@ -0,0 +1,258 @@ +/* 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 + +#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 + + +#ifdef __cplusplus +extern "C" { +#if 0 /* just to make Emacs auto-indent happy */ +} +#endif +#endif /* __cplusplus */ + +/* 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 + + +/* GCC feature test. */ +#undef _GPG_ERR_HAVE_CONSTRUCTOR +#if __GNUC__ +#define _GPG_ERR_GCC_VERSION (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) + +#if _GPG_ERR_GCC_VERSION > 30100 +#define _GPG_ERR_CONSTRUCTOR __attribute__ ((__constructor__)) +#define _GPG_ERR_HAVE_CONSTRUCTOR +#endif +#endif + +#ifndef _GPG_ERR_CONSTRUCTOR +#define _GPG_ERR_CONSTRUCTOR +#endif + + +/* Initialization function. */ + +/* Initialize the library. This function should be run early. */ +gpg_error_t gpg_err_init (void) _GPG_ERR_CONSTRUCTOR; + +/* If this is defined, the library is already initialized by the + constructor and does not need to be initialized explicitely. */ +#undef GPG_ERR_INITIALIZED +#ifdef _GPG_ERR_HAVE_CONSTRUCTOR +#define GPG_ERR_INITIALIZED 1 +#endif + + +/* 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); + + +/* Retrieve the error code directly from the ERRNO variable. This + returns GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped + (report this) and GPG_ERR_MISSING_ERRNO if ERRNO has the value 0. */ +gpg_err_code_t gpg_err_code_from_syserror (void); + + + + +/* 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)); +} + +static GPG_ERR_INLINE gpg_error_t +gpg_error_from_syserror (void) +{ + return gpg_error (gpg_err_code_from_syserror ()); +} + +#ifdef __cplusplus +} +#endif + + +#endif /* GPG_ERROR_H */ diff --git a/libkdenetwork/libgpg-error-copy/mkerrcodes.awk b/libkdenetwork/libgpg-error-copy/mkerrcodes.awk new file mode 100644 index 000000000..46d436c6b --- /dev/null +++ b/libkdenetwork/libgpg-error-copy/mkerrcodes.awk @@ -0,0 +1,99 @@ +# mkerrcodes.awk +# Copyright (C) 2004, 2005 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 mkerrcodes.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 mkerrcodes.awk appear in them. The GNU +# General Public License (GPL) does govern all other use of the material +# that constitutes the mkerrcodes.awk program. +# +# Certain portions of the mkerrcodes.awk source text are designed to be +# copied (in certain cases, depending on the input) into the output of +# mkerrcodes.awk. We call these the "data" portions. The rest of the +# mkerrcodes.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. +# mkerrcodes.h never copies any of the non-data portions into its output. +# +# This special exception to the GPL applies to versions of mkerrcodes.awk +# released by g10 Code GmbH. When you make and distribute a modified version +# of mkerrcodes.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 outputs an intermediate file that contains the following output: +# static struct +# { +# int err; +# const char *err_sym; +# } err_table[] = +# { +# { 7, "GPG_ERR_E2BIG" }, +# [...] +# }; +# +# The input file is a list of possible system errors, followed by a GPG_ERR_* name: +# +# 7 GPG_ERR_E2BIG +# +# Comments (starting with # and ending at the end of the line) are removed, +# as is trailing whitespace. + +BEGIN { + FS="[ \t]+GPG_ERR_"; + print "/* Output of mkerrcodes.awk. DO NOT EDIT. */"; + print ""; + header = 1; +} + +/^#/ { next; } + +header { + if (! /^[ \t]*$/) + { + header = 0; + + print "static struct"; + print " {"; + print " int err;"; + print " const char *err_sym;"; + print " } err_table[] = "; + print "{"; + } + else + print; +} + +!header { + sub (/\#.+/, ""); + sub (/[ ]+$/, ""); # Strip trailing space and tab characters. + + if (/^$/) + next; + + print " { " $1 ", \"GPG_ERR_" $2 "\" },"; +} + +END { + print "};"; +} diff --git a/libkdenetwork/libgpg-error-copy/mkerrcodes.c b/libkdenetwork/libgpg-error-copy/mkerrcodes.c new file mode 100644 index 000000000..29c1cc270 --- /dev/null +++ b/libkdenetwork/libgpg-error-copy/mkerrcodes.c @@ -0,0 +1,78 @@ +/* mkerrcodes.c - Generate list of system error values. + Copyright (C) 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. */ + +/* This file must not include config.h, as that is for the host + system, while this file will be run on the build system. */ + +#include + +#include "mkerrcodes.h" + +static const char header[] = +"/* errnos.h - List of system error values.\n" +" Copyright (C) 2004 g10 Code GmbH\n" +" This file is part of libgpg-error.\n" +"\n" +" libgpg-error is free software; you can redistribute it and/or\n" +" modify it under the terms of the GNU Lesser General Public License\n" +" as published by the Free Software Foundation; either version 2.1 of\n" +" the License, or (at your option) any later version.\n" +"\n" +" libgpg-error is distributed in the hope that it will be useful, but\n" +" WITHOUT ANY WARRANTY; without even the implied warranty of\n" +" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n" +" Lesser General Public License for more details.\n" +"\n" +" You should have received a copy of the GNU Lesser General Public\n" +" License along with libgpg-error; if not, write to the Free\n" +" Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA\n" +" 02111-1307, USA. */\n" +"\n"; + +int +main (int argc, char **argv) +{ + int sorted; + int i; + + printf ("%s", header); + do + { + sorted = 1; + for (i = 0; i < sizeof (err_table) / sizeof (err_table[0]) - 1; i++) + if (err_table[i].err > err_table[i + 1].err) + { + int err = err_table[i].err; + const char *err_sym = err_table[i].err_sym; + + err_table[i].err = err_table[i + 1].err; + err_table[i].err_sym = err_table[i + 1].err_sym; + err_table[i + 1].err = err; + err_table[i + 1].err_sym = err_sym; + sorted = 0; + } + } + while (!sorted); + + for (i = 0; i < sizeof (err_table) / sizeof (err_table[0]); i++) + printf ("%i\t%s\n", err_table[i].err, err_table[i].err_sym); + + return 0; +} diff --git a/libkdenetwork/libgpg-error-copy/mkerrcodes1.awk b/libkdenetwork/libgpg-error-copy/mkerrcodes1.awk new file mode 100644 index 000000000..3e9263652 --- /dev/null +++ b/libkdenetwork/libgpg-error-copy/mkerrcodes1.awk @@ -0,0 +1,90 @@ +# mkerrcodes.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 mkerrcodes.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 mkerrcodes.awk appear in them. The GNU +# General Public License (GPL) does govern all other use of the material +# that constitutes the mkerrcodes.awk program. +# +# Certain portions of the mkerrcodes.awk source text are designed to be +# copied (in certain cases, depending on the input) into the output of +# mkerrcodes.awk. We call these the "data" portions. The rest of the +# mkerrcodes.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. +# mkerrcodes.h never copies any of the non-data portions into its output. +# +# This special exception to the GPL applies to versions of mkerrcodes.awk +# released by g10 Code GmbH. When you make and distribute a modified version +# of mkerrcodes.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 outputs an intermediate file that contains the following block +# for each error value symbol in the input file (example for EINVAL): +# +# #ifdef EINVAL +# EINVAL GPG_ERR_EINVAL +# #endif +# +# 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 ""; +} + +/^#/ { next; } + +header { + if ($1 ~ /^[0-9]/) + { + print "#include "; + print ""; + header = 0; + } + else + print; +} + +!header { + sub (/\#.+/, ""); + sub (/[ ]+$/, ""); # Strip trailing space and tab characters. + + if (/^$/) + next; + + print "#ifdef " $errnoidx; + print $errnoidx "\tGPG_ERR_" $errnoidx; + print "#endif"; +} diff --git a/libkdenetwork/libgpg-error-copy/mkerrcodes2.awk b/libkdenetwork/libgpg-error-copy/mkerrcodes2.awk new file mode 100644 index 000000000..ea5850341 --- /dev/null +++ b/libkdenetwork/libgpg-error-copy/mkerrcodes2.awk @@ -0,0 +1,134 @@ +# mkstrtable.awk +# Copyright (C) 2003 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 mkerrcodes2.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 mkerrcodes2.awk appear in them. The GNU +# General Public License (GPL) does govern all other use of the material +# that constitutes the mkerrcodes2.awk program. +# +# Certain portions of the mkerrcodes2.awk source text are designed to be +# copied (in certain cases, depending on the input) into the output of +# mkerrcodes2.awk. We call these the "data" portions. The rest of the +# mkerrcodes2.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. +# mkstrtable.h never copies any of the non-data portions into its output. +# +# This special exception to the GPL applies to versions of mkerrcodes2.awk +# released by g10 Code GmbH. When you make and distribute a modified version +# of mkerrcodes2.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 outputs a source file that does define the following +# symbols: +# +# static const char msgstr[]; +# A string containing all messages in the list. +# +# static const int msgidx[]; +# A list of index numbers, one for each message, that points to the +# beginning of the string in msgstr. +# +# msgidxof (code); +# A macro that maps code numbers to idx numbers. If a DEFAULT MESSAGE +# is provided (see below), its index will be returned for unknown codes. +# Otherwise -1 is returned for codes that do not appear in the list. +# You can lookup the message with code CODE with: +# msgstr + msgidx[msgidxof (code)]. +# +# The input file has the following format: +# CODE1 MESSAGE1 (Code number, , message string) +# CODE2 MESSAGE2 (Code number, , message string) +# ... +# CODEn MESSAGEn (Code number, , message string) +# DEFAULT MESSAGE (, fall-back message string) +# +# 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. + +BEGIN { +# msg holds the number of messages. + msg = 0; + print "/* Output of mkerrcodes2.awk. DO NOT EDIT. */"; + print ""; + header = 1; +} + +/^#/ { next; } + +header { + if ($1 ~ /^[0123456789]+$/) + { + print "static const int err_code_from_index[] = {"; + header = 0; + } + else + print; +} + +!header { + sub (/\#.+/, ""); + sub (/[ ]+$/, ""); # Strip trailing space and tab characters. + + if (/^$/) + next; + +# Print the string msgstr line by line. We delay output by one line to be able +# to treat the last line differently (see END). + print " " $2 ","; + +# Remember the error value and index of each error code. + code[msg] = $1; + pos[msg] = $2; + msg++; +} +END { + print "};"; + print ""; + print "#define errno_to_idx(code) (0 ? -1 \\"; + +# Gather the ranges. + skip = code[0]; + start = code[0]; + stop = code[0]; + for (i = 1; i < msg; i++) + { + if (code[i] == stop + 1) + stop++; + else + { + print " : ((code >= " start ") && (code <= " stop ")) ? (code - " \ + skip ") \\"; + skip += code[i] - stop - 1; + start = code[i]; + stop = code[i]; + } + } + print " : ((code >= " start ") && (code <= " stop ")) ? (code - " \ + skip ") \\"; + print " : -1)"; +} diff --git a/libkdenetwork/libgpg-error-copy/mkerrnos.awk b/libkdenetwork/libgpg-error-copy/mkerrnos.awk new file mode 100644 index 000000000..c4bbf8146 --- /dev/null +++ b/libkdenetwork/libgpg-error-copy/mkerrnos.awk @@ -0,0 +1,97 @@ +# mkerrnos.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 mkerrnos.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 mkerrnos.awk appear in them. The GNU +# General Public License (GPL) does govern all other use of the material +# that constitutes the mkerrnos.awk program. +# +# Certain portions of the mkerrnos.awk source text are designed to be +# copied (in certain cases, depending on the input) into the output of +# mkerrnos.awk. We call these the "data" portions. The rest of the +# mkerrnos.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. +# mkerrnos.h never copies any of the non-data portions into its output. +# +# This special exception to the GPL applies to versions of mkerrnos.awk +# released by g10 Code GmbH. When you make and distribute a modified version +# of mkerrnos.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 outputs a source file that does define the following +# symbols: +# +# static const int err_code_to_errno[]; +# A mapping of gpg_err_code_t numbers to system errno. The index of an +# 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 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 ""; +} + +/^#/ { next; } + +header { + if ($1 ~ /^[0-9]/) + { + print "#include "; + print ""; + print "static const int err_code_to_errno [] = {"; + header = 0; + } + else + print; +} + +!header { + sub (/\#.+/, ""); + sub (/[ ]+$/, ""); # Strip trailing space and tab characters. + + if (/^$/) + next; + + print "#ifdef " $errnoidx; + print " " $errnoidx ","; + print "#else"; + print " 0,"; + print "#endif"; +} +END { + print "};"; +} diff --git a/libkdenetwork/libgpg-error-copy/mkheader.awk b/libkdenetwork/libgpg-error-copy/mkheader.awk new file mode 100644 index 000000000..67de05dd4 --- /dev/null +++ b/libkdenetwork/libgpg-error-copy/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/libkdenetwork/libgpg-error-copy/mkstrtable.awk b/libkdenetwork/libgpg-error-copy/mkstrtable.awk new file mode 100644 index 000000000..31eb121a7 --- /dev/null +++ b/libkdenetwork/libgpg-error-copy/mkstrtable.awk @@ -0,0 +1,186 @@ +# mkstrtable.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 mkstrtable.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 mkstrtable.awk appear in them. The GNU +# General Public License (GPL) does govern all other use of the material +# that constitutes the mkstrtable.awk program. +# +# Certain portions of the mkstrtable.awk source text are designed to be +# copied (in certain cases, depending on the input) into the output of +# mkstrtable.awk. We call these the "data" portions. The rest of the +# mkstrtable.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. +# mkstrtable.h never copies any of the non-data portions into its output. +# +# This special exception to the GPL applies to versions of mkstrtable.awk +# released by g10 Code GmbH. When you make and distribute a modified version +# of mkstrtable.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 outputs a source file that does define the following +# symbols: +# +# static const char msgstr[]; +# A string containing all messages in the list. +# +# static const int msgidx[]; +# A list of index numbers, one for each message, that points to the +# beginning of the string in msgstr. +# +# msgidxof (code); +# A macro that maps code numbers to idx numbers. If a DEFAULT MESSAGE +# is provided (see below), its index will be returned for unknown codes. +# Otherwise -1 is returned for codes that do not appear in the list. +# You can lookup the message with code CODE with: +# msgstr + msgidx[msgidxof (code)]. +# +# The input file has the following format: +# CODE1 ... MESSAGE1 (code nr, , something, , msg) +# CODE2 ... MESSAGE2 (code nr, , something, , msg) +# ... +# CODEn ... MESSAGEn (code nr, , something, , msg) +# ... DEFAULT-MESSAGE (, something, , 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]+"; +# cpos holds the current position in the message string. + cpos = 0; +# msg holds the number of messages. + msg = 0; + 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; } + +header { + if ($1 ~ /^[0123456789]+$/) + { + print "/* The purpose of this complex string table is to produce"; + print " optimal code with a minimum of relocations. */"; + print ""; + print "static const char " namespace "msgstr[] = "; + header = 0; + } + else + print; +} + +!header { + sub (/\#.+/, ""); + sub (/[ ]+$/, ""); # Strip trailing space and tab characters. + + if (/^$/) + next; + +# 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) + { + 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 (last_msgstr) + 1; + msg++; + + if ($1 == "") + { + has_default = 1; + exit; + } +} +END { + if (has_default) + coded_msgs = msg - 1; + else + coded_msgs = msg; + + if (nogettext) + print " \"" prefix last_msgstr "\";"; + else + print " gettext_noop (\"" prefix last_msgstr "\");"; + print ""; + 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 " namespace "msgidxof(code) (0 ? -1 \\"; + +# Gather the ranges. + skip = code[0]; + start = code[0]; + stop = code[0]; + for (i = 1; i < coded_msgs; i++) + { + if (code[i] == stop + 1) + stop++; + else + { + print " : ((code >= " start ") && (code <= " stop ")) ? (code - " \ + skip ") \\"; + skip += code[i] - stop - 1; + start = code[i]; + stop = code[i]; + } + } + print " : ((code >= " start ") && (code <= " stop ")) ? (code - " \ + skip ") \\"; + if (has_default) + print " : " stop + 1 " - " skip ")"; + else + print " : -1)"; + + } diff --git a/libkdenetwork/libgpg-error-copy/strerror.c b/libkdenetwork/libgpg-error-copy/strerror.c new file mode 100644 index 000000000..dc5604026 --- /dev/null +++ b/libkdenetwork/libgpg-error-copy/strerror.c @@ -0,0 +1,169 @@ +/* strerror.c - Describing an error code. + 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 +#endif + +#include +#include +#include +#include + +#include + +#include "gettext.h" +#include "err-codes.h" + +/* 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) +{ + gpg_err_code_t code = gpg_err_code (err); + + if (code & GPG_ERR_SYSTEM_ERROR) + { + int no = gpg_err_code_to_errno (code); + if (no) + return strerror (no); + else + code = GPG_ERR_UNKNOWN_ERRNO; + } + return dgettext (PACKAGE, msgstr + msgidx[msgidxof (code)]); +} + + +#ifdef HAVE_STRERROR_R +#ifdef STRERROR_R_CHAR_P +/* The GNU C library and probably some other systems have this weird + variant of strerror_r. */ + +/* Return a dynamically allocated string in *STR describing the system + error NO. If this call succeeds, return 1. If this call fails due + to a resource shortage, set *STR to NULL and return 1. If this + call fails because the error number is not valid, don't set *STR + and return 0. */ +static int +system_strerror_r (int no, char *buf, size_t buflen) +{ + char *errstr; + + errstr = strerror_r (no, buf, buflen); + if (errstr != buf) + { + size_t errstr_len = strlen (errstr) + 1; + size_t cpy_len = errstr_len < buflen ? errstr_len : buflen; + memcpy (buf, errstr, cpy_len); + + return cpy_len == errstr_len ? 0 : ERANGE; + } + else + { + /* We can not tell if the buffer was large enough, but we can + try to make a guess. */ + if (strlen (buf) + 1 >= buflen) + return ERANGE; + + return 0; + } +} + +#else /* STRERROR_R_CHAR_P */ +/* Now the POSIX version. */ + +static int +system_strerror_r (int no, char *buf, size_t buflen) +{ + return strerror_r (no, buf, buflen); +} + +#endif /* STRERROR_R_CHAR_P */ + +#else /* HAVE_STRERROR_H */ +/* Without strerror_r(), we can still provide a non-thread-safe + version. Maybe we are even lucky and the system's strerror() is + already thread-safe. */ + +static int +system_strerror_r (int no, char *buf, size_t buflen) +{ + char *errstr = strerror (no); + + if (!errstr) + { + int saved_errno = errno; + + if (saved_errno != EINVAL) + snprintf (buf, buflen, "strerror failed: %i\n", errno); + return saved_errno; + } + else + { + size_t errstr_len = strlen (errstr) + 1; + size_t cpy_len = errstr_len < buflen ? errstr_len : buflen; + memcpy (buf, errstr, cpy_len); + return cpy_len == errstr_len ? 0 : ERANGE; + } +} +#endif + + +/* 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) +{ + gpg_err_code_t code = gpg_err_code (err); + const char *errstr; + size_t errstr_len; + size_t cpy_len; + + if (code & GPG_ERR_SYSTEM_ERROR) + { + int no = gpg_err_code_to_errno (code); + if (no) + { + int system_err = system_strerror_r (no, buf, buflen); + + if (system_err != EINVAL) + { + if (buflen) + buf[buflen - 1] = '\0'; + return system_err; + } + } + code = GPG_ERR_UNKNOWN_ERRNO; + } + + errstr = dgettext (PACKAGE, msgstr + msgidx[msgidxof (code)]); + errstr_len = strlen (errstr) + 1; + cpy_len = errstr_len < buflen ? errstr_len : buflen; + memcpy (buf, errstr, cpy_len); + if (buflen) + buf[buflen - 1] = '\0'; + + return cpy_len == errstr_len ? 0 : ERANGE; +} diff --git a/libkdenetwork/libgpg-error-copy/strsource.c b/libkdenetwork/libgpg-error-copy/strsource.c new file mode 100644 index 000000000..66d783c43 --- /dev/null +++ b/libkdenetwork/libgpg-error-copy/strsource.c @@ -0,0 +1,37 @@ +/* strsource.c - Describing an error source. + 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 +#endif + +#include + +#include "gettext.h" +#include "err-sources.h" + +/* 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) +{ + gpg_err_source_t source = gpg_err_source (err); + return dgettext (PACKAGE, msgstr + msgidx[msgidxof (source)]); +} -- cgit v1.2.1