core: Use gpgrt locking for thread safeness
[gpgme.git] / src / engine.h
1 /* engine.h - GPGME engine interface.
2    Copyright (C) 2000 Werner Koch (dd9jn)
3    Copyright (C) 2001, 2002, 2003, 2004, 2010 g10 Code GmbH
4
5    This file is part of GPGME.
6
7    GPGME is free software; you can redistribute it and/or modify it
8    under the terms of the GNU Lesser General Public License as
9    published by the Free Software Foundation; either version 2.1 of
10    the License, or (at your option) any later version.
11
12    GPGME is distributed in the hope that it will be useful, but
13    WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    Lesser General Public License for more details.
16
17    You should have received a copy of the GNU Lesser General Public
18    License along with this program; if not, write to the Free Software
19    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20    02111-1307, USA.  */
21
22 #ifndef ENGINE_H
23 #define ENGINE_H
24
25 #include "gpgme.h"
26
27 /* Flags used by the EXTRAFLAGS arg of _gpgme_engine_op_genkey.  */
28 #define GENKEY_EXTRAFLAG_ARMOR   1
29 #define GENKEY_EXTRAFLAG_REVOKE  2
30
31
32 struct engine;
33 typedef struct engine *engine_t;
34
35 typedef gpgme_error_t (*engine_status_handler_t) (void *priv,
36                                                   gpgme_status_code_t code,
37                                                   char *args);
38 typedef gpgme_error_t (*engine_colon_line_handler_t) (void *priv, char *line);
39 typedef gpgme_error_t (*engine_command_handler_t) (void *priv,
40                                                    gpgme_status_code_t code,
41                                                    const char *keyword,
42                                                    int fd, int *processed);
43 typedef gpgme_error_t (*engine_assuan_result_cb_t) (void *priv,
44                                                     gpgme_error_t result);
45
46 /* Helper for gpgme_set_global_flag.  */
47 int _gpgme_set_engine_minimal_version (const char *value);
48
49 /* Get a deep copy of the engine info and return it in INFO.  */
50 gpgme_error_t _gpgme_engine_info_copy (gpgme_engine_info_t *r_info);
51
52 /* Release the engine info INFO.  */
53 void _gpgme_engine_info_release (gpgme_engine_info_t info);
54
55 /* Set the engine info for the info list INFO, protocol PROTO, to the
56    file name FILE_NAME and the home directory HOME_DIR.  */
57 gpgme_error_t _gpgme_set_engine_info (gpgme_engine_info_t info,
58                                       gpgme_protocol_t praoto,
59                                       const char *file_name,
60                                       const char *home_dir);
61
62
63 gpgme_error_t _gpgme_engine_new (gpgme_engine_info_t info,
64                                  engine_t *r_engine);
65 gpgme_error_t _gpgme_engine_reset (engine_t engine);
66
67 gpgme_error_t _gpgme_engine_set_locale (engine_t engine, int category,
68                                         const char *value);
69 gpgme_error_t _gpgme_engine_set_protocol (engine_t engine,
70                                           gpgme_protocol_t protocol);
71 void _gpgme_engine_release (engine_t engine);
72 void _gpgme_engine_set_status_cb (engine_t engine,
73                                   gpgme_status_cb_t cb, void *cb_value);
74 void _gpgme_engine_set_status_handler (engine_t engine,
75                                        engine_status_handler_t fnc,
76                                        void *fnc_value);
77 gpgme_error_t _gpgme_engine_set_command_handler (engine_t engine,
78                                                  engine_command_handler_t fnc,
79                                                  void *fnc_value,
80                                                  gpgme_data_t data);
81 gpgme_error_t
82 _gpgme_engine_set_colon_line_handler (engine_t engine,
83                                       engine_colon_line_handler_t fnc,
84                                       void *fnc_value);
85 gpgme_error_t _gpgme_engine_op_decrypt (engine_t engine, gpgme_data_t ciph,
86                                         gpgme_data_t plain);
87 gpgme_error_t _gpgme_engine_op_decrypt_verify (engine_t engine,
88                                                gpgme_data_t ciph,
89                                                gpgme_data_t plain);
90 gpgme_error_t _gpgme_engine_op_delete (engine_t engine, gpgme_key_t key,
91                                        int allow_secret);
92 gpgme_error_t _gpgme_engine_op_edit (engine_t engine, int type,
93                                      gpgme_key_t key, gpgme_data_t out,
94                                      gpgme_ctx_t ctx /* FIXME */);
95 gpgme_error_t _gpgme_engine_op_encrypt (engine_t engine,
96                                         gpgme_key_t recp[],
97                                         gpgme_encrypt_flags_t flags,
98                                         gpgme_data_t plain, gpgme_data_t ciph,
99                                         int use_armor);
100 gpgme_error_t _gpgme_engine_op_encrypt_sign (engine_t engine,
101                                              gpgme_key_t recp[],
102                                              gpgme_encrypt_flags_t flags,
103                                              gpgme_data_t plain,
104                                              gpgme_data_t ciph,
105                                              int use_armor,
106                                              gpgme_ctx_t ctx /* FIXME */);
107 gpgme_error_t _gpgme_engine_op_export (engine_t engine, const char *pattern,
108                                        gpgme_export_mode_t mode,
109                                        gpgme_data_t keydata, int use_armor);
110 gpgme_error_t _gpgme_engine_op_export_ext (engine_t engine,
111                                            const char *pattern[],
112                                            gpgme_export_mode_t mode,
113                                            gpgme_data_t keydata,
114                                            int use_armor);
115 gpgme_error_t _gpgme_engine_op_genkey (engine_t engine,
116                                        const char *userid, const char *algo,
117                                        unsigned long reserved,
118                                        unsigned long expires,
119                                        gpgme_key_t key, unsigned int flags,
120                                        gpgme_data_t help_data,
121                                        unsigned int extraflags,
122                                        gpgme_data_t pubkey,
123                                        gpgme_data_t seckey);
124 gpgme_error_t _gpgme_engine_op_keysign (engine_t engine,
125                                         gpgme_key_t key, const char *userid,
126                                         unsigned long expires,
127                                         unsigned int flags,
128                                         gpgme_ctx_t ctx);
129 gpgme_error_t _gpgme_engine_op_tofu_policy (engine_t engine,
130                                             gpgme_key_t key,
131                                             gpgme_tofu_policy_t policy);
132 gpgme_error_t _gpgme_engine_op_import (engine_t engine,
133                                        gpgme_data_t keydata,
134                                        gpgme_key_t *keyarray);
135 gpgme_error_t _gpgme_engine_op_keylist (engine_t engine,
136                                         const char *pattern,
137                                         int secret_only,
138                                         gpgme_keylist_mode_t mode,
139                                         int engine_flags);
140 gpgme_error_t _gpgme_engine_op_keylist_ext (engine_t engine,
141                                             const char *pattern[],
142                                             int secret_only,
143                                             int reserved,
144                                             gpgme_keylist_mode_t mode,
145                                             int engine_flags);
146 gpgme_error_t _gpgme_engine_op_sign (engine_t engine, gpgme_data_t in,
147                                      gpgme_data_t out, gpgme_sig_mode_t mode,
148                                      int use_armor, int use_textmode,
149                                      int include_certs,
150                                      gpgme_ctx_t ctx /* FIXME */);
151 gpgme_error_t _gpgme_engine_op_trustlist (engine_t engine,
152                                           const char *pattern);
153 gpgme_error_t _gpgme_engine_op_verify (engine_t engine, gpgme_data_t sig,
154                                        gpgme_data_t signed_text,
155                                        gpgme_data_t plaintext,
156                                        gpgme_ctx_t ctx);
157
158 gpgme_error_t _gpgme_engine_op_getauditlog (engine_t engine,
159                                             gpgme_data_t output,
160                                             unsigned int flags);
161 gpgme_error_t _gpgme_engine_op_assuan_transact
162                 (engine_t engine,
163                  const char *command,
164                  gpgme_assuan_data_cb_t data_cb,
165                  void *data_cb_value,
166                  gpgme_assuan_inquire_cb_t inq_cb,
167                  void *inq_cb_value,
168                  gpgme_assuan_status_cb_t status_cb,
169                  void *status_cb_value);
170
171 gpgme_error_t _gpgme_engine_op_conf_load (engine_t engine,
172                                           gpgme_conf_comp_t *conf_p);
173 gpgme_error_t _gpgme_engine_op_conf_save (engine_t engine,
174                                           gpgme_conf_comp_t conf);
175
176 gpgme_error_t _gpgme_engine_op_query_swdb (engine_t engine,
177                                            const char *name,
178                                            const char *iversion,
179                                            gpgme_query_swdb_result_t result);
180
181
182 void _gpgme_engine_set_io_cbs (engine_t engine,
183                                gpgme_io_cbs_t io_cbs);
184 void _gpgme_engine_io_event (engine_t engine,
185                              gpgme_event_io_t type, void *type_data);
186
187 gpgme_error_t _gpgme_engine_cancel (engine_t engine);
188
189 gpgme_error_t _gpgme_engine_cancel_op (engine_t engine);
190
191 gpgme_error_t _gpgme_engine_op_passwd (engine_t engine, gpgme_key_t key,
192                                        unsigned int flags);
193
194 gpgme_error_t _gpgme_engine_set_pinentry_mode (engine_t engine,
195                                                gpgme_pinentry_mode_t mode);
196
197 gpgme_error_t _gpgme_engine_op_spawn (engine_t engine,
198                                       const char *file, const char *argv[],
199                                       gpgme_data_t datain,
200                                       gpgme_data_t dataout,
201                                       gpgme_data_t dataerr,
202                                       unsigned int flags);
203
204 /* The available engine option flags.  */
205 #define GPGME_ENGINE_FLAG_OFFLINE        1
206
207
208 #endif /* ENGINE_H */