command.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * libdpkg - Debian packaging suite library routines
  3. * command.h - command execution support
  4. *
  5. * Copyright © 2010 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 <http://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. * Describe a command to execute.
  26. */
  27. struct command {
  28. /** Descriptive name of the command, used when printing. */
  29. const char *name;
  30. /** Filename to execute; either a path or the progname. */
  31. const char *filename;
  32. int argc;
  33. int argv_size;
  34. const char **argv;
  35. };
  36. void command_init(struct command *cmd, const char *filename, const char *name);
  37. void command_destroy(struct command *cmd);
  38. void command_add_arg(struct command *cmd, const char *arg);
  39. void command_add_argl(struct command *cmd, const char **argv);
  40. void command_add_argv(struct command *cmd, va_list al);
  41. void command_add_args(struct command *cmd, ...) DPKG_ATTR_SENTINEL;
  42. void command_exec(struct command *cmd) DPKG_ATTR_NORET;
  43. DPKG_END_DECLS
  44. #endif /* LIBDPKG_COMMAND_H */