mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 512564 - Support for the WinCE environment implementation. r=bsmedberg
This commit is contained in:
parent
51e0aac9d9
commit
767b15be45
@ -1246,17 +1246,16 @@ LaunchWinPostProcess(const WCHAR *appExe)
|
||||
static void
|
||||
LaunchCallbackApp(const NS_tchar *workingDir, int argc, NS_tchar **argv)
|
||||
{
|
||||
// Windows CE uses a mock environment by passing environment variable with
|
||||
// the command line. It is the responsibility of the application to provide
|
||||
// the working directory and other environment variables used by the
|
||||
// application which is then passed back to the application when the updater
|
||||
// launches it.
|
||||
putenv(const_cast<char*>("NO_EM_RESTART="));
|
||||
putenv(const_cast<char*>("MOZ_LAUNCHED_CHILD=1"));
|
||||
|
||||
// Run from the specified working directory (see bug 312360).
|
||||
#ifndef WINCE
|
||||
// Run from the specified working directory (see bug 312360). This is not
|
||||
// necessary on Windows CE since the application that launches the updater
|
||||
// passes the working directory as an --environ: command line argument.
|
||||
if(NS_tchdir(workingDir) != 0)
|
||||
LOG(("Warning: chdir failed\n"));
|
||||
#endif
|
||||
|
||||
#if defined(USE_EXECV)
|
||||
execv(argv[0], argv);
|
||||
@ -1317,6 +1316,23 @@ UpdateThreadFunc(void *param)
|
||||
QuitProgressUI();
|
||||
}
|
||||
|
||||
#ifdef WINCE
|
||||
static char*
|
||||
AllocConvertUTF16toUTF8(const WCHAR *arg)
|
||||
{
|
||||
// be generous... UTF16 units can expand up to 3 UTF8 units
|
||||
int len = wcslen(arg);
|
||||
char *s = new char[len * 3 + 1];
|
||||
if (!s)
|
||||
return NULL;
|
||||
|
||||
ConvertUTF16toUTF8 convert(s);
|
||||
convert.write(arg, len);
|
||||
convert.write_terminator();
|
||||
return s;
|
||||
}
|
||||
#endif
|
||||
|
||||
int NS_main(int argc, NS_tchar **argv)
|
||||
{
|
||||
InitProgressUI(&argc, &argv);
|
||||
@ -1482,12 +1498,42 @@ int NS_main(int argc, NS_tchar **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
// The callback to execute is given as the last N arguments of our command
|
||||
// line. The first of those arguments specifies the working directory for
|
||||
// the callback.
|
||||
if (argc > 4)
|
||||
LaunchCallbackApp(argv[3], argc - 4, argv + 4);
|
||||
// The callback is the last N command line arguments starting from argOffset.
|
||||
// The argument specified by argOffset is the callback executable and the
|
||||
// argument prior to argOffset is the working directory.
|
||||
const int argOffset = 4;
|
||||
if (argc > argOffset) {
|
||||
#ifdef WINCE
|
||||
// Support the mock environment used on Windows CE.
|
||||
int i;
|
||||
int winceArgc = 0;
|
||||
WCHAR **winceArgv;
|
||||
for (i = argOffset; i < argc; ++i) {
|
||||
if (wcsncmp(argv[i], L"--environ:", 10) != 0)
|
||||
winceArgc++;
|
||||
}
|
||||
|
||||
winceArgv = (WCHAR**) malloc(sizeof(WCHAR*) * (winceArgc + 1));
|
||||
if (!winceArgv)
|
||||
return 1;
|
||||
|
||||
for (i = argOffset; i < argc; ++i) {
|
||||
if (wcsncmp(argv[i], L"--environ:", 10) == 0) {
|
||||
char* key_val = AllocConvertUTF16toUTF8(wcsdup(argv[i] + 10));
|
||||
putenv(key_val);
|
||||
delete [] key_val;
|
||||
}
|
||||
else {
|
||||
winceArgv[i - argOffset] = argv[i];
|
||||
}
|
||||
}
|
||||
winceArgv[winceArgc + 1] = NULL;
|
||||
LaunchCallbackApp(argv[3], winceArgc, winceArgv);
|
||||
free(winceArgv);
|
||||
#else
|
||||
LaunchCallbackApp(argv[3], argc - argOffset, argv + argOffset);
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -50,10 +50,6 @@ int chmod(const char* path, unsigned int mode)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _wchdir(const WCHAR* path) {
|
||||
return SetEnvironmentVariableW(L"CWD", path);
|
||||
}
|
||||
|
||||
int _wchmod(const WCHAR* path, unsigned int mode)
|
||||
{
|
||||
return 0;
|
||||
|
@ -65,6 +65,5 @@ int _wmkdir(const WCHAR* path);
|
||||
int access(const char* path, int amode);
|
||||
int _waccess(const WCHAR* path, int amode);
|
||||
int _wremove(const WCHAR* wpath);
|
||||
int _wchdir(const unsigned short* path);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user