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