diff options
-rw-r--r-- | lib/libfetch/fetch.c | 8 | ||||
-rw-r--r-- | lib/libfetch/file.c | 2 | ||||
-rw-r--r-- | lib/libfetch/ftp.c | 22 | ||||
-rw-r--r-- | lib/libfetch/http.c | 12 |
4 files changed, 22 insertions, 22 deletions
diff --git a/lib/libfetch/fetch.c b/lib/libfetch/fetch.c index b814336..46da7ce 100644 --- a/lib/libfetch/fetch.c +++ b/lib/libfetch/fetch.c @@ -74,7 +74,7 @@ fetchXGet(struct url *URL, struct url_stat *us, char *flags) { int direct; - direct = (flags && strchr(flags, 'd')); + direct = CHECK_FLAG('d'); if (strcasecmp(URL->scheme, SCHEME_FILE) == 0) return fetchXGetFile(URL, us, flags); else if (strcasecmp(URL->scheme, SCHEME_HTTP) == 0) @@ -106,7 +106,7 @@ fetchPut(struct url *URL, char *flags) { int direct; - direct = (flags && strchr(flags, 'd')); + direct = CHECK_FLAG('d'); if (strcasecmp(URL->scheme, SCHEME_FILE) == 0) return fetchPutFile(URL, flags); else if (strcasecmp(URL->scheme, SCHEME_HTTP) == 0) @@ -128,7 +128,7 @@ fetchStat(struct url *URL, struct url_stat *us, char *flags) { int direct; - direct = (flags && strchr(flags, 'd')); + direct = CHECK_FLAG('d'); if (strcasecmp(URL->scheme, SCHEME_FILE) == 0) return fetchStatFile(URL, us, flags); else if (strcasecmp(URL->scheme, SCHEME_HTTP) == 0) @@ -150,7 +150,7 @@ fetchList(struct url *URL, char *flags) { int direct; - direct = (flags && strchr(flags, 'd')); + direct = CHECK_FLAG('d'); if (strcasecmp(URL->scheme, SCHEME_FILE) == 0) return fetchListFile(URL, flags); else if (strcasecmp(URL->scheme, SCHEME_HTTP) == 0) diff --git a/lib/libfetch/file.c b/lib/libfetch/file.c index 7cf6efd..5d59143 100644 --- a/lib/libfetch/file.c +++ b/lib/libfetch/file.c @@ -70,7 +70,7 @@ fetchPutFile(struct url *u, char *flags) { FILE *f; - if (flags && strchr(flags, 'a')) + if (CHECK_FLAG('a')) f = fopen(u->doc, "a"); else f = fopen(u->doc, "w+"); diff --git a/lib/libfetch/ftp.c b/lib/libfetch/ftp.c index 43648926b..18da8b2 100644 --- a/lib/libfetch/ftp.c +++ b/lib/libfetch/ftp.c @@ -458,9 +458,9 @@ _ftp_transfer(int cd, char *oper, char *file, FILE *df; /* check flags */ - pasv = (flags && strchr(flags, 'p')); - high = (flags && strchr(flags, 'h')); - verbose = (flags && strchr(flags, 'v')); + pasv = CHECK_FLAG('p'); + high = CHECK_FLAG('h'); + verbose = CHECK_FLAG('v'); /* passive mode */ if (!pasv) @@ -740,11 +740,11 @@ _ftp_connect(struct url *url, struct url *purl, char *flags) char localhost[MAXHOSTNAMELEN]; char pbuf[MAXHOSTNAMELEN + MAXLOGNAME + 1]; - direct = (flags && strchr(flags, 'd')); - verbose = (flags && strchr(flags, 'v')); - if ((flags && strchr(flags, '4'))) + direct = CHECK_FLAG('d'); + verbose = CHECK_FLAG('v'); + if (CHECK_FLAG('4')) af = AF_INET; - else if ((flags && strchr(flags, '6'))) + else if (CHECK_FLAG('6')) af = AF_INET6; if (direct) @@ -911,7 +911,7 @@ fetchXGetFTP(struct url *url, struct url_stat *us, char *flags) int cd; /* get the proxy URL, and check if we should use HTTP instead */ - if (!(flags && strchr(flags, 'd')) && (purl = _ftp_get_proxy()) != NULL) { + if (!CHECK_FLAG('d') && (purl = _ftp_get_proxy()) != NULL) { if (strcasecmp(purl->scheme, SCHEME_HTTP) == 0) return _http_request(url, "GET", us, purl, flags); } else { @@ -958,7 +958,7 @@ fetchPutFTP(struct url *url, char *flags) int cd; /* get the proxy URL, and check if we should use HTTP instead */ - if (!(flags && strchr(flags, 'd')) && (purl = _ftp_get_proxy()) != NULL) { + if (!CHECK_FLAG('d') && (purl = _ftp_get_proxy()) != NULL) { if (strcasecmp(purl->scheme, SCHEME_HTTP) == 0) /* XXX HTTP PUT is not implemented, so try without the proxy */ purl = NULL; @@ -978,7 +978,7 @@ fetchPutFTP(struct url *url, char *flags) return NULL; /* initiate the transfer */ - return _ftp_transfer(cd, (flags && strchr(flags, 'a')) ? "APPE" : "STOR", + return _ftp_transfer(cd, CHECK_FLAG('a') ? "APPE" : "STOR", url->doc, O_WRONLY, url->offset, flags); } @@ -992,7 +992,7 @@ fetchStatFTP(struct url *url, struct url_stat *us, char *flags) int cd; /* get the proxy URL, and check if we should use HTTP instead */ - if (!(flags && strchr(flags, 'd')) && (purl = _ftp_get_proxy()) != NULL) { + if (!CHECK_FLAG('d') && (purl = _ftp_get_proxy()) != NULL) { if (strcasecmp(purl->scheme, SCHEME_HTTP) == 0) { FILE *f; diff --git a/lib/libfetch/http.c b/lib/libfetch/http.c index a386364..e8d193b 100644 --- a/lib/libfetch/http.c +++ b/lib/libfetch/http.c @@ -640,11 +640,11 @@ _http_connect(struct url *URL, struct url *purl, char *flags) af = AF_INET; #endif - verbose = (flags && strchr(flags, 'v')); - if (flags && strchr(flags, '4')) + verbose = CHECK_FLAG('v'); + if (CHECK_FLAG('4')) af = AF_INET; #ifdef INET6 - else if (flags && strchr(flags, '6')) + else if (CHECK_FLAG('6')) af = AF_INET6; #endif @@ -705,9 +705,9 @@ _http_request(struct url *URL, char *op, struct url_stat *us, char hbuf[MAXHOSTNAMELEN + 1]; #endif - direct = (flags && strchr(flags, 'd')); - noredirect = (flags && strchr(flags, 'A')); - verbose = (flags && strchr(flags, 'v')); + direct = CHECK_FLAG('d'); + noredirect = CHECK_FLAG('A'); + verbose = CHECK_FLAG('v'); if (direct && purl) { fetchFreeURL(purl); |