libdebian-installer

exec.h

00001 /*
00002  * exec.h
00003  *
00004  * Copyright (C) 2003 Bastian Blank <waldi@debian.org>
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00018  */
00019 
00020 #ifndef DEBIAN_INSTALLER__EXEC_H
00021 #define DEBIAN_INSTALLER__EXEC_H
00022 
00023 #include <debian-installer/types.h>
00024 
00025 #include <sys/types.h>
00026 #include <sys/wait.h>
00027 #include <unistd.h>
00028 
00034 di_io_handler
00038   di_exec_io_log;
00039 di_process_handler
00045   di_exec_prepare_chdir,
00051   di_exec_prepare_chroot;
00052 
00068 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);
00069 
00078 static inline int di_exec (const char *path, const char *const argv[])
00079 {
00080   return di_exec_full (path, argv, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
00081 }
00082 
00099 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);
00100 
00110 static inline int di_exec_env (const char *path, const char *const argv[], const char *const envp[])
00111 {
00112   return di_exec_env_full (path, argv, envp, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
00113 }
00114 
00130 int di_exec_path_full (const char *file, 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);
00131 
00140 static inline int di_exec_path (const char *file, const char *const argv[])
00141 {
00142   return di_exec_path_full (file, argv, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
00143 }
00144 
00159 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);
00160 
00168 static inline int di_exec_shell (const char *const cmd)
00169 {
00170   return di_exec_shell_full (cmd, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
00171 }
00172 
00180 inline static int di_exec_shell_log (const char *const cmd)
00181 {
00182   return di_exec_shell_full (cmd, di_exec_io_log, NULL, NULL, NULL, NULL, NULL, NULL);
00183 }
00184 
00190 int di_exec_mangle_status (int status);
00191 
00196 inline static int di_execlog (const char *const cmd) __attribute__ ((deprecated));
00197 inline static int di_execlog (const char *const cmd)
00198 {
00199   return di_exec_shell_log (cmd);
00200 }
00201 
00203 #endif