summaryrefslogtreecommitdiff
path: root/ace/OS_NS_unistd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ace/OS_NS_unistd.cpp')
-rw-r--r--ace/OS_NS_unistd.cpp153
1 files changed, 12 insertions, 141 deletions
diff --git a/ace/OS_NS_unistd.cpp b/ace/OS_NS_unistd.cpp
index b39f0e527e3..3c3c2ecd823 100644
--- a/ace/OS_NS_unistd.cpp
+++ b/ace/OS_NS_unistd.cpp
@@ -54,7 +54,7 @@ ACE_OS::argv_to_string (ACE_TCHAR **argv,
// Account for environment variables.
if (substitute_env_args && argv[i][0] == ACE_LIB_TEXT ('$'))
{
-# if defined (ACE_WIN32) || !defined (ACE_HAS_WCHAR)
+# if defined (ACE_WIN32)
ACE_TCHAR *temp = 0;
// Win32 is the only platform with a wide-char ACE_OS::getenv().
if ((temp = ACE_OS::getenv (&argv[i][1])) != 0)
@@ -62,17 +62,17 @@ ACE_OS::argv_to_string (ACE_TCHAR **argv,
else
buf_len += ACE_OS::strlen (argv[i]);
# else
- // This is an ACE_HAS_WCHAR platform and not ACE_WIN32.
+ // This is not ACE_WIN32.
// Convert the env variable name for getenv(), then add
// the length of the returned char *string. Later, when we
// actually use the returned env variable value, convert it
// as well.
- char *ctemp = ACE_OS::getenv (ACE_TEXT_ALWAYS_CHAR (&argv[i][1]));
+ char *ctemp = ACE_OS::getenv (ACE_TEXT_TO_CHAR_IN (&argv[i][1]));
if (ctemp == 0)
buf_len += ACE_OS::strlen (argv[i]);
else
buf_len += ACE_OS::strlen (ctemp);
-# endif /* ACE_WIN32 || !ACE_HAS_WCHAR */
+# endif /* ACE_WIN32 */
}
else
#endif /* ACE_LACKS_ENV */
@@ -101,7 +101,7 @@ ACE_OS::argv_to_string (ACE_TCHAR **argv,
// Account for environment variables.
if (substitute_env_args && argv[j][0] == ACE_LIB_TEXT ('$'))
{
-# if defined (ACE_WIN32) || !defined (ACE_HAS_WCHAR)
+# if defined (ACE_WIN32)
// Win32 is the only platform with a wide-char ACE_OS::getenv().
ACE_TCHAR *temp = ACE_OS::getenv (&argv[j][1]);
if (temp != 0)
@@ -109,15 +109,15 @@ ACE_OS::argv_to_string (ACE_TCHAR **argv,
else
end = ACE_OS::strecpy (end, argv[j]);
# else
- // This is an ACE_HAS_WCHAR platform and not ACE_WIN32.
+ // This is not ACE_WIN32.
// Convert the env variable name for getenv(), then convert
// the returned char *string back to wchar_t.
- char *ctemp = ACE_OS::getenv (ACE_TEXT_ALWAYS_CHAR (&argv[j][1]));
+ char *ctemp = ACE_OS::getenv (ACE_TEXT_TO_CHAR_IN (&argv[j][1]));
if (ctemp == 0)
end = ACE_OS::strecpy (end, argv[j]);
else
- end = ACE_OS::strecpy (end, ACE_TEXT_CHAR_TO_TCHAR (ctemp));
-# endif /* ACE_WIN32 || !ACE_HAS_WCHAR */
+ end = ACE_OS::strecpy (end, ACE_TEXT_TO_TCHAR_IN (ctemp));
+# endif /* ACE_WIN32 */
}
else
#endif /* ACE_LACKS_ENV */
@@ -248,7 +248,7 @@ ACE_OS::fork_exec (ACE_TCHAR *argv[])
// narrow char strings for execv().
char **cargv;
int arg_count;
-# endif /* ACE_HAS_WCHAR */
+# endif /* ACE_USES_WCHAR */
switch (result)
{
@@ -267,7 +267,7 @@ ACE_OS::fork_exec (ACE_TCHAR *argv[])
--arg_count; // Back to 0-indexed
cargv[arg_count] = 0;
while (--arg_count >= 0)
- cargv[arg_count] = ACE_Wide_To_Ascii::convert (argv[arg_count]);
+ cargv[arg_count] = ACE_TEXT_TO_CHAR_OUT(argv[arg_count]); // memory allocated!
// Don't worry about freeing the cargv or the strings it points to.
// Either the process will be replaced, or we'll exit.
if (ACE_OS::execv (cargv[0], cargv) == -1)
@@ -282,7 +282,7 @@ ACE_OS::fork_exec (ACE_TCHAR *argv[])
// If the execv fails, this child needs to exit.
ACE_OS::exit (errno);
}
-# endif /* ACE_HAS_WCHAR */
+# endif /* ACE_USES_WCHAR */
default:
// Server process. The fork succeeded.
@@ -616,135 +616,6 @@ ACE_OS::pwrite (ACE_HANDLE handle,
# endif /* ACE_HAD_P_READ_WRITE */
}
-int
-ACE_OS::string_to_argv (ACE_TCHAR *buf,
- int &argc,
- ACE_TCHAR **&argv,
- bool substitute_env_args)
-{
- // Reset the number of arguments
- argc = 0;
-
- if (buf == 0)
- return -1;
-
- ACE_TCHAR *cp = buf;
-
- // First pass: count arguments.
-
- // '#' is the start-comment token..
- while (*cp != ACE_LIB_TEXT ('\0') && *cp != ACE_LIB_TEXT ('#'))
- {
- // Skip whitespace..
- while (ACE_OS::ace_isspace (*cp))
- cp++;
-
- // Increment count and move to next whitespace..
- if (*cp != ACE_LIB_TEXT ('\0'))
- argc++;
-
- while (*cp != ACE_LIB_TEXT ('\0') && !ACE_OS::ace_isspace (*cp))
- {
- // Grok quotes....
- if (*cp == ACE_LIB_TEXT ('\'') || *cp == ACE_LIB_TEXT ('"'))
- {
- ACE_TCHAR quote = *cp;
-
- // Scan past the string..
- for (cp++; *cp != ACE_LIB_TEXT ('\0') && *cp != quote; cp++)
- continue;
-
- // '\0' implies unmatched quote..
- if (*cp == ACE_LIB_TEXT ('\0'))
- {
- argc--;
- break;
- }
- else
- cp++;
- }
- else
- cp++;
- }
- }
-
- // Second pass: copy arguments.
- ACE_TCHAR arg[ACE_DEFAULT_ARGV_BUFSIZ];
- ACE_TCHAR *argp = arg;
-
- // Make sure that the buffer we're copying into is always large
- // enough.
- if (cp - buf >= ACE_DEFAULT_ARGV_BUFSIZ)
- ACE_NEW_RETURN (argp,
- ACE_TCHAR[cp - buf + 1],
- -1);
-
- // Make a new argv vector of argc + 1 elements.
- ACE_NEW_RETURN (argv,
- ACE_TCHAR *[argc + 1],
- -1);
-
- ACE_TCHAR *ptr = buf;
-
- for (int i = 0; i < argc; i++)
- {
- // Skip whitespace..
- while (ACE_OS::ace_isspace (*ptr))
- ptr++;
-
- // Copy next argument and move to next whitespace..
- cp = argp;
- while (*ptr != ACE_LIB_TEXT ('\0') && !ACE_OS::ace_isspace (*ptr))
- if (*ptr == ACE_LIB_TEXT ('\'') || *ptr == ACE_LIB_TEXT ('"'))
- {
- ACE_TCHAR quote = *ptr++;
-
- while (*ptr != ACE_LIB_TEXT ('\0') && *ptr != quote)
- *cp++ = *ptr++;
-
- if (*ptr == quote)
- ptr++;
- }
- else
- *cp++ = *ptr++;
-
- *cp = ACE_LIB_TEXT ('\0');
-
-#if !defined (ACE_LACKS_ENV)
- // Check for environment variable substitution here.
- if (substitute_env_args) {
- argv[i] = ACE_OS::strenvdup(argp);
-
- if (argv[i] == 0)
- {
- if (argp != arg)
- delete [] argp;
- errno = ENOMEM;
- return -1;
- }
- }
- else
-#endif /* ACE_LACKS_ENV */
- {
- argv[i] = ACE_OS::strdup(argp);
-
- if (argv[i] == 0)
- {
- if (argp != arg)
- delete [] argp;
- errno = ENOMEM;
- return -1;
- }
- }
- }
-
- if (argp != arg)
- delete [] argp;
-
- argv[argc] = 0;
- return 0;
-}
-
// Write <len> bytes from <buf> to <handle> (uses the <write>
// system call on UNIX and the <WriteFile> call on Win32).