~ubuntu-branches/ubuntu/feisty/libdebian-installer/feisty

« back to all changes in this revision

Viewing changes to include/debian-installer/exec.h

  • Committer: Bazaar Package Importer
  • Author(s): Joey Hess
  • Date: 2004-06-15 12:41:12 UTC
  • Revision ID: james.westby@ubuntu.com-20040615124112-irrmriyd8d6s067u
Tags: 0.29
* Joey Hess
  - Re-enable character device mapping. Though it often gets it wrong, the
    cases where it gets it right are used by prebaseconfig.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * exec.h
 
3
 *
 
4
 * Copyright (C) 2003 Bastian Blank <waldi@debian.org>
 
5
 *
 
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.
 
10
 *
 
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.
 
15
 *
 
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.
 
19
 *
 
20
 * $Id: exec.h 14853 2004-05-05 16:23:07Z waldi $
 
21
 */
 
22
 
 
23
#ifndef DEBIAN_INSTALLER__EXEC_H
 
24
#define DEBIAN_INSTALLER__EXEC_H
 
25
 
 
26
#include <debian-installer/types.h>
 
27
 
 
28
#include <sys/types.h>
 
29
#include <sys/wait.h>
 
30
#include <unistd.h>
 
31
 
 
32
/**
 
33
 * @addtogroup di_exec
 
34
 * @{
 
35
 */
 
36
 
 
37
di_io_handler
 
38
  /**
 
39
   * logs the output
 
40
   */
 
41
  di_exec_io_log;
 
42
di_process_handler
 
43
  /**
 
44
   * chdir to user_data
 
45
   *
 
46
   * @param user_data path
 
47
   */
 
48
  di_exec_prepare_chdir,
 
49
  /**
 
50
   * chroot to user_data
 
51
   *
 
52
   * @param user_data path
 
53
   */
 
54
  di_exec_prepare_chroot;
 
55
 
 
56
/**
 
57
 * execve like call
 
58
 *
 
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
 
69
 *
 
70
 * @return status or error
 
71
 */
 
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);
 
73
 
 
74
/**
 
75
 * execve like call
 
76
 *
 
77
 * @param path executable with path
 
78
 * @param argv NULL-terminated area of char pointer
 
79
 * @param envp NULL-terminated area of char pointer
 
80
 *
 
81
 * @return status or error
 
82
 */
 
83
static inline int di_exec_env (const char *path, const char *const argv[], const char *const envp[])
 
84
{
 
85
  return di_exec_env_full (path, argv, envp, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
86
}
 
87
 
 
88
/**
 
89
 * execv like call
 
90
 *
 
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
 
100
 *
 
101
 * @return status or error
 
102
 */
 
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);
 
104
 
 
105
/**
 
106
 * execv like call
 
107
 *
 
108
 * @param path executable with path
 
109
 * @param argv NULL-terminated area of char pointer
 
110
 *
 
111
 * @return status or error
 
112
 */
 
113
static inline int di_exec (const char *path, const char *const argv[])
 
114
{
 
115
  return di_exec_full (path, argv, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
116
}
 
117
 
 
118
/**
 
119
 * system like call
 
120
 *
 
121
 * @param cmd command
 
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
 
129
 *
 
130
 * @return status or error
 
131
 */
 
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);
 
133
 
 
134
/**
 
135
 * system like call
 
136
 *
 
137
 * @param cmd command
 
138
 *
 
139
 * @return status or error
 
140
 */
 
141
static inline int di_exec_shell (const char *const cmd)
 
142
{
 
143
  return di_exec_shell_full (cmd, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
144
}
 
145
 
 
146
/**
 
147
 * system like call with output via log
 
148
 *
 
149
 * @param cmd command
 
150
 *
 
151
 * @return status or error
 
152
 */
 
153
inline static int di_exec_shell_log (const char *const cmd)
 
154
{
 
155
  return di_exec_shell_full (cmd, di_exec_io_log, NULL, NULL, NULL, NULL, NULL, NULL);
 
156
}
 
157
 
 
158
/**
 
159
 * mangle status like sh does it:
 
160
 * * if signaled: 128 + signal
 
161
 * * else return code
 
162
 */
 
163
int di_exec_mangle_status (int status);
 
164
 
 
165
/**
 
166
 * @deprecated
 
167
 * Alias of di_exec_shell_log
 
168
 */
 
169
inline static int di_execlog (const char *const cmd) __attribute__ ((deprecated));
 
170
inline static int di_execlog (const char *const cmd)
 
171
{
 
172
  return di_exec_shell_log (cmd);
 
173
}
 
174
 
 
175
/** @} */
 
176
#endif