doc/
2003-06-06 Marcus Brinkmann <marcus@g10code.de> * gpgme.texi: Change error codes to GPG_ERR_* variants. (Error Handling): Rewritten. gpgme/ 2003-06-05 Marcus Brinkmann <marcus@g10code.de> Everywhere: Use libgpg-error error codes. * Makefile.am (EXTRA_DIST): Remove mkerrors. (BUILT_SOURCES): Remove errors.c. (MOSTLYCLEANFILES): Likewise. (libgpgme_la_SOURCES): Likewise. Add error.c. (errors.c): Remove target. * mkerrors: File removed. * error.c: New file. * gpgme.h (gpgme_error_t): Change to type gpg_error_t. (gpgme_err_code_t, gpgme_err_source_t): New types. (gpgme_err_code, gpgme_err_source, gpgme_error, gpgme_err_make): New static inline functions. (gpgme_strsource, gpgme_err_code_from_errno, gpgme_err_code_to_errno, gpgme_err_make_from_errno, gpgme_error_from_errno): New prototypes. tests/ 2003-06-06 Marcus Brinkmann <marcus@g10code.de> Everywhere: Use libgpg-error error codes. * gpg/Makefile.am (noinst_HEADERS): New variable. * gpg/t-support.h: New file. * gpgsm/Makefile.am (noinst_HEADERS): New variable. * gpgsm/t-support.h: New file.
This commit is contained in:
parent
8f8c78d534
commit
02536bb72b
@ -1,3 +1,8 @@
|
||||
2003-06-06 Marcus Brinkmann <marcus@g10code.de>
|
||||
|
||||
* configure.ac: Check for libgpg-error. Define
|
||||
GPG_ERR_SOURCE_DEFAULT.
|
||||
|
||||
2003-05-26 Marcus Brinkmann <marcus@g10code.de>
|
||||
|
||||
* configure.ac (NEED_GPG_VERSION): Bump up to 1.2.2.
|
||||
|
71
NEWS
71
NEWS
@ -18,6 +18,13 @@ Noteworthy changes in version 0.4.1 (unreleased)
|
||||
afterwards by calling one of the result functions. This unifies the
|
||||
synchronous and the asynchronous interface.
|
||||
|
||||
The error values have been completely replaced by a more
|
||||
sophisticated model that allows GPGME to transparently and accurately
|
||||
report all errors from the other GnuPG components, irregardless of
|
||||
process boundaries. This is achieved by using the library
|
||||
libgpg-errors, which is shared by all GnuPG components. This library
|
||||
is now required for GPGME.
|
||||
|
||||
The results of all operations are now provided by pointers to C
|
||||
structs rather than by XML structs or in other ways.
|
||||
|
||||
@ -26,20 +33,19 @@ Noteworthy changes in version 0.4.1 (unreleased)
|
||||
|
||||
Backward compatibility is provided where it was possible without too
|
||||
much effort and did not collide with the overall sanitization effort.
|
||||
However, it is recommended to update to the new interfaces soon, so
|
||||
the compatibility interfaces can be phased out quickly.
|
||||
Recommendations how to replace deprecated or removed functionality can
|
||||
be found within the description of each change.
|
||||
However, this is only for ease of transition. NO DEPRECATED FUNCTION
|
||||
OR DATA TYPE IS CONSIDERED A PART OF THE API OR ABI AND WILL BE
|
||||
DROPPED IN THE FUTURE WITHOUT CHANGING THE SONAME OF THE LIBRARY.
|
||||
Recommendations how to replace deprecated or removed functionality
|
||||
can be found within the description of each change.
|
||||
|
||||
What follows are all changes to the interface and behaviour of GPGME
|
||||
in detail.
|
||||
|
||||
* If gpgme.h is included in sources compiled by GCC 3.1 or later,
|
||||
deprecated attributes will warn about use of obsolete functions and
|
||||
typedefs. The use of obsolete error values will appear as the use
|
||||
of an obsolete type _gpgme_deprecated_error_t. You can suppress
|
||||
these warnings by passing -Wno-deprecated-declarations to the gcc
|
||||
command.
|
||||
type definitions. You can suppress these warnings by passing
|
||||
-Wno-deprecated-declarations to the gcc command.
|
||||
|
||||
* The following types have been renamed. The old types are still
|
||||
available as aliases, but they are deprecated now:
|
||||
@ -70,6 +76,17 @@ Noteworthy changes in version 0.4.1 (unreleased)
|
||||
GpgmeTrustItem gpgme_trust_item_t
|
||||
GpgmeStatusCode gpgme_status_code_t
|
||||
|
||||
* gpgme_error_t is now identical to gpg_error_t, the error type
|
||||
provided by libgpg-error. More about using libgpg-error with GPGME
|
||||
can be found in the manual. All error symbols have been removed!
|
||||
|
||||
* All functions and types in libgpg-error have been wrapped in GPGME.
|
||||
The new types are gpgme_err_code_t and gpgme_err_source_t. The new
|
||||
functions are gpgme_err_code, gpgme_err_source, gpgme_error,
|
||||
gpgme_err_make, gpgme_error_from_errno, gpgme_err_make_from_errno,
|
||||
gpgme_err_code_from_errno, gpgme_err_code_to_errno,
|
||||
gpgme_strsource.
|
||||
|
||||
* GPGME_ATTR_IS_SECRET is not anymore representable as a string.
|
||||
|
||||
* GnuPG 1.2.2 is required. The progress callback is now also invoked
|
||||
@ -89,7 +106,7 @@ Noteworthy changes in version 0.4.1 (unreleased)
|
||||
|
||||
The return type has been changed to gpgme_error_t value. This
|
||||
allowed to remove the gpgme_cancel function; just return
|
||||
GPGME_Canceled in the passphrase callback directly.
|
||||
the error code GPG_ERR_CANCELED in the passphrase callback directly.
|
||||
|
||||
* gpgme_edit_cb_t has been changed to take a file descriptor argument.
|
||||
The user is expected to write the response to the file descriptor,
|
||||
@ -145,13 +162,10 @@ Noteworthy changes in version 0.4.1 (unreleased)
|
||||
* The new function gpgme_get_protocol_name can be used to convert a
|
||||
gpgme_protocol_t value into a string.
|
||||
|
||||
* The status of a context operation is not checked anymore, so the
|
||||
errors GPGME_Busy and GPGME_No_Request can not occur anymore.
|
||||
|
||||
* For clarity and better reusability, the error codes
|
||||
GPGME_No_Recipients, GPGME_Invalid_Recipient and
|
||||
GPGME_No_Passphrase have been renamed to GPGME_No_UserID,
|
||||
GPGME_Invalid_UserID and GPGME_Bad_Passphrase resp.
|
||||
* The status of a context operation is not checked anymore. Starting
|
||||
a new operation will silently cancel the previous one. Calling a
|
||||
function that requires you to have started an operation before without
|
||||
doing so is undefined.
|
||||
|
||||
* The FPR argument to gpgme_op_genkey was removed. Instead, use the
|
||||
gpgme_op_genkey_result function to retrieve a gpgme_genkey_result_t
|
||||
@ -227,8 +241,7 @@ Noteworthy changes in version 0.4.1 (unreleased)
|
||||
interface, the generic gpgme_get_op_info interface is not useful
|
||||
anymore and dropped.
|
||||
|
||||
* The error values GPGME_Invalid_Type and GPGME_Invalid_Mode can not
|
||||
occur anymore and are thus deprecated.
|
||||
* The type and mode of data objects is not available anymore.
|
||||
|
||||
* Interface changes relative to the 0.4.0 release:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@ -283,6 +296,18 @@ gpgme_data_release_cb_t NEW
|
||||
gpgme_data_cbs_t NEW
|
||||
gpgme_trust_item_t NEW
|
||||
gpgme_status_code_t NEW
|
||||
GPGME_{some error code} REMOVED! Use GPG_ERR_* from libgpg-error.
|
||||
gpgme_err_code_t NEW
|
||||
gpgme_err_source_t NEW
|
||||
gpgme_err_code NEW
|
||||
gpgme_err_source NEW
|
||||
gpgme_error NEW
|
||||
gpgme_err_make NEW
|
||||
gpgme_error_from_errno NEW
|
||||
gpgme_err_make_from_errno NEW
|
||||
gpgme_err_code_from_errno NEW
|
||||
gpgme_err_code_to_errno NEW
|
||||
gpgme_strsource NEW
|
||||
gpgme_io_cb_t CHANGED: Return type from void to GpgmeError.
|
||||
gpgme_event_io_t CHANGED: New event type (all numbers changed).
|
||||
gpgme_passphrase_cb_t CHANGED: Desc decomposed, write directly to FD.
|
||||
@ -318,14 +343,6 @@ gpgme_engine_info_t NEW
|
||||
gpgme_get_engine_info CHANGED: Return info structure instead XML.
|
||||
gpgme_get_protocol_name NEW
|
||||
gpgme_cancel REMOVED: Return error in callback directly.
|
||||
GPGME_Busy DEPRECATED: Not in use.
|
||||
GPGME_No_Request DEPRECATED: Not in use.
|
||||
GPGME_No_Recipients DEPRECATED: Use GPGME_No_UserID.
|
||||
GPGME_No_UserID NEW
|
||||
GPGME_Invalid_Recipient DEPRECATED: Use GPGME_Invalid_UserID.
|
||||
GPGME_Invalid_UserID NEW
|
||||
GPGME_No_Passphrase DEPRECATED: Use GPGME_Bad_Passphrase.
|
||||
GPGME_Bad_Passphrase NEW
|
||||
gpgme_op_genkey CHANGED: FPR argument dropped.
|
||||
gpgme_op_genkey_result NEW
|
||||
gpgme_genkey_result_t NEW
|
||||
@ -372,8 +389,6 @@ gpgme_key_get_as_xml REMOVED
|
||||
gpgme_key_list_result_t NEW
|
||||
gpgme_op_keylist_result NEW
|
||||
gpgme_get_op_info REMOVED
|
||||
GPGME_Invalid_Type DEPRECATED
|
||||
GPGME_Invalid_Mode DEPRECATED
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Noteworthy changes in version 0.4.0 (2002-12-23)
|
||||
|
11
TODO
11
TODO
@ -1,7 +1,13 @@
|
||||
Hey Emacs, this is -*- outline -*- mode!
|
||||
|
||||
* Before release:
|
||||
** Change gpgme_invalid_user_id_t to gpgme_invalid_key_t.
|
||||
** Remove arg_error from rungpg.c
|
||||
** Make sure that notation value allocation has no leak at error
|
||||
** Make sure POSIX I/O functions set errno properly
|
||||
** gpgme-config must include info about libgpg-error.
|
||||
|
||||
* ABI's to break:
|
||||
** Use libgpg-error.
|
||||
** Compatibility interfaces that can be removed in future versions:
|
||||
*** gpgme_data_new_from_filepart
|
||||
*** gpgme_data_new_from_file
|
||||
@ -91,7 +97,8 @@ Hey Emacs, this is -*- outline -*- mode!
|
||||
|
||||
* Error Values
|
||||
** Map ASSUAN/GpgSM ERR error values in a better way than is done now. !!
|
||||
** Verify (and document) if Read_Error, Write_Error, Pipe_Error set errno.
|
||||
** Some error values should identify the source more correctly (mostly error
|
||||
values derived from status messages).
|
||||
|
||||
* Tests
|
||||
** Write a fake gpg-agent so that we can supply known passphrases to
|
||||
|
@ -164,14 +164,13 @@ if test "$ac_cv_func_vasprintf" != yes; then
|
||||
GNUPG_CHECK_VA_COPY
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# Note: fopencokie is only a dummy stub and not used.
|
||||
# However some code in assuan/ links against it.
|
||||
AC_REPLACE_FUNCS(fopencookie)
|
||||
|
||||
|
||||
|
||||
AC_CHECK_LIB(gpg-error, strerror)
|
||||
AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GPGME,
|
||||
[The default error source for GPGME.])
|
||||
dnl
|
||||
dnl Checks for system services
|
||||
dnl
|
||||
|
@ -1,3 +1,8 @@
|
||||
2003-06-06 Marcus Brinkmann <marcus@g10code.de>
|
||||
|
||||
* gpgme.texi: Change error codes to GPG_ERR_* variants.
|
||||
(Error Handling): Rewritten.
|
||||
|
||||
2003-05-29 Marcus Brinkmann <marcus@g10code.de>
|
||||
|
||||
* gpgme.texi (Exporting Keys): Change and document prototypes.
|
||||
|
890
doc/gpgme.texi
890
doc/gpgme.texi
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,23 @@
|
||||
2003-06-05 Marcus Brinkmann <marcus@g10code.de>
|
||||
|
||||
Everywhere: Use libgpg-error error codes.
|
||||
|
||||
* Makefile.am (EXTRA_DIST): Remove mkerrors.
|
||||
(BUILT_SOURCES): Remove errors.c.
|
||||
(MOSTLYCLEANFILES): Likewise.
|
||||
(libgpgme_la_SOURCES): Likewise. Add error.c.
|
||||
(errors.c): Remove target.
|
||||
* mkerrors: File removed.
|
||||
* error.c: New file.
|
||||
|
||||
* gpgme.h (gpgme_error_t): Change to type gpg_error_t.
|
||||
(gpgme_err_code_t, gpgme_err_source_t): New types.
|
||||
(gpgme_err_code, gpgme_err_source, gpgme_error, gpgme_err_make):
|
||||
New static inline functions.
|
||||
(gpgme_strsource, gpgme_err_code_from_errno,
|
||||
gpgme_err_code_to_errno, gpgme_err_make_from_errno,
|
||||
gpgme_error_from_errno): New prototypes.
|
||||
|
||||
2003-05-29 Marcus Brinkmann <marcus@g10code.de>
|
||||
|
||||
* gpgme.h (gpgme_op_export_start): Change second arg to const char *.
|
||||
|
@ -19,9 +19,9 @@
|
||||
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
EXTRA_DIST = gpgme-config.in gpgme.m4 mkerrors mkstatus libgpgme.vers
|
||||
BUILT_SOURCES = errors.c status-table.h
|
||||
MOSTLYCLEANFILES = errors.c status-table.h
|
||||
EXTRA_DIST = gpgme-config.in gpgme.m4 mkstatus libgpgme.vers
|
||||
BUILT_SOURCES = status-table.h
|
||||
MOSTLYCLEANFILES = status-table.h
|
||||
bin_SCRIPTS = gpgme-config
|
||||
m4datadir = $(datadir)/aclocal
|
||||
m4data_DATA = gpgme.m4
|
||||
@ -81,16 +81,12 @@ libgpgme_la_SOURCES = \
|
||||
import.c export.c genkey.c delete.c edit.c \
|
||||
engine.h engine-backend.h engine.c rungpg.c status-table.h \
|
||||
${gpgsm_components} sema.h io.h ${system_components} \
|
||||
debug.c debug.h gpgme.c version.c errors.c
|
||||
debug.c debug.h gpgme.c version.c error.c
|
||||
|
||||
libgpgme_la_DEPENDENCIES = ${assuan_libobjs} @LTLIBOBJS@ \
|
||||
$(srcdir)/libgpgme.vers
|
||||
|
||||
libgpgme_la_LIBADD = ${assuan_libobjs} @LTLIBOBJS@
|
||||
|
||||
errors.c : gpgme.h
|
||||
$(srcdir)/mkerrors < $(srcdir)/gpgme.h > errors.c
|
||||
|
||||
status-table.h : gpgme.h
|
||||
$(srcdir)/mkstatus < $(srcdir)/gpgme.h > status-table.h
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "gpgme.h"
|
||||
#include "util.h"
|
||||
@ -72,7 +73,7 @@ _gpgme_decode_c_string (const char *src, char **destp, int len)
|
||||
if (len)
|
||||
{
|
||||
if (len < strlen (src) + 1)
|
||||
return GPGME_General_Error;
|
||||
return gpg_error (GPG_ERR_INTERNAL);
|
||||
|
||||
dest = *destp;
|
||||
}
|
||||
@ -82,7 +83,7 @@ _gpgme_decode_c_string (const char *src, char **destp, int len)
|
||||
string. */
|
||||
dest = malloc (strlen (src) + 1);
|
||||
if (!dest)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
|
||||
*destp = dest;
|
||||
}
|
||||
@ -175,7 +176,7 @@ _gpgme_decode_percent_string (const char *src, char **destp, int len)
|
||||
if (len)
|
||||
{
|
||||
if (len < strlen (src) + 1)
|
||||
return GPGME_General_Error;
|
||||
return gpg_error (GPG_ERR_INTERNAL);
|
||||
|
||||
dest = *destp;
|
||||
}
|
||||
@ -185,7 +186,7 @@ _gpgme_decode_percent_string (const char *src, char **destp, int len)
|
||||
string. */
|
||||
dest = malloc (strlen (src) + 1);
|
||||
if (!dest)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
|
||||
*destp = dest;
|
||||
}
|
||||
@ -238,84 +239,84 @@ static struct
|
||||
gpgme_error_t err;
|
||||
} gnupg_errors[] =
|
||||
{
|
||||
{ "EOF", GPGME_EOF },
|
||||
{ "No_Error", GPGME_No_Error },
|
||||
{ "General_Error", GPGME_General_Error },
|
||||
{ "Out_Of_Core", GPGME_Out_Of_Core },
|
||||
{ "Invalid_Value", GPGME_Invalid_Value },
|
||||
{ "IO_Error", GPGME_General_Error },
|
||||
{ "Resource_Limit", GPGME_General_Error },
|
||||
{ "Internal_Error", GPGME_General_Error },
|
||||
{ "Bad_Certificate", GPGME_Invalid_Key },
|
||||
{ "Bad_Certificate_Chain", GPGME_General_Error },
|
||||
{ "Missing_Certificate", GPGME_No_Public_Key },
|
||||
{ "No_Data", GPGME_No_Data },
|
||||
{ "Bad_Signature", GPGME_Bad_Signature },
|
||||
{ "Not_Implemented", GPGME_Not_Implemented },
|
||||
{ "Conflict", GPGME_Conflict },
|
||||
{ "Bug", GPGME_General_Error },
|
||||
{ "Read_Error", GPGME_General_Error },
|
||||
{ "Write_Error", GPGME_General_Error },
|
||||
{ "Invalid_Line", GPGME_General_Error },
|
||||
{ "Incomplete_Line", GPGME_General_Error },
|
||||
{ "Invalid_Response", GPGME_General_Error },
|
||||
{ "Agent_Error", GPGME_General_Error },
|
||||
{ "No_Public_Key", GPGME_No_Public_Key },
|
||||
{ "No_Secret_Key", GPGME_No_Secret_Key },
|
||||
{ "File_Open_Error", GPGME_General_Error },
|
||||
{ "File_Create_Error", GPGME_General_Error },
|
||||
{ "File_Error", GPGME_General_Error },
|
||||
{ "Not_Supported", GPGME_General_Error },
|
||||
{ "Invalid_Data", GPGME_General_Error },
|
||||
{ "Assuan_Server_Fault", GPGME_General_Error },
|
||||
{ "Assuan_Error", GPGME_General_Error },
|
||||
{ "Invalid_Session_Key", GPGME_General_Error },
|
||||
{ "Invalid_Sexp", GPGME_General_Error },
|
||||
{ "Unsupported_Algorithm", GPGME_Unsupported_Algorithm },
|
||||
{ "No_PIN_Entry", GPGME_Invalid_Engine },
|
||||
{ "PIN_Entry_Error", GPGME_Invalid_Engine },
|
||||
{ "Bad_PIN", GPGME_Bad_Passphrase },
|
||||
{ "Bad_Passphrase", GPGME_Bad_Passphrase },
|
||||
{ "Invalid_Name", GPGME_General_Error },
|
||||
{ "Bad_Public_Key", GPGME_General_Error },
|
||||
{ "Bad_Secret_Key", GPGME_General_Error },
|
||||
{ "Bad_Data", GPGME_General_Error },
|
||||
{ "Invalid_Parameter", GPGME_General_Error },
|
||||
{ "Tribute_to_D_A", GPGME_General_Error },
|
||||
{ "No_Dirmngr", GPGME_Invalid_Engine },
|
||||
{ "Dirmngr_Error", GPGME_General_Error },
|
||||
{ "Certificate_Revoked", GPGME_Key_Revoked },
|
||||
{ "No_CRL_Known", GPGME_No_CRL_Known },
|
||||
{ "CRL_Too_Old", GPGME_CRL_Too_Old },
|
||||
{ "Line_Too_Long", GPGME_General_Error },
|
||||
{ "Not_Trusted", GPGME_Key_Not_Trusted },
|
||||
{ "Canceled", GPGME_Canceled },
|
||||
{ "Bad_CA_Certificate", GPGME_General_Error },
|
||||
{ "Certificate_Expired", GPGME_Key_Expired },
|
||||
{ "Certificate_Too_Young", GPGME_Invalid_Key },
|
||||
{ "Unsupported_Certificate", GPGME_General_Error },
|
||||
{ "Unknown_Sexp", GPGME_General_Error },
|
||||
{ "Unsupported_Protection", GPGME_General_Error },
|
||||
{ "Corrupted_Protection", GPGME_General_Error },
|
||||
{ "Ambiguous_Name", GPGME_Ambiguous_Specification },
|
||||
{ "Card_Error", GPGME_General_Error },
|
||||
{ "Card_Reset", GPGME_General_Error },
|
||||
{ "Card_Removed", GPGME_General_Error },
|
||||
{ "Invalid_Card", GPGME_General_Error },
|
||||
{ "Card_Not_Present", GPGME_General_Error },
|
||||
{ "No_PKCS15_App", GPGME_General_Error },
|
||||
{ "Not_Confirmed", GPGME_General_Error },
|
||||
{ "Configuration_Error", GPGME_General_Error },
|
||||
{ "No_Policy_Match", GPGME_Policy_Mismatch },
|
||||
{ "Invalid_Index", GPGME_General_Error },
|
||||
{ "Invalid_Id", GPGME_General_Error },
|
||||
{ "No_Scdaemon", GPGME_Invalid_Engine },
|
||||
{ "Scdaemon_Error", GPGME_General_Error },
|
||||
{ "Unsupported_Protocol", GPGME_General_Error },
|
||||
{ "Bad_PIN_Method", GPGME_General_Error },
|
||||
{ "Card_Not_Initialized", GPGME_General_Error },
|
||||
{ "Unsupported_Operation", GPGME_General_Error },
|
||||
{ "Wrong_Key_Usage", GPGME_Wrong_Key_Usage }
|
||||
{ "EOF", GPG_ERR_EOF },
|
||||
{ "No_Error", GPG_ERR_NO_ERROR },
|
||||
{ "General_Error", GPG_ERR_GENERAL },
|
||||
{ "Out_Of_Core", GPG_ERR_ENOMEM },
|
||||
{ "Invalid_Value", GPG_ERR_INV_VALUE },
|
||||
{ "IO_Error", GPG_ERR_GENERAL },
|
||||
{ "Resource_Limit", GPG_ERR_RESOURCE_LIMIT },
|
||||
{ "Internal_Error", GPG_ERR_INTERNAL },
|
||||
{ "Bad_Certificate", GPG_ERR_BAD_CERT },
|
||||
{ "Bad_Certificate_Chain", GPG_ERR_BAD_CERT_CHAIN},
|
||||
{ "Missing_Certificate", GPG_ERR_MISSING_CERT },
|
||||
{ "No_Data", GPG_ERR_NO_DATA },
|
||||
{ "Bad_Signature", GPG_ERR_BAD_SIGNATURE },
|
||||
{ "Not_Implemented", GPG_ERR_NOT_IMPLEMENTED },
|
||||
{ "Conflict", GPG_ERR_CONFLICT },
|
||||
{ "Bug", GPG_ERR_BUG },
|
||||
{ "Read_Error", GPG_ERR_GENERAL },
|
||||
{ "Write_Error", GPG_ERR_GENERAL },
|
||||
{ "Invalid_Line", GPG_ERR_GENERAL },
|
||||
{ "Incomplete_Line", GPG_ERR_INCOMPLETE_LINE },
|
||||
{ "Invalid_Response", GPG_ERR_INV_RESPONSE },
|
||||
{ "Agent_Error", GPG_ERR_AGENT },
|
||||
{ "No_Public_Key", GPG_ERR_NO_PUBKEY },
|
||||
{ "No_Secret_Key", GPG_ERR_NO_SECKEY },
|
||||
{ "File_Open_Error", GPG_ERR_GENERAL },
|
||||
{ "File_Create_Error", GPG_ERR_GENERAL },
|
||||
{ "File_Error", GPG_ERR_GENERAL },
|
||||
{ "Not_Supported", GPG_ERR_NOT_SUPPORTED },
|
||||
{ "Invalid_Data", GPG_ERR_INV_DATA },
|
||||
{ "Assuan_Server_Fault", GPG_ERR_ASSUAN_SERVER_FAULT },
|
||||
{ "Assuan_Error", GPG_ERR_ASSUAN },
|
||||
{ "Invalid_Session_Key", GPG_ERR_INV_SESSION_KEY },
|
||||
{ "Invalid_Sexp", GPG_ERR_INV_SEXP },
|
||||
{ "Unsupported_Algorithm", GPG_ERR_UNSUPPORTED_ALGORITHM },
|
||||
{ "No_PIN_Entry", GPG_ERR_NO_PIN_ENTRY },
|
||||
{ "PIN_Entry_Error", GPG_ERR_NO_PIN_ENTRY },
|
||||
{ "Bad_PIN", GPG_ERR_BAD_PIN },
|
||||
{ "Bad_Passphrase", GPG_ERR_BAD_PASSPHRASE },
|
||||
{ "Invalid_Name", GPG_ERR_INV_NAME },
|
||||
{ "Bad_Public_Key", GPG_ERR_BAD_PUBKEY },
|
||||
{ "Bad_Secret_Key", GPG_ERR_BAD_SECKEY },
|
||||
{ "Bad_Data", GPG_ERR_BAD_DATA },
|
||||
{ "Invalid_Parameter", GPG_ERR_INV_PARAMETER },
|
||||
{ "Tribute_to_D_A", GPG_ERR_TRIBUTE_TO_D_A },
|
||||
{ "No_Dirmngr", GPG_ERR_NO_DIRMNGR },
|
||||
{ "Dirmngr_Error", GPG_ERR_DIRMNGR },
|
||||
{ "Certificate_Revoked", GPG_ERR_CERT_REVOKED },
|
||||
{ "No_CRL_Known", GPG_ERR_NO_CRL_KNOWN },
|
||||
{ "CRL_Too_Old", GPG_ERR_CRL_TOO_OLD },
|
||||
{ "Line_Too_Long", GPG_ERR_LINE_TOO_LONG },
|
||||
{ "Not_Trusted", GPG_ERR_NOT_TRUSTED },
|
||||
{ "Canceled", GPG_ERR_CANCELED },
|
||||
{ "Bad_CA_Certificate", GPG_ERR_BAD_CA_CERT },
|
||||
{ "Certificate_Expired", GPG_ERR_CERT_EXPIRED },
|
||||
{ "Certificate_Too_Young", GPG_ERR_CERT_TOO_YOUNG },
|
||||
{ "Unsupported_Certificate", GPG_ERR_UNSUPPORTED_CERT },
|
||||
{ "Unknown_Sexp", GPG_ERR_UNKNOWN_SEXP },
|
||||
{ "Unsupported_Protection", GPG_ERR_UNSUPPORTED_PROTECTION },
|
||||
{ "Corrupted_Protection", GPG_ERR_CORRUPTED_PROTECTION },
|
||||
{ "Ambiguous_Name", GPG_ERR_AMBIGUOUS_NAME },
|
||||
{ "Card_Error", GPG_ERR_CARD },
|
||||
{ "Card_Reset", GPG_ERR_CARD_RESET },
|
||||
{ "Card_Removed", GPG_ERR_CARD_REMOVED },
|
||||
{ "Invalid_Card", GPG_ERR_INV_CARD },
|
||||
{ "Card_Not_Present", GPG_ERR_CARD_NOT_PRESENT },
|
||||
{ "No_PKCS15_App", GPG_ERR_NO_PKCS15_APP },
|
||||
{ "Not_Confirmed", GPG_ERR_NOT_CONFIRMED },
|
||||
{ "Configuration_Error", GPG_ERR_CONFIGURATION },
|
||||
{ "No_Policy_Match", GPG_ERR_NO_POLICY_MATCH },
|
||||
{ "Invalid_Index", GPG_ERR_INV_INDEX },
|
||||
{ "Invalid_Id", GPG_ERR_INV_ID },
|
||||
{ "No_Scdaemon", GPG_ERR_NO_SCDAEMON },
|
||||
{ "Scdaemon_Error", GPG_ERR_SCDAEMON },
|
||||
{ "Unsupported_Protocol", GPG_ERR_UNSUPPORTED_PROTOCOL },
|
||||
{ "Bad_PIN_Method", GPG_ERR_BAD_PIN_METHOD },
|
||||
{ "Card_Not_Initialized", GPG_ERR_CARD_NOT_INITIALIZED },
|
||||
{ "Unsupported_Operation", GPG_ERR_UNSUPPORTED_OPERATION },
|
||||
{ "Wrong_Key_Usage", GPG_ERR_WRONG_KEY_USAGE }
|
||||
};
|
||||
|
||||
|
||||
@ -326,7 +327,7 @@ _gpgme_map_gnupg_error (char *err)
|
||||
|
||||
for (i = 0; i < DIM (gnupg_errors); i++)
|
||||
if (!strcmp (gnupg_errors[i].name, err))
|
||||
return gnupg_errors[i].err;
|
||||
return gpg_err_make (GPG_ERR_SOURCE_GPG, gnupg_errors[i].err);
|
||||
|
||||
return GPGME_General_Error;
|
||||
return gpg_err_make (GPG_ERR_SOURCE_GPG, GPG_ERR_GENERAL);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* data-compat.c - Compatibility interfaces for data objects.
|
||||
Copyright (C) 2002 g10 Code GmbH
|
||||
Copyright (C) 2002, 2003 g10 Code GmbH
|
||||
|
||||
This file is part of GPGME.
|
||||
|
||||
@ -40,27 +40,40 @@ gpgme_data_new_from_filepart (gpgme_data_t *dh, const char *fname,
|
||||
char *buf = NULL;
|
||||
|
||||
if (stream && fname)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (fname)
|
||||
stream = fopen (fname, "rb");
|
||||
if (!stream)
|
||||
return GPGME_File_Error;
|
||||
return gpg_error_from_errno (errno);
|
||||
|
||||
if (fseek (stream, offset, SEEK_SET))
|
||||
goto ferr;
|
||||
{
|
||||
int saved_errno = errno;
|
||||
if (fname)
|
||||
fclose (stream);
|
||||
return gpg_error_from_errno (saved_errno);
|
||||
}
|
||||
|
||||
buf = malloc (length);
|
||||
if (!buf)
|
||||
goto ferr;
|
||||
{
|
||||
int saved_errno = errno;
|
||||
if (fname)
|
||||
fclose (stream);
|
||||
return gpg_error_from_errno (saved_errno);
|
||||
}
|
||||
|
||||
while (fread (buf, length, 1, stream) < 1
|
||||
&& ferror (stream) && errno == EINTR);
|
||||
if (ferror (stream))
|
||||
{
|
||||
int saved_errno = errno;
|
||||
if (buf)
|
||||
free (buf);
|
||||
goto ferr;
|
||||
if (fname)
|
||||
fclose (stream);
|
||||
return gpg_error_from_errno (saved_errno);
|
||||
}
|
||||
|
||||
if (fname)
|
||||
@ -78,15 +91,6 @@ gpgme_data_new_from_filepart (gpgme_data_t *dh, const char *fname,
|
||||
(*dh)->data.mem.size = length;
|
||||
(*dh)->data.mem.length = length;
|
||||
return 0;
|
||||
|
||||
ferr:
|
||||
{
|
||||
int saved_errno = errno;
|
||||
if (fname)
|
||||
fclose (stream);
|
||||
errno = saved_errno;
|
||||
return GPGME_File_Error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -98,10 +102,10 @@ gpgme_data_new_from_file (gpgme_data_t *dh, const char *fname, int copy)
|
||||
struct stat statbuf;
|
||||
|
||||
if (!fname || !copy)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (stat (fname, &statbuf) < 0)
|
||||
return GPGME_File_Error;
|
||||
return gpg_error_from_errno (errno);
|
||||
|
||||
return gpgme_data_new_from_filepart (dh, fname, NULL, 0, statbuf.st_size);
|
||||
}
|
||||
@ -110,26 +114,32 @@ gpgme_data_new_from_file (gpgme_data_t *dh, const char *fname, int copy)
|
||||
static int
|
||||
gpgme_error_to_errno (gpgme_error_t err)
|
||||
{
|
||||
switch (err)
|
||||
int no = gpg_err_code_to_errno (err);
|
||||
|
||||
if (no)
|
||||
{
|
||||
case GPGME_EOF:
|
||||
return 0;
|
||||
case GPGME_Out_Of_Core:
|
||||
errno = ENOMEM;
|
||||
errno = no;
|
||||
return -1;
|
||||
case GPGME_Invalid_Value:
|
||||
}
|
||||
|
||||
switch (gpg_err_code (err))
|
||||
{
|
||||
case GPG_ERR_EOF:
|
||||
return 0;
|
||||
case GPG_ERR_INV_VALUE:
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
case GPGME_Not_Implemented:
|
||||
case GPG_ERR_NOT_SUPPORTED:
|
||||
errno = EOPNOTSUPP;
|
||||
return -1;
|
||||
default:
|
||||
/* XXX Yeah, well. */
|
||||
/* FIXME: Yeah, well. */
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static ssize_t
|
||||
old_user_read (gpgme_data_t dh, void *buffer, size_t size)
|
||||
{
|
||||
@ -185,5 +195,5 @@ gpgme_error_t
|
||||
gpgme_data_rewind (gpgme_data_t dh)
|
||||
{
|
||||
return (gpgme_data_seek (dh, 0, SEEK_SET) == -1)
|
||||
? GPGME_File_Error : 0;
|
||||
? gpg_error_from_errno (errno) : 0;
|
||||
}
|
||||
|
16
gpgme/data.c
16
gpgme/data.c
@ -39,12 +39,12 @@ _gpgme_data_new (gpgme_data_t *r_dh, struct _gpgme_data_cbs *cbs)
|
||||
gpgme_data_t dh;
|
||||
|
||||
if (!r_dh)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
*r_dh = NULL;
|
||||
dh = calloc (1, sizeof (*dh));
|
||||
if (!dh)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
|
||||
dh->cbs = cbs;
|
||||
|
||||
@ -149,9 +149,9 @@ gpgme_error_t
|
||||
gpgme_data_set_encoding (gpgme_data_t dh, gpgme_data_encoding_t enc)
|
||||
{
|
||||
if (!dh)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
if (enc < 0 || enc > GPGME_DATA_ENCODING_ARMOR)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
dh->encoding = enc;
|
||||
return 0;
|
||||
}
|
||||
@ -169,7 +169,7 @@ _gpgme_data_inbound_handler (void *opaque, int fd)
|
||||
|
||||
buflen = read (fd, buffer, BUFFER_SIZE);
|
||||
if (buflen < 0)
|
||||
return GPGME_File_Error;
|
||||
return gpg_error_from_errno (errno);
|
||||
if (buflen == 0)
|
||||
{
|
||||
_gpgme_io_close (fd);
|
||||
@ -180,7 +180,7 @@ _gpgme_data_inbound_handler (void *opaque, int fd)
|
||||
{
|
||||
ssize_t amt = gpgme_data_write (dh, bufp, buflen);
|
||||
if (amt == 0 || (amt < 0 && errno != EINTR))
|
||||
return GPGME_File_Error;
|
||||
return gpg_error_from_errno (errno);
|
||||
bufp += amt;
|
||||
buflen -= amt;
|
||||
}
|
||||
@ -199,7 +199,7 @@ _gpgme_data_outbound_handler (void *opaque, int fd)
|
||||
{
|
||||
ssize_t amt = gpgme_data_read (dh, dh->pending, BUFFER_SIZE);
|
||||
if (amt < 0)
|
||||
return GPGME_File_Error;
|
||||
return gpg_error_from_errno (errno);
|
||||
if (amt == 0)
|
||||
{
|
||||
_gpgme_io_close (fd);
|
||||
@ -213,7 +213,7 @@ _gpgme_data_outbound_handler (void *opaque, int fd)
|
||||
return 0;
|
||||
|
||||
if (nwritten <= 0)
|
||||
return GPGME_File_Error;
|
||||
return gpg_error_from_errno (errno);
|
||||
|
||||
if (nwritten < dh->pending_len)
|
||||
memmove (dh->pending, dh->pending + nwritten, dh->pending_len - nwritten);
|
||||
|
@ -55,9 +55,9 @@ decrypt_verify_start (gpgme_ctx_t ctx, int synchronous,
|
||||
return err;
|
||||
|
||||
if (!cipher)
|
||||
return GPGME_No_Data;
|
||||
return gpg_error (GPG_ERR_NO_DATA);
|
||||
if (!plain)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (ctx->passphrase_cb)
|
||||
{
|
||||
|
@ -23,6 +23,7 @@
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "gpgme.h"
|
||||
#include "util.h"
|
||||
@ -86,10 +87,12 @@ _gpgme_decrypt_status_handler (void *priv, gpgme_status_code_t code,
|
||||
switch (code)
|
||||
{
|
||||
case GPGME_STATUS_EOF:
|
||||
/* FIXME: These error values should probably be attributed to
|
||||
the underlying crypto engine (as error source). */
|
||||
if (opd->failed)
|
||||
return GPGME_Decryption_Failed;
|
||||
return gpg_error (GPG_ERR_DECRYPT_FAILED);
|
||||
else if (!opd->okay)
|
||||
return GPGME_No_Data;
|
||||
return gpg_error (GPG_ERR_NO_DATA);
|
||||
break;
|
||||
|
||||
case GPGME_STATUS_DECRYPTION_OKAY:
|
||||
@ -126,7 +129,7 @@ _gpgme_decrypt_status_handler (void *priv, gpgme_status_code_t code,
|
||||
{
|
||||
opd->result.unsupported_algorithm = strdup (args);
|
||||
if (!opd->result.unsupported_algorithm)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -175,9 +178,9 @@ decrypt_start (gpgme_ctx_t ctx, int synchronous,
|
||||
return err;
|
||||
|
||||
if (!cipher)
|
||||
return GPGME_No_Data;
|
||||
return gpg_error (GPG_ERR_NO_DATA);
|
||||
if (!plain)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
|
@ -46,7 +46,7 @@ delete_status_handler (void *priv, gpgme_status_code_t code, char *args)
|
||||
errno = 0;
|
||||
problem = strtol (args, &tail, 0);
|
||||
if (errno || (*tail && *tail != ' '))
|
||||
return GPGME_General_Error;
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
|
||||
switch (problem)
|
||||
{
|
||||
@ -54,16 +54,16 @@ delete_status_handler (void *priv, gpgme_status_code_t code, char *args)
|
||||
break;
|
||||
|
||||
case DELETE_No_Such_Key:
|
||||
return GPGME_Invalid_Key;
|
||||
return gpg_error (GPG_ERR_NO_PUBKEY);
|
||||
|
||||
case DELETE_Must_Delete_Secret_Key:
|
||||
return GPGME_Conflict;
|
||||
return gpg_error (GPG_ERR_CONFLICT);
|
||||
|
||||
case DELETE_Ambiguous_Specification:
|
||||
return GPGME_Ambiguous_Specification;
|
||||
return gpg_error (GPG_ERR_AMBIGUOUS_NAME);
|
||||
|
||||
default:
|
||||
return GPGME_General_Error;
|
||||
return gpg_error (GPG_ERR_GENERAL);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -105,7 +105,7 @@ edit_start (gpgme_ctx_t ctx, int synchronous, gpgme_key_t key,
|
||||
return err;
|
||||
|
||||
if (!fnc || !out)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
err = _gpgme_op_data_lookup (ctx, OPDATA_EDIT, &hook, sizeof (*opd), NULL);
|
||||
opd = hook;
|
||||
|
@ -48,9 +48,9 @@ encrypt_sign_start (gpgme_ctx_t ctx, int synchronous, gpgme_key_t recp[],
|
||||
return err;
|
||||
|
||||
if (!plain)
|
||||
return GPGME_No_Data;
|
||||
return gpg_error (GPG_ERR_NO_DATA);
|
||||
if (!cipher || !recp)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
err = _gpgme_op_encrypt_init_result (ctx);
|
||||
if (err)
|
||||
|
@ -91,7 +91,7 @@ _gpgme_encrypt_status_handler (void *priv, gpgme_status_code_t code,
|
||||
{
|
||||
case GPGME_STATUS_EOF:
|
||||
if (opd->result.invalid_recipients)
|
||||
return GPGME_Invalid_Key;
|
||||
return gpg_error (GPG_ERR_UNUSABLE_PUBKEY);
|
||||
break;
|
||||
|
||||
case GPGME_STATUS_INV_RECP:
|
||||
@ -104,7 +104,7 @@ _gpgme_encrypt_status_handler (void *priv, gpgme_status_code_t code,
|
||||
|
||||
case GPGME_STATUS_NO_RECP:
|
||||
/* Should not happen, because we require at least one recipient. */
|
||||
return GPGME_General_Error;
|
||||
return gpg_error (GPG_ERR_GENERAL);
|
||||
|
||||
default:
|
||||
break;
|
||||
@ -167,11 +167,11 @@ encrypt_start (gpgme_ctx_t ctx, int synchronous, gpgme_key_t recp[],
|
||||
symmetric = 1;
|
||||
|
||||
if (!plain)
|
||||
return GPGME_No_Data;
|
||||
return gpg_error (GPG_ERR_NO_DATA);
|
||||
if (!cipher)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
if (recp && ! *recp)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (symmetric && ctx->passphrase_cb)
|
||||
{
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <unistd.h>
|
||||
#include <locale.h>
|
||||
#include <fcntl.h> /* FIXME */
|
||||
#include <errno.h>
|
||||
|
||||
#include "gpgme.h"
|
||||
#include "util.h"
|
||||
@ -151,100 +152,119 @@ close_notify_handler (int fd, void *opaque)
|
||||
static gpgme_error_t
|
||||
map_assuan_error (AssuanError err)
|
||||
{
|
||||
/* New code will use gpg_error_t values. */
|
||||
if (gpg_err_source (err))
|
||||
return (gpgme_error_t) err;
|
||||
|
||||
/* Legacy code will use old values. */
|
||||
switch (err)
|
||||
{
|
||||
case ASSUAN_No_Error:
|
||||
return GPGME_No_Error;
|
||||
return gpg_error (GPG_ERR_NO_ERROR);
|
||||
case ASSUAN_General_Error:
|
||||
return GPGME_General_Error;
|
||||
return gpg_error (GPG_ERR_GENERAL);
|
||||
case ASSUAN_Out_Of_Core:
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error (GPG_ERR_ENOMEM);
|
||||
case ASSUAN_Invalid_Value:
|
||||
return GPGME_Invalid_Value;
|
||||
case ASSUAN_Read_Error:
|
||||
return GPGME_Read_Error;
|
||||
case ASSUAN_Write_Error:
|
||||
return GPGME_Write_Error;
|
||||
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
case ASSUAN_Timeout:
|
||||
return gpg_error (GPG_ERR_ETIMEDOUT);
|
||||
case ASSUAN_Read_Error:
|
||||
return gpg_error (GPG_ERR_GENERAL);
|
||||
case ASSUAN_Write_Error:
|
||||
return gpg_error (GPG_ERR_GENERAL);
|
||||
|
||||
case ASSUAN_Problem_Starting_Server:
|
||||
case ASSUAN_Not_A_Server:
|
||||
case ASSUAN_Not_A_Client:
|
||||
case ASSUAN_Nested_Commands:
|
||||
case ASSUAN_Invalid_Response:
|
||||
case ASSUAN_No_Data_Callback:
|
||||
case ASSUAN_No_Inquire_Callback:
|
||||
case ASSUAN_Connect_Failed:
|
||||
case ASSUAN_Accept_Failed:
|
||||
return GPGME_General_Error;
|
||||
|
||||
/* The following error codes are meant as status codes. */
|
||||
case ASSUAN_Not_Implemented:
|
||||
return GPGME_Not_Implemented;
|
||||
case ASSUAN_Canceled:
|
||||
return GPGME_Canceled;
|
||||
case ASSUAN_Unsupported_Algorithm:
|
||||
return GPGME_Not_Implemented; /* XXX Argh. */
|
||||
|
||||
case ASSUAN_No_Data_Available:
|
||||
return GPGME_EOF;
|
||||
|
||||
/* These are errors internal to GPGME. */
|
||||
case ASSUAN_No_Input:
|
||||
case ASSUAN_No_Output:
|
||||
case ASSUAN_Invalid_Command:
|
||||
case ASSUAN_Unknown_Command:
|
||||
case ASSUAN_Syntax_Error:
|
||||
case ASSUAN_Parameter_Error:
|
||||
case ASSUAN_Parameter_Conflict:
|
||||
case ASSUAN_Line_Too_Long:
|
||||
case ASSUAN_Line_Not_Terminated:
|
||||
case ASSUAN_Invalid_Data:
|
||||
case ASSUAN_Unexpected_Command:
|
||||
case ASSUAN_No_Input:
|
||||
case ASSUAN_No_Output:
|
||||
case ASSUAN_No_Data_Available:
|
||||
case ASSUAN_Too_Much_Data:
|
||||
case ASSUAN_Inquire_Unknown:
|
||||
case ASSUAN_Inquire_Error:
|
||||
case ASSUAN_Invalid_Option:
|
||||
case ASSUAN_Invalid_Index:
|
||||
case ASSUAN_Unexpected_Status:
|
||||
case ASSUAN_Unexpected_Data:
|
||||
case ASSUAN_Invalid_Status:
|
||||
case ASSUAN_Not_Confirmed:
|
||||
return GPGME_General_Error;
|
||||
return gpg_error (GPG_ERR_ASSUAN);
|
||||
|
||||
/* These are errors in the server. */
|
||||
case ASSUAN_Server_Fault:
|
||||
case ASSUAN_Invalid_Response:
|
||||
return gpg_error (GPG_ERR_INV_RESPONSE);
|
||||
|
||||
case ASSUAN_Not_Implemented:
|
||||
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
|
||||
case ASSUAN_Line_Too_Long:
|
||||
return gpg_error (GPG_ERR_LINE_TOO_LONG);
|
||||
case ASSUAN_Line_Not_Terminated:
|
||||
return gpg_error (GPG_ERR_INCOMPLETE_LINE);
|
||||
case ASSUAN_Canceled:
|
||||
return gpg_error (GPG_ERR_CANCELED);
|
||||
|
||||
case ASSUAN_Unsupported_Algorithm:
|
||||
return gpg_error (GPG_ERR_UNSUPPORTED_ALGORITHM);
|
||||
case ASSUAN_Server_Resource_Problem:
|
||||
return gpg_error (GPG_ERR_RESOURCE_LIMIT);
|
||||
case ASSUAN_Server_IO_Error:
|
||||
return gpg_error (GPG_ERR_GENERAL);
|
||||
case ASSUAN_Server_Bug:
|
||||
case ASSUAN_No_Agent:
|
||||
case ASSUAN_Agent_Error:
|
||||
return GPGME_Invalid_Engine; /* XXX: Need something more useful. */
|
||||
|
||||
return gpg_error (GPG_ERR_BUG);
|
||||
case ASSUAN_Invalid_Data:
|
||||
return gpg_error (GPG_ERR_INV_DATA);
|
||||
case ASSUAN_Invalid_Index:
|
||||
return gpg_error (GPG_ERR_INV_INDEX);
|
||||
case ASSUAN_Not_Confirmed:
|
||||
return gpg_error (GPG_ERR_NOT_CONFIRMED);
|
||||
case ASSUAN_Bad_Certificate:
|
||||
return gpg_error (GPG_ERR_BAD_CERT);
|
||||
case ASSUAN_Bad_Certificate_Chain:
|
||||
return gpg_error (GPG_ERR_BAD_CERT_CHAIN);
|
||||
case ASSUAN_Missing_Certificate:
|
||||
case ASSUAN_No_Public_Key:
|
||||
case ASSUAN_No_Secret_Key:
|
||||
case ASSUAN_Invalid_Name:
|
||||
case ASSUAN_Card_Error: /* XXX: Oh well. */
|
||||
case ASSUAN_Invalid_Card: /* XXX: Oh well. */
|
||||
case ASSUAN_No_PKCS15_App: /* XXX: Oh well. */
|
||||
case ASSUAN_Card_Not_Present: /* XXX: Oh well. */
|
||||
case ASSUAN_Invalid_Id: /* XXX: Oh well. */
|
||||
return GPGME_Invalid_Key;
|
||||
|
||||
return gpg_error (GPG_ERR_MISSING_CERT);
|
||||
case ASSUAN_Bad_Signature:
|
||||
return GPGME_Invalid_Key; /* XXX: This is wrong. */
|
||||
return gpg_error (GPG_ERR_BAD_SIGNATURE);
|
||||
case ASSUAN_No_Agent:
|
||||
return gpg_error (GPG_ERR_NO_AGENT);
|
||||
case ASSUAN_Agent_Error:
|
||||
return gpg_error (GPG_ERR_AGENT);
|
||||
case ASSUAN_No_Public_Key:
|
||||
return gpg_error (GPG_ERR_NO_PUBKEY);
|
||||
case ASSUAN_No_Secret_Key:
|
||||
return gpg_error (GPG_ERR_NO_SECKEY);
|
||||
case ASSUAN_Invalid_Name:
|
||||
return gpg_error (GPG_ERR_INV_NAME);
|
||||
|
||||
case ASSUAN_Cert_Revoked:
|
||||
return gpg_error (GPG_ERR_CERT_REVOKED);
|
||||
case ASSUAN_No_CRL_For_Cert:
|
||||
return gpg_error (GPG_ERR_NO_CRL_KNOWN);
|
||||
case ASSUAN_CRL_Too_Old:
|
||||
return gpg_error (GPG_ERR_CRL_TOO_OLD);
|
||||
case ASSUAN_Not_Trusted:
|
||||
return GPGME_Invalid_Key; /* XXX Some more details would be good. */
|
||||
return gpg_error (GPG_ERR_NOT_TRUSTED);
|
||||
|
||||
case ASSUAN_Card_Error:
|
||||
return gpg_error (GPG_ERR_CARD);
|
||||
case ASSUAN_Invalid_Card:
|
||||
return gpg_error (GPG_ERR_INV_CARD);
|
||||
case ASSUAN_No_PKCS15_App:
|
||||
return gpg_error (GPG_ERR_NO_PKCS15_APP);
|
||||
case ASSUAN_Card_Not_Present:
|
||||
return gpg_error (GPG_ERR_CARD_NOT_PRESENT);
|
||||
case ASSUAN_Invalid_Id:
|
||||
return gpg_error (GPG_ERR_INV_ID);
|
||||
default:
|
||||
return GPGME_General_Error;
|
||||
return gpg_error (GPG_ERR_GENERAL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -292,10 +312,7 @@ gpgsm_new (void **engine)
|
||||
|
||||
gpgsm = calloc (1, sizeof *gpgsm);
|
||||
if (!gpgsm)
|
||||
{
|
||||
err = GPGME_Out_Of_Core;
|
||||
return err;
|
||||
}
|
||||
return gpg_error_from_errno (errno);
|
||||
|
||||
gpgsm->status_cb.fd = -1;
|
||||
gpgsm->status_cb.tag = 0;
|
||||
@ -325,7 +342,7 @@ gpgsm_new (void **engine)
|
||||
|
||||
if (_gpgme_io_pipe (fds, 0) < 0)
|
||||
{
|
||||
err = GPGME_Pipe_Error;
|
||||
err = gpg_error_from_errno (errno);
|
||||
goto leave;
|
||||
}
|
||||
gpgsm->input_cb.fd = fds[1];
|
||||
@ -334,7 +351,7 @@ gpgsm_new (void **engine)
|
||||
|
||||
if (_gpgme_io_pipe (fds, 1) < 0)
|
||||
{
|
||||
err = GPGME_Pipe_Error;
|
||||
err = gpg_error_from_errno (errno);
|
||||
goto leave;
|
||||
}
|
||||
gpgsm->output_cb.fd = fds[0];
|
||||
@ -343,7 +360,7 @@ gpgsm_new (void **engine)
|
||||
|
||||
if (_gpgme_io_pipe (fds, 0) < 0)
|
||||
{
|
||||
err = GPGME_Pipe_Error;
|
||||
err = gpg_error_from_errno (errno);
|
||||
goto leave;
|
||||
}
|
||||
gpgsm->message_cb.fd = fds[1];
|
||||
@ -369,7 +386,7 @@ gpgsm_new (void **engine)
|
||||
fdlist, DIM (fdlist));
|
||||
if (nfds < 1)
|
||||
{
|
||||
err = GPGME_General_Error; /* FIXME */
|
||||
err = gpg_error (GPG_ERR_GENERAL); /* FIXME */
|
||||
goto leave;
|
||||
}
|
||||
/* We duplicate the file descriptor, so we can close it without
|
||||
@ -380,7 +397,7 @@ gpgsm_new (void **engine)
|
||||
gpgsm->status_cb.fd = dup (fdlist[0]);
|
||||
if (gpgsm->status_cb.fd < 0)
|
||||
{
|
||||
err = GPGME_General_Error; /* FIXME */
|
||||
err = gpg_error (GPG_ERR_GENERAL); /* FIXME */
|
||||
goto leave;
|
||||
}
|
||||
gpgsm->status_cb.dir = 1;
|
||||
@ -391,7 +408,7 @@ gpgsm_new (void **engine)
|
||||
{
|
||||
if (asprintf (&optstr, "OPTION display=%s", dft_display) < 0)
|
||||
{
|
||||
err = GPGME_Out_Of_Core;
|
||||
err = gpg_error_from_errno (errno);
|
||||
goto leave;
|
||||
}
|
||||
err = assuan_transact (gpgsm->assuan_ctx, optstr, NULL, NULL, NULL,
|
||||
@ -408,7 +425,7 @@ gpgsm_new (void **engine)
|
||||
{
|
||||
if (asprintf (&optstr, "OPTION ttyname=%s", dft_ttyname) < 0)
|
||||
{
|
||||
err = GPGME_Out_Of_Core;
|
||||
err = gpg_error_from_errno (errno);
|
||||
goto leave;
|
||||
}
|
||||
err = assuan_transact (gpgsm->assuan_ctx, optstr, NULL, NULL, NULL,
|
||||
@ -425,7 +442,7 @@ gpgsm_new (void **engine)
|
||||
{
|
||||
if (asprintf (&optstr, "OPTION ttytype=%s", dft_ttytype) < 0)
|
||||
{
|
||||
err = GPGME_Out_Of_Core;
|
||||
err = gpg_error_from_errno (errno);
|
||||
goto leave;
|
||||
}
|
||||
err = assuan_transact (gpgsm->assuan_ctx, optstr, NULL, NULL, NULL,
|
||||
@ -444,7 +461,7 @@ gpgsm_new (void **engine)
|
||||
old_lc = strdup (old_lc);
|
||||
if (!old_lc)
|
||||
{
|
||||
err = GPGME_Out_Of_Core;
|
||||
err = gpg_error_from_errno (errno);
|
||||
goto leave;
|
||||
}
|
||||
}
|
||||
@ -452,7 +469,7 @@ gpgsm_new (void **engine)
|
||||
if (dft_lc)
|
||||
{
|
||||
if (asprintf (&optstr, "OPTION lc-ctype=%s", dft_lc) < 0)
|
||||
err = GPGME_Out_Of_Core;
|
||||
err = gpg_error_from_errno (errno);
|
||||
else
|
||||
{
|
||||
err = assuan_transact (gpgsm->assuan_ctx, optstr, NULL, NULL,
|
||||
@ -470,14 +487,13 @@ gpgsm_new (void **engine)
|
||||
if (err)
|
||||
goto leave;
|
||||
|
||||
|
||||
old_lc = setlocale (LC_MESSAGES, NULL);
|
||||
if (old_lc)
|
||||
{
|
||||
old_lc = strdup (old_lc);
|
||||
if (!old_lc)
|
||||
{
|
||||
err = GPGME_Out_Of_Core;
|
||||
err = gpg_error_from_errno (errno);
|
||||
goto leave;
|
||||
}
|
||||
}
|
||||
@ -485,7 +501,7 @@ gpgsm_new (void **engine)
|
||||
if (dft_lc)
|
||||
{
|
||||
if (asprintf (&optstr, "OPTION lc-messages=%s", dft_lc) < 0)
|
||||
err = GPGME_Out_Of_Core;
|
||||
err = gpg_error_from_errno (errno);
|
||||
else
|
||||
{
|
||||
err = assuan_transact (gpgsm->assuan_ctx, optstr, NULL, NULL,
|
||||
@ -514,7 +530,7 @@ gpgsm_new (void **engine)
|
||||
|| _gpgme_io_set_close_notify (gpgsm->message_cb.fd,
|
||||
close_notify_handler, gpgsm)))
|
||||
{
|
||||
err = GPGME_General_Error;
|
||||
err = gpg_error (GPG_ERR_GENERAL);
|
||||
goto leave;
|
||||
}
|
||||
|
||||
@ -587,10 +603,10 @@ gpgsm_assuan_simple_command (ASSUAN_CONTEXT ctx, char *cmd,
|
||||
if (r >= 0 && status_fnc)
|
||||
status_fnc (status_fnc_value, r, rest);
|
||||
else
|
||||
err = GPGME_General_Error;
|
||||
err = gpg_error (GPG_ERR_GENERAL);
|
||||
}
|
||||
else
|
||||
err = GPGME_General_Error;
|
||||
err = gpg_error (GPG_ERR_GENERAL);
|
||||
}
|
||||
while (!err);
|
||||
|
||||
@ -679,7 +695,7 @@ status_handler (void *opaque, int fd)
|
||||
if (line[3] == ' ')
|
||||
err = map_assuan_error (atoi (&line[4]));
|
||||
else
|
||||
err = GPGME_General_Error;
|
||||
err = gpg_error (GPG_ERR_GENERAL);
|
||||
}
|
||||
else if (linelen >= 2
|
||||
&& line[0] == 'O' && line[1] == 'K'
|
||||
@ -724,7 +740,7 @@ status_handler (void *opaque, int fd)
|
||||
unsigned char *newline = realloc (*aline,
|
||||
*alinelen + linelen + 1);
|
||||
if (!newline)
|
||||
err = GPGME_Out_Of_Core;
|
||||
err = gpg_error_from_errno (errno);
|
||||
else
|
||||
{
|
||||
*aline = newline;
|
||||
@ -850,17 +866,17 @@ gpgsm_decrypt (void *engine, gpgme_data_t ciph, gpgme_data_t plain)
|
||||
gpgme_error_t err;
|
||||
|
||||
if (!gpgsm)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
gpgsm->input_cb.data = ciph;
|
||||
err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server,
|
||||
map_input_enc (gpgsm->input_cb.data));
|
||||
if (err)
|
||||
return GPGME_General_Error; /* FIXME */
|
||||
return gpg_error (GPG_ERR_GENERAL); /* FIXME */
|
||||
gpgsm->output_cb.data = plain;
|
||||
err = gpgsm_set_fd (gpgsm->assuan_ctx, "OUTPUT", gpgsm->output_fd_server, 0);
|
||||
if (err)
|
||||
return GPGME_General_Error; /* FIXME */
|
||||
return gpg_error (GPG_ERR_GENERAL); /* FIXME */
|
||||
_gpgme_io_close (gpgsm->message_cb.fd);
|
||||
|
||||
err = start (engine, "DECRYPT");
|
||||
@ -879,7 +895,7 @@ gpgsm_delete (void *engine, gpgme_key_t key, int allow_secret)
|
||||
int length = 8; /* "DELKEYS " */
|
||||
|
||||
if (!fpr)
|
||||
return GPGME_Invalid_Key;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
while (*linep)
|
||||
{
|
||||
@ -892,7 +908,7 @@ gpgsm_delete (void *engine, gpgme_key_t key, int allow_secret)
|
||||
|
||||
line = malloc (length);
|
||||
if (!line)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
|
||||
strcpy (line, "DELKEYS ");
|
||||
linep = &line[8];
|
||||
@ -948,7 +964,7 @@ set_recipients (engine_gpgsm_t gpgsm, gpgme_key_t recp[])
|
||||
linelen = 10 + 40 + 1; /* "RECIPIENT " + guess + '\0'. */
|
||||
line = malloc (10 + 40 + 1);
|
||||
if (!line)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
strcpy (line, "RECIPIENT ");
|
||||
while (!err && recp[i])
|
||||
{
|
||||
@ -967,8 +983,9 @@ set_recipients (engine_gpgsm_t gpgsm, gpgme_key_t recp[])
|
||||
char *newline = realloc (line, newlen);
|
||||
if (! newline)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
free (line);
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (saved_errno);
|
||||
}
|
||||
line = newline;
|
||||
linelen = newlen;
|
||||
@ -977,7 +994,8 @@ set_recipients (engine_gpgsm_t gpgsm, gpgme_key_t recp[])
|
||||
|
||||
err = gpgsm_assuan_simple_command (ctx, line, gpgsm->status.fnc,
|
||||
gpgsm->status.fnc_value);
|
||||
if (err == GPGME_Invalid_Key)
|
||||
/* FIXME: This requires more work. */
|
||||
if (gpg_err_code (err) == GPG_ERR_NO_PUBKEY)
|
||||
invalid_recipients++;
|
||||
else if (err)
|
||||
{
|
||||
@ -987,7 +1005,8 @@ set_recipients (engine_gpgsm_t gpgsm, gpgme_key_t recp[])
|
||||
i++;
|
||||
}
|
||||
free (line);
|
||||
return invalid_recipients ? GPGME_Invalid_Key : 0;
|
||||
return gpg_error (invalid_recipients
|
||||
? GPG_ERR_UNUSABLE_PUBKEY : GPG_ERR_NO_ERROR);
|
||||
}
|
||||
|
||||
|
||||
@ -999,9 +1018,9 @@ gpgsm_encrypt (void *engine, gpgme_key_t recp[], gpgme_encrypt_flags_t flags,
|
||||
gpgme_error_t err;
|
||||
|
||||
if (!gpgsm)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
if (!recp)
|
||||
return GPGME_Not_Implemented;
|
||||
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
|
||||
|
||||
gpgsm->input_cb.data = plain;
|
||||
err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server,
|
||||
@ -1033,14 +1052,14 @@ gpgsm_export (void *engine, const char *pattern, unsigned int reserved,
|
||||
char *cmd;
|
||||
|
||||
if (!gpgsm || reserved)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (!pattern)
|
||||
pattern = "";
|
||||
|
||||
cmd = malloc (7 + strlen (pattern) + 1);
|
||||
if (!cmd)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
strcpy (cmd, "EXPORT ");
|
||||
strcpy (&cmd[7], pattern);
|
||||
|
||||
@ -1070,7 +1089,7 @@ gpgsm_export_ext (void *engine, const char *pattern[], unsigned int reserved,
|
||||
char *linep;
|
||||
|
||||
if (!gpgsm || reserved)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (pattern && *pattern)
|
||||
{
|
||||
@ -1094,7 +1113,7 @@ gpgsm_export_ext (void *engine, const char *pattern[], unsigned int reserved,
|
||||
}
|
||||
line = malloc (length);
|
||||
if (!line)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
|
||||
strcpy (line, "EXPORT ");
|
||||
linep = &line[7];
|
||||
@ -1157,7 +1176,7 @@ gpgsm_genkey (void *engine, gpgme_data_t help_data, int use_armor,
|
||||
gpgme_error_t err;
|
||||
|
||||
if (!gpgsm || !pubkey || seckey)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
gpgsm->input_cb.data = help_data;
|
||||
err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server,
|
||||
@ -1183,7 +1202,7 @@ gpgsm_import (void *engine, gpgme_data_t keydata)
|
||||
gpgme_error_t err;
|
||||
|
||||
if (!gpgsm)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
gpgsm->input_cb.data = keydata;
|
||||
err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server,
|
||||
@ -1216,7 +1235,7 @@ gpgsm_keylist (void *engine, const char *pattern, int secret_only,
|
||||
pattern = "";
|
||||
|
||||
if (asprintf (&line, "OPTION list-mode=%d", (list_mode & 3)) < 0)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
err = gpgsm_assuan_simple_command (gpgsm->assuan_ctx, line, NULL, NULL);
|
||||
free (line);
|
||||
if (err)
|
||||
@ -1225,7 +1244,7 @@ gpgsm_keylist (void *engine, const char *pattern, int secret_only,
|
||||
/* Length is "LISTSECRETKEYS " + p + '\0'. */
|
||||
line = malloc (15 + strlen (pattern) + 1);
|
||||
if (!line)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
if (secret_only)
|
||||
{
|
||||
strcpy (line, "LISTSECRETKEYS ");
|
||||
@ -1260,7 +1279,7 @@ gpgsm_keylist_ext (void *engine, const char *pattern[], int secret_only,
|
||||
int list_mode = 0;
|
||||
|
||||
if (reserved)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (mode & GPGME_KEYLIST_MODE_LOCAL)
|
||||
list_mode |= 1;
|
||||
@ -1268,7 +1287,7 @@ gpgsm_keylist_ext (void *engine, const char *pattern[], int secret_only,
|
||||
list_mode |= 2;
|
||||
|
||||
if (asprintf (&line, "OPTION list-mode=%d", (list_mode & 3)) < 0)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
err = gpgsm_assuan_simple_command (gpgsm->assuan_ctx, line, NULL, NULL);
|
||||
free (line);
|
||||
if (err)
|
||||
@ -1296,7 +1315,7 @@ gpgsm_keylist_ext (void *engine, const char *pattern[], int secret_only,
|
||||
}
|
||||
line = malloc (length);
|
||||
if (!line)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
if (secret_only)
|
||||
{
|
||||
strcpy (line, "LISTSECRETKEYS ");
|
||||
@ -1366,10 +1385,10 @@ gpgsm_sign (void *engine, gpgme_data_t in, gpgme_data_t out,
|
||||
gpgme_key_t key;
|
||||
|
||||
if (!gpgsm)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (asprintf (&assuan_cmd, "OPTION include-certs %i", include_certs) < 0)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
err = gpgsm_assuan_simple_command (gpgsm->assuan_ctx, assuan_cmd, NULL,NULL);
|
||||
free (assuan_cmd);
|
||||
if (err)
|
||||
@ -1393,7 +1412,7 @@ gpgsm_sign (void *engine, gpgme_data_t in, gpgme_data_t out,
|
||||
NULL, NULL);
|
||||
}
|
||||
else
|
||||
err = GPGME_Invalid_Key;
|
||||
err = gpg_error (GPG_ERR_INV_VALUE);
|
||||
gpgme_key_unref (key);
|
||||
if (err)
|
||||
return err;
|
||||
@ -1417,14 +1436,6 @@ gpgsm_sign (void *engine, gpgme_data_t in, gpgme_data_t out,
|
||||
}
|
||||
|
||||
|
||||
static gpgme_error_t
|
||||
gpgsm_trustlist (void *engine, const char *pattern)
|
||||
{
|
||||
/* FIXME */
|
||||
return GPGME_Not_Implemented;
|
||||
}
|
||||
|
||||
|
||||
static gpgme_error_t
|
||||
gpgsm_verify (void *engine, gpgme_data_t sig, gpgme_data_t signed_text,
|
||||
gpgme_data_t plaintext)
|
||||
@ -1433,7 +1444,7 @@ gpgsm_verify (void *engine, gpgme_data_t sig, gpgme_data_t signed_text,
|
||||
gpgme_error_t err;
|
||||
|
||||
if (!gpgsm)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
gpgsm->input_cb.data = sig;
|
||||
err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server,
|
||||
@ -1531,7 +1542,7 @@ struct engine_ops _gpgme_engine_ops_gpgsm =
|
||||
gpgsm_keylist,
|
||||
gpgsm_keylist_ext,
|
||||
gpgsm_sign,
|
||||
gpgsm_trustlist,
|
||||
NULL, /* trustlist */
|
||||
gpgsm_verify,
|
||||
gpgsm_set_io_cbs,
|
||||
gpgsm_io_event
|
||||
|
@ -23,6 +23,7 @@
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "gpgme.h"
|
||||
#include "util.h"
|
||||
@ -99,7 +100,7 @@ gpgme_engine_check_version (gpgme_protocol_t proto)
|
||||
{
|
||||
return _gpgme_compare_versions (engine_get_version (proto),
|
||||
engine_get_req_version (proto))
|
||||
? 0 : GPGME_Invalid_Engine;
|
||||
? 0 : gpg_error (GPG_ERR_INV_ENGINE);
|
||||
}
|
||||
|
||||
|
||||
@ -130,6 +131,8 @@ gpgme_get_engine_info (gpgme_engine_info_t *info)
|
||||
*lastp = malloc (sizeof (*engine_info));
|
||||
if (!*lastp)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
|
||||
while (engine_info)
|
||||
{
|
||||
gpgme_engine_info_t next_info = engine_info->next;
|
||||
@ -137,7 +140,7 @@ gpgme_get_engine_info (gpgme_engine_info_t *info)
|
||||
engine_info = next_info;
|
||||
}
|
||||
UNLOCK (engine_info_lock);
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (saved_errno);
|
||||
}
|
||||
|
||||
(*lastp)->protocol = proto_list[proto];
|
||||
@ -162,19 +165,19 @@ _gpgme_engine_new (gpgme_protocol_t proto, engine_t *r_engine)
|
||||
const char *version;
|
||||
|
||||
if (proto > DIM (engine_ops))
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (!engine_ops[proto])
|
||||
return GPGME_Invalid_Engine;
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
|
||||
file_name = engine_get_file_name (proto);
|
||||
version = engine_get_version (proto);
|
||||
if (!file_name || !version)
|
||||
return GPGME_Invalid_Engine;
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
|
||||
engine = calloc (1, sizeof *engine);
|
||||
if (!engine)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
|
||||
engine->ops = engine_ops[proto];
|
||||
if (engine_ops[proto]->new)
|
||||
@ -225,10 +228,10 @@ _gpgme_engine_set_command_handler (engine_t engine,
|
||||
gpgme_data_t linked_data)
|
||||
{
|
||||
if (!engine)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (!engine->ops->set_command_handler)
|
||||
return GPGME_Not_Implemented;
|
||||
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
|
||||
|
||||
return (*engine->ops->set_command_handler) (engine->engine,
|
||||
fnc, fnc_value, linked_data);
|
||||
@ -240,10 +243,10 @@ _gpgme_engine_set_colon_line_handler (engine_t engine,
|
||||
void *fnc_value)
|
||||
{
|
||||
if (!engine)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (!engine->ops->set_colon_line_handler)
|
||||
return GPGME_Not_Implemented;
|
||||
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
|
||||
|
||||
return (*engine->ops->set_colon_line_handler) (engine->engine,
|
||||
fnc, fnc_value);
|
||||
@ -254,10 +257,10 @@ _gpgme_engine_op_decrypt (engine_t engine, gpgme_data_t ciph,
|
||||
gpgme_data_t plain)
|
||||
{
|
||||
if (!engine)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (!engine->ops->decrypt)
|
||||
return GPGME_Not_Implemented;
|
||||
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
|
||||
|
||||
return (*engine->ops->decrypt) (engine->engine, ciph, plain);
|
||||
}
|
||||
@ -267,10 +270,10 @@ _gpgme_engine_op_delete (engine_t engine, gpgme_key_t key,
|
||||
int allow_secret)
|
||||
{
|
||||
if (!engine)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (!engine->ops->delete)
|
||||
return GPGME_Not_Implemented;
|
||||
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
|
||||
|
||||
return (*engine->ops->delete) (engine->engine, key, allow_secret);
|
||||
}
|
||||
@ -281,10 +284,10 @@ _gpgme_engine_op_edit (engine_t engine, gpgme_key_t key, gpgme_data_t out,
|
||||
gpgme_ctx_t ctx /* FIXME */)
|
||||
{
|
||||
if (!engine)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (!engine->ops->edit)
|
||||
return GPGME_Not_Implemented;
|
||||
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
|
||||
|
||||
return (*engine->ops->edit) (engine->engine, key, out, ctx);
|
||||
}
|
||||
@ -296,10 +299,10 @@ _gpgme_engine_op_encrypt (engine_t engine, gpgme_key_t recp[],
|
||||
gpgme_data_t plain, gpgme_data_t ciph, int use_armor)
|
||||
{
|
||||
if (!engine)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (!engine->ops->encrypt)
|
||||
return GPGME_Not_Implemented;
|
||||
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
|
||||
|
||||
return (*engine->ops->encrypt) (engine->engine, recp, flags, plain, ciph,
|
||||
use_armor);
|
||||
@ -313,10 +316,10 @@ _gpgme_engine_op_encrypt_sign (engine_t engine, gpgme_key_t recp[],
|
||||
int use_armor, gpgme_ctx_t ctx /* FIXME */)
|
||||
{
|
||||
if (!engine)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (!engine->ops->encrypt_sign)
|
||||
return GPGME_Not_Implemented;
|
||||
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
|
||||
|
||||
return (*engine->ops->encrypt_sign) (engine->engine, recp, flags,
|
||||
plain, ciph, use_armor, ctx);
|
||||
@ -329,10 +332,10 @@ _gpgme_engine_op_export (engine_t engine, const char *pattern,
|
||||
int use_armor)
|
||||
{
|
||||
if (!engine)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (!engine->ops->export)
|
||||
return GPGME_Not_Implemented;
|
||||
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
|
||||
|
||||
return (*engine->ops->export) (engine->engine, pattern, reserved,
|
||||
keydata, use_armor);
|
||||
@ -345,10 +348,10 @@ _gpgme_engine_op_export_ext (engine_t engine, const char *pattern[],
|
||||
int use_armor)
|
||||
{
|
||||
if (!engine)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (!engine->ops->export_ext)
|
||||
return GPGME_Not_Implemented;
|
||||
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
|
||||
|
||||
return (*engine->ops->export_ext) (engine->engine, pattern, reserved,
|
||||
keydata, use_armor);
|
||||
@ -361,10 +364,10 @@ _gpgme_engine_op_genkey (engine_t engine, gpgme_data_t help_data,
|
||||
gpgme_data_t seckey)
|
||||
{
|
||||
if (!engine)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (!engine->ops->genkey)
|
||||
return GPGME_Not_Implemented;
|
||||
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
|
||||
|
||||
return (*engine->ops->genkey) (engine->engine, help_data, use_armor,
|
||||
pubkey, seckey);
|
||||
@ -375,10 +378,10 @@ gpgme_error_t
|
||||
_gpgme_engine_op_import (engine_t engine, gpgme_data_t keydata)
|
||||
{
|
||||
if (!engine)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (!engine->ops->import)
|
||||
return GPGME_Not_Implemented;
|
||||
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
|
||||
|
||||
return (*engine->ops->import) (engine->engine, keydata);
|
||||
}
|
||||
@ -389,10 +392,10 @@ _gpgme_engine_op_keylist (engine_t engine, const char *pattern,
|
||||
int secret_only, gpgme_keylist_mode_t mode)
|
||||
{
|
||||
if (!engine)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (!engine->ops->keylist)
|
||||
return GPGME_Not_Implemented;
|
||||
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
|
||||
|
||||
return (*engine->ops->keylist) (engine->engine, pattern, secret_only, mode);
|
||||
}
|
||||
@ -404,10 +407,10 @@ _gpgme_engine_op_keylist_ext (engine_t engine, const char *pattern[],
|
||||
gpgme_keylist_mode_t mode)
|
||||
{
|
||||
if (!engine)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (!engine->ops->keylist_ext)
|
||||
return GPGME_Not_Implemented;
|
||||
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
|
||||
|
||||
return (*engine->ops->keylist_ext) (engine->engine, pattern, secret_only,
|
||||
reserved, mode);
|
||||
@ -421,10 +424,10 @@ _gpgme_engine_op_sign (engine_t engine, gpgme_data_t in, gpgme_data_t out,
|
||||
gpgme_ctx_t ctx /* FIXME */)
|
||||
{
|
||||
if (!engine)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (!engine->ops->sign)
|
||||
return GPGME_Not_Implemented;
|
||||
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
|
||||
|
||||
return (*engine->ops->sign) (engine->engine, in, out, mode, use_armor,
|
||||
use_textmode, include_certs, ctx);
|
||||
@ -435,10 +438,10 @@ gpgme_error_t
|
||||
_gpgme_engine_op_trustlist (engine_t engine, const char *pattern)
|
||||
{
|
||||
if (!engine)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (!engine->ops->trustlist)
|
||||
return GPGME_Not_Implemented;
|
||||
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
|
||||
|
||||
return (*engine->ops->trustlist) (engine->engine, pattern);
|
||||
}
|
||||
@ -449,10 +452,10 @@ _gpgme_engine_op_verify (engine_t engine, gpgme_data_t sig,
|
||||
gpgme_data_t signed_text, gpgme_data_t plaintext)
|
||||
{
|
||||
if (!engine)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (!engine->ops->verify)
|
||||
return GPGME_Not_Implemented;
|
||||
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
|
||||
|
||||
return (*engine->ops->verify) (engine->engine, sig, signed_text, plaintext);
|
||||
}
|
||||
|
77
gpgme/error.c
Normal file
77
gpgme/error.c
Normal file
@ -0,0 +1,77 @@
|
||||
/* error.c - Error handling for GPGME.
|
||||
Copyright (C) 2003 g10 Code GmbH
|
||||
|
||||
This file is part of GPGME.
|
||||
|
||||
GPGME 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.
|
||||
|
||||
GPGME 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 GPGME; 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 <gpgme.h>
|
||||
|
||||
/* Return a pointer to a string containing a description of the error
|
||||
code in the error value ERR. */
|
||||
const char *
|
||||
gpgme_strerror (gpgme_error_t err)
|
||||
{
|
||||
return gpg_strerror (err);
|
||||
}
|
||||
|
||||
|
||||
/* Return a pointer to a string containing a description of the error
|
||||
source in the error value ERR. */
|
||||
const char *
|
||||
gpgme_strsource (gpgme_error_t err)
|
||||
{
|
||||
return gpg_strsource (err);
|
||||
}
|
||||
|
||||
|
||||
/* Retrieve the error code for the system error ERR. This returns
|
||||
GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped (report
|
||||
this). */
|
||||
gpgme_err_code_t
|
||||
gpgme_err_code_from_errno (int err)
|
||||
{
|
||||
return gpg_err_code_from_errno (err);
|
||||
}
|
||||
|
||||
|
||||
/* Retrieve the system error for the error code CODE. This returns 0
|
||||
if CODE is not a system error code. */
|
||||
int
|
||||
gpgme_err_code_to_errno (gpgme_err_code_t code)
|
||||
{
|
||||
return gpg_err_code_from_errno (code);
|
||||
}
|
||||
|
||||
|
||||
/* Return an error value with the error source SOURCE and the system
|
||||
error ERR. */
|
||||
gpgme_error_t
|
||||
gpgme_err_make_from_errno (gpg_err_source_t source, int err)
|
||||
{
|
||||
return gpg_err_make_from_errno (source, err);
|
||||
}
|
||||
|
||||
|
||||
/* Return an error value with the system error ERR. */
|
||||
gpgme_err_code_t
|
||||
gpgme_error_from_errno (int err)
|
||||
{
|
||||
return gpgme_error (gpg_err_code_from_errno (err));
|
||||
}
|
@ -41,7 +41,7 @@ export_start (gpgme_ctx_t ctx, int synchronous, const char *pattern,
|
||||
gpgme_error_t err;
|
||||
|
||||
if (!keydata)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
err = _gpgme_op_reset (ctx, synchronous);
|
||||
if (err)
|
||||
@ -82,7 +82,7 @@ export_ext_start (gpgme_ctx_t ctx, int synchronous, const char *pattern[],
|
||||
gpgme_error_t err;
|
||||
|
||||
if (!keydata)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
err = _gpgme_op_reset (ctx, synchronous);
|
||||
if (err)
|
||||
|
@ -23,6 +23,7 @@
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "gpgme.h"
|
||||
#include "context.h"
|
||||
@ -99,7 +100,7 @@ genkey_status_handler (void *priv, gpgme_status_code_t code, char *args)
|
||||
free (opd->result.fpr);
|
||||
opd->result.fpr = strdup (&args[2]);
|
||||
if (!opd->result.fpr)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -107,7 +108,7 @@ genkey_status_handler (void *priv, gpgme_status_code_t code, char *args)
|
||||
case GPGME_STATUS_EOF:
|
||||
/* FIXME: Should return some more useful error value. */
|
||||
if (!opd->result.primary && !opd->result.sub)
|
||||
return GPGME_General_Error;
|
||||
return gpg_error (GPG_ERR_GENERAL);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -127,16 +128,16 @@ get_key_parameter (const char *parms, gpgme_data_t *key_parameter)
|
||||
/* Extract the key parameter from the XML structure. */
|
||||
parms = strstr (parms, "<GnupgKeyParms ");
|
||||
if (!parms)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
content = strchr (parms, '>');
|
||||
if (!content)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
content++;
|
||||
|
||||
attrib = strstr (parms, "format=\"internal\"");
|
||||
if (!attrib || attrib >= content)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
endtag = strstr (content, "</GnupgKeyParms>");
|
||||
/* FIXME: Check that there are no control statements inside. */
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "context.h"
|
||||
@ -40,7 +41,7 @@ gpgme_new (gpgme_ctx_t *r_ctx)
|
||||
|
||||
ctx = calloc (1, sizeof *ctx);
|
||||
if (!ctx)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
ctx->keylist_mode = GPGME_KEYLIST_MODE_LOCAL;
|
||||
ctx->include_certs = 1;
|
||||
ctx->protocol = GPGME_PROTOCOL_OpenPGP;
|
||||
@ -85,7 +86,7 @@ gpgme_error_t
|
||||
gpgme_set_protocol (gpgme_ctx_t ctx, gpgme_protocol_t protocol)
|
||||
{
|
||||
if (protocol != GPGME_PROTOCOL_OpenPGP && protocol != GPGME_PROTOCOL_CMS)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
ctx->protocol = protocol;
|
||||
return 0;
|
||||
@ -180,7 +181,7 @@ gpgme_set_keylist_mode (gpgme_ctx_t ctx, gpgme_keylist_mode_t mode)
|
||||
if (!((mode & GPGME_KEYLIST_MODE_LOCAL)
|
||||
|| (mode & GPGME_KEYLIST_MODE_EXTERN)
|
||||
|| (mode & GPGME_KEYLIST_MODE_SIGS)))
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
ctx->keylist_mode = mode;
|
||||
return 0;
|
||||
|
132
gpgme/gpgme.h
132
gpgme/gpgme.h
@ -38,6 +38,8 @@ extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <gpg-error.h>
|
||||
|
||||
|
||||
/* Check for compiler features. */
|
||||
#if __GNUC__
|
||||
@ -76,74 +78,75 @@ struct gpgme_data;
|
||||
typedef struct gpgme_data *gpgme_data_t;
|
||||
|
||||
|
||||
/* Public data types provided by GPGME. */
|
||||
/* Wrappers for the libgpg-error library. */
|
||||
|
||||
/* The error numbers used by GPGME. */
|
||||
typedef enum
|
||||
typedef gpg_error_t gpgme_error_t;
|
||||
typedef gpg_err_code_t gpgme_err_code_t;
|
||||
typedef gpg_err_source_t gpgme_err_source_t;
|
||||
|
||||
|
||||
static __inline__ gpgme_error_t
|
||||
gpgme_err_make (gpgme_err_source_t source, gpgme_err_code_t code)
|
||||
{
|
||||
GPGME_EOF = -1,
|
||||
GPGME_No_Error = 0x0000,
|
||||
GPGME_General_Error = 0x0001,
|
||||
GPGME_Out_Of_Core = 0x0002,
|
||||
GPGME_Invalid_Value = 0x0003,
|
||||
GPGME_Exec_Error = 0x0004,
|
||||
GPGME_Too_Many_Procs = 0x0005,
|
||||
GPGME_Pipe_Error = 0x0006,
|
||||
GPGME_No_Data = 0x0007,
|
||||
GPGME_Conflict = 0x0008,
|
||||
GPGME_Not_Implemented = 0x0009,
|
||||
GPGME_Read_Error = 0x000a,
|
||||
GPGME_Write_Error = 0x000b,
|
||||
GPGME_File_Error = 0x000c, /* errno is set in this case. */
|
||||
GPGME_Decryption_Failed = 0x000d,
|
||||
GPGME_Bad_Passphrase = 0x000e,
|
||||
GPGME_Canceled = 0x000f,
|
||||
GPGME_Invalid_Key = 0x0010,
|
||||
GPGME_Invalid_Engine = 0x0011,
|
||||
GPGME_No_UserID = 0x0012,
|
||||
GPGME_Invalid_UserID = 0x0013,
|
||||
|
||||
/* Reasons for invalid user id. */
|
||||
GPGME_Unknown_Reason = 0x0100,
|
||||
GPGME_Not_Found = 0x0101,
|
||||
GPGME_Ambiguous_Specification = 0x0102,
|
||||
GPGME_Wrong_Key_Usage = 0x0103,
|
||||
GPGME_Key_Revoked = 0x0104,
|
||||
GPGME_Key_Expired = 0x0105,
|
||||
GPGME_No_CRL_Known = 0x0106,
|
||||
GPGME_CRL_Too_Old = 0x0107,
|
||||
GPGME_Policy_Mismatch = 0x0108,
|
||||
GPGME_No_Secret_Key = 0x0109,
|
||||
GPGME_Key_Not_Trusted = 0x010a,
|
||||
|
||||
/* Import problems. */
|
||||
GPGME_Issuer_Missing = 0x0200,
|
||||
GPGME_Chain_Too_Long = 0x0201,
|
||||
|
||||
/* Verification problems. */
|
||||
GPGME_Unsupported_Algorithm = 0x0300,
|
||||
GPGME_Sig_Expired = 0x0301,
|
||||
GPGME_Bad_Signature = 0x0302,
|
||||
GPGME_No_Public_Key = 0x0303,
|
||||
|
||||
/* Deprecated, see below. */
|
||||
GPGME_x_Busy = -2,
|
||||
GPGME_x_No_Request = -3,
|
||||
GPGME_x_Invalid_Type = -4,
|
||||
GPGME_x_Invalid_Mode = -5
|
||||
return gpg_err_make (source, code);
|
||||
}
|
||||
gpgme_error_t;
|
||||
|
||||
typedef gpgme_error_t _gpgme_deprecated_error_t _GPGME_DEPRECATED;
|
||||
|
||||
#define GPGME_Busy ((_gpgme_deprecated_error_t) GPGME_x_Busy)
|
||||
#define GPGME_No_Request ((_gpgme_deprecated_error_t) GPGME_x_No_Request)
|
||||
#define GPGME_Invalid_Type ((_gpgme_deprecated_error_t) GPGME_x_Invalid_Type)
|
||||
#define GPGME_Invalid_Mode ((_gpgme_deprecated_error_t) GPGME_x_Invalid_Mode)
|
||||
#define GPGME_No_Recipients ((_gpgme_deprecated_error_t) GPGME_No_UserID)
|
||||
#define GPGME_Invalid_Recipients \
|
||||
((_gpgme_deprecated_error_t) GPGME_Invalid_UserID)
|
||||
#define GPGME_No_Passphrase ((_gpgme_deprecated_error_t) GPGME_Bad_Passphrase)
|
||||
/* The user can define GPG_ERR_SOURCE_DEFAULT before including this
|
||||
file to specify a default source for gpg_error. */
|
||||
#ifndef GPGME_ERR_SOURCE_DEFAULT
|
||||
#define GPGME_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_USER_1
|
||||
#endif
|
||||
|
||||
static __inline__ gpgme_error_t
|
||||
gpgme_error (gpgme_err_code_t code)
|
||||
{
|
||||
return gpgme_err_make (GPGME_ERR_SOURCE_DEFAULT, code);
|
||||
}
|
||||
|
||||
|
||||
static __inline__ gpgme_err_code_t
|
||||
gpgme_err_code (gpgme_error_t err)
|
||||
{
|
||||
return gpg_err_code (err);
|
||||
}
|
||||
|
||||
|
||||
static __inline__ gpgme_err_source_t
|
||||
gpgme_err_source (gpgme_error_t err)
|
||||
{
|
||||
return gpg_err_source (err);
|
||||
}
|
||||
|
||||
|
||||
/* Return a pointer to a string containing a description of the error
|
||||
code in the error value ERR. */
|
||||
const char *gpgme_strerror (gpgme_error_t err);
|
||||
|
||||
|
||||
/* Return a pointer to a string containing a description of the error
|
||||
source in the error value ERR. */
|
||||
const char *gpgme_strsource (gpgme_error_t err);
|
||||
|
||||
|
||||
/* Retrieve the error code for the system error ERR. This returns
|
||||
GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped (report
|
||||
this). */
|
||||
gpgme_err_code_t gpgme_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 gpgme_err_code_to_errno (gpgme_err_code_t code);
|
||||
|
||||
|
||||
/* Return an error value with the error source SOURCE and the system
|
||||
error ERR. */
|
||||
gpgme_error_t gpgme_err_make_from_errno (gpg_err_source_t source, int err);
|
||||
|
||||
|
||||
/* Return an error value with the system error ERR. */
|
||||
gpgme_err_code_t gpg_error_from_errno (int err);
|
||||
|
||||
|
||||
/* The possible encoding mode of gpgme_data_t objects. */
|
||||
@ -1425,9 +1428,6 @@ const char *gpgme_check_version (const char *req_version);
|
||||
/* Retrieve information about the backend engines. */
|
||||
gpgme_error_t gpgme_get_engine_info (gpgme_engine_info_t *engine_info);
|
||||
|
||||
/* Return a string describing ERR. */
|
||||
const char *gpgme_strerror (gpgme_error_t err);
|
||||
|
||||
|
||||
/* Engine support functions. */
|
||||
|
||||
|
@ -82,7 +82,7 @@ parse_import (char *args, gpgme_import_status_t *import_status, int problem)
|
||||
|
||||
import = malloc (sizeof (*import));
|
||||
if (!import)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
import->next = NULL;
|
||||
|
||||
errno = 0;
|
||||
@ -91,7 +91,7 @@ parse_import (char *args, gpgme_import_status_t *import_status, int problem)
|
||||
{
|
||||
/* The crypto backend does not behave. */
|
||||
free (import);
|
||||
return GPGME_General_Error;
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
}
|
||||
args = tail;
|
||||
|
||||
@ -102,26 +102,26 @@ parse_import (char *args, gpgme_import_status_t *import_status, int problem)
|
||||
case 0:
|
||||
case 4:
|
||||
default:
|
||||
import->result = GPGME_Unknown_Reason;
|
||||
import->result = gpg_error (GPG_ERR_GENERAL);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
import->result = GPGME_Invalid_Key;
|
||||
import->result = gpg_error (GPG_ERR_BAD_CERT);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
import->result = GPGME_Issuer_Missing;
|
||||
import->result = gpg_error (GPG_ERR_MISSING_CERT);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
import->result = GPGME_Chain_Too_Long;
|
||||
import->result = gpg_error (GPG_ERR_BAD_CERT_CHAIN);
|
||||
break;
|
||||
}
|
||||
import->status = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
import->result = GPGME_No_Error;
|
||||
import->result = gpg_error (GPG_ERR_NO_ERROR);
|
||||
import->status = nr;
|
||||
}
|
||||
|
||||
@ -134,8 +134,9 @@ parse_import (char *args, gpgme_import_status_t *import_status, int problem)
|
||||
import->fpr = strdup (args);
|
||||
if (!import->fpr)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
free (import);
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (saved_errno);
|
||||
}
|
||||
|
||||
*import_status = import;
|
||||
@ -155,7 +156,7 @@ parse_import_res (char *args, gpgme_import_result_t result)
|
||||
(x) = strtol (args, &tail, 0); \
|
||||
if (errno || args == tail || *tail != ' ') \
|
||||
/* The crypto backend does not behave. */ \
|
||||
return GPGME_General_Error; \
|
||||
return gpg_error (GPG_ERR_INV_ENGINE); \
|
||||
args = tail;
|
||||
|
||||
PARSE_NEXT (result->considered);
|
||||
@ -232,7 +233,7 @@ _gpgme_op_import_start (gpgme_ctx_t ctx, int synchronous, gpgme_data_t keydata)
|
||||
opd->lastp = &opd->result.imports;
|
||||
|
||||
if (!keydata)
|
||||
return GPGME_No_Data;
|
||||
return gpg_error (GPG_ERR_NO_DATA);
|
||||
|
||||
_gpgme_engine_set_status_handler (ctx->engine, import_status_handler, ctx);
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "ops.h"
|
||||
@ -43,7 +44,7 @@ _gpgme_key_new (gpgme_key_t *r_key)
|
||||
|
||||
key = calloc (1, sizeof *key);
|
||||
if (!key)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
key->_refs = 1;
|
||||
|
||||
*r_key = key;
|
||||
@ -58,7 +59,7 @@ _gpgme_key_add_subkey (gpgme_key_t key, gpgme_subkey_t *r_subkey)
|
||||
|
||||
subkey = calloc (1, sizeof *subkey);
|
||||
if (!subkey)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
subkey->keyid = subkey->_keyid;
|
||||
subkey->_keyid[16] = '\0';
|
||||
|
||||
@ -212,7 +213,7 @@ _gpgme_key_append_name (gpgme_key_t key, char *src)
|
||||
size, so that we are able to store the parsed stuff there too. */
|
||||
uid = malloc (sizeof (*uid) + 2 * src_len + 3);
|
||||
if (!uid)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
memset (uid, 0, sizeof *uid);
|
||||
|
||||
uid->uid = ((char *) uid) + sizeof (*uid);
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <time.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "gpgme.h"
|
||||
#include "util.h"
|
||||
@ -479,7 +480,7 @@ keylist_colon_handler (void *priv, char *line)
|
||||
{
|
||||
key->issuer_serial = strdup (field[7]);
|
||||
if (!key->issuer_serial)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
}
|
||||
|
||||
/* Field 9 has the ownertrust. */
|
||||
@ -490,7 +491,7 @@ keylist_colon_handler (void *priv, char *line)
|
||||
but GPGSM stores the issuer name. */
|
||||
if (fields >= 10 && (rectype == RT_CRT || rectype == RT_CRS))
|
||||
if (_gpgme_decode_c_string (field[9], &key->issuer_name, 0))
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error (GPG_ERR_ENOMEM); /* FIXME */
|
||||
|
||||
/* Field 11 has the signature class. */
|
||||
|
||||
@ -558,7 +559,7 @@ keylist_colon_handler (void *priv, char *line)
|
||||
if (fields >= 10)
|
||||
{
|
||||
if (_gpgme_key_append_name (key, field[9]))
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (GPG_ERR_ENOMEM); /* FIXME */
|
||||
else
|
||||
{
|
||||
if (field[1])
|
||||
@ -574,7 +575,7 @@ keylist_colon_handler (void *priv, char *line)
|
||||
{
|
||||
key->subkeys->fpr = strdup (field[9]);
|
||||
if (!key->subkeys->fpr)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
}
|
||||
|
||||
/* Field 13 has the gpgsm chain ID (take only the first one). */
|
||||
@ -582,7 +583,7 @@ keylist_colon_handler (void *priv, char *line)
|
||||
{
|
||||
key->chain_id = strdup (field[12]);
|
||||
if (!key->chain_id)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -595,30 +596,30 @@ keylist_colon_handler (void *priv, char *line)
|
||||
assert (opd->tmp_uid == key->_last_uid);
|
||||
keysig = _gpgme_key_add_sig (key, (fields >= 10) ? field[9] : NULL);
|
||||
if (!keysig)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error (GPG_ERR_ENOMEM); /* FIXME */
|
||||
|
||||
/* Field 2 has the calculated trust ('!', '-', '?', '%'). */
|
||||
if (fields >= 2)
|
||||
switch (field[1][0])
|
||||
{
|
||||
case '!':
|
||||
keysig->status = GPGME_No_Error;
|
||||
keysig->status = gpg_error (GPG_ERR_NO_ERROR);
|
||||
break;
|
||||
|
||||
case '-':
|
||||
keysig->status = GPGME_Bad_Signature;
|
||||
keysig->status = gpg_error (GPG_ERR_BAD_SIGNATURE);
|
||||
break;
|
||||
|
||||
case '?':
|
||||
keysig->status = GPGME_No_Public_Key;
|
||||
keysig->status = gpg_error (GPG_ERR_NO_PUBKEY);
|
||||
break;
|
||||
|
||||
case '%':
|
||||
keysig->status = GPGME_General_Error;
|
||||
keysig->status = gpg_error (GPG_ERR_GENERAL);
|
||||
break;
|
||||
|
||||
default:
|
||||
keysig->status = GPGME_No_Error;
|
||||
keysig->status = gpg_error (GPG_ERR_NO_ERROR);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -779,10 +780,10 @@ gpgme_op_keylist_next (gpgme_ctx_t ctx, gpgme_key_t *r_key)
|
||||
op_data_t opd;
|
||||
|
||||
if (!ctx || !r_key)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
*r_key = NULL;
|
||||
if (!ctx)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
err = _gpgme_op_data_lookup (ctx, OPDATA_KEYLIST, &hook, -1, NULL);
|
||||
opd = hook;
|
||||
@ -796,7 +797,7 @@ gpgme_op_keylist_next (gpgme_ctx_t ctx, gpgme_key_t *r_key)
|
||||
return err;
|
||||
|
||||
if (!opd->key_cond)
|
||||
return GPGME_EOF;
|
||||
return gpg_error (GPG_ERR_EOF);
|
||||
|
||||
opd->key_cond = 0;
|
||||
assert (opd->key_queue);
|
||||
@ -817,7 +818,7 @@ gpgme_error_t
|
||||
gpgme_op_keylist_end (gpgme_ctx_t ctx)
|
||||
{
|
||||
if (!ctx)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -833,10 +834,10 @@ gpgme_get_key (gpgme_ctx_t ctx, const char *fpr, gpgme_key_t *r_key,
|
||||
gpgme_error_t err;
|
||||
|
||||
if (!ctx || !r_key)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (strlen (fpr) < 16) /* We have at least a key ID. */
|
||||
return GPGME_Invalid_Key;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
/* FIXME: We use our own context because we have to avoid the user's
|
||||
I/O callback handlers. */
|
||||
|
@ -1,84 +0,0 @@
|
||||
#!/bin/sh
|
||||
# mkerrors - Extract error strings from gpgme.h
|
||||
# and create C source for gpgme_strerror
|
||||
# Copyright (C) 2000 Werner Koch (dd9jn)
|
||||
# Copyright (C) 2001 g10 Code GmbH
|
||||
#
|
||||
# This file is part of GPGME.
|
||||
#
|
||||
# GPGME 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.
|
||||
#
|
||||
# GPGME 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
|
||||
|
||||
cat <<EOF
|
||||
/* Generated automatically by mkerrors */
|
||||
/* Do not edit! */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "gpgme.h"
|
||||
|
||||
/**
|
||||
* gpgme_strerror:
|
||||
* @err: Error code
|
||||
*
|
||||
* This function returns a textual representaion of the given
|
||||
* errocode. If this is an unknown value, a string with the value
|
||||
* is returned (which is hold in a static buffer).
|
||||
*
|
||||
* Return value: String with the error description.
|
||||
**/
|
||||
const char *
|
||||
gpgme_strerror (gpgme_error_t err)
|
||||
{
|
||||
const char *s;
|
||||
static char buf[25];
|
||||
|
||||
switch (err) {
|
||||
EOF
|
||||
|
||||
awk '
|
||||
/GPGME_No_Error/ { okay=1 }
|
||||
!okay {next}
|
||||
/}/ { exit 0 }
|
||||
/GPGME_[A-Za-z_]*/ { print_code($1) }
|
||||
|
||||
|
||||
function print_code( s )
|
||||
{
|
||||
printf " case %s: s=\"", s ;
|
||||
gsub(/_/, " ", s );
|
||||
printf "%s\"; break;\n", substr(s,7);
|
||||
}
|
||||
'
|
||||
|
||||
cat <<EOF
|
||||
default: sprintf (buf, "ec=%d", err ); s=buf; break;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
EOF
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -46,7 +46,7 @@ _gpgme_op_data_lookup (gpgme_ctx_t ctx, ctx_op_data_id_t type, void **hook,
|
||||
|
||||
data = calloc (1, sizeof (struct ctx_op_data) + size);
|
||||
if (!data)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
data->next = ctx->op_data;
|
||||
data->type = type;
|
||||
data->cleanup = cleanup;
|
||||
@ -71,8 +71,11 @@ _gpgme_op_reset (gpgme_ctx_t ctx, int type)
|
||||
_gpgme_release_result (ctx);
|
||||
|
||||
/* Create an engine object. */
|
||||
if (ctx->engine)
|
||||
{
|
||||
_gpgme_engine_release (ctx->engine);
|
||||
ctx->engine = NULL;
|
||||
}
|
||||
err = _gpgme_engine_new (ctx->protocol, &ctx->engine);
|
||||
if (err)
|
||||
return err;
|
||||
@ -118,7 +121,7 @@ _gpgme_parse_inv_userid (char *args, gpgme_invalid_user_id_t *userid)
|
||||
|
||||
inv_userid = malloc (sizeof (*inv_userid));
|
||||
if (!inv_userid)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
inv_userid->next = NULL;
|
||||
errno = 0;
|
||||
reason = strtol (args, &tail, 0);
|
||||
@ -126,54 +129,55 @@ _gpgme_parse_inv_userid (char *args, gpgme_invalid_user_id_t *userid)
|
||||
{
|
||||
/* The crypto backend does not behave. */
|
||||
free (inv_userid);
|
||||
return GPGME_General_Error;
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
}
|
||||
|
||||
switch (reason)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
inv_userid->reason = GPGME_Unknown_Reason;
|
||||
inv_userid->reason = gpg_error (GPG_ERR_GENERAL);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
inv_userid->reason = GPGME_Not_Found;
|
||||
inv_userid->reason = gpg_error (GPG_ERR_NO_PUBKEY);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
inv_userid->reason = GPGME_Ambiguous_Specification;
|
||||
/* FIXME: Ambiguous specification. */
|
||||
inv_userid->reason = gpg_error (GPG_ERR_AMBIGUOUS_NAME);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
inv_userid->reason = GPGME_Wrong_Key_Usage;
|
||||
inv_userid->reason = gpg_error (GPG_ERR_WRONG_KEY_USAGE);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
inv_userid->reason = GPGME_Key_Revoked;
|
||||
inv_userid->reason = gpg_error (GPG_ERR_CERT_REVOKED);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
inv_userid->reason = GPGME_Key_Expired;
|
||||
inv_userid->reason = gpg_error (GPG_ERR_CERT_EXPIRED);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
inv_userid->reason = GPGME_No_CRL_Known;
|
||||
inv_userid->reason = gpg_error (GPG_ERR_NO_CRL_KNOWN);
|
||||
break;
|
||||
|
||||
case 7:
|
||||
inv_userid->reason = GPGME_CRL_Too_Old;
|
||||
inv_userid->reason = gpg_error (GPG_ERR_CRL_TOO_OLD);
|
||||
break;
|
||||
|
||||
case 8:
|
||||
inv_userid->reason = GPGME_Policy_Mismatch;
|
||||
inv_userid->reason = gpg_error (GPG_ERR_NO_POLICY_MATCH);
|
||||
break;
|
||||
|
||||
case 9:
|
||||
inv_userid->reason = GPGME_No_Secret_Key;
|
||||
inv_userid->reason = gpg_error (GPG_ERR_NO_SECKEY);
|
||||
break;
|
||||
|
||||
case 10:
|
||||
inv_userid->reason = GPGME_Key_Not_Trusted;
|
||||
inv_userid->reason = gpg_error (GPG_ERR_PUBKEY_NOT_TRUSTED);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -184,8 +188,9 @@ _gpgme_parse_inv_userid (char *args, gpgme_invalid_user_id_t *userid)
|
||||
inv_userid->id = strdup (tail);
|
||||
if (!inv_userid->id)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
free (inv_userid);
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (saved_errno);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "gpgme.h"
|
||||
#include "context.h"
|
||||
@ -76,7 +77,7 @@ _gpgme_passphrase_status_handler (void *priv, gpgme_status_code_t code,
|
||||
if (opd->uid_hint)
|
||||
free (opd->uid_hint);
|
||||
if (!(opd->uid_hint = strdup (args)))
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
break;
|
||||
|
||||
case GPGME_STATUS_BAD_PASSPHRASE:
|
||||
@ -95,7 +96,7 @@ _gpgme_passphrase_status_handler (void *priv, gpgme_status_code_t code,
|
||||
free (opd->passphrase_info);
|
||||
opd->passphrase_info = strdup (args);
|
||||
if (!opd->passphrase_info)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
break;
|
||||
|
||||
case GPGME_STATUS_MISSING_PASSPHRASE:
|
||||
@ -104,7 +105,7 @@ _gpgme_passphrase_status_handler (void *priv, gpgme_status_code_t code,
|
||||
|
||||
case GPGME_STATUS_EOF:
|
||||
if (opd->no_passphrase || opd->bad_passphrase)
|
||||
return GPGME_Bad_Passphrase;
|
||||
return gpg_error (GPG_ERR_BAD_PASSPHRASE);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -23,6 +23,7 @@
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "context.h"
|
||||
@ -44,7 +45,7 @@ _gpgme_progress_status_handler (void *priv, gpgme_status_code_t code,
|
||||
|
||||
args_cpy = strdup (args);
|
||||
if (!args_cpy)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
|
||||
p = strchr (args_cpy, ' ');
|
||||
if (p)
|
||||
|
@ -193,7 +193,7 @@ add_arg (engine_gpg_t gpg, const char *arg)
|
||||
if (!a)
|
||||
{
|
||||
gpg->arg_error = 1;
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
}
|
||||
a->next = NULL;
|
||||
a->data = NULL;
|
||||
@ -216,7 +216,7 @@ add_data (engine_gpg_t gpg, gpgme_data_t data, int dup_to, int inbound)
|
||||
if (!a)
|
||||
{
|
||||
gpg->arg_error = 1;
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
}
|
||||
a->next = NULL;
|
||||
a->data = data;
|
||||
@ -335,16 +335,13 @@ static gpgme_error_t
|
||||
gpg_new (void **engine)
|
||||
{
|
||||
engine_gpg_t gpg;
|
||||
int rc = 0;
|
||||
gpgme_error_t rc = 0;
|
||||
|
||||
gpg = calloc (1, sizeof *gpg);
|
||||
if (!gpg)
|
||||
{
|
||||
rc = GPGME_Out_Of_Core;
|
||||
goto leave;
|
||||
}
|
||||
gpg->argtail = &gpg->arglist;
|
||||
return gpg_error_from_errno (errno);
|
||||
|
||||
gpg->argtail = &gpg->arglist;
|
||||
gpg->status.fd[0] = -1;
|
||||
gpg->status.fd[1] = -1;
|
||||
gpg->colon.fd[0] = -1;
|
||||
@ -360,14 +357,14 @@ gpg_new (void **engine)
|
||||
gpg->status.buffer = malloc (gpg->status.bufsize);
|
||||
if (!gpg->status.buffer)
|
||||
{
|
||||
rc = GPGME_Out_Of_Core;
|
||||
rc = gpg_error_from_errno (errno);
|
||||
goto leave;
|
||||
}
|
||||
/* In any case we need a status pipe - create it right here and
|
||||
don't handle it with our generic gpgme_data_t mechanism. */
|
||||
if (_gpgme_io_pipe (gpg->status.fd, 1) == -1)
|
||||
{
|
||||
rc = GPGME_Pipe_Error;
|
||||
rc = gpg_error_from_errno (errno);
|
||||
goto leave;
|
||||
}
|
||||
if (_gpgme_io_set_close_notify (gpg->status.fd[0],
|
||||
@ -375,7 +372,7 @@ gpg_new (void **engine)
|
||||
|| _gpgme_io_set_close_notify (gpg->status.fd[1],
|
||||
close_notify_handler, gpg))
|
||||
{
|
||||
rc = GPGME_General_Error;
|
||||
rc = gpg_error (GPG_ERR_GENERAL);
|
||||
goto leave;
|
||||
}
|
||||
gpg->status.eof = 0;
|
||||
@ -422,18 +419,19 @@ gpg_set_colon_line_handler (void *engine, engine_colon_line_handler_t fnc,
|
||||
gpg->colon.readpos = 0;
|
||||
gpg->colon.buffer = malloc (gpg->colon.bufsize);
|
||||
if (!gpg->colon.buffer)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
|
||||
if (_gpgme_io_pipe (gpg->colon.fd, 1) == -1)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
free (gpg->colon.buffer);
|
||||
gpg->colon.buffer = NULL;
|
||||
return GPGME_Pipe_Error;
|
||||
return gpg_error_from_errno (saved_errno);
|
||||
}
|
||||
if (_gpgme_io_set_close_notify (gpg->colon.fd[0], close_notify_handler, gpg)
|
||||
|| _gpgme_io_set_close_notify (gpg->colon.fd[1],
|
||||
close_notify_handler, gpg))
|
||||
return GPGME_General_Error;
|
||||
return gpg_error (GPG_ERR_GENERAL);
|
||||
gpg->colon.eof = 0;
|
||||
gpg->colon.fnc = fnc;
|
||||
gpg->colon.fnc_value = fnc_value;
|
||||
@ -547,21 +545,23 @@ build_argv (engine_gpg_t gpg)
|
||||
|
||||
argv = calloc (argc + 1, sizeof *argv);
|
||||
if (!argv)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
fd_data_map = calloc (datac + 1, sizeof *fd_data_map);
|
||||
if (!fd_data_map)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
free_argv (argv);
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (saved_errno);
|
||||
}
|
||||
|
||||
argc = datac = 0;
|
||||
argv[argc] = strdup ("gpg"); /* argv[0] */
|
||||
if (!argv[argc])
|
||||
{
|
||||
int saved_errno = errno;
|
||||
free (fd_data_map);
|
||||
free_argv (argv);
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (saved_errno);
|
||||
}
|
||||
argc++;
|
||||
if (need_special)
|
||||
@ -569,9 +569,10 @@ build_argv (engine_gpg_t gpg)
|
||||
argv[argc] = strdup ("--enable-special-filenames");
|
||||
if (!argv[argc])
|
||||
{
|
||||
int saved_errno = errno;
|
||||
free (fd_data_map);
|
||||
free_argv (argv);
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (saved_errno);
|
||||
}
|
||||
argc++;
|
||||
}
|
||||
@ -580,9 +581,10 @@ build_argv (engine_gpg_t gpg)
|
||||
argv[argc] = strdup ("--use-agent");
|
||||
if (!argv[argc])
|
||||
{
|
||||
int saved_errno = errno;
|
||||
free (fd_data_map);
|
||||
free_argv (argv);
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (saved_errno);
|
||||
}
|
||||
argc++;
|
||||
}
|
||||
@ -591,26 +593,29 @@ build_argv (engine_gpg_t gpg)
|
||||
argv[argc] = strdup ("--batch");
|
||||
if (!argv[argc])
|
||||
{
|
||||
int saved_errno = errno;
|
||||
free (fd_data_map);
|
||||
free_argv (argv);
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (saved_errno);
|
||||
}
|
||||
argc++;
|
||||
}
|
||||
argv[argc] = strdup ("--comment");
|
||||
if (!argv[argc])
|
||||
{
|
||||
int saved_errno = errno;
|
||||
free (fd_data_map);
|
||||
free_argv (argv);
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (saved_errno);
|
||||
}
|
||||
argc++;
|
||||
argv[argc] = strdup ("");
|
||||
if (!argv[argc])
|
||||
{
|
||||
int saved_errno = errno;
|
||||
free (fd_data_map);
|
||||
free_argv (argv);
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (saved_errno);
|
||||
}
|
||||
argc++;
|
||||
for (a = gpg->arglist; a; a = a->next)
|
||||
@ -627,9 +632,10 @@ build_argv (engine_gpg_t gpg)
|
||||
if (_gpgme_io_pipe (fds, fd_data_map[datac].inbound ? 1 : 0)
|
||||
== -1)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
free (fd_data_map);
|
||||
free_argv (argv);
|
||||
return GPGME_Pipe_Error;
|
||||
return gpg_error (saved_errno);
|
||||
}
|
||||
if (_gpgme_io_set_close_notify (fds[0],
|
||||
close_notify_handler, gpg)
|
||||
@ -637,7 +643,7 @@ build_argv (engine_gpg_t gpg)
|
||||
close_notify_handler,
|
||||
gpg))
|
||||
{
|
||||
return GPGME_General_Error;
|
||||
return gpg_error (GPG_ERR_GENERAL);
|
||||
}
|
||||
/* If the data_type is FD, we have to do a dup2 here. */
|
||||
if (fd_data_map[datac].inbound)
|
||||
@ -674,9 +680,10 @@ build_argv (engine_gpg_t gpg)
|
||||
argv[argc] = malloc (25);
|
||||
if (!argv[argc])
|
||||
{
|
||||
int saved_errno = errno;
|
||||
free (fd_data_map);
|
||||
free_argv (argv);
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (saved_errno);
|
||||
}
|
||||
sprintf (argv[argc],
|
||||
a->print_fd ? "%d" : "-&%d",
|
||||
@ -690,9 +697,10 @@ build_argv (engine_gpg_t gpg)
|
||||
argv[argc] = strdup (a->arg);
|
||||
if (!argv[argc])
|
||||
{
|
||||
int saved_errno = errno;
|
||||
free (fd_data_map);
|
||||
free_argv (argv);
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (saved_errno);
|
||||
}
|
||||
argc++;
|
||||
}
|
||||
@ -753,13 +761,13 @@ read_status (engine_gpg_t gpg)
|
||||
bufsize += 1024;
|
||||
buffer = realloc (buffer, bufsize);
|
||||
if (!buffer)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
}
|
||||
|
||||
nread = _gpgme_io_read (gpg->status.fd[0],
|
||||
buffer + readpos, bufsize-readpos);
|
||||
if (nread == -1)
|
||||
return GPGME_Read_Error;
|
||||
return gpg_error_from_errno (errno);
|
||||
|
||||
if (!nread)
|
||||
{
|
||||
@ -810,7 +818,7 @@ read_status (engine_gpg_t gpg)
|
||||
free (gpg->cmd.keyword);
|
||||
gpg->cmd.keyword = strdup (rest);
|
||||
if (!gpg->cmd.keyword)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
/* This should be the last thing we have
|
||||
received and the next thing will be that
|
||||
the command handler does its action. */
|
||||
@ -927,12 +935,12 @@ read_colon_line (engine_gpg_t gpg)
|
||||
bufsize += 1024;
|
||||
buffer = realloc (buffer, bufsize);
|
||||
if (!buffer)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
}
|
||||
|
||||
nread = _gpgme_io_read (gpg->colon.fd[0], buffer+readpos, bufsize-readpos);
|
||||
if (nread == -1)
|
||||
return GPGME_Read_Error;
|
||||
return gpg_error_from_errno (errno);
|
||||
|
||||
if (!nread)
|
||||
{
|
||||
@ -1009,20 +1017,21 @@ static gpgme_error_t
|
||||
start (engine_gpg_t gpg)
|
||||
{
|
||||
gpgme_error_t rc;
|
||||
int saved_errno;
|
||||
int i, n;
|
||||
int status;
|
||||
struct spawn_fd_item_s *fd_child_list, *fd_parent_list;
|
||||
|
||||
if (!gpg)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (! _gpgme_get_gpg_path ())
|
||||
return GPGME_Invalid_Engine;
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
|
||||
/* Kludge, so that we don't need to check the return code of all the
|
||||
add_arg (). We bail out here instead. */
|
||||
if (gpg->arg_error)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error (GPG_ERR_ENOMEM);
|
||||
|
||||
rc = build_argv (gpg);
|
||||
if (rc)
|
||||
@ -1033,7 +1042,7 @@ start (engine_gpg_t gpg)
|
||||
n++;
|
||||
fd_child_list = calloc (n + n, sizeof *fd_child_list);
|
||||
if (!fd_child_list)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
fd_parent_list = fd_child_list + n;
|
||||
|
||||
/* build the fd list for the child */
|
||||
@ -1081,9 +1090,10 @@ start (engine_gpg_t gpg)
|
||||
|
||||
status = _gpgme_io_spawn (_gpgme_get_gpg_path (),
|
||||
gpg->argv, fd_child_list, fd_parent_list);
|
||||
saved_errno = errno;
|
||||
free (fd_child_list);
|
||||
if (status == -1)
|
||||
return GPGME_Exec_Error;
|
||||
return gpg_error_from_errno (errno);
|
||||
|
||||
/*_gpgme_register_term_handler ( closure, closure_value, pid );*/
|
||||
|
||||
@ -1169,7 +1179,7 @@ gpg_delete (void *engine, gpgme_key_t key, int allow_secret)
|
||||
if (!err)
|
||||
{
|
||||
if (!key->subkeys || !key->subkeys->fpr)
|
||||
err = GPGME_Invalid_Key;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
else
|
||||
err = add_arg (gpg, key->subkeys->fpr);
|
||||
}
|
||||
@ -1224,7 +1234,7 @@ gpg_edit (void *engine, gpgme_key_t key, gpgme_data_t out,
|
||||
{
|
||||
const char *s = key->subkeys ? key->subkeys->fpr : NULL;
|
||||
if (!s)
|
||||
err = GPGME_Invalid_Key;
|
||||
err = gpg_error (GPG_ERR_INV_VALUE);
|
||||
else
|
||||
err = add_arg (gpg, s);
|
||||
}
|
||||
@ -1244,7 +1254,7 @@ append_args_from_recipients (engine_gpg_t gpg, gpgme_key_t recp[])
|
||||
while (recp[i])
|
||||
{
|
||||
if (!recp[i]->subkeys || !recp[i]->subkeys->fpr)
|
||||
err = GPGME_Invalid_Key;
|
||||
err = gpg_error (GPG_ERR_INV_VALUE);
|
||||
if (!err)
|
||||
err = add_arg (gpg, "-r");
|
||||
if (!err)
|
||||
@ -1353,7 +1363,7 @@ gpg_export (void *engine, const char *pattern, unsigned int reserved,
|
||||
gpgme_error_t err;
|
||||
|
||||
if (reserved)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
err = add_arg (gpg, "--export");
|
||||
if (!err && use_armor)
|
||||
@ -1381,7 +1391,7 @@ gpg_export_ext (void *engine, const char *pattern[], unsigned int reserved,
|
||||
gpgme_error_t err;
|
||||
|
||||
if (reserved)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
err = add_arg (gpg, "--export");
|
||||
if (!err && use_armor)
|
||||
@ -1412,14 +1422,14 @@ gpg_genkey (void *engine, gpgme_data_t help_data, int use_armor,
|
||||
gpgme_error_t err;
|
||||
|
||||
if (!gpg)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
/* We need a special mechanism to get the fd of a pipe here, so that
|
||||
we can use this for the %pubring and %secring parameters. We
|
||||
don't have this yet, so we implement only the adding to the
|
||||
standard keyrings. */
|
||||
if (pubkey || seckey)
|
||||
return err = GPGME_Not_Implemented;
|
||||
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
|
||||
|
||||
err = add_arg (gpg, "--gen-key");
|
||||
if (!err && use_armor)
|
||||
@ -1491,7 +1501,7 @@ gpg_keylist_ext (void *engine, const char *pattern[], int secret_only,
|
||||
gpgme_error_t err;
|
||||
|
||||
if (reserved)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
err = add_arg (gpg, "--with-colons");
|
||||
if (!err)
|
||||
|
27
gpgme/sign.c
27
gpgme/sign.c
@ -93,7 +93,7 @@ parse_sig_created (char *args, gpgme_new_signature_t *sigp)
|
||||
|
||||
sig = malloc (sizeof (*sig));
|
||||
if (!sig)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
|
||||
sig->next = NULL;
|
||||
switch (*args)
|
||||
@ -113,14 +113,14 @@ parse_sig_created (char *args, gpgme_new_signature_t *sigp)
|
||||
default:
|
||||
/* The backend engine is not behaving. */
|
||||
free (sig);
|
||||
return GPGME_General_Error;
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
}
|
||||
|
||||
args++;
|
||||
if (*args != ' ')
|
||||
{
|
||||
free (sig);
|
||||
return GPGME_General_Error;
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
@ -129,7 +129,7 @@ parse_sig_created (char *args, gpgme_new_signature_t *sigp)
|
||||
{
|
||||
/* The crypto backend does not behave. */
|
||||
free (sig);
|
||||
return GPGME_General_Error;
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
}
|
||||
args = tail;
|
||||
|
||||
@ -138,7 +138,7 @@ parse_sig_created (char *args, gpgme_new_signature_t *sigp)
|
||||
{
|
||||
/* The crypto backend does not behave. */
|
||||
free (sig);
|
||||
return GPGME_General_Error;
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
}
|
||||
args = tail;
|
||||
|
||||
@ -147,7 +147,7 @@ parse_sig_created (char *args, gpgme_new_signature_t *sigp)
|
||||
{
|
||||
/* The crypto backend does not behave. */
|
||||
free (sig);
|
||||
return GPGME_General_Error;
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
}
|
||||
args = tail;
|
||||
|
||||
@ -156,7 +156,7 @@ parse_sig_created (char *args, gpgme_new_signature_t *sigp)
|
||||
{
|
||||
/* The crypto backend does not behave. */
|
||||
free (sig);
|
||||
return GPGME_General_Error;
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
}
|
||||
args = tail;
|
||||
while (*args == ' ')
|
||||
@ -166,7 +166,7 @@ parse_sig_created (char *args, gpgme_new_signature_t *sigp)
|
||||
{
|
||||
/* The crypto backend does not behave. */
|
||||
free (sig);
|
||||
return GPGME_General_Error;
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
}
|
||||
|
||||
tail = strchr (args, ' ');
|
||||
@ -176,8 +176,9 @@ parse_sig_created (char *args, gpgme_new_signature_t *sigp)
|
||||
sig->fpr = strdup (args);
|
||||
if (!sig->fpr)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
free (sig);
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (saved_errno);
|
||||
}
|
||||
*sigp = sig;
|
||||
return 0;
|
||||
@ -221,7 +222,7 @@ _gpgme_sign_status_handler (void *priv, gpgme_status_code_t code, char *args)
|
||||
|
||||
case GPGME_STATUS_EOF:
|
||||
if (opd->result.invalid_signers)
|
||||
return GPGME_Invalid_UserID;
|
||||
return gpg_error (GPG_ERR_INV_USER_ID);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -273,12 +274,12 @@ sign_start (gpgme_ctx_t ctx, int synchronous, gpgme_data_t plain,
|
||||
|
||||
if (mode != GPGME_SIG_MODE_NORMAL && mode != GPGME_SIG_MODE_DETACH
|
||||
&& mode != GPGME_SIG_MODE_CLEAR)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (!plain)
|
||||
return GPGME_No_Data;
|
||||
return gpg_error (GPG_ERR_NO_DATA);
|
||||
if (!sig)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (ctx->passphrase_cb)
|
||||
{
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "context.h"
|
||||
@ -53,7 +54,7 @@ gpgme_error_t
|
||||
gpgme_signers_add (gpgme_ctx_t ctx, const gpgme_key_t key)
|
||||
{
|
||||
if (!ctx || !key)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
if (ctx->signers_len == ctx->signers_size)
|
||||
{
|
||||
@ -63,7 +64,7 @@ gpgme_signers_add (gpgme_ctx_t ctx, const gpgme_key_t key)
|
||||
|
||||
newarr = realloc (ctx->signers, n * sizeof (*newarr));
|
||||
if (!newarr)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
for (j = ctx->signers_size; j < n; j++)
|
||||
newarr[j] = NULL;
|
||||
ctx->signers = newarr;
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "ops.h"
|
||||
@ -44,7 +45,7 @@ _gpgme_trust_item_new (gpgme_trust_item_t *r_item)
|
||||
|
||||
item = calloc (1, sizeof *item);
|
||||
if (!item)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
item->_refs = 1;
|
||||
item->keyid = item->_keyid;
|
||||
item->_keyid[16] = '\0';
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "gpgme.h"
|
||||
#include "util.h"
|
||||
@ -106,9 +107,11 @@ trustlist_colon_handler (void *priv, char *line)
|
||||
break;
|
||||
case 9: /* user ID */
|
||||
item->name = strdup (p);
|
||||
if (!item->name) {
|
||||
if (!item->name)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
gpgme_trust_item_unref (item);
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (saved_errno);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -170,7 +173,7 @@ gpgme_op_trustlist_start (gpgme_ctx_t ctx, const char *pattern, int max_level)
|
||||
op_data_t opd;
|
||||
|
||||
if (!pattern || !*pattern)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
err = _gpgme_op_reset (ctx, 2);
|
||||
if (err)
|
||||
@ -202,10 +205,10 @@ gpgme_op_trustlist_next (gpgme_ctx_t ctx, gpgme_trust_item_t *r_item)
|
||||
struct trust_queue_item_s *q;
|
||||
|
||||
if (!r_item)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
*r_item = NULL;
|
||||
if (!ctx)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
err = _gpgme_op_data_lookup (ctx, OPDATA_TRUSTLIST, &hook, -1, NULL);
|
||||
opd = hook;
|
||||
@ -218,7 +221,7 @@ gpgme_op_trustlist_next (gpgme_ctx_t ctx, gpgme_trust_item_t *r_item)
|
||||
if (err)
|
||||
return err;
|
||||
if (!opd->trust_cond)
|
||||
return GPGME_EOF;
|
||||
return gpg_error (GPG_ERR_EOF);
|
||||
opd->trust_cond = 0;
|
||||
assert (opd->trust_queue);
|
||||
}
|
||||
@ -236,7 +239,7 @@ gpgme_error_t
|
||||
gpgme_op_trustlist_end (gpgme_ctx_t ctx)
|
||||
{
|
||||
if (!ctx)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
133
gpgme/verify.c
133
gpgme/verify.c
@ -94,38 +94,38 @@ calc_sig_summary (gpgme_signature_t sig)
|
||||
if (sig->validity == GPGME_VALIDITY_FULL
|
||||
|| sig->validity == GPGME_VALIDITY_ULTIMATE)
|
||||
{
|
||||
if (sig->status == GPGME_No_Error
|
||||
|| sig->status == GPGME_Sig_Expired
|
||||
|| sig->status == GPGME_Key_Expired)
|
||||
if (gpg_err_code (sig->status) == GPG_ERR_NO_ERROR
|
||||
|| gpg_err_code (sig->status) == GPG_ERR_SIG_EXPIRED
|
||||
|| gpg_err_code (sig->status) == GPG_ERR_KEY_EXPIRED)
|
||||
sum |= GPGME_SIGSUM_GREEN;
|
||||
}
|
||||
else if (sig->validity == GPGME_VALIDITY_NEVER)
|
||||
{
|
||||
if (sig->status == GPGME_No_Error
|
||||
|| sig->status == GPGME_Sig_Expired
|
||||
|| sig->status == GPGME_Key_Expired)
|
||||
if (gpg_err_code (sig->status) == GPG_ERR_NO_ERROR
|
||||
|| gpg_err_code (sig->status) == GPG_ERR_SIG_EXPIRED
|
||||
|| gpg_err_code (sig->status) == GPG_ERR_KEY_EXPIRED)
|
||||
sum |= GPGME_SIGSUM_RED;
|
||||
}
|
||||
else if (sig->status == GPGME_Bad_Signature)
|
||||
else if (gpg_err_code (sig->status) == GPG_ERR_BAD_SIGNATURE)
|
||||
sum |= GPGME_SIGSUM_RED;
|
||||
|
||||
/* FIXME: handle the case when key and message are expired. */
|
||||
switch (sig->status)
|
||||
switch (gpg_err_code (sig->status))
|
||||
{
|
||||
case GPGME_Sig_Expired:
|
||||
case GPG_ERR_SIG_EXPIRED:
|
||||
sum |= GPGME_SIGSUM_SIG_EXPIRED;
|
||||
break;
|
||||
|
||||
case GPGME_Key_Expired:
|
||||
case GPG_ERR_KEY_EXPIRED:
|
||||
sum |= GPGME_SIGSUM_KEY_EXPIRED;
|
||||
break;
|
||||
|
||||
case GPGME_No_Public_Key:
|
||||
case GPG_ERR_NO_PUBKEY:
|
||||
sum |= GPGME_SIGSUM_KEY_MISSING;
|
||||
break;
|
||||
|
||||
case GPGME_Bad_Signature:
|
||||
case GPGME_No_Error:
|
||||
case GPG_ERR_BAD_SIGNATURE:
|
||||
case GPG_ERR_NO_ERROR:
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -159,29 +159,30 @@ parse_new_sig (op_data_t opd, gpgme_status_code_t code, char *args)
|
||||
|
||||
sig = calloc (1, sizeof (*sig));
|
||||
if (!sig)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
if (!opd->result.signatures)
|
||||
opd->result.signatures = sig;
|
||||
if (opd->current_sig)
|
||||
opd->current_sig->next = sig;
|
||||
opd->current_sig = sig;
|
||||
|
||||
/* FIXME: We should set the source of the state. */
|
||||
switch (code)
|
||||
{
|
||||
case GPGME_STATUS_GOODSIG:
|
||||
sig->status = GPGME_No_Error;
|
||||
sig->status = gpg_error (GPG_ERR_NO_ERROR);
|
||||
break;
|
||||
|
||||
case GPGME_STATUS_EXPSIG:
|
||||
sig->status = GPGME_Sig_Expired;
|
||||
sig->status = gpg_error (GPG_ERR_SIG_EXPIRED);
|
||||
break;
|
||||
|
||||
case GPGME_STATUS_EXPKEYSIG:
|
||||
sig->status = GPGME_Key_Expired;
|
||||
sig->status = gpg_error (GPG_ERR_KEY_EXPIRED);
|
||||
break;
|
||||
|
||||
case GPGME_STATUS_BADSIG:
|
||||
sig->status = GPGME_Bad_Signature;
|
||||
sig->status = gpg_error (GPG_ERR_BAD_SIGNATURE);
|
||||
break;
|
||||
|
||||
case GPGME_STATUS_ERRSIG:
|
||||
@ -202,31 +203,31 @@ parse_new_sig (op_data_t opd, gpgme_status_code_t code, char *args)
|
||||
switch (end[0])
|
||||
{
|
||||
case '4':
|
||||
sig->status = GPGME_Unsupported_Algorithm;
|
||||
sig->status = gpg_error (GPG_ERR_UNSUPPORTED_ALGORITHM);
|
||||
break;
|
||||
|
||||
case 9:
|
||||
sig->status = GPGME_No_Public_Key;
|
||||
sig->status = gpg_error (GPG_ERR_NO_PUBKEY);
|
||||
break;
|
||||
|
||||
default:
|
||||
sig->status = GPGME_General_Error;
|
||||
sig->status = gpg_error (GPG_ERR_GENERAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
sig->status = GPGME_General_Error;
|
||||
sig->status = gpg_error (GPG_ERR_GENERAL);
|
||||
break;
|
||||
|
||||
default:
|
||||
return GPGME_General_Error;
|
||||
return gpg_error (GPG_ERR_GENERAL);
|
||||
}
|
||||
|
||||
if (*args)
|
||||
{
|
||||
sig->fpr = strdup (args);
|
||||
if (!sig->fpr)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -245,13 +246,13 @@ parse_valid_sig (gpgme_signature_t sig, char *args)
|
||||
|
||||
if (!*args)
|
||||
/* We require at least the fingerprint. */
|
||||
return GPGME_General_Error;
|
||||
return gpg_error (GPG_ERR_GENERAL);
|
||||
|
||||
if (sig->fpr)
|
||||
free (sig->fpr);
|
||||
sig->fpr = strdup (args);
|
||||
if (!sig->fpr)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
|
||||
end = strchr (end, ' ');
|
||||
if (end)
|
||||
@ -260,12 +261,12 @@ parse_valid_sig (gpgme_signature_t sig, char *args)
|
||||
errno = 0;
|
||||
sig->timestamp = strtol (end, &tail, 0);
|
||||
if (errno || end == tail || (*tail && *tail != ' '))
|
||||
return GPGME_General_Error;
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
end = tail;
|
||||
|
||||
sig->exp_timestamp = strtol (end, &tail, 0);
|
||||
if (errno || end == tail || (*tail && *tail != ' '))
|
||||
return GPGME_General_Error;
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -294,11 +295,11 @@ parse_notation (gpgme_signature_t sig, gpgme_status_code_t code, char *args)
|
||||
if (notation)
|
||||
/* There is another notation name without data for the
|
||||
previous one. The crypto backend misbehaves. */
|
||||
return GPGME_General_Error;
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
|
||||
notation = malloc (sizeof (*sig));
|
||||
if (!notation)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
notation->next = NULL;
|
||||
|
||||
if (code == GPGME_STATUS_NOTATION_NAME)
|
||||
@ -308,8 +309,9 @@ parse_notation (gpgme_signature_t sig, gpgme_status_code_t code, char *args)
|
||||
notation->name = malloc (len);
|
||||
if (!notation->name)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
free (notation);
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (saved_errno);
|
||||
}
|
||||
err = _gpgme_decode_percent_string (args, ¬ation->name, len);
|
||||
if (err)
|
||||
@ -325,8 +327,9 @@ parse_notation (gpgme_signature_t sig, gpgme_status_code_t code, char *args)
|
||||
notation->value = malloc (len);
|
||||
if (!notation->value)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
free (notation);
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (saved_errno);
|
||||
}
|
||||
err = _gpgme_decode_percent_string (args, ¬ation->value, len);
|
||||
if (err)
|
||||
@ -349,20 +352,20 @@ parse_notation (gpgme_signature_t sig, gpgme_status_code_t code, char *args)
|
||||
if (!notation || !notation->name)
|
||||
/* There is notation data without a previous notation
|
||||
name. The crypto backend misbehaves. */
|
||||
return GPGME_General_Error;
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
|
||||
if (!notation->value)
|
||||
{
|
||||
dest = notation->value = malloc (len);
|
||||
if (!dest)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
}
|
||||
else
|
||||
{
|
||||
int cur_len = strlen (notation->value);
|
||||
dest = realloc (notation->value, len + strlen (notation->value));
|
||||
if (!dest)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
notation->value = dest;
|
||||
dest += cur_len;
|
||||
}
|
||||
@ -372,7 +375,7 @@ parse_notation (gpgme_signature_t sig, gpgme_status_code_t code, char *args)
|
||||
return err;
|
||||
}
|
||||
else
|
||||
return GPGME_General_Error;
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -432,13 +435,14 @@ parse_error (gpgme_signature_t sig, char *args)
|
||||
where = args;
|
||||
}
|
||||
else
|
||||
return GPGME_General_Error;
|
||||
return gpg_error (GPG_ERR_INV_ENGINE);
|
||||
|
||||
err = _gpgme_map_gnupg_error (which);
|
||||
|
||||
if (!strcmp (where, "verify.findkey"))
|
||||
sig->status = err;
|
||||
else if (!strcmp (where, "verify.keyusage") && err == GPGME_Wrong_Key_Usage)
|
||||
else if (!strcmp (where, "verify.keyusage")
|
||||
&& gpg_err_code (err) == GPG_ERR_WRONG_KEY_USAGE)
|
||||
sig->wrong_key_usage = 1;
|
||||
|
||||
return 0;
|
||||
@ -473,34 +477,37 @@ _gpgme_verify_status_handler (void *priv, gpgme_status_code_t code, char *args)
|
||||
return parse_new_sig (opd, code, args);
|
||||
|
||||
case GPGME_STATUS_VALIDSIG:
|
||||
return sig ? parse_valid_sig (sig, args) : GPGME_General_Error;
|
||||
return sig ? parse_valid_sig (sig, args)
|
||||
: gpg_error (GPG_ERR_INV_ENGINE);
|
||||
|
||||
case GPGME_STATUS_NODATA:
|
||||
if (!sig)
|
||||
return GPGME_No_Data;
|
||||
sig->status = GPGME_No_Data;
|
||||
return gpg_error (GPG_ERR_NO_DATA);
|
||||
sig->status = gpg_error (GPG_ERR_NO_DATA);
|
||||
break;
|
||||
|
||||
case GPGME_STATUS_UNEXPECTED:
|
||||
if (!sig)
|
||||
return GPGME_General_Error;
|
||||
sig->status = GPGME_No_Data;
|
||||
return gpg_error (GPG_ERR_GENERAL);
|
||||
sig->status = gpg_error (GPG_ERR_NO_DATA);
|
||||
break;
|
||||
|
||||
case GPGME_STATUS_NOTATION_NAME:
|
||||
case GPGME_STATUS_NOTATION_DATA:
|
||||
case GPGME_STATUS_POLICY_URL:
|
||||
return sig ? parse_notation (sig, code, args) : GPGME_General_Error;
|
||||
return sig ? parse_notation (sig, code, args)
|
||||
: gpg_error (GPG_ERR_INV_ENGINE);
|
||||
|
||||
case GPGME_STATUS_TRUST_UNDEFINED:
|
||||
case GPGME_STATUS_TRUST_NEVER:
|
||||
case GPGME_STATUS_TRUST_MARGINAL:
|
||||
case GPGME_STATUS_TRUST_FULLY:
|
||||
case GPGME_STATUS_TRUST_ULTIMATE:
|
||||
return sig ? parse_trust (sig, code, args) : GPGME_General_Error;
|
||||
return sig ? parse_trust (sig, code, args)
|
||||
: gpg_error (GPG_ERR_INV_ENGINE);
|
||||
|
||||
case GPGME_STATUS_ERROR:
|
||||
return sig ? parse_error (sig, args) : GPGME_General_Error;
|
||||
return sig ? parse_error (sig, args) : gpg_error (GPG_ERR_INV_ENGINE);
|
||||
|
||||
case GPGME_STATUS_EOF:
|
||||
if (sig)
|
||||
@ -550,9 +557,9 @@ verify_start (gpgme_ctx_t ctx, int synchronous, gpgme_data_t sig,
|
||||
_gpgme_engine_set_status_handler (ctx->engine, verify_status_handler, ctx);
|
||||
|
||||
if (!sig)
|
||||
return GPGME_No_Data;
|
||||
return gpg_error (GPG_ERR_NO_DATA);
|
||||
if (!signed_text && !plaintext)
|
||||
return GPGME_Invalid_Value;
|
||||
return gpg_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
return _gpgme_engine_op_verify (ctx->engine, sig, signed_text, plaintext);
|
||||
}
|
||||
@ -602,7 +609,7 @@ gpgme_get_sig_key (gpgme_ctx_t ctx, int idx, gpgme_key_t *r_key)
|
||||
idx--;
|
||||
}
|
||||
if (!sig || idx)
|
||||
return GPGME_EOF;
|
||||
return gpg_error (GPG_ERR_EOF);
|
||||
|
||||
return gpgme_get_key (ctx, sig->fpr, r_key, 0);
|
||||
}
|
||||
@ -631,29 +638,29 @@ const char *gpgme_get_sig_status (gpgme_ctx_t ctx, int idx,
|
||||
|
||||
if (r_stat)
|
||||
{
|
||||
switch (sig->status)
|
||||
switch (gpg_err_code (sig->status))
|
||||
{
|
||||
case GPGME_No_Error:
|
||||
case GPG_ERR_NO_ERROR:
|
||||
*r_stat = GPGME_SIG_STAT_GOOD;
|
||||
break;
|
||||
|
||||
case GPGME_Bad_Signature:
|
||||
case GPG_ERR_BAD_SIGNATURE:
|
||||
*r_stat = GPGME_SIG_STAT_BAD;
|
||||
break;
|
||||
|
||||
case GPGME_No_Public_Key:
|
||||
case GPG_ERR_NO_PUBKEY:
|
||||
*r_stat = GPGME_SIG_STAT_NOKEY;
|
||||
break;
|
||||
|
||||
case GPGME_No_Data:
|
||||
case GPG_ERR_NO_DATA:
|
||||
*r_stat = GPGME_SIG_STAT_NOSIG;
|
||||
break;
|
||||
|
||||
case GPGME_Sig_Expired:
|
||||
case GPG_ERR_SIG_EXPIRED:
|
||||
*r_stat = GPGME_SIG_STAT_GOOD_EXP;
|
||||
break;
|
||||
|
||||
case GPGME_Key_Expired:
|
||||
case GPG_ERR_KEY_EXPIRED:
|
||||
*r_stat = GPGME_SIG_STAT_GOOD_EXPKEY;
|
||||
break;
|
||||
|
||||
@ -701,24 +708,24 @@ unsigned long gpgme_get_sig_ulong_attr (gpgme_ctx_t ctx, int idx,
|
||||
return (unsigned long) sig->validity;
|
||||
|
||||
case GPGME_ATTR_SIG_STATUS:
|
||||
switch (sig->status)
|
||||
switch (gpg_err_code (sig->status))
|
||||
{
|
||||
case GPGME_No_Error:
|
||||
case GPG_ERR_NO_ERROR:
|
||||
return GPGME_SIG_STAT_GOOD;
|
||||
|
||||
case GPGME_Bad_Signature:
|
||||
case GPG_ERR_BAD_SIGNATURE:
|
||||
return GPGME_SIG_STAT_BAD;
|
||||
|
||||
case GPGME_No_Public_Key:
|
||||
case GPG_ERR_NO_PUBKEY:
|
||||
return GPGME_SIG_STAT_NOKEY;
|
||||
|
||||
case GPGME_No_Data:
|
||||
case GPG_ERR_NO_DATA:
|
||||
return GPGME_SIG_STAT_NOSIG;
|
||||
|
||||
case GPGME_Sig_Expired:
|
||||
case GPG_ERR_SIG_EXPIRED:
|
||||
return GPGME_SIG_STAT_GOOD_EXP;
|
||||
|
||||
case GPGME_Key_Expired:
|
||||
case GPG_ERR_KEY_EXPIRED:
|
||||
return GPGME_SIG_STAT_GOOD_EXPKEY;
|
||||
|
||||
default:
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "gpgme.h"
|
||||
#include "sema.h"
|
||||
@ -92,7 +93,7 @@ ctx_active (gpgme_ctx_t ctx)
|
||||
{
|
||||
struct ctx_list_item *li = malloc (sizeof (struct ctx_list_item));
|
||||
if (!li)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
li->ctx = ctx;
|
||||
|
||||
LOCK (ctx_list_lock);
|
||||
@ -266,9 +267,10 @@ gpgme_wait (gpgme_ctx_t ctx, gpgme_error_t *status, int hang)
|
||||
fdt.fds = malloc (i * sizeof (struct io_select_fd_s));
|
||||
if (!fdt.fds)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
UNLOCK (ctx_list_lock);
|
||||
if (status)
|
||||
*status = GPGME_Out_Of_Core;
|
||||
*status = gpg_error_from_errno (saved_errno);
|
||||
return NULL;
|
||||
}
|
||||
fdt.size = i;
|
||||
@ -284,9 +286,10 @@ gpgme_wait (gpgme_ctx_t ctx, gpgme_error_t *status, int hang)
|
||||
nr = _gpgme_io_select (fdt.fds, fdt.size, 0);
|
||||
if (nr < 0)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
free (fdt.fds);
|
||||
if (status)
|
||||
*status = GPGME_File_Error;
|
||||
*status = gpg_error_from_errno (saved_errno);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "gpgme.h"
|
||||
#include "context.h"
|
||||
@ -86,7 +87,7 @@ _gpgme_wait_on_condition (gpgme_ctx_t ctx, volatile int *cond)
|
||||
signal it. */
|
||||
int idx;
|
||||
|
||||
err = GPGME_File_Error;
|
||||
err = gpg_error_from_errno (errno);
|
||||
for (idx = 0; idx < ctx->fdt.size; idx++)
|
||||
if (ctx->fdt.fds[idx].fd != -1)
|
||||
_gpgme_io_close (ctx->fdt.fds[idx].fd);
|
||||
|
@ -70,7 +70,7 @@ fd_table_put (fd_table_t fdt, int fd, int dir, void *opaque, int *idx)
|
||||
new_fds = realloc (fdt->fds, (fdt->size + FDT_ALLOCSIZE)
|
||||
* sizeof (*new_fds));
|
||||
if (!new_fds)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
|
||||
fdt->fds = new_fds;
|
||||
fdt->size += FDT_ALLOCSIZE;
|
||||
@ -111,15 +111,16 @@ _gpgme_add_io_cb (void *data, int fd, int dir, gpgme_io_cb_t fnc,
|
||||
|
||||
tag = malloc (sizeof *tag);
|
||||
if (!tag)
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (errno);
|
||||
tag->ctx = ctx;
|
||||
|
||||
/* Allocate a structure to hold information about the handler. */
|
||||
item = calloc (1, sizeof *item);
|
||||
if (!item)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
free (tag);
|
||||
return GPGME_Out_Of_Core;
|
||||
return gpg_error_from_errno (saved_errno);
|
||||
}
|
||||
item->ctx = ctx;
|
||||
item->dir = dir;
|
||||
|
@ -1,3 +1,12 @@
|
||||
2003-06-06 Marcus Brinkmann <marcus@g10code.de>
|
||||
|
||||
Everywhere: Use libgpg-error error codes.
|
||||
|
||||
* gpg/Makefile.am (noinst_HEADERS): New variable.
|
||||
* gpg/t-support.h: New file.
|
||||
* gpgsm/Makefile.am (noinst_HEADERS): New variable.
|
||||
* gpgsm/t-support.h: New file.
|
||||
|
||||
2003-05-29 Marcus Brinkmann <marcus@g10code.de>
|
||||
|
||||
* gpg/t-encrypt-sym.c (main): Adapt to new syntax.
|
||||
|
@ -24,6 +24,7 @@ GPG = @GPG@
|
||||
TESTS_ENVIRONMENT = GNUPGHOME=. GPG_AGENT_INFO=
|
||||
|
||||
# The keylist tests must come after the import and the edit test.
|
||||
noinst_HEADERS = t-support.h
|
||||
TESTS = t-encrypt t-encrypt-sym t-encrypt-sign t-sign t-signers \
|
||||
t-decrypt t-verify t-decrypt-verify \
|
||||
t-export t-import t-trustlist t-eventloop t-edit \
|
||||
|
@ -26,68 +26,9 @@
|
||||
|
||||
#include <gpgme.h>
|
||||
|
||||
#include "t-support.h"
|
||||
|
||||
|
||||
#define fail_if_err(err) \
|
||||
do \
|
||||
{ \
|
||||
if (err) \
|
||||
{ \
|
||||
fprintf (stderr, "%s:%d: gpgme_error_t %s\n", \
|
||||
__FILE__, __LINE__, gpgme_strerror (err)); \
|
||||
exit (1); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
||||
static void
|
||||
print_data (gpgme_data_t dh)
|
||||
{
|
||||
#define BUF_SIZE 512
|
||||
char buf[BUF_SIZE + 1];
|
||||
int ret;
|
||||
|
||||
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
||||
if (ret)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
while ((ret = gpgme_data_read (dh, buf, BUF_SIZE)) > 0)
|
||||
fwrite (buf, ret, 1, stdout);
|
||||
if (ret < 0)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
}
|
||||
|
||||
|
||||
static gpgme_error_t
|
||||
passphrase_cb (void *opaque, const char *uid_hint, const char *passphrase_info,
|
||||
int last_was_bad, int fd)
|
||||
{
|
||||
write (fd, "abc\n", 4);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
make_filename (const char *fname)
|
||||
{
|
||||
const char *srcdir = getenv ("srcdir");
|
||||
char *buf;
|
||||
|
||||
if (!srcdir)
|
||||
srcdir = ".";
|
||||
buf = malloc (strlen(srcdir) + strlen(fname) + 2);
|
||||
if (!buf)
|
||||
{
|
||||
fprintf (stderr, "%s:%d: could not allocate string: %s\n",
|
||||
__FILE__, __LINE__, strerror (errno));
|
||||
exit (1);
|
||||
}
|
||||
strcpy (buf, srcdir);
|
||||
strcat (buf, "/");
|
||||
strcat (buf, fname);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
check_verify_result (gpgme_verify_result_t result, int summary, char *fpr,
|
||||
gpgme_error_t status)
|
||||
@ -113,7 +54,7 @@ check_verify_result (gpgme_verify_result_t result, int summary, char *fpr,
|
||||
__FILE__, __LINE__, sig->fpr);
|
||||
exit (1);
|
||||
}
|
||||
if (sig->status != status)
|
||||
if (gpg_err_code (sig->status) != status)
|
||||
{
|
||||
fprintf (stderr, "%s:%i: Unexpected signature status: %s\n",
|
||||
__FILE__, __LINE__, gpgme_strerror (sig->status));
|
||||
@ -137,7 +78,7 @@ check_verify_result (gpgme_verify_result_t result, int summary, char *fpr,
|
||||
__FILE__, __LINE__, sig->validity);
|
||||
exit (1);
|
||||
}
|
||||
if (sig->validity_reason != GPGME_No_Error)
|
||||
if (gpg_err_code (sig->validity_reason) != GPG_ERR_NO_ERROR)
|
||||
{
|
||||
fprintf (stderr, "%s:%i: Unexpected validity reason: %s\n",
|
||||
__FILE__, __LINE__, gpgme_strerror (sig->validity_reason));
|
||||
@ -182,7 +123,7 @@ main (int argc, char *argv[])
|
||||
verify_result = gpgme_op_verify_result (ctx);
|
||||
check_verify_result (verify_result, 0,
|
||||
"A0FF4590BB6122EDEF6E3C542D727CC768697734",
|
||||
GPGME_No_Error);
|
||||
GPG_ERR_NO_ERROR);
|
||||
|
||||
gpgme_data_release (in);
|
||||
gpgme_data_release (out);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* t-decrypt.c - regression test
|
||||
/* t-decrypt.c - Regression test.
|
||||
Copyright (C) 2000 Werner Koch (dd9jn)
|
||||
Copyright (C) 2001, 2003 g10 Code GmbH
|
||||
|
||||
@ -26,67 +26,9 @@
|
||||
|
||||
#include <gpgme.h>
|
||||
|
||||
#define fail_if_err(err) \
|
||||
do \
|
||||
{ \
|
||||
if (err) \
|
||||
{ \
|
||||
fprintf (stderr, "%s:%d: gpgme_error_t %s\n", \
|
||||
__FILE__, __LINE__, gpgme_strerror (err)); \
|
||||
exit (1); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
||||
static void
|
||||
print_data (gpgme_data_t dh)
|
||||
{
|
||||
#define BUF_SIZE 512
|
||||
char buf[BUF_SIZE + 1];
|
||||
int ret;
|
||||
|
||||
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
||||
if (ret)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
while ((ret = gpgme_data_read (dh, buf, BUF_SIZE)) > 0)
|
||||
fwrite (buf, ret, 1, stdout);
|
||||
if (ret < 0)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
}
|
||||
|
||||
|
||||
static gpgme_error_t
|
||||
passphrase_cb (void *opaque, const char *uid_hint, const char *passphrase_info,
|
||||
int last_was_bad, int fd)
|
||||
{
|
||||
write (fd, "abc\n", 4);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
make_filename (const char *fname)
|
||||
{
|
||||
const char *srcdir = getenv ("srcdir");
|
||||
char *buf;
|
||||
|
||||
if (!srcdir)
|
||||
srcdir = ".";
|
||||
buf = malloc (strlen(srcdir) + strlen(fname) + 2);
|
||||
if (!buf)
|
||||
{
|
||||
fprintf (stderr, "%s:%d: could not allocate string: %s\n",
|
||||
__FILE__, __LINE__, strerror (errno));
|
||||
exit (1);
|
||||
}
|
||||
strcpy (buf, srcdir);
|
||||
strcat (buf, "/");
|
||||
strcat (buf, fname);
|
||||
return buf;
|
||||
}
|
||||
|
||||
#include "t-support.h"
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
|
@ -1,23 +1,22 @@
|
||||
/* t-edit.c - regression test
|
||||
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||
* Copyright (C) 2001, 2002, 2003 g10 Code GmbH
|
||||
*
|
||||
* This file is part of GPGME.
|
||||
*
|
||||
* GPGME 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.
|
||||
*
|
||||
* GPGME 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
|
||||
*/
|
||||
/* t-edit.c - Regression test.
|
||||
Copyright (C) 2000 Werner Koch (dd9jn)
|
||||
Copyright (C) 2001, 2002, 2003 g10 Code GmbH
|
||||
|
||||
This file is part of GPGME.
|
||||
|
||||
GPGME 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.
|
||||
|
||||
GPGME 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 GPGME; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -25,23 +24,13 @@
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <gpgme.h>
|
||||
|
||||
struct passphrase_cb_info_s {
|
||||
gpgme_ctx_t c;
|
||||
int did_it;
|
||||
};
|
||||
|
||||
|
||||
#define fail_if_err(a) do { if(a) { int my_errno = errno; \
|
||||
fprintf (stderr, "%s:%d: gpgme_error_t %s\n", \
|
||||
__FILE__, __LINE__, gpgme_strerror(a)); \
|
||||
if ((a) == GPGME_File_Error) \
|
||||
fprintf (stderr, "\terrno=`%s'\n", strerror (my_errno)); \
|
||||
exit (1); } \
|
||||
} while(0)
|
||||
#include "t-support.h"
|
||||
|
||||
|
||||
static void
|
||||
flush_data (gpgme_data_t dh)
|
||||
{
|
||||
@ -50,20 +39,11 @@ flush_data (gpgme_data_t dh)
|
||||
|
||||
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
||||
if (ret)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
fail_if_err (gpg_error_from_errno (errno));
|
||||
while ((ret = gpgme_data_read (dh, buf, 100)) > 0)
|
||||
fwrite (buf, ret, 1, stdout);
|
||||
if (ret < 0)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
}
|
||||
|
||||
|
||||
static gpgme_error_t
|
||||
passphrase_cb (void *opaque, const char *uid_hint, const char *passphrase_info,
|
||||
int last_was_bad, int fd)
|
||||
{
|
||||
write (fd, "abc\n", 4);
|
||||
return 0;
|
||||
fail_if_err (gpg_error_from_errno (errno));
|
||||
}
|
||||
|
||||
|
||||
@ -130,24 +110,17 @@ main (int argc, char **argv)
|
||||
gpgme_error_t err;
|
||||
gpgme_data_t out = NULL;
|
||||
gpgme_key_t key = NULL;
|
||||
struct passphrase_cb_info_s info;
|
||||
const char *pattern = "Alpha";
|
||||
char *p;
|
||||
char *agent_info;
|
||||
|
||||
do
|
||||
{
|
||||
err = gpgme_new (&ctx);
|
||||
fail_if_err (err);
|
||||
err = gpgme_data_new (&out);
|
||||
fail_if_err (err);
|
||||
|
||||
p = getenv("GPG_AGENT_INFO");
|
||||
if (!(p && strchr (p, ':')))
|
||||
{
|
||||
memset (&info, 0, sizeof info);
|
||||
info.c = ctx;
|
||||
gpgme_set_passphrase_cb (ctx, passphrase_cb, &info);
|
||||
}
|
||||
agent_info = getenv("GPG_AGENT_INFO");
|
||||
if (!(agent_info && strchr (agent_info, ':')))
|
||||
gpgme_set_passphrase_cb (ctx, passphrase_cb, 0);
|
||||
|
||||
err = gpgme_op_keylist_start (ctx, pattern, 0);
|
||||
fail_if_err (err);
|
||||
@ -165,8 +138,6 @@ main (int argc, char **argv)
|
||||
gpgme_data_release (out);
|
||||
gpgme_key_unref (key);
|
||||
gpgme_release (ctx);
|
||||
}
|
||||
while (argc > 1 && !strcmp( argv[1], "--loop"));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -25,45 +25,9 @@
|
||||
|
||||
#include <gpgme.h>
|
||||
|
||||
#define fail_if_err(err) \
|
||||
do \
|
||||
{ \
|
||||
if (err) \
|
||||
{ \
|
||||
fprintf (stderr, "%s:%d: gpgme_error_t %s\n", \
|
||||
__FILE__, __LINE__, gpgme_strerror (err)); \
|
||||
exit (1); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
||||
static void
|
||||
print_data (gpgme_data_t dh)
|
||||
{
|
||||
#define BUF_SIZE 512
|
||||
char buf[BUF_SIZE + 1];
|
||||
int ret;
|
||||
|
||||
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
||||
if (ret)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
while ((ret = gpgme_data_read (dh, buf, BUF_SIZE)) > 0)
|
||||
fwrite (buf, ret, 1, stdout);
|
||||
if (ret < 0)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
}
|
||||
|
||||
|
||||
static gpgme_error_t
|
||||
passphrase_cb (void *opaque, const char *uid_hint, const char *passphrase_info,
|
||||
int last_was_bad, int fd)
|
||||
{
|
||||
write (fd, "abc\n", 4);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include "t-support.h"
|
||||
|
||||
|
||||
static void
|
||||
check_result (gpgme_sign_result_t result, gpgme_sig_mode_t type)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* t-encrypt-sym.c - regression test
|
||||
/* t-encrypt-sym.c - Regression test.
|
||||
Copyright (C) 2000 Werner Koch (dd9jn)
|
||||
Copyright (C) 2001, 2003 g10 Code GmbH
|
||||
|
||||
@ -26,46 +26,11 @@
|
||||
|
||||
#include <gpgme.h>
|
||||
|
||||
#define fail_if_err(err) \
|
||||
do \
|
||||
{ \
|
||||
if (err) \
|
||||
{ \
|
||||
fprintf (stderr, "%s:%d: gpgme_error_t %s\n", \
|
||||
__FILE__, __LINE__, gpgme_strerror (err)); \
|
||||
exit (1); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
||||
static void
|
||||
print_data (gpgme_data_t dh)
|
||||
{
|
||||
char buf[100];
|
||||
int ret;
|
||||
|
||||
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
||||
if (ret)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
while ((ret = gpgme_data_read (dh, buf, 100)) > 0)
|
||||
fwrite (buf, ret, 1, stdout);
|
||||
if (ret < 0)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
}
|
||||
|
||||
|
||||
static gpgme_error_t
|
||||
passphrase_cb (void *opaque, const char *uid_hint, const char *passphrase_info,
|
||||
int last_was_bad, int fd)
|
||||
{
|
||||
write (fd, "abc\n", 4);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include "t-support.h"
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
gpgme_ctx_t ctx;
|
||||
gpgme_error_t err;
|
||||
|
@ -24,38 +24,11 @@
|
||||
|
||||
#include <gpgme.h>
|
||||
|
||||
#define fail_if_err(err) \
|
||||
do \
|
||||
{ \
|
||||
if (err) \
|
||||
{ \
|
||||
fprintf (stderr, "%s:%d: gpgme_error_t %s\n", \
|
||||
__FILE__, __LINE__, gpgme_strerror (err)); \
|
||||
exit (1); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
||||
static void
|
||||
print_data (gpgme_data_t dh)
|
||||
{
|
||||
#define BUF_SIZE 512
|
||||
char buf[BUF_SIZE + 1];
|
||||
int ret;
|
||||
|
||||
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
||||
if (ret)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
while ((ret = gpgme_data_read (dh, buf, BUF_SIZE)) > 0)
|
||||
fwrite (buf, ret, 1, stdout);
|
||||
if (ret < 0)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
}
|
||||
|
||||
#include "t-support.h"
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
gpgme_ctx_t ctx;
|
||||
gpgme_error_t err;
|
||||
|
@ -27,35 +27,9 @@
|
||||
|
||||
#include <gpgme.h>
|
||||
|
||||
#define fail_if_err(err) \
|
||||
do \
|
||||
{ \
|
||||
if (err) \
|
||||
{ \
|
||||
fprintf (stderr, "%s:%d: gpgme_error_t %s\n", \
|
||||
__FILE__, __LINE__, gpgme_strerror (err)); \
|
||||
exit (1); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
||||
static void
|
||||
print_data (gpgme_data_t dh)
|
||||
{
|
||||
char buf[100];
|
||||
int ret;
|
||||
|
||||
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
||||
if (ret)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
while ((ret = gpgme_data_read (dh, buf, 100)) > 0)
|
||||
fwrite (buf, ret, 1, stdout);
|
||||
if (ret < 0)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
}
|
||||
|
||||
#include "t-support.h"
|
||||
|
||||
|
||||
/* Stripped down version of gpgme/wait.c. */
|
||||
|
||||
struct op_result
|
||||
@ -96,7 +70,7 @@ add_io_cb (void *data, int fd, int dir, gpgme_io_cb_t fnc, void *fnc_data,
|
||||
}
|
||||
}
|
||||
if (i == FDLIST_MAX)
|
||||
return GPGME_General_Error;
|
||||
return gpg_err_make (GPG_ERR_SOURCE_USER_1, GPG_ERR_GENERAL);
|
||||
*r_tag = &fds[i];
|
||||
return 0;
|
||||
}
|
||||
|
@ -25,35 +25,9 @@
|
||||
|
||||
#include <gpgme.h>
|
||||
|
||||
#define fail_if_err(err) \
|
||||
do \
|
||||
{ \
|
||||
if (err) \
|
||||
{ \
|
||||
fprintf (stderr, "%s:%d: gpgme_error_t %s\n", \
|
||||
__FILE__, __LINE__, gpgme_strerror (err)); \
|
||||
exit (1); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
||||
static void
|
||||
print_data (gpgme_data_t dh)
|
||||
{
|
||||
char buf[100];
|
||||
int ret;
|
||||
|
||||
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
||||
if (ret)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
while ((ret = gpgme_data_read (dh, buf, 100)) > 0)
|
||||
fwrite (buf, ret, 1, stdout);
|
||||
if (ret < 0)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
}
|
||||
|
||||
#include "t-support.h"
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
|
@ -24,20 +24,11 @@
|
||||
|
||||
#include <gpgme.h>
|
||||
|
||||
#define fail_if_err(err) \
|
||||
do \
|
||||
{ \
|
||||
if (err) \
|
||||
{ \
|
||||
fprintf (stderr, "%s:%d: gpgme_error_t %s\n", \
|
||||
__FILE__, __LINE__, gpgme_strerror (err)); \
|
||||
exit (1); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
#include "t-support.h"
|
||||
|
||||
|
||||
/* True if progress function printed something on the screen. */
|
||||
int progress_called;
|
||||
static int progress_called;
|
||||
|
||||
static void
|
||||
progress (void *self, const char *what, int type, int current, int total)
|
||||
|
@ -25,38 +25,9 @@
|
||||
|
||||
#include <gpgme.h>
|
||||
|
||||
#include "t-support.h"
|
||||
|
||||
|
||||
#define fail_if_err(err) \
|
||||
do \
|
||||
{ \
|
||||
if (err) \
|
||||
{ \
|
||||
fprintf (stderr, "%s:%d: gpgme_error_t %s\n", \
|
||||
__FILE__, __LINE__, gpgme_strerror (err)); \
|
||||
exit (1); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
||||
static char *
|
||||
mk_fname (const char *fname)
|
||||
{
|
||||
const char *srcdir = getenv ("srcdir");
|
||||
char *buf;
|
||||
|
||||
if (!srcdir)
|
||||
srcdir = ".";
|
||||
buf = malloc (strlen(srcdir) + strlen(fname) + 2);
|
||||
if (!buf)
|
||||
exit (8);
|
||||
strcpy (buf, srcdir);
|
||||
strcat (buf, "/");
|
||||
strcat (buf, fname);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
check_result (gpgme_import_result_t result, char *fpr, int secret)
|
||||
{
|
||||
@ -223,14 +194,14 @@ check_result (gpgme_import_result_t result, char *fpr, int secret)
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
gpgme_ctx_t ctx;
|
||||
gpgme_error_t err;
|
||||
gpgme_data_t in;
|
||||
gpgme_import_result_t result;
|
||||
const char *pubkey_1_asc = mk_fname ("pubkey-1.asc");
|
||||
const char *seckey_1_asc = mk_fname ("seckey-1.asc");
|
||||
const char *pubkey_1_asc = make_filename ("pubkey-1.asc");
|
||||
const char *seckey_1_asc = make_filename ("seckey-1.asc");
|
||||
|
||||
err = gpgme_new (&ctx);
|
||||
fail_if_err (err);
|
||||
|
@ -24,20 +24,9 @@
|
||||
|
||||
#include <gpgme.h>
|
||||
|
||||
#include "t-support.h"
|
||||
|
||||
|
||||
#define fail_if_err(err) \
|
||||
do \
|
||||
{ \
|
||||
if (err) \
|
||||
{ \
|
||||
fprintf (stderr, "%s:%d: gpgme_error_t %s\n", \
|
||||
__FILE__, __LINE__, gpgme_strerror (err)); \
|
||||
exit (1); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
||||
struct
|
||||
{
|
||||
char *fpr;
|
||||
@ -74,6 +63,7 @@ keys[] =
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
@ -611,7 +601,7 @@ main (int argc, char **argv)
|
||||
gpgme_key_unref (key);
|
||||
i++;
|
||||
}
|
||||
if (err != GPGME_EOF)
|
||||
if (gpg_err_code (err) != GPG_ERR_EOF)
|
||||
fail_if_err (err);
|
||||
err = gpgme_op_keylist_end (ctx);
|
||||
fail_if_err (err);
|
||||
|
@ -24,20 +24,9 @@
|
||||
|
||||
#include <gpgme.h>
|
||||
|
||||
#include "t-support.h"
|
||||
|
||||
|
||||
#define fail_if_err(err) \
|
||||
do \
|
||||
{ \
|
||||
if (err) \
|
||||
{ \
|
||||
fprintf (stderr, "%s:%d: gpgme_error_t %s\n", \
|
||||
__FILE__, __LINE__, gpgme_strerror (err)); \
|
||||
exit (1); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
||||
struct
|
||||
{
|
||||
char *fpr;
|
||||
@ -514,7 +503,7 @@ main (int argc, char **argv)
|
||||
gpgme_key_unref (key);
|
||||
i++;
|
||||
}
|
||||
if (err != GPGME_EOF)
|
||||
if (gpg_err_code (err) != GPG_ERR_EOF)
|
||||
fail_if_err (err);
|
||||
err = gpgme_op_keylist_end (ctx);
|
||||
fail_if_err (err);
|
||||
|
@ -25,45 +25,9 @@
|
||||
|
||||
#include <gpgme.h>
|
||||
|
||||
#define fail_if_err(err) \
|
||||
do \
|
||||
{ \
|
||||
if (err) \
|
||||
{ \
|
||||
fprintf (stderr, "%s:%d: gpgme_error_t %s\n", \
|
||||
__FILE__, __LINE__, gpgme_strerror (err)); \
|
||||
exit (1); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
||||
static void
|
||||
print_data (gpgme_data_t dh)
|
||||
{
|
||||
#define BUF_SIZE 512
|
||||
char buf[BUF_SIZE + 1];
|
||||
int ret;
|
||||
|
||||
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
||||
if (ret)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
while ((ret = gpgme_data_read (dh, buf, BUF_SIZE)) > 0)
|
||||
fwrite (buf, ret, 1, stdout);
|
||||
if (ret < 0)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
}
|
||||
|
||||
|
||||
static gpgme_error_t
|
||||
passphrase_cb (void *opaque, const char *uid_hint, const char *passphrase_info,
|
||||
int last_was_bad, int fd)
|
||||
{
|
||||
write (fd, "abc\n", 4);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include "t-support.h"
|
||||
|
||||
|
||||
static void
|
||||
check_result (gpgme_sign_result_t result, gpgme_sig_mode_t type)
|
||||
{
|
||||
|
@ -25,45 +25,9 @@
|
||||
|
||||
#include <gpgme.h>
|
||||
|
||||
#define fail_if_err(err) \
|
||||
do \
|
||||
{ \
|
||||
if (err) \
|
||||
{ \
|
||||
fprintf (stderr, "%s:%d: gpgme_error_t %s\n", \
|
||||
__FILE__, __LINE__, gpgme_strerror (err)); \
|
||||
exit (1); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
||||
static void
|
||||
print_data (gpgme_data_t dh)
|
||||
{
|
||||
#define BUF_SIZE 512
|
||||
char buf[BUF_SIZE + 1];
|
||||
int ret;
|
||||
|
||||
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
||||
if (ret)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
while ((ret = gpgme_data_read (dh, buf, BUF_SIZE)) > 0)
|
||||
fwrite (buf, ret, 1, stdout);
|
||||
if (ret < 0)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
}
|
||||
|
||||
|
||||
static gpgme_error_t
|
||||
passphrase_cb (void *opaque, const char *uid_hint, const char *passphrase_info,
|
||||
int last_was_bad, int fd)
|
||||
{
|
||||
write (fd, "abc\n", 4);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include "t-support.h"
|
||||
|
||||
|
||||
static void
|
||||
check_result (gpgme_sign_result_t result, gpgme_sig_mode_t type)
|
||||
{
|
||||
|
81
tests/gpg/t-support.h
Normal file
81
tests/gpg/t-support.h
Normal file
@ -0,0 +1,81 @@
|
||||
/* t-support.h - Helper routines for regression tests.
|
||||
Copyright (C) 2000 Werner Koch (dd9jn)
|
||||
Copyright (C) 2001, 2002, 2003 g10 Code GmbH
|
||||
|
||||
This file is part of GPGME.
|
||||
|
||||
GPGME 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.
|
||||
|
||||
GPGME 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 GPGME; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <gpgme.h>
|
||||
|
||||
#define fail_if_err(err) \
|
||||
do \
|
||||
{ \
|
||||
if (err) \
|
||||
{ \
|
||||
fprintf (stderr, "%s:%d: %s: %s\n", \
|
||||
__FILE__, __LINE__, gpgme_strsource (err), \
|
||||
gpgme_strerror (err)); \
|
||||
exit (1); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
||||
void
|
||||
print_data (gpgme_data_t dh)
|
||||
{
|
||||
#define BUF_SIZE 512
|
||||
char buf[BUF_SIZE + 1];
|
||||
int ret;
|
||||
|
||||
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
||||
if (ret)
|
||||
fail_if_err (gpgme_error_from_errno (errno));
|
||||
while ((ret = gpgme_data_read (dh, buf, BUF_SIZE)) > 0)
|
||||
fwrite (buf, ret, 1, stdout);
|
||||
if (ret < 0)
|
||||
fail_if_err (gpgme_error_from_errno (errno));
|
||||
}
|
||||
|
||||
|
||||
gpgme_error_t
|
||||
passphrase_cb (void *opaque, const char *uid_hint, const char *passphrase_info,
|
||||
int last_was_bad, int fd)
|
||||
{
|
||||
write (fd, "abc\n", 4);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
make_filename (const char *fname)
|
||||
{
|
||||
const char *srcdir = getenv ("srcdir");
|
||||
char *buf;
|
||||
|
||||
if (!srcdir)
|
||||
srcdir = ".";
|
||||
buf = malloc (strlen(srcdir) + strlen(fname) + 2);
|
||||
if (!buf)
|
||||
exit (8);
|
||||
strcpy (buf, srcdir);
|
||||
strcat (buf, "/");
|
||||
strcat (buf, fname);
|
||||
return buf;
|
||||
}
|
@ -24,20 +24,9 @@
|
||||
|
||||
#include <gpgme.h>
|
||||
|
||||
#include "t-support.h"
|
||||
|
||||
|
||||
#define fail_if_err(err) \
|
||||
do \
|
||||
{ \
|
||||
if (err) \
|
||||
{ \
|
||||
fprintf (stderr, "%s:%d: gpgme_error_t %s\n", \
|
||||
__FILE__, __LINE__, gpgme_strerror (err)); \
|
||||
exit (1); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
@ -58,7 +47,7 @@ main (int argc, char *argv[])
|
||||
item->validity, item->name);
|
||||
gpgme_trust_item_unref (item);
|
||||
}
|
||||
if (err != GPGME_EOF)
|
||||
if (gpg_err_code (err) != GPG_ERR_EOF)
|
||||
fail_if_err (err);
|
||||
|
||||
gpgme_release (ctx);
|
||||
|
@ -24,18 +24,7 @@
|
||||
|
||||
#include <gpgme.h>
|
||||
|
||||
|
||||
#define fail_if_err(err) \
|
||||
do \
|
||||
{ \
|
||||
if (err) \
|
||||
{ \
|
||||
fprintf (stderr, "%s:%d: gpgme_error_t %s\n", \
|
||||
__FILE__, __LINE__, gpgme_strerror (err)); \
|
||||
exit (1); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
#include "t-support.h"
|
||||
|
||||
|
||||
static const char test_text1[] = "Just GNU it!\n";
|
||||
@ -106,10 +95,10 @@ check_result (gpgme_verify_result_t result, int summary, char *fpr,
|
||||
__FILE__, __LINE__, sig->fpr);
|
||||
exit (1);
|
||||
}
|
||||
if (sig->status != status)
|
||||
if (gpg_err_code (sig->status) != status)
|
||||
{
|
||||
fprintf (stderr, "%s:%i: Unexpected signature status: %s\n",
|
||||
__FILE__, __LINE__, gpgme_strerror (sig->status));
|
||||
__FILE__, __LINE__, gpg_strerror (sig->status));
|
||||
exit (1);
|
||||
}
|
||||
if (notation)
|
||||
@ -145,7 +134,7 @@ check_result (gpgme_verify_result_t result, int summary, char *fpr,
|
||||
__FILE__, __LINE__, sig->validity);
|
||||
exit (1);
|
||||
}
|
||||
if (sig->validity_reason != GPGME_No_Error)
|
||||
if (gpg_err_code (sig->validity_reason) != GPG_ERR_NO_ERROR)
|
||||
{
|
||||
fprintf (stderr, "%s:%i: Unexpected validity reason: %s\n",
|
||||
__FILE__, __LINE__, gpgme_strerror (sig->validity_reason));
|
||||
@ -174,7 +163,7 @@ main (int argc, char *argv[])
|
||||
fail_if_err (err);
|
||||
result = gpgme_op_verify_result (ctx);
|
||||
check_result (result, 0, "A0FF4590BB6122EDEF6E3C542D727CC768697734",
|
||||
GPGME_No_Error, 1);
|
||||
GPG_ERR_NO_ERROR, 1);
|
||||
|
||||
/* Checking a manipulated message. */
|
||||
gpgme_data_release (text);
|
||||
@ -185,7 +174,7 @@ main (int argc, char *argv[])
|
||||
fail_if_err (err);
|
||||
result = gpgme_op_verify_result (ctx);
|
||||
check_result (result, GPGME_SIGSUM_RED, "2D727CC768697734",
|
||||
GPGME_Bad_Signature, 0);
|
||||
GPG_ERR_BAD_SIGNATURE, 0);
|
||||
|
||||
/* Checking a normal signature. */
|
||||
gpgme_data_release (sig);
|
||||
@ -198,7 +187,7 @@ main (int argc, char *argv[])
|
||||
fail_if_err (err);
|
||||
result = gpgme_op_verify_result (ctx);
|
||||
check_result (result, 0, "A0FF4590BB6122EDEF6E3C542D727CC768697734",
|
||||
GPGME_No_Error, 0);
|
||||
GPG_ERR_NO_ERROR, 0);
|
||||
|
||||
gpgme_data_release (sig);
|
||||
gpgme_data_release (text);
|
||||
|
@ -23,9 +23,11 @@ GPGSM = @GPGSM@
|
||||
|
||||
TESTS_ENVIRONMENT = GNUPGHOME=.
|
||||
|
||||
noinst_HEADERS = t-support.h
|
||||
TESTS = t-import t-keylist t-encrypt t-verify t-decrypt t-sign t-export
|
||||
|
||||
EXTRA_DIST = cert_dfn_pca01.der cert_dfn_pca15.der cert_g10code_test1.der $(key_id)
|
||||
EXTRA_DIST = cert_dfn_pca01.der cert_dfn_pca15.der cert_g10code_test1.der \
|
||||
$(key_id)
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/gpgme
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include <gpgme.h>
|
||||
#include "t-support.h"
|
||||
|
||||
|
||||
static const char test_text1[] = "Hallo Leute!\n";
|
||||
@ -39,30 +40,6 @@ static const char test_cip1[] =
|
||||
"BAiiytWtOSmqnwAA\n"
|
||||
"-----END CMS OBJECT-----\n";
|
||||
|
||||
#define fail_if_err(a) do { if(a) { int my_errno = errno; \
|
||||
fprintf (stderr, "%s:%d: gpgme_error_t %s\n", \
|
||||
__FILE__, __LINE__, gpgme_strerror(a)); \
|
||||
if ((a) == GPGME_File_Error) \
|
||||
fprintf (stderr, "\terrno=`%s'\n", strerror (my_errno)); \
|
||||
exit (1); } \
|
||||
} while(0)
|
||||
|
||||
static void
|
||||
print_data (gpgme_data_t dh)
|
||||
{
|
||||
#define BUF_SIZE 512
|
||||
char buf[BUF_SIZE + 1];
|
||||
int ret;
|
||||
|
||||
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
||||
if (ret)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
while ((ret = gpgme_data_read (dh, buf, BUF_SIZE)) > 0)
|
||||
fwrite (buf, ret, 1, stdout);
|
||||
if (ret < 0)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
|
@ -24,35 +24,7 @@
|
||||
|
||||
#include <gpgme.h>
|
||||
|
||||
#define fail_if_err(err) \
|
||||
do \
|
||||
{ \
|
||||
if (err) \
|
||||
{ \
|
||||
fprintf (stderr, "%s:%d: gpgme_error_t %s\n", \
|
||||
__FILE__, __LINE__, gpgme_strerror (err)); \
|
||||
exit (1); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
||||
static void
|
||||
print_data (gpgme_data_t dh)
|
||||
{
|
||||
#define BUF_SIZE 512
|
||||
char buf[BUF_SIZE + 1];
|
||||
int ret;
|
||||
|
||||
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
||||
if (ret)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
while ((ret = gpgme_data_read (dh, buf, BUF_SIZE)) > 0)
|
||||
fwrite (buf, ret, 1, stdout);
|
||||
if (ret < 0)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
}
|
||||
|
||||
#include "t-support.h"
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
|
@ -24,34 +24,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include <gpgme.h>
|
||||
|
||||
#define fail_if_err(err) \
|
||||
do \
|
||||
{ \
|
||||
if (err) \
|
||||
{ \
|
||||
fprintf (stderr, "%s:%d: gpgme_error_t %s\n", \
|
||||
__FILE__, __LINE__, gpgme_strerror (err)); \
|
||||
exit (1); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
||||
static void
|
||||
print_data (gpgme_data_t dh)
|
||||
{
|
||||
char buf[100];
|
||||
int ret;
|
||||
|
||||
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
||||
if (ret)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
while ((ret = gpgme_data_read (dh, buf, 100)) > 0)
|
||||
fwrite (buf, ret, 1, stdout);
|
||||
if (ret < 0)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
}
|
||||
#include "t-support.h"
|
||||
|
||||
|
||||
int
|
||||
|
@ -24,35 +24,7 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include <gpgme.h>
|
||||
|
||||
#define fail_if_err(err) \
|
||||
do \
|
||||
{ \
|
||||
if (err) \
|
||||
{ \
|
||||
fprintf (stderr, "%s:%d: gpgme_error_t %s\n", \
|
||||
__FILE__, __LINE__, gpgme_strerror (err)); \
|
||||
exit (1); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
||||
static void
|
||||
print_data (gpgme_data_t dh)
|
||||
{
|
||||
#define BUF_SIZE 512
|
||||
char buf[BUF_SIZE + 1];
|
||||
int ret;
|
||||
|
||||
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
||||
if (ret)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
while ((ret = gpgme_data_read (dh, buf, BUF_SIZE)) > 0)
|
||||
fwrite (buf, ret, 1, stdout);
|
||||
if (ret < 0)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
}
|
||||
#include "t-support.h"
|
||||
|
||||
|
||||
/* True if progress function printed something on the screen. */
|
||||
@ -79,7 +51,7 @@ progress (void *self, const char *what, int type, int current, int total)
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
gpgme_ctx_t ctx;
|
||||
gpgme_error_t err;
|
||||
|
@ -335,7 +335,7 @@ main (int argc, char **argv)
|
||||
gpgme_key_unref (key);
|
||||
i++;
|
||||
}
|
||||
if (err != GPGME_EOF)
|
||||
if (gpg_err_code (err) != GPG_ERR_EOF)
|
||||
fail_if_err (err);
|
||||
err = gpgme_op_keylist_end (ctx);
|
||||
fail_if_err (err);
|
||||
|
@ -23,35 +23,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <gpgme.h>
|
||||
|
||||
#define fail_if_err(err) \
|
||||
do \
|
||||
{ \
|
||||
if (err) \
|
||||
{ \
|
||||
fprintf (stderr, "%s:%d: gpgme_error_t %s\n", \
|
||||
__FILE__, __LINE__, gpgme_strerror (err)); \
|
||||
exit (1); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
||||
static void
|
||||
print_data (gpgme_data_t dh)
|
||||
{
|
||||
#define BUF_SIZE 512
|
||||
char buf[BUF_SIZE + 1];
|
||||
int ret;
|
||||
|
||||
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
||||
if (ret)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
while ((ret = gpgme_data_read (dh, buf, BUF_SIZE)) > 0)
|
||||
fwrite (buf, ret, 1, stdout);
|
||||
if (ret < 0)
|
||||
fail_if_err (GPGME_File_Error);
|
||||
}
|
||||
#include "t-support.h"
|
||||
|
||||
|
||||
static void
|
||||
@ -102,7 +74,7 @@ check_result (gpgme_sign_result_t result, gpgme_sig_mode_t type)
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
gpgme_ctx_t ctx;
|
||||
gpgme_error_t err;
|
||||
|
81
tests/gpgsm/t-support.h
Normal file
81
tests/gpgsm/t-support.h
Normal file
@ -0,0 +1,81 @@
|
||||
/* t-support.h - Helper routines for regression tests.
|
||||
Copyright (C) 2000 Werner Koch (dd9jn)
|
||||
Copyright (C) 2001, 2002, 2003 g10 Code GmbH
|
||||
|
||||
This file is part of GPGME.
|
||||
|
||||
GPGME 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.
|
||||
|
||||
GPGME 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 GPGME; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <gpgme.h>
|
||||
|
||||
#define fail_if_err(err) \
|
||||
do \
|
||||
{ \
|
||||
if (err) \
|
||||
{ \
|
||||
fprintf (stderr, "%s:%d: %s: %s\n", \
|
||||
__FILE__, __LINE__, gpg_strsource (err), \
|
||||
gpg_strerror (err)); \
|
||||
exit (1); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
||||
void
|
||||
print_data (gpgme_data_t dh)
|
||||
{
|
||||
#define BUF_SIZE 512
|
||||
char buf[BUF_SIZE + 1];
|
||||
int ret;
|
||||
|
||||
ret = gpgme_data_seek (dh, 0, SEEK_SET);
|
||||
if (ret)
|
||||
fail_if_err (gpg_error_from_errno (errno));
|
||||
while ((ret = gpgme_data_read (dh, buf, BUF_SIZE)) > 0)
|
||||
fwrite (buf, ret, 1, stdout);
|
||||
if (ret < 0)
|
||||
fail_if_err (gpg_error_from_errno (errno));
|
||||
}
|
||||
|
||||
|
||||
gpgme_error_t
|
||||
passphrase_cb (void *opaque, const char *uid_hint, const char *passphrase_info,
|
||||
int last_was_bad, int fd)
|
||||
{
|
||||
write (fd, "abc\n", 4);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
make_filename (const char *fname)
|
||||
{
|
||||
const char *srcdir = getenv ("srcdir");
|
||||
char *buf;
|
||||
|
||||
if (!srcdir)
|
||||
srcdir = ".";
|
||||
buf = malloc (strlen(srcdir) + strlen(fname) + 2);
|
||||
if (!buf)
|
||||
exit (8);
|
||||
strcpy (buf, srcdir);
|
||||
strcat (buf, "/");
|
||||
strcat (buf, fname);
|
||||
return buf;
|
||||
}
|
@ -78,7 +78,7 @@ check_result (gpgme_verify_result_t result, int summary, char *fpr,
|
||||
__FILE__, __LINE__, sig->fpr);
|
||||
exit (1);
|
||||
}
|
||||
if (sig->status != status)
|
||||
if (gpg_err_code (sig->status) != status)
|
||||
{
|
||||
fprintf (stderr, "%s:%i: Unexpected signature status: %s\n",
|
||||
__FILE__, __LINE__, gpgme_strerror (sig->status));
|
||||
@ -102,7 +102,7 @@ check_result (gpgme_verify_result_t result, int summary, char *fpr,
|
||||
__FILE__, __LINE__, sig->validity);
|
||||
exit (1);
|
||||
}
|
||||
if (sig->validity_reason != GPGME_No_Error)
|
||||
if (gpg_err_code (sig->validity_reason) != GPG_ERR_NO_ERROR)
|
||||
{
|
||||
fprintf (stderr, "%s:%i: Unexpected validity reason: %s\n",
|
||||
__FILE__, __LINE__, gpgme_strerror (sig->validity_reason));
|
||||
@ -133,7 +133,7 @@ main (int argc, char **argv)
|
||||
result = gpgme_op_verify_result (ctx);
|
||||
check_result (result, GPGME_SIGSUM_VALID | GPGME_SIGSUM_GREEN,
|
||||
"3CF405464F66ED4A7DF45BBDD1E4282E33BDB76E",
|
||||
GPGME_No_Error, GPGME_VALIDITY_FULL);
|
||||
GPG_ERR_NO_ERROR, GPGME_VALIDITY_FULL);
|
||||
|
||||
/* Checking a manipulated message. */
|
||||
gpgme_data_release (text);
|
||||
@ -145,7 +145,7 @@ main (int argc, char **argv)
|
||||
result = gpgme_op_verify_result (ctx);
|
||||
check_result (result, GPGME_SIGSUM_RED,
|
||||
"3CF405464F66ED4A7DF45BBDD1E4282E33BDB76E",
|
||||
GPGME_Bad_Signature, GPGME_VALIDITY_UNKNOWN);
|
||||
GPG_ERR_BAD_SIGNATURE, GPGME_VALIDITY_UNKNOWN);
|
||||
|
||||
gpgme_release (ctx);
|
||||
return 0;
|
||||
|
@ -157,7 +157,7 @@ write_test (round_t round, gpgme_data_t data)
|
||||
|
||||
amt = gpgme_data_write (data, text, strlen (text));
|
||||
if (amt != strlen (text))
|
||||
fail_if_err (GPGME_File_Error);
|
||||
fail_if_err (gpg_error_from_errno (errno));
|
||||
|
||||
gpgme_data_seek (data, 0, SEEK_SET);
|
||||
|
||||
@ -191,7 +191,7 @@ main (int argc, char **argv)
|
||||
const char *text_filename = make_filename ("t-data-1.txt");
|
||||
const char *longer_text_filename = make_filename ("t-data-2.txt");
|
||||
const char *missing_filename = "this-file-surely-does-not-exist";
|
||||
gpgme_error_t err = GPGME_No_Error;
|
||||
gpgme_error_t err = 0;
|
||||
gpgme_data_t data;
|
||||
|
||||
while (++round)
|
||||
@ -231,7 +231,8 @@ main (int argc, char **argv)
|
||||
case TEST_INOUT_MEM_FROM_FILE_NO_COPY:
|
||||
err = gpgme_data_new_from_file (&data, text_filename, 0);
|
||||
/* This is not implemented yet. */
|
||||
if (err == GPGME_Not_Implemented || err == GPGME_Invalid_Value)
|
||||
if (gpg_err_code (err) == GPG_ERR_NOT_IMPLEMENTED
|
||||
|| gpg_err_code (err) == GPG_ERR_INV_VALUE)
|
||||
continue;
|
||||
break;
|
||||
case TEST_INOUT_MEM_FROM_FILE_PART_BY_NAME:
|
||||
|
Loading…
Reference in New Issue
Block a user