mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
w32: Almost everywhere include winsock2.h before windows.h.
-- This is required by newer mingw toolchain versions which demand that winsock2.h is included before windows.h. Now, due to the use of socket definitions in pth.h we need to include winsock2.h also in pth.h, now pth.h is often included after an include of windows.h and thus the compiler spits out a warning. To avoid that we include winsock2.h at all places the compiler complains about.
This commit is contained in:
parent
a557a74615
commit
40ca0022a7
20 changed files with 436 additions and 380 deletions
|
@ -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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue