command.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. #ifndef LIBDPKG_COMMAND_H
  21. #define LIBDPKG_COMMAND_H
  22. #include <dpkg/macros.h>
  23. DPKG_BEGIN_DECLS
  24. /**
  25. * @defgroup command Command execution
  26. * @ingroup dpkg-internal
  27. * @{
  28. */
  29. /**
  30. * Describe a command to execute.
  31. */
  32. struct command {
  33. /** Descriptive name of the command, used when printing. */
  34. const char *name;
  35. /** Filename to execute; either a path or the progname. */
  36. const char *filename;
  37. int argc;
  38. int argv_size;
  39. const char **argv;
  40. };
  41. void command_init(struct command *cmd, const char *filename, const char *name);
  42. void command_destroy(struct command *cmd);
  43. void command_add_arg(struct command *cmd, const char *arg);
  44. void command_add_argl(struct command *cmd, const char **argv);
  45. void command_add_argv(struct command *cmd, va_list args);
  46. void command_add_args(struct command *cmd, ...) DPKG_ATTR_SENTINEL;
  47. void command_exec(struct command *cmd) DPKG_ATTR_NORET;
  48. void runcmd(struct command *cmd) DPKG_ATTR_NORET;
  49. const char *command_get_pager(void);
  50. void command_shell(const char *cmd, const char *name) DPKG_ATTR_NORET;
  51. /** @} */
  52. DPKG_END_DECLS
  53. #endif /* LIBDPKG_COMMAND_H */