Clean up namespace violations.
MFC after: 1 week
This commit is contained in:
parent
1b61ad6f38
commit
a1b37df2d7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=174588
@ -28,7 +28,7 @@ WARNS?= 2
|
||||
SHLIB_MAJOR= 5
|
||||
|
||||
ftperr.h: ftp.errors
|
||||
@echo "static struct fetcherr _ftp_errlist[] = {" > ${.TARGET}
|
||||
@echo "static struct fetcherr ftp_errlist[] = {" > ${.TARGET}
|
||||
@cat ${.ALLSRC} \
|
||||
| grep -v ^# \
|
||||
| sort \
|
||||
@ -39,7 +39,7 @@ ftperr.h: ftp.errors
|
||||
@echo "};" >> ${.TARGET}
|
||||
|
||||
httperr.h: http.errors
|
||||
@echo "static struct fetcherr _http_errlist[] = {" > ${.TARGET}
|
||||
@echo "static struct fetcherr http_errlist[] = {" > ${.TARGET}
|
||||
@cat ${.ALLSRC} \
|
||||
| grep -v ^# \
|
||||
| sort \
|
||||
|
@ -53,7 +53,7 @@ __FBSDID("$FreeBSD$");
|
||||
/*
|
||||
* Error messages for resolver errors
|
||||
*/
|
||||
static struct fetcherr _netdb_errlist[] = {
|
||||
static struct fetcherr netdb_errlist[] = {
|
||||
#ifdef EAI_NODATA
|
||||
{ EAI_NODATA, FETCH_RESOLV, "Host not found" },
|
||||
#endif
|
||||
@ -73,7 +73,7 @@ static const char ENDL[2] = "\r\n";
|
||||
* Map error code to string
|
||||
*/
|
||||
static struct fetcherr *
|
||||
_fetch_finderr(struct fetcherr *p, int e)
|
||||
fetch_finderr(struct fetcherr *p, int e)
|
||||
{
|
||||
while (p->num != -1 && p->num != e)
|
||||
p++;
|
||||
@ -84,9 +84,9 @@ _fetch_finderr(struct fetcherr *p, int e)
|
||||
* Set error code
|
||||
*/
|
||||
void
|
||||
_fetch_seterr(struct fetcherr *p, int e)
|
||||
fetch_seterr(struct fetcherr *p, int e)
|
||||
{
|
||||
p = _fetch_finderr(p, e);
|
||||
p = fetch_finderr(p, e);
|
||||
fetchLastErrCode = p->cat;
|
||||
snprintf(fetchLastErrString, MAXERRSTRING, "%s", p->string);
|
||||
}
|
||||
@ -95,7 +95,7 @@ _fetch_seterr(struct fetcherr *p, int e)
|
||||
* Set error code according to errno
|
||||
*/
|
||||
void
|
||||
_fetch_syserr(void)
|
||||
fetch_syserr(void)
|
||||
{
|
||||
switch (errno) {
|
||||
case 0:
|
||||
@ -155,7 +155,7 @@ _fetch_syserr(void)
|
||||
* Emit status message
|
||||
*/
|
||||
void
|
||||
_fetch_info(const char *fmt, ...)
|
||||
fetch_info(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
@ -172,7 +172,7 @@ _fetch_info(const char *fmt, ...)
|
||||
* Return the default port for a scheme
|
||||
*/
|
||||
int
|
||||
_fetch_default_port(const char *scheme)
|
||||
fetch_default_port(const char *scheme)
|
||||
{
|
||||
struct servent *se;
|
||||
|
||||
@ -189,7 +189,7 @@ _fetch_default_port(const char *scheme)
|
||||
* Return the default proxy port for a scheme
|
||||
*/
|
||||
int
|
||||
_fetch_default_proxy_port(const char *scheme)
|
||||
fetch_default_proxy_port(const char *scheme)
|
||||
{
|
||||
if (strcasecmp(scheme, SCHEME_FTP) == 0)
|
||||
return (FTP_DEFAULT_PROXY_PORT);
|
||||
@ -203,7 +203,7 @@ _fetch_default_proxy_port(const char *scheme)
|
||||
* Create a connection for an existing descriptor.
|
||||
*/
|
||||
conn_t *
|
||||
_fetch_reopen(int sd)
|
||||
fetch_reopen(int sd)
|
||||
{
|
||||
conn_t *conn;
|
||||
|
||||
@ -220,7 +220,7 @@ _fetch_reopen(int sd)
|
||||
* Bump a connection's reference count.
|
||||
*/
|
||||
conn_t *
|
||||
_fetch_ref(conn_t *conn)
|
||||
fetch_ref(conn_t *conn)
|
||||
{
|
||||
|
||||
++conn->ref;
|
||||
@ -232,7 +232,7 @@ _fetch_ref(conn_t *conn)
|
||||
* Bind a socket to a specific local address
|
||||
*/
|
||||
int
|
||||
_fetch_bind(int sd, int af, const char *addr)
|
||||
fetch_bind(int sd, int af, const char *addr)
|
||||
{
|
||||
struct addrinfo hints, *res, *res0;
|
||||
int err;
|
||||
@ -254,7 +254,7 @@ _fetch_bind(int sd, int af, const char *addr)
|
||||
* Establish a TCP connection to the specified port on the specified host.
|
||||
*/
|
||||
conn_t *
|
||||
_fetch_connect(const char *host, int port, int af, int verbose)
|
||||
fetch_connect(const char *host, int port, int af, int verbose)
|
||||
{
|
||||
conn_t *conn;
|
||||
char pbuf[10];
|
||||
@ -265,7 +265,7 @@ _fetch_connect(const char *host, int port, int af, int verbose)
|
||||
DEBUG(fprintf(stderr, "---> %s:%d\n", host, port));
|
||||
|
||||
if (verbose)
|
||||
_fetch_info("looking up %s", host);
|
||||
fetch_info("looking up %s", host);
|
||||
|
||||
/* look up host name and set up socket address structure */
|
||||
snprintf(pbuf, sizeof(pbuf), "%d", port);
|
||||
@ -274,13 +274,13 @@ _fetch_connect(const char *host, int port, int af, int verbose)
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_protocol = 0;
|
||||
if ((err = getaddrinfo(host, pbuf, &hints, &res0)) != 0) {
|
||||
_netdb_seterr(err);
|
||||
netdb_seterr(err);
|
||||
return (NULL);
|
||||
}
|
||||
bindaddr = getenv("FETCH_BIND_ADDRESS");
|
||||
|
||||
if (verbose)
|
||||
_fetch_info("connecting to %s:%d", host, port);
|
||||
fetch_info("connecting to %s:%d", host, port);
|
||||
|
||||
/* try to connect */
|
||||
for (sd = -1, res = res0; res; sd = -1, res = res->ai_next) {
|
||||
@ -288,8 +288,8 @@ _fetch_connect(const char *host, int port, int af, int verbose)
|
||||
res->ai_protocol)) == -1)
|
||||
continue;
|
||||
if (bindaddr != NULL && *bindaddr != '\0' &&
|
||||
_fetch_bind(sd, res->ai_family, bindaddr) != 0) {
|
||||
_fetch_info("failed to bind to '%s'", bindaddr);
|
||||
fetch_bind(sd, res->ai_family, bindaddr) != 0) {
|
||||
fetch_info("failed to bind to '%s'", bindaddr);
|
||||
close(sd);
|
||||
continue;
|
||||
}
|
||||
@ -299,12 +299,12 @@ _fetch_connect(const char *host, int port, int af, int verbose)
|
||||
}
|
||||
freeaddrinfo(res0);
|
||||
if (sd == -1) {
|
||||
_fetch_syserr();
|
||||
fetch_syserr();
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if ((conn = _fetch_reopen(sd)) == NULL) {
|
||||
_fetch_syserr();
|
||||
if ((conn = fetch_reopen(sd)) == NULL) {
|
||||
fetch_syserr();
|
||||
close(sd);
|
||||
}
|
||||
return (conn);
|
||||
@ -315,7 +315,7 @@ _fetch_connect(const char *host, int port, int af, int verbose)
|
||||
* Enable SSL on a connection.
|
||||
*/
|
||||
int
|
||||
_fetch_ssl(conn_t *conn, int verbose)
|
||||
fetch_ssl(conn_t *conn, int verbose)
|
||||
{
|
||||
|
||||
#ifdef WITH_SSL
|
||||
@ -373,7 +373,7 @@ _fetch_ssl(conn_t *conn, int verbose)
|
||||
* Read a character from a connection w/ timeout
|
||||
*/
|
||||
ssize_t
|
||||
_fetch_read(conn_t *conn, char *buf, size_t len)
|
||||
fetch_read(conn_t *conn, char *buf, size_t len)
|
||||
{
|
||||
struct timeval now, timeout, wait;
|
||||
fd_set readfds;
|
||||
@ -399,7 +399,7 @@ _fetch_read(conn_t *conn, char *buf, size_t len)
|
||||
}
|
||||
if (wait.tv_sec < 0) {
|
||||
errno = ETIMEDOUT;
|
||||
_fetch_syserr();
|
||||
fetch_syserr();
|
||||
return (-1);
|
||||
}
|
||||
errno = 0;
|
||||
@ -407,7 +407,7 @@ _fetch_read(conn_t *conn, char *buf, size_t len)
|
||||
if (r == -1) {
|
||||
if (errno == EINTR && fetchRestartCalls)
|
||||
continue;
|
||||
_fetch_syserr();
|
||||
fetch_syserr();
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
@ -438,7 +438,7 @@ _fetch_read(conn_t *conn, char *buf, size_t len)
|
||||
#define MIN_BUF_SIZE 1024
|
||||
|
||||
int
|
||||
_fetch_getln(conn_t *conn)
|
||||
fetch_getln(conn_t *conn)
|
||||
{
|
||||
char *tmp;
|
||||
size_t tmpsize;
|
||||
@ -457,7 +457,7 @@ _fetch_getln(conn_t *conn)
|
||||
conn->buflen = 0;
|
||||
|
||||
do {
|
||||
len = _fetch_read(conn, &c, 1);
|
||||
len = fetch_read(conn, &c, 1);
|
||||
if (len == -1)
|
||||
return (-1);
|
||||
if (len == 0)
|
||||
@ -485,13 +485,13 @@ _fetch_getln(conn_t *conn)
|
||||
* Write to a connection w/ timeout
|
||||
*/
|
||||
ssize_t
|
||||
_fetch_write(conn_t *conn, const char *buf, size_t len)
|
||||
fetch_write(conn_t *conn, const char *buf, size_t len)
|
||||
{
|
||||
struct iovec iov;
|
||||
|
||||
iov.iov_base = __DECONST(char *, buf);
|
||||
iov.iov_len = len;
|
||||
return _fetch_writev(conn, &iov, 1);
|
||||
return fetch_writev(conn, &iov, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -499,7 +499,7 @@ _fetch_write(conn_t *conn, const char *buf, size_t len)
|
||||
* Note: can modify the iovec.
|
||||
*/
|
||||
ssize_t
|
||||
_fetch_writev(conn_t *conn, struct iovec *iov, int iovcnt)
|
||||
fetch_writev(conn_t *conn, struct iovec *iov, int iovcnt)
|
||||
{
|
||||
struct timeval now, timeout, wait;
|
||||
fd_set writefds;
|
||||
@ -525,7 +525,7 @@ _fetch_writev(conn_t *conn, struct iovec *iov, int iovcnt)
|
||||
}
|
||||
if (wait.tv_sec < 0) {
|
||||
errno = ETIMEDOUT;
|
||||
_fetch_syserr();
|
||||
fetch_syserr();
|
||||
return (-1);
|
||||
}
|
||||
errno = 0;
|
||||
@ -547,7 +547,7 @@ _fetch_writev(conn_t *conn, struct iovec *iov, int iovcnt)
|
||||
if (wlen == 0) {
|
||||
/* we consider a short write a failure */
|
||||
errno = EPIPE;
|
||||
_fetch_syserr();
|
||||
fetch_syserr();
|
||||
return (-1);
|
||||
}
|
||||
if (wlen < 0) {
|
||||
@ -574,7 +574,7 @@ _fetch_writev(conn_t *conn, struct iovec *iov, int iovcnt)
|
||||
* Write a line of text to a connection w/ timeout
|
||||
*/
|
||||
int
|
||||
_fetch_putln(conn_t *conn, const char *str, size_t len)
|
||||
fetch_putln(conn_t *conn, const char *str, size_t len)
|
||||
{
|
||||
struct iovec iov[2];
|
||||
int ret;
|
||||
@ -585,9 +585,9 @@ _fetch_putln(conn_t *conn, const char *str, size_t len)
|
||||
iov[1].iov_base = __DECONST(char *, ENDL);
|
||||
iov[1].iov_len = sizeof(ENDL);
|
||||
if (len == 0)
|
||||
ret = _fetch_writev(conn, &iov[1], 1);
|
||||
ret = fetch_writev(conn, &iov[1], 1);
|
||||
else
|
||||
ret = _fetch_writev(conn, iov, 2);
|
||||
ret = fetch_writev(conn, iov, 2);
|
||||
if (ret == -1)
|
||||
return (-1);
|
||||
return (0);
|
||||
@ -598,7 +598,7 @@ _fetch_putln(conn_t *conn, const char *str, size_t len)
|
||||
* Close connection
|
||||
*/
|
||||
int
|
||||
_fetch_close(conn_t *conn)
|
||||
fetch_close(conn_t *conn)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@ -614,7 +614,7 @@ _fetch_close(conn_t *conn)
|
||||
/*** Directory-related utility functions *************************************/
|
||||
|
||||
int
|
||||
_fetch_add_entry(struct url_ent **p, int *size, int *len,
|
||||
fetch_add_entry(struct url_ent **p, int *size, int *len,
|
||||
const char *name, struct url_stat *us)
|
||||
{
|
||||
struct url_ent *tmp;
|
||||
@ -628,7 +628,7 @@ _fetch_add_entry(struct url_ent **p, int *size, int *len,
|
||||
tmp = realloc(*p, (*size * 2 + 1) * sizeof(**p));
|
||||
if (tmp == NULL) {
|
||||
errno = ENOMEM;
|
||||
_fetch_syserr();
|
||||
fetch_syserr();
|
||||
return (-1);
|
||||
}
|
||||
*size = (*size * 2 + 1);
|
||||
@ -649,7 +649,7 @@ _fetch_add_entry(struct url_ent **p, int *size, int *len,
|
||||
/*** Authentication-related utility functions ********************************/
|
||||
|
||||
static const char *
|
||||
_fetch_read_word(FILE *f)
|
||||
fetch_read_word(FILE *f)
|
||||
{
|
||||
static char word[1024];
|
||||
|
||||
@ -662,7 +662,7 @@ _fetch_read_word(FILE *f)
|
||||
* Get authentication data for a URL from .netrc
|
||||
*/
|
||||
int
|
||||
_fetch_netrc_auth(struct url *url)
|
||||
fetch_netrc_auth(struct url *url)
|
||||
{
|
||||
char fn[PATH_MAX];
|
||||
const char *word;
|
||||
@ -671,7 +671,7 @@ _fetch_netrc_auth(struct url *url)
|
||||
|
||||
if ((p = getenv("NETRC")) != NULL) {
|
||||
if (snprintf(fn, sizeof(fn), "%s", p) >= (int)sizeof(fn)) {
|
||||
_fetch_info("$NETRC specifies a file name "
|
||||
fetch_info("$NETRC specifies a file name "
|
||||
"longer than PATH_MAX");
|
||||
return (-1);
|
||||
}
|
||||
@ -689,39 +689,39 @@ _fetch_netrc_auth(struct url *url)
|
||||
|
||||
if ((f = fopen(fn, "r")) == NULL)
|
||||
return (-1);
|
||||
while ((word = _fetch_read_word(f)) != NULL) {
|
||||
while ((word = fetch_read_word(f)) != NULL) {
|
||||
if (strcmp(word, "default") == 0) {
|
||||
DEBUG(_fetch_info("Using default .netrc settings"));
|
||||
DEBUG(fetch_info("Using default .netrc settings"));
|
||||
break;
|
||||
}
|
||||
if (strcmp(word, "machine") == 0 &&
|
||||
(word = _fetch_read_word(f)) != NULL &&
|
||||
(word = fetch_read_word(f)) != NULL &&
|
||||
strcasecmp(word, url->host) == 0) {
|
||||
DEBUG(_fetch_info("Using .netrc settings for %s", word));
|
||||
DEBUG(fetch_info("Using .netrc settings for %s", word));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (word == NULL)
|
||||
goto ferr;
|
||||
while ((word = _fetch_read_word(f)) != NULL) {
|
||||
while ((word = fetch_read_word(f)) != NULL) {
|
||||
if (strcmp(word, "login") == 0) {
|
||||
if ((word = _fetch_read_word(f)) == NULL)
|
||||
if ((word = fetch_read_word(f)) == NULL)
|
||||
goto ferr;
|
||||
if (snprintf(url->user, sizeof(url->user),
|
||||
"%s", word) > (int)sizeof(url->user)) {
|
||||
_fetch_info("login name in .netrc is too long");
|
||||
fetch_info("login name in .netrc is too long");
|
||||
url->user[0] = '\0';
|
||||
}
|
||||
} else if (strcmp(word, "password") == 0) {
|
||||
if ((word = _fetch_read_word(f)) == NULL)
|
||||
if ((word = fetch_read_word(f)) == NULL)
|
||||
goto ferr;
|
||||
if (snprintf(url->pwd, sizeof(url->pwd),
|
||||
"%s", word) > (int)sizeof(url->pwd)) {
|
||||
_fetch_info("password in .netrc is too long");
|
||||
fetch_info("password in .netrc is too long");
|
||||
url->pwd[0] = '\0';
|
||||
}
|
||||
} else if (strcmp(word, "account") == 0) {
|
||||
if ((word = _fetch_read_word(f)) == NULL)
|
||||
if ((word = fetch_read_word(f)) == NULL)
|
||||
goto ferr;
|
||||
/* XXX not supported! */
|
||||
} else {
|
||||
|
@ -68,33 +68,33 @@ struct fetcherr {
|
||||
const char *string;
|
||||
};
|
||||
|
||||
/* for _fetch_writev */
|
||||
/* for fetch_writev */
|
||||
struct iovec;
|
||||
|
||||
void _fetch_seterr(struct fetcherr *, int);
|
||||
void _fetch_syserr(void);
|
||||
void _fetch_info(const char *, ...);
|
||||
int _fetch_default_port(const char *);
|
||||
int _fetch_default_proxy_port(const char *);
|
||||
int _fetch_bind(int, int, const char *);
|
||||
conn_t *_fetch_connect(const char *, int, int, int);
|
||||
conn_t *_fetch_reopen(int);
|
||||
conn_t *_fetch_ref(conn_t *);
|
||||
int _fetch_ssl(conn_t *, int);
|
||||
ssize_t _fetch_read(conn_t *, char *, size_t);
|
||||
int _fetch_getln(conn_t *);
|
||||
ssize_t _fetch_write(conn_t *, const char *, size_t);
|
||||
ssize_t _fetch_writev(conn_t *, struct iovec *, int);
|
||||
int _fetch_putln(conn_t *, const char *, size_t);
|
||||
int _fetch_close(conn_t *);
|
||||
int _fetch_add_entry(struct url_ent **, int *, int *,
|
||||
void fetch_seterr(struct fetcherr *, int);
|
||||
void fetch_syserr(void);
|
||||
void fetch_info(const char *, ...);
|
||||
int fetch_default_port(const char *);
|
||||
int fetch_default_proxy_port(const char *);
|
||||
int fetch_bind(int, int, const char *);
|
||||
conn_t *fetch_connect(const char *, int, int, int);
|
||||
conn_t *fetch_reopen(int);
|
||||
conn_t *fetch_ref(conn_t *);
|
||||
int fetch_ssl(conn_t *, int);
|
||||
ssize_t fetch_read(conn_t *, char *, size_t);
|
||||
int fetch_getln(conn_t *);
|
||||
ssize_t fetch_write(conn_t *, const char *, size_t);
|
||||
ssize_t fetch_writev(conn_t *, struct iovec *, int);
|
||||
int fetch_putln(conn_t *, const char *, size_t);
|
||||
int fetch_close(conn_t *);
|
||||
int fetch_add_entry(struct url_ent **, int *, int *,
|
||||
const char *, struct url_stat *);
|
||||
int _fetch_netrc_auth(struct url *url);
|
||||
int fetch_netrc_auth(struct url *url);
|
||||
|
||||
#define _ftp_seterr(n) _fetch_seterr(_ftp_errlist, n)
|
||||
#define _http_seterr(n) _fetch_seterr(_http_errlist, n)
|
||||
#define _netdb_seterr(n) _fetch_seterr(_netdb_errlist, n)
|
||||
#define _url_seterr(n) _fetch_seterr(_url_errlist, n)
|
||||
#define ftp_seterr(n) fetch_seterr(ftp_errlist, n)
|
||||
#define http_seterr(n) fetch_seterr(http_errlist, n)
|
||||
#define netdb_seterr(n) fetch_seterr(netdb_errlist, n)
|
||||
#define url_seterr(n) fetch_seterr(url_errlist, n)
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define DEBUG(x) do { if (fetchDebug) { x; } } while (0)
|
||||
@ -103,7 +103,7 @@ int _fetch_netrc_auth(struct url *url);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* I don't really like exporting _http_request() and _ftp_request(),
|
||||
* I don't really like exporting http_request() and ftp_request(),
|
||||
* but the HTTP and FTP code occasionally needs to cross-call
|
||||
* eachother, and this saves me from adding a lot of special-case code
|
||||
* to handle those cases.
|
||||
@ -111,9 +111,9 @@ int _fetch_netrc_auth(struct url *url);
|
||||
* Note that _*_request() free purl, which is way ugly but saves us a
|
||||
* whole lot of trouble.
|
||||
*/
|
||||
FILE *_http_request(struct url *, const char *,
|
||||
FILE *http_request(struct url *, const char *,
|
||||
struct url_stat *, struct url *, const char *);
|
||||
FILE *_ftp_request(struct url *, const char *,
|
||||
FILE *ftp_request(struct url *, const char *,
|
||||
struct url_stat *, struct url *, const char *);
|
||||
|
||||
/*
|
||||
|
@ -56,7 +56,7 @@ int fetchDebug;
|
||||
#define URL_MALFORMED 1
|
||||
#define URL_BAD_SCHEME 2
|
||||
#define URL_BAD_PORT 3
|
||||
static struct fetcherr _url_errlist[] = {
|
||||
static struct fetcherr url_errlist[] = {
|
||||
{ URL_MALFORMED, FETCH_URL, "Malformed URL" },
|
||||
{ URL_BAD_SCHEME, FETCH_URL, "Invalid URL scheme" },
|
||||
{ URL_BAD_PORT, FETCH_URL, "Invalid server port" },
|
||||
@ -89,7 +89,7 @@ fetchXGet(struct url *URL, struct url_stat *us, const char *flags)
|
||||
return (fetchXGetHTTP(URL, us, flags));
|
||||
else if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0)
|
||||
return (fetchXGetHTTP(URL, us, flags));
|
||||
_url_seterr(URL_BAD_SCHEME);
|
||||
url_seterr(URL_BAD_SCHEME);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
@ -121,7 +121,7 @@ fetchPut(struct url *URL, const char *flags)
|
||||
return (fetchPutHTTP(URL, flags));
|
||||
else if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0)
|
||||
return (fetchPutHTTP(URL, flags));
|
||||
_url_seterr(URL_BAD_SCHEME);
|
||||
url_seterr(URL_BAD_SCHEME);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
@ -147,7 +147,7 @@ fetchStat(struct url *URL, struct url_stat *us, const char *flags)
|
||||
return (fetchStatHTTP(URL, us, flags));
|
||||
else if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0)
|
||||
return (fetchStatHTTP(URL, us, flags));
|
||||
_url_seterr(URL_BAD_SCHEME);
|
||||
url_seterr(URL_BAD_SCHEME);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
@ -169,7 +169,7 @@ fetchList(struct url *URL, const char *flags)
|
||||
return (fetchListHTTP(URL, flags));
|
||||
else if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0)
|
||||
return (fetchListHTTP(URL, flags));
|
||||
_url_seterr(URL_BAD_SCHEME);
|
||||
url_seterr(URL_BAD_SCHEME);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
@ -264,23 +264,23 @@ fetchMakeURL(const char *scheme, const char *host, int port, const char *doc,
|
||||
struct url *u;
|
||||
|
||||
if (!scheme || (!host && !doc)) {
|
||||
_url_seterr(URL_MALFORMED);
|
||||
url_seterr(URL_MALFORMED);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if (port < 0 || port > 65535) {
|
||||
_url_seterr(URL_BAD_PORT);
|
||||
url_seterr(URL_BAD_PORT);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/* allocate struct url */
|
||||
if ((u = calloc(1, sizeof(*u))) == NULL) {
|
||||
_fetch_syserr();
|
||||
fetch_syserr();
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if ((u->doc = strdup(doc ? doc : "/")) == NULL) {
|
||||
_fetch_syserr();
|
||||
fetch_syserr();
|
||||
free(u);
|
||||
return (NULL);
|
||||
}
|
||||
@ -311,7 +311,7 @@ fetchParseURL(const char *URL)
|
||||
|
||||
/* allocate struct url */
|
||||
if ((u = calloc(1, sizeof(*u))) == NULL) {
|
||||
_fetch_syserr();
|
||||
fetch_syserr();
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
@ -373,7 +373,7 @@ fetchParseURL(const char *URL)
|
||||
u->port = u->port * 10 + (*q - '0');
|
||||
else {
|
||||
/* invalid port */
|
||||
_url_seterr(URL_BAD_PORT);
|
||||
url_seterr(URL_BAD_PORT);
|
||||
goto ouch;
|
||||
}
|
||||
p = q;
|
||||
@ -390,7 +390,7 @@ fetchParseURL(const char *URL)
|
||||
|
||||
/* percent-escape whitespace. */
|
||||
if ((doc = malloc(strlen(p) * 3 + 1)) == NULL) {
|
||||
_fetch_syserr();
|
||||
fetch_syserr();
|
||||
goto ouch;
|
||||
}
|
||||
u->doc = doc;
|
||||
@ -406,7 +406,7 @@ fetchParseURL(const char *URL)
|
||||
}
|
||||
*doc = '\0';
|
||||
} else if ((u->doc = strdup(p)) == NULL) {
|
||||
_fetch_syserr();
|
||||
fetch_syserr();
|
||||
goto ouch;
|
||||
}
|
||||
|
||||
|
@ -50,11 +50,11 @@ fetchXGetFile(struct url *u, struct url_stat *us, const char *flags)
|
||||
f = fopen(u->doc, "r");
|
||||
|
||||
if (f == NULL)
|
||||
_fetch_syserr();
|
||||
fetch_syserr();
|
||||
|
||||
if (u->offset && fseeko(f, u->offset, SEEK_SET) == -1) {
|
||||
fclose(f);
|
||||
_fetch_syserr();
|
||||
fetch_syserr();
|
||||
}
|
||||
|
||||
return (f);
|
||||
@ -77,25 +77,25 @@ fetchPutFile(struct url *u, const char *flags)
|
||||
f = fopen(u->doc, "w+");
|
||||
|
||||
if (f == NULL)
|
||||
_fetch_syserr();
|
||||
fetch_syserr();
|
||||
|
||||
if (u->offset && fseeko(f, u->offset, SEEK_SET) == -1) {
|
||||
fclose(f);
|
||||
_fetch_syserr();
|
||||
fetch_syserr();
|
||||
}
|
||||
|
||||
return (f);
|
||||
}
|
||||
|
||||
static int
|
||||
_fetch_stat_file(const char *fn, struct url_stat *us)
|
||||
fetch_stat_file(const char *fn, struct url_stat *us)
|
||||
{
|
||||
struct stat sb;
|
||||
|
||||
us->size = -1;
|
||||
us->atime = us->mtime = 0;
|
||||
if (stat(fn, &sb) == -1) {
|
||||
_fetch_syserr();
|
||||
fetch_syserr();
|
||||
return (-1);
|
||||
}
|
||||
us->size = sb.st_size;
|
||||
@ -107,7 +107,7 @@ _fetch_stat_file(const char *fn, struct url_stat *us)
|
||||
int
|
||||
fetchStatFile(struct url *u, struct url_stat *us, const char *flags __unused)
|
||||
{
|
||||
return (_fetch_stat_file(u->doc, us));
|
||||
return (fetch_stat_file(u->doc, us));
|
||||
}
|
||||
|
||||
struct url_ent *
|
||||
@ -122,7 +122,7 @@ fetchListFile(struct url *u, const char *flags __unused)
|
||||
int l;
|
||||
|
||||
if ((dir = opendir(u->doc)) == NULL) {
|
||||
_fetch_syserr();
|
||||
fetch_syserr();
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
@ -136,10 +136,10 @@ fetchListFile(struct url *u, const char *flags __unused)
|
||||
while ((de = readdir(dir)) != NULL) {
|
||||
strncpy(p, de->d_name, l - 1);
|
||||
p[l - 1] = 0;
|
||||
if (_fetch_stat_file(fn, &us) == -1)
|
||||
if (fetch_stat_file(fn, &us) == -1)
|
||||
/* should I return a partial result, or abort? */
|
||||
break;
|
||||
_fetch_add_entry(&ue, &size, &len, de->d_name, &us);
|
||||
fetch_add_entry(&ue, &size, &len, de->d_name, &us);
|
||||
}
|
||||
|
||||
return (ue);
|
||||
|
@ -135,16 +135,16 @@ unmappedaddr(struct sockaddr_in6 *sin6)
|
||||
* Get server response
|
||||
*/
|
||||
static int
|
||||
_ftp_chkerr(conn_t *conn)
|
||||
ftp_chkerr(conn_t *conn)
|
||||
{
|
||||
if (_fetch_getln(conn) == -1) {
|
||||
_fetch_syserr();
|
||||
if (fetch_getln(conn) == -1) {
|
||||
fetch_syserr();
|
||||
return (-1);
|
||||
}
|
||||
if (isftpinfo(conn->buf)) {
|
||||
while (conn->buflen && !isftpreply(conn->buf)) {
|
||||
if (_fetch_getln(conn) == -1) {
|
||||
_fetch_syserr();
|
||||
if (fetch_getln(conn) == -1) {
|
||||
fetch_syserr();
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
@ -155,7 +155,7 @@ _ftp_chkerr(conn_t *conn)
|
||||
conn->buf[conn->buflen] = '\0';
|
||||
|
||||
if (!isftpreply(conn->buf)) {
|
||||
_ftp_seterr(FTP_PROTOCOL_ERROR);
|
||||
ftp_seterr(FTP_PROTOCOL_ERROR);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
@ -170,7 +170,7 @@ _ftp_chkerr(conn_t *conn)
|
||||
* Send a command and check reply
|
||||
*/
|
||||
static int
|
||||
_ftp_cmd(conn_t *conn, const char *fmt, ...)
|
||||
ftp_cmd(conn_t *conn, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
size_t len;
|
||||
@ -183,26 +183,26 @@ _ftp_cmd(conn_t *conn, const char *fmt, ...)
|
||||
|
||||
if (msg == NULL) {
|
||||
errno = ENOMEM;
|
||||
_fetch_syserr();
|
||||
fetch_syserr();
|
||||
return (-1);
|
||||
}
|
||||
|
||||
r = _fetch_putln(conn, msg, len);
|
||||
r = fetch_putln(conn, msg, len);
|
||||
free(msg);
|
||||
|
||||
if (r == -1) {
|
||||
_fetch_syserr();
|
||||
fetch_syserr();
|
||||
return (-1);
|
||||
}
|
||||
|
||||
return (_ftp_chkerr(conn));
|
||||
return (ftp_chkerr(conn));
|
||||
}
|
||||
|
||||
/*
|
||||
* Return a pointer to the filename part of a path
|
||||
*/
|
||||
static const char *
|
||||
_ftp_filename(const char *file, int *len, int *type)
|
||||
ftp_filename(const char *file, int *len, int *type)
|
||||
{
|
||||
const char *s;
|
||||
|
||||
@ -225,7 +225,7 @@ _ftp_filename(const char *file, int *len, int *type)
|
||||
* command.
|
||||
*/
|
||||
static int
|
||||
_ftp_pwd(conn_t *conn, char *pwd, size_t pwdlen)
|
||||
ftp_pwd(conn_t *conn, char *pwd, size_t pwdlen)
|
||||
{
|
||||
char *src, *dst, *end;
|
||||
int q;
|
||||
@ -261,7 +261,7 @@ _ftp_pwd(conn_t *conn, char *pwd, size_t pwdlen)
|
||||
* file.
|
||||
*/
|
||||
static int
|
||||
_ftp_cwd(conn_t *conn, const char *file)
|
||||
ftp_cwd(conn_t *conn, const char *file)
|
||||
{
|
||||
const char *beg, *end;
|
||||
char pwd[PATH_MAX];
|
||||
@ -270,9 +270,9 @@ _ftp_cwd(conn_t *conn, const char *file)
|
||||
/* If no slashes in name, no need to change dirs. */
|
||||
if ((end = strrchr(file, '/')) == NULL)
|
||||
return (0);
|
||||
if ((e = _ftp_cmd(conn, "PWD")) != FTP_WORKING_DIRECTORY ||
|
||||
(e = _ftp_pwd(conn, pwd, sizeof(pwd))) != FTP_OK) {
|
||||
_ftp_seterr(e);
|
||||
if ((e = ftp_cmd(conn, "PWD")) != FTP_WORKING_DIRECTORY ||
|
||||
(e = ftp_pwd(conn, pwd, sizeof(pwd))) != FTP_OK) {
|
||||
ftp_seterr(e);
|
||||
return (-1);
|
||||
}
|
||||
for (;;) {
|
||||
@ -289,10 +289,10 @@ _ftp_cwd(conn_t *conn, const char *file)
|
||||
/* Keep going up a dir until we have a matching prefix. */
|
||||
if (pwd[i] == '\0' && (file[i - 1] == '/' || file[i] == '/'))
|
||||
break;
|
||||
if ((e = _ftp_cmd(conn, "CDUP")) != FTP_FILE_ACTION_OK ||
|
||||
(e = _ftp_cmd(conn, "PWD")) != FTP_WORKING_DIRECTORY ||
|
||||
(e = _ftp_pwd(conn, pwd, sizeof(pwd))) != FTP_OK) {
|
||||
_ftp_seterr(e);
|
||||
if ((e = ftp_cmd(conn, "CDUP")) != FTP_FILE_ACTION_OK ||
|
||||
(e = ftp_cmd(conn, "PWD")) != FTP_WORKING_DIRECTORY ||
|
||||
(e = ftp_pwd(conn, pwd, sizeof(pwd))) != FTP_OK) {
|
||||
ftp_seterr(e);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
@ -307,7 +307,7 @@ _ftp_cwd(conn_t *conn, const char *file)
|
||||
return (0);
|
||||
|
||||
/* Change to the directory all in one chunk (e.g., foo/bar/baz). */
|
||||
e = _ftp_cmd(conn, "CWD %.*s", (int)(end - beg), beg);
|
||||
e = ftp_cmd(conn, "CWD %.*s", (int)(end - beg), beg);
|
||||
if (e == FTP_FILE_ACTION_OK)
|
||||
return (0);
|
||||
#endif /* FTP_COMBINE_CWDS */
|
||||
@ -318,9 +318,9 @@ _ftp_cwd(conn_t *conn, const char *file)
|
||||
++beg, ++i;
|
||||
for (++i; file + i < end && file[i] != '/'; ++i)
|
||||
/* nothing */ ;
|
||||
e = _ftp_cmd(conn, "CWD %.*s", file + i - beg, beg);
|
||||
e = ftp_cmd(conn, "CWD %.*s", file + i - beg, beg);
|
||||
if (e != FTP_FILE_ACTION_OK) {
|
||||
_ftp_seterr(e);
|
||||
ftp_seterr(e);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
@ -331,7 +331,7 @@ _ftp_cwd(conn_t *conn, const char *file)
|
||||
* Set transfer mode and data type
|
||||
*/
|
||||
static int
|
||||
_ftp_mode_type(conn_t *conn, int mode, int type)
|
||||
ftp_mode_type(conn_t *conn, int mode, int type)
|
||||
{
|
||||
int e;
|
||||
|
||||
@ -344,7 +344,7 @@ _ftp_mode_type(conn_t *conn, int mode, int type)
|
||||
default:
|
||||
return (FTP_PROTOCOL_ERROR);
|
||||
}
|
||||
if ((e = _ftp_cmd(conn, "MODE %c", mode)) != FTP_OK) {
|
||||
if ((e = ftp_cmd(conn, "MODE %c", mode)) != FTP_OK) {
|
||||
if (mode == 'S') {
|
||||
/*
|
||||
* Stream mode is supposed to be the default - so
|
||||
@ -380,7 +380,7 @@ _ftp_mode_type(conn_t *conn, int mode, int type)
|
||||
default:
|
||||
return (FTP_PROTOCOL_ERROR);
|
||||
}
|
||||
if ((e = _ftp_cmd(conn, "TYPE %c", type)) != FTP_OK)
|
||||
if ((e = ftp_cmd(conn, "TYPE %c", type)) != FTP_OK)
|
||||
return (e);
|
||||
|
||||
return (FTP_OK);
|
||||
@ -390,7 +390,7 @@ _ftp_mode_type(conn_t *conn, int mode, int type)
|
||||
* Request and parse file stats
|
||||
*/
|
||||
static int
|
||||
_ftp_stat(conn_t *conn, const char *file, struct url_stat *us)
|
||||
ftp_stat(conn_t *conn, const char *file, struct url_stat *us)
|
||||
{
|
||||
char *ln;
|
||||
const char *filename;
|
||||
@ -402,16 +402,16 @@ _ftp_stat(conn_t *conn, const char *file, struct url_stat *us)
|
||||
us->size = -1;
|
||||
us->atime = us->mtime = 0;
|
||||
|
||||
filename = _ftp_filename(file, &filenamelen, &type);
|
||||
filename = ftp_filename(file, &filenamelen, &type);
|
||||
|
||||
if ((e = _ftp_mode_type(conn, 0, type)) != FTP_OK) {
|
||||
_ftp_seterr(e);
|
||||
if ((e = ftp_mode_type(conn, 0, type)) != FTP_OK) {
|
||||
ftp_seterr(e);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
e = _ftp_cmd(conn, "SIZE %.*s", filenamelen, filename);
|
||||
e = ftp_cmd(conn, "SIZE %.*s", filenamelen, filename);
|
||||
if (e != FTP_FILE_STATUS) {
|
||||
_ftp_seterr(e);
|
||||
ftp_seterr(e);
|
||||
return (-1);
|
||||
}
|
||||
for (ln = conn->buf + 4; *ln && isspace(*ln); ln++)
|
||||
@ -419,7 +419,7 @@ _ftp_stat(conn_t *conn, const char *file, struct url_stat *us)
|
||||
for (us->size = 0; *ln && isdigit(*ln); ln++)
|
||||
us->size = us->size * 10 + *ln - '0';
|
||||
if (*ln && !isspace(*ln)) {
|
||||
_ftp_seterr(FTP_PROTOCOL_ERROR);
|
||||
ftp_seterr(FTP_PROTOCOL_ERROR);
|
||||
us->size = -1;
|
||||
return (-1);
|
||||
}
|
||||
@ -427,9 +427,9 @@ _ftp_stat(conn_t *conn, const char *file, struct url_stat *us)
|
||||
us->size = -1;
|
||||
DEBUG(fprintf(stderr, "size: [%lld]\n", (long long)us->size));
|
||||
|
||||
e = _ftp_cmd(conn, "MDTM %.*s", filenamelen, filename);
|
||||
e = ftp_cmd(conn, "MDTM %.*s", filenamelen, filename);
|
||||
if (e != FTP_FILE_STATUS) {
|
||||
_ftp_seterr(e);
|
||||
ftp_seterr(e);
|
||||
return (-1);
|
||||
}
|
||||
for (ln = conn->buf + 4; *ln && isspace(*ln); ln++)
|
||||
@ -443,13 +443,13 @@ _ftp_stat(conn_t *conn, const char *file, struct url_stat *us)
|
||||
ln[1] = '0';
|
||||
break;
|
||||
default:
|
||||
_ftp_seterr(FTP_PROTOCOL_ERROR);
|
||||
ftp_seterr(FTP_PROTOCOL_ERROR);
|
||||
return (-1);
|
||||
}
|
||||
if (sscanf(ln, "%04d%02d%02d%02d%02d%02d",
|
||||
&tm.tm_year, &tm.tm_mon, &tm.tm_mday,
|
||||
&tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) {
|
||||
_ftp_seterr(FTP_PROTOCOL_ERROR);
|
||||
ftp_seterr(FTP_PROTOCOL_ERROR);
|
||||
return (-1);
|
||||
}
|
||||
tm.tm_mon--;
|
||||
@ -478,13 +478,13 @@ struct ftpio {
|
||||
int err; /* Error code */
|
||||
};
|
||||
|
||||
static int _ftp_readfn(void *, char *, int);
|
||||
static int _ftp_writefn(void *, const char *, int);
|
||||
static fpos_t _ftp_seekfn(void *, fpos_t, int);
|
||||
static int _ftp_closefn(void *);
|
||||
static int ftp_readfn(void *, char *, int);
|
||||
static int ftp_writefn(void *, const char *, int);
|
||||
static fpos_t ftp_seekfn(void *, fpos_t, int);
|
||||
static int ftp_closefn(void *);
|
||||
|
||||
static int
|
||||
_ftp_readfn(void *v, char *buf, int len)
|
||||
ftp_readfn(void *v, char *buf, int len)
|
||||
{
|
||||
struct ftpio *io;
|
||||
int r;
|
||||
@ -504,7 +504,7 @@ _ftp_readfn(void *v, char *buf, int len)
|
||||
}
|
||||
if (io->eof)
|
||||
return (0);
|
||||
r = _fetch_read(io->dconn, buf, len);
|
||||
r = fetch_read(io->dconn, buf, len);
|
||||
if (r > 0)
|
||||
return (r);
|
||||
if (r == 0) {
|
||||
@ -517,7 +517,7 @@ _ftp_readfn(void *v, char *buf, int len)
|
||||
}
|
||||
|
||||
static int
|
||||
_ftp_writefn(void *v, const char *buf, int len)
|
||||
ftp_writefn(void *v, const char *buf, int len)
|
||||
{
|
||||
struct ftpio *io;
|
||||
int w;
|
||||
@ -535,7 +535,7 @@ _ftp_writefn(void *v, const char *buf, int len)
|
||||
errno = io->err;
|
||||
return (-1);
|
||||
}
|
||||
w = _fetch_write(io->dconn, buf, len);
|
||||
w = fetch_write(io->dconn, buf, len);
|
||||
if (w >= 0)
|
||||
return (w);
|
||||
if (errno != EINTR)
|
||||
@ -544,7 +544,7 @@ _ftp_writefn(void *v, const char *buf, int len)
|
||||
}
|
||||
|
||||
static fpos_t
|
||||
_ftp_seekfn(void *v, fpos_t pos __unused, int whence __unused)
|
||||
ftp_seekfn(void *v, fpos_t pos __unused, int whence __unused)
|
||||
{
|
||||
struct ftpio *io;
|
||||
|
||||
@ -558,7 +558,7 @@ _ftp_seekfn(void *v, fpos_t pos __unused, int whence __unused)
|
||||
}
|
||||
|
||||
static int
|
||||
_ftp_closefn(void *v)
|
||||
ftp_closefn(void *v)
|
||||
{
|
||||
struct ftpio *io;
|
||||
int r;
|
||||
@ -574,20 +574,20 @@ _ftp_closefn(void *v)
|
||||
errno = EBADF;
|
||||
return (-1);
|
||||
}
|
||||
_fetch_close(io->dconn);
|
||||
fetch_close(io->dconn);
|
||||
io->dir = -1;
|
||||
io->dconn = NULL;
|
||||
DEBUG(fprintf(stderr, "Waiting for final status\n"));
|
||||
r = _ftp_chkerr(io->cconn);
|
||||
r = ftp_chkerr(io->cconn);
|
||||
if (io->cconn == cached_connection && io->cconn->ref == 1)
|
||||
cached_connection = NULL;
|
||||
_fetch_close(io->cconn);
|
||||
fetch_close(io->cconn);
|
||||
free(io);
|
||||
return (r == FTP_TRANSFER_COMPLETE) ? 0 : -1;
|
||||
}
|
||||
|
||||
static FILE *
|
||||
_ftp_setup(conn_t *cconn, conn_t *dconn, int mode)
|
||||
ftp_setup(conn_t *cconn, conn_t *dconn, int mode)
|
||||
{
|
||||
struct ftpio *io;
|
||||
FILE *f;
|
||||
@ -600,7 +600,7 @@ _ftp_setup(conn_t *cconn, conn_t *dconn, int mode)
|
||||
io->dconn = dconn;
|
||||
io->dir = mode;
|
||||
io->eof = io->err = 0;
|
||||
f = funopen(io, _ftp_readfn, _ftp_writefn, _ftp_seekfn, _ftp_closefn);
|
||||
f = funopen(io, ftp_readfn, ftp_writefn, ftp_seekfn, ftp_closefn);
|
||||
if (f == NULL)
|
||||
free(io);
|
||||
return (f);
|
||||
@ -610,7 +610,7 @@ _ftp_setup(conn_t *cconn, conn_t *dconn, int mode)
|
||||
* Transfer file
|
||||
*/
|
||||
static FILE *
|
||||
_ftp_transfer(conn_t *conn, const char *oper, const char *file,
|
||||
ftp_transfer(conn_t *conn, const char *oper, const char *file,
|
||||
int mode, off_t offset, const char *flags)
|
||||
{
|
||||
struct sockaddr_storage sa;
|
||||
@ -636,10 +636,10 @@ _ftp_transfer(conn_t *conn, const char *oper, const char *file,
|
||||
strncasecmp(s, "no", 2) != 0);
|
||||
|
||||
/* isolate filename */
|
||||
filename = _ftp_filename(file, &filenamelen, &type);
|
||||
filename = ftp_filename(file, &filenamelen, &type);
|
||||
|
||||
/* set transfer mode and data type */
|
||||
if ((e = _ftp_mode_type(conn, 0, type)) != FTP_OK)
|
||||
if ((e = ftp_mode_type(conn, 0, type)) != FTP_OK)
|
||||
goto ouch;
|
||||
|
||||
/* find our own address, bind, and listen */
|
||||
@ -651,7 +651,7 @@ _ftp_transfer(conn_t *conn, const char *oper, const char *file,
|
||||
|
||||
/* open data socket */
|
||||
if ((sd = socket(sa.ss_family, SOCK_STREAM, IPPROTO_TCP)) == -1) {
|
||||
_fetch_syserr();
|
||||
fetch_syserr();
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
@ -663,17 +663,17 @@ _ftp_transfer(conn_t *conn, const char *oper, const char *file,
|
||||
|
||||
/* send PASV command */
|
||||
if (verbose)
|
||||
_fetch_info("setting passive mode");
|
||||
fetch_info("setting passive mode");
|
||||
switch (sa.ss_family) {
|
||||
case AF_INET:
|
||||
if ((e = _ftp_cmd(conn, "PASV")) != FTP_PASSIVE_MODE)
|
||||
if ((e = ftp_cmd(conn, "PASV")) != FTP_PASSIVE_MODE)
|
||||
goto ouch;
|
||||
break;
|
||||
case AF_INET6:
|
||||
if ((e = _ftp_cmd(conn, "EPSV")) != FTP_EPASSIVE_MODE) {
|
||||
if ((e = ftp_cmd(conn, "EPSV")) != FTP_EPASSIVE_MODE) {
|
||||
if (e == -1)
|
||||
goto ouch;
|
||||
if ((e = _ftp_cmd(conn, "LPSV")) !=
|
||||
if ((e = ftp_cmd(conn, "LPSV")) !=
|
||||
FTP_LPASSIVE_MODE)
|
||||
goto ouch;
|
||||
}
|
||||
@ -725,7 +725,7 @@ _ftp_transfer(conn_t *conn, const char *oper, const char *file,
|
||||
|
||||
/* seek to required offset */
|
||||
if (offset)
|
||||
if (_ftp_cmd(conn, "REST %lu", (u_long)offset) != FTP_FILE_OK)
|
||||
if (ftp_cmd(conn, "REST %lu", (u_long)offset) != FTP_FILE_OK)
|
||||
goto sysouch;
|
||||
|
||||
/* construct sockaddr for data socket */
|
||||
@ -760,18 +760,18 @@ _ftp_transfer(conn_t *conn, const char *oper, const char *file,
|
||||
|
||||
/* connect to data port */
|
||||
if (verbose)
|
||||
_fetch_info("opening data connection");
|
||||
fetch_info("opening data connection");
|
||||
bindaddr = getenv("FETCH_BIND_ADDRESS");
|
||||
if (bindaddr != NULL && *bindaddr != '\0' &&
|
||||
_fetch_bind(sd, sa.ss_family, bindaddr) != 0)
|
||||
fetch_bind(sd, sa.ss_family, bindaddr) != 0)
|
||||
goto sysouch;
|
||||
if (connect(sd, (struct sockaddr *)&sa, sa.ss_len) == -1)
|
||||
goto sysouch;
|
||||
|
||||
/* make the server initiate the transfer */
|
||||
if (verbose)
|
||||
_fetch_info("initiating transfer");
|
||||
e = _ftp_cmd(conn, "%s %.*s", oper, filenamelen, filename);
|
||||
fetch_info("initiating transfer");
|
||||
e = ftp_cmd(conn, "%s %.*s", oper, filenamelen, filename);
|
||||
if (e != FTP_CONNECTION_ALREADY_OPEN && e != FTP_OPEN_DATA_CONNECTION)
|
||||
goto ouch;
|
||||
|
||||
@ -801,7 +801,7 @@ _ftp_transfer(conn_t *conn, const char *oper, const char *file,
|
||||
break;
|
||||
}
|
||||
if (verbose)
|
||||
_fetch_info("binding data socket");
|
||||
fetch_info("binding data socket");
|
||||
if (bind(sd, (struct sockaddr *)&sa, sa.ss_len) == -1)
|
||||
goto sysouch;
|
||||
if (listen(sd, 1) == -1)
|
||||
@ -815,7 +815,7 @@ _ftp_transfer(conn_t *conn, const char *oper, const char *file,
|
||||
sin4 = (struct sockaddr_in *)&sa;
|
||||
a = ntohl(sin4->sin_addr.s_addr);
|
||||
p = ntohs(sin4->sin_port);
|
||||
e = _ftp_cmd(conn, "PORT %d,%d,%d,%d,%d,%d",
|
||||
e = ftp_cmd(conn, "PORT %d,%d,%d,%d,%d,%d",
|
||||
(a >> 24) & 0xff, (a >> 16) & 0xff,
|
||||
(a >> 8) & 0xff, a & 0xff,
|
||||
(p >> 8) & 0xff, p & 0xff);
|
||||
@ -828,14 +828,14 @@ _ftp_transfer(conn_t *conn, const char *oper, const char *file,
|
||||
if (getnameinfo((struct sockaddr *)&sa, sa.ss_len,
|
||||
hname, sizeof(hname),
|
||||
NULL, 0, NI_NUMERICHOST) == 0) {
|
||||
e = _ftp_cmd(conn, "EPRT |%d|%s|%d|", 2, hname,
|
||||
e = ftp_cmd(conn, "EPRT |%d|%s|%d|", 2, hname,
|
||||
htons(sin6->sin6_port));
|
||||
if (e == -1)
|
||||
goto ouch;
|
||||
}
|
||||
if (e != FTP_OK) {
|
||||
ap = (char *)&sin6->sin6_addr;
|
||||
e = _ftp_cmd(conn,
|
||||
e = ftp_cmd(conn,
|
||||
"LPRT %d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
|
||||
6, 16,
|
||||
UC(ap[0]), UC(ap[1]), UC(ap[2]), UC(ap[3]),
|
||||
@ -856,13 +856,13 @@ _ftp_transfer(conn_t *conn, const char *oper, const char *file,
|
||||
|
||||
/* seek to required offset */
|
||||
if (offset)
|
||||
if (_ftp_cmd(conn, "REST %ju", (uintmax_t)offset) != FTP_FILE_OK)
|
||||
if (ftp_cmd(conn, "REST %ju", (uintmax_t)offset) != FTP_FILE_OK)
|
||||
goto sysouch;
|
||||
|
||||
/* make the server initiate the transfer */
|
||||
if (verbose)
|
||||
_fetch_info("initiating transfer");
|
||||
e = _ftp_cmd(conn, "%s %.*s", oper, filenamelen, filename);
|
||||
fetch_info("initiating transfer");
|
||||
e = ftp_cmd(conn, "%s %.*s", oper, filenamelen, filename);
|
||||
if (e != FTP_CONNECTION_ALREADY_OPEN && e != FTP_OPEN_DATA_CONNECTION)
|
||||
goto ouch;
|
||||
|
||||
@ -873,19 +873,19 @@ _ftp_transfer(conn_t *conn, const char *oper, const char *file,
|
||||
sd = d;
|
||||
}
|
||||
|
||||
if ((df = _ftp_setup(conn, _fetch_reopen(sd), mode)) == NULL)
|
||||
if ((df = ftp_setup(conn, fetch_reopen(sd), mode)) == NULL)
|
||||
goto sysouch;
|
||||
return (df);
|
||||
|
||||
sysouch:
|
||||
_fetch_syserr();
|
||||
fetch_syserr();
|
||||
if (sd >= 0)
|
||||
close(sd);
|
||||
return (NULL);
|
||||
|
||||
ouch:
|
||||
if (e != -1)
|
||||
_ftp_seterr(e);
|
||||
ftp_seterr(e);
|
||||
if (sd >= 0)
|
||||
close(sd);
|
||||
return (NULL);
|
||||
@ -895,7 +895,7 @@ _ftp_transfer(conn_t *conn, const char *oper, const char *file,
|
||||
* Authenticate
|
||||
*/
|
||||
static int
|
||||
_ftp_authenticate(conn_t *conn, struct url *url, struct url *purl)
|
||||
ftp_authenticate(conn_t *conn, struct url *url, struct url *purl)
|
||||
{
|
||||
const char *user, *pwd, *logname;
|
||||
char pbuf[MAXHOSTNAMELEN + MAXLOGNAME + 1];
|
||||
@ -905,18 +905,18 @@ _ftp_authenticate(conn_t *conn, struct url *url, struct url *purl)
|
||||
|
||||
/* send user name and password */
|
||||
if (url->user[0] == '\0')
|
||||
_fetch_netrc_auth(url);
|
||||
fetch_netrc_auth(url);
|
||||
user = url->user;
|
||||
if (*user == '\0')
|
||||
user = getenv("FTP_LOGIN");
|
||||
if (user == NULL || *user == '\0')
|
||||
user = FTP_ANONYMOUS_USER;
|
||||
if (purl && url->port == _fetch_default_port(url->scheme))
|
||||
e = _ftp_cmd(conn, "USER %s@%s", user, url->host);
|
||||
if (purl && url->port == fetch_default_port(url->scheme))
|
||||
e = ftp_cmd(conn, "USER %s@%s", user, url->host);
|
||||
else if (purl)
|
||||
e = _ftp_cmd(conn, "USER %s@%s@%d", user, url->host, url->port);
|
||||
e = ftp_cmd(conn, "USER %s@%s@%d", user, url->host, url->port);
|
||||
else
|
||||
e = _ftp_cmd(conn, "USER %s", user);
|
||||
e = ftp_cmd(conn, "USER %s", user);
|
||||
|
||||
/* did the server request a password? */
|
||||
if (e == FTP_NEED_PASSWORD) {
|
||||
@ -933,7 +933,7 @@ _ftp_authenticate(conn_t *conn, struct url *url, struct url *purl)
|
||||
gethostname(pbuf + len, sizeof(pbuf) - len);
|
||||
pwd = pbuf;
|
||||
}
|
||||
e = _ftp_cmd(conn, "PASS %s", pwd);
|
||||
e = ftp_cmd(conn, "PASS %s", pwd);
|
||||
}
|
||||
|
||||
return (e);
|
||||
@ -943,7 +943,7 @@ _ftp_authenticate(conn_t *conn, struct url *url, struct url *purl)
|
||||
* Log on to FTP server
|
||||
*/
|
||||
static conn_t *
|
||||
_ftp_connect(struct url *url, struct url *purl, const char *flags)
|
||||
ftp_connect(struct url *url, struct url *purl, const char *flags)
|
||||
{
|
||||
conn_t *conn;
|
||||
int e, direct, verbose;
|
||||
@ -966,24 +966,24 @@ _ftp_connect(struct url *url, struct url *purl, const char *flags)
|
||||
/* check for proxy */
|
||||
if (purl) {
|
||||
/* XXX proxy authentication! */
|
||||
conn = _fetch_connect(purl->host, purl->port, af, verbose);
|
||||
conn = fetch_connect(purl->host, purl->port, af, verbose);
|
||||
} else {
|
||||
/* no proxy, go straight to target */
|
||||
conn = _fetch_connect(url->host, url->port, af, verbose);
|
||||
conn = fetch_connect(url->host, url->port, af, verbose);
|
||||
purl = NULL;
|
||||
}
|
||||
|
||||
/* check connection */
|
||||
if (conn == NULL)
|
||||
/* _fetch_connect() has already set an error code */
|
||||
/* fetch_connect() has already set an error code */
|
||||
return (NULL);
|
||||
|
||||
/* expect welcome message */
|
||||
if ((e = _ftp_chkerr(conn)) != FTP_SERVICE_READY)
|
||||
if ((e = ftp_chkerr(conn)) != FTP_SERVICE_READY)
|
||||
goto fouch;
|
||||
|
||||
/* authenticate */
|
||||
if ((e = _ftp_authenticate(conn, url, purl)) != FTP_LOGGED_IN)
|
||||
if ((e = ftp_authenticate(conn, url, purl)) != FTP_LOGGED_IN)
|
||||
goto fouch;
|
||||
|
||||
/* TODO: Request extended features supported, if any (RFC 3659). */
|
||||
@ -993,8 +993,8 @@ _ftp_connect(struct url *url, struct url *purl, const char *flags)
|
||||
|
||||
fouch:
|
||||
if (e != -1)
|
||||
_ftp_seterr(e);
|
||||
_fetch_close(conn);
|
||||
ftp_seterr(e);
|
||||
fetch_close(conn);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
@ -1002,19 +1002,19 @@ _ftp_connect(struct url *url, struct url *purl, const char *flags)
|
||||
* Disconnect from server
|
||||
*/
|
||||
static void
|
||||
_ftp_disconnect(conn_t *conn)
|
||||
ftp_disconnect(conn_t *conn)
|
||||
{
|
||||
(void)_ftp_cmd(conn, "QUIT");
|
||||
(void)ftp_cmd(conn, "QUIT");
|
||||
if (conn == cached_connection && conn->ref == 1)
|
||||
cached_connection = NULL;
|
||||
_fetch_close(conn);
|
||||
fetch_close(conn);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if we're already connected
|
||||
*/
|
||||
static int
|
||||
_ftp_isconnected(struct url *url)
|
||||
ftp_isconnected(struct url *url)
|
||||
{
|
||||
return (cached_connection
|
||||
&& (strcmp(url->host, cached_host.host) == 0)
|
||||
@ -1027,28 +1027,28 @@ _ftp_isconnected(struct url *url)
|
||||
* Check the cache, reconnect if no luck
|
||||
*/
|
||||
static conn_t *
|
||||
_ftp_cached_connect(struct url *url, struct url *purl, const char *flags)
|
||||
ftp_cached_connect(struct url *url, struct url *purl, const char *flags)
|
||||
{
|
||||
conn_t *conn;
|
||||
int e;
|
||||
|
||||
/* set default port */
|
||||
if (!url->port)
|
||||
url->port = _fetch_default_port(url->scheme);
|
||||
url->port = fetch_default_port(url->scheme);
|
||||
|
||||
/* try to use previously cached connection */
|
||||
if (_ftp_isconnected(url)) {
|
||||
e = _ftp_cmd(cached_connection, "NOOP");
|
||||
if (ftp_isconnected(url)) {
|
||||
e = ftp_cmd(cached_connection, "NOOP");
|
||||
if (e == FTP_OK || e == FTP_SYNTAX_ERROR)
|
||||
return (_fetch_ref(cached_connection));
|
||||
return (fetch_ref(cached_connection));
|
||||
}
|
||||
|
||||
/* connect to server */
|
||||
if ((conn = _ftp_connect(url, purl, flags)) == NULL)
|
||||
if ((conn = ftp_connect(url, purl, flags)) == NULL)
|
||||
return (NULL);
|
||||
if (cached_connection)
|
||||
_ftp_disconnect(cached_connection);
|
||||
cached_connection = _fetch_ref(conn);
|
||||
ftp_disconnect(cached_connection);
|
||||
cached_connection = fetch_ref(conn);
|
||||
memcpy(&cached_host, url, sizeof(*url));
|
||||
return (conn);
|
||||
}
|
||||
@ -1057,7 +1057,7 @@ _ftp_cached_connect(struct url *url, struct url *purl, const char *flags)
|
||||
* Check the proxy settings
|
||||
*/
|
||||
static struct url *
|
||||
_ftp_get_proxy(const char *flags)
|
||||
ftp_get_proxy(const char *flags)
|
||||
{
|
||||
struct url *purl;
|
||||
char *p;
|
||||
@ -1074,7 +1074,7 @@ _ftp_get_proxy(const char *flags)
|
||||
strcpy(purl->scheme, SCHEME_HTTP);
|
||||
}
|
||||
if (!purl->port)
|
||||
purl->port = _fetch_default_proxy_port(purl->scheme);
|
||||
purl->port = fetch_default_proxy_port(purl->scheme);
|
||||
if (strcasecmp(purl->scheme, SCHEME_FTP) == 0 ||
|
||||
strcasecmp(purl->scheme, SCHEME_HTTP) == 0)
|
||||
return (purl);
|
||||
@ -1087,7 +1087,7 @@ _ftp_get_proxy(const char *flags)
|
||||
* Process an FTP request
|
||||
*/
|
||||
FILE *
|
||||
_ftp_request(struct url *url, const char *op, struct url_stat *us,
|
||||
ftp_request(struct url *url, const char *op, struct url_stat *us,
|
||||
struct url *purl, const char *flags)
|
||||
{
|
||||
conn_t *conn;
|
||||
@ -1096,9 +1096,9 @@ _ftp_request(struct url *url, const char *op, struct url_stat *us,
|
||||
/* check if we should use HTTP instead */
|
||||
if (purl && strcasecmp(purl->scheme, SCHEME_HTTP) == 0) {
|
||||
if (strcmp(op, "STAT") == 0)
|
||||
return (_http_request(url, "HEAD", us, purl, flags));
|
||||
return (http_request(url, "HEAD", us, purl, flags));
|
||||
else if (strcmp(op, "RETR") == 0)
|
||||
return (_http_request(url, "GET", us, purl, flags));
|
||||
return (http_request(url, "GET", us, purl, flags));
|
||||
/*
|
||||
* Our HTTP code doesn't support PUT requests yet, so try
|
||||
* a direct connection.
|
||||
@ -1106,18 +1106,18 @@ _ftp_request(struct url *url, const char *op, struct url_stat *us,
|
||||
}
|
||||
|
||||
/* connect to server */
|
||||
conn = _ftp_cached_connect(url, purl, flags);
|
||||
conn = ftp_cached_connect(url, purl, flags);
|
||||
if (purl)
|
||||
fetchFreeURL(purl);
|
||||
if (conn == NULL)
|
||||
return (NULL);
|
||||
|
||||
/* change directory */
|
||||
if (_ftp_cwd(conn, url->doc) == -1)
|
||||
if (ftp_cwd(conn, url->doc) == -1)
|
||||
return (NULL);
|
||||
|
||||
/* stat file */
|
||||
if (us && _ftp_stat(conn, url->doc, us) == -1
|
||||
if (us && ftp_stat(conn, url->doc, us) == -1
|
||||
&& fetchLastErrCode != FETCH_PROTO
|
||||
&& fetchLastErrCode != FETCH_UNAVAIL)
|
||||
return (NULL);
|
||||
@ -1131,7 +1131,7 @@ _ftp_request(struct url *url, const char *op, struct url_stat *us,
|
||||
oflag = O_RDONLY;
|
||||
|
||||
/* initiate the transfer */
|
||||
return (_ftp_transfer(conn, op, url->doc, oflag, url->offset, flags));
|
||||
return (ftp_transfer(conn, op, url->doc, oflag, url->offset, flags));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1140,7 +1140,7 @@ _ftp_request(struct url *url, const char *op, struct url_stat *us,
|
||||
FILE *
|
||||
fetchXGetFTP(struct url *url, struct url_stat *us, const char *flags)
|
||||
{
|
||||
return (_ftp_request(url, "RETR", us, _ftp_get_proxy(flags), flags));
|
||||
return (ftp_request(url, "RETR", us, ftp_get_proxy(flags), flags));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1159,8 +1159,8 @@ FILE *
|
||||
fetchPutFTP(struct url *url, const char *flags)
|
||||
{
|
||||
|
||||
return (_ftp_request(url, CHECK_FLAG('a') ? "APPE" : "STOR", NULL,
|
||||
_ftp_get_proxy(flags), flags));
|
||||
return (ftp_request(url, CHECK_FLAG('a') ? "APPE" : "STOR", NULL,
|
||||
ftp_get_proxy(flags), flags));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1171,7 +1171,7 @@ fetchStatFTP(struct url *url, struct url_stat *us, const char *flags)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
f = _ftp_request(url, "STAT", us, _ftp_get_proxy(flags), flags);
|
||||
f = ftp_request(url, "STAT", us, ftp_get_proxy(flags), flags);
|
||||
if (f == NULL)
|
||||
return (-1);
|
||||
return (0);
|
||||
|
@ -130,11 +130,11 @@ struct httpio
|
||||
* Get next chunk header
|
||||
*/
|
||||
static int
|
||||
_http_new_chunk(struct httpio *io)
|
||||
http_new_chunk(struct httpio *io)
|
||||
{
|
||||
char *p;
|
||||
|
||||
if (_fetch_getln(io->conn) == -1)
|
||||
if (fetch_getln(io->conn) == -1)
|
||||
return (-1);
|
||||
|
||||
if (io->conn->buflen < 2 || !ishexnumber(*io->conn->buf))
|
||||
@ -173,7 +173,7 @@ _http_new_chunk(struct httpio *io)
|
||||
* Grow the input buffer to at least len bytes
|
||||
*/
|
||||
static inline int
|
||||
_http_growbuf(struct httpio *io, size_t len)
|
||||
http_growbuf(struct httpio *io, size_t len)
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
@ -191,7 +191,7 @@ _http_growbuf(struct httpio *io, size_t len)
|
||||
* Fill the input buffer, do chunk decoding on the fly
|
||||
*/
|
||||
static int
|
||||
_http_fillbuf(struct httpio *io, size_t len)
|
||||
http_fillbuf(struct httpio *io, size_t len)
|
||||
{
|
||||
if (io->error)
|
||||
return (-1);
|
||||
@ -199,9 +199,9 @@ _http_fillbuf(struct httpio *io, size_t len)
|
||||
return (0);
|
||||
|
||||
if (io->chunked == 0) {
|
||||
if (_http_growbuf(io, len) == -1)
|
||||
if (http_growbuf(io, len) == -1)
|
||||
return (-1);
|
||||
if ((io->buflen = _fetch_read(io->conn, io->buf, len)) == -1) {
|
||||
if ((io->buflen = fetch_read(io->conn, io->buf, len)) == -1) {
|
||||
io->error = 1;
|
||||
return (-1);
|
||||
}
|
||||
@ -210,7 +210,7 @@ _http_fillbuf(struct httpio *io, size_t len)
|
||||
}
|
||||
|
||||
if (io->chunksize == 0) {
|
||||
switch (_http_new_chunk(io)) {
|
||||
switch (http_new_chunk(io)) {
|
||||
case -1:
|
||||
io->error = 1;
|
||||
return (-1);
|
||||
@ -222,9 +222,9 @@ _http_fillbuf(struct httpio *io, size_t len)
|
||||
|
||||
if (len > io->chunksize)
|
||||
len = io->chunksize;
|
||||
if (_http_growbuf(io, len) == -1)
|
||||
if (http_growbuf(io, len) == -1)
|
||||
return (-1);
|
||||
if ((io->buflen = _fetch_read(io->conn, io->buf, len)) == -1) {
|
||||
if ((io->buflen = fetch_read(io->conn, io->buf, len)) == -1) {
|
||||
io->error = 1;
|
||||
return (-1);
|
||||
}
|
||||
@ -233,7 +233,7 @@ _http_fillbuf(struct httpio *io, size_t len)
|
||||
if (io->chunksize == 0) {
|
||||
char endl[2];
|
||||
|
||||
if (_fetch_read(io->conn, endl, 2) != 2 ||
|
||||
if (fetch_read(io->conn, endl, 2) != 2 ||
|
||||
endl[0] != '\r' || endl[1] != '\n')
|
||||
return (-1);
|
||||
}
|
||||
@ -247,7 +247,7 @@ _http_fillbuf(struct httpio *io, size_t len)
|
||||
* Read function
|
||||
*/
|
||||
static int
|
||||
_http_readfn(void *v, char *buf, int len)
|
||||
http_readfn(void *v, char *buf, int len)
|
||||
{
|
||||
struct httpio *io = (struct httpio *)v;
|
||||
int l, pos;
|
||||
@ -260,7 +260,7 @@ _http_readfn(void *v, char *buf, int len)
|
||||
for (pos = 0; len > 0; pos += l, len -= l) {
|
||||
/* empty buffer */
|
||||
if (!io->buf || io->bufpos == io->buflen)
|
||||
if (_http_fillbuf(io, len) < 1)
|
||||
if (http_fillbuf(io, len) < 1)
|
||||
break;
|
||||
l = io->buflen - io->bufpos;
|
||||
if (len < l)
|
||||
@ -278,23 +278,23 @@ _http_readfn(void *v, char *buf, int len)
|
||||
* Write function
|
||||
*/
|
||||
static int
|
||||
_http_writefn(void *v, const char *buf, int len)
|
||||
http_writefn(void *v, const char *buf, int len)
|
||||
{
|
||||
struct httpio *io = (struct httpio *)v;
|
||||
|
||||
return (_fetch_write(io->conn, buf, len));
|
||||
return (fetch_write(io->conn, buf, len));
|
||||
}
|
||||
|
||||
/*
|
||||
* Close function
|
||||
*/
|
||||
static int
|
||||
_http_closefn(void *v)
|
||||
http_closefn(void *v)
|
||||
{
|
||||
struct httpio *io = (struct httpio *)v;
|
||||
int r;
|
||||
|
||||
r = _fetch_close(io->conn);
|
||||
r = fetch_close(io->conn);
|
||||
if (io->buf)
|
||||
free(io->buf);
|
||||
free(io);
|
||||
@ -305,20 +305,20 @@ _http_closefn(void *v)
|
||||
* Wrap a file descriptor up
|
||||
*/
|
||||
static FILE *
|
||||
_http_funopen(conn_t *conn, int chunked)
|
||||
http_funopen(conn_t *conn, int chunked)
|
||||
{
|
||||
struct httpio *io;
|
||||
FILE *f;
|
||||
|
||||
if ((io = calloc(1, sizeof(*io))) == NULL) {
|
||||
_fetch_syserr();
|
||||
fetch_syserr();
|
||||
return (NULL);
|
||||
}
|
||||
io->conn = conn;
|
||||
io->chunked = chunked;
|
||||
f = funopen(io, _http_readfn, _http_writefn, NULL, _http_closefn);
|
||||
f = funopen(io, http_readfn, http_writefn, NULL, http_closefn);
|
||||
if (f == NULL) {
|
||||
_fetch_syserr();
|
||||
fetch_syserr();
|
||||
free(io);
|
||||
return (NULL);
|
||||
}
|
||||
@ -362,7 +362,7 @@ static struct {
|
||||
* Send a formatted line; optionally echo to terminal
|
||||
*/
|
||||
static int
|
||||
_http_cmd(conn_t *conn, const char *fmt, ...)
|
||||
http_cmd(conn_t *conn, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
size_t len;
|
||||
@ -375,15 +375,15 @@ _http_cmd(conn_t *conn, const char *fmt, ...)
|
||||
|
||||
if (msg == NULL) {
|
||||
errno = ENOMEM;
|
||||
_fetch_syserr();
|
||||
fetch_syserr();
|
||||
return (-1);
|
||||
}
|
||||
|
||||
r = _fetch_putln(conn, msg, len);
|
||||
r = fetch_putln(conn, msg, len);
|
||||
free(msg);
|
||||
|
||||
if (r == -1) {
|
||||
_fetch_syserr();
|
||||
fetch_syserr();
|
||||
return (-1);
|
||||
}
|
||||
|
||||
@ -394,11 +394,11 @@ _http_cmd(conn_t *conn, const char *fmt, ...)
|
||||
* Get and parse status line
|
||||
*/
|
||||
static int
|
||||
_http_get_reply(conn_t *conn)
|
||||
http_get_reply(conn_t *conn)
|
||||
{
|
||||
char *p;
|
||||
|
||||
if (_fetch_getln(conn) == -1)
|
||||
if (fetch_getln(conn) == -1)
|
||||
return (-1);
|
||||
/*
|
||||
* A valid status line looks like "HTTP/m.n xyz reason" where m
|
||||
@ -429,7 +429,7 @@ _http_get_reply(conn_t *conn)
|
||||
* to the beginning of the value.
|
||||
*/
|
||||
static const char *
|
||||
_http_match(const char *str, const char *hdr)
|
||||
http_match(const char *str, const char *hdr)
|
||||
{
|
||||
while (*str && *hdr && tolower(*str++) == tolower(*hdr++))
|
||||
/* nothing */;
|
||||
@ -444,11 +444,11 @@ _http_match(const char *str, const char *hdr)
|
||||
* Get the next header and return the appropriate symbolic code.
|
||||
*/
|
||||
static hdr_t
|
||||
_http_next_header(conn_t *conn, const char **p)
|
||||
http_next_header(conn_t *conn, const char **p)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (_fetch_getln(conn) == -1)
|
||||
if (fetch_getln(conn) == -1)
|
||||
return (hdr_syserror);
|
||||
while (conn->buflen && isspace(conn->buf[conn->buflen - 1]))
|
||||
conn->buflen--;
|
||||
@ -462,7 +462,7 @@ _http_next_header(conn_t *conn, const char **p)
|
||||
* characters except "()<>@,;:\\\"{}".
|
||||
*/
|
||||
for (i = 0; hdr_names[i].num != hdr_unknown; i++)
|
||||
if ((*p = _http_match(hdr_names[i].name, conn->buf)) != NULL)
|
||||
if ((*p = http_match(hdr_names[i].name, conn->buf)) != NULL)
|
||||
return (hdr_names[i].num);
|
||||
return (hdr_unknown);
|
||||
}
|
||||
@ -471,7 +471,7 @@ _http_next_header(conn_t *conn, const char **p)
|
||||
* Parse a last-modified header
|
||||
*/
|
||||
static int
|
||||
_http_parse_mtime(const char *p, time_t *mtime)
|
||||
http_parse_mtime(const char *p, time_t *mtime)
|
||||
{
|
||||
char locale[64], *r;
|
||||
struct tm tm;
|
||||
@ -495,7 +495,7 @@ _http_parse_mtime(const char *p, time_t *mtime)
|
||||
* Parse a content-length header
|
||||
*/
|
||||
static int
|
||||
_http_parse_length(const char *p, off_t *length)
|
||||
http_parse_length(const char *p, off_t *length)
|
||||
{
|
||||
off_t len;
|
||||
|
||||
@ -513,7 +513,7 @@ _http_parse_length(const char *p, off_t *length)
|
||||
* Parse a content-range header
|
||||
*/
|
||||
static int
|
||||
_http_parse_range(const char *p, off_t *offset, off_t *length, off_t *size)
|
||||
http_parse_range(const char *p, off_t *offset, off_t *length, off_t *size)
|
||||
{
|
||||
off_t first, last, len;
|
||||
|
||||
@ -560,7 +560,7 @@ _http_parse_range(const char *p, off_t *offset, off_t *length, off_t *size)
|
||||
* Base64 encoding
|
||||
*/
|
||||
static char *
|
||||
_http_base64(const char *src)
|
||||
http_base64(const char *src)
|
||||
{
|
||||
static const char base64[] =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
@ -616,7 +616,7 @@ _http_base64(const char *src)
|
||||
* Encode username and password
|
||||
*/
|
||||
static int
|
||||
_http_basic_auth(conn_t *conn, const char *hdr, const char *usr, const char *pwd)
|
||||
http_basic_auth(conn_t *conn, const char *hdr, const char *usr, const char *pwd)
|
||||
{
|
||||
char *upw, *auth;
|
||||
int r;
|
||||
@ -625,11 +625,11 @@ _http_basic_auth(conn_t *conn, const char *hdr, const char *usr, const char *pwd
|
||||
DEBUG(fprintf(stderr, "pwd: [%s]\n", pwd));
|
||||
if (asprintf(&upw, "%s:%s", usr, pwd) == -1)
|
||||
return (-1);
|
||||
auth = _http_base64(upw);
|
||||
auth = http_base64(upw);
|
||||
free(upw);
|
||||
if (auth == NULL)
|
||||
return (-1);
|
||||
r = _http_cmd(conn, "%s: Basic %s", hdr, auth);
|
||||
r = http_cmd(conn, "%s: Basic %s", hdr, auth);
|
||||
free(auth);
|
||||
return (r);
|
||||
}
|
||||
@ -638,7 +638,7 @@ _http_basic_auth(conn_t *conn, const char *hdr, const char *usr, const char *pwd
|
||||
* Send an authorization header
|
||||
*/
|
||||
static int
|
||||
_http_authorize(conn_t *conn, const char *hdr, const char *p)
|
||||
http_authorize(conn_t *conn, const char *hdr, const char *p)
|
||||
{
|
||||
/* basic authorization */
|
||||
if (strncasecmp(p, "basic:", 6) == 0) {
|
||||
@ -655,7 +655,7 @@ _http_authorize(conn_t *conn, const char *hdr, const char *p)
|
||||
user = str;
|
||||
pwd = strchr(str, ':');
|
||||
*pwd++ = '\0';
|
||||
r = _http_basic_auth(conn, hdr, user, pwd);
|
||||
r = http_basic_auth(conn, hdr, user, pwd);
|
||||
free(str);
|
||||
return (r);
|
||||
}
|
||||
@ -671,7 +671,7 @@ _http_authorize(conn_t *conn, const char *hdr, const char *p)
|
||||
* Connect to the correct HTTP server or proxy.
|
||||
*/
|
||||
static conn_t *
|
||||
_http_connect(struct url *URL, struct url *purl, const char *flags)
|
||||
http_connect(struct url *URL, struct url *purl, const char *flags)
|
||||
{
|
||||
conn_t *conn;
|
||||
int verbose;
|
||||
@ -699,15 +699,15 @@ _http_connect(struct url *URL, struct url *purl, const char *flags)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if ((conn = _fetch_connect(URL->host, URL->port, af, verbose)) == NULL)
|
||||
/* _fetch_connect() has already set an error code */
|
||||
if ((conn = fetch_connect(URL->host, URL->port, af, verbose)) == NULL)
|
||||
/* fetch_connect() has already set an error code */
|
||||
return (NULL);
|
||||
if (strcasecmp(URL->scheme, SCHEME_HTTPS) == 0 &&
|
||||
_fetch_ssl(conn, verbose) == -1) {
|
||||
_fetch_close(conn);
|
||||
fetch_ssl(conn, verbose) == -1) {
|
||||
fetch_close(conn);
|
||||
/* grrr */
|
||||
errno = EAUTH;
|
||||
_fetch_syserr();
|
||||
fetch_syserr();
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
@ -718,7 +718,7 @@ _http_connect(struct url *URL, struct url *purl, const char *flags)
|
||||
}
|
||||
|
||||
static struct url *
|
||||
_http_get_proxy(const char *flags)
|
||||
http_get_proxy(const char *flags)
|
||||
{
|
||||
struct url *purl;
|
||||
char *p;
|
||||
@ -730,7 +730,7 @@ _http_get_proxy(const char *flags)
|
||||
if (!*purl->scheme)
|
||||
strcpy(purl->scheme, SCHEME_HTTP);
|
||||
if (!purl->port)
|
||||
purl->port = _fetch_default_proxy_port(purl->scheme);
|
||||
purl->port = fetch_default_proxy_port(purl->scheme);
|
||||
if (strcasecmp(purl->scheme, SCHEME_HTTP) == 0)
|
||||
return (purl);
|
||||
fetchFreeURL(purl);
|
||||
@ -739,7 +739,7 @@ _http_get_proxy(const char *flags)
|
||||
}
|
||||
|
||||
static void
|
||||
_http_print_html(FILE *out, FILE *in)
|
||||
http_print_html(FILE *out, FILE *in)
|
||||
{
|
||||
size_t len;
|
||||
char *line, *p, *q;
|
||||
@ -788,7 +788,7 @@ _http_print_html(FILE *out, FILE *in)
|
||||
* XXX off into a separate function.
|
||||
*/
|
||||
FILE *
|
||||
_http_request(struct url *URL, const char *op, struct url_stat *us,
|
||||
http_request(struct url *URL, const char *op, struct url_stat *us,
|
||||
struct url *purl, const char *flags)
|
||||
{
|
||||
conn_t *conn;
|
||||
@ -831,18 +831,18 @@ _http_request(struct url *URL, const char *op, struct url_stat *us,
|
||||
|
||||
/* check port */
|
||||
if (!url->port)
|
||||
url->port = _fetch_default_port(url->scheme);
|
||||
url->port = fetch_default_port(url->scheme);
|
||||
|
||||
/* were we redirected to an FTP URL? */
|
||||
if (purl == NULL && strcmp(url->scheme, SCHEME_FTP) == 0) {
|
||||
if (strcmp(op, "GET") == 0)
|
||||
return (_ftp_request(url, "RETR", us, purl, flags));
|
||||
return (ftp_request(url, "RETR", us, purl, flags));
|
||||
else if (strcmp(op, "HEAD") == 0)
|
||||
return (_ftp_request(url, "STAT", us, purl, flags));
|
||||
return (ftp_request(url, "STAT", us, purl, flags));
|
||||
}
|
||||
|
||||
/* connect to server or proxy */
|
||||
if ((conn = _http_connect(url, purl, flags)) == NULL)
|
||||
if ((conn = http_connect(url, purl, flags)) == NULL)
|
||||
goto ouch;
|
||||
|
||||
host = url->host;
|
||||
@ -852,7 +852,7 @@ _http_request(struct url *URL, const char *op, struct url_stat *us,
|
||||
host = hbuf;
|
||||
}
|
||||
#endif
|
||||
if (url->port != _fetch_default_port(url->scheme)) {
|
||||
if (url->port != fetch_default_port(url->scheme)) {
|
||||
if (host != hbuf) {
|
||||
strcpy(hbuf, host);
|
||||
host = hbuf;
|
||||
@ -863,38 +863,38 @@ _http_request(struct url *URL, const char *op, struct url_stat *us,
|
||||
|
||||
/* send request */
|
||||
if (verbose)
|
||||
_fetch_info("requesting %s://%s%s",
|
||||
fetch_info("requesting %s://%s%s",
|
||||
url->scheme, host, url->doc);
|
||||
if (purl) {
|
||||
_http_cmd(conn, "%s %s://%s%s HTTP/1.1",
|
||||
http_cmd(conn, "%s %s://%s%s HTTP/1.1",
|
||||
op, url->scheme, host, url->doc);
|
||||
} else {
|
||||
_http_cmd(conn, "%s %s HTTP/1.1",
|
||||
http_cmd(conn, "%s %s HTTP/1.1",
|
||||
op, url->doc);
|
||||
}
|
||||
|
||||
/* virtual host */
|
||||
_http_cmd(conn, "Host: %s", host);
|
||||
http_cmd(conn, "Host: %s", host);
|
||||
|
||||
/* proxy authorization */
|
||||
if (purl) {
|
||||
if (*purl->user || *purl->pwd)
|
||||
_http_basic_auth(conn, "Proxy-Authorization",
|
||||
http_basic_auth(conn, "Proxy-Authorization",
|
||||
purl->user, purl->pwd);
|
||||
else if ((p = getenv("HTTP_PROXY_AUTH")) != NULL && *p != '\0')
|
||||
_http_authorize(conn, "Proxy-Authorization", p);
|
||||
http_authorize(conn, "Proxy-Authorization", p);
|
||||
}
|
||||
|
||||
/* server authorization */
|
||||
if (need_auth || *url->user || *url->pwd) {
|
||||
if (*url->user || *url->pwd)
|
||||
_http_basic_auth(conn, "Authorization", url->user, url->pwd);
|
||||
http_basic_auth(conn, "Authorization", url->user, url->pwd);
|
||||
else if ((p = getenv("HTTP_AUTH")) != NULL && *p != '\0')
|
||||
_http_authorize(conn, "Authorization", p);
|
||||
http_authorize(conn, "Authorization", p);
|
||||
else if (fetchAuthMethod && fetchAuthMethod(url) == 0) {
|
||||
_http_basic_auth(conn, "Authorization", url->user, url->pwd);
|
||||
http_basic_auth(conn, "Authorization", url->user, url->pwd);
|
||||
} else {
|
||||
_http_seterr(HTTP_NEED_AUTH);
|
||||
http_seterr(HTTP_NEED_AUTH);
|
||||
goto ouch;
|
||||
}
|
||||
}
|
||||
@ -902,19 +902,19 @@ _http_request(struct url *URL, const char *op, struct url_stat *us,
|
||||
/* other headers */
|
||||
if ((p = getenv("HTTP_REFERER")) != NULL && *p != '\0') {
|
||||
if (strcasecmp(p, "auto") == 0)
|
||||
_http_cmd(conn, "Referer: %s://%s%s",
|
||||
http_cmd(conn, "Referer: %s://%s%s",
|
||||
url->scheme, host, url->doc);
|
||||
else
|
||||
_http_cmd(conn, "Referer: %s", p);
|
||||
http_cmd(conn, "Referer: %s", p);
|
||||
}
|
||||
if ((p = getenv("HTTP_USER_AGENT")) != NULL && *p != '\0')
|
||||
_http_cmd(conn, "User-Agent: %s", p);
|
||||
http_cmd(conn, "User-Agent: %s", p);
|
||||
else
|
||||
_http_cmd(conn, "User-Agent: %s " _LIBFETCH_VER, getprogname());
|
||||
http_cmd(conn, "User-Agent: %s " _LIBFETCH_VER, getprogname());
|
||||
if (url->offset > 0)
|
||||
_http_cmd(conn, "Range: bytes=%lld-", (long long)url->offset);
|
||||
_http_cmd(conn, "Connection: close");
|
||||
_http_cmd(conn, "");
|
||||
http_cmd(conn, "Range: bytes=%lld-", (long long)url->offset);
|
||||
http_cmd(conn, "Connection: close");
|
||||
http_cmd(conn, "");
|
||||
|
||||
/*
|
||||
* Force the queued request to be dispatched. Normally, one
|
||||
@ -931,7 +931,7 @@ _http_request(struct url *URL, const char *op, struct url_stat *us,
|
||||
sizeof(val));
|
||||
|
||||
/* get reply */
|
||||
switch (_http_get_reply(conn)) {
|
||||
switch (http_get_reply(conn)) {
|
||||
case HTTP_OK:
|
||||
case HTTP_PARTIAL:
|
||||
/* fine */
|
||||
@ -950,12 +950,12 @@ _http_request(struct url *URL, const char *op, struct url_stat *us,
|
||||
* We already sent out authorization code,
|
||||
* so there's nothing more we can do.
|
||||
*/
|
||||
_http_seterr(conn->err);
|
||||
http_seterr(conn->err);
|
||||
goto ouch;
|
||||
}
|
||||
/* try again, but send the password this time */
|
||||
if (verbose)
|
||||
_fetch_info("server requires authorization");
|
||||
fetch_info("server requires authorization");
|
||||
break;
|
||||
case HTTP_NEED_PROXY_AUTH:
|
||||
/*
|
||||
@ -963,7 +963,7 @@ _http_request(struct url *URL, const char *op, struct url_stat *us,
|
||||
* our proxy authorization code, so there's
|
||||
* nothing more we can do.
|
||||
*/
|
||||
_http_seterr(conn->err);
|
||||
http_seterr(conn->err);
|
||||
goto ouch;
|
||||
case HTTP_BAD_RANGE:
|
||||
/*
|
||||
@ -975,10 +975,10 @@ _http_request(struct url *URL, const char *op, struct url_stat *us,
|
||||
case HTTP_PROTOCOL_ERROR:
|
||||
/* fall through */
|
||||
case -1:
|
||||
_fetch_syserr();
|
||||
fetch_syserr();
|
||||
goto ouch;
|
||||
default:
|
||||
_http_seterr(conn->err);
|
||||
http_seterr(conn->err);
|
||||
if (!verbose)
|
||||
goto ouch;
|
||||
/* fall through so we can get the full error message */
|
||||
@ -986,21 +986,21 @@ _http_request(struct url *URL, const char *op, struct url_stat *us,
|
||||
|
||||
/* get headers */
|
||||
do {
|
||||
switch ((h = _http_next_header(conn, &p))) {
|
||||
switch ((h = http_next_header(conn, &p))) {
|
||||
case hdr_syserror:
|
||||
_fetch_syserr();
|
||||
fetch_syserr();
|
||||
goto ouch;
|
||||
case hdr_error:
|
||||
_http_seterr(HTTP_PROTOCOL_ERROR);
|
||||
http_seterr(HTTP_PROTOCOL_ERROR);
|
||||
goto ouch;
|
||||
case hdr_content_length:
|
||||
_http_parse_length(p, &clength);
|
||||
http_parse_length(p, &clength);
|
||||
break;
|
||||
case hdr_content_range:
|
||||
_http_parse_range(p, &offset, &length, &size);
|
||||
http_parse_range(p, &offset, &length, &size);
|
||||
break;
|
||||
case hdr_last_modified:
|
||||
_http_parse_mtime(p, &mtime);
|
||||
http_parse_mtime(p, &mtime);
|
||||
break;
|
||||
case hdr_location:
|
||||
if (!HTTP_REDIRECT(conn->err))
|
||||
@ -1008,7 +1008,7 @@ _http_request(struct url *URL, const char *op, struct url_stat *us,
|
||||
if (new)
|
||||
free(new);
|
||||
if (verbose)
|
||||
_fetch_info("%d redirect to %s", conn->err, p);
|
||||
fetch_info("%d redirect to %s", conn->err, p);
|
||||
if (*p == '/')
|
||||
/* absolute path */
|
||||
new = fetchMakeURL(url->scheme, url->host, url->port, p,
|
||||
@ -1048,7 +1048,7 @@ _http_request(struct url *URL, const char *op, struct url_stat *us,
|
||||
if (conn->err == HTTP_NEED_AUTH) {
|
||||
e = conn->err;
|
||||
need_auth = 1;
|
||||
_fetch_close(conn);
|
||||
fetch_close(conn);
|
||||
conn = NULL;
|
||||
continue;
|
||||
}
|
||||
@ -1061,7 +1061,7 @@ _http_request(struct url *URL, const char *op, struct url_stat *us,
|
||||
conn->err = HTTP_OK;
|
||||
break;
|
||||
} else {
|
||||
_http_seterr(conn->err);
|
||||
http_seterr(conn->err);
|
||||
goto ouch;
|
||||
}
|
||||
}
|
||||
@ -1073,7 +1073,7 @@ _http_request(struct url *URL, const char *op, struct url_stat *us,
|
||||
/* all other cases: we got a redirect */
|
||||
e = conn->err;
|
||||
need_auth = 0;
|
||||
_fetch_close(conn);
|
||||
fetch_close(conn);
|
||||
conn = NULL;
|
||||
if (!new) {
|
||||
DEBUG(fprintf(stderr, "redirect with no new location\n"));
|
||||
@ -1086,7 +1086,7 @@ _http_request(struct url *URL, const char *op, struct url_stat *us,
|
||||
|
||||
/* we failed, or ran out of retries */
|
||||
if (conn == NULL) {
|
||||
_http_seterr(e);
|
||||
http_seterr(e);
|
||||
goto ouch;
|
||||
}
|
||||
|
||||
@ -1097,7 +1097,7 @@ _http_request(struct url *URL, const char *op, struct url_stat *us,
|
||||
|
||||
/* check for inconsistencies */
|
||||
if (clength != -1 && length != -1 && clength != length) {
|
||||
_http_seterr(HTTP_PROTOCOL_ERROR);
|
||||
http_seterr(HTTP_PROTOCOL_ERROR);
|
||||
goto ouch;
|
||||
}
|
||||
if (clength == -1)
|
||||
@ -1105,7 +1105,7 @@ _http_request(struct url *URL, const char *op, struct url_stat *us,
|
||||
if (clength != -1)
|
||||
length = offset + clength;
|
||||
if (length != -1 && size != -1 && length != size) {
|
||||
_http_seterr(HTTP_PROTOCOL_ERROR);
|
||||
http_seterr(HTTP_PROTOCOL_ERROR);
|
||||
goto ouch;
|
||||
}
|
||||
if (size == -1)
|
||||
@ -1119,7 +1119,7 @@ _http_request(struct url *URL, const char *op, struct url_stat *us,
|
||||
|
||||
/* too far? */
|
||||
if (URL->offset > 0 && offset > URL->offset) {
|
||||
_http_seterr(HTTP_PROTOCOL_ERROR);
|
||||
http_seterr(HTTP_PROTOCOL_ERROR);
|
||||
goto ouch;
|
||||
}
|
||||
|
||||
@ -1128,8 +1128,8 @@ _http_request(struct url *URL, const char *op, struct url_stat *us,
|
||||
URL->length = clength;
|
||||
|
||||
/* wrap it up in a FILE */
|
||||
if ((f = _http_funopen(conn, chunked)) == NULL) {
|
||||
_fetch_syserr();
|
||||
if ((f = http_funopen(conn, chunked)) == NULL) {
|
||||
fetch_syserr();
|
||||
goto ouch;
|
||||
}
|
||||
|
||||
@ -1139,7 +1139,7 @@ _http_request(struct url *URL, const char *op, struct url_stat *us,
|
||||
fetchFreeURL(purl);
|
||||
|
||||
if (HTTP_ERROR(conn->err)) {
|
||||
_http_print_html(stderr, f);
|
||||
http_print_html(stderr, f);
|
||||
fclose(f);
|
||||
f = NULL;
|
||||
}
|
||||
@ -1152,7 +1152,7 @@ _http_request(struct url *URL, const char *op, struct url_stat *us,
|
||||
if (purl)
|
||||
fetchFreeURL(purl);
|
||||
if (conn != NULL)
|
||||
_fetch_close(conn);
|
||||
fetch_close(conn);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
@ -1167,7 +1167,7 @@ _http_request(struct url *URL, const char *op, struct url_stat *us,
|
||||
FILE *
|
||||
fetchXGetHTTP(struct url *URL, struct url_stat *us, const char *flags)
|
||||
{
|
||||
return (_http_request(URL, "GET", us, _http_get_proxy(flags), flags));
|
||||
return (http_request(URL, "GET", us, http_get_proxy(flags), flags));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1197,7 +1197,7 @@ fetchStatHTTP(struct url *URL, struct url_stat *us, const char *flags)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
f = _http_request(URL, "HEAD", us, _http_get_proxy(flags), flags);
|
||||
f = http_request(URL, "HEAD", us, http_get_proxy(flags), flags);
|
||||
if (f == NULL)
|
||||
return (-1);
|
||||
fclose(f);
|
||||
|
Loading…
Reference in New Issue
Block a user