mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 08:08:50 -05:00
cleaned up some #ifdef mess, now uses data->fwrite() to write headers
This commit is contained in:
parent
8629719e0e
commit
ab05797500
20
lib/ftp.c
20
lib/ftp.c
@ -244,13 +244,7 @@ static int GetLastResponse(int sockfd, char *buf,
|
|||||||
char *getmyhost(void)
|
char *getmyhost(void)
|
||||||
{
|
{
|
||||||
static char myhost[256];
|
static char myhost[256];
|
||||||
#if !defined(WIN32) && !defined(HAVE_UNAME) && !defined(HAVE_GETHOSTNAME)
|
#ifdef HAVE_UNAME
|
||||||
/* We have no means of finding the local host name! */
|
|
||||||
strcpy(myhost, "localhost");
|
|
||||||
#endif
|
|
||||||
#if defined(WIN32) || !defined(HAVE_UNAME)
|
|
||||||
gethostname(myhost, 256);
|
|
||||||
#else
|
|
||||||
struct utsname ugnm;
|
struct utsname ugnm;
|
||||||
|
|
||||||
if (uname(&ugnm) < 0)
|
if (uname(&ugnm) < 0)
|
||||||
@ -258,6 +252,13 @@ char *getmyhost(void)
|
|||||||
|
|
||||||
(void) strncpy(myhost, ugnm.nodename, 255);
|
(void) strncpy(myhost, ugnm.nodename, 255);
|
||||||
myhost[255] = '\0';
|
myhost[255] = '\0';
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_GETHOSTNAME
|
||||||
|
gethostname(myhost, 256);
|
||||||
|
#endif
|
||||||
|
#if !defined(HAVE_UNAME) && !defined(HAVE_GETHOSTNAME)
|
||||||
|
/* We have no means of finding the local host name! */
|
||||||
|
strcpy(myhost, "localhost");
|
||||||
#endif
|
#endif
|
||||||
return myhost;
|
return myhost;
|
||||||
}
|
}
|
||||||
@ -425,7 +426,8 @@ UrgError _ftp(struct UrlData *data,
|
|||||||
}
|
}
|
||||||
if(data->writeheader) {
|
if(data->writeheader) {
|
||||||
/* the header is requested to be written to this file */
|
/* the header is requested to be written to this file */
|
||||||
if(strlen(buf) != fwrite (buf, 1, strlen(buf), data->writeheader)) {
|
if(strlen(buf) != data->fwrite (buf, 1, strlen(buf),
|
||||||
|
data->writeheader)) {
|
||||||
failf (data, "Failed writing output");
|
failf (data, "Failed writing output");
|
||||||
return URG_WRITE_ERROR;
|
return URG_WRITE_ERROR;
|
||||||
}
|
}
|
||||||
@ -583,7 +585,7 @@ UrgError _ftp(struct UrlData *data,
|
|||||||
struct hostent * answer;
|
struct hostent * answer;
|
||||||
|
|
||||||
unsigned long address;
|
unsigned long address;
|
||||||
#if defined(HAVE_INET_ADDR) || defined(WIN32)
|
#if defined(HAVE_INET_ADDR)
|
||||||
address = inet_addr(newhost);
|
address = inet_addr(newhost);
|
||||||
answer = gethostbyaddr((char *) &address, sizeof(address),
|
answer = gethostbyaddr((char *) &address, sizeof(address),
|
||||||
AF_INET);
|
AF_INET);
|
||||||
|
Loading…
Reference in New Issue
Block a user