Hopefully last changes for building with MSC.
[gpgme.git] / src / engine-backend.h
1 /* engine-backend.h - A crypto backend for the engine interface.
2    Copyright (C) 2002, 2003, 2004, 2009 g10 Code GmbH
3  
4    This file is part of GPGME.
5  
6    GPGME is free software; you can redistribute it and/or modify it
7    under the terms of the GNU Lesser General Public License as
8    published by the Free Software Foundation; either version 2.1 of
9    the License, or (at your option) any later version.
10    
11    GPGME is distributed in the hope that it will be useful, but
12    WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Lesser General Public License for more details.
15    
16    You should have received a copy of the GNU Lesser General Public
17    License along with this program; if not, see <http://www.gnu.org/licenses/>.
18  */
19
20 #ifndef ENGINE_BACKEND_H
21 #define ENGINE_BACKEND_H
22
23 #include "engine.h"
24
25 struct engine_ops
26 {
27   /* Static functions.  */
28
29   /* Return the default file name for the binary of this engine.  */
30   const char *(*get_file_name) (void);
31
32   /* Return the default home dir for the binary of this engine.  If
33      this function pointer is not set, the standard default home dir
34      of the engine is used. */
35   const char *(*get_home_dir) (void);
36
37   /* Returns a malloced string containing the version of the engine
38      with the given binary file name (or the default if FILE_NAME is
39      NULL.  */
40   char *(*get_version) (const char *file_name);
41
42   /* Returns a statically allocated string containing the required
43      version.  */
44   const char *(*get_req_version) (void);
45
46   gpgme_error_t (*new) (void **r_engine,
47                         const char *file_name, const char *home_dir);
48
49   /* Member functions.  */
50   void (*release) (void *engine);
51   gpgme_error_t (*reset) (void *engine);
52   void (*set_status_handler) (void *engine, engine_status_handler_t fnc,
53                               void *fnc_value);
54   gpgme_error_t (*set_command_handler) (void *engine,
55                                         engine_command_handler_t fnc,
56                                         void *fnc_value, gpgme_data_t data);
57   gpgme_error_t (*set_colon_line_handler) (void *engine,
58                                            engine_colon_line_handler_t fnc,
59                                            void *fnc_value);
60   gpgme_error_t (*set_locale) (void *engine, int category, const char *value);
61   gpgme_error_t (*set_protocol) (void *engine, gpgme_protocol_t protocol);
62   gpgme_error_t (*decrypt) (void *engine, gpgme_data_t ciph,
63                             gpgme_data_t plain);
64   gpgme_error_t (*decrypt_verify) (void *engine, gpgme_data_t ciph,
65                                    gpgme_data_t plain);
66   gpgme_error_t (*delete) (void *engine, gpgme_key_t key, int allow_secret);
67   gpgme_error_t (*edit) (void *engine, int type, gpgme_key_t key,
68                          gpgme_data_t out, gpgme_ctx_t ctx /* FIXME */);
69   gpgme_error_t (*encrypt) (void *engine, gpgme_key_t recp[],
70                             gpgme_encrypt_flags_t flags,
71                             gpgme_data_t plain, gpgme_data_t ciph,
72                             int use_armor);
73   gpgme_error_t (*encrypt_sign) (void *engine, gpgme_key_t recp[],
74                                  gpgme_encrypt_flags_t flags,
75                                  gpgme_data_t plain, gpgme_data_t ciph,
76                                  int use_armor, gpgme_ctx_t ctx /* FIXME */);
77   gpgme_error_t (*export) (void *engine, const char *pattern,
78                            gpgme_export_mode_t mode, gpgme_data_t keydata,
79                            int use_armor);
80   gpgme_error_t (*export_ext) (void *engine, const char *pattern[],
81                                gpgme_export_mode_t mode, gpgme_data_t keydata,
82                                int use_armor);
83   gpgme_error_t (*genkey) (void *engine, gpgme_data_t help_data, int use_armor,
84                            gpgme_data_t pubkey, gpgme_data_t seckey);
85   gpgme_error_t (*import) (void *engine, gpgme_data_t keydata,
86                            gpgme_key_t *keyarray);
87   gpgme_error_t (*keylist) (void *engine, const char *pattern,
88                             int secret_only, gpgme_keylist_mode_t mode);
89   gpgme_error_t (*keylist_ext) (void *engine, const char *pattern[],
90                                 int secret_only, int reserved,
91                                 gpgme_keylist_mode_t mode);
92   gpgme_error_t (*sign) (void *engine, gpgme_data_t in, gpgme_data_t out,
93                          gpgme_sig_mode_t mode, int use_armor,
94                          int use_textmode, int include_certs,
95                          gpgme_ctx_t ctx /* FIXME */);
96   gpgme_error_t (*trustlist) (void *engine, const char *pattern);
97   gpgme_error_t (*verify) (void *engine, gpgme_data_t sig,
98                            gpgme_data_t signed_text, gpgme_data_t plaintext);
99   gpgme_error_t  (*getauditlog) (void *engine, gpgme_data_t output,
100                                  unsigned int flags);
101   gpgme_error_t  (*opassuan_transact) (void *engine, 
102                                        const char *command,
103                                        gpgme_assuan_data_cb_t data_cb,
104                                        void *data_cb_value,
105                                        gpgme_assuan_inquire_cb_t inq_cb,
106                                        void *inq_cb_value,
107                                        gpgme_assuan_status_cb_t status_cb,
108                                        void *status_cb_value);
109
110   gpgme_error_t  (*conf_load) (void *engine, gpgme_conf_comp_t *conf_p);
111   gpgme_error_t  (*conf_save) (void *engine, gpgme_conf_comp_t conf);
112
113   void (*set_io_cbs) (void *engine, gpgme_io_cbs_t io_cbs);
114   void (*io_event) (void *engine, gpgme_event_io_t type, void *type_data);
115
116   /* Cancel the whole engine session.  */
117   gpgme_error_t (*cancel) (void *engine);
118
119   /* Cancel only the current operation, not the whole session.  */
120   gpgme_error_t (*cancel_op) (void *engine);
121
122   /* Change the passphrase for KEY. */
123   gpgme_error_t (*passwd) (void *engine, gpgme_key_t key, unsigned int flags);
124 };
125
126
127 extern struct engine_ops _gpgme_engine_ops_gpg;         /* OpenPGP.  */
128 #ifdef ENABLE_GPGSM
129 extern struct engine_ops _gpgme_engine_ops_gpgsm;       /* CMS.  */
130 #endif
131 #ifdef ENABLE_GPGCONF
132 extern struct engine_ops _gpgme_engine_ops_gpgconf;     /* gpg-conf.  */
133 #endif
134 #ifdef ENABLE_ASSUAN
135 extern struct engine_ops _gpgme_engine_ops_assuan;      /* Low-level Assuan. */
136 #endif
137 #ifdef ENABLE_G13
138 extern struct engine_ops _gpgme_engine_ops_g13;         /* Crypto VFS. */
139 #endif
140 #ifdef ENABLE_UISERVER
141 extern struct engine_ops _gpgme_engine_ops_uiserver;
142 #endif
143
144 #endif /* ENGINE_BACKEND_H */