summaryrefslogtreecommitdiff
path: root/apt-private/private-utils.cc
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2013-11-29 13:39:45 +0100
committerMichael Vogt <mvo@debian.org>2013-11-29 13:39:45 +0100
commite4a93f90b2e50f6833f7146496e574a5a9cedaca (patch)
tree836dd5e70b394f9996d4af0bdfcd52d2a388a007 /apt-private/private-utils.cc
parentfdef7c5e3a19c5f35ee952598124d0fe8d03c7ec (diff)
parentfaeb435cab7b41a50c621ef9f96853d15c57d0d8 (diff)
Merge remote-tracking branch 'mvo/debian/sid' into debian/sid
Conflicts: apt-private/private-cmndline.cc
Diffstat (limited to 'apt-private/private-utils.cc')
-rw-r--r--apt-private/private-utils.cc50
1 files changed, 50 insertions, 0 deletions
diff --git a/apt-private/private-utils.cc b/apt-private/private-utils.cc
new file mode 100644
index 000000000..813f19329
--- /dev/null
+++ b/apt-private/private-utils.cc
@@ -0,0 +1,50 @@
+#include <cstdlib>
+
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/fileutl.h>
+#include "private-utils.h"
+
+
+// DisplayFileInPager - Display File with pager /*{{{*/
+void DisplayFileInPager(std::string filename)
+{
+ std::string pager = _config->Find("Dir::Bin::Pager",
+ "/usr/bin/sensible-pager");
+
+ pid_t Process = ExecFork();
+ if (Process == 0)
+ {
+ const char *Args[3];
+ Args[0] = pager.c_str();
+ Args[1] = filename.c_str();
+ Args[2] = 0;
+ execvp(Args[0],(char **)Args);
+ exit(100);
+ }
+
+ // Wait for the subprocess
+ ExecWait(Process, "sensible-pager", false);
+}
+ /*}}}*/
+
+// EditFileInSensibleEditor - Edit File with editor /*{{{*/
+void EditFileInSensibleEditor(std::string filename)
+{
+ std::string editor = _config->Find("Dir::Bin::Editor",
+ "/usr/bin/sensible-editor");
+
+ pid_t Process = ExecFork();
+ if (Process == 0)
+ {
+ const char *Args[3];
+ Args[0] = editor.c_str();
+ Args[1] = filename.c_str();
+ Args[2] = 0;
+ execvp(Args[0],(char **)Args);
+ exit(100);
+ }
+
+ // Wait for the subprocess
+ ExecWait(Process, "sensible-editor", false);
+}
+ /*}}}*/