2005-04-14 Marcus Brinkmann <marcus@g10code.de>
[gpgme.git] / gpgme / engine.h
1 /* engine.h - GPGME engine interface.
2    Copyright (C) 2000 Werner Koch (dd9jn)
3    Copyright (C) 2001, 2002, 2003, 2004 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);
38
39 /* Get a deep copy of the engine info and return it in INFO.  */
40 gpgme_error_t _gpgme_engine_info_copy (gpgme_engine_info_t *r_info);
41
42 /* Release the engine info INFO.  */
43 void _gpgme_engine_info_release (gpgme_engine_info_t info);
44
45
46 gpgme_error_t _gpgme_engine_new (gpgme_engine_info_t info,
47                                  engine_t *r_engine,
48                                  const char *lc_ctype,
49                                  const char *lc_messages);
50 void _gpgme_engine_release (engine_t engine);
51 void _gpgme_engine_set_status_handler (engine_t engine,
52                                        engine_status_handler_t fnc,
53                                        void *fnc_value);
54 gpgme_error_t _gpgme_engine_set_command_handler (engine_t engine,
55                                                  engine_command_handler_t fnc,
56                                                  void *fnc_value,
57                                                  gpgme_data_t data);
58 gpgme_error_t
59 _gpgme_engine_set_colon_line_handler (engine_t engine,
60                                       engine_colon_line_handler_t fnc,
61                                       void *fnc_value);
62 gpgme_error_t _gpgme_engine_op_decrypt (engine_t engine,
63                                         gpgme_data_t ciph,
64                                         gpgme_data_t plain);
65 gpgme_error_t _gpgme_engine_op_delete (engine_t engine, gpgme_key_t key,
66                                        int allow_secret);
67 gpgme_error_t _gpgme_engine_op_edit (engine_t engine, int type,
68                                      gpgme_key_t key, gpgme_data_t out,
69                                      gpgme_ctx_t ctx /* FIXME */);
70 gpgme_error_t _gpgme_engine_op_encrypt (engine_t engine,
71                                         gpgme_key_t recp[],
72                                         gpgme_encrypt_flags_t flags,
73                                         gpgme_data_t plain, gpgme_data_t ciph,
74                                         int use_armor);
75 gpgme_error_t _gpgme_engine_op_encrypt_sign (engine_t engine,
76                                              gpgme_key_t recp[],
77                                              gpgme_encrypt_flags_t flags,
78                                              gpgme_data_t plain,
79                                              gpgme_data_t ciph,
80                                              int use_armor,
81                                              gpgme_ctx_t ctx /* FIXME */);
82 gpgme_error_t _gpgme_engine_op_export (engine_t engine, const char *pattern,
83                                        unsigned int reserved,
84                                        gpgme_data_t keydata, int use_armor);
85 gpgme_error_t _gpgme_engine_op_export_ext (engine_t engine,
86                                            const char *pattern[],
87                                            unsigned int reserved,
88                                            gpgme_data_t keydata,
89                                            int use_armor);
90 gpgme_error_t _gpgme_engine_op_genkey (engine_t engine,
91                                        gpgme_data_t help_data,
92                                        int use_armor, gpgme_data_t pubkey,
93                                        gpgme_data_t seckey);
94 gpgme_error_t _gpgme_engine_op_import (engine_t engine,
95                                        gpgme_data_t keydata);
96 gpgme_error_t _gpgme_engine_op_keylist (engine_t engine,
97                                         const char *pattern,
98                                         int secret_only,
99                                         gpgme_keylist_mode_t mode);
100 gpgme_error_t _gpgme_engine_op_keylist_ext (engine_t engine,
101                                             const char *pattern[],
102                                             int secret_only,
103                                             int reserved,
104                                             gpgme_keylist_mode_t mode);
105 gpgme_error_t _gpgme_engine_op_sign (engine_t engine, gpgme_data_t in,
106                                      gpgme_data_t out, gpgme_sig_mode_t mode,
107                                      int use_armor, int use_textmode,
108                                      int include_certs,
109                                      gpgme_ctx_t ctx /* FIXME */);
110 gpgme_error_t _gpgme_engine_op_trustlist (engine_t engine,
111                                           const char *pattern);
112 gpgme_error_t _gpgme_engine_op_verify (engine_t engine, gpgme_data_t sig,
113                                        gpgme_data_t signed_text,
114                                        gpgme_data_t plaintext);
115
116 void _gpgme_engine_set_io_cbs (engine_t engine,
117                                gpgme_io_cbs_t io_cbs);
118 void _gpgme_engine_io_event (engine_t engine,
119                              gpgme_event_io_t type, void *type_data);
120
121 gpgme_error_t _gpgme_engine_cancel (engine_t engine);
122
123 #endif /* ENGINE_H */