Module: GPGME

Defined in:
lib/gpgme/compat.rb,
lib/gpgme.rb,
lib/gpgme/ctx.rb,
lib/gpgme/key.rb,
lib/gpgme/misc.rb,
lib/gpgme/data.rb,
lib/gpgme/error.rb,
lib/gpgme/engine.rb,
lib/gpgme/crypto.rb,
lib/gpgme/version.rb,
lib/gpgme/sub_key.rb,
lib/gpgme/user_id.rb,
lib/gpgme/key_sig.rb,
lib/gpgme/constants.rb,
lib/gpgme/signature.rb,
lib/gpgme/key_common.rb,
lib/gpgme/io_callbacks.rb,
ext/gpgme/gpgme_n.c

Overview

TODO: Find why is this needed. I guess the name compat means it's just backwards compatibility. Consider removing?

Defined Under Namespace

Modules: Engine, KeyCommon Classes: Crypto, Ctx, Data, DecryptResult, EncryptResult, EngineInfo, Error, IOCallbacks, ImportResult, ImportStatus, InvalidKey, Key, KeySig, NewSignature, SigNotation, SignResult, Signature, SubKey, TrustItem, UserID, VerifyResult

Constant Summary

GpgmeError =
Error
GpgmeData =
Data
GpgmeEngineInfo =
EngineInfo
GpgmeCtx =
Ctx
GpgmeKey =
Key
GpgmeSubKey =
SubKey
GpgmeUserID =
UserID
GpgmeKeySig =
KeySig
GpgmeVerifyResult =
VerifyResult
GpgmeSignature =
Signature
GpgmeDecryptResult =
DecryptResult
GpgmeSignResult =
SignResult
GpgmeEncryptResult =
EncryptResult
GpgmeInvalidKey =
InvalidKey
GpgmeNewSignature =
NewSignature
GpgmeImportStatus =
ImportStatus
GpgmeImportResult =
ImportResult
VERSION =
"1.0.8"
ATTR_ALGO =
GPGME_ATTR_ALGO
ATTR_CAN_CERTIFY =
GPGME_ATTR_CAN_CERTIFY
ATTR_CAN_ENCRYPT =
GPGME_ATTR_CAN_ENCRYPT
ATTR_CAN_SIGN =
GPGME_ATTR_CAN_SIGN
ATTR_CHAINID =
GPGME_ATTR_CHAINID
ATTR_COMMENT =
GPGME_ATTR_COMMENT
ATTR_CREATED =
GPGME_ATTR_CREATED
ATTR_EMAIL =
GPGME_ATTR_EMAIL
ATTR_ERRTOK =
GPGME_ATTR_ERRTOK
ATTR_EXPIRE =
GPGME_ATTR_EXPIRE
ATTR_FPR =
GPGME_ATTR_FPR
ATTR_ISSUER =
GPGME_ATTR_ISSUER
ATTR_IS_SECRET =
GPGME_ATTR_IS_SECRET
ATTR_KEYID =
GPGME_ATTR_KEYID
ATTR_KEY_CAPS =
GPGME_ATTR_KEY_CAPS
ATTR_KEY_DISABLED =
GPGME_ATTR_KEY_DISABLED
ATTR_KEY_EXPIRED =
GPGME_ATTR_KEY_EXPIRED
ATTR_KEY_INVALID =
GPGME_ATTR_KEY_INVALID
ATTR_KEY_REVOKED =
GPGME_ATTR_KEY_REVOKED
ATTR_LEN =
GPGME_ATTR_LEN
ATTR_LEVEL =
GPGME_ATTR_LEVEL
ATTR_NAME =
GPGME_ATTR_NAME
ATTR_OTRUST =
GPGME_ATTR_OTRUST
ATTR_SERIAL =
GPGME_ATTR_SERIAL
ATTR_SIG_STATUS =
GPGME_ATTR_SIG_STATUS
ATTR_SIG_SUMMARY =
GPGME_ATTR_SIG_SUMMARY
ATTR_TYPE =
GPGME_ATTR_TYPE
ATTR_UID_INVALID =
GPGME_ATTR_UID_INVALID
ATTR_UID_REVOKED =
GPGME_ATTR_UID_REVOKED
ATTR_USERID =
GPGME_ATTR_USERID
ATTR_VALIDITY =
GPGME_ATTR_VALIDITY
DATA_ENCODING_ARMOR =
GPGME_DATA_ENCODING_ARMOR
DATA_ENCODING_BASE64 =
GPGME_DATA_ENCODING_BASE64
DATA_ENCODING_BINARY =
GPGME_DATA_ENCODING_BINARY
DATA_ENCODING_NONE =
GPGME_DATA_ENCODING_NONE
ENCRYPT_ALWAYS_TRUST =
GPGME_ENCRYPT_ALWAYS_TRUST
IMPORT_NEW =
GPGME_IMPORT_NEW
IMPORT_SECRET =
GPGME_IMPORT_SECRET
IMPORT_SIG =
GPGME_IMPORT_SIG
IMPORT_SUBKEY =
GPGME_IMPORT_SUBKEY
IMPORT_UID =
GPGME_IMPORT_UID
KEYLIST_MODE_EXTERN =
GPGME_KEYLIST_MODE_EXTERN
KEYLIST_MODE_LOCAL =
GPGME_KEYLIST_MODE_LOCAL
KEYLIST_MODE_SIGS =
GPGME_KEYLIST_MODE_SIGS
KEYLIST_MODE_VALIDATE =
GPGME_KEYLIST_MODE_VALIDATE
MD_CRC24_RFC2440 =
GPGME_MD_CRC24_RFC2440
MD_CRC32 =
GPGME_MD_CRC32
MD_CRC32_RFC1510 =
GPGME_MD_CRC32_RFC1510
MD_HAVAL =
GPGME_MD_HAVAL
MD_MD2 =
GPGME_MD_MD2
MD_MD4 =
GPGME_MD_MD4
MD_MD5 =
GPGME_MD_MD5
MD_RMD160 =
GPGME_MD_RMD160
MD_SHA1 =
GPGME_MD_SHA1
MD_SHA256 =
GPGME_MD_SHA256
MD_SHA384 =
GPGME_MD_SHA384
MD_SHA512 =
GPGME_MD_SHA512
MD_TIGER =
GPGME_MD_TIGER
PINENTRY_MODE_DEFAULT =
GPGME_PINENTRY_MODE_DEFAULT
PINENTRY_MODE_ASK =
GPGME_PINENTRY_MODE_ASK
PINENTRY_MODE_CANCEL =
GPGME_PINENTRY_MODE_CANCEL
PINENTRY_MODE_ERROR =
GPGME_PINENTRY_MODE_ERROR
PINENTRY_MODE_LOOPBACK =
GPGME_PINENTRY_MODE_LOOPBACK
PK_DSA =
GPGME_PK_DSA
PK_ELG =
GPGME_PK_ELG
PK_ELG_E =
GPGME_PK_ELG_E
PK_RSA =
GPGME_PK_RSA
PROTOCOL_CMS =
GPGME_PROTOCOL_CMS
PROTOCOL_OpenPGP =
GPGME_PROTOCOL_OpenPGP
SIGSUM_BAD_POLICY =
GPGME_SIGSUM_BAD_POLICY
SIGSUM_CRL_MISSING =
GPGME_SIGSUM_CRL_MISSING
SIGSUM_CRL_TOO_OLD =
GPGME_SIGSUM_CRL_TOO_OLD
SIGSUM_GREEN =
GPGME_SIGSUM_GREEN
SIGSUM_KEY_EXPIRED =
GPGME_SIGSUM_KEY_EXPIRED
SIGSUM_KEY_MISSING =
GPGME_SIGSUM_KEY_MISSING
SIGSUM_KEY_REVOKED =
GPGME_SIGSUM_KEY_REVOKED
SIGSUM_RED =
GPGME_SIGSUM_RED
SIGSUM_SIG_EXPIRED =
GPGME_SIGSUM_SIG_EXPIRED
SIGSUM_SYS_ERROR =
GPGME_SIGSUM_SYS_ERROR
SIGSUM_VALID =
GPGME_SIGSUM_VALID
SIG_MODE_CLEAR =
GPGME_SIG_MODE_CLEAR
SIG_MODE_DETACH =
GPGME_SIG_MODE_DETACH
SIG_MODE_NORMAL =
GPGME_SIG_MODE_NORMAL
SIG_STAT_BAD =
GPGME_SIG_STAT_BAD
SIG_STAT_DIFF =
GPGME_SIG_STAT_DIFF
SIG_STAT_ERROR =
GPGME_SIG_STAT_ERROR
SIG_STAT_GOOD =
GPGME_SIG_STAT_GOOD
SIG_STAT_GOOD_EXP =
GPGME_SIG_STAT_GOOD_EXP
SIG_STAT_GOOD_EXPKEY =
GPGME_SIG_STAT_GOOD_EXPKEY
SIG_STAT_NOKEY =
GPGME_SIG_STAT_NOKEY
SIG_STAT_NONE =
GPGME_SIG_STAT_NONE
SIG_STAT_NOSIG =
GPGME_SIG_STAT_NOSIG
STATUS_ABORT =
GPGME_STATUS_ABORT
STATUS_ALREADY_SIGNED =
GPGME_STATUS_ALREADY_SIGNED
STATUS_BADARMOR =
GPGME_STATUS_BADARMOR
STATUS_BADMDC =
GPGME_STATUS_BADMDC
STATUS_BADSIG =
GPGME_STATUS_BADSIG
STATUS_BAD_PASSPHRASE =
GPGME_STATUS_BAD_PASSPHRASE
STATUS_BEGIN_DECRYPTION =
GPGME_STATUS_BEGIN_DECRYPTION
STATUS_BEGIN_ENCRYPTION =
GPGME_STATUS_BEGIN_ENCRYPTION
STATUS_BEGIN_STREAM =
GPGME_STATUS_BEGIN_STREAM
STATUS_DECRYPTION_FAILED =
GPGME_STATUS_DECRYPTION_FAILED
STATUS_DECRYPTION_OKAY =
GPGME_STATUS_DECRYPTION_OKAY
STATUS_DELETE_PROBLEM =
GPGME_STATUS_DELETE_PROBLEM
STATUS_ENC_TO =
GPGME_STATUS_ENC_TO
STATUS_END_DECRYPTION =
GPGME_STATUS_END_DECRYPTION
STATUS_END_ENCRYPTION =
GPGME_STATUS_END_ENCRYPTION
STATUS_END_STREAM =
GPGME_STATUS_END_STREAM
STATUS_ENTER =
GPGME_STATUS_ENTER
STATUS_EOF =
GPGME_STATUS_EOF
STATUS_ERRMDC =
GPGME_STATUS_ERRMDC
STATUS_ERROR =
GPGME_STATUS_ERROR
STATUS_ERRSIG =
GPGME_STATUS_ERRSIG
STATUS_EXPKEYSIG =
GPGME_STATUS_EXPKEYSIG
STATUS_EXPSIG =
GPGME_STATUS_EXPSIG
STATUS_FILE_DONE =
GPGME_STATUS_FILE_DONE
STATUS_FILE_ERROR =
GPGME_STATUS_FILE_ERROR
STATUS_FILE_START =
GPGME_STATUS_FILE_START
STATUS_GET_BOOL =
GPGME_STATUS_GET_BOOL
STATUS_GET_HIDDEN =
GPGME_STATUS_GET_HIDDEN
STATUS_GET_LINE =
GPGME_STATUS_GET_LINE
STATUS_GOODMDC =
GPGME_STATUS_GOODMDC
STATUS_GOODSIG =
GPGME_STATUS_GOODSIG
STATUS_GOOD_PASSPHRASE =
GPGME_STATUS_GOOD_PASSPHRASE
STATUS_GOT_IT =
GPGME_STATUS_GOT_IT
STATUS_IMPORTED =
GPGME_STATUS_IMPORTED
STATUS_IMPORT_RES =
GPGME_STATUS_IMPORT_RES
STATUS_INV_RECP =
GPGME_STATUS_INV_RECP
STATUS_KEYEXPIRED =
GPGME_STATUS_KEYEXPIRED
STATUS_KEYREVOKED =
GPGME_STATUS_KEYREVOKED
STATUS_KEY_CREATED =
GPGME_STATUS_KEY_CREATED
STATUS_LEAVE =
GPGME_STATUS_LEAVE
STATUS_MISSING_PASSPHRASE =
GPGME_STATUS_MISSING_PASSPHRASE
STATUS_NEED_PASSPHRASE =
GPGME_STATUS_NEED_PASSPHRASE
STATUS_NEED_PASSPHRASE_SYM =
GPGME_STATUS_NEED_PASSPHRASE_SYM
STATUS_NODATA =
GPGME_STATUS_NODATA
STATUS_NOTATION_DATA =
GPGME_STATUS_NOTATION_DATA
STATUS_NOTATION_NAME =
GPGME_STATUS_NOTATION_NAME
STATUS_NO_PUBKEY =
GPGME_STATUS_NO_PUBKEY
STATUS_NO_RECP =
GPGME_STATUS_NO_RECP
STATUS_NO_SECKEY =
GPGME_STATUS_NO_SECKEY
STATUS_POLICY_URL =
GPGME_STATUS_POLICY_URL
STATUS_PROGRESS =
GPGME_STATUS_PROGRESS
STATUS_RSA_OR_IDEA =
GPGME_STATUS_RSA_OR_IDEA
STATUS_SESSION_KEY =
GPGME_STATUS_SESSION_KEY
STATUS_SHM_GET =
GPGME_STATUS_SHM_GET
STATUS_SHM_GET_BOOL =
GPGME_STATUS_SHM_GET_BOOL
STATUS_SHM_GET_HIDDEN =
GPGME_STATUS_SHM_GET_HIDDEN
STATUS_SHM_INFO =
GPGME_STATUS_SHM_INFO
STATUS_SIGEXPIRED =
GPGME_STATUS_SIGEXPIRED
STATUS_SIG_CREATED =
GPGME_STATUS_SIG_CREATED
STATUS_SIG_ID =
GPGME_STATUS_SIG_ID
STATUS_TRUNCATED =
GPGME_STATUS_TRUNCATED
STATUS_TRUST_FULLY =
GPGME_STATUS_TRUST_FULLY
STATUS_TRUST_MARGINAL =
GPGME_STATUS_TRUST_MARGINAL
STATUS_TRUST_NEVER =
GPGME_STATUS_TRUST_NEVER
STATUS_TRUST_ULTIMATE =
GPGME_STATUS_TRUST_ULTIMATE
STATUS_TRUST_UNDEFINED =
GPGME_STATUS_TRUST_UNDEFINED
STATUS_UNEXPECTED =
GPGME_STATUS_UNEXPECTED
STATUS_USERID_HINT =
GPGME_STATUS_USERID_HINT
STATUS_VALIDSIG =
GPGME_STATUS_VALIDSIG
VALIDITY_FULL =
GPGME_VALIDITY_FULL
VALIDITY_MARGINAL =
GPGME_VALIDITY_MARGINAL
VALIDITY_NEVER =
GPGME_VALIDITY_NEVER
VALIDITY_ULTIMATE =
GPGME_VALIDITY_ULTIMATE
VALIDITY_UNDEFINED =
GPGME_VALIDITY_UNDEFINED
VALIDITY_UNKNOWN =
GPGME_VALIDITY_UNKNOWN
PROTOCOL_NAMES =
{
  PROTOCOL_OpenPGP  => :OpenPGP,
  PROTOCOL_CMS      => :CMS
}
KEYLIST_MODE_NAMES =
{
  KEYLIST_MODE_LOCAL    => :local,
  KEYLIST_MODE_EXTERN   => :extern,
  KEYLIST_MODE_SIGS     => :sigs,
  KEYLIST_MODE_VALIDATE => :validate
}
VALIDITY_NAMES =
{
  VALIDITY_UNKNOWN    => :unknown,
  VALIDITY_UNDEFINED  => :undefined,
  VALIDITY_NEVER      => :never,
  VALIDITY_MARGINAL   => :marginal,
  VALIDITY_FULL       => :full,
  VALIDITY_ULTIMATE   => :ultimate
}
PINENTRY_MODE_NAMES =
{
  PINENTRY_MODE_DEFAULT  => :default,
  PINENTRY_MODE_ASK      => :ask,
  PINENTRY_MODE_CANCEL   => :cancel,
  PINENTRY_MODE_ERROR    => :error,
  PINENTRY_MODE_LOOPBACK => :loopback
}
GPGME_PK_RSA =

gpgme_pubkey_algo_t

INT2FIX(GPGME_PK_RSA)
GPGME_PK_DSA =
INT2FIX(GPGME_PK_DSA)
GPGME_PK_ELG =
INT2FIX(GPGME_PK_ELG)
GPGME_PK_ELG_E =
INT2FIX(GPGME_PK_ELG_E)
GPGME_MD_MD5 =

gpgme_hash_algo_t

INT2FIX(GPGME_MD_MD5)
GPGME_MD_SHA1 =
INT2FIX(GPGME_MD_SHA1)
GPGME_MD_RMD160 =
INT2FIX(GPGME_MD_RMD160)
GPGME_MD_MD2 =
INT2FIX(GPGME_MD_MD2)
GPGME_MD_TIGER =
INT2FIX(GPGME_MD_TIGER)
GPGME_MD_HAVAL =
INT2FIX(GPGME_MD_HAVAL)
GPGME_MD_SHA256 =
INT2FIX(GPGME_MD_SHA256)
GPGME_MD_SHA384 =
INT2FIX(GPGME_MD_SHA384)
GPGME_MD_SHA512 =
INT2FIX(GPGME_MD_SHA512)
GPGME_MD_MD4 =
INT2FIX(GPGME_MD_MD4)
GPGME_MD_CRC32 =
INT2FIX(GPGME_MD_CRC32)
GPGME_MD_CRC32_RFC1510 =
INT2FIX(GPGME_MD_CRC32_RFC1510)
GPGME_MD_CRC24_RFC2440 =
INT2FIX(GPGME_MD_CRC24_RFC2440)
GPG_ERR_EOF =

gpgme_err_code_t

INT2FIX(GPG_ERR_EOF)
GPG_ERR_NO_ERROR =
INT2FIX(GPG_ERR_NO_ERROR)
GPG_ERR_GENERAL =
INT2FIX(GPG_ERR_GENERAL)
GPG_ERR_ENOMEM =
INT2FIX(GPG_ERR_ENOMEM)
GPG_ERR_INV_VALUE =
INT2FIX(GPG_ERR_INV_VALUE)
GPG_ERR_UNUSABLE_PUBKEY =
INT2FIX(GPG_ERR_UNUSABLE_PUBKEY)
GPG_ERR_UNUSABLE_SECKEY =
INT2FIX(GPG_ERR_UNUSABLE_SECKEY)
GPG_ERR_NO_DATA =
INT2FIX(GPG_ERR_NO_DATA)
GPG_ERR_CONFLICT =
INT2FIX(GPG_ERR_CONFLICT)
GPG_ERR_NOT_IMPLEMENTED =
INT2FIX(GPG_ERR_NOT_IMPLEMENTED)
GPG_ERR_DECRYPT_FAILED =
INT2FIX(GPG_ERR_DECRYPT_FAILED)
GPG_ERR_BAD_PASSPHRASE =
INT2FIX(GPG_ERR_BAD_PASSPHRASE)
GPG_ERR_KEY_EXPIRED =
INT2FIX(GPG_ERR_KEY_EXPIRED)
GPG_ERR_SIG_EXPIRED =
INT2FIX(GPG_ERR_SIG_EXPIRED)
GPG_ERR_CANCELED =
INT2FIX(GPG_ERR_CANCELED)
GPG_ERR_INV_ENGINE =
INT2FIX(GPG_ERR_INV_ENGINE)
GPG_ERR_AMBIGUOUS_NAME =
INT2FIX(GPG_ERR_AMBIGUOUS_NAME)
GPG_ERR_WRONG_KEY_USAGE =
INT2FIX(GPG_ERR_WRONG_KEY_USAGE)
GPG_ERR_CERT_REVOKED =
INT2FIX(GPG_ERR_CERT_REVOKED)
GPG_ERR_CERT_EXPIRED =
INT2FIX(GPG_ERR_CERT_EXPIRED)
GPG_ERR_NO_CRL_KNOWN =
INT2FIX(GPG_ERR_NO_CRL_KNOWN)
GPG_ERR_NO_POLICY_MATCH =
INT2FIX(GPG_ERR_NO_POLICY_MATCH)
GPG_ERR_NO_SECKEY =
INT2FIX(GPG_ERR_NO_SECKEY)
GPG_ERR_MISSING_CERT =
INT2FIX(GPG_ERR_MISSING_CERT)
GPG_ERR_BAD_CERT_CHAIN =
INT2FIX(GPG_ERR_BAD_CERT_CHAIN)
GPG_ERR_UNSUPPORTED_ALGORITHM =
INT2FIX(GPG_ERR_UNSUPPORTED_ALGORITHM)
GPG_ERR_BAD_SIGNATURE =
INT2FIX(GPG_ERR_BAD_SIGNATURE)
GPG_ERR_NO_PUBKEY =
INT2FIX(GPG_ERR_NO_PUBKEY)
GPG_ERR_SOURCE_UNKNOWN =

gpgme_err_source_t

INT2FIX(GPG_ERR_SOURCE_UNKNOWN)
GPG_ERR_SOURCE_GPGME =
INT2FIX(GPG_ERR_SOURCE_GPGME)
GPG_ERR_SOURCE_GPG =
INT2FIX(GPG_ERR_SOURCE_GPG)
GPG_ERR_SOURCE_GPGSM =
INT2FIX(GPG_ERR_SOURCE_GPGSM)
GPG_ERR_SOURCE_GCRYPT =
INT2FIX(GPG_ERR_SOURCE_GCRYPT)
GPG_ERR_SOURCE_GPGAGENT =
INT2FIX(GPG_ERR_SOURCE_GPGAGENT)
GPG_ERR_SOURCE_PINENTRY =
INT2FIX(GPG_ERR_SOURCE_PINENTRY)
GPG_ERR_SOURCE_SCD =
INT2FIX(GPG_ERR_SOURCE_SCD)
GPG_ERR_SOURCE_KEYBOX =
INT2FIX(GPG_ERR_SOURCE_KEYBOX)
GPG_ERR_SOURCE_USER_1 =
INT2FIX(GPG_ERR_SOURCE_USER_1)
GPG_ERR_SOURCE_USER_2 =
INT2FIX(GPG_ERR_SOURCE_USER_2)
GPG_ERR_SOURCE_USER_3 =
INT2FIX(GPG_ERR_SOURCE_USER_3)
GPG_ERR_SOURCE_USER_4 =
INT2FIX(GPG_ERR_SOURCE_USER_4)
GPGME_DATA_ENCODING_NONE =

gpgme_data_encoding_t

INT2FIX(GPGME_DATA_ENCODING_NONE)
GPGME_DATA_ENCODING_BINARY =
INT2FIX(GPGME_DATA_ENCODING_BINARY)
GPGME_DATA_ENCODING_BASE64 =
INT2FIX(GPGME_DATA_ENCODING_BASE64)
GPGME_DATA_ENCODING_ARMOR =
INT2FIX(GPGME_DATA_ENCODING_ARMOR)
GPGME_SIG_STAT_NONE =

gpgme_sig_stat_t

INT2FIX(GPGME_SIG_STAT_NONE)
GPGME_SIG_STAT_GOOD =
INT2FIX(GPGME_SIG_STAT_GOOD)
GPGME_SIG_STAT_BAD =
INT2FIX(GPGME_SIG_STAT_BAD)
GPGME_SIG_STAT_NOKEY =
INT2FIX(GPGME_SIG_STAT_NOKEY)
GPGME_SIG_STAT_NOSIG =
INT2FIX(GPGME_SIG_STAT_NOSIG)
GPGME_SIG_STAT_ERROR =
INT2FIX(GPGME_SIG_STAT_ERROR)
GPGME_SIG_STAT_DIFF =
INT2FIX(GPGME_SIG_STAT_DIFF)
GPGME_SIG_STAT_GOOD_EXP =
INT2FIX(GPGME_SIG_STAT_GOOD_EXP)
GPGME_SIG_STAT_GOOD_EXPKEY =
INT2FIX(GPGME_SIG_STAT_GOOD_EXPKEY)
GPGME_SIGSUM_VALID =

gpgme_sigsum_t

INT2FIX(GPGME_SIGSUM_VALID)
GPGME_SIGSUM_GREEN =
INT2FIX(GPGME_SIGSUM_GREEN)
GPGME_SIGSUM_RED =
INT2FIX(GPGME_SIGSUM_RED)
GPGME_SIGSUM_KEY_REVOKED =
INT2FIX(GPGME_SIGSUM_KEY_REVOKED)
GPGME_SIGSUM_KEY_EXPIRED =
INT2FIX(GPGME_SIGSUM_KEY_EXPIRED)
GPGME_SIGSUM_SIG_EXPIRED =
INT2FIX(GPGME_SIGSUM_SIG_EXPIRED)
GPGME_SIGSUM_KEY_MISSING =
INT2FIX(GPGME_SIGSUM_KEY_MISSING)
GPGME_SIGSUM_CRL_MISSING =
INT2FIX(GPGME_SIGSUM_CRL_MISSING)
GPGME_SIGSUM_CRL_TOO_OLD =
INT2FIX(GPGME_SIGSUM_CRL_TOO_OLD)
GPGME_SIGSUM_BAD_POLICY =
INT2FIX(GPGME_SIGSUM_BAD_POLICY)
GPGME_SIGSUM_SYS_ERROR =
INT2FIX(GPGME_SIGSUM_SYS_ERROR)
GPGME_SIG_MODE_NORMAL =

gpgme_sig_mode_t

INT2FIX(GPGME_SIG_MODE_NORMAL)
GPGME_SIG_MODE_DETACH =
INT2FIX(GPGME_SIG_MODE_DETACH)
GPGME_SIG_MODE_CLEAR =
INT2FIX(GPGME_SIG_MODE_CLEAR)
GPGME_ATTR_KEYID =

gpgme_attr_t

INT2FIX(GPGME_ATTR_KEYID)
GPGME_ATTR_FPR =
INT2FIX(GPGME_ATTR_FPR)
GPGME_ATTR_ALGO =
INT2FIX(GPGME_ATTR_ALGO)
GPGME_ATTR_LEN =
INT2FIX(GPGME_ATTR_LEN)
GPGME_ATTR_CREATED =
INT2FIX(GPGME_ATTR_CREATED)
GPGME_ATTR_EXPIRE =
INT2FIX(GPGME_ATTR_EXPIRE)
GPGME_ATTR_OTRUST =
INT2FIX(GPGME_ATTR_OTRUST)
GPGME_ATTR_USERID =
INT2FIX(GPGME_ATTR_USERID)
GPGME_ATTR_NAME =
INT2FIX(GPGME_ATTR_NAME)
GPGME_ATTR_EMAIL =
INT2FIX(GPGME_ATTR_EMAIL)
GPGME_ATTR_COMMENT =
INT2FIX(GPGME_ATTR_COMMENT)
GPGME_ATTR_VALIDITY =
INT2FIX(GPGME_ATTR_VALIDITY)
GPGME_ATTR_LEVEL =
INT2FIX(GPGME_ATTR_LEVEL)
GPGME_ATTR_TYPE =
INT2FIX(GPGME_ATTR_TYPE)
GPGME_ATTR_IS_SECRET =
INT2FIX(GPGME_ATTR_IS_SECRET)
GPGME_ATTR_KEY_REVOKED =
INT2FIX(GPGME_ATTR_KEY_REVOKED)
GPGME_ATTR_KEY_INVALID =
INT2FIX(GPGME_ATTR_KEY_INVALID)
GPGME_ATTR_UID_REVOKED =
INT2FIX(GPGME_ATTR_UID_REVOKED)
GPGME_ATTR_UID_INVALID =
INT2FIX(GPGME_ATTR_UID_INVALID)
GPGME_ATTR_KEY_CAPS =
INT2FIX(GPGME_ATTR_KEY_CAPS)
GPGME_ATTR_CAN_ENCRYPT =
INT2FIX(GPGME_ATTR_CAN_ENCRYPT)
GPGME_ATTR_CAN_SIGN =
INT2FIX(GPGME_ATTR_CAN_SIGN)
GPGME_ATTR_CAN_CERTIFY =
INT2FIX(GPGME_ATTR_CAN_CERTIFY)
GPGME_ATTR_KEY_EXPIRED =
INT2FIX(GPGME_ATTR_KEY_EXPIRED)
GPGME_ATTR_KEY_DISABLED =
INT2FIX(GPGME_ATTR_KEY_DISABLED)
GPGME_ATTR_SERIAL =
INT2FIX(GPGME_ATTR_SERIAL)
GPGME_ATTR_ISSUER =
INT2FIX(GPGME_ATTR_ISSUER)
GPGME_ATTR_CHAINID =
INT2FIX(GPGME_ATTR_CHAINID)
GPGME_ATTR_SIG_STATUS =
INT2FIX(GPGME_ATTR_SIG_STATUS)
GPGME_ATTR_ERRTOK =
INT2FIX(GPGME_ATTR_ERRTOK)
GPGME_ATTR_SIG_SUMMARY =
INT2FIX(GPGME_ATTR_SIG_SUMMARY)
GPGME_VALIDITY_UNKNOWN =

gpgme_validity_t

INT2FIX(GPGME_VALIDITY_UNKNOWN)
GPGME_VALIDITY_UNDEFINED =
INT2FIX(GPGME_VALIDITY_UNDEFINED)
GPGME_VALIDITY_NEVER =
INT2FIX(GPGME_VALIDITY_NEVER)
GPGME_VALIDITY_MARGINAL =
INT2FIX(GPGME_VALIDITY_MARGINAL)
GPGME_VALIDITY_FULL =
INT2FIX(GPGME_VALIDITY_FULL)
GPGME_VALIDITY_ULTIMATE =
INT2FIX(GPGME_VALIDITY_ULTIMATE)
GPGME_PROTOCOL_OpenPGP =

gpgme_protocol_t

INT2FIX(GPGME_PROTOCOL_OpenPGP)
GPGME_PROTOCOL_CMS =
INT2FIX(GPGME_PROTOCOL_CMS)
GPGME_PROTOCOL_ASSUAN =

gpgme_status_code_t

INT2FIX(GPGME_PROTOCOL_ASSUAN))
#endif

  /* gpgme_status_code_t */
  rb_define_const (mGPGME, "GPGME_STATUS_EOF",
INT2FIX(GPGME_STATUS_EOF)
GPGME_STATUS_ENTER =

mkstatus starts here

INT2FIX(GPGME_STATUS_ENTER)
GPGME_STATUS_LEAVE =
INT2FIX(GPGME_STATUS_LEAVE)
GPGME_STATUS_ABORT =
INT2FIX(GPGME_STATUS_ABORT)
GPGME_STATUS_GOODSIG =
INT2FIX(GPGME_STATUS_GOODSIG)
GPGME_STATUS_BADSIG =
INT2FIX(GPGME_STATUS_BADSIG)
GPGME_STATUS_ERRSIG =
INT2FIX(GPGME_STATUS_ERRSIG)
GPGME_STATUS_BADARMOR =
INT2FIX(GPGME_STATUS_BADARMOR)
GPGME_STATUS_RSA_OR_IDEA =
INT2FIX(GPGME_STATUS_RSA_OR_IDEA)
GPGME_STATUS_KEYEXPIRED =
INT2FIX(GPGME_STATUS_KEYEXPIRED)
GPGME_STATUS_KEYREVOKED =
INT2FIX(GPGME_STATUS_KEYREVOKED)
GPGME_STATUS_TRUST_UNDEFINED =
INT2FIX(GPGME_STATUS_TRUST_UNDEFINED)
GPGME_STATUS_TRUST_NEVER =
INT2FIX(GPGME_STATUS_TRUST_NEVER)
GPGME_STATUS_TRUST_MARGINAL =
INT2FIX(GPGME_STATUS_TRUST_MARGINAL)
GPGME_STATUS_TRUST_FULLY =
INT2FIX(GPGME_STATUS_TRUST_FULLY)
GPGME_STATUS_TRUST_ULTIMATE =
INT2FIX(GPGME_STATUS_TRUST_ULTIMATE)
GPGME_STATUS_SHM_INFO =
INT2FIX(GPGME_STATUS_SHM_INFO)
GPGME_STATUS_SHM_GET =
INT2FIX(GPGME_STATUS_SHM_GET)
GPGME_STATUS_SHM_GET_BOOL =
INT2FIX(GPGME_STATUS_SHM_GET_BOOL)
GPGME_STATUS_SHM_GET_HIDDEN =
INT2FIX(GPGME_STATUS_SHM_GET_HIDDEN)
GPGME_STATUS_NEED_PASSPHRASE =
INT2FIX(GPGME_STATUS_NEED_PASSPHRASE)
GPGME_STATUS_VALIDSIG =
INT2FIX(GPGME_STATUS_VALIDSIG)
GPGME_STATUS_SIG_ID =
INT2FIX(GPGME_STATUS_SIG_ID)
GPGME_STATUS_ENC_TO =
INT2FIX(GPGME_STATUS_ENC_TO)
GPGME_STATUS_NODATA =
INT2FIX(GPGME_STATUS_NODATA)
GPGME_STATUS_BAD_PASSPHRASE =
INT2FIX(GPGME_STATUS_BAD_PASSPHRASE)
GPGME_STATUS_NO_PUBKEY =
INT2FIX(GPGME_STATUS_NO_PUBKEY)
GPGME_STATUS_NO_SECKEY =
INT2FIX(GPGME_STATUS_NO_SECKEY)
GPGME_STATUS_NEED_PASSPHRASE_SYM =
INT2FIX(GPGME_STATUS_NEED_PASSPHRASE_SYM)
GPGME_STATUS_DECRYPTION_FAILED =
INT2FIX(GPGME_STATUS_DECRYPTION_FAILED)
GPGME_STATUS_DECRYPTION_OKAY =
INT2FIX(GPGME_STATUS_DECRYPTION_OKAY)
GPGME_STATUS_MISSING_PASSPHRASE =
INT2FIX(GPGME_STATUS_MISSING_PASSPHRASE)
GPGME_STATUS_GOOD_PASSPHRASE =
INT2FIX(GPGME_STATUS_GOOD_PASSPHRASE)
GPGME_STATUS_GOODMDC =
INT2FIX(GPGME_STATUS_GOODMDC)
GPGME_STATUS_BADMDC =
INT2FIX(GPGME_STATUS_BADMDC)
GPGME_STATUS_ERRMDC =
INT2FIX(GPGME_STATUS_ERRMDC)
GPGME_STATUS_IMPORTED =
INT2FIX(GPGME_STATUS_IMPORTED)
GPGME_STATUS_IMPORT_RES =
INT2FIX(GPGME_STATUS_IMPORT_RES)
GPGME_STATUS_FILE_START =
INT2FIX(GPGME_STATUS_FILE_START)
GPGME_STATUS_FILE_DONE =
INT2FIX(GPGME_STATUS_FILE_DONE)
GPGME_STATUS_FILE_ERROR =
INT2FIX(GPGME_STATUS_FILE_ERROR)
GPGME_STATUS_BEGIN_DECRYPTION =
INT2FIX(GPGME_STATUS_BEGIN_DECRYPTION)
GPGME_STATUS_END_DECRYPTION =
INT2FIX(GPGME_STATUS_END_DECRYPTION)
GPGME_STATUS_BEGIN_ENCRYPTION =
INT2FIX(GPGME_STATUS_BEGIN_ENCRYPTION)
GPGME_STATUS_END_ENCRYPTION =
INT2FIX(GPGME_STATUS_END_ENCRYPTION)
GPGME_STATUS_DELETE_PROBLEM =
INT2FIX(GPGME_STATUS_DELETE_PROBLEM)
GPGME_STATUS_GET_BOOL =
INT2FIX(GPGME_STATUS_GET_BOOL)
GPGME_STATUS_GET_LINE =
INT2FIX(GPGME_STATUS_GET_LINE)
GPGME_STATUS_GET_HIDDEN =
INT2FIX(GPGME_STATUS_GET_HIDDEN)
GPGME_STATUS_GOT_IT =
INT2FIX(GPGME_STATUS_GOT_IT)
GPGME_STATUS_PROGRESS =
INT2FIX(GPGME_STATUS_PROGRESS)
GPGME_STATUS_SIG_CREATED =
INT2FIX(GPGME_STATUS_SIG_CREATED)
GPGME_STATUS_SESSION_KEY =
INT2FIX(GPGME_STATUS_SESSION_KEY)
GPGME_STATUS_NOTATION_NAME =
INT2FIX(GPGME_STATUS_NOTATION_NAME)
GPGME_STATUS_NOTATION_DATA =
INT2FIX(GPGME_STATUS_NOTATION_DATA)
GPGME_STATUS_POLICY_URL =
INT2FIX(GPGME_STATUS_POLICY_URL)
GPGME_STATUS_BEGIN_STREAM =
INT2FIX(GPGME_STATUS_BEGIN_STREAM)
GPGME_STATUS_END_STREAM =
INT2FIX(GPGME_STATUS_END_STREAM)
GPGME_STATUS_KEY_CREATED =
INT2FIX(GPGME_STATUS_KEY_CREATED)
GPGME_STATUS_USERID_HINT =
INT2FIX(GPGME_STATUS_USERID_HINT)
GPGME_STATUS_UNEXPECTED =
INT2FIX(GPGME_STATUS_UNEXPECTED)
GPGME_STATUS_INV_RECP =
INT2FIX(GPGME_STATUS_INV_RECP)
GPGME_STATUS_NO_RECP =
INT2FIX(GPGME_STATUS_NO_RECP)
GPGME_STATUS_ALREADY_SIGNED =
INT2FIX(GPGME_STATUS_ALREADY_SIGNED)
GPGME_STATUS_SIGEXPIRED =
INT2FIX(GPGME_STATUS_SIGEXPIRED)
GPGME_STATUS_EXPSIG =
INT2FIX(GPGME_STATUS_EXPSIG)
GPGME_STATUS_EXPKEYSIG =
INT2FIX(GPGME_STATUS_EXPKEYSIG)
GPGME_STATUS_TRUNCATED =
INT2FIX(GPGME_STATUS_TRUNCATED)
GPGME_STATUS_ERROR =
INT2FIX(GPGME_STATUS_ERROR)
GPGME_STATUS_PKA_TRUST_BAD =
INT2FIX(GPGME_STATUS_PKA_TRUST_BAD)
GPGME_STATUS_PKA_TRUST_GOOD =
INT2FIX(GPGME_STATUS_PKA_TRUST_GOOD)
GPGME_KEYLIST_MODE_LOCAL =

The available keylist mode flags.

INT2FIX(GPGME_KEYLIST_MODE_LOCAL)
GPGME_KEYLIST_MODE_EXTERN =
INT2FIX(GPGME_KEYLIST_MODE_EXTERN)
GPGME_KEYLIST_MODE_SIGS =
INT2FIX(GPGME_KEYLIST_MODE_SIGS)
GPGME_KEYLIST_MODE_SIG_NOTATIONS =
INT2FIX(GPGME_KEYLIST_MODE_SIG_NOTATIONS)
GPGME_KEYLIST_MODE_VALIDATE =
INT2FIX(GPGME_KEYLIST_MODE_VALIDATE)
GPGME_KEYLIST_MODE_EPHEMERAL =
INT2FIX(GPGME_KEYLIST_MODE_EPHEMERAL)
GPGME_IMPORT_NEW =

The available flags for status field of gpgme_import_status_t.

INT2FIX(GPGME_IMPORT_NEW)
GPGME_IMPORT_UID =
INT2FIX(GPGME_IMPORT_UID)
GPGME_IMPORT_SIG =
INT2FIX(GPGME_IMPORT_SIG)
GPGME_IMPORT_SUBKEY =
INT2FIX(GPGME_IMPORT_SUBKEY)
GPGME_IMPORT_SECRET =
INT2FIX(GPGME_IMPORT_SECRET)
GPGME_ENCRYPT_ALWAYS_TRUST =

The available flags for gpgme_op_encrypt.

INT2FIX(GPGME_ENCRYPT_ALWAYS_TRUST)
GPGME_ENCRYPT_NO_ENCRYPT_TO =
INT2FIX(GPGME_ENCRYPT_NO_ENCRYPT_TO)
GPGME_PINENTRY_MODE_DEFAULT =
INT2FIX(GPGME_PINENTRY_MODE_DEFAULT)
GPGME_PINENTRY_MODE_ASK =
INT2FIX(GPGME_PINENTRY_MODE_ASK)
GPGME_PINENTRY_MODE_CANCEL =
INT2FIX(GPGME_PINENTRY_MODE_CANCEL)
GPGME_PINENTRY_MODE_ERROR =
INT2FIX(GPGME_PINENTRY_MODE_ERROR)
GPGME_PINENTRY_MODE_LOOPBACK =
INT2FIX(GPGME_PINENTRY_MODE_LOOPBACK)

Class Method Summary (collapse)

Class Method Details

+ (Object) check_version(options = nil)

TODO find out what it does, can't seem to find a proper parameter that returns something other than nil.



95
96
97
98
99
100
101
102
103
104
105
# File 'lib/gpgme.rb', line 95

def check_version(options = nil)
  version = nil
  if options.kind_of?(String)
    version = options
  elsif options.include?(:version)
    version = options[:version]
  end
  unless GPGME::gpgme_check_version(version)
    raise Error::InvalidVersion.new
  end
end

+ (Object) error_to_exception(err)

Auxiliary method used by all the library to generate exceptions from error codes returned by the C extension.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/gpgme.rb', line 33

def error_to_exception(err)
  case GPGME::gpgme_err_code(err)
  when GPG_ERR_EOF
    EOFError.new
  when GPG_ERR_NO_ERROR
    nil
  when GPG_ERR_GENERAL
    Error::General.new(err)
  when GPG_ERR_ENOMEM
    Errno::ENOMEM.new
  when GPG_ERR_INV_VALUE
    Error::InvalidValue.new(err)
  when GPG_ERR_UNUSABLE_PUBKEY
    Error::UnusablePublicKey.new(err)
  when GPG_ERR_UNUSABLE_SECKEY
    Error::UnusableSecretKey.new(err)
  when GPG_ERR_NO_DATA
    Error::NoData.new(err)
  when GPG_ERR_CONFLICT
    Error::Conflict.new(err)
  when GPG_ERR_NOT_IMPLEMENTED
    Error::NotImplemented.new(err)
  when GPG_ERR_DECRYPT_FAILED
    Error::DecryptFailed.new(err)
  when GPG_ERR_BAD_PASSPHRASE
    Error::BadPassphrase.new(err)
  when GPG_ERR_CANCELED
    Error::Canceled.new(err)
  when GPG_ERR_INV_ENGINE
    Error::InvalidEngine.new(err)
  when GPG_ERR_AMBIGUOUS_NAME
    Error::AmbiguousName.new(err)
  when GPG_ERR_WRONG_KEY_USAGE
    Error::WrongKeyUsage.new(err)
  when GPG_ERR_CERT_REVOKED
    Error::CertificateRevoked.new(err)
  when GPG_ERR_CERT_EXPIRED
    Error::CertificateExpired.new(err)
  when GPG_ERR_NO_CRL_KNOWN
    Error::NoCRLKnown.new(err)
  when GPG_ERR_NO_POLICY_MATCH
    Error::NoPolicyMatch.new(err)
  when GPG_ERR_NO_SECKEY
    Error::NoSecretKey.new(err)
  when GPG_ERR_MISSING_CERT
    Error::MissingCertificate.new(err)
  when GPG_ERR_BAD_CERT_CHAIN
    Error::BadCertificateChain.new(err)
  when GPG_ERR_UNSUPPORTED_ALGORITHM
    Error::UnsupportedAlgorithm.new(err)
  when GPG_ERR_BAD_SIGNATURE
    Error::BadSignature.new(err)
  when GPG_ERR_NO_PUBKEY
    Error::NoPublicKey.new(err)
  else
    Error.new(err)
  end
end

+ (Object) gpgme_check_version



131
132
133
134
135
136
137
# File 'ext/gpgme/gpgme_n.c', line 131

static VALUE
rb_s_gpgme_check_version (VALUE dummy, VALUE vreq)
{
  const char *result = gpgme_check_version (NIL_P(vreq) ? NULL :
					    StringValueCStr(vreq));
  return result ? rb_str_new2 (result) : Qnil;
}

+ (Object) gpgme_data_get_encoding



389
390
391
392
393
394
395
396
397
398
# File 'ext/gpgme/gpgme_n.c', line 389

static VALUE
rb_s_gpgme_data_get_encoding (VALUE dummy, VALUE vdh)
{
  gpgme_data_t dh;
  gpgme_error_t err;

  UNWRAP_GPGME_DATA(vdh, dh);
  err = gpgme_data_get_encoding (dh);
  return LONG2NUM(err);
}

+ (Object) gpgme_data_new

Creating Data Buffers

gpgme_data_new_from_filepart is not currently supported.



222
223
224
225
226
227
228
229
230
231
# File 'ext/gpgme/gpgme_n.c', line 222

static VALUE
rb_s_gpgme_data_new (VALUE dummy, VALUE rdh)
{
  gpgme_data_t dh;
  gpgme_error_t err = gpgme_data_new (&dh);

  if (gpgme_err_code(err) == GPG_ERR_NO_ERROR)
    rb_ary_store (rdh, 0, WRAP_GPGME_DATA(dh));
  return LONG2NUM(err);
}

+ (Object) gpgme_data_new_from_cbs



321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
# File 'ext/gpgme/gpgme_n.c', line 321

static VALUE
rb_s_gpgme_data_new_from_cbs (VALUE dummy, VALUE rdh, VALUE vcbs,
			      VALUE vhandle)
{
  gpgme_data_t dh;
  gpgme_error_t err;
  VALUE vcbs_handle = rb_ary_new ();

  rb_ary_push (vcbs_handle, vcbs);
  rb_ary_push (vcbs_handle, vhandle);

  err = gpgme_data_new_from_cbs (&dh, &cbs, (void*)vcbs_handle);
  if (gpgme_err_code(err) == GPG_ERR_NO_ERROR)
    {
      VALUE vdh = WRAP_GPGME_DATA(dh);
      /* Keep a reference to avoid GC. */
      rb_iv_set (vdh, "@cbs_handle", vcbs_handle);
      rb_ary_store (rdh, 0, vdh);
    }
  return LONG2NUM(err);
}

+ (Object) gpgme_data_new_from_fd



254
255
256
257
258
259
260
261
262
# File 'ext/gpgme/gpgme_n.c', line 254

static VALUE
rb_s_gpgme_data_new_from_fd (VALUE dummy, VALUE rdh, VALUE vfd)
{
  gpgme_data_t dh;
  gpgme_error_t err = gpgme_data_new_from_fd (&dh, NUM2INT(vfd));
  if (gpgme_err_code(err) == GPG_ERR_NO_ERROR)
    rb_ary_store (rdh, 0, WRAP_GPGME_DATA(dh));
  return LONG2NUM(err);
}

+ (Object) gpgme_data_new_from_mem



233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# File 'ext/gpgme/gpgme_n.c', line 233

static VALUE
rb_s_gpgme_data_new_from_mem (VALUE dummy, VALUE rdh, VALUE vbuffer,
			      VALUE vsize)
{
  gpgme_data_t dh;
  VALUE vdh;
  size_t size = NUM2UINT(vsize);
  gpgme_error_t err;

  if (RSTRING_LEN(vbuffer) < size)
    rb_raise (rb_eArgError, "argument out of range");

  err = gpgme_data_new_from_mem (&dh, StringValuePtr(vbuffer), size, 1);
  if (gpgme_err_code(err) == GPG_ERR_NO_ERROR)
    {
      vdh = WRAP_GPGME_DATA(dh);
      rb_ary_store (rdh, 0, vdh);
    }
  return LONG2NUM(err);
}

+ (Object) gpgme_data_read

Manipulating Data Buffers



343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
# File 'ext/gpgme/gpgme_n.c', line 343

static VALUE
rb_s_gpgme_data_read (VALUE dummy, VALUE vdh, VALUE vlength)
{
  gpgme_data_t dh;
  ssize_t length = NUM2LONG(vlength), nread;
  void *buffer;
  VALUE vbuffer = Qnil;

  UNWRAP_GPGME_DATA(vdh, dh);

  buffer = ALLOC_N (char, length);
  nread = gpgme_data_read (dh, buffer, length);
  if (nread > 0)
    vbuffer = rb_str_new (buffer, nread);
  xfree (buffer);
  if (nread < 0)
    rb_sys_fail ("rb_s_gpgme_data_read");
  return vbuffer;
}

+ (Object) gpgme_data_rewind(dh)



31
32
33
34
35
36
37
# File 'lib/gpgme/compat.rb', line 31

def gpgme_data_rewind(dh)
  begin
    GPGME::gpgme_data_seek(dh, 0, IO::SEEK_SET)
  rescue SystemCallError => e
    return e.errno
  end
end

+ (Object) gpgme_data_seek



363
364
365
366
367
368
369
370
371
372
373
374
# File 'ext/gpgme/gpgme_n.c', line 363

static VALUE
rb_s_gpgme_data_seek (VALUE dummy, VALUE vdh, VALUE voffset, VALUE vwhence)
{
  gpgme_data_t dh;
  off_t pos;

  UNWRAP_GPGME_DATA(vdh, dh);
  pos = gpgme_data_seek (dh, NUM2LONG(voffset), NUM2INT(vwhence));
  if (pos < 0)
    rb_sys_fail ("rb_s_gpgme_data_seek");
  return LONG2NUM(pos);
}

+ (Object) gpgme_data_set_encoding



400
401
402
403
404
405
406
407
408
409
# File 'ext/gpgme/gpgme_n.c', line 400

static VALUE
rb_s_gpgme_data_set_encoding (VALUE dummy, VALUE vdh, VALUE venc)
{
  gpgme_data_t dh;
  gpgme_error_t err;

  UNWRAP_GPGME_DATA(vdh, dh);
  err = gpgme_data_set_encoding (dh, NUM2INT(venc));
  return LONG2NUM(err);
}

+ (Object) gpgme_data_write



376
377
378
379
380
381
382
383
384
385
386
387
# File 'ext/gpgme/gpgme_n.c', line 376

static VALUE
rb_s_gpgme_data_write (VALUE dummy, VALUE vdh, VALUE vbuf, VALUE vlen)
{
  gpgme_data_t dh;
  ssize_t nwrite;

  UNWRAP_GPGME_DATA(vdh, dh);
  nwrite = gpgme_data_write (dh, StringValuePtr(vbuf), NUM2UINT(vlen));
  if (nwrite < 0)
    rb_sys_fail ("rb_s_gpgme_data_write");
  return LONG2NUM(nwrite);
}

+ (Object) gpgme_engine_check_version



139
140
141
142
143
144
# File 'ext/gpgme/gpgme_n.c', line 139

static VALUE
rb_s_gpgme_engine_check_version (VALUE dummy, VALUE vproto)
{
  gpgme_error_t err = gpgme_engine_check_version (NUM2INT(vproto));
  return LONG2NUM(err);
}

+ (Object) gpgme_err_code



204
205
206
207
208
# File 'ext/gpgme/gpgme_n.c', line 204

static VALUE
rb_s_gpgme_err_code (VALUE dummy, VALUE verr)
{
  return INT2FIX(gpgme_err_code (NUM2LONG(verr)));
}

+ (Object) gpgme_err_source



210
211
212
213
214
# File 'ext/gpgme/gpgme_n.c', line 210

static VALUE
rb_s_gpgme_err_source (VALUE dummy, VALUE verr)
{
  return INT2FIX(gpgme_err_source (NUM2LONG(verr)));
}

+ (Object) gpgme_get_armor



474
475
476
477
478
479
480
481
482
483
484
485
# File 'ext/gpgme/gpgme_n.c', line 474

static VALUE
rb_s_gpgme_get_armor (VALUE dummy, VALUE vctx)
{
  gpgme_ctx_t ctx;
  int yes;

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  yes = gpgme_get_armor (ctx);
  return INT2FIX(yes);
}

+ (Object) gpgme_get_engine_info



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'ext/gpgme/gpgme_n.c', line 146

static VALUE
rb_s_gpgme_get_engine_info (VALUE dummy, VALUE rinfo)
{
  gpgme_engine_info_t info;
  gpgme_error_t err;
  long idx;

  err = gpgme_get_engine_info (&info);
  if (gpgme_err_code(err) == GPG_ERR_NO_ERROR)
    {
      for (idx = 0; info; info = info->next, idx++)
	{
	  VALUE vinfo = rb_class_new_instance (0, NULL, cEngineInfo);
	  rb_iv_set (vinfo, "@protocol", INT2FIX(info->protocol));
	  if (info->file_name)
	    rb_iv_set (vinfo, "@file_name", rb_str_new2 (info->file_name));
	  if (info->version)
	    rb_iv_set (vinfo, "@version", rb_str_new2 (info->version));
	  if (info->req_version)
	    rb_iv_set (vinfo, "@req_version", rb_str_new2 (info->req_version));
	  if (info->home_dir)
	    rb_iv_set (vinfo, "@home_dir", rb_str_new2 (info->home_dir));
	  rb_ary_store (rinfo, idx, vinfo);
	}
    }
  return LONG2NUM(err);
}

+ (Object) gpgme_get_include_certs



524
525
526
527
528
529
530
531
532
533
534
535
# File 'ext/gpgme/gpgme_n.c', line 524

static VALUE
rb_s_gpgme_get_include_certs (VALUE dummy, VALUE vctx)
{
  gpgme_ctx_t ctx;
  gpgme_error_t err;

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  err = gpgme_get_include_certs (ctx);
  return LONG2NUM(err);
}

+ (Object) gpgme_get_key



874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
# File 'ext/gpgme/gpgme_n.c', line 874

static VALUE
rb_s_gpgme_get_key (VALUE dummy, VALUE vctx, VALUE vfpr, VALUE rkey,
		    VALUE vsecret)
{
  gpgme_ctx_t ctx;
  gpgme_error_t err;
  gpgme_key_t key;

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  err = gpgme_get_key (ctx, StringValueCStr(vfpr), &key, NUM2INT(vsecret));

  if (gpgme_err_code(err) == GPG_ERR_NO_ERROR)
    {
      VALUE vkey = WRAP_GPGME_KEY(key);
      save_gpgme_key_attrs (vkey, key);
      rb_ary_store (rkey, 0, vkey);
    }
  return LONG2NUM(err);
}

+ (Object) gpgme_get_keylist_mode



550
551
552
553
554
555
556
557
558
559
560
561
# File 'ext/gpgme/gpgme_n.c', line 550

static VALUE
rb_s_gpgme_get_keylist_mode (VALUE dummy, VALUE vctx)
{
  gpgme_ctx_t ctx;
  int mode;

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  mode = gpgme_get_keylist_mode (ctx);
  return INT2FIX(mode);
}

+ (Object) gpgme_get_passphrase_cb



600
601
602
603
604
605
606
607
608
609
610
# File 'ext/gpgme/gpgme_n.c', line 600

static VALUE
rb_s_gpgme_get_passphrase_cb (VALUE dummy, VALUE vctx, VALUE rpassfunc,
			      VALUE rhook_value)
{
  VALUE vcb = rb_iv_get (vctx, "@passphrase_cb");

  /* No need to call gpgme_get_passphrase_cb. */
  rb_ary_store (rpassfunc, 0, RARRAY_PTR(vcb)[0]);
  rb_ary_store (rhook_value, 0, RARRAY_PTR(vcb)[1]);
  return Qnil;
}

+ (Object) gpgme_get_pinentry_mode



684
685
686
687
688
689
690
691
692
693
694
695
696
# File 'ext/gpgme/gpgme_n.c', line 684

static VALUE
rb_s_gpgme_get_pinentry_mode (VALUE dummy, VALUE vctx)
{
  gpgme_ctx_t ctx;
  gpgme_pinentry_mode_t mode;
  
  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");

  mode = gpgme_get_pinentry_mode (ctx);
  return INT2FIX(mode);
}

+ (Object) gpgme_get_progress_cb



645
646
647
648
649
650
651
652
653
# File 'ext/gpgme/gpgme_n.c', line 645

static VALUE
rb_s_gpgme_get_progress_cb (VALUE dummy, VALUE vctx, VALUE rprogfunc,
			    VALUE rhook_value)
{
  VALUE vcb = rb_iv_get (vctx, "@progress_cb");
  rb_ary_store (rprogfunc, 0, RARRAY_PTR(vcb)[0]);
  rb_ary_store (rhook_value, 0, RARRAY_PTR(vcb)[1]);
  return Qnil;
}

+ (Object) gpgme_get_protocol



448
449
450
451
452
453
454
455
456
457
458
459
# File 'ext/gpgme/gpgme_n.c', line 448

static VALUE
rb_s_gpgme_get_protocol (VALUE dummy, VALUE vctx)
{
  gpgme_ctx_t ctx;
  gpgme_protocol_t proto;

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  proto = gpgme_get_protocol (ctx);
  return INT2FIX(proto);
}

+ (Object) gpgme_get_textmode



499
500
501
502
503
504
505
506
507
508
509
510
# File 'ext/gpgme/gpgme_n.c', line 499

static VALUE
rb_s_gpgme_get_textmode (VALUE dummy, VALUE vctx)
{
  gpgme_ctx_t ctx;
  int yes;

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  yes = gpgme_get_textmode (ctx);
  return INT2FIX(yes);
}

+ (Object) gpgme_hash_algo_name Also known as: hash_algo_name



195
196
197
198
199
200
201
202
# File 'ext/gpgme/gpgme_n.c', line 195

static VALUE
rb_s_gpgme_hash_algo_name (VALUE dummy, VALUE valgo)
{
  const char *name = gpgme_hash_algo_name (NUM2INT(valgo));
  if (name)
    return rb_str_new2 (name);
  return Qnil;
}

+ (Object) gpgme_new

Creating Contexts



411
412
413
414
415
416
417
418
419
420
# File 'ext/gpgme/gpgme_n.c', line 411

static VALUE
rb_s_gpgme_new (VALUE dummy, VALUE rctx)
{
  gpgme_ctx_t ctx;
  gpgme_error_t err = gpgme_new (&ctx);

  if (gpgme_err_code(err) == GPG_ERR_NO_ERROR)
    rb_ary_store (rctx, 0, WRAP_GPGME_CTX(ctx));
  return LONG2NUM(err);
}

+ (Object) gpgme_op_card_edit



1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
# File 'ext/gpgme/gpgme_n.c', line 1317

static VALUE
rb_s_gpgme_op_card_edit (VALUE dummy, VALUE vctx, VALUE vkey,
		    VALUE veditfunc, VALUE vhook_value, VALUE vout)
{
  gpgme_ctx_t ctx;
  gpgme_key_t key;
  gpgme_data_t out = NULL;
  VALUE vcb;
  gpgme_error_t err;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  UNWRAP_GPGME_KEY(vkey, key);
  if (!NIL_P(vout))
    UNWRAP_GPGME_DATA(vout, out);

  vcb = rb_ary_new ();
  rb_ary_push (vcb, veditfunc);
  rb_ary_push (vcb, vhook_value);
  /* Keep a reference to avoid GC. */
  rb_iv_set (vctx, "@card_edit_cb", vcb);

  err = gpgme_op_card_edit (ctx, key, edit_cb, (void *)vcb, out);
  return LONG2NUM(err);
}

+ (Object) gpgme_op_card_edit_start



1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
# File 'ext/gpgme/gpgme_n.c', line 1346

static VALUE
rb_s_gpgme_op_card_edit_start (VALUE dummy, VALUE vctx, VALUE vkey,
			       VALUE veditfunc, VALUE vhook_value, VALUE vout)
{
  gpgme_ctx_t ctx;
  gpgme_key_t key;
  gpgme_data_t out = NULL;
  VALUE vcb;
  gpgme_error_t err;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  UNWRAP_GPGME_KEY(vkey, key);
  if (!NIL_P(vout))
    UNWRAP_GPGME_DATA(vout, out);

  vcb = rb_ary_new ();
  rb_ary_push (vcb, veditfunc);
  rb_ary_push (vcb, vhook_value);
  /* Keep a reference to avoid GC. */
  rb_iv_set (vctx, "@card_edit_cb", vcb);

  err = gpgme_op_card_edit_start (ctx, key, edit_cb, (void *)vcb, out);
  return LONG2NUM(err);
}

+ (Object) gpgme_op_decrypt

Decrypt



1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
# File 'ext/gpgme/gpgme_n.c', line 1439

static VALUE
rb_s_gpgme_op_decrypt (VALUE dummy, VALUE vctx, VALUE vcipher, VALUE vplain)
{
  gpgme_ctx_t ctx;
  gpgme_data_t cipher, plain;
  gpgme_error_t err;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  UNWRAP_GPGME_DATA(vcipher, cipher);
  UNWRAP_GPGME_DATA(vplain, plain);

  err = gpgme_op_decrypt (ctx, cipher, plain);
  return LONG2NUM(err);
}

+ (Object) gpgme_op_decrypt_result



1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
# File 'ext/gpgme/gpgme_n.c', line 1478

static VALUE
rb_s_gpgme_op_decrypt_result (VALUE dummy, VALUE vctx)
{
  gpgme_ctx_t ctx;
  gpgme_decrypt_result_t result;
  VALUE vresult;

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");

  result = gpgme_op_decrypt_result (ctx);
  vresult = rb_class_new_instance (0, NULL, cDecryptResult);
  if (result->unsupported_algorithm)
    rb_iv_set (vresult, "@unsupported_algorithm",
	       rb_str_new2 (result->unsupported_algorithm));
  rb_iv_set (vresult, "@wrong_key_usage", INT2FIX(result->wrong_key_usage));
  return vresult;
}

+ (Object) gpgme_op_decrypt_start



1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
# File 'ext/gpgme/gpgme_n.c', line 1458

static VALUE
rb_s_gpgme_op_decrypt_start (VALUE dummy, VALUE vctx, VALUE vcipher,
			     VALUE vplain)
{
  gpgme_ctx_t ctx;
  gpgme_data_t cipher, plain;
  gpgme_error_t err;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  UNWRAP_GPGME_DATA(vcipher, cipher);
  UNWRAP_GPGME_DATA(vplain, plain);

  err = gpgme_op_decrypt_start (ctx, cipher, plain);
  return LONG2NUM(err);
}

+ (Object) gpgme_op_decrypt_verify

Decrypt and Verify



1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
# File 'ext/gpgme/gpgme_n.c', line 1602

static VALUE
rb_s_gpgme_op_decrypt_verify (VALUE dummy, VALUE vctx, VALUE vcipher,
			      VALUE vplain)
{
  gpgme_ctx_t ctx;
  gpgme_data_t cipher, plain;
  gpgme_error_t err;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  UNWRAP_GPGME_DATA(vcipher, cipher);
  UNWRAP_GPGME_DATA(vplain, plain);

  err = gpgme_op_decrypt_verify (ctx, cipher, plain);
  return LONG2NUM(err);
}

+ (Object) gpgme_op_decrypt_verify_start



1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
# File 'ext/gpgme/gpgme_n.c', line 1622

static VALUE
rb_s_gpgme_op_decrypt_verify_start (VALUE dummy, VALUE vctx, VALUE vcipher,
				    VALUE vplain)
{
  gpgme_ctx_t ctx;
  gpgme_data_t cipher, plain;
  gpgme_error_t err;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  UNWRAP_GPGME_DATA(vcipher, cipher);
  UNWRAP_GPGME_DATA(vplain, plain);

  err = gpgme_op_decrypt_verify_start (ctx, cipher, plain);
  return LONG2NUM(err);
}

+ (Object) gpgme_op_delete



1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
# File 'ext/gpgme/gpgme_n.c', line 1208

static VALUE
rb_s_gpgme_op_delete (VALUE dummy, VALUE vctx, VALUE vkey, VALUE vallow_secret)
{
  gpgme_ctx_t ctx;
  gpgme_key_t key;
  gpgme_error_t err;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  UNWRAP_GPGME_KEY(vkey, key);

  err = gpgme_op_delete (ctx, key, NUM2INT(vallow_secret));
  return LONG2NUM(err);
}

+ (Object) gpgme_op_delete_start



1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
# File 'ext/gpgme/gpgme_n.c', line 1226

static VALUE
rb_s_gpgme_op_delete_start (VALUE dummy, VALUE vctx, VALUE vkey,
			    VALUE vallow_secret)
{
  gpgme_ctx_t ctx;
  gpgme_key_t key;
  gpgme_error_t err;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  UNWRAP_GPGME_KEY(vkey, key);

  err = gpgme_op_delete_start (ctx, key, NUM2INT(vallow_secret));
  return LONG2NUM(err);
}

+ (Object) gpgme_op_edit



1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
# File 'ext/gpgme/gpgme_n.c', line 1259

static VALUE
rb_s_gpgme_op_edit (VALUE dummy, VALUE vctx, VALUE vkey,
		    VALUE veditfunc, VALUE vhook_value, VALUE vout)
{
  gpgme_ctx_t ctx;
  gpgme_key_t key;
  gpgme_data_t out = NULL;
  VALUE vcb;
  gpgme_error_t err;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  UNWRAP_GPGME_KEY(vkey, key);
  if (!NIL_P(vout))
    UNWRAP_GPGME_DATA(vout, out);

  vcb = rb_ary_new ();
  rb_ary_push (vcb, veditfunc);
  rb_ary_push (vcb, vhook_value);
  /* Keep a reference to avoid GC. */
  rb_iv_set (vctx, "@edit_cb", vcb);

  err = gpgme_op_edit (ctx, key, edit_cb, (void *)vcb, out);
  return LONG2NUM(err);
}

+ (Object) gpgme_op_edit_start



1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
# File 'ext/gpgme/gpgme_n.c', line 1288

static VALUE
rb_s_gpgme_op_edit_start (VALUE dummy, VALUE vctx, VALUE vkey,
			  VALUE veditfunc, VALUE vhook_value, VALUE vout)
{
  gpgme_ctx_t ctx;
  gpgme_key_t key;
  gpgme_data_t out = NULL;
  VALUE vcb;
  gpgme_error_t err;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  UNWRAP_GPGME_KEY(vkey, key);
  if (!NIL_P(vout))
    UNWRAP_GPGME_DATA(vout, out);

  vcb = rb_ary_new ();
  rb_ary_push (vcb, veditfunc);
  rb_ary_push (vcb, vhook_value);
  /* Keep a reference to avoid GC. */
  rb_iv_set (vctx, "@edit_cb", vcb);

  err = gpgme_op_edit_start (ctx, key, edit_cb, (void *)vcb, out);
  return LONG2NUM(err);
}

+ (Object) gpgme_op_encrypt

Encrypt



1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
# File 'ext/gpgme/gpgme_n.c', line 1774

static VALUE
rb_s_gpgme_op_encrypt (VALUE dummy, VALUE vctx, VALUE vrecp, VALUE vflags,
		       VALUE vplain, VALUE vcipher)
{
  gpgme_ctx_t ctx;
  gpgme_key_t *recp = NULL;
  gpgme_data_t plain, cipher;
  gpgme_error_t err;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  /* If RECP is `NULL', symmetric rather than public key encryption is
     performed. */
  if (!NIL_P(vrecp))
    {
      int i;
      recp = ALLOC_N(gpgme_key_t, RARRAY_LEN(vrecp) + 1);
      for (i = 0; i < RARRAY_LEN(vrecp); i++)
	UNWRAP_GPGME_KEY(RARRAY_PTR(vrecp)[i], recp[i]);
      recp[i] = NULL;
    }
  UNWRAP_GPGME_DATA(vplain, plain);
  UNWRAP_GPGME_DATA(vcipher, cipher);

  err = gpgme_op_encrypt (ctx, recp, NUM2INT(vflags), plain, cipher);
  if (recp)
    xfree (recp);
  return LONG2NUM(err);
}

+ (Object) gpgme_op_encrypt_result



1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
# File 'ext/gpgme/gpgme_n.c', line 1840

static VALUE
rb_s_gpgme_op_encrypt_result (VALUE dummy, VALUE vctx)
{
  gpgme_ctx_t ctx;
  gpgme_encrypt_result_t result;
  gpgme_invalid_key_t invalid_key;
  VALUE vresult, vinvalid_recipients;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");

  result = gpgme_op_encrypt_result (ctx);
  vresult = rb_class_new_instance (0, NULL, cEncryptResult);
  vinvalid_recipients = rb_ary_new ();
  rb_iv_set (vresult, "@invalid_recipients", vinvalid_recipients);
  for (invalid_key = result->invalid_recipients; invalid_key;
       invalid_key = invalid_key->next)
    {
      VALUE vinvalid_key =
	rb_class_new_instance (0, NULL, cInvalidKey);
      rb_iv_set (vinvalid_key, "@fpr", rb_str_new2 (invalid_key->fpr));
      rb_iv_set (vinvalid_key, "@reason", LONG2NUM(invalid_key->reason));
      rb_ary_push (vinvalid_recipients, vinvalid_key);
    }
  return vresult;
}

+ (Object) gpgme_op_encrypt_sign



1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
# File 'ext/gpgme/gpgme_n.c', line 1870

static VALUE
rb_s_gpgme_op_encrypt_sign (VALUE dummy, VALUE vctx, VALUE vrecp, VALUE vflags,
			    VALUE vplain, VALUE vcipher)
{
  gpgme_ctx_t ctx;
  gpgme_key_t *recp = NULL;
  gpgme_data_t plain, cipher;
  gpgme_error_t err;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  /* If RECP is `NULL', symmetric rather than public key encryption is
     performed. */
  if (!NIL_P(vrecp))
    {
      int i;
      recp = ALLOC_N(gpgme_key_t, RARRAY_LEN(vrecp) + 1);
      for (i = 0; i < RARRAY_LEN(vrecp); i++)
	UNWRAP_GPGME_KEY(RARRAY_PTR(vrecp)[i], recp[i]);
      recp[i] = NULL;
    }
  UNWRAP_GPGME_DATA(vplain, plain);
  UNWRAP_GPGME_DATA(vcipher, cipher);

  err = gpgme_op_encrypt_sign (ctx, recp, NUM2INT(vflags), plain, cipher);
  if (recp)
    xfree (recp);
  return LONG2NUM(err);
}

+ (Object) gpgme_op_encrypt_sign_start



1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
# File 'ext/gpgme/gpgme_n.c', line 1903

static VALUE
rb_s_gpgme_op_encrypt_sign_start (VALUE dummy, VALUE vctx, VALUE vrecp,
				  VALUE vflags, VALUE vplain, VALUE vcipher)
{
  gpgme_ctx_t ctx;
  gpgme_key_t *recp = NULL;
  gpgme_data_t plain, cipher;
  gpgme_error_t err;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  /* If RECP is `NULL', symmetric rather than public key encryption is
     performed. */
  if (!NIL_P(vrecp))
    {
      int i;
      recp = ALLOC_N(gpgme_key_t, RARRAY_LEN(vrecp) + 1);
      for (i = 0; i < RARRAY_LEN(vrecp); i++)
	UNWRAP_GPGME_KEY(RARRAY_PTR(vrecp)[i], recp[i]);
      recp[i] = NULL;
    }
  UNWRAP_GPGME_DATA(vplain, plain);
  UNWRAP_GPGME_DATA(vcipher, cipher);

  err = gpgme_op_encrypt_sign_start (ctx, recp, NUM2INT(vflags), plain,
				     cipher);
  if (recp)
    xfree (recp);
  return LONG2NUM(err);
}

+ (Object) gpgme_op_encrypt_start



1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
# File 'ext/gpgme/gpgme_n.c', line 1807

static VALUE
rb_s_gpgme_op_encrypt_start (VALUE dummy, VALUE vctx, VALUE vrecp,
			     VALUE vflags, VALUE vplain, VALUE vcipher)
{
  gpgme_ctx_t ctx;
  gpgme_key_t *recp = NULL;
  gpgme_data_t plain, cipher;
  gpgme_error_t err;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  /* If RECP is `NULL', symmetric rather than public key encryption is
     performed. */
  if (!NIL_P(vrecp))
    {
      int i;
      recp = ALLOC_N(gpgme_key_t, RARRAY_LEN(vrecp) + 1);
      for (i = 0; i < RARRAY_LEN(vrecp); i++)
	UNWRAP_GPGME_KEY(RARRAY_PTR(vrecp)[i], recp[i]);
      recp[i] = NULL;
    }
  UNWRAP_GPGME_DATA(vplain, plain);
  UNWRAP_GPGME_DATA(vcipher, cipher);

  err = gpgme_op_encrypt_start (ctx, recp, NUM2INT(vflags), plain, cipher);
  if (recp)
    xfree (recp);
  return LONG2NUM(err);
}

+ (Object) gpgme_op_export



940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
# File 'ext/gpgme/gpgme_n.c', line 940

static VALUE
rb_s_gpgme_op_export (VALUE dummy, VALUE vctx, VALUE vpattern, VALUE vmode,
		      VALUE vkeydata)
{
  gpgme_ctx_t ctx;
  gpgme_data_t keydata;
  gpgme_error_t err;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  UNWRAP_GPGME_DATA(vkeydata, keydata);

  err = gpgme_op_export (ctx, StringValueCStr(vpattern), NUM2UINT(vmode),
			 keydata);
  return LONG2NUM(err);
}

+ (Object) gpgme_op_export_ext



980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
# File 'ext/gpgme/gpgme_n.c', line 980

static VALUE
rb_s_gpgme_op_export_ext (VALUE dummy, VALUE vctx, VALUE vpattern, VALUE vmode,
			  VALUE vkeydata)
{
  gpgme_ctx_t ctx;
  gpgme_data_t keydata;
  gpgme_error_t err;
  const char **pattern;
  int i;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  pattern = ALLOC_N(const char *, RARRAY_LEN(vpattern));
  for (i = 0; i < RARRAY_LEN(vpattern); i++)
    pattern[i] = StringValueCStr(RARRAY_PTR(vpattern)[i]);
  UNWRAP_GPGME_DATA(vkeydata, keydata);

  err = gpgme_op_export_ext (ctx, pattern, NUM2UINT(vmode), keydata);
  return LONG2NUM(err);
}

+ (Object) gpgme_op_export_ext_start



1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
# File 'ext/gpgme/gpgme_n.c', line 1004

static VALUE
rb_s_gpgme_op_export_ext_start (VALUE dummy, VALUE vctx, VALUE vpattern,
			    VALUE vmode, VALUE vkeydata)
{
  gpgme_ctx_t ctx;
  gpgme_data_t keydata;
  gpgme_error_t err;
  const char **pattern;
  int i;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  pattern = ALLOC_N(const char *, RARRAY_LEN(vpattern));
  for (i = 0; i < RARRAY_LEN(vpattern); i++)
    pattern[i] = StringValueCStr(RARRAY_PTR(vpattern)[i]);
  UNWRAP_GPGME_DATA(vkeydata, keydata);

  err = gpgme_op_export_ext_start (ctx, pattern, NUM2UINT(vmode), keydata);
  return LONG2NUM(err);
}

+ (Object) gpgme_op_export_keys



1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
# File 'ext/gpgme/gpgme_n.c', line 1029

static VALUE
rb_s_gpgme_op_export_keys (VALUE dummy, VALUE vctx, VALUE vkeys,
			   VALUE vmode, VALUE vkeydata)
{
  gpgme_ctx_t ctx;
  gpgme_key_t *keys;
  gpgme_data_t keydata;
  gpgme_error_t err;
  int i;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");

  keys = ALLOC_N(gpgme_key_t, RARRAY_LEN(vkeys) + 1);
  for (i = 0; i < RARRAY_LEN(vkeys); i++)
    UNWRAP_GPGME_KEY(RARRAY_PTR(vkeys)[i], keys[i]);

  UNWRAP_GPGME_DATA(vkeydata, keydata);

  err = gpgme_op_export_keys (ctx, keys, NUM2UINT(vmode), keydata);
  return LONG2NUM(err);
}

+ (Object) gpgme_op_export_keys_start



1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
# File 'ext/gpgme/gpgme_n.c', line 1055

static VALUE
rb_s_gpgme_op_export_keys_start (VALUE dummy, VALUE vctx, VALUE vkeys,
				 VALUE vmode, VALUE vkeydata)
{
  gpgme_ctx_t ctx;
  gpgme_key_t *keys;
  gpgme_data_t keydata;
  gpgme_error_t err;
  int i;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");

  keys = ALLOC_N(gpgme_key_t, RARRAY_LEN(vkeys) + 1);
  for (i = 0; i < RARRAY_LEN(vkeys); i++)
    UNWRAP_GPGME_KEY(RARRAY_PTR(vkeys)[i], keys[i]);

  UNWRAP_GPGME_DATA(vkeydata, keydata);

  err = gpgme_op_export_keys_start (ctx, keys, NUM2UINT(vmode), keydata);
  return LONG2NUM(err);
}

+ (Object) gpgme_op_export_start



960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
# File 'ext/gpgme/gpgme_n.c', line 960

static VALUE
rb_s_gpgme_op_export_start (VALUE dummy, VALUE vctx, VALUE vpattern,
			    VALUE vmode, VALUE vkeydata)
{
  gpgme_ctx_t ctx;
  gpgme_data_t keydata;
  gpgme_error_t err;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  UNWRAP_GPGME_DATA(vkeydata, keydata);

  err = gpgme_op_export_start (ctx, StringValueCStr(vpattern),
			       NUM2UINT(vmode), keydata);
  return LONG2NUM(err);
}

+ (Object) gpgme_op_genkey



896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
# File 'ext/gpgme/gpgme_n.c', line 896

static VALUE
rb_s_gpgme_op_genkey (VALUE dummy, VALUE vctx, VALUE vparms, VALUE vpubkey,
		      VALUE vseckey)
{
  gpgme_ctx_t ctx;
  gpgme_data_t pubkey = NULL, seckey = NULL;
  gpgme_error_t err;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  if (!NIL_P(vpubkey))
    UNWRAP_GPGME_DATA(vpubkey, pubkey);
  if (!NIL_P(vseckey))
    UNWRAP_GPGME_DATA(vseckey, seckey);

  err = gpgme_op_genkey (ctx, StringValueCStr(vparms), pubkey, seckey);
  return LONG2NUM(err);
}

+ (Object) gpgme_op_genkey_start



918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
# File 'ext/gpgme/gpgme_n.c', line 918

static VALUE
rb_s_gpgme_op_genkey_start (VALUE dummy, VALUE vctx, VALUE vparms,
			    VALUE vpubkey, VALUE vseckey)
{
  gpgme_ctx_t ctx;
  gpgme_data_t pubkey = NULL, seckey = NULL;
  gpgme_error_t err;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  if (!NIL_P(vpubkey))
    UNWRAP_GPGME_DATA(vpubkey, pubkey);
  if (!NIL_P(vseckey))
    UNWRAP_GPGME_DATA(vseckey, seckey);

  err = gpgme_op_genkey_start (ctx, StringValueCStr(vparms), pubkey, seckey);
  return LONG2NUM(err);
}

+ (Object) gpgme_op_import



1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
# File 'ext/gpgme/gpgme_n.c', line 1082

static VALUE
rb_s_gpgme_op_import (VALUE dummy, VALUE vctx, VALUE vkeydata)
{
  gpgme_ctx_t ctx;
  gpgme_data_t keydata;
  gpgme_error_t err;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  UNWRAP_GPGME_DATA(vkeydata, keydata);

  err = gpgme_op_import (ctx, keydata);
  return LONG2NUM(err);
}

+ (Object) gpgme_op_import_ext(ctx, keydata, nr)



40
41
42
43
44
45
46
# File 'lib/gpgme/compat.rb', line 40

def gpgme_op_import_ext(ctx, keydata, nr)
  err = GPGME::gpgme_op_import(ctx, keydata)
  if GPGME::gpgme_err_code(err) == GPGME::GPG_ERR_NO_ERROR
    result = GPGME::gpgme_op_import_result(ctx)
    nr.push(result.considered)
  end
end

+ (Object) gpgme_op_import_keys



1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
# File 'ext/gpgme/gpgme_n.c', line 1119

static VALUE
rb_s_gpgme_op_import_keys (VALUE dummy, VALUE vctx, VALUE vkeys)
{
  gpgme_ctx_t ctx;
  gpgme_key_t *keys;
  gpgme_error_t err;
  int i;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");

  keys = ALLOC_N(gpgme_key_t, RARRAY_LEN(vkeys) + 1);
  for (i = 0; i < RARRAY_LEN(vkeys); i++)
    UNWRAP_GPGME_KEY(RARRAY_PTR(vkeys)[i], keys[i]);
  keys[i] = NULL;

  err = gpgme_op_import_keys (ctx, keys);
  return LONG2NUM(err);
}

+ (Object) gpgme_op_import_keys_start



1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
# File 'ext/gpgme/gpgme_n.c', line 1142

static VALUE
rb_s_gpgme_op_import_keys_start (VALUE dummy, VALUE vctx, VALUE vkeys)
{
  gpgme_ctx_t ctx;
  gpgme_key_t *keys;
  gpgme_error_t err;
  int i;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");

  keys = ALLOC_N(gpgme_key_t, RARRAY_LEN(vkeys) + 1);
  for (i = 0; i < RARRAY_LEN(vkeys); i++)
    UNWRAP_GPGME_KEY(RARRAY_PTR(vkeys)[i], keys[i]);
  keys[i] = NULL;

  err = gpgme_op_import_keys_start (ctx, keys);
  return LONG2NUM(err);
}

+ (Object) gpgme_op_import_result



1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
# File 'ext/gpgme/gpgme_n.c', line 1166

static VALUE
rb_s_gpgme_op_import_result (VALUE dummy, VALUE vctx)
{
  gpgme_ctx_t ctx;
  gpgme_import_result_t result;
  gpgme_import_status_t status;
  VALUE vresult, vimports;

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");

  result = gpgme_op_import_result (ctx);
  vresult = rb_class_new_instance (0, NULL, cImportResult);
  rb_iv_set (vresult, "@considered", INT2NUM(result->considered));
  rb_iv_set (vresult, "@no_user_id", INT2NUM(result->no_user_id));
  rb_iv_set (vresult, "@imported", INT2NUM(result->imported));
  rb_iv_set (vresult, "@imported_rsa", INT2NUM(result->imported_rsa));
  rb_iv_set (vresult, "@unchanged", INT2NUM(result->unchanged));
  rb_iv_set (vresult, "@new_user_ids", INT2NUM(result->new_user_ids));
  rb_iv_set (vresult, "@new_sub_keys", INT2NUM(result->new_sub_keys));
  rb_iv_set (vresult, "@new_signatures", INT2NUM(result->new_signatures));
  rb_iv_set (vresult, "@new_revocations", INT2NUM(result->new_revocations));
  rb_iv_set (vresult, "@secret_read", INT2NUM(result->secret_read));
  rb_iv_set (vresult, "@secret_imported", INT2NUM(result->secret_imported));
  rb_iv_set (vresult, "@secret_unchanged", INT2NUM(result->secret_unchanged));
  rb_iv_set (vresult, "@not_imported", INT2NUM(result->not_imported));
  vimports = rb_ary_new ();
  rb_iv_set (vresult, "@imports", vimports);
  for (status = result->imports; status;
       status = status->next)
    {
      VALUE vstatus =
	rb_class_new_instance (0, NULL, cImportStatus);
      rb_iv_set (vstatus, "@fpr", rb_str_new2 (status->fpr));
      rb_iv_set (vstatus, "@result", LONG2NUM(status->result));
      rb_iv_set (vstatus, "@status", UINT2NUM(status->status));
      rb_ary_push (vimports, vstatus);
    }
  return vresult;
}

+ (Object) gpgme_op_import_start



1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
# File 'ext/gpgme/gpgme_n.c', line 1100

static VALUE
rb_s_gpgme_op_import_start (VALUE dummy, VALUE vctx, VALUE vkeydata)
{
  gpgme_ctx_t ctx;
  gpgme_data_t keydata;
  gpgme_error_t err;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  UNWRAP_GPGME_DATA(vkeydata, keydata);

  err = gpgme_op_import_start (ctx, keydata);
  return LONG2NUM(err);
}

+ (Object) gpgme_op_keylist_end



857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
# File 'ext/gpgme/gpgme_n.c', line 857

static VALUE
rb_s_gpgme_op_keylist_end (VALUE dummy, VALUE vctx)
{
  gpgme_ctx_t ctx;
  gpgme_error_t err;

  CHECK_KEYLIST_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");

  err = gpgme_op_keylist_end (ctx);
  RESET_KEYLIST_IN_PROGRESS(vctx);
  return LONG2NUM(err);
}

+ (Object) gpgme_op_keylist_ext_start



720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
# File 'ext/gpgme/gpgme_n.c', line 720

static VALUE
rb_s_gpgme_op_keylist_ext_start (VALUE dummy, VALUE vctx, VALUE vpattern,
				 VALUE vsecret_only)
{
  gpgme_ctx_t ctx;
  const char **pattern = NULL;
  int i, err;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");

  if (!NIL_P(vpattern))
    {
      /* Convert RARRAY into `const char *' array. */
      pattern = ALLOC_N(const char *, RARRAY_LEN(vpattern) + 1);
      for (i = 0; i<RARRAY_LEN(vpattern); i++)
	pattern[i] = StringValueCStr(RARRAY_PTR(vpattern)[i]);
      pattern[RARRAY_LEN(vpattern)] = NULL;
    }

  err = gpgme_op_keylist_ext_start (ctx, pattern, NUM2INT(vsecret_only), 0);
  if (gpgme_err_code (err) == GPG_ERR_NO_ERROR)
    SET_KEYLIST_IN_PROGRESS(vctx);
  if (pattern)
    xfree (pattern);
  return LONG2NUM(err);
}

+ (Object) gpgme_op_keylist_next



834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
# File 'ext/gpgme/gpgme_n.c', line 834

static VALUE
rb_s_gpgme_op_keylist_next (VALUE dummy, VALUE vctx, VALUE rkey)
{
  gpgme_ctx_t ctx;
  gpgme_key_t key;
  gpgme_error_t err;

  CHECK_KEYLIST_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");

  err = gpgme_op_keylist_next (ctx, &key);
  if (gpgme_err_code(err) == GPG_ERR_NO_ERROR)
    {
      VALUE vkey = WRAP_GPGME_KEY(key);
      save_gpgme_key_attrs (vkey, key);
      rb_ary_store (rkey, 0, vkey);
    }
  return LONG2NUM(err);
}

+ (Object) gpgme_op_keylist_start

Key Management



699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
# File 'ext/gpgme/gpgme_n.c', line 699

static VALUE
rb_s_gpgme_op_keylist_start (VALUE dummy, VALUE vctx, VALUE vpattern,
			     VALUE vsecret_only)
{
  gpgme_ctx_t ctx;
  gpgme_error_t err;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");

  err = gpgme_op_keylist_start (ctx, NIL_P(vpattern) ? NULL :
				StringValueCStr(vpattern),
				NUM2INT(vsecret_only));
  if (gpgme_err_code (err) == GPG_ERR_NO_ERROR)
    SET_KEYLIST_IN_PROGRESS(vctx);
  return LONG2NUM(err);
}

+ (Object) gpgme_op_sign



1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
# File 'ext/gpgme/gpgme_n.c', line 1686

static VALUE
rb_s_gpgme_op_sign (VALUE dummy, VALUE vctx, VALUE vplain, VALUE vsig,
		    VALUE vmode)
{
  gpgme_ctx_t ctx;
  gpgme_data_t plain, sig;
  gpgme_error_t err;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  UNWRAP_GPGME_DATA(vplain, plain);
  UNWRAP_GPGME_DATA(vsig, sig);

  err = gpgme_op_sign (ctx, plain, sig, NUM2INT(vmode));
  return LONG2NUM(err);
}

+ (Object) gpgme_op_sign_result



1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
# File 'ext/gpgme/gpgme_n.c', line 1726

static VALUE
rb_s_gpgme_op_sign_result (VALUE dummy, VALUE vctx)
{
  gpgme_ctx_t ctx;
  gpgme_sign_result_t result;
  gpgme_invalid_key_t invalid_key;
  gpgme_new_signature_t new_signature;
  VALUE vresult, vinvalid_signers, vsignatures;

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");

  result = gpgme_op_sign_result (ctx);
  vresult = rb_class_new_instance (0, NULL, cSignResult);
  vinvalid_signers = rb_ary_new ();
  rb_iv_set (vresult, "@invalid_signers", vinvalid_signers);
  for (invalid_key = result->invalid_signers; invalid_key;
       invalid_key = invalid_key->next)
    {
      VALUE vinvalid_key =
	rb_class_new_instance (0, NULL, cInvalidKey);
      rb_iv_set (vinvalid_key, "@fpr", rb_str_new2 (invalid_key->fpr));
      rb_iv_set (vinvalid_key, "@reason", LONG2NUM(invalid_key->reason));
      rb_ary_push (vinvalid_signers, vinvalid_key);
    }
  vsignatures = rb_ary_new ();
  rb_iv_set (vresult, "@signatures", vsignatures);
  for (new_signature = result->signatures; new_signature;
       new_signature = new_signature->next)
    {
      VALUE vnew_signature =
	rb_class_new_instance (0, NULL, cNewSignature);
      rb_iv_set (vnew_signature, "@type", INT2FIX(new_signature->type));
      rb_iv_set (vnew_signature, "@pubkey_algo",
		 INT2FIX(new_signature->pubkey_algo));
      rb_iv_set (vnew_signature, "@hash_algo",
		 INT2FIX(new_signature->hash_algo));
      rb_iv_set (vnew_signature, "@sig_class",
		 UINT2NUM(new_signature->sig_class));
      rb_iv_set (vnew_signature, "@timestamp",
		 LONG2NUM(new_signature->timestamp));
      rb_iv_set (vnew_signature, "@fpr", rb_str_new2 (new_signature->fpr));
      rb_ary_push (vsignatures, vnew_signature);
    }
  return vresult;
}

+ (Object) gpgme_op_sign_start



1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
# File 'ext/gpgme/gpgme_n.c', line 1706

static VALUE
rb_s_gpgme_op_sign_start (VALUE dummy, VALUE vctx, VALUE vplain, VALUE vsig,
			  VALUE vmode)
{
  gpgme_ctx_t ctx;
  gpgme_data_t plain, sig;
  gpgme_error_t err;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  UNWRAP_GPGME_DATA(vplain, plain);
  UNWRAP_GPGME_DATA(vsig, sig);

  err = gpgme_op_sign_start (ctx, plain, sig, NUM2INT(vmode));
  return LONG2NUM(err);
}

+ (Object) gpgme_op_trustlist_end



1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
# File 'ext/gpgme/gpgme_n.c', line 1423

static VALUE
rb_s_gpgme_op_trustlist_end (VALUE dummy, VALUE vctx)
{
  gpgme_ctx_t ctx;
  gpgme_error_t err;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");

  err = gpgme_op_trustlist_end (ctx);
  return LONG2NUM(err);
}

+ (Object) gpgme_op_trustlist_next



1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
# File 'ext/gpgme/gpgme_n.c', line 1392

static VALUE
rb_s_gpgme_op_trustlist_next (VALUE dummy, VALUE vctx, VALUE ritem)
{
  gpgme_ctx_t ctx;
  gpgme_trust_item_t item;
  gpgme_error_t err;
  VALUE vitem;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");

  err = gpgme_op_trustlist_next (ctx, &item);
  if (gpgme_err_code(err) == GPG_ERR_NO_ERROR)
    {
      vitem = WRAP_GPGME_TRUST_ITEM(item);
      rb_iv_set (vitem, "@keyid", rb_str_new2 (item->keyid));
      rb_iv_set (vitem, "@type", INT2FIX(item->type));
      rb_iv_set (vitem, "@level", INT2FIX(item->level));
      if (item->owner_trust)
	rb_iv_set (vitem, "@owner_trust", rb_str_new2 (item->owner_trust));
      rb_iv_set (vitem, "@validity", rb_str_new2 (item->validity));
      if (item->name)
	rb_iv_set (vitem, "@name", rb_str_new2 (item->name));
      rb_ary_store (ritem, 0, vitem);
    }
  return LONG2NUM(err);
}

+ (Object) gpgme_op_trustlist_start

Trust Item Management



1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
# File 'ext/gpgme/gpgme_n.c', line 1375

static VALUE
rb_s_gpgme_op_trustlist_start (VALUE dummy, VALUE vctx, VALUE vpattern,
			       VALUE vmax_level)
{
  gpgme_ctx_t ctx;
  gpgme_error_t err;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  err = gpgme_op_trustlist_start (ctx, StringValueCStr(vpattern),
				  NUM2INT(vmax_level));
  return LONG2NUM(err);
}

+ (Object) gpgme_op_verify

Verify



1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
# File 'ext/gpgme/gpgme_n.c', line 1498

static VALUE
rb_s_gpgme_op_verify (VALUE dummy, VALUE vctx, VALUE vsig, VALUE vsigned_text,
		      VALUE vplain)
{
  gpgme_ctx_t ctx;
  gpgme_data_t sig, signed_text = NULL, plain = NULL;
  gpgme_error_t err;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  UNWRAP_GPGME_DATA(vsig, sig);
  if (!NIL_P(vsigned_text))
    UNWRAP_GPGME_DATA(vsigned_text, signed_text);
  if (!NIL_P(vplain))
    UNWRAP_GPGME_DATA(vplain, plain);

  err = gpgme_op_verify (ctx, sig, signed_text, plain);
  return LONG2NUM(err);
}

+ (Object) gpgme_op_verify_result



1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
# File 'ext/gpgme/gpgme_n.c', line 1544

static VALUE
rb_s_gpgme_op_verify_result (VALUE dummy, VALUE vctx)
{
  gpgme_ctx_t ctx;
  gpgme_verify_result_t verify_result;
  gpgme_signature_t signature;
  VALUE vverify_result, vsignatures = rb_ary_new ();

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");

  verify_result = gpgme_op_verify_result (ctx);
  vverify_result = rb_class_new_instance(0, NULL, cVerifyResult);
  rb_iv_set (vverify_result, "@signatures", vsignatures);
  for (signature = verify_result->signatures; signature;
       signature = signature->next)
    {
      VALUE vsignature = rb_class_new_instance(0, NULL, cSignature),
	vnotations = rb_ary_new ();
      gpgme_sig_notation_t notation;
      rb_iv_set (vsignature, "@summary", INT2FIX(signature->summary));
      rb_iv_set (vsignature, "@fpr", rb_str_new2 (signature->fpr));
      rb_iv_set (vsignature, "@status", LONG2NUM(signature->status));
      rb_iv_set (vsignature, "@notations", vnotations);
      for (notation = signature->notations; notation;
	   notation = notation->next)
	{
	  VALUE vnotation = rb_class_new_instance(0, NULL, cSigNotation);
	  /* The docs say:
	   * The name of the notation field. If this is NULL, then the member
	   * value will contain a policy URL. */
	  if (notation->name == NULL)
	    rb_iv_set (vnotation, "@name", Qnil);
	  else
	    rb_iv_set (vnotation, "@name", rb_str_new2 (notation->name));
	  rb_iv_set (vnotation, "@value", rb_str_new2 (notation->value));
	  rb_ary_push (vnotations, vnotation);
	}
      rb_iv_set (vsignature, "@timestamp", ULONG2NUM(signature->timestamp));
      rb_iv_set (vsignature, "@exp_timestamp",
		 ULONG2NUM(signature->exp_timestamp));
      rb_iv_set (vsignature, "@wrong_key_usage",
		 INT2FIX(signature->wrong_key_usage));
      rb_iv_set (vsignature, "@validity", INT2FIX(signature->validity));
      rb_iv_set (vsignature, "@validity_reason",
		 LONG2NUM(signature->validity_reason));
      /* PKA related fields were added in 1.1.1. */
#ifdef GPGME_STATUS_PKA_TRUST_BAD
      rb_iv_set (vsignature, "@pka_trust", INT2FIX(signature->pka_trust));
      rb_iv_set (vsignature, "@pka_address",
		 rb_str_new2 (signature->pka_address));
#endif
      rb_ary_push (vsignatures, vsignature);
    }
  return vverify_result;
}

+ (Object) gpgme_op_verify_start



1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
# File 'ext/gpgme/gpgme_n.c', line 1521

static VALUE
rb_s_gpgme_op_verify_start (VALUE dummy, VALUE vctx, VALUE vsig,
			    VALUE vsigned_text, VALUE vplain)
{
  gpgme_ctx_t ctx;
  gpgme_data_t sig, signed_text = NULL, plain = NULL;
  gpgme_error_t err;

  CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  UNWRAP_GPGME_DATA(vsig, sig);
  if (!NIL_P(vsigned_text))
    UNWRAP_GPGME_DATA(vsigned_text, signed_text);
  if (!NIL_P(vplain))
    UNWRAP_GPGME_DATA(vplain, plain);

  err = gpgme_op_verify_start (ctx, sig, signed_text, plain);
  return LONG2NUM(err);
}

+ (Object) gpgme_pubkey_algo_name Also known as: pubkey_algo_name



186
187
188
189
190
191
192
193
# File 'ext/gpgme/gpgme_n.c', line 186

static VALUE
rb_s_gpgme_pubkey_algo_name (VALUE dummy, VALUE valgo)
{
  const char *name = gpgme_pubkey_algo_name (NUM2INT(valgo));
  if (name)
    return rb_str_new2 (name);
  return Qnil;
}

+ (Object) gpgme_release



422
423
424
425
426
427
428
429
430
431
432
433
# File 'ext/gpgme/gpgme_n.c', line 422

static VALUE
rb_s_gpgme_release (VALUE dummy, VALUE vctx)
{
  gpgme_ctx_t ctx;

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  gpgme_release (ctx);
  DATA_PTR(vctx) = NULL;
  return Qnil;
}

+ (Object) gpgme_set_armor



461
462
463
464
465
466
467
468
469
470
471
472
# File 'ext/gpgme/gpgme_n.c', line 461

static VALUE
rb_s_gpgme_set_armor (VALUE dummy, VALUE vctx, VALUE vyes)
{
  gpgme_ctx_t ctx;

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  gpgme_set_armor (ctx, NUM2INT(vyes));

  return Qnil;
}

+ (Object) gpgme_set_engine_info



174
175
176
177
178
179
180
181
182
183
184
# File 'ext/gpgme/gpgme_n.c', line 174

static VALUE
rb_s_gpgme_set_engine_info (VALUE dummy, VALUE vproto, VALUE vfile_name,
			    VALUE vhome_dir)
{
  gpgme_error_t err = gpgme_set_engine_info (NUM2INT(vproto),
					     NIL_P(vfile_name) ? NULL :
					     StringValueCStr(vfile_name),
					     NIL_P(vhome_dir) ? NULL :
					     StringValueCStr(vhome_dir));
  return LONG2NUM(err);
}

+ (Object) gpgme_set_include_certs



512
513
514
515
516
517
518
519
520
521
522
# File 'ext/gpgme/gpgme_n.c', line 512

static VALUE
rb_s_gpgme_set_include_certs (VALUE dummy, VALUE vctx, VALUE vnr_of_certs)
{
  gpgme_ctx_t ctx;

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  gpgme_set_include_certs (ctx, NUM2INT(vnr_of_certs));
  return Qnil;
}

+ (Object) gpgme_set_keylist_mode



537
538
539
540
541
542
543
544
545
546
547
548
# File 'ext/gpgme/gpgme_n.c', line 537

static VALUE
rb_s_gpgme_set_keylist_mode (VALUE dummy, VALUE vctx, VALUE vmode)
{
  gpgme_ctx_t ctx;
  gpgme_error_t err;

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  err = gpgme_set_keylist_mode (ctx, NUM2INT(vmode));
  return LONG2NUM(err);
}

+ (Object) gpgme_set_locale



655
656
657
658
659
660
661
662
663
664
665
666
667
# File 'ext/gpgme/gpgme_n.c', line 655

static VALUE
rb_s_gpgme_set_locale (VALUE dummy, VALUE vctx, VALUE vcategory, VALUE vvalue)
{
  gpgme_ctx_t ctx;
  gpgme_error_t err;

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");

  err = gpgme_set_locale (ctx, NUM2INT(vcategory), StringValueCStr(vvalue));
  return LONG2NUM(err);
}

+ (Object) gpgme_set_passphrase_cb



581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
# File 'ext/gpgme/gpgme_n.c', line 581

static VALUE
rb_s_gpgme_set_passphrase_cb (VALUE dummy, VALUE vctx, VALUE vpassfunc,
			      VALUE vhook_value)
{
  gpgme_ctx_t ctx;
  VALUE vcb = rb_ary_new ();

  rb_ary_push (vcb, vpassfunc);
  rb_ary_push (vcb, vhook_value);
  /* Keep a reference to avoid GC. */
  rb_iv_set (vctx, "@passphrase_cb", vcb);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  gpgme_set_passphrase_cb (ctx, passphrase_cb, (void*)vcb);
  return Qnil;
}

+ (Object) gpgme_set_pinentry_mode



670
671
672
673
674
675
676
677
678
679
680
681
682
# File 'ext/gpgme/gpgme_n.c', line 670

static VALUE
rb_s_gpgme_set_pinentry_mode (VALUE dummy, VALUE vctx, VALUE vmode)
{
  gpgme_ctx_t ctx;
  gpgme_error_t err;

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");

  err = gpgme_set_pinentry_mode (ctx, NUM2INT(vmode));
  return LONG2NUM(err);
}

+ (Object) gpgme_set_progress_cb



625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
# File 'ext/gpgme/gpgme_n.c', line 625

static VALUE
rb_s_gpgme_set_progress_cb (VALUE dummy, VALUE vctx, VALUE vprogfunc,
			    VALUE vhook_value)
{
  gpgme_ctx_t ctx;
  VALUE vcb = rb_ary_new ();

  rb_ary_push (vcb, vprogfunc);
  rb_ary_push (vcb, vhook_value);
  /* Keep a reference to avoid GC. */
  rb_iv_set (vctx, "@progress_cb", vcb);

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  gpgme_set_progress_cb (ctx, progress_cb, (void*)vcb);

  return Qnil;
}

+ (Object) gpgme_set_protocol

Context Attributes



435
436
437
438
439
440
441
442
443
444
445
446
# File 'ext/gpgme/gpgme_n.c', line 435

static VALUE
rb_s_gpgme_set_protocol (VALUE dummy, VALUE vctx, VALUE vproto)
{
  gpgme_ctx_t ctx;
  gpgme_error_t err;

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  err = gpgme_set_protocol (ctx, NUM2INT(vproto));
  return LONG2NUM(err);
}

+ (Object) gpgme_set_textmode



487
488
489
490
491
492
493
494
495
496
497
# File 'ext/gpgme/gpgme_n.c', line 487

static VALUE
rb_s_gpgme_set_textmode (VALUE dummy, VALUE vctx, VALUE vyes)
{
  gpgme_ctx_t ctx;

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  gpgme_set_textmode (ctx, NUM2INT(vyes));
  return Qnil;
}

+ (Object) gpgme_signers_add



1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
# File 'ext/gpgme/gpgme_n.c', line 1654

static VALUE
rb_s_gpgme_signers_add (VALUE dummy, VALUE vctx, VALUE vkey)
{
  gpgme_ctx_t ctx;
  gpgme_key_t key;
  gpgme_error_t err;

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  UNWRAP_GPGME_KEY(vkey, key);

  err = gpgme_signers_add (ctx, key);
  return LONG2NUM(err);
}

+ (Object) gpgme_signers_clear

Sign



1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
# File 'ext/gpgme/gpgme_n.c', line 1642

static VALUE
rb_s_gpgme_signers_clear (VALUE dummy, VALUE vctx)
{
  gpgme_ctx_t ctx;

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");
  gpgme_signers_clear (ctx);
  return Qnil;
}

+ (Object) gpgme_signers_enum



1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
# File 'ext/gpgme/gpgme_n.c', line 1670

static VALUE
rb_s_gpgme_signers_enum (VALUE dummy, VALUE vctx, VALUE vseq)
{
  gpgme_ctx_t ctx;
  gpgme_key_t key;

  UNWRAP_GPGME_CTX(vctx, ctx);
  if (!ctx)
    rb_raise (rb_eArgError, "released ctx");

  key = gpgme_signers_enum (ctx, NUM2INT(vseq));
  if (!key)
    return Qnil;
  return WRAP_GPGME_KEY(key);
}

+ (Object) gpgme_strerror



216
217
218
219
220
# File 'ext/gpgme/gpgme_n.c', line 216

static VALUE
rb_s_gpgme_strerror (VALUE dummy, VALUE verr)
{
  return rb_str_new2 (gpgme_strerror (NUM2LONG(verr)));
}

+ (Object) gpgme_wait

Run Control



1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
# File 'ext/gpgme/gpgme_n.c', line 1937

static VALUE
rb_s_gpgme_wait (VALUE dummy, VALUE vctx, VALUE rstatus, VALUE vhang)
{
  gpgme_ctx_t ctx = NULL, ret;
  gpgme_error_t status;

  /* The CTX argument can be `NULL'.  In that case, `gpgme_wait' waits
     for any context to complete its operation. */
  if (!NIL_P(vctx))
    {
      UNWRAP_GPGME_CTX(vctx, ctx);
      if (!ctx)
	rb_raise (rb_eArgError, "released ctx");
    }

  ret = gpgme_wait (ctx, &status, NUM2INT(vhang));
  if (ret)
    {
      rb_ary_store (rstatus, 0, INT2NUM(status));
      if (ret != ctx)
	vctx = WRAP_GPGME_CTX(ret);
      return vctx;
    }
  return Qnil;
}