aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/os/utils.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-07-18 10:12:07 +0200
committermarha <marha@users.sourceforge.net>2012-07-18 10:12:07 +0200
commit980040093547dc8dd563d8cb9d003aa39737eda4 (patch)
treec85afeb4affd10ee0d6001d18569510ef6488272 /xorg-server/os/utils.c
parent01102cdf33d68a7be192a139752831ff93dee117 (diff)
parent2ff5448bcca8cba4b62026d5493cb08aaf2838d8 (diff)
downloadvcxsrv-980040093547dc8dd563d8cb9d003aa39737eda4.tar.gz
vcxsrv-980040093547dc8dd563d8cb9d003aa39737eda4.tar.bz2
vcxsrv-980040093547dc8dd563d8cb9d003aa39737eda4.zip
Merge remote-tracking branch 'origin/released'
Conflicts: mesalib/src/glsl/.gitignore xorg-server/Xext/panoramiX.c xorg-server/hw/xwin/win.h xorg-server/hw/xwin/winclipboardinit.c xorg-server/hw/xwin/winclipboardthread.c xorg-server/hw/xwin/winclipboardunicode.c xorg-server/hw/xwin/winclipboardwrappers.c xorg-server/hw/xwin/winclipboardxevents.c xorg-server/hw/xwin/wincreatewnd.c xorg-server/hw/xwin/windialogs.c xorg-server/hw/xwin/winerror.c xorg-server/hw/xwin/winmonitors.c xorg-server/hw/xwin/winmultiwindowwm.c xorg-server/hw/xwin/winprocarg.c xorg-server/hw/xwin/winwndproc.c
Diffstat (limited to 'xorg-server/os/utils.c')
-rw-r--r--xorg-server/os/utils.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/xorg-server/os/utils.c b/xorg-server/os/utils.c
index 909c1f73e..b40f43fed 100644
--- a/xorg-server/os/utils.c
+++ b/xorg-server/os/utils.c
@@ -1622,6 +1622,79 @@ Fclose(pointer iop)
#endif /* !WIN32 */
+#ifdef WIN32
+
+#include <X11/Xwindows.h>
+
+const char *
+Win32TempDir()
+{
+ static char buffer[PATH_MAX];
+
+ if (GetTempPath(sizeof(buffer), buffer)) {
+ int len;
+
+ buffer[sizeof(buffer) - 1] = 0;
+ len = strlen(buffer);
+ if (len > 0)
+ if (buffer[len - 1] == '\\')
+ buffer[len - 1] = 0;
+ return buffer;
+ }
+ if (getenv("TEMP") != NULL)
+ return getenv("TEMP");
+ else if (getenv("TMP") != NULL)
+ return getenv("TEMP");
+ else
+ return "/tmp";
+}
+
+int
+System(const char *cmdline)
+{
+ STARTUPINFO si;
+ PROCESS_INFORMATION pi;
+ DWORD dwExitCode;
+ char *cmd = strdup(cmdline);
+
+ ZeroMemory(&si, sizeof(si));
+ si.cb = sizeof(si);
+ ZeroMemory(&pi, sizeof(pi));
+
+ if (!CreateProcess(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
+ LPVOID buffer;
+
+ if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ GetLastError(),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR) & buffer, 0, NULL)) {
+ ErrorF("[xkb] Starting '%s' failed!\n", cmdline);
+ }
+ else {
+ ErrorF("[xkb] Starting '%s' failed: %s", cmdline, (char *) buffer);
+ LocalFree(buffer);
+ }
+
+ free(cmd);
+ return -1;
+ }
+ /* Wait until child process exits. */
+ WaitForSingleObject(pi.hProcess, INFINITE);
+
+ GetExitCodeProcess(pi.hProcess, &dwExitCode);
+
+ /* Close process and thread handles. */
+ CloseHandle(pi.hProcess);
+ CloseHandle(pi.hThread);
+ free(cmd);
+
+ return dwExitCode;
+}
+#endif
+
/*
* CheckUserParameters: check for long command line arguments and long
* environment variables. By default, these checks are only done when