src/pgp_gpg_internal.h
author Krista Grothoff <krista@pep-project.org>
Mon, 13 Feb 2017 22:13:48 +0100
branchenigmail-color-tests
changeset 1582 7dd855780eef
parent 1513 e7f7e42385b5
child 1639 be84d676f3ef
permissions -rw-r--r--
closing branch
     1 // This file is under GNU General Public License 3.0
     2 // see LICENSE.txt
     3 
     4 #pragma once
     5 
     6 #include <gpgme.h>
     7 
     8 // init
     9 
    10 typedef const char * (*gpgme_check_version_t)(const char*);
    11 typedef gpgme_error_t (*gpgme_get_engine_info_t)(gpgme_engine_info_t *INFO);
    12 typedef gpgme_error_t(*gpgme_set_locale_t)(gpgme_ctx_t CTX, int CATEGORY,
    13     const char *VALUE);
    14 typedef gpgme_error_t(*gpgme_new_t)(gpgme_ctx_t *CTX);
    15 typedef void(*gpgme_release_t)(gpgme_ctx_t CTX);
    16 typedef gpgme_error_t(*gpgme_set_protocol_t)(gpgme_ctx_t CTX,
    17     gpgme_protocol_t PROTO);
    18 typedef void(*gpgme_set_armor_t)(gpgme_ctx_t CTX, int YES);
    19 
    20 // data
    21 
    22 typedef gpgme_error_t(*gpgme_data_new_t)(gpgme_data_t *DH);
    23 typedef gpgme_error_t(*gpgme_data_new_from_mem_t)(gpgme_data_t *DH,
    24     const char *BUFFER, size_t SIZE, int COPY);
    25 typedef gpgme_error_t (*gpgme_data_new_from_cbs_t)(gpgme_data_t *DH,
    26         gpgme_data_cbs_t CBS, void *HANDLE);
    27 typedef void(*gpgme_data_release_t)(gpgme_data_t DH);
    28 typedef gpgme_data_type_t(*gpgme_data_identify_t)(gpgme_data_t DH);
    29 typedef size_t(*gpgme_data_seek_t)(gpgme_data_t DH, size_t OFFSET,
    30     int WHENCE);
    31 typedef size_t(*gpgme_data_read_t)(gpgme_data_t DH, void *BUFFER,
    32     size_t LENGTH);
    33 
    34 // encrypt and decrypt
    35 
    36 typedef gpgme_error_t(*gpgme_op_decrypt_t)(gpgme_ctx_t CTX,
    37     gpgme_data_t CIPHER, gpgme_data_t PLAIN);
    38 typedef gpgme_error_t(*gpgme_op_verify_t)(gpgme_ctx_t CTX, gpgme_data_t SIG,
    39     gpgme_data_t SIGNED_TEXT, gpgme_data_t PLAIN);
    40 typedef gpgme_error_t(*gpgme_op_decrypt_verify_t)(gpgme_ctx_t CTX,
    41     gpgme_data_t CIPHER, gpgme_data_t PLAIN);
    42 typedef gpgme_decrypt_result_t(*gpgme_op_decrypt_result_t)(gpgme_ctx_t CTX);
    43 typedef gpgme_error_t(*gpgme_op_encrypt_sign_t)(gpgme_ctx_t CTX,
    44     gpgme_key_t RECP[], gpgme_encrypt_flags_t FLAGS, gpgme_data_t PLAIN,
    45     gpgme_data_t CIPHER);
    46 typedef gpgme_verify_result_t(*gpgme_op_verify_result_t)(gpgme_ctx_t CTX);
    47 typedef void(*gpgme_signers_clear_t)(gpgme_ctx_t CTX);
    48 typedef gpgme_error_t(*gpgme_signers_add_t)(gpgme_ctx_t CTX, const gpgme_key_t KEY);
    49 
    50 // keys
    51 
    52 typedef gpgme_error_t(*gpgme_get_key_t)(gpgme_ctx_t CTX, const char *FPR,
    53     gpgme_key_t *R_KEY, int SECRET);
    54 typedef gpgme_error_t(*gpgme_op_genkey_t)(gpgme_ctx_t CTX, const char *PARMS,
    55     gpgme_data_t PUBLIC, gpgme_data_t SECRET);
    56 typedef gpgme_genkey_result_t(*gpgme_op_genkey_result_t)(gpgme_ctx_t CTX);
    57 typedef gpgme_error_t(*gpgme_op_delete_t)(gpgme_ctx_t CTX,
    58     const gpgme_key_t KEY, int ALLOW_SECRET);
    59 typedef gpgme_error_t(*gpgme_op_import_t)(gpgme_ctx_t CTX,
    60     gpgme_data_t KEYDATA);
    61 typedef gpgme_import_result_t(*gpgme_op_import_result_t)(gpgme_ctx_t CTX);
    62 typedef gpgme_error_t(*gpgme_op_export_t)(gpgme_ctx_t CTX,
    63     const char *PATTERN, gpgme_export_mode_t MODE, gpgme_data_t KEYDATA);
    64 typedef gpgme_error_t(*gpgme_set_keylist_mode_t)(gpgme_ctx_t CTX,
    65     gpgme_keylist_mode_t MODE);
    66 typedef gpgme_keylist_mode_t(*gpgme_get_keylist_mode_t)(gpgme_ctx_t CTX);
    67 typedef gpgme_error_t(*gpgme_op_keylist_start_t)(gpgme_ctx_t CTX,
    68     const char *PATTERN, int SECRET_ONLY);
    69 typedef gpgme_error_t(*gpgme_op_keylist_next_t)(gpgme_ctx_t CTX,
    70     gpgme_key_t *R_KEY);
    71 typedef gpgme_error_t(*gpgme_op_keylist_end_t)(gpgme_ctx_t CTX);
    72 typedef gpgme_error_t(*gpgme_op_import_keys_t)(gpgme_ctx_t CTX,
    73     gpgme_key_t *KEYS);
    74 typedef void(*gpgme_key_ref_t)(gpgme_key_t KEY);
    75 typedef void(*gpgme_key_unref_t)(gpgme_key_t KEY);
    76 typedef void(*gpgme_key_release_t)(gpgme_key_t KEY);
    77 typedef gpgme_error_t (*gpgme_op_edit_t)(gpgme_ctx_t CTX, gpgme_key_t KEY,
    78         gpgme_edit_cb_t FNC, void *HANDLE, gpgme_data_t OUT);
    79 typedef gpgme_ssize_t (*gpgme_io_write_t)(int fd, const void *buffer,
    80         size_t count);
    81 
    82 struct gpg_s {
    83     const char * version;
    84     gpgme_check_version_t gpgme_check;
    85     gpgme_get_engine_info_t gpgme_get_engine_info;
    86     gpgme_set_locale_t gpgme_set_locale;
    87     gpgme_new_t gpgme_new;
    88     gpgme_release_t gpgme_release;
    89     gpgme_set_protocol_t gpgme_set_protocol;
    90     gpgme_set_armor_t gpgme_set_armor;
    91 
    92     gpgme_data_new_t gpgme_data_new;
    93     gpgme_data_new_from_mem_t gpgme_data_new_from_mem;
    94     gpgme_data_new_from_cbs_t gpgme_data_new_from_cbs;
    95     gpgme_data_release_t gpgme_data_release;
    96     gpgme_data_identify_t gpgme_data_identify;
    97     gpgme_data_seek_t gpgme_data_seek;
    98     gpgme_data_read_t gpgme_data_read;
    99 
   100     gpgme_op_decrypt_t gpgme_op_decrypt;
   101     gpgme_op_verify_t gpgme_op_verify;
   102     gpgme_op_decrypt_verify_t gpgme_op_decrypt_verify;
   103     gpgme_op_decrypt_result_t gpgme_op_decrypt_result;
   104     gpgme_op_encrypt_sign_t gpgme_op_encrypt_sign;
   105     gpgme_op_verify_result_t gpgme_op_verify_result;
   106     gpgme_signers_clear_t gpgme_signers_clear;
   107     gpgme_signers_add_t gpgme_signers_add;
   108 
   109     gpgme_get_key_t gpgme_get_key;
   110     gpgme_op_genkey_t gpgme_op_genkey;
   111     gpgme_op_genkey_result_t gpgme_op_genkey_result;
   112     gpgme_op_delete_t gpgme_op_delete;
   113     gpgme_op_import_t gpgme_op_import;
   114     gpgme_op_import_result_t gpgme_op_import_result;
   115     gpgme_op_export_t gpgme_op_export;
   116     gpgme_set_keylist_mode_t gpgme_set_keylist_mode;
   117     gpgme_get_keylist_mode_t gpgme_get_keylist_mode;
   118     gpgme_op_keylist_start_t gpgme_op_keylist_start;
   119     gpgme_op_keylist_next_t gpgme_op_keylist_next;
   120     gpgme_op_keylist_end_t gpgme_op_keylist_end;
   121     gpgme_op_import_keys_t gpgme_op_import_keys;
   122     gpgme_key_ref_t gpgme_key_ref;
   123     gpgme_key_unref_t gpgme_key_unref;
   124 	gpgme_key_release_t gpgme_key_release;
   125     gpgme_op_edit_t gpgme_op_edit;
   126     gpgme_io_write_t gpgme_io_write;
   127 };
   128