inet_ntoa_r() usage made more portable
This commit is contained in:
parent
d4ffc5ef32
commit
400ca043c7
11
lib/ftp.c
11
lib/ftp.c
@ -38,14 +38,14 @@
|
|||||||
* ------------------------------------------------------------
|
* ------------------------------------------------------------
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "setup.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include "setup.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
@ -680,7 +680,10 @@ CURLcode _ftp(struct connectdata *conn)
|
|||||||
unsigned short ip[5];
|
unsigned short ip[5];
|
||||||
(void) memcpy(&in.s_addr, *h->h_addr_list, sizeof (in.s_addr));
|
(void) memcpy(&in.s_addr, *h->h_addr_list, sizeof (in.s_addr));
|
||||||
#if defined (HAVE_INET_NTOA_R)
|
#if defined (HAVE_INET_NTOA_R)
|
||||||
sscanf( inet_ntoa_r(in, ntoa_buf, sizeof(ntoa_buf)), "%hu.%hu.%hu.%hu",
|
/* ignore the return code from inet_ntoa_r() as it is int or
|
||||||
|
char * depending on system */
|
||||||
|
inet_ntoa_r(in, ntoa_buf, sizeof(ntoa_buf));
|
||||||
|
sscanf( ntoa_buf, "%hu.%hu.%hu.%hu",
|
||||||
&ip[0], &ip[1], &ip[2], &ip[3]);
|
&ip[0], &ip[1], &ip[2], &ip[3]);
|
||||||
#else
|
#else
|
||||||
sscanf( inet_ntoa(in), "%hu.%hu.%hu.%hu",
|
sscanf( inet_ntoa(in), "%hu.%hu.%hu.%hu",
|
||||||
@ -815,7 +818,7 @@ CURLcode _ftp(struct connectdata *conn)
|
|||||||
infof(data, "Connecting to %s (%s) port %u\n",
|
infof(data, "Connecting to %s (%s) port %u\n",
|
||||||
answer?answer->h_name:newhost,
|
answer?answer->h_name:newhost,
|
||||||
#if defined(HAVE_INET_NTOA_R)
|
#if defined(HAVE_INET_NTOA_R)
|
||||||
ip_addr = inet_ntoa_r(in, ntoa_buf, sizeof(ntoa_buf)),
|
inet_ntoa_r(in, ip_addr=ntoa_buf, sizeof(ntoa_buf)),
|
||||||
#else
|
#else
|
||||||
ip_addr = inet_ntoa(in),
|
ip_addr = inet_ntoa(in),
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user