aboutsummaryrefslogtreecommitdiffstats
path: root/common/sysutils.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/sysutils.c')
-rw-r--r--common/sysutils.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/common/sysutils.c b/common/sysutils.c
index 8e0c75c1a..82bc81f56 100644
--- a/common/sysutils.c
+++ b/common/sysutils.c
@@ -43,10 +43,15 @@
# include <sys/resource.h>
#endif
#ifdef HAVE_W32_SYSTEM
-# define WINVER 0x0500 /* Required for AllowSetForegroundWindow. */
+# ifndef WINVER
+# define WINVER 0x0500 /* Required for AllowSetForegroundWindow. */
+# endif
+# ifdef HAVE_WINSOCK2_H
+# include <winsock2.h>
+# endif
# include <windows.h>
#endif
-#ifdef HAVE_PTH
+#ifdef HAVE_PTH
# include <pth.h>
#endif
#include <fcntl.h>
@@ -144,8 +149,8 @@ get_session_marker( size_t *rlen )
initialized = 1;
/* Although this marker is guessable it is not easy to use
* for a faked control packet because an attacker does not
- * have enough control about the time the verification does
- * take place. Of course, we can add just more random but
+ * have enough control about the time the verification does
+ * take place. Of course, we can add just more random but
* than we need the random generator even for verification
* tasks - which does not make sense. */
a = aa ^ (ulong)getpid();
@@ -260,7 +265,7 @@ gnupg_sleep (unsigned int seconds)
the process will give up its timeslot. */
if (!seconds)
{
-# ifdef HAVE_W32_SYSTEM
+# ifdef HAVE_W32_SYSTEM
Sleep (0);
# else
sleep (0);
@@ -269,7 +274,7 @@ gnupg_sleep (unsigned int seconds)
pth_sleep (seconds);
#else
/* Fixme: make sure that a sleep won't wake up to early. */
-# ifdef HAVE_W32_SYSTEM
+# ifdef HAVE_W32_SYSTEM
Sleep (seconds*1000);
# else
sleep (seconds);
@@ -291,7 +296,7 @@ translate_sys2libc_fd (gnupg_fd_t fd, int for_write)
if (fd == GNUPG_INVALID_FD)
return -1;
-
+
/* Note that _open_osfhandle is currently defined to take and return
a long. */
x = _open_osfhandle ((long)fd, for_write ? 1 : 0);
@@ -414,7 +419,7 @@ gnupg_tmpfile (void)
Must be called before we open any files! */
void
gnupg_reopen_std (const char *pgmname)
-{
+{
#if defined(HAVE_STAT) && !defined(HAVE_W32_SYSTEM)
struct stat statbuf;
int did_stdin = 0;
@@ -429,7 +434,7 @@ gnupg_reopen_std (const char *pgmname)
else
did_stdin = 2;
}
-
+
if (fstat (STDOUT_FILENO, &statbuf) == -1 && errno == EBADF)
{
if (open ("/dev/null",O_WRONLY) == STDOUT_FILENO)
@@ -478,13 +483,13 @@ gnupg_reopen_std (const char *pgmname)
/* Hack required for Windows. */
-void
+void
gnupg_allow_set_foregound_window (pid_t pid)
{
if (!pid)
log_info ("%s called with invalid pid %lu\n",
"gnupg_allow_set_foregound_window", (unsigned long)pid);
-#ifdef HAVE_W32_SYSTEM
+#ifdef HAVE_W32_SYSTEM
else if (!AllowSetForegroundWindow ((pid_t)pid == (pid_t)(-1)?ASFW_ANY:pid))
log_info ("AllowSetForegroundWindow(%lu) failed: %s\n",
(unsigned long)pid, w32_strerror (-1));