summaryrefslogtreecommitdiff
path: root/ace/Process.cpp
diff options
context:
space:
mode:
authorjxh <jxh@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-05-13 18:30:13 +0000
committerjxh <jxh@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-05-13 18:30:13 +0000
commit20c9bc3b8e21286571132c1adbec743cec2506f1 (patch)
treef81b3462bc47ab64a22b692154cc5d9fb6c06940 /ace/Process.cpp
parentbdb8a0a0bfa6c2ffa51cdad6aaf0b615a8238ed7 (diff)
downloadATCD-20c9bc3b8e21286571132c1adbec743cec2506f1.tar.gz
Implemented new ACE_Process interfaces for argv style parameters.
Diffstat (limited to 'ace/Process.cpp')
-rw-r--r--ace/Process.cpp61
1 files changed, 53 insertions, 8 deletions
diff --git a/ace/Process.cpp b/ace/Process.cpp
index 5fcc11a6c36..8cee08a789a 100644
--- a/ace/Process.cpp
+++ b/ace/Process.cpp
@@ -605,15 +605,28 @@ ACE_Process_Options::inherit_environment (void)
#endif /* ACE_WIN32 */
int
-ACE_Process_Options::setenv (char *[])
+ACE_Process_Options::setenv (char *envp[])
{
- ACE_ERROR_RETURN ((LM_ERROR, "ACE_Process_Options::setenv not implemented.\n"), -1);
+ int i = 0;
+ while (envp[i])
+ {
+ if (this->setenv_i (envp[i], ACE_OS::strlen (envp[i])) == -1)
+ return -1;
+ i++;
+ }
+
+#if defined (ACE_WIN32)
+ if (inherit_environment_)
+ this->inherit_environment ();
+#endif /* ACE_WIN32 */
+
+ return 0;
}
int
ACE_Process_Options::setenv (const char *format, ...)
{
- char stack_buf[1024];
+ char stack_buf[DEFAULT_COMMAND_LINE_BUF_LEN];
// Start varargs.
va_list argp;
@@ -641,13 +654,33 @@ int
ACE_Process_Options::setenv (const char *variable_name,
const char *format, ...)
{
- char newformat[1024];
+ char newformat[DEFAULT_COMMAND_LINE_BUF_LEN];
// Add in the variable name.
ACE_OS::sprintf (newformat, "%s=%s", variable_name, format);
- // Delegate.
- return this->setenv (newformat);
+ char stack_buf[DEFAULT_COMMAND_LINE_BUF_LEN];
+
+ // Start varargs.
+ va_list argp;
+ va_start (argp, format);
+
+ // Add the rest of the varargs.
+ ::vsprintf (stack_buf, newformat, argp);
+
+ // End varargs.
+ va_end (argp);
+
+ // Append the string to our environment buffer.
+ if (this->setenv_i (stack_buf, ACE_OS::strlen (stack_buf)) == -1)
+ return -1;
+
+#if defined (ACE_WIN32)
+ if (inherit_environment_)
+ this->inherit_environment ();
+#endif /* ACE_WIN32 */
+
+ return 0;
}
int
@@ -746,9 +779,21 @@ ACE_Process_Options::set_handles (ACE_HANDLE std_in,
}
int
-ACE_Process_Options::command_line (char *[])
+ACE_Process_Options::command_line (char *argv[])
{
- ACE_ERROR_RETURN ((LM_ERROR, "ACE_Process_Options::command_line not implemented.\n"), -1);
+ int i;
+
+ if (argv[i = 0])
+ {
+ ACE_OS::strcat (command_line_buf_, argv[i]);
+ while (argv[++i])
+ {
+ ACE_OS::strcat (command_line_buf_, " ");
+ ACE_OS::strcat (command_line_buf_, argv[i]);
+ }
+ }
+
+ return 0; // Success.
}
int