Translate the oktext (yes/no).
[gnupg.git] / common / exechelp.h
blob0ad956f7a46636d1df78b93b2a939c6b86c9d1eb
1 /* exechelp.h - Definitions for the fork and exec helpers
2 * Copyright (C) 2004 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 GNUPG_COMMON_EXECHELP_H
21 #define GNUPG_COMMON_EXECHELP_H
24 /* Portable function to create a pipe. Under Windows the write end is
25 inheritable. */
26 gpg_error_t gnupg_create_inbound_pipe (int filedes[2]);
29 /* Fork and exec the PGMNAME, connect the file descriptor of INFILE to
30 stdin, write the output to OUTFILE, return a new stream in
31 STATUSFILE for stderr and the pid of the process in PID. The
32 arguments for the process are expected in the NULL terminated array
33 ARGV. The program name itself should not be included there. If
34 PREEXEC is not NULL, that function will be called right before the
35 exec. FLAGS is currently only useful for W32, see the source for
36 details. Calling gnupg_wait_process is required. Returns 0 on
37 success or an error code. */
38 gpg_error_t gnupg_spawn_process (const char *pgmname, const char *argv[],
39 FILE *infile, FILE *outfile,
40 void (*preexec)(void), unsigned int flags,
41 FILE **statusfile, pid_t *pid);
44 /* Simplified version of gnupg_spawn_process. This function forks and
45 then execs PGMNAME, while connecting INFD to stdin, OUTFD to stdout
46 and ERRFD to stderr (any of them may be -1 to connect them to
47 /dev/null). The arguments for the process are expected in the NULL
48 terminated array ARGV. The program name itself should not be
49 included there. Calling gnupg_wait_process is required. Returns 0
50 on success or an error code. */
51 gpg_error_t gnupg_spawn_process_fd (const char *pgmname,
52 const char *argv[],
53 int infd, int outfd, int errfd,
54 pid_t *pid);
57 /* Wait for the process identified by PID to terminate. PGMNAME should
58 be the same as supplied to the spawn fucntion and is only used for
59 diagnostics. Returns 0 if the process succeded, GPG_ERR_GENERAL
60 for any failures of the spawned program or other error codes. If
61 EXITCODE is not NULL the exit code of the process is stored at this
62 address or -1 if it could not be retrieved. */
63 gpg_error_t gnupg_wait_process (const char *pgmname, pid_t pid, int *exitcode);
66 /* Spawn a new process and immediatley detach from it. The name of
67 the program to exec is PGMNAME and its arguments are in ARGV (the
68 programname is automatically passed as first argument).
69 Environment strings in ENVP are set. An error is returned if
70 pgmname is not executable; to make this work it is necessary to
71 provide an absolute file name. */
72 gpg_error_t gnupg_spawn_process_detached (const char *pgmname,
73 const char *argv[],
74 const char *envp[] );
78 #endif /*GNUPG_COMMON_EXECHELP_H*/