Commit | Line | Data |
---|---|---|
1479465f GJ |
1 | /* |
2 | * libdpkg - Debian packaging suite library routines | |
3 | * command.h - command execution support | |
4 | * | |
5 | * Copyright © 2010, 2012, 2015 Guillem Jover <guillem@debian.org> | |
6 | * | |
7 | * This is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published by | |
9 | * the Free Software Foundation; either version 2 of the License, or | |
10 | * (at your option) any later version. | |
11 | * | |
12 | * This is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | |
19 | */ | |
20 | ||
21 | #ifndef LIBDPKG_COMMAND_H | |
22 | #define LIBDPKG_COMMAND_H | |
23 | ||
24 | #include <dpkg/macros.h> | |
25 | ||
26 | DPKG_BEGIN_DECLS | |
27 | ||
28 | /** | |
29 | * @defgroup command Command execution | |
30 | * @ingroup dpkg-internal | |
31 | * @{ | |
32 | */ | |
33 | ||
34 | /** | |
35 | * Describe a command to execute. | |
36 | */ | |
37 | struct command { | |
38 | /** Descriptive name of the command, used when printing. */ | |
39 | const char *name; | |
40 | /** Filename to execute; either a path or the progname. */ | |
41 | const char *filename; | |
42 | int argc; | |
43 | int argv_size; | |
44 | const char **argv; | |
45 | }; | |
46 | ||
47 | void command_init(struct command *cmd, const char *filename, const char *name); | |
48 | void command_destroy(struct command *cmd); | |
49 | ||
50 | void command_add_arg(struct command *cmd, const char *arg); | |
51 | void command_add_argl(struct command *cmd, const char **argv); | |
52 | void command_add_argv(struct command *cmd, va_list args); | |
53 | void command_add_args(struct command *cmd, ...) DPKG_ATTR_SENTINEL; | |
54 | ||
55 | void command_exec(struct command *cmd) DPKG_ATTR_NORET; | |
56 | ||
57 | const char *command_get_pager(void); | |
58 | void command_shell(const char *cmd, const char *name) DPKG_ATTR_NORET; | |
59 | ||
60 | /** @} */ | |
61 | ||
62 | DPKG_END_DECLS | |
63 | ||
64 | #endif /* LIBDPKG_COMMAND_H */ |