Blame src/context.h

Packit Service 672cf4
/* context.h - Definitions for a GPGME context.
Packit Service 672cf4
   Copyright (C) 2000 Werner Koch (dd9jn)
Packit Service 672cf4
   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2010 g10 Code GmbH
Packit Service 672cf4
Packit Service 672cf4
   This file is part of GPGME.
Packit Service 672cf4
Packit Service 672cf4
   GPGME is free software; you can redistribute it and/or modify it
Packit Service 672cf4
   under the terms of the GNU Lesser General Public License as
Packit Service 672cf4
   published by the Free Software Foundation; either version 2.1 of
Packit Service 672cf4
   the License, or (at your option) any later version.
Packit Service 672cf4
Packit Service 672cf4
   GPGME is distributed in the hope that it will be useful, but
Packit Service 672cf4
   WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 672cf4
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 672cf4
   Lesser General Public License for more details.
Packit Service 672cf4
Packit Service 672cf4
   You should have received a copy of the GNU Lesser General Public
Packit Service 672cf4
   License along with this program; if not, see <https://www.gnu.org/licenses/>.
Packit Service 672cf4
 */
Packit Service 672cf4
Packit Service 672cf4
#ifndef CONTEXT_H
Packit Service 672cf4
#define CONTEXT_H
Packit Service 672cf4
Packit Service 672cf4
#include "gpgme.h"
Packit Service 672cf4
#include "engine.h"
Packit Service 672cf4
#include "wait.h"
Packit Service 672cf4
#include "sema.h"
Packit Service 672cf4
Packit Service 672cf4

Packit Service 672cf4
extern gpgme_error_t _gpgme_selftest;
Packit Service 672cf4
Packit Service 672cf4
/* Operations might require to remember arbitrary information and data
Packit Service 672cf4
   objects during invocations of the status handler.  The
Packit Service 672cf4
   ctx_op_data structure provides a generic framework to hook in
Packit Service 672cf4
   such additional data.  */
Packit Service 672cf4
typedef enum
Packit Service 672cf4
  {
Packit Service 672cf4
    OPDATA_DECRYPT, OPDATA_SIGN, OPDATA_ENCRYPT, OPDATA_PASSPHRASE,
Packit Service 672cf4
    OPDATA_IMPORT, OPDATA_GENKEY, OPDATA_KEYLIST, OPDATA_EDIT,
Packit Service 672cf4
    OPDATA_VERIFY, OPDATA_TRUSTLIST, OPDATA_ASSUAN, OPDATA_VFS_MOUNT,
Packit Service 672cf4
    OPDATA_PASSWD, OPDATA_EXPORT, OPDATA_KEYSIGN, OPDATA_TOFU_POLICY,
Packit Service 672cf4
    OPDATA_QUERY_SWDB
Packit Service 672cf4
  } ctx_op_data_id_t;
Packit Service 672cf4
Packit Service 672cf4
Packit Service 672cf4
/* "gpgmeres" in ASCII.  */
Packit Service 672cf4
#define CTX_OP_DATA_MAGIC 0x736572656d677067ULL
Packit Service 672cf4
struct ctx_op_data
Packit Service 672cf4
{
Packit Service 672cf4
  /* A magic word just to make sure people don't deallocate something
Packit Service 672cf4
     that ain't a result structure.  */
Packit Service 672cf4
  unsigned long long magic;
Packit Service 672cf4
Packit Service 672cf4
  /* The next element in the linked list, or NULL if this is the last
Packit Service 672cf4
     element.  Used by op data structures linked into a context.  */
Packit Service 672cf4
  struct ctx_op_data *next;
Packit Service 672cf4
Packit Service 672cf4
  /* The type of the hook data, which can be used by a routine to
Packit Service 672cf4
     lookup the hook data.  */
Packit Service 672cf4
  ctx_op_data_id_t type;
Packit Service 672cf4
Packit Service 672cf4
  /* The function to release HOOK and all its associated resources.
Packit Service 672cf4
     Can be NULL if no special deallocation routine is necessary.  */
Packit Service 672cf4
  void (*cleanup) (void *hook);
Packit Service 672cf4
Packit Service 672cf4
  /* The hook that points to the operation data.  */
Packit Service 672cf4
  void *hook;
Packit Service 672cf4
Packit Service 672cf4
  /* The number of outstanding references.  */
Packit Service 672cf4
  int references;
Packit Service 672cf4
};
Packit Service 672cf4
typedef struct ctx_op_data *ctx_op_data_t;
Packit Service 672cf4
Packit Service 672cf4

Packit Service 672cf4
/* The context defines an environment in which crypto operations can
Packit Service 672cf4
   be performed (sequentially).  */
Packit Service 672cf4
struct gpgme_context
Packit Service 672cf4
{
Packit Service 672cf4
  DECLARE_LOCK (lock);
Packit Service 672cf4
Packit Service 672cf4
  /* True if the context was canceled asynchronously.  */
Packit Service 672cf4
  int canceled;
Packit Service 672cf4
Packit Service 672cf4
  /* The engine info for this context.  */
Packit Service 672cf4
  gpgme_engine_info_t engine_info;
Packit Service 672cf4
Packit Service 672cf4
  /* The protocol used by this context.  */
Packit Service 672cf4
  gpgme_protocol_t protocol;
Packit Service 672cf4
Packit Service 672cf4
  /* The running engine process.  */
Packit Service 672cf4
  engine_t engine;
Packit Service 672cf4
Packit Service 672cf4
  /* Engine's sub protocol.  */
Packit Service 672cf4
  gpgme_protocol_t sub_protocol;
Packit Service 672cf4
Packit Service 672cf4
  /* True if armor mode should be used.  */
Packit Service 672cf4
  unsigned int use_armor : 1;
Packit Service 672cf4
Packit Service 672cf4
  /* True if text mode should be used.  */
Packit Service 672cf4
  unsigned int use_textmode : 1;
Packit Service 672cf4
Packit Service 672cf4
  /* True if offline mode should be used.  */
Packit Service 672cf4
  unsigned int offline : 1;
Packit Service 672cf4
Packit Service 672cf4
  /* True if a status callback shall be called for nearly all status
Packit Service 672cf4
   * lines.  */
Packit Service 672cf4
  unsigned int full_status : 1;
Packit Service 672cf4
Packit Service 672cf4
  /* The Tofu info has a human readable string which is presented to
Packit Service 672cf4
   * the user in a directly usable format.  By enabling this flag the
Packit Service 672cf4
   * unmodified string, as received form gpg, will be returned.  */
Packit Service 672cf4
  unsigned int raw_description : 1;
Packit Service 672cf4
Packit Service 672cf4
  /* True if session keys should be exported upon decryption.  */
Packit Service 672cf4
  unsigned int export_session_keys : 1;
Packit Service 672cf4
Packit Service 672cf4
  /* True if a Pinentry was launched during the last operation.  This
Packit Service 672cf4
   * flag is cleared with each operation.  */
Packit Service 672cf4
  unsigned int redraw_suggested : 1;
Packit Service 672cf4
Packit Service 672cf4
  /* True if the option --auto-key-retrieve shall be passed to gpg.  */
Packit Service 672cf4
  unsigned int auto_key_retrieve : 1;
Packit Service 672cf4
Packit Service 672cf4
  /* Flags for keylist mode.  */
Packit Service 672cf4
  gpgme_keylist_mode_t keylist_mode;
Packit Service 672cf4
Packit Service 672cf4
  /* The current pinentry mode.  */
Packit Service 672cf4
  gpgme_pinentry_mode_t pinentry_mode;
Packit Service 672cf4
Packit Service 672cf4
  /* Number of certs to be included.  */
Packit Service 672cf4
  unsigned int include_certs;
Packit Service 672cf4
Packit Service 672cf4
  /* The actual number of keys in SIGNERS, the allocated size of the
Packit Service 672cf4
   * array, and the array with the signing keys.  */
Packit Service 672cf4
  unsigned int signers_len;
Packit Service 672cf4
  unsigned int signers_size;
Packit Service 672cf4
  gpgme_key_t *signers;
Packit Service 672cf4
Packit Service 672cf4
  /* The signature notations for this context.  */
Packit Service 672cf4
  gpgme_sig_notation_t sig_notations;
Packit Service 672cf4
Packit Service 672cf4
  /* The sender's addr-spec or NULL.  */
Packit Service 672cf4
  char *sender;
Packit Service 672cf4
Packit Service 672cf4
  /* The gpg specific override session key or NULL. */
Packit Service 672cf4
  char *override_session_key;
Packit Service 672cf4
Packit Service 672cf4
  /* The locale for the pinentry.  */
Packit Service 672cf4
  char *lc_ctype;
Packit Service 672cf4
  char *lc_messages;
Packit Service 672cf4
Packit Service 672cf4
  /* The operation data hooked into the context.  */
Packit Service 672cf4
  ctx_op_data_t op_data;
Packit Service 672cf4
Packit Service 672cf4
  /* The user provided passphrase callback and its hook value.  */
Packit Service 672cf4
  gpgme_passphrase_cb_t passphrase_cb;
Packit Service 672cf4
  void *passphrase_cb_value;
Packit Service 672cf4
Packit Service 672cf4
  /* The user provided progress callback and its hook value.  */
Packit Service 672cf4
  gpgme_progress_cb_t progress_cb;
Packit Service 672cf4
  void *progress_cb_value;
Packit Service 672cf4
Packit Service 672cf4
  /* The user provided status callback and its hook value.  */
Packit Service 672cf4
  gpgme_status_cb_t status_cb;
Packit Service 672cf4
  void *status_cb_value;
Packit Service 672cf4
Packit Service 672cf4
  /* A list of file descriptors in active use by the current
Packit Service 672cf4
     operation.  */
Packit Service 672cf4
  struct fd_table fdt;
Packit Service 672cf4
  struct gpgme_io_cbs io_cbs;
Packit Service 672cf4
};
Packit Service 672cf4
Packit Service 672cf4
#endif	/* CONTEXT_H */