chiark / gitweb /
asshelp.c: add a lot of debug logging
[gnupg2.git] / g13 / runner.h
1 /* runner.h - Run and watch the backend engines
2  * Copyright (C) 2009 Free Software Foundation, Inc.
3  *
4  * This file is part of GnuPG.
5  *
6  * GnuPG is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * GnuPG is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see <https://www.gnu.org/licenses/>.
18  */
19
20 #ifndef G13_RUNNER_H
21 #define G13_RUNNER_H
22
23 /* The runner object.  */
24 struct runner_s;
25 typedef struct runner_s *runner_t;
26
27 /* Prototypes for the handler functions provided by the engine.  */
28 typedef gpg_error_t (*engine_handler_fnc_t) (void *opaque,
29                                              runner_t runner,
30                                              const char *statusline);
31 typedef void (*engine_handler_cleanup_fnc_t) (void *opaque);
32
33
34 /* Return the number of active threads.  */
35 unsigned int runner_get_threads (void);
36
37 /* Create a new runner object.  */
38 gpg_error_t runner_new (runner_t *r_runner, const char *name);
39
40 /* Free a runner object.  */
41 void runner_release (runner_t runner);
42
43 /* Return the identifier of RUNNER.  */
44 unsigned int runner_get_rid (runner_t runner);
45
46 /* Find a runner by its rid.  */
47 runner_t runner_find_by_rid (unsigned int rid);
48
49 /* Functions to set properties of the runner.  */
50 void runner_set_fds (runner_t runner, int in_fd, int out_fd);
51
52 void runner_set_pid (runner_t runner, pid_t pid);
53
54 /* Register the handler functions with a runner.  */
55 void runner_set_handler (runner_t runner,
56                          engine_handler_fnc_t handler,
57                          engine_handler_cleanup_fnc_t handler_cleanup,
58                          void *handler_data);
59
60 /* Start the runner.  */
61 gpg_error_t runner_spawn (runner_t runner);
62
63 /* Cancel a runner.  */
64 void runner_cancel (runner_t runner);
65
66 /* Cancel all runner.  */
67 void runner_cancel_all (void);
68
69 /* Send data back to the engine.  This function is used by the
70    engine's handler.  */
71 gpg_error_t runner_send_line (runner_t runner,
72                               const void *data, size_t datalen);
73
74
75
76 #endif /*G13_RUNNER_H*/