Do not include the removed file status-table.h
[gpgme.git] / src / decrypt.c
index da08e7424b96605bc8d8fe1b78f9a4e5ca1fb49d..43945ec34a600c378016fe0458ea7e32a833f6ed 100644 (file)
@@ -3,17 +3,17 @@
    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
@@ -32,6 +32,7 @@
 #include "context.h"
 #include "ops.h"
 
+
 \f
 typedef struct
 {
@@ -39,7 +40,7 @@ typedef struct
 
   int okay;
   int failed;
-  
+
   /* A pointer to the next pointer of the last recipient in the list.
      This makes appending new invalid signers painless while
      preserving the order.  */
@@ -126,7 +127,7 @@ parse_enc_to (char *args, gpgme_recipient_t *recp)
 
   rec = malloc (sizeof (*rec));
   if (!rec)
-    return gpg_error_from_errno (errno);
+    return gpg_error_from_syserror ();
 
   rec->next = NULL;
   rec->keyid = rec->_keyid;
@@ -153,7 +154,7 @@ parse_enc_to (char *args, gpgme_recipient_t *recp)
 
   if (*args)
     {
-      errno = 0;
+      gpg_err_set_errno (0);
       rec->pubkey_algo = strtol (args, &tail, 0);
       if (errno || args == tail || *tail != ' ')
        {
@@ -200,6 +201,10 @@ _gpgme_decrypt_status_handler (void *priv, gpgme_status_code_t code,
        return gpg_error (GPG_ERR_NO_DATA);
       break;
 
+    case GPGME_STATUS_DECRYPTION_INFO:
+      /* Fixme: Provide a way to return the used symmetric algorithm. */
+      break;
+
     case GPGME_STATUS_DECRYPTION_OKAY:
       opd->okay = 1;
       break;
@@ -239,7 +244,7 @@ _gpgme_decrypt_status_handler (void *priv, gpgme_status_code_t code,
                  {
                    opd->result.unsupported_algorithm = strdup (args);
                    if (!opd->result.unsupported_algorithm)
-                     return gpg_error_from_errno (errno);
+                     return gpg_error_from_syserror ();
                  }
              }
          }
@@ -286,7 +291,7 @@ _gpgme_decrypt_status_handler (void *priv, gpgme_status_code_t code,
       err = _gpgme_parse_plaintext (args, &opd->result.file_name);
       if (err)
        return err;
-      
+
     default:
       break;
     }
@@ -365,9 +370,16 @@ gpgme_error_t
 gpgme_op_decrypt_start (gpgme_ctx_t ctx, gpgme_data_t cipher,
                        gpgme_data_t plain)
 {
+  gpgme_error_t err;
+
   TRACE_BEG2 (DEBUG_CTX, "gpgme_op_decrypt_start", ctx,
              "cipher=%p, plain=%p", cipher, plain);
-  return TRACE_ERR (decrypt_start (ctx, 0, cipher, plain));
+
+  if (!ctx)
+    return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
+  
+  err = decrypt_start (ctx, 0, cipher, plain);
+  return TRACE_ERR (err);
 }
 
 
@@ -380,6 +392,10 @@ gpgme_op_decrypt (gpgme_ctx_t ctx, gpgme_data_t cipher, gpgme_data_t plain)
 
   TRACE_BEG2 (DEBUG_CTX, "gpgme_op_decrypt", ctx,
              "cipher=%p, plain=%p", cipher, plain);
+
+  if (!ctx)
+    return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
+  
   err = decrypt_start (ctx, 1, cipher, plain);
   if (!err)
     err = _gpgme_wait_one (ctx);