agent/
[gnupg.git] / g13 / runner.h
blobe68eca03a7d1b3fa8d52b9b271e69479ed287912
1 /* runner.h - Run and watch the backend engines
2 * Copyright (C) 2009 Free Software Foundation, Inc.
4 * This file is part of GnuPG.
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.
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.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #ifndef G13_RUNNER_H
21 #define G13_RUNNER_H
23 /* The runner object. */
24 struct runner_s;
25 typedef struct runner_s *runner_t;
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);
34 /* Return the number of active threads. */
35 unsigned int runner_get_threads (void);
37 /* Create a new runner object. */
38 gpg_error_t runner_new (runner_t *r_runner, const char *name);
40 /* Free a runner object. */
41 void runner_release (runner_t runner);
43 /* Return the identifier of RUNNER. */
44 unsigned int runner_get_rid (runner_t runner);
46 /* Find a runner by its rid. */
47 runner_t runner_find_by_rid (unsigned int rid);
49 /* Functions to set properties of the runner. */
50 void runner_set_fds (runner_t runner, int in_fd, int out_fd);
52 void runner_set_pid (runner_t runner, pid_t pid);
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);
60 /* Start the runner. */
61 gpg_error_t runner_spawn (runner_t runner);
63 /* Cancel a runner. */
64 void runner_cancel (runner_t runner);
66 /* Cancel all runner. */
67 void runner_cancel_all (void);
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);
76 #endif /*G13_RUNNER_H*/