* dotlock.c, http.c, iobuf.c, simple-gettext.c, srv.c, srv.h, strgutil.c,

ttyio.c, w32reg.c: s/__MINGW32__/_WIN32/ to help building on native
Windows compilers.  Requested by Brian Gladman. From Werner on stable
branch.

* http.c (connect_server): Oops - forgot to freeaddrinfo().
This commit is contained in:
David Shaw 2003-08-28 23:29:32 +00:00
parent 2d682ddc00
commit cd06705184
10 changed files with 48 additions and 35 deletions

View File

@ -1,3 +1,12 @@
2003-08-28 David Shaw <dshaw@jabberwocky.com>
* dotlock.c, http.c, iobuf.c, simple-gettext.c, srv.c, srv.h,
strgutil.c, ttyio.c, w32reg.c: s/__MINGW32__/_WIN32/ to help
building on native Windows compilers. Requested by Brian Gladman.
From Werner on stable branch.
* http.c (connect_server): Oops - forgot to freeaddrinfo().
2003-08-24 David Shaw <dshaw@jabberwocky.com> 2003-08-24 David Shaw <dshaw@jabberwocky.com>
* http.c (connect_server): Try and use getaddrinfo if it is * http.c (connect_server): Try and use getaddrinfo if it is

View File

@ -29,7 +29,9 @@
#include <sys/utsname.h> #include <sys/utsname.h>
#endif #endif
#include <sys/types.h> #include <sys/types.h>
#ifndef _WIN32
#include <sys/time.h> #include <sys/time.h>
#endif
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <signal.h> #include <signal.h>

View File

@ -26,7 +26,7 @@
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>
#ifdef __MINGW32__ #ifdef _WIN32
#include <windows.h> #include <windows.h>
#else #else
#include <unistd.h> #include <unistd.h>
@ -53,7 +53,7 @@
#define HTTP_PROXY_ENV_PRINTABLE "$http_proxy" #define HTTP_PROXY_ENV_PRINTABLE "$http_proxy"
#endif #endif
#ifdef __MINGW32__ #ifdef _WIN32
#define sock_close(a) closesocket(a) #define sock_close(a) closesocket(a)
#else #else
#define sock_close(a) close(a) #define sock_close(a) close(a)
@ -83,7 +83,7 @@ static int parse_response( HTTP_HD hd );
static int connect_server(const char *server, ushort port, unsigned int flags); static int connect_server(const char *server, ushort port, unsigned int flags);
static int write_server( int sock, const char *data, size_t length ); static int write_server( int sock, const char *data, size_t length );
#ifdef __MINGW32__ #ifdef _WIN32
static void static void
deinit_sockets (void) deinit_sockets (void)
{ {
@ -113,7 +113,7 @@ init_sockets (void)
atexit ( deinit_sockets ); atexit ( deinit_sockets );
initialized = 1; initialized = 1;
} }
#endif /*__MINGW32__*/ #endif /*_WIN32*/
int int
@ -713,7 +713,7 @@ connect_server( const char *server, ushort port, unsigned int flags )
int sock=-1,srv,srvcount=0,connected=0; int sock=-1,srv,srvcount=0,connected=0;
struct srventry *srvlist=NULL; struct srventry *srvlist=NULL;
#ifdef __MINGW32__ #ifdef _WIN32
in_addr_t inaddr; in_addr_t inaddr;
#warning check the windoze type #warning check the windoze type
@ -787,6 +787,7 @@ connect_server( const char *server, ushort port, unsigned int flags )
if((sock=socket(ai->ai_family,ai->ai_socktype,ai->ai_protocol))==-1) if((sock=socket(ai->ai_family,ai->ai_socktype,ai->ai_protocol))==-1)
{ {
log_error("error creating socket: %s\n",strerror(errno)); log_error("error creating socket: %s\n",strerror(errno));
freeaddrinfo(res);
return -1; return -1;
} }
@ -797,6 +798,8 @@ connect_server( const char *server, ushort port, unsigned int flags )
} }
} }
freeaddrinfo(res);
if(ai) if(ai)
break; break;
} }
@ -846,7 +849,7 @@ connect_server( const char *server, ushort port, unsigned int flags )
if(!connected) if(!connected)
{ {
#ifdef __MINGW32__ #ifdef _WIN32
log_error("%s: host not found: ec=%d\n",server,(int)WSAGetLastError()); log_error("%s: host not found: ec=%d\n",server,(int)WSAGetLastError());
#else #else
log_error("%s: host not found\n",server); log_error("%s: host not found\n",server);
@ -867,7 +870,7 @@ write_server( int sock, const char *data, size_t length )
nleft = length; nleft = length;
while( nleft > 0 ) { while( nleft > 0 ) {
#ifdef __MINGW32__ #ifdef _WIN32
int nwritten; int nwritten;
nwritten = send (sock, data, nleft, 0); nwritten = send (sock, data, nleft, 0);

View File

@ -1,5 +1,5 @@
/* iobuf.c - file handling /* iobuf.c - file handling
* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. * Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
* *
* This file is part of GnuPG. * This file is part of GnuPG.
* *
@ -96,7 +96,7 @@ typedef struct {
static CLOSE_CACHE close_cache; static CLOSE_CACHE close_cache;
#endif #endif
#ifdef __MINGW32__ #ifdef _WIN32
typedef struct { typedef struct {
int sock; int sock;
int keep_open; int keep_open;
@ -105,7 +105,7 @@ typedef struct {
int print_only_name; /* flags indicating that fname is not a real file*/ int print_only_name; /* flags indicating that fname is not a real file*/
char fname[1]; /* name of the file */ char fname[1]; /* name of the file */
} sock_filter_ctx_t ; } sock_filter_ctx_t ;
#endif /*__MINGW32__*/ #endif /*_WIN32*/
/* The first partial length header block must be of size 512 /* The first partial length header block must be of size 512
* to make it easier (and efficienter) we use a min. block size of 512 * to make it easier (and efficienter) we use a min. block size of 512
@ -515,7 +515,7 @@ file_filter(void *opaque, int control, IOBUF chain, byte *buf, size_t *ret_len)
return rc; return rc;
} }
#ifdef __MINGW32__ #ifdef _WIN32
/* Becuase sockets are an special object under Lose32 we have to /* Becuase sockets are an special object under Lose32 we have to
* use a special filter */ * use a special filter */
static int static int
@ -587,7 +587,7 @@ sock_filter (void *opaque, int control, IOBUF chain, byte *buf, size_t *ret_len)
} }
return rc; return rc;
} }
#endif /*__MINGW32__*/ #endif /*_WIN32*/
/**************** /****************
* This is used to implement the block write mode. * This is used to implement the block write mode.
@ -1122,7 +1122,7 @@ IOBUF
iobuf_sockopen ( int fd, const char *mode ) iobuf_sockopen ( int fd, const char *mode )
{ {
IOBUF a; IOBUF a;
#ifdef __MINGW32__ #ifdef _WIN32
sock_filter_ctx_t *scx; sock_filter_ctx_t *scx;
size_t len; size_t len;
@ -1261,7 +1261,7 @@ iobuf_ioctl ( IOBUF a, int cmd, int intval, void *ptrval )
b->keep_open = intval; b->keep_open = intval;
return 0; return 0;
} }
#ifdef __MINGW32__ #ifdef _WIN32
else if( !a->chain && a->filter == sock_filter ) { else if( !a->chain && a->filter == sock_filter ) {
sock_filter_ctx_t *b = a->filter_ov; sock_filter_ctx_t *b = a->filter_ov;
b->keep_open = intval; b->keep_open = intval;
@ -1290,7 +1290,7 @@ iobuf_ioctl ( IOBUF a, int cmd, int intval, void *ptrval )
b->no_cache = intval; b->no_cache = intval;
return 0; return 0;
} }
#ifdef __MINGW32__ #ifdef _WIN32
else if( !a->chain && a->filter == sock_filter ) { else if( !a->chain && a->filter == sock_filter ) {
sock_filter_ctx_t *b = a->filter_ov; sock_filter_ctx_t *b = a->filter_ov;
b->no_cache = intval; b->no_cache = intval;
@ -2141,7 +2141,7 @@ iobuf_read_line( IOBUF a, byte **addr_of_buffer,
int int
iobuf_translate_file_handle ( int fd, int for_write ) iobuf_translate_file_handle ( int fd, int for_write )
{ {
#ifdef __MINGW32__ #ifdef _WIN32
{ {
int x; int x;
@ -2164,7 +2164,7 @@ iobuf_translate_file_handle ( int fd, int for_write )
static int static int
translate_file_handle ( int fd, int for_write ) translate_file_handle ( int fd, int for_write )
{ {
#ifdef __MINGW32__ #ifdef _WIN32
#ifdef FILE_FILTER_USES_STDIO #ifdef FILE_FILTER_USES_STDIO
fd = iobuf_translate_file_handle (fd, for_write); fd = iobuf_translate_file_handle (fd, for_write);
#else #else

View File

@ -27,8 +27,8 @@
#include <config.h> #include <config.h>
#ifdef USE_SIMPLE_GETTEXT #ifdef USE_SIMPLE_GETTEXT
#if !defined (__MINGW32__) && !defined (__CYGWIN32__) #if !defined (_WIN32) && !defined (__CYGWIN32__)
#error This file can only be used with MingW32 or Cygwin32 #error This file can only be used udner Windows or Cygwin32
#endif #endif
#include <stdio.h> #include <stdio.h>

View File

@ -20,7 +20,7 @@
#include <config.h> #include <config.h>
#ifdef USE_DNS_SRV #ifdef USE_DNS_SRV
#ifdef __MINGW32__ #ifdef _WIN32
#include <windows.h> #include <windows.h>
#else #else
#include <netinet/in.h> #include <netinet/in.h>

View File

@ -21,7 +21,7 @@
#ifndef _SRV_H_ #ifndef _SRV_H_
#define _SRV_H_ #define _SRV_H_
#ifdef __MINGW32__ #ifdef _WIN32
#include <windows.h> #include <windows.h>
#else #else
#include <netinet/in.h> #include <netinet/in.h>

View File

@ -860,7 +860,7 @@ strncasecmp( const char *a, const char *b, size_t n )
#endif #endif
#ifdef __MINGW32__ #ifdef _WIN32
/* /*
* Like vsprintf but provides a pointer to malloc'd storage, which * Like vsprintf but provides a pointer to malloc'd storage, which
* must be freed by the caller (m_free). Taken from libiberty as * must be freed by the caller (m_free). Taken from libiberty as
@ -954,5 +954,4 @@ vasprintf ( char **result, const char *format, va_list args)
return 0; return 0;
} }
#endif /*__MINGW32__*/ #endif /*_WIN32*/

View File

@ -37,10 +37,10 @@
#define HAVE_TCGETATTR #define HAVE_TCGETATTR
#endif #endif
#endif #endif
#ifdef __MINGW32__ /* use the odd Win32 functions */ #ifdef _WIN32 /* use the odd Win32 functions */
#include <windows.h> #include <windows.h>
#ifdef HAVE_TCGETATTR #ifdef HAVE_TCGETATTR
#error mingw32 and termios #error windows and termios
#endif #endif
#endif #endif
#include <errno.h> #include <errno.h>
@ -51,7 +51,7 @@
#define CONTROL_D ('D' - 'A' + 1) #define CONTROL_D ('D' - 'A' + 1)
#ifdef __MINGW32__ /* use the odd Win32 functions */ #ifdef _WIN32 /* use the odd Win32 functions */
static struct { static struct {
HANDLE in, out; HANDLE in, out;
} con; } con;
@ -99,8 +99,8 @@ tty_get_ttyname (void)
got_name = 1; got_name = 1;
} }
#endif #endif
/* Assume the staandrd tty on memory error or when tehre is no /* Assume the standard tty on memory error or when there is no
certmid. */ ctermid. */
return name? name : "/dev/tty"; return name? name : "/dev/tty";
} }
@ -123,7 +123,7 @@ init_ttyfp(void)
if( initialized ) if( initialized )
return; return;
#if defined(__MINGW32__) #if defined(_WIN32)
{ {
SECURITY_ATTRIBUTES sa; SECURITY_ATTRIBUTES sa;
@ -192,7 +192,7 @@ tty_printf( const char *fmt, ... )
init_ttyfp(); init_ttyfp();
va_start( arg_ptr, fmt ) ; va_start( arg_ptr, fmt ) ;
#ifdef __MINGW32__ #ifdef _WIN32
{ {
char *buf = NULL; char *buf = NULL;
int n; int n;
@ -229,7 +229,7 @@ tty_print_string( byte *p, size_t n )
if( !initialized ) if( !initialized )
init_ttyfp(); init_ttyfp();
#ifdef __MINGW32__ #ifdef _WIN32
/* not so effective, change it if you want */ /* not so effective, change it if you want */
for( ; n; n--, p++ ) for( ; n; n--, p++ )
if( iscntrl( *p ) ) { if( iscntrl( *p ) ) {
@ -323,7 +323,7 @@ do_get( const char *prompt, int hidden )
buf = m_alloc(n=50); buf = m_alloc(n=50);
i = 0; i = 0;
#ifdef __MINGW32__ /* windoze version */ #ifdef _WIN32 /* windoze version */
if( hidden ) if( hidden )
SetConsoleMode(con.in, HID_INPMODE ); SetConsoleMode(con.in, HID_INPMODE );
@ -478,7 +478,7 @@ tty_kill_prompt()
last_prompt_len = 0; last_prompt_len = 0;
if( !last_prompt_len ) if( !last_prompt_len )
return; return;
#ifdef __MINGW32__ #ifdef _WIN32
tty_printf("\r%*s\r", last_prompt_len, ""); tty_printf("\r%*s\r", last_prompt_len, "");
#else #else
{ {

View File

@ -19,7 +19,7 @@
*/ */
#include <config.h> #include <config.h>
#if defined (__MINGW32__) || defined (__CYGWIN32__) #if defined (_WIN32) || defined (__CYGWIN32__)
/* This module is only used in this environment */ /* This module is only used in this environment */
#include <stdio.h> #include <stdio.h>