4
* Copyright (C) 2003 Bastian Blank <waldi@debian.org>
6
* This program 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 2 of the License, or
9
* (at your option) any later version.
11
* This program 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, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
* $Id: exec.h 14853 2004-05-05 16:23:07Z waldi $
23
#ifndef DEBIAN_INSTALLER__EXEC_H
24
#define DEBIAN_INSTALLER__EXEC_H
26
#include <debian-installer/types.h>
28
#include <sys/types.h>
46
* @param user_data path
48
di_exec_prepare_chdir,
52
* @param user_data path
54
di_exec_prepare_chroot;
59
* @param path executable with path
60
* @param argv NULL-terminated area of char pointer
61
* @param envp NULL-terminated area of char pointer
62
* @param stdout_handler di_io_handler which gets stdout (and to stderr if stderr_handler is NULL)
63
* @param stderr_handler di_io_handler which gets stderr
64
* @param io_user_data user_data for di_io_handler
65
* @param parent_prepare_handler di_process_handler which is called after the fork in the parent
66
* @param parent_prepare_user_data user_data for parent_prepare_handler
67
* @param child_prepare_handler di_process_handler which is called after the fork in the child
68
* @param child_prepare_user_data user_data for child_prepare_handler
70
* @return status or error
72
int di_exec_env_full (const char *path, const char *const argv[], const char *const envp[], di_io_handler *stdout_handler, di_io_handler *stderr_handler, void *io_user_data, di_process_handler *parent_prepare_handler, void *parent_prepare_user_data, di_process_handler *child_prepare_handler, void *child_prepare_user_data);
77
* @param path executable with path
78
* @param argv NULL-terminated area of char pointer
79
* @param envp NULL-terminated area of char pointer
81
* @return status or error
83
static inline int di_exec_env (const char *path, const char *const argv[], const char *const envp[])
85
return di_exec_env_full (path, argv, envp, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
91
* @param path executable with path
92
* @param argv NULL-terminated area of char pointer
93
* @param stdout_handler di_io_handler which gets stdout (and to stderr if stderr_handler is NULL)
94
* @param stderr_handler di_io_handler which gets stderr
95
* @param io_user_data user_data for di_io_handler
96
* @param parent_prepare_handler di_process_handler which is called after the fork in the parent
97
* @param parent_prepare_user_data user_data for parent_prepare_handler
98
* @param child_prepare_handler di_process_handler which is called after the fork in the child
99
* @param child_prepare_user_data user_data for child_prepare_handler
101
* @return status or error
103
int di_exec_full (const char *path, const char *const argv[], di_io_handler *stdout_handler, di_io_handler *stderr_handler, void *io_user_data, di_process_handler *parent_prepare_handler, void *parent_prepare_user_data, di_process_handler *child_prepare_handler, void *child_prepare_user_data);
108
* @param path executable with path
109
* @param argv NULL-terminated area of char pointer
111
* @return status or error
113
static inline int di_exec (const char *path, const char *const argv[])
115
return di_exec_full (path, argv, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
122
* @param stdout_handler di_io_handler which gets stdout
123
* @param stderr_handler di_io_handler which gets stderr
124
* @param io_user_data user_data for di_io_handler
125
* @param parent_prepare_handler di_process_handler which is called after the fork in the parent
126
* @param parent_prepare_user_data user_data for parent_prepare_handler
127
* @param child_prepare_handler di_process_handler which is called after the fork in the child
128
* @param child_prepare_user_data user_data for child_prepare_handler
130
* @return status or error
132
int di_exec_shell_full (const char *const cmd, di_io_handler *stdout_handler, di_io_handler *stderr_handler, void *io_user_data, di_process_handler *parent_prepare_handler, void *parent_prepare_user_data, di_process_handler *child_prepare_handler, void *child_prepare_user_data);
139
* @return status or error
141
static inline int di_exec_shell (const char *const cmd)
143
return di_exec_shell_full (cmd, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
147
* system like call with output via log
151
* @return status or error
153
inline static int di_exec_shell_log (const char *const cmd)
155
return di_exec_shell_full (cmd, di_exec_io_log, NULL, NULL, NULL, NULL, NULL, NULL);
159
* mangle status like sh does it:
160
* * if signaled: 128 + signal
163
int di_exec_mangle_status (int status);
167
* Alias of di_exec_shell_log
169
inline static int di_execlog (const char *const cmd) __attribute__ ((deprecated));
170
inline static int di_execlog (const char *const cmd)
172
return di_exec_shell_log (cmd);