private-utils.cc 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include <cstdlib>
  2. #include <apt-pkg/configuration.h>
  3. #include <apt-pkg/fileutl.h>
  4. #include "private-utils.h"
  5. // DisplayFileInPager - Display File with pager /*{{{*/
  6. void DisplayFileInPager(std::string filename)
  7. {
  8. std::string pager = _config->Find("Dir::Bin::Pager",
  9. "/usr/bin/sensible-pager");
  10. pid_t Process = ExecFork();
  11. if (Process == 0)
  12. {
  13. const char *Args[3];
  14. Args[0] = pager.c_str();
  15. Args[1] = filename.c_str();
  16. Args[2] = 0;
  17. execvp(Args[0],(char **)Args);
  18. exit(100);
  19. }
  20. // Wait for the subprocess
  21. ExecWait(Process, "sensible-pager", false);
  22. }
  23. /*}}}*/
  24. // EditFileInSensibleEditor - Edit File with editor /*{{{*/
  25. void EditFileInSensibleEditor(std::string filename)
  26. {
  27. std::string editor = _config->Find("Dir::Bin::Editor",
  28. "/usr/bin/sensible-editor");
  29. pid_t Process = ExecFork();
  30. if (Process == 0)
  31. {
  32. const char *Args[3];
  33. Args[0] = editor.c_str();
  34. Args[1] = filename.c_str();
  35. Args[2] = 0;
  36. execvp(Args[0],(char **)Args);
  37. exit(100);
  38. }
  39. // Wait for the subprocess
  40. ExecWait(Process, "sensible-editor", false);
  41. }
  42. /*}}}*/