1 |
/* wptKeyserver.cpp - W32 Keyserver Access |
/* wptKeyserver.cpp - W32 Keyserver Access |
2 |
* Copyright (C) 2000-2005 Timo Schulz |
* Copyright (C) 2000-2006 Timo Schulz |
3 |
* Copyright (C) 2001 Marco Cunha |
* Copyright (C) 2001 Marco Cunha |
4 |
* |
* |
5 |
* This file is part of WinPT. |
* This file is part of WinPT. |
37 |
#include "wptGPG.h" |
#include "wptGPG.h" |
38 |
#include "wptRegistry.h" |
#include "wptRegistry.h" |
39 |
|
|
40 |
/* just map net_errno to a winsock error. */ |
/* Map net_errno to a winsock error. */ |
41 |
#define net_errno ((int)WSAGetLastError ()) |
#define net_errno ((int)WSAGetLastError ()) |
42 |
|
|
43 |
|
|
660 |
Return value: 0 on success */ |
Return value: 0 on success */ |
661 |
int |
int |
662 |
kserver_connect (const char *hostname, WORD port, int *conn_fd) |
kserver_connect (const char *hostname, WORD port, int *conn_fd) |
663 |
{ |
{ |
|
int rc, fd; |
|
|
DWORD iaddr; |
|
|
char host[128] = {0}; |
|
664 |
struct hostent *hp; |
struct hostent *hp; |
665 |
struct sockaddr_in sock; |
struct sockaddr_in sock; |
666 |
|
char host[128] = {0}; |
667 |
|
DWORD iaddr; |
668 |
|
int rc, fd; |
669 |
|
|
670 |
log_debug ("kserver_connect: %s:%d\r\n", hostname, port); |
log_debug ("kserver_connect: %s:%d\r\n", hostname, port); |
671 |
|
|
675 |
*conn_fd = 0; |
*conn_fd = 0; |
676 |
hostname = skip_type_prefix (hostname); |
hostname = skip_type_prefix (hostname); |
677 |
|
|
678 |
|
if (proxy.host && proxy.proto == PROXY_PROTO_HTTP) |
679 |
|
port = proxy.port; |
680 |
memset (&sock, 0, sizeof (sock)); |
memset (&sock, 0, sizeof (sock)); |
681 |
sock.sin_family = AF_INET; |
sock.sin_family = AF_INET; |
682 |
sock.sin_port = proxy.host? htons (proxy.port) : htons (port); |
sock.sin_port = htons (port); |
683 |
if (proxy.host) |
if (proxy.host) |
684 |
strncpy (host, proxy.host, 127); |
strncpy (host, proxy.host, 127); |
685 |
else |
else |
686 |
strncpy (host, hostname, 127); |
strncpy (host, hostname, 127); |
687 |
|
|
688 |
if ((iaddr = inet_addr (host)) != INADDR_NONE) |
if ((iaddr = inet_addr (host)) != INADDR_NONE) |
689 |
memcpy (&sock.sin_addr, &iaddr, sizeof (iaddr)); |
memcpy (&sock.sin_addr, &iaddr, sizeof (iaddr)); |
690 |
else if ((hp = gethostbyname (host))) { |
else if ((hp = gethostbyname (host))) { |