diff --git a/util/ChangeLog b/util/ChangeLog index 8b296a8c9..0b14f2071 100644 --- a/util/ChangeLog +++ b/util/ChangeLog @@ -1,3 +1,12 @@ +2003-08-28 David Shaw + + * 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 * http.c (connect_server): Try and use getaddrinfo if it is diff --git a/util/dotlock.c b/util/dotlock.c index 571262674..79e45c734 100644 --- a/util/dotlock.c +++ b/util/dotlock.c @@ -29,7 +29,9 @@ #include #endif #include +#ifndef _WIN32 #include +#endif #include #include #include diff --git a/util/http.c b/util/http.c index fcad64bd3..2417f30b0 100644 --- a/util/http.c +++ b/util/http.c @@ -26,7 +26,7 @@ #include #include -#ifdef __MINGW32__ +#ifdef _WIN32 #include #else #include @@ -53,7 +53,7 @@ #define HTTP_PROXY_ENV_PRINTABLE "$http_proxy" #endif -#ifdef __MINGW32__ +#ifdef _WIN32 #define sock_close(a) closesocket(a) #else #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 write_server( int sock, const char *data, size_t length ); -#ifdef __MINGW32__ +#ifdef _WIN32 static void deinit_sockets (void) { @@ -113,7 +113,7 @@ init_sockets (void) atexit ( deinit_sockets ); initialized = 1; } -#endif /*__MINGW32__*/ +#endif /*_WIN32*/ int @@ -713,7 +713,7 @@ connect_server( const char *server, ushort port, unsigned int flags ) int sock=-1,srv,srvcount=0,connected=0; struct srventry *srvlist=NULL; -#ifdef __MINGW32__ +#ifdef _WIN32 in_addr_t inaddr; #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) { log_error("error creating socket: %s\n",strerror(errno)); + freeaddrinfo(res); return -1; } @@ -797,6 +798,8 @@ connect_server( const char *server, ushort port, unsigned int flags ) } } + freeaddrinfo(res); + if(ai) break; } @@ -846,7 +849,7 @@ connect_server( const char *server, ushort port, unsigned int flags ) if(!connected) { -#ifdef __MINGW32__ +#ifdef _WIN32 log_error("%s: host not found: ec=%d\n",server,(int)WSAGetLastError()); #else log_error("%s: host not found\n",server); @@ -867,7 +870,7 @@ write_server( int sock, const char *data, size_t length ) nleft = length; while( nleft > 0 ) { -#ifdef __MINGW32__ +#ifdef _WIN32 int nwritten; nwritten = send (sock, data, nleft, 0); diff --git a/util/iobuf.c b/util/iobuf.c index 2b63d5c08..5bef61bd0 100644 --- a/util/iobuf.c +++ b/util/iobuf.c @@ -1,5 +1,5 @@ /* 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. * @@ -96,7 +96,7 @@ typedef struct { static CLOSE_CACHE close_cache; #endif -#ifdef __MINGW32__ +#ifdef _WIN32 typedef struct { int sock; int keep_open; @@ -105,7 +105,7 @@ typedef struct { int print_only_name; /* flags indicating that fname is not a real file*/ char fname[1]; /* name of the file */ } sock_filter_ctx_t ; -#endif /*__MINGW32__*/ +#endif /*_WIN32*/ /* 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 @@ -515,7 +515,7 @@ file_filter(void *opaque, int control, IOBUF chain, byte *buf, size_t *ret_len) return rc; } -#ifdef __MINGW32__ +#ifdef _WIN32 /* Becuase sockets are an special object under Lose32 we have to * use a special filter */ static int @@ -587,7 +587,7 @@ sock_filter (void *opaque, int control, IOBUF chain, byte *buf, size_t *ret_len) } return rc; } -#endif /*__MINGW32__*/ +#endif /*_WIN32*/ /**************** * This is used to implement the block write mode. @@ -1122,7 +1122,7 @@ IOBUF iobuf_sockopen ( int fd, const char *mode ) { IOBUF a; -#ifdef __MINGW32__ +#ifdef _WIN32 sock_filter_ctx_t *scx; size_t len; @@ -1261,7 +1261,7 @@ iobuf_ioctl ( IOBUF a, int cmd, int intval, void *ptrval ) b->keep_open = intval; return 0; } -#ifdef __MINGW32__ +#ifdef _WIN32 else if( !a->chain && a->filter == sock_filter ) { sock_filter_ctx_t *b = a->filter_ov; b->keep_open = intval; @@ -1290,7 +1290,7 @@ iobuf_ioctl ( IOBUF a, int cmd, int intval, void *ptrval ) b->no_cache = intval; return 0; } -#ifdef __MINGW32__ +#ifdef _WIN32 else if( !a->chain && a->filter == sock_filter ) { sock_filter_ctx_t *b = a->filter_ov; b->no_cache = intval; @@ -2141,7 +2141,7 @@ iobuf_read_line( IOBUF a, byte **addr_of_buffer, int iobuf_translate_file_handle ( int fd, int for_write ) { -#ifdef __MINGW32__ +#ifdef _WIN32 { int x; @@ -2164,7 +2164,7 @@ iobuf_translate_file_handle ( int fd, int for_write ) static int translate_file_handle ( int fd, int for_write ) { -#ifdef __MINGW32__ +#ifdef _WIN32 #ifdef FILE_FILTER_USES_STDIO fd = iobuf_translate_file_handle (fd, for_write); #else diff --git a/util/simple-gettext.c b/util/simple-gettext.c index 5d29804f1..151e7b326 100644 --- a/util/simple-gettext.c +++ b/util/simple-gettext.c @@ -27,8 +27,8 @@ #include #ifdef USE_SIMPLE_GETTEXT -#if !defined (__MINGW32__) && !defined (__CYGWIN32__) -#error This file can only be used with MingW32 or Cygwin32 +#if !defined (_WIN32) && !defined (__CYGWIN32__) +#error This file can only be used udner Windows or Cygwin32 #endif #include diff --git a/util/srv.c b/util/srv.c index e73d3f85c..91e1b9f3a 100644 --- a/util/srv.c +++ b/util/srv.c @@ -20,7 +20,7 @@ #include #ifdef USE_DNS_SRV -#ifdef __MINGW32__ +#ifdef _WIN32 #include #else #include diff --git a/util/srv.h b/util/srv.h index de239b6bc..903a80483 100644 --- a/util/srv.h +++ b/util/srv.h @@ -21,7 +21,7 @@ #ifndef _SRV_H_ #define _SRV_H_ -#ifdef __MINGW32__ +#ifdef _WIN32 #include #else #include diff --git a/util/strgutil.c b/util/strgutil.c index 05524d84d..2db4182a5 100644 --- a/util/strgutil.c +++ b/util/strgutil.c @@ -860,7 +860,7 @@ strncasecmp( const char *a, const char *b, size_t n ) #endif -#ifdef __MINGW32__ +#ifdef _WIN32 /* * Like vsprintf but provides a pointer to malloc'd storage, which * 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; } -#endif /*__MINGW32__*/ - +#endif /*_WIN32*/ diff --git a/util/ttyio.c b/util/ttyio.c index 955dd1b4c..f2463aa87 100644 --- a/util/ttyio.c +++ b/util/ttyio.c @@ -37,10 +37,10 @@ #define HAVE_TCGETATTR #endif #endif -#ifdef __MINGW32__ /* use the odd Win32 functions */ +#ifdef _WIN32 /* use the odd Win32 functions */ #include #ifdef HAVE_TCGETATTR -#error mingw32 and termios +#error windows and termios #endif #endif #include @@ -51,7 +51,7 @@ #define CONTROL_D ('D' - 'A' + 1) -#ifdef __MINGW32__ /* use the odd Win32 functions */ +#ifdef _WIN32 /* use the odd Win32 functions */ static struct { HANDLE in, out; } con; @@ -99,8 +99,8 @@ tty_get_ttyname (void) got_name = 1; } #endif - /* Assume the staandrd tty on memory error or when tehre is no - certmid. */ + /* Assume the standard tty on memory error or when there is no + ctermid. */ return name? name : "/dev/tty"; } @@ -123,7 +123,7 @@ init_ttyfp(void) if( initialized ) return; -#if defined(__MINGW32__) +#if defined(_WIN32) { SECURITY_ATTRIBUTES sa; @@ -192,7 +192,7 @@ tty_printf( const char *fmt, ... ) init_ttyfp(); va_start( arg_ptr, fmt ) ; -#ifdef __MINGW32__ +#ifdef _WIN32 { char *buf = NULL; int n; @@ -229,7 +229,7 @@ tty_print_string( byte *p, size_t n ) if( !initialized ) init_ttyfp(); -#ifdef __MINGW32__ +#ifdef _WIN32 /* not so effective, change it if you want */ for( ; n; n--, p++ ) if( iscntrl( *p ) ) { @@ -323,7 +323,7 @@ do_get( const char *prompt, int hidden ) buf = m_alloc(n=50); i = 0; -#ifdef __MINGW32__ /* windoze version */ +#ifdef _WIN32 /* windoze version */ if( hidden ) SetConsoleMode(con.in, HID_INPMODE ); @@ -478,7 +478,7 @@ tty_kill_prompt() last_prompt_len = 0; if( !last_prompt_len ) return; -#ifdef __MINGW32__ +#ifdef _WIN32 tty_printf("\r%*s\r", last_prompt_len, ""); #else { diff --git a/util/w32reg.c b/util/w32reg.c index aa507b2d7..edc77ced9 100644 --- a/util/w32reg.c +++ b/util/w32reg.c @@ -19,7 +19,7 @@ */ #include -#if defined (__MINGW32__) || defined (__CYGWIN32__) +#if defined (_WIN32) || defined (__CYGWIN32__) /* This module is only used in this environment */ #include