diff options
author | archie <archie@FreeBSD.org> | 2001-04-24 00:06:21 +0000 |
---|---|---|
committer | archie <archie@FreeBSD.org> | 2001-04-24 00:06:21 +0000 |
commit | 21cf7b313e0bc24fdfba9db608502a795edc2f64 (patch) | |
tree | 05583e8bec8550e39a977336f8b644648077d02e | |
parent | 6f92ffe2eb286bd4cfe49b9ef57447223e5a5858 (diff) | |
download | FreeBSD-src-21cf7b313e0bc24fdfba9db608502a795edc2f64.zip FreeBSD-src-21cf7b313e0bc24fdfba9db608502a795edc2f64.tar.gz |
Apply 'const' liberally.
Fix some other minor glitches.
-rw-r--r-- | lib/libfetch/common.c | 18 | ||||
-rw-r--r-- | lib/libfetch/common.h | 17 | ||||
-rw-r--r-- | lib/libfetch/fetch.3 | 56 | ||||
-rw-r--r-- | lib/libfetch/fetch.c | 29 | ||||
-rw-r--r-- | lib/libfetch/fetch.h | 55 | ||||
-rw-r--r-- | lib/libfetch/file.c | 12 | ||||
-rw-r--r-- | lib/libfetch/ftp.c | 36 | ||||
-rw-r--r-- | lib/libfetch/http.c | 40 |
8 files changed, 134 insertions, 129 deletions
diff --git a/lib/libfetch/common.c b/lib/libfetch/common.c index 459154f..34981e9 100644 --- a/lib/libfetch/common.c +++ b/lib/libfetch/common.c @@ -60,7 +60,7 @@ static struct fetcherr _netdb_errlist[] = { }; /* End-of-Line */ -static char ENDL[2] = "\r\n"; +static const char ENDL[2] = "\r\n"; /*** Error-reporting functions ***********************************************/ @@ -154,7 +154,7 @@ _fetch_syserr(void) * Emit status message */ void -_fetch_info(char *fmt, ...) +_fetch_info(const char *fmt, ...) { va_list ap; @@ -171,7 +171,7 @@ _fetch_info(char *fmt, ...) * Return the default port for a scheme */ int -_fetch_default_port(char *scheme) +_fetch_default_port(const char *scheme) { struct servent *se; @@ -188,7 +188,7 @@ _fetch_default_port(char *scheme) * Return the default proxy port for a scheme */ int -_fetch_default_proxy_port(char *scheme) +_fetch_default_proxy_port(const char *scheme) { if (strcasecmp(scheme, SCHEME_FTP) == 0) return FTP_DEFAULT_PROXY_PORT; @@ -201,7 +201,7 @@ _fetch_default_proxy_port(char *scheme) * Establish a TCP connection to the specified port on the specified host. */ int -_fetch_connect(char *host, int port, int af, int verbose) +_fetch_connect(const char *host, int port, int af, int verbose) { char pbuf[10]; struct addrinfo hints, *res, *res0; @@ -333,15 +333,15 @@ _fetch_getln(int fd, char **buf, size_t *size, size_t *len) * XXX currently does not enforce timeout */ int -_fetch_putln(int fd, char *str, size_t len) +_fetch_putln(int fd, const char *str, size_t len) { struct iovec iov[2]; ssize_t wlen; /* XXX should enforce timeout */ - iov[0].iov_base = str; + iov[0].iov_base = (char *)str; iov[0].iov_len = len; - iov[1].iov_base = ENDL; + iov[1].iov_base = (char *)ENDL; iov[1].iov_len = sizeof ENDL; wlen = writev(fd, iov, 2); DEBUG(fprintf(stderr, "\033[1m>>> %s\n\033[m", str)); @@ -353,7 +353,7 @@ _fetch_putln(int fd, char *str, size_t len) int _fetch_add_entry(struct url_ent **p, int *size, int *len, - char *name, struct url_stat *stat) + const char *name, struct url_stat *stat) { struct url_ent *tmp; diff --git a/lib/libfetch/common.h b/lib/libfetch/common.h index 13723a3..0c67b28 100644 --- a/lib/libfetch/common.h +++ b/lib/libfetch/common.h @@ -44,14 +44,14 @@ struct fetcherr { void _fetch_seterr(struct fetcherr *p, int e); void _fetch_syserr(void); -void _fetch_info(char *fmt, ...); -int _fetch_default_port(char *); -int _fetch_default_proxy_port(char *); -int _fetch_connect(char *host, int port, int af, int verbose); +void _fetch_info(const char *fmt, ...); +int _fetch_default_port(const char *); +int _fetch_default_proxy_port(const char *); +int _fetch_connect(const char *host, int port, int af, int verbose); int _fetch_getln(int fd, char **buf, size_t *size, size_t *len); -int _fetch_putln(int fd, char *str, size_t len); +int _fetch_putln(int fd, const char *str, size_t len); int _fetch_add_entry(struct url_ent **p, int *size, int *len, - char *name, struct url_stat *stat); + const char *name, struct url_stat *stat); #define _ftp_seterr(n) _fetch_seterr(_ftp_errlist, n) #define _http_seterr(n) _fetch_seterr(_http_errlist, n) @@ -72,8 +72,9 @@ int _fetch_add_entry(struct url_ent **p, int *size, int *len, * Note that _http_request() frees purl, which is way ugly but saves us a * whole lot of trouble. */ -FILE *_http_request(struct url *URL, char *op, struct url_stat *us, - struct url *purl, char *flags); +FILE *_http_request(struct url *URL, const char *op, + struct url_stat *us, struct url *purl, + const char *flags); /* * Check whether a particular flag is set diff --git a/lib/libfetch/fetch.3 b/lib/libfetch/fetch.3 index d1918fa..702c6bc 100644 --- a/lib/libfetch/fetch.3 +++ b/lib/libfetch/fetch.3 @@ -64,61 +64,61 @@ .Fd #include <stdio.h> .Fd #include <fetch.h> .Ft struct url * -.Fn fetchMakeURL "char *scheme" "char *host" "int port" "char *doc" "char *user" "char *pwd" +.Fn fetchMakeURL "const char *scheme" "const char *host" "int port" "const char *doc" "const char *user" "const char *pwd" .Ft struct url * -.Fn fetchParseURL "char *URL" +.Fn fetchParseURL "const char *URL" .Ft void -.Fn fetchFreeURL "struct url *URL" +.Fn fetchFreeURL "struct url *u" .Ft FILE * -.Fn fetchXGetURL "char *URL" "struct url_stat *us" "char *flags" +.Fn fetchXGetURL "const char *URL" "struct url_stat *us" "const char *flags" .Ft FILE * -.Fn fetchGetURL "char *URL" "char *flags" +.Fn fetchGetURL "const char *URL" "const char *flags" .Ft FILE * -.Fn fetchPutURL "char *URL" "char *flags" +.Fn fetchPutURL "const char *URL" "const char *flags" .Ft int -.Fn fetchStatURL "char *URL" "struct url_stat *us" "char *flags" +.Fn fetchStatURL "const char *URL" "struct url_stat *us" "const char *flags" .Ft struct url_ent * -.Fn fetchListURL "char *URL" "char *flags" +.Fn fetchListURL "const char *URL" "const char *flags" .Ft FILE * -.Fn fetchXGet "struct url *URL" "struct url_stat *us" "char *flags" +.Fn fetchXGet "struct url *u" "struct url_stat *us" "const char *flags" .Ft FILE * -.Fn fetchGet "struct url *URL" "char *flags" +.Fn fetchGet "struct url *u" "const char *flags" .Ft FILE * -.Fn fetchPut "struct url *URL" "char *flags" +.Fn fetchPut "struct url *u" "const char *flags" .Ft int -.Fn fetchStat "struct url *URL" "struct url_stat *us" "char *flags" +.Fn fetchStat "struct url *u" "struct url_stat *us" "const char *flags" .Ft struct url_ent * -.Fn fetchList "struct url *" "char *flags" +.Fn fetchList "struct url *u" "const char *flags" .Ft FILE * -.Fn fetchXGetFile "struct url *u" "struct url_stat *us" "char *flags" +.Fn fetchXGetFile "struct url *u" "struct url_stat *us" "const char *flags" .Ft FILE * -.Fn fetchGetFile "struct url *u" "char *flags" +.Fn fetchGetFile "struct url *u" "const char *flags" .Ft FILE * -.Fn fetchPutFile "struct url *u" "char *flags" +.Fn fetchPutFile "struct url *u" "const char *flags" .Ft int -.Fn fetchStatFile "struct url *URL" "struct url_stat *us" "char *flags" +.Fn fetchStatFile "struct url *u" "struct url_stat *us" "const char *flags" .Ft struct url_ent * -.Fn fetchListFile "struct url *" "char *flags" +.Fn fetchListFile "struct url *u" "const char *flags" .Ft FILE * -.Fn fetchXGetHTTP "struct url *u" "struct url_stat *us" "char *flags" +.Fn fetchXGetHTTP "struct url *u" "struct url_stat *us" "const char *flags" .Ft FILE * -.Fn fetchGetHTTP "struct url *u" "char *flags" +.Fn fetchGetHTTP "struct url *u" "const char *flags" .Ft FILE * -.Fn fetchPutHTTP "struct url *u" "char *flags" +.Fn fetchPutHTTP "struct url *u" "const char *flags" .Ft int -.Fn fetchStatHTTP "struct url *URL" "struct url_stat *us" "char *flags" +.Fn fetchStatHTTP "struct url *u" "struct url_stat *us" "const char *flags" .Ft struct url_ent * -.Fn fetchListHTTP "struct url *" "char *flags" +.Fn fetchListHTTP "struct url *u" "const char *flags" .Ft FILE * -.Fn fetchXGetFTP "struct url *u" "struct url_stat *us" "char *flags" +.Fn fetchXGetFTP "struct url *u" "struct url_stat *us" "const char *flags" .Ft FILE * -.Fn fetchGetFTP "struct url *u" "char *flags" +.Fn fetchGetFTP "struct url *u" "const char *flags" .Ft FILE * -.Fn fetchPutFTP "struct url *u" "char *flags" +.Fn fetchPutFTP "struct url *u" "const char *flags" .Ft int -.Fn fetchStatFTP "struct url *URL" "struct url_stat *us" "char *flags" +.Fn fetchStatFTP "struct url *u" "struct url_stat *us" "const char *flags" .Ft struct url_ent * -.Fn fetchListFTP "struct url *" "char *flags" +.Fn fetchListFTP "struct url *u" "const char *flags" .Sh DESCRIPTION .Pp These functions implement a high-level library for retrieving and diff --git a/lib/libfetch/fetch.c b/lib/libfetch/fetch.c index bc803d5..de23f00 100644 --- a/lib/libfetch/fetch.c +++ b/lib/libfetch/fetch.c @@ -70,7 +70,7 @@ static struct fetcherr _url_errlist[] = { * Also fill out the struct url_stat. */ FILE * -fetchXGet(struct url *URL, struct url_stat *us, char *flags) +fetchXGet(struct url *URL, struct url_stat *us, const char *flags) { int direct; @@ -92,7 +92,7 @@ fetchXGet(struct url *URL, struct url_stat *us, char *flags) * read-only stream connected to the document referenced by the URL. */ FILE * -fetchGet(struct url *URL, char *flags) +fetchGet(struct url *URL, const char *flags) { return fetchXGet(URL, NULL, flags); } @@ -102,7 +102,7 @@ fetchGet(struct url *URL, char *flags) * write-only stream connected to the document referenced by the URL. */ FILE * -fetchPut(struct url *URL, char *flags) +fetchPut(struct url *URL, const char *flags) { int direct; @@ -124,7 +124,7 @@ fetchPut(struct url *URL, char *flags) * size of the document referenced by the URL if it exists. */ int -fetchStat(struct url *URL, struct url_stat *us, char *flags) +fetchStat(struct url *URL, struct url_stat *us, const char *flags) { int direct; @@ -146,7 +146,7 @@ fetchStat(struct url *URL, struct url_stat *us, char *flags) * list of files in the directory pointed to by the URL. */ struct url_ent * -fetchList(struct url *URL, char *flags) +fetchList(struct url *URL, const char *flags) { int direct; @@ -167,7 +167,7 @@ fetchList(struct url *URL, char *flags) * Attempt to parse the given URL; if successful, call fetchXGet(). */ FILE * -fetchXGetURL(char *URL, struct url_stat *us, char *flags) +fetchXGetURL(const char *URL, struct url_stat *us, const char *flags) { struct url *u; FILE *f; @@ -185,7 +185,7 @@ fetchXGetURL(char *URL, struct url_stat *us, char *flags) * Attempt to parse the given URL; if successful, call fetchGet(). */ FILE * -fetchGetURL(char *URL, char *flags) +fetchGetURL(const char *URL, const char *flags) { return fetchXGetURL(URL, NULL, flags); } @@ -194,7 +194,7 @@ fetchGetURL(char *URL, char *flags) * Attempt to parse the given URL; if successful, call fetchPut(). */ FILE * -fetchPutURL(char *URL, char *flags) +fetchPutURL(const char *URL, const char *flags) { struct url *u; FILE *f; @@ -212,7 +212,7 @@ fetchPutURL(char *URL, char *flags) * Attempt to parse the given URL; if successful, call fetchStat(). */ int -fetchStatURL(char *URL, struct url_stat *us, char *flags) +fetchStatURL(const char *URL, struct url_stat *us, const char *flags) { struct url *u; int s; @@ -230,7 +230,7 @@ fetchStatURL(char *URL, struct url_stat *us, char *flags) * Attempt to parse the given URL; if successful, call fetchList(). */ struct url_ent * -fetchListURL(char *URL, char *flags) +fetchListURL(const char *URL, const char *flags) { struct url *u; struct url_ent *ue; @@ -248,8 +248,8 @@ fetchListURL(char *URL, char *flags) * Make a URL */ struct url * -fetchMakeURL(char *scheme, char *host, int port, char *doc, - char *user, char *pwd) +fetchMakeURL(const char *scheme, const char *host, int port, const char *doc, + const char *user, const char *pwd) { struct url *u; @@ -292,9 +292,10 @@ fetchMakeURL(char *scheme, char *host, int port, char *doc, * This almost, but not quite, RFC1738 URL syntax. */ struct url * -fetchParseURL(char *URL) +fetchParseURL(const char *URL) { - char *doc, *p, *q; + char *doc; + const char *p, *q; struct url *u; int i; diff --git a/lib/libfetch/fetch.h b/lib/libfetch/fetch.h index bc944c8..dc5fc05 100644 --- a/lib/libfetch/fetch.h +++ b/lib/libfetch/fetch.h @@ -87,41 +87,42 @@ struct url_ent { #define FETCH_VERBOSE 19 /* FILE-specific functions */ -FILE *fetchXGetFile(struct url *, struct url_stat *, char *); -FILE *fetchGetFile(struct url *, char *); -FILE *fetchPutFile(struct url *, char *); -int fetchStatFile(struct url *, struct url_stat *, char *); -struct url_ent *fetchListFile(struct url *, char *); +FILE *fetchXGetFile(struct url *, struct url_stat *, const char *); +FILE *fetchGetFile(struct url *, const char *); +FILE *fetchPutFile(struct url *, const char *); +int fetchStatFile(struct url *, struct url_stat *, const char *); +struct url_ent *fetchListFile(struct url *, const char *); /* HTTP-specific functions */ -FILE *fetchXGetHTTP(struct url *, struct url_stat *, char *); -FILE *fetchGetHTTP(struct url *, char *); -FILE *fetchPutHTTP(struct url *, char *); -int fetchStatHTTP(struct url *, struct url_stat *, char *); -struct url_ent *fetchListHTTP(struct url *, char *); +FILE *fetchXGetHTTP(struct url *, struct url_stat *, const char *); +FILE *fetchGetHTTP(struct url *, const char *); +FILE *fetchPutHTTP(struct url *, const char *); +int fetchStatHTTP(struct url *, struct url_stat *, const char *); +struct url_ent *fetchListHTTP(struct url *, const char *); /* FTP-specific functions */ -FILE *fetchXGetFTP(struct url *, struct url_stat *, char *); -FILE *fetchGetFTP(struct url *, char *); -FILE *fetchPutFTP(struct url *, char *); -int fetchStatFTP(struct url *, struct url_stat *, char *); -struct url_ent *fetchListFTP(struct url *, char *); +FILE *fetchXGetFTP(struct url *, struct url_stat *, const char *); +FILE *fetchGetFTP(struct url *, const char *); +FILE *fetchPutFTP(struct url *, const char *); +int fetchStatFTP(struct url *, struct url_stat *, const char *); +struct url_ent *fetchListFTP(struct url *, const char *); /* Generic functions */ -FILE *fetchXGetURL(char *, struct url_stat *, char *); -FILE *fetchGetURL(char *, char *); -FILE *fetchPutURL(char *, char *); -int fetchStatURL(char *, struct url_stat *, char *); -struct url_ent *fetchListURL(char *, char *); -FILE *fetchXGet(struct url *, struct url_stat *, char *); -FILE *fetchGet(struct url *, char *); -FILE *fetchPut(struct url *, char *); -int fetchStat(struct url *, struct url_stat *, char *); -struct url_ent *fetchList(struct url *, char *); +FILE *fetchXGetURL(const char *, struct url_stat *, const char *); +FILE *fetchGetURL(const char *, const char *); +FILE *fetchPutURL(const char *, const char *); +int fetchStatURL(const char *, struct url_stat *, const char *); +struct url_ent *fetchListURL(const char *, const char *); +FILE *fetchXGet(struct url *, struct url_stat *, const char *); +FILE *fetchGet(struct url *, const char *); +FILE *fetchPut(struct url *, const char *); +int fetchStat(struct url *, struct url_stat *, const char *); +struct url_ent *fetchList(struct url *, const char *); /* URL parsing */ -struct url *fetchMakeURL(char *, char *, int, char *, char *, char *); -struct url *fetchParseURL(char *); +struct url *fetchMakeURL(const char *, const char *, int, + const char *, const char *, const char *); +struct url *fetchParseURL(const char *); void fetchFreeURL(struct url *); /* Last error code */ diff --git a/lib/libfetch/file.c b/lib/libfetch/file.c index 5d59143..2db091d 100644 --- a/lib/libfetch/file.c +++ b/lib/libfetch/file.c @@ -39,7 +39,7 @@ #include "common.h" FILE * -fetchXGetFile(struct url *u, struct url_stat *us, char *flags) +fetchXGetFile(struct url *u, struct url_stat *us, const char *flags) { FILE *f; @@ -60,13 +60,13 @@ fetchXGetFile(struct url *u, struct url_stat *us, char *flags) } FILE * -fetchGetFile(struct url *u, char *flags) +fetchGetFile(struct url *u, const char *flags) { return fetchXGetFile(u, NULL, flags); } FILE * -fetchPutFile(struct url *u, char *flags) +fetchPutFile(struct url *u, const char *flags) { FILE *f; @@ -87,7 +87,7 @@ fetchPutFile(struct url *u, char *flags) } static int -_fetch_stat_file(char *fn, struct url_stat *us) +_fetch_stat_file(const char *fn, struct url_stat *us) { struct stat sb; @@ -104,13 +104,13 @@ _fetch_stat_file(char *fn, struct url_stat *us) } int -fetchStatFile(struct url *u, struct url_stat *us, char *flags) +fetchStatFile(struct url *u, struct url_stat *us, const char *flags) { return _fetch_stat_file(u->doc, us); } struct url_ent * -fetchListFile(struct url *u, char *flags) +fetchListFile(struct url *u, const char *flags) { DIR *dir; struct dirent *de; diff --git a/lib/libfetch/ftp.c b/lib/libfetch/ftp.c index a2dfc93..09b72ca 100644 --- a/lib/libfetch/ftp.c +++ b/lib/libfetch/ftp.c @@ -60,6 +60,7 @@ #include <netinet/in.h> #include <ctype.h> +#include <err.h> #include <errno.h> #include <fcntl.h> #include <netdb.h> @@ -166,7 +167,7 @@ _ftp_chkerr(int cd) * Send a command and check reply */ static int -_ftp_cmd(int cd, char *fmt, ...) +_ftp_cmd(int cd, const char *fmt, ...) { va_list ap; size_t len; @@ -197,8 +198,8 @@ _ftp_cmd(int cd, char *fmt, ...) /* * Return a pointer to the filename part of a path */ -static char * -_ftp_filename(char *file) +static const char * +_ftp_filename(const char *file) { char *s; @@ -213,7 +214,7 @@ _ftp_filename(char *file) * specified file. */ static int -_ftp_cwd(int cd, char *file) +_ftp_cwd(int cd, const char *file) { char *s; int e; @@ -234,9 +235,10 @@ _ftp_cwd(int cd, char *file) * Request and parse file stats */ static int -_ftp_stat(int cd, char *file, struct url_stat *us) +_ftp_stat(int cd, const char *file, struct url_stat *us) { - char *ln, *s; + char *ln; + const char *s; struct tm tm; time_t t; int e; @@ -447,8 +449,8 @@ _ftp_setup(int csd, int dsd, int mode) * Transfer file */ static FILE * -_ftp_transfer(int cd, char *oper, char *file, - int mode, off_t offset, char *flags) +_ftp_transfer(int cd, const char *oper, const char *file, + int mode, off_t offset, const char *flags) { struct sockaddr_storage sin; struct sockaddr_in6 *sin6; @@ -716,7 +718,7 @@ ouch: * Log on to FTP server */ static int -_ftp_connect(struct url *url, struct url *purl, char *flags) +_ftp_connect(struct url *url, struct url *purl, const char *flags) { int cd, e, direct, verbose; #ifdef INET6 @@ -725,7 +727,8 @@ _ftp_connect(struct url *url, struct url *purl, char *flags) int af = AF_INET; #endif const char *logname; - char *user, *pwd; + const char *user; + const char *pwd; char localhost[MAXHOSTNAMELEN]; char pbuf[MAXHOSTNAMELEN + MAXLOGNAME + 1]; @@ -842,7 +845,7 @@ _ftp_isconnected(struct url *url) * Check the cache, reconnect if no luck */ static int -_ftp_cached_connect(struct url *url, struct url *purl, char *flags) +_ftp_cached_connect(struct url *url, struct url *purl, const char *flags) { int e, cd; @@ -901,7 +904,7 @@ _ftp_get_proxy(void) * Get and stat file */ FILE * -fetchXGetFTP(struct url *url, struct url_stat *us, char *flags) +fetchXGetFTP(struct url *url, struct url_stat *us, const char *flags) { struct url *purl; int cd; @@ -939,7 +942,7 @@ fetchXGetFTP(struct url *url, struct url_stat *us, char *flags) * Get file */ FILE * -fetchGetFTP(struct url *url, char *flags) +fetchGetFTP(struct url *url, const char *flags) { return fetchXGetFTP(url, NULL, flags); } @@ -948,7 +951,7 @@ fetchGetFTP(struct url *url, char *flags) * Put file */ FILE * -fetchPutFTP(struct url *url, char *flags) +fetchPutFTP(struct url *url, const char *flags) { struct url *purl; int cd; @@ -982,7 +985,7 @@ fetchPutFTP(struct url *url, char *flags) * Get file stats */ int -fetchStatFTP(struct url *url, struct url_stat *us, char *flags) +fetchStatFTP(struct url *url, struct url_stat *us, const char *flags) { struct url *purl; int cd; @@ -1019,9 +1022,8 @@ fetchStatFTP(struct url *url, struct url_stat *us, char *flags) /* * List a directory */ -extern void warnx(char *, ...); struct url_ent * -fetchListFTP(struct url *url, char *flags) +fetchListFTP(struct url *url, const char *flags) { warnx("fetchListFTP(): not implemented"); return NULL; diff --git a/lib/libfetch/http.c b/lib/libfetch/http.c index 5c22097..b1332b3 100644 --- a/lib/libfetch/http.c +++ b/lib/libfetch/http.c @@ -300,7 +300,7 @@ typedef enum { /* Names of interesting headers */ static struct { hdr num; - char *name; + const char *name; } hdr_names[] = { { hdr_content_length, "Content-Length" }, { hdr_content_range, "Content-Range" }, @@ -318,7 +318,7 @@ static size_t reply_length; * Send a formatted line; optionally echo to terminal */ static int -_http_cmd(int fd, char *fmt, ...) +_http_cmd(int fd, const char *fmt, ...) { va_list ap; size_t len; @@ -386,8 +386,8 @@ _http_get_reply(int fd) * Check a header; if the type matches the given string, return a * pointer to the beginning of the value. */ -static char * -_http_match(char *str, char *hdr) +static const char * +_http_match(const char *str, const char *hdr) { while (*str && *hdr && tolower(*str++) == tolower(*hdr++)) /* nothing */; @@ -402,7 +402,7 @@ _http_match(char *str, char *hdr) * Get the next header and return the appropriate symbolic code. */ static hdr -_http_next_header(int fd, char **p) +_http_next_header(int fd, const char **p) { int i; @@ -429,7 +429,7 @@ _http_next_header(int fd, char **p) * Parse a last-modified header */ static int -_http_parse_mtime(char *p, time_t *mtime) +_http_parse_mtime(const char *p, time_t *mtime) { char locale[64], *r; struct tm tm; @@ -453,7 +453,7 @@ _http_parse_mtime(char *p, time_t *mtime) * Parse a content-length header */ static int -_http_parse_length(char *p, off_t *length) +_http_parse_length(const char *p, off_t *length) { off_t len; @@ -468,7 +468,7 @@ _http_parse_length(char *p, off_t *length) * Parse a content-range header */ static int -_http_parse_range(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) { int first, last, len; @@ -559,7 +559,7 @@ _http_base64(char *src) * Encode username and password */ static int -_http_basic_auth(int fd, char *hdr, char *usr, char *pwd) +_http_basic_auth(int fd, const char *hdr, const char *usr, const char *pwd) { char *upw, *auth; int r; @@ -579,7 +579,7 @@ _http_basic_auth(int fd, char *hdr, char *usr, char *pwd) * Send an authorization header */ static int -_http_authorize(int fd, char *hdr, char *p) +_http_authorize(int fd, const char *hdr, const char *p) { /* basic authorization */ if (strncasecmp(p, "basic:", 6) == 0) { @@ -612,7 +612,7 @@ _http_authorize(int fd, char *hdr, char *p) * Connect to the correct HTTP server or proxy. */ static int -_http_connect(struct url *URL, struct url *purl, char *flags) +_http_connect(struct url *URL, struct url *purl, const char *flags) { int verbose; int af, fd; @@ -646,7 +646,7 @@ _http_connect(struct url *URL, struct url *purl, char *flags) } static struct url * -_http_get_proxy() +_http_get_proxy(void) { struct url *purl; char *p; @@ -673,15 +673,15 @@ _http_get_proxy() * Send a request and process the reply */ FILE * -_http_request(struct url *URL, char *op, struct url_stat *us, - struct url *purl, char *flags) +_http_request(struct url *URL, const char *op, struct url_stat *us, + struct url *purl, const char *flags) { struct url *url, *new; int chunked, direct, need_auth, noredirect, verbose; int code, fd, i, n; off_t offset, clength, length, size; time_t mtime; - char *p; + const char *p; FILE *f; hdr h; char *host; @@ -960,7 +960,7 @@ _http_request(struct url *URL, char *op, struct url_stat *us, * Retrieve and stat a file by HTTP */ FILE * -fetchXGetHTTP(struct url *URL, struct url_stat *us, char *flags) +fetchXGetHTTP(struct url *URL, struct url_stat *us, const char *flags) { return _http_request(URL, "GET", us, _http_get_proxy(), flags); } @@ -969,7 +969,7 @@ fetchXGetHTTP(struct url *URL, struct url_stat *us, char *flags) * Retrieve a file by HTTP */ FILE * -fetchGetHTTP(struct url *URL, char *flags) +fetchGetHTTP(struct url *URL, const char *flags) { return fetchXGetHTTP(URL, NULL, flags); } @@ -978,7 +978,7 @@ fetchGetHTTP(struct url *URL, char *flags) * Store a file by HTTP */ FILE * -fetchPutHTTP(struct url *URL, char *flags) +fetchPutHTTP(struct url *URL, const char *flags) { warnx("fetchPutHTTP(): not implemented"); return NULL; @@ -988,7 +988,7 @@ fetchPutHTTP(struct url *URL, char *flags) * Get an HTTP document's metadata */ int -fetchStatHTTP(struct url *URL, struct url_stat *us, char *flags) +fetchStatHTTP(struct url *URL, struct url_stat *us, const char *flags) { FILE *f; @@ -1002,7 +1002,7 @@ fetchStatHTTP(struct url *URL, struct url_stat *us, char *flags) * List a directory */ struct url_ent * -fetchListHTTP(struct url *url, char *flags) +fetchListHTTP(struct url *url, const char *flags) { warnx("fetchListHTTP(): not implemented"); return NULL; |