1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

[svn] Renamed xread/xwrite/xclose to fd_read/fd_write/fd_close. The "x" prefix is

not appropriate because the semantics have diverged from read/write/close
too significantly.
This commit is contained in:
hniksic 2003-11-20 07:19:59 -08:00
parent 0c4b349c5a
commit 0716c335a0
9 changed files with 143 additions and 135 deletions

View File

@ -1,3 +1,10 @@
2003-11-20 Hrvoje Niksic <hniksic@xemacs.org>
* connect.c: Renamed xread/xwrite/xclose to
fd_read/fd_write/fd_close. The "x" prefix is not appropriate
because the semantics have diverged from read/write/close too
significantly. Updated all callers.
2003-11-20 Hrvoje Niksic <hniksic@xemacs.org>
* connect.c (sock_write): It's not necessary to initialize RES.

View File

@ -321,7 +321,7 @@ connect_to_ip (const ip_address *ip, int port, const char *print)
logprintf. */
int save_errno = errno;
if (sock >= 0)
xclose (sock);
fd_close (sock);
if (print)
logprintf (LOG_VERBOSE, "failed: %s.\n", strerror (errno));
errno = save_errno;
@ -431,7 +431,7 @@ bind_local (const ip_address *bind_address, int *port)
sockaddr_set_data (sa, bind_address, *port);
if (bind (sock, sa, sockaddr_size (sa)) < 0)
{
xclose (sock);
fd_close (sock);
return -1;
}
DEBUGP (("Local socket fd %d bound.\n", sock));
@ -446,7 +446,7 @@ bind_local (const ip_address *bind_address, int *port)
something is seriously wrong with the socket, and it's
unusable for us anyway because we must know the chosen
port. */
xclose (sock);
fd_close (sock);
return -1;
}
sockaddr_get_data (sa, NULL, port);
@ -455,7 +455,7 @@ bind_local (const ip_address *bind_address, int *port)
}
if (listen (sock, 1) < 0)
{
xclose (sock);
fd_close (sock);
return -1;
}
return sock;
@ -609,7 +609,7 @@ socket_has_inet6 (void)
supported = 0;
else
{
xclose (sock);
fd_close (sock);
supported = 1;
}
}
@ -750,17 +750,17 @@ sock_close (int fd)
that are not mere file descriptors under the hood, such as SSL
sockets.
That way the user code can call xread(fd, ...) and we'll run read
That way the user code can call fd_read(fd, ...) and we'll run read
or SSL_read or whatever is necessary. */
static struct hash_table *transport_map;
static int transport_map_modified_tick;
struct transport_info {
xreader_t reader;
xwriter_t writer;
xpoller_t poller;
xcloser_t closer;
fd_reader_t reader;
fd_writer_t writer;
fd_poller_t poller;
fd_closer_t closer;
void *ctx;
};
@ -772,13 +772,13 @@ struct transport_info {
call getpeername, etc. */
void
register_transport (int fd, xreader_t reader, xwriter_t writer,
xpoller_t poller, xcloser_t closer, void *ctx)
fd_register_transport (int fd, fd_reader_t reader, fd_writer_t writer,
fd_poller_t poller, fd_closer_t closer, void *ctx)
{
struct transport_info *info;
/* The file descriptor must be non-negative to be registered.
Negative values are ignored by xclose(), and -1 cannot be used as
Negative values are ignored by fd_close(), and -1 cannot be used as
hash key. */
assert (fd >= 0);
@ -794,7 +794,7 @@ register_transport (int fd, xreader_t reader, xwriter_t writer,
++transport_map_modified_tick;
}
/* When xread/xwrite are called multiple times in a loop, they should
/* When fd_read/fd_write are called multiple times in a loop, they should
remember the INFO pointer instead of fetching it every time. It is
not enough to compare FD to LAST_FD because FD might have been
closed and reopened. modified_tick ensures that changes to
@ -825,7 +825,7 @@ register_transport (int fd, xreader_t reader, xwriter_t writer,
opt.timeout is used for TIMEOUT. */
int
xread (int fd, char *buf, int bufsize, double timeout)
fd_read (int fd, char *buf, int bufsize, double timeout)
{
struct transport_info *info;
LAZY_RETRIEVE_INFO (info);
@ -855,7 +855,7 @@ xread (int fd, char *buf, int bufsize, double timeout)
TIMEOUT. */
int
xwrite (int fd, char *buf, int bufsize, double timeout)
fd_write (int fd, char *buf, int bufsize, double timeout)
{
int res;
struct transport_info *info;
@ -895,13 +895,13 @@ xwrite (int fd, char *buf, int bufsize, double timeout)
/* Close the file descriptor FD. */
void
xclose (int fd)
fd_close (int fd)
{
struct transport_info *info;
if (fd < 0)
return;
/* Don't use LAZY_RETRIEVE_INFO because xclose() is only called once
/* Don't use LAZY_RETRIEVE_INFO because fd_close() is only called once
per socket, so that particular optimization wouldn't work. */
info = NULL;
if (transport_map)

View File

@ -67,15 +67,16 @@ int select_fd PARAMS ((int, double, int));
int test_socket_open PARAMS ((int));
int socket_has_inet6 PARAMS ((void));
typedef int (*xreader_t) PARAMS ((int, char *, int, void *));
typedef int (*xwriter_t) PARAMS ((int, char *, int, void *));
typedef int (*xpoller_t) PARAMS ((int, double, int, void *));
typedef void (*xcloser_t) PARAMS ((int, void *));
void register_transport PARAMS ((int,
xreader_t, xwriter_t, xpoller_t, xcloser_t,
void *));
typedef int (*fd_reader_t) PARAMS ((int, char *, int, void *));
typedef int (*fd_writer_t) PARAMS ((int, char *, int, void *));
typedef int (*fd_poller_t) PARAMS ((int, double, int, void *));
typedef void (*fd_closer_t) PARAMS ((int, void *));
void fd_register_transport PARAMS ((int,
fd_reader_t, fd_writer_t,
fd_poller_t, fd_closer_t,
void *));
int xread PARAMS ((int, char *, int, double));
int xwrite PARAMS ((int, char *, int, double));
void xclose PARAMS ((int));
int fd_read PARAMS ((int, char *, int, double));
int fd_write PARAMS ((int, char *, int, double));
void fd_close PARAMS ((int));
#endif /* CONNECT_H */

View File

@ -147,7 +147,7 @@ ftp_login (struct rbuf *rbuf, const char *acc, const char *pass)
xfree (respline);
/* Send USER username. */
request = ftp_request ("USER", acc);
nwritten = xwrite (RBUF_FD (rbuf), request, strlen (request), -1);
nwritten = fd_write (RBUF_FD (rbuf), request, strlen (request), -1);
if (nwritten < 0)
{
xfree (request);
@ -214,7 +214,7 @@ ftp_login (struct rbuf *rbuf, const char *acc, const char *pass)
xfree (respline);
/* Send PASS password. */
request = ftp_request ("PASS", pass);
nwritten = xwrite (RBUF_FD (rbuf), request, strlen (request), -1);
nwritten = fd_write (RBUF_FD (rbuf), request, strlen (request), -1);
if (nwritten < 0)
{
xfree (request);
@ -292,11 +292,11 @@ ftp_port (struct rbuf *rbuf, int *local_sock)
/* Send PORT request. */
request = ftp_request ("PORT", bytes);
nwritten = xwrite (RBUF_FD (rbuf), request, strlen (request), -1);
nwritten = fd_write (RBUF_FD (rbuf), request, strlen (request), -1);
if (nwritten < 0)
{
xfree (request);
xclose (*local_sock);
fd_close (*local_sock);
return WRITEFAILED;
}
xfree (request);
@ -306,13 +306,13 @@ ftp_port (struct rbuf *rbuf, int *local_sock)
if (err != FTPOK)
{
xfree (respline);
xclose (*local_sock);
fd_close (*local_sock);
return err;
}
if (*respline != '2')
{
xfree (respline);
xclose (*local_sock);
fd_close (*local_sock);
return FTPPORTERR;
}
xfree (respline);
@ -389,11 +389,11 @@ ftp_lprt (struct rbuf *rbuf, int *local_sock)
/* Send PORT request. */
request = ftp_request ("LPRT", bytes);
nwritten = xwrite (RBUF_FD (rbuf), request, strlen (request), -1);
nwritten = fd_write (RBUF_FD (rbuf), request, strlen (request), -1);
if (nwritten < 0)
{
xfree (request);
xclose (*local_sock);
fd_close (*local_sock);
return WRITEFAILED;
}
xfree (request);
@ -402,13 +402,13 @@ ftp_lprt (struct rbuf *rbuf, int *local_sock)
if (err != FTPOK)
{
xfree (respline);
xclose (*local_sock);
fd_close (*local_sock);
return err;
}
if (*respline != '2')
{
xfree (respline);
xclose (*local_sock);
fd_close (*local_sock);
return FTPPORTERR;
}
xfree (respline);
@ -473,11 +473,11 @@ ftp_eprt (struct rbuf *rbuf, int *local_sock)
/* Send PORT request. */
request = ftp_request ("EPRT", bytes);
nwritten = xwrite (RBUF_FD (rbuf), request, strlen (request), -1);
nwritten = fd_write (RBUF_FD (rbuf), request, strlen (request), -1);
if (nwritten < 0)
{
xfree (request);
xclose (*local_sock);
fd_close (*local_sock);
return WRITEFAILED;
}
xfree (request);
@ -486,13 +486,13 @@ ftp_eprt (struct rbuf *rbuf, int *local_sock)
if (err != FTPOK)
{
xfree (respline);
xclose (*local_sock);
fd_close (*local_sock);
return err;
}
if (*respline != '2')
{
xfree (respline);
xclose (*local_sock);
fd_close (*local_sock);
return FTPPORTERR;
}
xfree (respline);
@ -521,7 +521,7 @@ ftp_pasv (struct rbuf *rbuf, ip_address *addr, int *port)
/* Form the request. */
request = ftp_request ("PASV", NULL);
/* And send it. */
nwritten = xwrite (RBUF_FD (rbuf), request, strlen (request), -1);
nwritten = fd_write (RBUF_FD (rbuf), request, strlen (request), -1);
if (nwritten < 0)
{
xfree (request);
@ -592,7 +592,7 @@ ftp_lpsv (struct rbuf *rbuf, ip_address *addr, int *port)
request = ftp_request ("LPSV", NULL);
/* And send it. */
nwritten = xwrite (RBUF_FD (rbuf), request, strlen (request), -1);
nwritten = fd_write (RBUF_FD (rbuf), request, strlen (request), -1);
if (nwritten < 0)
{
xfree (request);
@ -759,7 +759,7 @@ ftp_epsv (struct rbuf *rbuf, ip_address *ip, int *port)
request = ftp_request ("EPSV", (ip->type == IPV4_ADDRESS ? "1" : "2"));
/* And send it. */
nwritten = xwrite (RBUF_FD (rbuf), request, strlen (request), -1);
nwritten = fd_write (RBUF_FD (rbuf), request, strlen (request), -1);
if (nwritten < 0)
{
xfree (request);
@ -859,7 +859,7 @@ ftp_type (struct rbuf *rbuf, int type)
stype[1] = 0;
/* Send TYPE request. */
request = ftp_request ("TYPE", stype);
nwritten = xwrite (RBUF_FD (rbuf), request, strlen (request), -1);
nwritten = fd_write (RBUF_FD (rbuf), request, strlen (request), -1);
if (nwritten < 0)
{
xfree (request);
@ -894,7 +894,7 @@ ftp_cwd (struct rbuf *rbuf, const char *dir)
/* Send CWD request. */
request = ftp_request ("CWD", dir);
nwritten = xwrite (RBUF_FD (rbuf), request, strlen (request), -1);
nwritten = fd_write (RBUF_FD (rbuf), request, strlen (request), -1);
if (nwritten < 0)
{
xfree (request);
@ -934,7 +934,7 @@ ftp_rest (struct rbuf *rbuf, long offset)
number_to_string (numbuf, offset);
request = ftp_request ("REST", numbuf);
nwritten = xwrite (RBUF_FD (rbuf), request, strlen (request), -1);
nwritten = fd_write (RBUF_FD (rbuf), request, strlen (request), -1);
if (nwritten < 0)
{
xfree (request);
@ -968,7 +968,7 @@ ftp_retr (struct rbuf *rbuf, const char *file)
/* Send RETR request. */
request = ftp_request ("RETR", file);
nwritten = xwrite (RBUF_FD (rbuf), request, strlen (request), -1);
nwritten = fd_write (RBUF_FD (rbuf), request, strlen (request), -1);
if (nwritten < 0)
{
xfree (request);
@ -1008,7 +1008,7 @@ ftp_list (struct rbuf *rbuf, const char *file)
/* Send LIST request. */
request = ftp_request ("LIST", file);
nwritten = xwrite (RBUF_FD (rbuf), request, strlen (request), -1);
nwritten = fd_write (RBUF_FD (rbuf), request, strlen (request), -1);
if (nwritten < 0)
{
xfree (request);
@ -1047,7 +1047,7 @@ ftp_syst (struct rbuf *rbuf, enum stype *server_type)
/* Send SYST request. */
request = ftp_request ("SYST", NULL);
nwritten = xwrite (RBUF_FD (rbuf), request, strlen (request), -1);
nwritten = fd_write (RBUF_FD (rbuf), request, strlen (request), -1);
if (nwritten < 0)
{
xfree (request);
@ -1104,7 +1104,7 @@ ftp_pwd (struct rbuf *rbuf, char **pwd)
/* Send PWD request. */
request = ftp_request ("PWD", NULL);
nwritten = xwrite (RBUF_FD (rbuf), request, strlen (request), -1);
nwritten = fd_write (RBUF_FD (rbuf), request, strlen (request), -1);
if (nwritten < 0)
{
xfree (request);
@ -1150,7 +1150,7 @@ ftp_size (struct rbuf *rbuf, const char *file, long int *size)
/* Send PWD request. */
request = ftp_request ("SIZE", file);
nwritten = xwrite (RBUF_FD (rbuf), request, strlen (request), -1);
nwritten = fd_write (RBUF_FD (rbuf), request, strlen (request), -1);
if (nwritten < 0)
{
xfree (request);

138
src/ftp.c
View File

@ -319,14 +319,14 @@ getftp (struct url *u, long *len, long restval, ccon *con)
logputs (LOG_VERBOSE, "\n");
logputs (LOG_NOTQUIET, _("\
Error in server response, closing control connection.\n"));
xclose (csock);
fd_close (csock);
rbuf_uninitialize (&con->rbuf);
return err;
break;
case FTPSRVERR:
logputs (LOG_VERBOSE, "\n");
logputs (LOG_NOTQUIET, _("Error in server greeting.\n"));
xclose (csock);
fd_close (csock);
rbuf_uninitialize (&con->rbuf);
return err;
break;
@ -334,21 +334,21 @@ Error in server response, closing control connection.\n"));
logputs (LOG_VERBOSE, "\n");
logputs (LOG_NOTQUIET,
_("Write failed, closing control connection.\n"));
xclose (csock);
fd_close (csock);
rbuf_uninitialize (&con->rbuf);
return err;
break;
case FTPLOGREFUSED:
logputs (LOG_VERBOSE, "\n");
logputs (LOG_NOTQUIET, _("The server refuses login.\n"));
xclose (csock);
fd_close (csock);
rbuf_uninitialize (&con->rbuf);
return FTPLOGREFUSED;
break;
case FTPLOGINC:
logputs (LOG_VERBOSE, "\n");
logputs (LOG_NOTQUIET, _("Login incorrect.\n"));
xclose (csock);
fd_close (csock);
rbuf_uninitialize (&con->rbuf);
return FTPLOGINC;
break;
@ -372,7 +372,7 @@ Error in server response, closing control connection.\n"));
logputs (LOG_VERBOSE, "\n");
logputs (LOG_NOTQUIET, _("\
Error in server response, closing control connection.\n"));
xclose (csock);
fd_close (csock);
rbuf_uninitialize (&con->rbuf);
return err;
break;
@ -403,7 +403,7 @@ Error in server response, closing control connection.\n"));
logputs (LOG_VERBOSE, "\n");
logputs (LOG_NOTQUIET, _("\
Error in server response, closing control connection.\n"));
xclose (csock);
fd_close (csock);
rbuf_uninitialize (&con->rbuf);
return err;
break;
@ -457,7 +457,7 @@ Error in server response, closing control connection.\n"));
logputs (LOG_VERBOSE, "\n");
logputs (LOG_NOTQUIET, _("\
Error in server response, closing control connection.\n"));
xclose (csock);
fd_close (csock);
rbuf_uninitialize (&con->rbuf);
return err;
break;
@ -465,7 +465,7 @@ Error in server response, closing control connection.\n"));
logputs (LOG_VERBOSE, "\n");
logputs (LOG_NOTQUIET,
_("Write failed, closing control connection.\n"));
xclose (csock);
fd_close (csock);
rbuf_uninitialize (&con->rbuf);
return err;
break;
@ -474,7 +474,7 @@ Error in server response, closing control connection.\n"));
logprintf (LOG_NOTQUIET,
_("Unknown type `%c', closing control connection.\n"),
type_char);
xclose (csock);
fd_close (csock);
rbuf_uninitialize (&con->rbuf);
return err;
case FTPOK:
@ -572,7 +572,7 @@ Error in server response, closing control connection.\n"));
logputs (LOG_VERBOSE, "\n");
logputs (LOG_NOTQUIET, _("\
Error in server response, closing control connection.\n"));
xclose (csock);
fd_close (csock);
rbuf_uninitialize (&con->rbuf);
return err;
break;
@ -580,7 +580,7 @@ Error in server response, closing control connection.\n"));
logputs (LOG_VERBOSE, "\n");
logputs (LOG_NOTQUIET,
_("Write failed, closing control connection.\n"));
xclose (csock);
fd_close (csock);
rbuf_uninitialize (&con->rbuf);
return err;
break;
@ -588,7 +588,7 @@ Error in server response, closing control connection.\n"));
logputs (LOG_VERBOSE, "\n");
logprintf (LOG_NOTQUIET, _("No such directory `%s'.\n\n"),
u->dir);
xclose (csock);
fd_close (csock);
rbuf_uninitialize (&con->rbuf);
return err;
break;
@ -623,7 +623,7 @@ Error in server response, closing control connection.\n"));
logputs (LOG_VERBOSE, "\n");
logputs (LOG_NOTQUIET, _("\
Error in server response, closing control connection.\n"));
xclose (csock);
fd_close (csock);
rbuf_uninitialize (&con->rbuf);
return err;
break;
@ -653,7 +653,7 @@ Error in server response, closing control connection.\n"));
logputs (LOG_VERBOSE, "\n");
logputs (LOG_NOTQUIET, _("\
Error in server response, closing control connection.\n"));
xclose (csock);
fd_close (csock);
rbuf_uninitialize (&con->rbuf);
return err;
break;
@ -661,7 +661,7 @@ Error in server response, closing control connection.\n"));
logputs (LOG_VERBOSE, "\n");
logputs (LOG_NOTQUIET,
_("Write failed, closing control connection.\n"));
xclose (csock);
fd_close (csock);
rbuf_uninitialize (&con->rbuf);
return err;
break;
@ -689,7 +689,7 @@ Error in server response, closing control connection.\n"));
if (dtsock < 0)
{
int save_errno = errno;
xclose (csock);
fd_close (csock);
rbuf_uninitialize (&con->rbuf);
logprintf (LOG_VERBOSE, _("couldn't connect to %s port %hu: %s\n"),
pretty_print_address (&passive_addr), passive_port,
@ -715,9 +715,9 @@ Error in server response, closing control connection.\n"));
logputs (LOG_VERBOSE, "\n");
logputs (LOG_NOTQUIET, _("\
Error in server response, closing control connection.\n"));
xclose (csock);
xclose (dtsock);
xclose (local_sock);
fd_close (csock);
fd_close (dtsock);
fd_close (local_sock);
rbuf_uninitialize (&con->rbuf);
return err;
break;
@ -725,18 +725,18 @@ Error in server response, closing control connection.\n"));
logputs (LOG_VERBOSE, "\n");
logputs (LOG_NOTQUIET,
_("Write failed, closing control connection.\n"));
xclose (csock);
xclose (dtsock);
xclose (local_sock);
fd_close (csock);
fd_close (dtsock);
fd_close (local_sock);
rbuf_uninitialize (&con->rbuf);
return err;
break;
case CONSOCKERR:
logputs (LOG_VERBOSE, "\n");
logprintf (LOG_NOTQUIET, "socket: %s\n", strerror (errno));
xclose (csock);
xclose (dtsock);
xclose (local_sock);
fd_close (csock);
fd_close (dtsock);
fd_close (local_sock);
rbuf_uninitialize (&con->rbuf);
return err;
break;
@ -744,15 +744,15 @@ Error in server response, closing control connection.\n"));
logputs (LOG_VERBOSE, "\n");
logprintf (LOG_NOTQUIET, _("Bind error (%s).\n"),
strerror (errno));
xclose (dtsock);
fd_close (dtsock);
return err;
break;
case FTPPORTERR:
logputs (LOG_VERBOSE, "\n");
logputs (LOG_NOTQUIET, _("Invalid PORT.\n"));
xclose (csock);
xclose (dtsock);
xclose (local_sock);
fd_close (csock);
fd_close (dtsock);
fd_close (local_sock);
rbuf_uninitialize (&con->rbuf);
return err;
break;
@ -782,9 +782,9 @@ Error in server response, closing control connection.\n"));
logputs (LOG_VERBOSE, "\n");
logputs (LOG_NOTQUIET, _("\
Error in server response, closing control connection.\n"));
xclose (csock);
xclose (dtsock);
xclose (local_sock);
fd_close (csock);
fd_close (dtsock);
fd_close (local_sock);
rbuf_uninitialize (&con->rbuf);
return err;
break;
@ -792,9 +792,9 @@ Error in server response, closing control connection.\n"));
logputs (LOG_VERBOSE, "\n");
logputs (LOG_NOTQUIET,
_("Write failed, closing control connection.\n"));
xclose (csock);
xclose (dtsock);
xclose (local_sock);
fd_close (csock);
fd_close (dtsock);
fd_close (local_sock);
rbuf_uninitialize (&con->rbuf);
return err;
break;
@ -807,9 +807,9 @@ Error in server response, closing control connection.\n"));
logprintf (LOG_NOTQUIET,
_("\nREST failed; will not truncate `%s'.\n"),
con->target);
xclose (csock);
xclose (dtsock);
xclose (local_sock);
fd_close (csock);
fd_close (dtsock);
fd_close (local_sock);
rbuf_uninitialize (&con->rbuf);
return CONTNOTSUPPORTED;
}
@ -835,9 +835,9 @@ Error in server response, closing control connection.\n"));
request. */
if (opt.spider)
{
xclose (csock);
xclose (dtsock);
xclose (local_sock);
fd_close (csock);
fd_close (dtsock);
fd_close (local_sock);
rbuf_uninitialize (&con->rbuf);
return RETRFINISHED;
}
@ -860,9 +860,9 @@ Error in server response, closing control connection.\n"));
logputs (LOG_VERBOSE, "\n");
logputs (LOG_NOTQUIET, _("\
Error in server response, closing control connection.\n"));
xclose (csock);
xclose (dtsock);
xclose (local_sock);
fd_close (csock);
fd_close (dtsock);
fd_close (local_sock);
rbuf_uninitialize (&con->rbuf);
return err;
break;
@ -870,17 +870,17 @@ Error in server response, closing control connection.\n"));
logputs (LOG_VERBOSE, "\n");
logputs (LOG_NOTQUIET,
_("Write failed, closing control connection.\n"));
xclose (csock);
xclose (dtsock);
xclose (local_sock);
fd_close (csock);
fd_close (dtsock);
fd_close (local_sock);
rbuf_uninitialize (&con->rbuf);
return err;
break;
case FTPNSFOD:
logputs (LOG_VERBOSE, "\n");
logprintf (LOG_NOTQUIET, _("No such file `%s'.\n\n"), u->file);
xclose (dtsock);
xclose (local_sock);
fd_close (dtsock);
fd_close (local_sock);
return err;
break;
case FTPOK:
@ -911,9 +911,9 @@ Error in server response, closing control connection.\n"));
logputs (LOG_VERBOSE, "\n");
logputs (LOG_NOTQUIET, _("\
Error in server response, closing control connection.\n"));
xclose (csock);
xclose (dtsock);
xclose (local_sock);
fd_close (csock);
fd_close (dtsock);
fd_close (local_sock);
rbuf_uninitialize (&con->rbuf);
return err;
break;
@ -921,9 +921,9 @@ Error in server response, closing control connection.\n"));
logputs (LOG_VERBOSE, "\n");
logputs (LOG_NOTQUIET,
_("Write failed, closing control connection.\n"));
xclose (csock);
xclose (dtsock);
xclose (local_sock);
fd_close (csock);
fd_close (dtsock);
fd_close (local_sock);
rbuf_uninitialize (&con->rbuf);
return err;
break;
@ -931,8 +931,8 @@ Error in server response, closing control connection.\n"));
logputs (LOG_VERBOSE, "\n");
logprintf (LOG_NOTQUIET, _("No such file or directory `%s'.\n\n"),
".");
xclose (dtsock);
xclose (local_sock);
fd_close (dtsock);
fd_close (local_sock);
return err;
break;
case FTPOK:
@ -986,10 +986,10 @@ Error in server response, closing control connection.\n"));
if (!fp)
{
logprintf (LOG_NOTQUIET, "%s: %s\n", con->target, strerror (errno));
xclose (csock);
fd_close (csock);
rbuf_uninitialize (&con->rbuf);
xclose (dtsock);
xclose (local_sock);
fd_close (dtsock);
fd_close (local_sock);
return FOPENERR;
}
}
@ -1036,8 +1036,8 @@ Error in server response, closing control connection.\n"));
tms = time_str (NULL);
tmrate = retr_rate (*len - restval, con->dltime, 0);
/* Close data connection socket. */
xclose (dtsock);
xclose (local_sock);
fd_close (dtsock);
fd_close (local_sock);
/* Close the local file. */
{
/* Close or flush the file. We have to be careful to check for
@ -1057,7 +1057,7 @@ Error in server response, closing control connection.\n"));
{
logprintf (LOG_NOTQUIET, _("%s: %s, closing control connection.\n"),
con->target, strerror (errno));
xclose (csock);
fd_close (csock);
rbuf_uninitialize (&con->rbuf);
return FWRITEERR;
}
@ -1085,7 +1085,7 @@ Error in server response, closing control connection.\n"));
return FTPRETRINT, since there is a possibility that the
whole file was retrieved nevertheless (but that is for
ftp_loop_internal to decide). */
xclose (csock);
fd_close (csock);
rbuf_uninitialize (&con->rbuf);
return FTPRETRINT;
} /* err != FTPOK */
@ -1114,7 +1114,7 @@ Error in server response, closing control connection.\n"));
{
/* I should probably send 'QUIT' and check for a reply, but this
is faster. #### Is it OK, though? */
xclose (csock);
fd_close (csock);
rbuf_uninitialize (&con->rbuf);
}
/* If it was a listing, and opt.server_response is true,
@ -1294,7 +1294,7 @@ ftp_loop_internal (struct url *u, struct fileinfo *f, ccon *con)
if (con->st & ON_YOUR_OWN)
{
xclose (RBUF_FD (&con->rbuf));
fd_close (RBUF_FD (&con->rbuf));
rbuf_uninitialize (&con->rbuf);
}
if (!opt.spider)
@ -1356,7 +1356,7 @@ ftp_loop_internal (struct url *u, struct fileinfo *f, ccon *con)
if (rbuf_initialized_p (&con->rbuf) && (con->st & ON_YOUR_OWN))
{
xclose (RBUF_FD (&con->rbuf));
fd_close (RBUF_FD (&con->rbuf));
rbuf_uninitialize (&con->rbuf);
}
return TRYLIMEXC;
@ -1917,7 +1917,7 @@ ftp_loop (struct url *u, int *dt, struct url *proxy)
*dt |= RETROKF;
/* If a connection was left, quench it. */
if (rbuf_initialized_p (&con.rbuf))
xclose (RBUF_FD (&con.rbuf));
fd_close (RBUF_FD (&con.rbuf));
xfree_null (con.id);
con.id = NULL;
xfree_null (con.target);

View File

@ -335,9 +335,9 @@ ssl_connect (int fd)
/* Register FD with Wget's transport layer, i.e. arrange that
SSL-enabled functions are used for reading, writing, and polling.
That way the rest of Wget can keep using xread, xwrite, and
friends and not care what happens underneath. */
register_transport (fd, ssl_read, ssl_write, ssl_poll, ssl_close, ssl);
That way the rest of Wget can use fd_read, fd_write, and friends
and not care what happens underneath. */
fd_register_transport (fd, ssl_read, ssl_write, ssl_poll, ssl_close, ssl);
DEBUGP (("Connected %d to SSL 0x%0lx\n", fd, (unsigned long) ssl));
return ssl;

View File

@ -211,7 +211,7 @@ post_file (int sock, const char *file_name, long promised_size)
if (length == 0)
break;
towrite = WMIN (promised_size - written, length);
write_error = xwrite (sock, chunk, towrite, -1);
write_error = fd_write (sock, chunk, towrite, -1);
if (write_error < 0)
{
fclose (fp);
@ -370,7 +370,7 @@ invalidate_persistent (void)
{
DEBUGP (("Disabling further reuse of socket %d.\n", pconn.socket));
pconn_active = 0;
xclose (pconn.socket);
fd_close (pconn.socket);
xfree (pconn.host);
xzero (pconn);
}
@ -525,7 +525,7 @@ persistent_available_p (const char *host, int port, int ssl,
if (pconn_active && (fd) == pconn.socket) \
invalidate_persistent (); \
else \
xclose (fd); \
fd_close (fd); \
} \
} while (0)
@ -533,7 +533,7 @@ persistent_available_p (const char *host, int port, int ssl,
if (pconn_active && (fd) == pconn.socket) \
invalidate_persistent (); \
else \
xclose (fd); \
fd_close (fd); \
} while (0)
struct http_stat
@ -728,7 +728,7 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy)
logputs (LOG_VERBOSE, "\n");
logprintf (LOG_NOTQUIET,
_("Unable to establish SSL connection.\n"));
xclose (sock);
fd_close (sock);
return CONSSLERR;
}
using_ssl = 1;
@ -961,14 +961,14 @@ Accept: %s\r\n\
xfree (full_path);
/* Send the request to server. */
write_error = xwrite (sock, request, strlen (request), -1);
write_error = fd_write (sock, request, strlen (request), -1);
if (write_error >= 0)
{
if (opt.post_data)
{
DEBUGP (("[POST data: %s]\n", opt.post_data));
write_error = xwrite (sock, opt.post_data, post_data_size, -1);
write_error = fd_write (sock, opt.post_data, post_data_size, -1);
}
else if (opt.post_file_name && post_data_size != 0)
write_error = post_file (sock, opt.post_file_name, post_data_size);

View File

@ -65,7 +65,7 @@ rbuf_uninitialize (struct rbuf *rbuf)
int
rbuf_read_bufferful (struct rbuf *rbuf)
{
return xread (rbuf->fd, rbuf->buffer, sizeof (rbuf->buffer), -1);
return fd_read (rbuf->fd, rbuf->buffer, sizeof (rbuf->buffer), -1);
}
/* Currently unused -- see RBUF_READCHAR. */
@ -87,7 +87,7 @@ rbuf_peek (struct rbuf *rbuf, char *store)
int res;
rbuf->buffer_pos = rbuf->buffer;
rbuf->buffer_left = 0;
res = xread (rbuf->fd, rbuf->buffer, sizeof (rbuf->buffer), -1);
res = fd_read (rbuf->fd, rbuf->buffer, sizeof (rbuf->buffer), -1);
if (res <= 0)
return res;
rbuf->buffer_left = res;

View File

@ -243,7 +243,7 @@ get_contents (int fd, FILE *fp, long *len, long restval, long expected,
}
}
}
res = xread (fd, dlbuf, amount_to_read, tmout);
res = fd_read (fd, dlbuf, amount_to_read, tmout);
if (res == 0 || (res < 0 && errno != ETIMEDOUT))
break;