core: Fix condition-always-true warning in trace macro.
[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 struct engine;
28 typedef struct engine *engine_t;
29
30 typedef gpgme_error_t (*engine_status_handler_t) (void *priv,
31                                                   gpgme_status_code_t code,
32                                                   char *args);
33 typedef gpgme_error_t (*engine_colon_line_handler_t) (void *priv, char *line);
34 typedef gpgme_error_t (*engine_command_handler_t) (void *priv,
35                                                    gpgme_status_code_t code,
36                                                    const char *keyword,
37                                                    int fd, int *processed);
38 typedef gpgme_error_t (*engine_assuan_result_cb_t) (void *priv,
39                                                     gpgme_error_t result);
40
41 /* Helper for gpgme_set_global_flag.  */
42 int _gpgme_set_engine_minimal_version (const char *value);
43
44 /* Get a deep copy of the engine info and return it in INFO.  */
45 gpgme_error_t _gpgme_engine_info_copy (gpgme_engine_info_t *r_info);
46
47 /* Release the engine info INFO.  */
48 void _gpgme_engine_info_release (gpgme_engine_info_t info);
49
50 /* Set the engine info for the info list INFO, protocol PROTO, to the
51    file name FILE_NAME and the home directory HOME_DIR.  */
52 gpgme_error_t _gpgme_set_engine_info (gpgme_engine_info_t info,
53                                       gpgme_protocol_t praoto,
54                                       const char *file_name,
55                                       const char *home_dir);
56
57
58 gpgme_error_t _gpgme_engine_new (gpgme_engine_info_t info,
59                                  engine_t *r_engine);
60 gpgme_error_t _gpgme_engine_reset (engine_t engine);
61
62 gpgme_error_t _gpgme_engine_set_locale (engine_t engine, int category,
63                                         const char *value);
64 gpgme_error_t _gpgme_engine_set_protocol (engine_t engine,
65                                           gpgme_protocol_t protocol);
66 void _gpgme_engine_release (engine_t engine);
67 void _gpgme_engine_set_status_cb (engine_t engine,
68                                   gpgme_status_cb_t cb, void *cb_value);
69 void _gpgme_engine_set_status_handler (engine_t engine,
70                                        engine_status_handler_t fnc,
71                                        void *fnc_value);
72 gpgme_error_t _gpgme_engine_set_command_handler (engine_t engine,
73                                                  engine_command_handler_t fnc,
74                                                  void *fnc_value,
75                                                  gpgme_data_t data);
76 gpgme_error_t
77 _gpgme_engine_set_colon_line_handler (engine_t engine,
78                                       engine_colon_line_handler_t fnc,
79                                       void *fnc_value);
80 gpgme_error_t _gpgme_engine_op_decrypt (engine_t engine, gpgme_data_t ciph,
81                                         gpgme_data_t plain);
82 gpgme_error_t _gpgme_engine_op_decrypt_verify (engine_t engine,
83                                                gpgme_data_t ciph,
84                                                gpgme_data_t plain);
85 gpgme_error_t _gpgme_engine_op_delete (engine_t engine, gpgme_key_t key,
86                                        int allow_secret);
87 gpgme_error_t _gpgme_engine_op_edit (engine_t engine, int type,
88                                      gpgme_key_t key, gpgme_data_t out,
89                                      gpgme_ctx_t ctx /* FIXME */);
90 gpgme_error_t _gpgme_engine_op_encrypt (engine_t engine,
91                                         gpgme_key_t recp[],
92                                         gpgme_encrypt_flags_t flags,
93                                         gpgme_data_t plain, gpgme_data_t ciph,
94                                         int use_armor);
95 gpgme_error_t _gpgme_engine_op_encrypt_sign (engine_t engine,
96                                              gpgme_key_t recp[],
97                                              gpgme_encrypt_flags_t flags,
98                                              gpgme_data_t plain,
99                                              gpgme_data_t ciph,
100                                              int use_armor,
101                                              gpgme_ctx_t ctx /* FIXME */);
102 gpgme_error_t _gpgme_engine_op_export (engine_t engine, const char *pattern,
103                                        gpgme_export_mode_t mode,
104                                        gpgme_data_t keydata, int use_armor);
105 gpgme_error_t _gpgme_engine_op_export_ext (engine_t engine,
106                                            const char *pattern[],
107                                            gpgme_export_mode_t mode,
108                                            gpgme_data_t keydata,
109                                            int use_armor);
110 gpgme_error_t _gpgme_engine_op_genkey (engine_t engine,
111                                        const char *userid, const char *algo,
112                                        unsigned long reserved,
113                                        unsigned long expires,
114                                        gpgme_key_t key, unsigned int flags,
115                                        gpgme_data_t help_data,
116                                        int use_armor, gpgme_data_t pubkey,
117                                        gpgme_data_t seckey);
118 gpgme_error_t _gpgme_engine_op_import (engine_t engine,
119                                        gpgme_data_t keydata,
120                                        gpgme_key_t *keyarray);
121 gpgme_error_t _gpgme_engine_op_keylist (engine_t engine,
122                                         const char *pattern,
123                                         int secret_only,
124                                         gpgme_keylist_mode_t mode,
125                                         int engine_flags);
126 gpgme_error_t _gpgme_engine_op_keylist_ext (engine_t engine,
127                                             const char *pattern[],
128                                             int secret_only,
129                                             int reserved,
130                                             gpgme_keylist_mode_t mode,
131                                             int engine_flags);
132 gpgme_error_t _gpgme_engine_op_sign (engine_t engine, gpgme_data_t in,
133                                      gpgme_data_t out, gpgme_sig_mode_t mode,
134                                      int use_armor, int use_textmode,
135                                      int include_certs,
136                                      gpgme_ctx_t ctx /* FIXME */);
137 gpgme_error_t _gpgme_engine_op_trustlist (engine_t engine,
138                                           const char *pattern);
139 gpgme_error_t _gpgme_engine_op_verify (engine_t engine, gpgme_data_t sig,
140                                        gpgme_data_t signed_text,
141                                        gpgme_data_t plaintext);
142
143 gpgme_error_t _gpgme_engine_op_getauditlog (engine_t engine,
144                                             gpgme_data_t output,
145                                             unsigned int flags);
146 gpgme_error_t _gpgme_engine_op_assuan_transact
147                 (engine_t engine,
148                  const char *command,
149                  gpgme_assuan_data_cb_t data_cb,
150                  void *data_cb_value,
151                  gpgme_assuan_inquire_cb_t inq_cb,
152                  void *inq_cb_value,
153                  gpgme_assuan_status_cb_t status_cb,
154                  void *status_cb_value);
155
156 gpgme_error_t _gpgme_engine_op_conf_load (engine_t engine,
157                                           gpgme_conf_comp_t *conf_p);
158 gpgme_error_t _gpgme_engine_op_conf_save (engine_t engine,
159                                           gpgme_conf_comp_t conf);
160
161 void _gpgme_engine_set_io_cbs (engine_t engine,
162                                gpgme_io_cbs_t io_cbs);
163 void _gpgme_engine_io_event (engine_t engine,
164                              gpgme_event_io_t type, void *type_data);
165
166 gpgme_error_t _gpgme_engine_cancel (engine_t engine);
167
168 gpgme_error_t _gpgme_engine_cancel_op (engine_t engine);
169
170 gpgme_error_t _gpgme_engine_op_passwd (engine_t engine, gpgme_key_t key,
171                                        unsigned int flags);
172
173 gpgme_error_t _gpgme_engine_set_pinentry_mode (engine_t engine,
174                                                gpgme_pinentry_mode_t mode);
175
176 gpgme_error_t _gpgme_engine_op_spawn (engine_t engine,
177                                       const char *file, const char *argv[],
178                                       gpgme_data_t datain,
179                                       gpgme_data_t dataout,
180                                       gpgme_data_t dataerr,
181                                       unsigned int flags);
182
183 /* The available engine option flags.  */
184 #define GPGME_ENGINE_FLAG_OFFLINE        1
185
186
187 #endif /* ENGINE_H */