Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2011-10-05 16:27:37 +0400
committerCorinna Vinschen <corinna@vinschen.de>2011-10-05 16:27:37 +0400
commit8dfce03bfaae529e872ddfa39b5879ae6a9fdf06 (patch)
treee61bf7c10431b33674313344f71b84e07193fdc2 /winsup/cygwin/external.cc
parenta06c3bf33666f8d2749381c5ef7f800c23f05c38 (diff)
* external.cc (create_winenv): Rename from sync_winenv. Take
environment pointer as parameter and return pointer to corresponding win32 environment block if != NULL. Otherwise just sync as before. (cygwin_internal): Add CW_CVT_ENV_TO_WINENV case. * include/cygwin/version.h: Bump API minor number. * include/sys/cygwin.h (cygwin_getinfo_types): Add CW_CVT_ENV_TO_WINENV.
Diffstat (limited to 'winsup/cygwin/external.cc')
-rw-r--r--winsup/cygwin/external.cc22
1 files changed, 17 insertions, 5 deletions
diff --git a/winsup/cygwin/external.cc b/winsup/cygwin/external.cc
index d818cbc78..35f0f0909 100644
--- a/winsup/cygwin/external.cc
+++ b/winsup/cygwin/external.cc
@@ -132,12 +132,12 @@ check_ntsec (const char *filename)
}
/* Copy cygwin environment variables to the Windows environment. */
-static void
-sync_winenv ()
+static PWCHAR
+create_winenv (const char * const *env)
{
int unused_envc;
PWCHAR envblock = NULL;
- char **envp = build_env (cur_environ (), envblock, unused_envc, false);
+ char **envp = build_env (env ?: cur_environ (), envblock, unused_envc, false);
PWCHAR p = envblock;
if (envp)
@@ -146,8 +146,12 @@ sync_winenv ()
cfree (*e);
cfree (envp);
}
+ /* If we got an env block, just return pointer to win env. */
+ if (env)
+ return envblock;
+ /* Otherwise sync win env of current process with its posix env. */
if (!p)
- return;
+ return NULL;
while (*p)
{
PWCHAR eq = wcschr (p, L'=');
@@ -160,6 +164,7 @@ sync_winenv ()
p = wcschr (p, L'\0') + 1;
}
free (envblock);
+ return NULL;
}
/*
@@ -419,7 +424,7 @@ cygwin_internal (cygwin_getinfo_types t, ...)
try_to_debug ();
break;
case CW_SYNC_WINENV:
- sync_winenv ();
+ create_winenv (NULL);
res = 0;
break;
case CW_CYGTLS_PADSIZE:
@@ -516,6 +521,13 @@ cygwin_internal (cygwin_getinfo_types t, ...)
}
break;
+ case CW_CVT_ENV_TO_WINENV:
+ {
+ char **posix_env = va_arg (arg, char **);
+ res = (uintptr_t) create_winenv (posix_env);
+ }
+ break;
+
default:
set_errno (ENOSYS);
}