Copyright (C) 2001, 2002, 2003, 2004 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 Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of
the License, or (at your option) any later version.
-
+
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
Lesser General Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include "debug.h"
#include "context.h"
#include "ops.h"
+#include "util.h"
\f
typedef struct
return NULL;
}
-
+
if (_gpgme_debug_trace ())
{
gpgme_import_status_t impstat;
import = malloc (sizeof (*import));
if (!import)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
import->next = NULL;
- errno = 0;
+ gpg_err_set_errno (0);
nr = strtol (args, &tail, 0);
if (errno || args == tail || *tail != ' ')
{
/* The crypto backend does not behave. */
free (import);
- return gpg_error (GPG_ERR_INV_ENGINE);
+ return trace_gpg_error (GPG_ERR_INV_ENGINE);
}
args = tail;
break;
case 2:
- import->result = gpg_error (GPG_ERR_MISSING_CERT);
+ import->result = gpg_error (GPG_ERR_MISSING_ISSUER_CERT);
break;
case 3:
import->fpr = strdup (args);
if (!import->fpr)
{
- int saved_errno = errno;
free (import);
- return gpg_error_from_errno (saved_errno);
+ return gpg_error_from_syserror ();
}
*import_status = import;
{
char *tail;
- errno = 0;
+ gpg_err_set_errno (0);
#define PARSE_NEXT(x) \
(x) = strtol (args, &tail, 0); \
if (errno || args == tail || *tail != ' ') \
/* The crypto backend does not behave. */ \
- return gpg_error (GPG_ERR_INV_ENGINE); \
+ return trace_gpg_error (GPG_ERR_INV_ENGINE); \
args = tail;
PARSE_NEXT (result->considered);
TRACE_BEG1 (DEBUG_CTX, "gpgme_op_import_start", ctx,
"keydata=%p", keydata);
+ if (!ctx)
+ return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
+
err = _gpgme_op_import_start (ctx, 0, keydata);
return TRACE_ERR (err);
}
TRACE_BEG1 (DEBUG_CTX, "gpgme_op_import", ctx,
"keydata=%p", keydata);
+ if (!ctx)
+ return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
+
err = _gpgme_op_import_start (ctx, 1, keydata);
if (!err)
err = _gpgme_wait_one (ctx);
\f
static gpgme_error_t
-_gpgme_op_import_keys_start (gpgme_ctx_t ctx, int synchronous,
+_gpgme_op_import_keys_start (gpgme_ctx_t ctx, int synchronous,
gpgme_key_t *keys)
{
gpgme_error_t err;
gpg_error_t err;
TRACE_BEG (DEBUG_CTX, "gpgme_op_import_keys_start", ctx);
+
+ if (!ctx)
+ return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
+
if (_gpgme_debug_trace () && keys)
{
int i = 0;
while (keys[i])
{
TRACE_LOG3 ("keys[%i] = %p (%s)", i, keys[i],
- (keys[i]->subkeys && keys[i]->subkeys->fpr) ?
+ (keys[i]->subkeys && keys[i]->subkeys->fpr) ?
keys[i]->subkeys->fpr : "invalid");
i++;
}
gpgme_error_t err;
TRACE_BEG (DEBUG_CTX, "gpgme_op_import_keys", ctx);
+
+ if (!ctx)
+ return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
+
if (_gpgme_debug_trace () && keys)
{
int i = 0;
while (keys[i])
{
TRACE_LOG3 ("keys[%i] = %p (%s)", i, keys[i],
- (keys[i]->subkeys && keys[i]->subkeys->fpr) ?
+ (keys[i]->subkeys && keys[i]->subkeys->fpr) ?
keys[i]->subkeys->fpr : "invalid");
i++;
}