[libvtemm] Forking and pty adaptation for empty string terminated vector.
- From: Krzesimir Nowak <krnowak src gnome org>
- To: svn-commits-list gnome org
- Subject: [libvtemm] Forking and pty adaptation for empty string terminated vector.
- Date: Wed, 20 May 2009 15:13:41 -0400 (EDT)
commit 42b6c55061e3865370482c057de66c8a8b634141
Author: Krzesimir Nowak <krnowak svn gnome org>
Date: Wed May 20 09:33:49 2009 +0200
Forking and pty adaptation for empty string terminated vector.
* src/libvtemm/g/libvte_docs_override.xml: Added description of
StdStringArrayHandle parameters in fork_command and forkpty.
* src/libvtemm/internalroutines.cc: Modified it to cope with
empty string terminated StdStringArrayHandle, so now it can take
arguments from Glib::shell_parse_argv or user defined vectors.
* src/libvtemm/internalroutines.h: Documented them a bit.
* src/libvtemm/pty.h: Mentioned about argument formats.
---
src/libvtemm/g/libvte_docs_override.xml | 5 +++++
src/libvtemm/internalroutines.cc | 6 +++++-
src/libvtemm/internalroutines.h | 10 ++++++++++
src/libvtemm/pty.h | 4 ++--
4 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/src/libvtemm/g/libvte_docs_override.xml b/src/libvtemm/g/libvte_docs_override.xml
index 86a7bde..4a30a0c 100644
--- a/src/libvtemm/g/libvte_docs_override.xml
+++ b/src/libvtemm/g/libvte_docs_override.xml
@@ -191,6 +191,8 @@ Starts a new child process under a newly-allocated controlling
pseudo-terminal. TERM is automatically set to reflect the terminal widget's
emulation setting. If @lastlog, @utmp, or @wtmp are %true, logs the session
to the specified system log files.
+See Gnome::Vte::Terminal::fork_command() for description about format of @envv
+parameter.
</description>
@@ -233,6 +235,9 @@ pseudo-terminal. The argv[0] is expected to be the name of the file being run,
as it would be if execve() were being called. TERM is automatically set to
reflect the terminal widget's emulation setting. If @lastlog, @utmp, or
@wtmp are %true, logs the session to the specified system log files.
+ argv and @envv can be in two formats: with last string empty and with last
+string non-empty, so user-defined vector or result of #Glib::shell_parse_argv
+can be passed.
</description>
diff --git a/src/libvtemm/internalroutines.cc b/src/libvtemm/internalroutines.cc
index 7b6674b..32d65b8 100644
--- a/src/libvtemm/internalroutines.cc
+++ b/src/libvtemm/internalroutines.cc
@@ -39,11 +39,15 @@ get_c_string(const std::string& cpp_string)
char**
get_c_string_vector(const StdStringArrayHandle& cpp_string_vector)
{
- if (cpp_string_vector.empty())
+ if (cpp_string_vector.empty() || cpp_string_vector[0].empty())
{
return 0;
}
unsigned int cpp_string_vector_len = cpp_string_vector.size();
+ if (cpp_string_vector[cpp_string_vector_len - 1].empty())
+ {
+ cpp_string_vector_len--;
+ }
char** c_string_vector = reinterpret_cast<char**>(g_malloc0(cpp_string_vector_len + 1));
const char* const * temp_c_string_vector = cpp_string_vector.data();
for (unsigned int iter = 0; iter < cpp_string_vector_len; iter++)
diff --git a/src/libvtemm/internalroutines.h b/src/libvtemm/internalroutines.h
index 5d19c5d..c09ebeb 100644
--- a/src/libvtemm/internalroutines.h
+++ b/src/libvtemm/internalroutines.h
@@ -29,9 +29,19 @@ namespace Gnome
namespace Vte
{
+/* Returns a c string from std::string. If std::string is empty, returns 0.
+ * Returned string should not be modified nor freed manually.
+ */
const char*
get_c_string(const std::string& cpp_string);
+/* Returns a 0 terminated c string vector from StdStringArrayHandle. If
+ * StdStringArrayHandle has n strings and all of them are not empty, it will
+ * return c string vector with n + 1 strings, where last is 0. If
+ * StdStringArrayHandle has n strings and last string is empty, then it will
+ * return c string vector with n elements, where last is 0.
+ * Returned c string vector has to be freed with g_strfreev.
+ */
char**
get_c_string_vector(const StdStringArrayHandle& cpp_string_vector);
diff --git a/src/libvtemm/pty.h b/src/libvtemm/pty.h
index d2b5ba6..dff721a 100644
--- a/src/libvtemm/pty.h
+++ b/src/libvtemm/pty.h
@@ -38,9 +38,9 @@ namespace Pty
* side of the PTY pair, logging the session to the specified files, and
* storing the child's PID in the given argument.
* @param child Stored child's PID.
- * @param env_add Empty string terminated list of environment variables to be added before executing a command.
+ * @param env_add Empty string terminated list of environment variables to be added before executing a command. See Gnome::Vte::Terminal::fork_command() for description about format of this parameter.
* @param command Command to be executed (not interpreted at all). If empty, fork will be executed.
- * @param argv Empty string terminated list of arguments given to executed binary (argv[0] should be a binary name).
+ * @param argv Empty string terminated list of arguments given to executed binary (argv[0] should be a binary name). See Gnome::Vte::Terminal::fork_command() for description about format of this parameter.
* @param directory Path where command have to be executed. If empty, path will be inherited from parent.
* @param columns Number of columns of pty.
* @param rows Number of rows of pty.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]