build: use more const

Mostly with `char *` types.

Also:
- mime, x509asn1, tool_operate, lib3207: drop redundant casts.
- examples/smooth-gtk-thread: add missing variable declaration.
- reduce variable scopes.
- tests/server: move `data_to_hex()` to its only user: `sws`.

Closes #20489
This commit is contained in:
Viktor Szakats 2026-02-01 03:57:45 +01:00
parent 66bb641331
commit 9630593650
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201
111 changed files with 278 additions and 268 deletions

View File

@ -131,7 +131,7 @@ int main(void)
/* !checksrc! disable EQUALSNULL 1 */ /* !checksrc! disable EQUALSNULL 1 */
while((msg = curl_multi_info_read(multi, &msgs_left)) != NULL) { while((msg = curl_multi_info_read(multi, &msgs_left)) != NULL) {
if(msg->msg == CURLMSG_DONE) { if(msg->msg == CURLMSG_DONE) {
char *url; const char *url;
CURL *curl = msg->easy_handle; CURL *curl = msg->easy_handle;
curl_easy_getinfo(curl, CURLINFO_PRIVATE, &url); curl_easy_getinfo(curl, CURLINFO_PRIVATE, &url);
fprintf(stderr, "R: %d - %s <%s>\n", fprintf(stderr, "R: %d - %s <%s>\n",

View File

@ -88,15 +88,15 @@ static size_t read_cb(char *ptr, size_t size, size_t nmemb, void *stream)
return nread; return nread;
} }
int main(int argc, char **argv) int main(int argc, const char **argv)
{ {
CURL *curl; CURL *curl;
CURLcode result; CURLcode result;
FILE *fp; FILE *fp;
struct stat file_info; struct stat file_info;
char *file; const char *file;
char *url; const char *url;
if(argc < 3) if(argc < 3)
return 1; return 1;

View File

@ -191,8 +191,8 @@ static int ip_match(struct ip *ip, void *netaddr)
int bytes, tailbits; int bytes, tailbits;
const unsigned char *x, *y; const unsigned char *x, *y;
x = (unsigned char *)&ip->netaddr; x = (const unsigned char *)&ip->netaddr;
y = (unsigned char *)netaddr; y = (const unsigned char *)netaddr;
for(bytes = ip->maskbits / 8; bytes; --bytes) { for(bytes = ip->maskbits / 8; bytes; --bytes) {
if(*x++ != *y++) if(*x++ != *y++)
@ -214,7 +214,7 @@ static int is_ipv4_mapped_ipv6_address(int family, void *netaddr)
{ {
if(family == AF_INET6) { if(family == AF_INET6) {
int i; int i;
unsigned char *x = (unsigned char *)netaddr; const unsigned char *x = (const unsigned char *)netaddr;
for(i = 0; i < 12; ++i) { for(i = 0; i < 12; ++i) {
if(x[i]) if(x[i])
break; break;

View File

@ -66,13 +66,13 @@ static size_t write_cb(void *ptr, size_t size, size_t nmemb, void *data)
return (size_t)(size * nmemb); return (size_t)(size * nmemb);
} }
int main(int argc, char *argv[]) int main(int argc, const char *argv[])
{ {
CURL *curl; CURL *curl;
CURLcode result; CURLcode result;
int prtall = 0, prtsep = 0, prttime = 0; int prtall = 0, prtsep = 0, prttime = 0;
const char *url = URL_1M; const char *url = URL_1M;
char *appname = argv[0]; const char *appname = argv[0];
if(argc > 1) { if(argc > 1) {
/* parse input parameters */ /* parse input parameters */

View File

@ -97,7 +97,7 @@ static size_t write_cb(char *buff, size_t size, size_t nmemb, void *cb_data)
return written; return written;
} }
int main(int argc, char **argv) int main(int argc, const char **argv)
{ {
/* curl easy handle */ /* curl easy handle */
CURL *curl; CURL *curl;

View File

@ -43,7 +43,7 @@ int main(void)
result = curl_easy_perform(curl); result = curl_easy_perform(curl);
if(CURLE_OK == result) { if(CURLE_OK == result) {
char *ct; const char *ct;
/* ask for the content-type */ /* ask for the content-type */
result = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct); result = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct);

View File

@ -33,8 +33,6 @@ int main(void)
{ {
CURL *curl; CURL *curl;
CURLcode result; CURLcode result;
char *location;
long response_code;
result = curl_global_init(CURL_GLOBAL_ALL); result = curl_global_init(CURL_GLOBAL_ALL);
if(result) if(result)
@ -53,12 +51,14 @@ int main(void)
fprintf(stderr, "curl_easy_perform() failed: %s\n", fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(result)); curl_easy_strerror(result));
else { else {
long response_code;
result = curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code); result = curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code);
if((result == CURLE_OK) && ((response_code / 100) != 3)) { if((result == CURLE_OK) && ((response_code / 100) != 3)) {
/* a redirect implies a 3xx response code */ /* a redirect implies a 3xx response code */
fprintf(stderr, "Not a redirect.\n"); fprintf(stderr, "Not a redirect.\n");
} }
else { else {
const char *location;
result = curl_easy_getinfo(curl, CURLINFO_REDIRECT_URL, &location); result = curl_easy_getinfo(curl, CURLINFO_REDIRECT_URL, &location);
if((result == CURLE_OK) && location) { if((result == CURLE_OK) && location) {

View File

@ -49,7 +49,7 @@ int main(void)
fprintf(stderr, "curl_easy_perform() failed: %s\n", fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(result)); curl_easy_strerror(result));
else { else {
char *hdr; const char *hdr;
result = curl_easy_getinfo(curl, CURLINFO_REFERER, &hdr); result = curl_easy_getinfo(curl, CURLINFO_REFERER, &hdr);
if((result == CURLE_OK) && hdr) if((result == CURLE_OK) && hdr)
printf("Referrer header: %s\n", hdr); printf("Referrer header: %s\n", hdr);

View File

@ -74,7 +74,7 @@ static void dumpNode(TidyDoc doc, TidyNode tnod, int indent)
} }
} }
int main(int argc, char **argv) int main(int argc, const char **argv)
{ {
CURL *curl; CURL *curl;
char curl_errbuf[CURL_ERROR_SIZE]; char curl_errbuf[CURL_ERROR_SIZE];

View File

@ -250,7 +250,7 @@ static void parseHtml(const std::string &html,
title = context.title; title = context.title;
} }
int main(int argc, char *argv[]) int main(int argc, const char *argv[])
{ {
CURL *curl = NULL; CURL *curl = NULL;
CURLcode result; CURLcode result;

View File

@ -187,7 +187,7 @@ static int setup(struct transfer *t, int num)
/* /*
* Download many transfers over HTTP/2, using the same connection! * Download many transfers over HTTP/2, using the same connection!
*/ */
int main(int argc, char **argv) int main(int argc, const char **argv)
{ {
CURLcode result; CURLcode result;
struct transfer *trans; struct transfer *trans;

View File

@ -93,7 +93,7 @@ static int server_push_callback(CURL *parent,
struct curl_pushheaders *headers, struct curl_pushheaders *headers,
void *userp) void *userp)
{ {
char *headp; const char *headp;
int *transfers = (int *)userp; int *transfers = (int *)userp;
(void)parent; (void)parent;
(void)num_headers; (void)num_headers;

View File

@ -172,7 +172,7 @@ static int server_push_callback(CURL *parent,
struct curl_pushheaders *headers, struct curl_pushheaders *headers,
void *userp) void *userp)
{ {
char *headp; const char *headp;
size_t i; size_t i;
int *transfers = (int *)userp; int *transfers = (int *)userp;
char filename[128]; char filename[128];
@ -214,7 +214,7 @@ static int server_push_callback(CURL *parent,
/* /*
* Download a file over HTTP/2, take care of server push. * Download a file over HTTP/2, take care of server push.
*/ */
int main(int argc, char *argv[]) int main(int argc, const char *argv[])
{ {
CURLcode result; CURLcode result;
CURL *curl; CURL *curl;

View File

@ -285,7 +285,7 @@ static int setup(struct input *t, int num, const char *upload)
/* /*
* Upload all files over HTTP/2, using the same physical connection! * Upload all files over HTTP/2, using the same physical connection!
*/ */
int main(int argc, char **argv) int main(int argc, const char **argv)
{ {
CURLcode result; CURLcode result;
struct input *trans; struct input *trans;

View File

@ -47,11 +47,11 @@ static const char olivertwist[] =
* CURLOPT_POSTFIELDS to the URL given as an argument. * CURLOPT_POSTFIELDS to the URL given as an argument.
*/ */
int main(int argc, char **argv) int main(int argc, const char **argv)
{ {
CURL *curl; CURL *curl;
CURLcode result; CURLcode result;
char *url; const char *url;
if(argc < 2) if(argc < 2)
return 1; return 1;

View File

@ -73,15 +73,15 @@ static size_t read_cb(char *ptr, size_t size, size_t nmemb, void *stream)
return retcode; return retcode;
} }
int main(int argc, char **argv) int main(int argc, const char **argv)
{ {
CURL *curl; CURL *curl;
CURLcode result; CURLcode result;
FILE *hd_src; FILE *hd_src;
struct stat file_info; struct stat file_info;
char *file; const char *file;
char *url; const char *url;
if(argc < 3) if(argc < 3)
return 1; return 1;

View File

@ -213,7 +213,7 @@ static int handle_socket(CURL *curl, curl_socket_t s, int action, void *userp,
return 0; return 0;
} }
int main(int argc, char **argv) int main(int argc, const char **argv)
{ {
CURLcode result; CURLcode result;

View File

@ -227,7 +227,7 @@ static int cb_socket(CURL *curl, curl_socket_t s, int action,
return 0; return 0;
} }
int main(int argc, char **argv) int main(int argc, const char **argv)
{ {
CURLcode result; CURLcode result;
struct datauv uv = { 0 }; struct datauv uv = { 0 };

View File

@ -45,7 +45,7 @@
#include <curl/curl.h> #include <curl/curl.h>
int main(int argc, char *argv[]) int main(int argc, const char *argv[])
{ {
CURL *curl; CURL *curl;
CURLcode result; CURLcode result;

View File

@ -42,7 +42,7 @@
#include <curl/curl.h> #include <curl/curl.h>
int main(int argc, char *argv[]) int main(int argc, const char *argv[])
{ {
CURL *curl; CURL *curl;

View File

@ -65,7 +65,7 @@ static size_t write_cb(void *ptr, size_t size, size_t nmemb, FILE *stream)
return fwrite(ptr, size, nmemb, stream); return fwrite(ptr, size, nmemb, stream);
} }
static void run_one(gchar *http, int j) static void run_one(const gchar *http, int j)
{ {
CURL *curl; CURL *curl;
@ -94,6 +94,7 @@ static void *pull_one_url(void *NaN)
/* protect the reading and increasing of 'j' with a mutex */ /* protect the reading and increasing of 'j' with a mutex */
pthread_mutex_lock(&lock); pthread_mutex_lock(&lock);
while(j < num_urls) { while(j < num_urls) {
gchar *http;
int i = j; int i = j;
j++; j++;
pthread_mutex_unlock(&lock); pthread_mutex_unlock(&lock);
@ -165,7 +166,7 @@ static gboolean cb_delete(GtkWidget *window, gpointer data)
return FALSE; return FALSE;
} }
int main(int argc, char **argv) int main(int argc, const char **argv)
{ {
GtkWidget *top_window, *outside_frame, *inside_frame, *progress_bar; GtkWidget *top_window, *outside_frame, *inside_frame, *progress_bar;

View File

@ -40,7 +40,7 @@
* **** This example only works with libcurl 7.56.0 and later! **** * **** This example only works with libcurl 7.56.0 and later! ****
*/ */
int main(int argc, char **argv) int main(int argc, const char **argv)
{ {
const char *name = argc > 1 ? argv[1] : "openssl"; const char *name = argc > 1 ? argv[1] : "openssl";
CURLsslset result; CURLsslset result;

View File

@ -126,7 +126,7 @@ static size_t SyncTime_CURL_WriteHeader(void *ptr, size_t size, size_t nmemb,
if(ShowAllHeader == 1) if(ShowAllHeader == 1)
fprintf(stderr, "%.*s", (int)nmemb, (char *)ptr); fprintf(stderr, "%.*s", (int)nmemb, (char *)ptr);
if((nmemb >= 5) && !strncmp((char *)ptr, "Date:", 5)) { if((nmemb >= 5) && !strncmp((const char *)ptr, "Date:", 5)) {
if(ShowAllHeader == 0) if(ShowAllHeader == 0)
fprintf(stderr, "HTTP Server. %.*s", (int)nmemb, (char *)ptr); fprintf(stderr, "HTTP Server. %.*s", (int)nmemb, (char *)ptr);
@ -163,7 +163,7 @@ static size_t SyncTime_CURL_WriteHeader(void *ptr, size_t size, size_t nmemb,
} }
} }
if((nmemb >= 12) && !strncmp((char *)ptr, "X-Cache: HIT", 12)) { if((nmemb >= 12) && !strncmp((const char *)ptr, "X-Cache: HIT", 12)) {
fprintf(stderr, "ERROR: HTTP Server data is cached." fprintf(stderr, "ERROR: HTTP Server data is cached."
" Server Date is no longer valid.\n"); " Server Date is no longer valid.\n");
AutoSyncTime = 0; AutoSyncTime = 0;
@ -226,7 +226,7 @@ static void showUsage(void)
return; return;
} }
int main(int argc, char *argv[]) int main(int argc, const char *argv[])
{ {
CURLcode result; CURLcode result;
CURL *curl; CURL *curl;

View File

@ -42,7 +42,7 @@ static size_t write_cb(void *ptr, size_t size, size_t nmemb, void *stream)
return written; return written;
} }
int main(int argc, char *argv[]) int main(int argc, const char *argv[])
{ {
static const char *pagefilename = "page.out"; static const char *pagefilename = "page.out";

View File

@ -241,7 +241,7 @@ static CURLcode send_CONNECT(struct Curl_cfilter *cf,
struct h1_tunnel_state *ts, struct h1_tunnel_state *ts,
bool *done) bool *done)
{ {
uint8_t *buf = curlx_dyn_uptr(&ts->request_data); const uint8_t *buf = curlx_dyn_uptr(&ts->request_data);
size_t request_len = curlx_dyn_len(&ts->request_data); size_t request_len = curlx_dyn_len(&ts->request_data);
size_t blen = request_len; size_t blen = request_len;
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
@ -262,7 +262,7 @@ static CURLcode send_CONNECT(struct Curl_cfilter *cf,
DEBUGASSERT(blen >= nwritten); DEBUGASSERT(blen >= nwritten);
ts->nsent += nwritten; ts->nsent += nwritten;
Curl_debug(data, CURLINFO_HEADER_OUT, (char *)buf, nwritten); Curl_debug(data, CURLINFO_HEADER_OUT, (const char *)buf, nwritten);
out: out:
if(result) if(result)
@ -353,9 +353,9 @@ static CURLcode single_header(struct Curl_cfilter *cf,
struct h1_tunnel_state *ts) struct h1_tunnel_state *ts)
{ {
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
char *linep = curlx_dyn_ptr(&ts->rcvbuf); const char *linep = curlx_dyn_ptr(&ts->rcvbuf);
size_t line_len = curlx_dyn_len(&ts->rcvbuf); /* bytes in this line */ size_t line_len = curlx_dyn_len(&ts->rcvbuf); /* bytes in this line */
struct SingleRequest *k = &data->req; const struct SingleRequest *k = &data->req;
int writetype; int writetype;
ts->headerlines++; ts->headerlines++;
@ -531,7 +531,7 @@ static CURLcode recv_CONNECT_resp(struct Curl_cfilter *cf,
if(byte != 0x0a) if(byte != 0x0a)
continue; continue;
else { else {
char *linep = curlx_dyn_ptr(&ts->rcvbuf); const char *linep = curlx_dyn_ptr(&ts->rcvbuf);
size_t hlen = curlx_dyn_len(&ts->rcvbuf); size_t hlen = curlx_dyn_len(&ts->rcvbuf);
if(hlen && ISNEWLINE(linep[0])) { if(hlen && ISNEWLINE(linep[0])) {
/* end of headers */ /* end of headers */

View File

@ -41,7 +41,7 @@ CURLcode Curl_get_line(struct dynbuf *buf, FILE *input, bool *eof)
curlx_dyn_reset(buf); curlx_dyn_reset(buf);
while(1) { while(1) {
size_t rlen; size_t rlen;
char *b = fgets(buffer, sizeof(buffer), input); const char *b = fgets(buffer, sizeof(buffer), input);
*eof = feof(input); *eof = feof(input);

View File

@ -551,9 +551,9 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_hash(const char *user, size_t userlen,
* *
* Returns CURLE_OK on success. * Returns CURLE_OK on success.
*/ */
CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash, CURLcode Curl_ntlm_core_mk_ntlmv2_resp(const unsigned char *ntlmv2hash,
unsigned char *challenge_client, const unsigned char *challenge_client,
struct ntlmdata *ntlm, const struct ntlmdata *ntlm,
unsigned char **ntresp, unsigned char **ntresp,
unsigned int *ntresp_len) unsigned int *ntresp_len)
{ {
@ -644,9 +644,9 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash,
* *
* Returns CURLE_OK on success. * Returns CURLE_OK on success.
*/ */
CURLcode Curl_ntlm_core_mk_lmv2_resp(unsigned char *ntlmv2hash, CURLcode Curl_ntlm_core_mk_lmv2_resp(const unsigned char *ntlmv2hash,
unsigned char *challenge_client, const unsigned char *challenge_client,
unsigned char *challenge_server, const unsigned char *challenge_server,
unsigned char *lmresp) unsigned char *lmresp)
{ {
unsigned char data[16]; unsigned char data[16];

View File

@ -55,15 +55,15 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_hash(const char *user, size_t userlen,
unsigned char *ntlmhash, unsigned char *ntlmhash,
unsigned char *ntlmv2hash); unsigned char *ntlmv2hash);
CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash, CURLcode Curl_ntlm_core_mk_ntlmv2_resp(const unsigned char *ntlmv2hash,
unsigned char *challenge_client, const unsigned char *challenge_client,
struct ntlmdata *ntlm, const struct ntlmdata *ntlm,
unsigned char **ntresp, unsigned char **ntresp,
unsigned int *ntresp_len); unsigned int *ntresp_len);
CURLcode Curl_ntlm_core_mk_lmv2_resp(unsigned char *ntlmv2hash, CURLcode Curl_ntlm_core_mk_lmv2_resp(const unsigned char *ntlmv2hash,
unsigned char *challenge_client, const unsigned char *challenge_client,
unsigned char *challenge_server, const unsigned char *challenge_server,
unsigned char *lmresp); unsigned char *lmresp);
#endif /* !USE_WINDOWS_SSPI */ #endif /* !USE_WINDOWS_SSPI */

View File

@ -227,13 +227,14 @@ static CURLcode get_server_message(struct SASL *sasl, struct Curl_easy *data,
result = sasl->params->getmessage(data, out); result = sasl->params->getmessage(data, out);
if(!result && (sasl->params->flags & SASL_FLAG_BASE64)) { if(!result && (sasl->params->flags & SASL_FLAG_BASE64)) {
unsigned char *msg;
size_t msglen;
const char *serverdata = Curl_bufref_ptr(out); const char *serverdata = Curl_bufref_ptr(out);
if(!*serverdata || *serverdata == '=') if(!*serverdata || *serverdata == '=')
Curl_bufref_set(out, NULL, 0, NULL); Curl_bufref_set(out, NULL, 0, NULL);
else { else {
unsigned char *msg;
size_t msglen;
result = curlx_base64_decode(serverdata, &msg, &msglen); result = curlx_base64_decode(serverdata, &msg, &msglen);
if(!result) if(!result)
Curl_bufref_set(out, msg, msglen, curl_free); Curl_bufref_set(out, msg, msglen, curl_free);

View File

@ -292,7 +292,7 @@ const char *curlx_strerror(int err, char *buf, size_t buflen)
*/ */
{ {
char buffer[256]; char buffer[256];
char *msg = strerror_r(err, buffer, sizeof(buffer)); const char *msg = strerror_r(err, buffer, sizeof(buffer));
if(msg && buflen > 1) if(msg && buflen > 1)
SNPRINTF(buf, buflen, "%s", msg); SNPRINTF(buf, buflen, "%s", msg);
else if(buflen > sizeof("Unknown error ") + 20) else if(buflen > sizeof("Unknown error ") + 20)

View File

@ -304,7 +304,7 @@ static CURLFORMcode FormAdd(struct curl_httppost **httppost,
struct FormInfo *first_form, *curr, *form = NULL; struct FormInfo *first_form, *curr, *form = NULL;
CURLFORMcode retval = CURL_FORMADD_OK; CURLFORMcode retval = CURL_FORMADD_OK;
CURLformoption option; CURLformoption option;
struct curl_forms *forms = NULL; const struct curl_forms *forms = NULL;
char *avalue = NULL; char *avalue = NULL;
struct curl_httppost *newchain = NULL; struct curl_httppost *newchain = NULL;
struct curl_httppost *lastnode = NULL; struct curl_httppost *lastnode = NULL;

View File

@ -886,7 +886,7 @@ static CURLcode ftp_state_use_port(struct Curl_easy *data,
char myhost[MAX_IPADR_LEN + 1] = ""; char myhost[MAX_IPADR_LEN + 1] = "";
struct Curl_sockaddr_storage ss; struct Curl_sockaddr_storage ss;
struct Curl_addrinfo *res, *ai; const struct Curl_addrinfo *res, *ai;
curl_socklen_t sslen; curl_socklen_t sslen;
char hbuf[NI_MAXHOST]; char hbuf[NI_MAXHOST];
struct sockaddr *sa = (struct sockaddr *)&ss; struct sockaddr *sa = (struct sockaddr *)&ss;
@ -896,15 +896,15 @@ static CURLcode ftp_state_use_port(struct Curl_easy *data,
#endif #endif
static const char mode[][5] = { "EPRT", "PORT" }; static const char mode[][5] = { "EPRT", "PORT" };
int error; int error;
char *host = NULL; const char *host = NULL;
char *string_ftpport = data->set.str[STRING_FTPPORT]; const char *string_ftpport = data->set.str[STRING_FTPPORT];
struct Curl_dns_entry *dns_entry = NULL; struct Curl_dns_entry *dns_entry = NULL;
unsigned short port_min = 0; unsigned short port_min = 0;
unsigned short port_max = 0; unsigned short port_max = 0;
unsigned short port; unsigned short port;
bool possibly_non_local = TRUE; bool possibly_non_local = TRUE;
char buffer[STRERROR_LEN]; char buffer[STRERROR_LEN];
char *addr = NULL; const char *addr = NULL;
size_t addrlen = 0; size_t addrlen = 0;
char ipstr[50]; char ipstr[50];
@ -920,7 +920,7 @@ static CURLcode ftp_state_use_port(struct Curl_easy *data,
#ifdef USE_IPV6 #ifdef USE_IPV6
if(*string_ftpport == '[') { if(*string_ftpport == '[') {
/* [ipv6]:port(-range) */ /* [ipv6]:port(-range) */
char *ip_start = string_ftpport + 1; const char *ip_start = string_ftpport + 1;
ip_end = strchr(ip_start, ']'); ip_end = strchr(ip_start, ']');
if(ip_end) { if(ip_end) {
addrlen = ip_end - ip_start; addrlen = ip_end - ip_start;
@ -1214,7 +1214,7 @@ static CURLcode ftp_state_use_port(struct Curl_easy *data,
if(PORT == fcmd) { if(PORT == fcmd) {
/* large enough for [IP address],[num],[num] */ /* large enough for [IP address],[num],[num] */
char target[sizeof(myhost) + 20]; char target[sizeof(myhost) + 20];
char *source = myhost; const char *source = myhost;
char *dest = target; char *dest = target;
/* translate x.x.x.x to x,x,x,x */ /* translate x.x.x.x to x,x,x,x */
@ -1766,7 +1766,7 @@ static CURLcode ftp_state_quote(struct Curl_easy *data,
i++; i++;
} }
if(item) { if(item) {
char *cmd = item->data; const char *cmd = item->data;
if(cmd[0] == '*') { if(cmd[0] == '*') {
cmd++; cmd++;
ftpc->count2 = 1; /* the sent command is allowed to fail */ ftpc->count2 = 1; /* the sent command is allowed to fail */
@ -1924,11 +1924,11 @@ static CURLcode ftp_state_pasv_resp(struct Curl_easy *data,
CURLcode result; CURLcode result;
struct Curl_dns_entry *dns = NULL; struct Curl_dns_entry *dns = NULL;
unsigned short connectport; /* the local port connect() should use! */ unsigned short connectport; /* the local port connect() should use! */
struct pingpong *pp = &ftpc->pp; const struct pingpong *pp = &ftpc->pp;
char *newhost = NULL; char *newhost = NULL;
unsigned short newport = 0; unsigned short newport = 0;
char *str = curlx_dyn_ptr(&pp->recvbuf) + 4; /* start on the first letter */ const char *str = curlx_dyn_ptr(&pp->recvbuf) + 4; /* start on the first
letter */
if((ftpc->count1 == 0) && if((ftpc->count1 == 0) &&
(ftpcode == 229)) { (ftpcode == 229)) {
/* positive EPSV response */ /* positive EPSV response */
@ -2419,7 +2419,7 @@ static CURLcode ftp_state_mdtm_resp(struct Curl_easy *data,
last .sss part is optional and means fractions of a second */ last .sss part is optional and means fractions of a second */
int year, month, day, hour, minute, second; int year, month, day, hour, minute, second;
struct pingpong *pp = &ftpc->pp; struct pingpong *pp = &ftpc->pp;
char *resp = curlx_dyn_ptr(&pp->recvbuf) + 4; const char *resp = curlx_dyn_ptr(&pp->recvbuf) + 4;
bool showtime = FALSE; bool showtime = FALSE;
if(ftp_213_date(resp, &year, &month, &day, &hour, &minute, &second)) { if(ftp_213_date(resp, &year, &month, &day, &hour, &minute, &second)) {
/* we have a time, reformat it */ /* we have a time, reformat it */
@ -2561,7 +2561,7 @@ static CURLcode ftp_state_size_resp(struct Curl_easy *data,
{ {
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
curl_off_t filesize = -1; curl_off_t filesize = -1;
char *buf = curlx_dyn_ptr(&ftpc->pp.recvbuf); const char *buf = curlx_dyn_ptr(&ftpc->pp.recvbuf);
size_t len = ftpc->pp.nfinal; size_t len = ftpc->pp.nfinal;
/* get the size from the ascii string: */ /* get the size from the ascii string: */
@ -2569,7 +2569,7 @@ static CURLcode ftp_state_size_resp(struct Curl_easy *data,
/* To allow servers to prepend "rubbish" in the response string, we scan /* To allow servers to prepend "rubbish" in the response string, we scan
for all the digits at the end of the response and parse only those as a for all the digits at the end of the response and parse only those as a
number. */ number. */
char *start = &buf[4]; const char *start = &buf[4];
const char *fdigit = memchr(start, '\r', len - 4); const char *fdigit = memchr(start, '\r', len - 4);
if(fdigit) { if(fdigit) {
fdigit--; fdigit--;
@ -2740,7 +2740,7 @@ static CURLcode ftp_state_get_resp(struct Curl_easy *data,
size_t i; size_t i;
for(i = 0; i < len - 7; i++) { for(i = 0; i < len - 7; i++) {
curl_off_t what; curl_off_t what;
char *buf = curlx_dyn_ptr(&ftpc->pp.recvbuf); const char *buf = curlx_dyn_ptr(&ftpc->pp.recvbuf);
const char *c = &buf[i]; const char *c = &buf[i];
if(!curlx_str_number(&c, &what, CURL_OFF_T_MAX) && if(!curlx_str_number(&c, &what, CURL_OFF_T_MAX) &&
!curlx_str_single(&c, ' ') && !curlx_str_single(&c, ' ') &&
@ -2910,8 +2910,8 @@ static CURLcode ftp_pwd_resp(struct Curl_easy *data,
CURLcode result; CURLcode result;
if(ftpcode == 257) { if(ftpcode == 257) {
char *ptr = curlx_dyn_ptr(&pp->recvbuf) + 4; /* start on the first const char *ptr = curlx_dyn_ptr(&pp->recvbuf) + 4; /* start on the first
letter */ letter */
bool entry_extracted = FALSE; bool entry_extracted = FALSE;
struct dynbuf out; struct dynbuf out;
curlx_dyn_init(&out, 1000); curlx_dyn_init(&out, 1000);
@ -3183,10 +3183,10 @@ static CURLcode ftp_pp_statemachine(struct Curl_easy *data,
case FTP_SYST: case FTP_SYST:
if(ftpcode == 215) { if(ftpcode == 215) {
char *ptr = curlx_dyn_ptr(&pp->recvbuf) + 4; /* start on the first const char *ptr = curlx_dyn_ptr(&pp->recvbuf) + 4; /* start on the first
letter */ letter */
const char *start;
char *os; char *os;
char *start;
/* Reply format is like /* Reply format is like
215<space><OS-name><space><commentary> 215<space><OS-name><space><commentary>
@ -3453,7 +3453,7 @@ static CURLcode ftp_sendquote(struct Curl_easy *data,
while(item) { while(item) {
if(item->data) { if(item->data) {
size_t nread; size_t nread;
char *cmd = item->data; const char *cmd = item->data;
bool acceptfail = FALSE; bool acceptfail = FALSE;
CURLcode result; CURLcode result;
int ftpcode = 0; int ftpcode = 0;

View File

@ -127,7 +127,7 @@ static CURLcode getinfo_char(struct Curl_easy *data, CURLINFO info,
*param_charp = data->info.contenttype; *param_charp = data->info.contenttype;
break; break;
case CURLINFO_PRIVATE: case CURLINFO_PRIVATE:
*param_charp = (char *)data->set.private_data; *param_charp = (const char *)data->set.private_data;
break; break;
case CURLINFO_FTP_ENTRY_PATH: case CURLINFO_FTP_ENTRY_PATH:
/* Return the entrypath string from the most recent connection. /* Return the entrypath string from the most recent connection.

View File

@ -63,8 +63,8 @@ static CURLcode gopher_do(struct Curl_easy *data, bool *done)
struct connectdata *conn = data->conn; struct connectdata *conn = data->conn;
curl_socket_t sockfd = conn->sock[FIRSTSOCKET]; curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
char *gopherpath; char *gopherpath;
char *path = data->state.up.path; const char *path = data->state.up.path;
char *query = data->state.up.query; const char *query = data->state.up.query;
const char *buf = NULL; const char *buf = NULL;
char *buf_alloc = NULL; char *buf_alloc = NULL;
size_t nwritten, buf_len; size_t nwritten, buf_len;
@ -91,7 +91,7 @@ static CURLcode gopher_do(struct Curl_easy *data, bool *done)
curlx_free(gopherpath); curlx_free(gopherpath);
} }
else { else {
char *newp; const char *newp;
/* Otherwise, drop / and the first character (i.e., item type) ... */ /* Otherwise, drop / and the first character (i.e., item type) ... */
newp = gopherpath; newp = gopherpath;

View File

@ -118,7 +118,7 @@
static void show_resolve_info(struct Curl_easy *data, static void show_resolve_info(struct Curl_easy *data,
struct Curl_dns_entry *dns) struct Curl_dns_entry *dns)
{ {
struct Curl_addrinfo *a; const struct Curl_addrinfo *a;
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
#ifdef CURLRES_IPV6 #ifdef CURLRES_IPV6
struct dynbuf out[2]; struct dynbuf out[2];

View File

@ -4343,7 +4343,7 @@ static CURLcode http_rw_hd(struct Curl_easy *data,
void Curl_http_to_fold(struct dynbuf *bf) void Curl_http_to_fold(struct dynbuf *bf)
{ {
size_t len = curlx_dyn_len(bf); size_t len = curlx_dyn_len(bf);
char *hd = curlx_dyn_ptr(bf); const char *hd = curlx_dyn_ptr(bf);
if(len && (hd[len - 1] == '\n')) if(len && (hd[len - 1] == '\n'))
len--; len--;
if(len && (hd[len - 1] == '\r')) if(len && (hd[len - 1] == '\r'))
@ -4397,7 +4397,7 @@ static CURLcode http_parse_headers(struct Curl_easy *data,
while(blen && k->header) { while(blen && k->header) {
size_t consumed; size_t consumed;
size_t hlen; size_t hlen;
char *hd; const char *hd;
size_t unfold_len = 0; size_t unfold_len = 0;
if(data->state.leading_unfold) { if(data->state.leading_unfold) {

View File

@ -732,7 +732,7 @@ UNITTEST CURLcode canon_query(const char *query, struct dynbuf *dq)
size_t in_key_len; size_t in_key_len;
const char *offset; const char *offset;
size_t query_part_len = curlx_dyn_len(&query_array[index]); size_t query_part_len = curlx_dyn_len(&query_array[index]);
char *query_part = curlx_dyn_ptr(&query_array[index]); const char *query_part = curlx_dyn_ptr(&query_array[index]);
in_key = query_part; in_key = query_part;
@ -788,8 +788,8 @@ UNITTEST CURLcode canon_query(const char *query, struct dynbuf *dq)
if(index) if(index)
result = curlx_dyn_addn(dq, "&", 1); result = curlx_dyn_addn(dq, "&", 1);
if(!result) { if(!result) {
char *key_ptr = curlx_dyn_ptr(&encoded_query_array[index].key); const char *key_ptr = curlx_dyn_ptr(&encoded_query_array[index].key);
char *value_ptr = curlx_dyn_ptr(&encoded_query_array[index].value); const char *value_ptr = curlx_dyn_ptr(&encoded_query_array[index].value);
size_t vlen = curlx_dyn_len(&encoded_query_array[index].value); size_t vlen = curlx_dyn_len(&encoded_query_array[index].value);
if(value_ptr && vlen) { if(value_ptr && vlen) {
result = curlx_dyn_addf(dq, "%s=%s", key_ptr, value_ptr); result = curlx_dyn_addf(dq, "%s=%s", key_ptr, value_ptr);

View File

@ -242,7 +242,7 @@ static CURLcode httpchunk_readwrite(struct Curl_easy *data,
case CHUNK_TRAILER: case CHUNK_TRAILER:
if((*buf == 0x0d) || (*buf == 0x0a)) { if((*buf == 0x0d) || (*buf == 0x0a)) {
char *tr = curlx_dyn_ptr(&ch->trailer); const char *tr = curlx_dyn_ptr(&ch->trailer);
/* this is the end of a trailer, but if the trailer was zero bytes /* this is the end of a trailer, but if the trailer was zero bytes
there was no trailer and we move on */ there was no trailer and we move on */
@ -517,7 +517,7 @@ static CURLcode add_last_chunk(struct Curl_easy *data,
for(tr = trailers; tr; tr = tr->next) { for(tr = trailers; tr; tr = tr->next) {
/* only add correctly formatted trailers */ /* only add correctly formatted trailers */
char *ptr = strchr(tr->data, ':'); const char *ptr = strchr(tr->data, ':');
if(!ptr || *(ptr + 1) != ' ') { if(!ptr || *(ptr + 1) != ' ') {
infof(data, "Malformatted trailing header, skipping trailer"); infof(data, "Malformatted trailing header, skipping trailer");
continue; continue;

View File

@ -1220,7 +1220,7 @@ static CURLcode imap_state_listsearch_resp(struct Curl_easy *data,
imapstate instate) imapstate instate)
{ {
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
char *line = curlx_dyn_ptr(&imapc->pp.recvbuf); const char *line = curlx_dyn_ptr(&imapc->pp.recvbuf);
size_t len = imapc->pp.nfinal; size_t len = imapc->pp.nfinal;
struct IMAP *imap = Curl_meta_get(data, CURL_META_IMAP_EASY); struct IMAP *imap = Curl_meta_get(data, CURL_META_IMAP_EASY);

View File

@ -338,7 +338,7 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
ldap_set_option(server, LDAP_OPT_SSL, LDAP_OPT_ON); ldap_set_option(server, LDAP_OPT_SSL, LDAP_OPT_ON);
#else /* !USE_WIN32_LDAP */ #else /* !USE_WIN32_LDAP */
int ldap_option; int ldap_option;
char *ldap_ca = conn->ssl_config.CAfile; const char *ldap_ca = conn->ssl_config.CAfile;
#ifdef LDAP_OPT_X_TLS #ifdef LDAP_OPT_X_TLS
if(conn->ssl_config.verifypeer) { if(conn->ssl_config.verifypeer) {
/* OpenLDAP SDK supports BASE64 files. */ /* OpenLDAP SDK supports BASE64 files. */

View File

@ -1204,7 +1204,7 @@ curl_mime *curl_mime_init(void *easy)
/* Initialize a mime part. */ /* Initialize a mime part. */
void Curl_mime_initpart(curl_mimepart *part) void Curl_mime_initpart(curl_mimepart *part)
{ {
memset((char *)part, 0, sizeof(*part)); memset(part, 0, sizeof(*part));
part->lastreadstatus = 1; /* Successful read status. */ part->lastreadstatus = 1; /* Successful read status. */
mimesetstate(&part->state, MIMESTATE_BEGIN, NULL); mimesetstate(&part->state, MIMESTATE_BEGIN, NULL);
} }

View File

@ -403,7 +403,7 @@ static CURLcode mqtt_verify_connack(struct Curl_easy *data)
{ {
struct MQTT *mq = Curl_meta_get(data, CURL_META_MQTT_EASY); struct MQTT *mq = Curl_meta_get(data, CURL_META_MQTT_EASY);
CURLcode result; CURLcode result;
char *ptr; const char *ptr;
DEBUGASSERT(mq); DEBUGASSERT(mq);
if(!mq) if(!mq)
@ -433,7 +433,7 @@ fail:
static CURLcode mqtt_get_topic(struct Curl_easy *data, static CURLcode mqtt_get_topic(struct Curl_easy *data,
char **topic, size_t *topiclen) char **topic, size_t *topiclen)
{ {
char *path = data->state.up.path; const char *path = data->state.up.path;
CURLcode result = CURLE_URL_MALFORMAT; CURLcode result = CURLE_URL_MALFORMAT;
if(strlen(path) > 1) { if(strlen(path) > 1) {
result = Curl_urldecode(path + 1, 0, topic, topiclen, REJECT_NADA); result = Curl_urldecode(path + 1, 0, topic, topiclen, REJECT_NADA);
@ -506,7 +506,7 @@ static CURLcode mqtt_verify_suback(struct Curl_easy *data)
struct connectdata *conn = data->conn; struct connectdata *conn = data->conn;
struct mqtt_conn *mqtt = Curl_conn_meta_get(conn, CURL_META_MQTT_CONN); struct mqtt_conn *mqtt = Curl_conn_meta_get(conn, CURL_META_MQTT_CONN);
CURLcode result; CURLcode result;
char *ptr; const char *ptr;
if(!mqtt || !mq) if(!mqtt || !mq)
return CURLE_FAILED_INIT; return CURLE_FAILED_INIT;
@ -595,7 +595,8 @@ fail:
} }
/* return 0 on success, non-zero on error */ /* return 0 on success, non-zero on error */
static int mqtt_decode_len(size_t *lenp, unsigned char *buf, size_t buflen) static int mqtt_decode_len(size_t *lenp, const unsigned char *buf,
size_t buflen)
{ {
size_t len = 0; size_t len = 0;
size_t mult = 1; size_t mult = 1;

View File

@ -337,7 +337,7 @@ static CURLcode oldap_perform_bind(struct Curl_easy *data, ldapstate newstate)
{ {
struct connectdata *conn = data->conn; struct connectdata *conn = data->conn;
struct ldapconninfo *li = Curl_conn_meta_get(conn, CURL_META_LDAP_CONN); struct ldapconninfo *li = Curl_conn_meta_get(conn, CURL_META_LDAP_CONN);
char *binddn = NULL; const char *binddn = NULL;
struct berval passwd; struct berval passwd;
int rc; int rc;
@ -724,8 +724,9 @@ static CURLcode oldap_state_mechs_resp(struct Curl_easy *data,
if(bvals) { if(bvals) {
for(i = 0; bvals[i].bv_val; i++) { for(i = 0; bvals[i].bv_val; i++) {
size_t llen; size_t llen;
unsigned short mech = Curl_sasl_decode_mech((char *)bvals[i].bv_val, unsigned short mech =
bvals[i].bv_len, &llen); Curl_sasl_decode_mech((const char *)bvals[i].bv_val,
bvals[i].bv_len, &llen);
if(bvals[i].bv_len == llen) if(bvals[i].bv_len == llen)
li->sasl.authmechs |= mech; li->sasl.authmechs |= mech;
} }

View File

@ -1341,7 +1341,7 @@ static CURLcode smtp_state_command_resp(struct Curl_easy *data,
smtpstate instate) smtpstate instate)
{ {
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
char *line = curlx_dyn_ptr(&smtpc->pp.recvbuf); const char *line = curlx_dyn_ptr(&smtpc->pp.recvbuf);
size_t len = smtpc->pp.nfinal; size_t len = smtpc->pp.nfinal;
(void)instate; (void)instate;

View File

@ -837,7 +837,7 @@ static CURLproxycode socks5_resolving(struct socks_state *sx,
struct Curl_dns_entry *dns = NULL; struct Curl_dns_entry *dns = NULL;
struct Curl_addrinfo *hp = NULL; struct Curl_addrinfo *hp = NULL;
char dest[MAX_IPADR_LEN]; /* printable address */ char dest[MAX_IPADR_LEN]; /* printable address */
unsigned char *destination = NULL; const unsigned char *destination = NULL;
unsigned char desttype = 1, destlen = 4; unsigned char desttype = 1, destlen = 4;
unsigned char req[2]; unsigned char req[2];
CURLcode result; CURLcode result;
@ -896,7 +896,7 @@ static CURLproxycode socks5_resolving(struct socks_state *sx,
desttype = 1; /* ATYP: IPv4 = 1 */ desttype = 1; /* ATYP: IPv4 = 1 */
destlen = 4; destlen = 4;
saddr_in = (struct sockaddr_in *)(void *)hp->ai_addr; saddr_in = (struct sockaddr_in *)(void *)hp->ai_addr;
destination = (unsigned char *)&saddr_in->sin_addr.s_addr; destination = (const unsigned char *)&saddr_in->sin_addr.s_addr;
CURL_TRC_CF(data, cf, "SOCKS5 connect to %s:%d (locally resolved)", CURL_TRC_CF(data, cf, "SOCKS5 connect to %s:%d (locally resolved)",
dest, sx->remote_port); dest, sx->remote_port);
} }
@ -906,7 +906,7 @@ static CURLproxycode socks5_resolving(struct socks_state *sx,
desttype = 4; /* ATYP: IPv6 = 4 */ desttype = 4; /* ATYP: IPv6 = 4 */
destlen = 16; destlen = 16;
saddr_in6 = (struct sockaddr_in6 *)(void *)hp->ai_addr; saddr_in6 = (struct sockaddr_in6 *)(void *)hp->ai_addr;
destination = (unsigned char *)&saddr_in6->sin6_addr.s6_addr; destination = (const unsigned char *)&saddr_in6->sin6_addr.s6_addr;
CURL_TRC_CF(data, cf, "SOCKS5 connect to [%s]:%d (locally resolved)", CURL_TRC_CF(data, cf, "SOCKS5 connect to [%s]:%d (locally resolved)",
dest, sx->remote_port); dest, sx->remote_port);
} }

View File

@ -317,7 +317,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf,
} }
infof(data, "SOCKS5 server authenticated user %.*s with GSS-API.", infof(data, "SOCKS5 server authenticated user %.*s with GSS-API.",
(int)gss_send_token.length, (char *)gss_send_token.value); (int)gss_send_token.length, (const char *)gss_send_token.value);
gss_release_name(&gss_status, &gss_client_name); gss_release_name(&gss_status, &gss_client_name);
gss_release_buffer(&gss_status, &gss_send_token); gss_release_buffer(&gss_status, &gss_send_token);

View File

@ -116,7 +116,7 @@ void Curl_strntolower(char *dest, const char *src, size_t n)
/* Compare case-sensitive null-terminated strings, taking care of possible /* Compare case-sensitive null-terminated strings, taking care of possible
* null pointers. Return true if arguments match. * null pointers. Return true if arguments match.
*/ */
bool Curl_safecmp(char *a, char *b) bool Curl_safecmp(const char *a, const char *b)
{ {
if(a && b) if(a && b)
return !strcmp(a, b); return !strcmp(a, b);

View File

@ -35,7 +35,7 @@ char Curl_raw_tolower(char in);
void Curl_strntoupper(char *dest, const char *src, size_t n); void Curl_strntoupper(char *dest, const char *src, size_t n);
void Curl_strntolower(char *dest, const char *src, size_t n); void Curl_strntolower(char *dest, const char *src, size_t n);
bool Curl_safecmp(char *a, char *b); bool Curl_safecmp(const char *a, const char *b);
int Curl_timestrcmp(const char *first, const char *second); int Curl_timestrcmp(const char *first, const char *second);
#endif /* HEADER_CURL_STRCASE_H */ #endif /* HEADER_CURL_STRCASE_H */

View File

@ -36,13 +36,13 @@ char *Curl_strdup(const char *str)
char *newstr; char *newstr;
if(!str) if(!str)
return (char *)NULL; return NULL;
len = strlen(str) + 1; len = strlen(str) + 1;
newstr = curlx_malloc(len); newstr = curlx_malloc(len);
if(!newstr) if(!newstr)
return (char *)NULL; return NULL;
memcpy(newstr, str, len); memcpy(newstr, str, len);
return newstr; return newstr;

View File

@ -496,9 +496,9 @@ static void rec_wont(struct Curl_easy *data, struct TELNET *tn, int option)
} }
static void printsub(struct Curl_easy *data, static void printsub(struct Curl_easy *data,
int direction, /* '<' or '>' */ int direction, /* '<' or '>' */
unsigned char *pointer, /* where suboption data is */ const unsigned char *pointer, /* ptr to suboption data */
size_t length) /* length of suboption data */ size_t length) /* suboption data length */
{ {
if(data->set.verbose) { if(data->set.verbose) {
unsigned int i = 0; unsigned int i = 0;
@ -611,10 +611,10 @@ static void printsub(struct Curl_easy *data,
/* Escape and send a telnet data block */ /* Escape and send a telnet data block */
static CURLcode send_telnet_data(struct Curl_easy *data, static CURLcode send_telnet_data(struct Curl_easy *data,
struct TELNET *tn, struct TELNET *tn,
char *buffer, ssize_t nread) const char *buffer, ssize_t nread)
{ {
size_t i, outlen; size_t i, outlen;
unsigned char *outbuf; const unsigned char *outbuf;
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
size_t bytes_written; size_t bytes_written;
size_t total_written = 0; size_t total_written = 0;
@ -641,7 +641,7 @@ static CURLcode send_telnet_data(struct Curl_easy *data,
} }
else { else {
outlen = (size_t)nread; outlen = (size_t)nread;
outbuf = (unsigned char *)buffer; outbuf = (const unsigned char *)buffer;
} }
while(!result && total_written < outlen) { while(!result && total_written < outlen) {
/* Make sure socket is writable to avoid EWOULDBLOCK condition */ /* Make sure socket is writable to avoid EWOULDBLOCK condition */
@ -676,7 +676,7 @@ static void sendsuboption(struct Curl_easy *data,
ssize_t bytes_written; ssize_t bytes_written;
int err; int err;
unsigned short x, y; unsigned short x, y;
unsigned char *uc1, *uc2; const unsigned char *uc1, *uc2;
struct connectdata *conn = data->conn; struct connectdata *conn = data->conn;
switch(option) { switch(option) {
@ -690,8 +690,8 @@ static void sendsuboption(struct Curl_easy *data,
/* Window size must be sent according to the 'network order' */ /* Window size must be sent according to the 'network order' */
x = htons(tn->subopt_wsx); x = htons(tn->subopt_wsx);
y = htons(tn->subopt_wsy); y = htons(tn->subopt_wsy);
uc1 = (unsigned char *)&x; uc1 = (const unsigned char *)&x;
uc2 = (unsigned char *)&y; uc2 = (const unsigned char *)&y;
CURL_SB_ACCUM(tn, uc1[0]); CURL_SB_ACCUM(tn, uc1[0]);
CURL_SB_ACCUM(tn, uc1[1]); CURL_SB_ACCUM(tn, uc1[1]);
CURL_SB_ACCUM(tn, uc2[0]); CURL_SB_ACCUM(tn, uc2[0]);
@ -702,7 +702,7 @@ static void sendsuboption(struct Curl_easy *data,
CURL_SB_TERM(tn); CURL_SB_TERM(tn);
/* data suboption is now ready */ /* data suboption is now ready */
printsub(data, '>', (unsigned char *)tn->subbuffer + 2, printsub(data, '>', (const unsigned char *)tn->subbuffer + 2,
CURL_SB_LEN(tn) - 2); CURL_SB_LEN(tn) - 2);
/* we send the header of the suboption... */ /* we send the header of the suboption... */
@ -713,7 +713,7 @@ static void sendsuboption(struct Curl_easy *data,
} }
/* ... then the window size with the send_telnet_data() function /* ... then the window size with the send_telnet_data() function
to deal with 0xFF cases ... */ to deal with 0xFF cases ... */
send_telnet_data(data, tn, (char *)tn->subbuffer + 3, 4); send_telnet_data(data, tn, (const char *)tn->subbuffer + 3, 4);
/* ... and the footer */ /* ... and the footer */
bytes_written = swrite(conn->sock[FIRSTSOCKET], tn->subbuffer + 7, 2); bytes_written = swrite(conn->sock[FIRSTSOCKET], tn->subbuffer + 7, 2);
if(bytes_written < 0) { if(bytes_written < 0) {
@ -986,7 +986,8 @@ static CURLcode suboption(struct Curl_easy *data, struct TELNET *tn)
if(!CURL_SB_LEN(tn)) /* ignore empty suboption */ if(!CURL_SB_LEN(tn)) /* ignore empty suboption */
return CURLE_OK; return CURLE_OK;
printsub(data, '<', (unsigned char *)tn->subbuffer, CURL_SB_LEN(tn) + 2); printsub(data, '<', (const unsigned char *)tn->subbuffer,
CURL_SB_LEN(tn) + 2);
switch(CURL_SB_GET(tn)) { switch(CURL_SB_GET(tn)) {
case CURL_TELOPT_TTYPE: case CURL_TELOPT_TTYPE:
if(bad_option(tn->subopt_ttype)) if(bad_option(tn->subopt_ttype))

View File

@ -1078,7 +1078,7 @@ static CURLcode tftp_receive_packet(struct Curl_easy *data,
if(state->rbytes > 4 && if(state->rbytes > 4 &&
(NEXT_BLOCKNUM(state->block) == getrpacketblock(&state->rpacket))) { (NEXT_BLOCKNUM(state->block) == getrpacketblock(&state->rpacket))) {
result = Curl_client_write(data, CLIENTWRITE_BODY, result = Curl_client_write(data, CLIENTWRITE_BODY,
(char *)state->rpacket.data + 4, (const char *)state->rpacket.data + 4,
state->rbytes - 4); state->rbytes - 4);
if(result) { if(result) {
tftp_state_machine(state, TFTP_EVENT_ERROR); tftp_state_machine(state, TFTP_EVENT_ERROR);
@ -1088,7 +1088,7 @@ static CURLcode tftp_receive_packet(struct Curl_easy *data,
break; break;
case TFTP_EVENT_ERROR: { case TFTP_EVENT_ERROR: {
unsigned short error = getrpacketblock(&state->rpacket); unsigned short error = getrpacketblock(&state->rpacket);
char *str = (char *)state->rpacket.data + 4; const char *str = (const char *)state->rpacket.data + 4;
size_t strn = state->rbytes - 4; size_t strn = state->rbytes - 4;
state->error = (tftp_error_t)error; state->error = (tftp_error_t)error;
if(tftp_strnlen(str, strn) < strn) if(tftp_strnlen(str, strn) < strn)

View File

@ -1965,7 +1965,7 @@ static char *detect_proxy(struct Curl_easy *data,
* that may exist registered to the same proxy host. * that may exist registered to the same proxy host.
*/ */
static CURLcode parse_proxy(struct Curl_easy *data, static CURLcode parse_proxy(struct Curl_easy *data,
struct connectdata *conn, char *proxy, struct connectdata *conn, const char *proxy,
long proxytype) long proxytype)
{ {
char *portptr = NULL; char *portptr = NULL;
@ -2997,7 +2997,7 @@ static CURLcode parse_connect_to_slist(struct Curl_easy *data,
#ifdef USE_UNIX_SOCKETS #ifdef USE_UNIX_SOCKETS
static CURLcode resolve_unix(struct Curl_easy *data, static CURLcode resolve_unix(struct Curl_easy *data,
struct connectdata *conn, struct connectdata *conn,
char *unix_path, const char *unix_path,
struct Curl_dns_entry **pdns) struct Curl_dns_entry **pdns)
{ {
struct Curl_dns_entry *hostaddr; struct Curl_dns_entry *hostaddr;
@ -3047,7 +3047,7 @@ static CURLcode resolve_server(struct Curl_easy *data,
#ifdef USE_UNIX_SOCKETS #ifdef USE_UNIX_SOCKETS
{ {
char *unix_path = conn->unix_domain_socket; const char *unix_path = conn->unix_domain_socket;
#ifndef CURL_DISABLE_PROXY #ifndef CURL_DISABLE_PROXY
if(!unix_path && CONN_IS_PROXIED(conn) && conn->socks_proxy.host.name && if(!unix_path && CONN_IS_PROXIED(conn) && conn->socks_proxy.host.name &&

View File

@ -336,7 +336,7 @@ UNITTEST CURLUcode Curl_parse_port(struct Curl_URL *u, struct dynbuf *host,
bool has_scheme) bool has_scheme)
{ {
const char *portptr; const char *portptr;
char *hostname = curlx_dyn_ptr(host); const char *hostname = curlx_dyn_ptr(host);
/* /*
* Find the end of an IPv6 address on the ']' ending bracket. * Find the end of an IPv6 address on the ']' ending bracket.
*/ */

View File

@ -130,8 +130,9 @@ bool Curl_auth_digest_get_pair(const char *str, char *value, char *content,
#ifndef USE_WINDOWS_SSPI #ifndef USE_WINDOWS_SSPI
/* Convert MD5 chunk to RFC2617 (section 3.1.3) -suitable ASCII string */ /* Convert MD5 chunk to RFC2617 (section 3.1.3) -suitable ASCII string */
static void auth_digest_md5_to_ascii(unsigned char *source, /* 16 bytes */ static void auth_digest_md5_to_ascii(
unsigned char *dest) /* 33 bytes */ const unsigned char *source, /* 16 bytes */
unsigned char *dest) /* 33 bytes */
{ {
int i; int i;
for(i = 0; i < 16; i++) for(i = 0; i < 16; i++)
@ -139,8 +140,9 @@ static void auth_digest_md5_to_ascii(unsigned char *source, /* 16 bytes */
} }
/* Convert sha256 or SHA-512/256 chunk to RFC7616 -suitable ASCII string */ /* Convert sha256 or SHA-512/256 chunk to RFC7616 -suitable ASCII string */
static void auth_digest_sha256_to_ascii(unsigned char *source, /* 32 bytes */ static void auth_digest_sha256_to_ascii(
unsigned char *dest) /* 65 bytes */ const unsigned char *source, /* 32 bytes */
unsigned char *dest) /* 65 bytes */
{ {
int i; int i;
for(i = 0; i < 32; i++) for(i = 0; i < 32; i++)
@ -670,7 +672,7 @@ static CURLcode auth_create_digest_http_message(
const unsigned char *uripath, const unsigned char *uripath,
struct digestdata *digest, struct digestdata *digest,
char **outptr, size_t *outlen, char **outptr, size_t *outlen,
void (*convert_to_ascii)(unsigned char *, unsigned char *), void (*convert_to_ascii)(const unsigned char *, unsigned char *),
CURLcode (*hash)(unsigned char *, const unsigned char *, const size_t)) CURLcode (*hash)(unsigned char *, const unsigned char *, const size_t))
{ {
CURLcode result; CURLcode result;

View File

@ -565,7 +565,7 @@ CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data,
unsigned int ntrespoff; unsigned int ntrespoff;
unsigned int ntresplen = 24; unsigned int ntresplen = 24;
unsigned char ntresp[24]; /* fixed-size */ unsigned char ntresp[24]; /* fixed-size */
unsigned char *ptr_ntresp = &ntresp[0]; const unsigned char *ptr_ntresp = &ntresp[0];
unsigned char *ntlmv2resp = NULL; unsigned char *ntlmv2resp = NULL;
bool unicode = (ntlm->flags & NTLMFLAG_NEGOTIATE_UNICODE); bool unicode = (ntlm->flags & NTLMFLAG_NEGOTIATE_UNICODE);
/* The fixed hostname we provide, in order to not leak our real local host /* The fixed hostname we provide, in order to not leak our real local host

View File

@ -1367,7 +1367,7 @@ static int myssh_in_SFTP_QUOTE(struct Curl_easy *data,
/* /*
* Support some of the "FTP" commands * Support some of the "FTP" commands
*/ */
char *cmd = sshc->quote_item->data; const char *cmd = sshc->quote_item->data;
sshc->acceptfail = FALSE; sshc->acceptfail = FALSE;
/* if a command starts with an asterisk, which a legal SFTP command never /* if a command starts with an asterisk, which a legal SFTP command never
@ -1578,7 +1578,7 @@ static int myssh_in_SFTP_NEXT_QUOTE(struct Curl_easy *data,
static int myssh_in_SFTP_QUOTE_STAT(struct Curl_easy *data, static int myssh_in_SFTP_QUOTE_STAT(struct Curl_easy *data,
struct ssh_conn *sshc) struct ssh_conn *sshc)
{ {
char *cmd = sshc->quote_item->data; const char *cmd = sshc->quote_item->data;
sshc->acceptfail = FALSE; sshc->acceptfail = FALSE;
/* if a command starts with an asterisk, which a legal SFTP command never /* if a command starts with an asterisk, which a legal SFTP command never

View File

@ -737,7 +737,7 @@ static CURLcode sftp_quote(struct Curl_easy *data,
* 'sshc->quote_item' is already verified to be non-NULL before it * 'sshc->quote_item' is already verified to be non-NULL before it
* switched to this state. * switched to this state.
*/ */
char *cmd = sshc->quote_item->data; const char *cmd = sshc->quote_item->data;
sshc->acceptfail = FALSE; sshc->acceptfail = FALSE;
/* if a command starts with an asterisk, which a legal SFTP command never /* if a command starts with an asterisk, which a legal SFTP command never
@ -1165,7 +1165,7 @@ static CURLcode sftp_quote_stat(struct Curl_easy *data,
struct SSHPROTO *sshp, struct SSHPROTO *sshp,
bool *blockp) bool *blockp)
{ {
char *cmd = sshc->quote_item->data; const char *cmd = sshc->quote_item->data;
sshc->acceptfail = FALSE; sshc->acceptfail = FALSE;
/* if a command starts with an asterisk, which a legal SFTP command never /* if a command starts with an asterisk, which a legal SFTP command never

View File

@ -125,7 +125,7 @@ void Curl_ssh_set_state(struct Curl_easy *data,
/* figure out the path to work with in this particular request */ /* figure out the path to work with in this particular request */
CURLcode Curl_getworkingpath(struct Curl_easy *data, CURLcode Curl_getworkingpath(struct Curl_easy *data,
char *homedir, /* when SFTP is used */ const char *homedir, /* when SFTP is used */
char **path) /* returns the allocated char **path) /* returns the allocated
real path to work with */ real path to work with */
{ {

View File

@ -28,7 +28,7 @@
#include "../urldata.h" #include "../urldata.h"
CURLcode Curl_getworkingpath(struct Curl_easy *data, CURLcode Curl_getworkingpath(struct Curl_easy *data,
char *homedir, const char *homedir,
char **path); char **path);
CURLcode Curl_get_pathname(const char **cpp, char **path, const char *homedir); CURLcode Curl_get_pathname(const char **cpp, char **path, const char *homedir);

View File

@ -1058,7 +1058,7 @@ static size_t multissl_version(char *buffer, size_t size)
if(current != selected) { if(current != selected) {
char *p = backends; char *p = backends;
char *end = backends + sizeof(backends); const char *end = backends + sizeof(backends);
int i; int i;
selected = current; selected = current;

View File

@ -1135,7 +1135,7 @@ CURLcode Curl_wssl_ctx_init(struct wssl_ctx *wctx,
#ifndef WOLFSSL_TLS13 #ifndef WOLFSSL_TLS13
{ {
char *ciphers = conn_config->cipher_list; const char *ciphers = conn_config->cipher_list;
if(ciphers) { if(ciphers) {
if(!SSL_CTX_set_cipher_list(wctx->ssl_ctx, ciphers)) { if(!SSL_CTX_set_cipher_list(wctx->ssl_ctx, ciphers)) {
failf(data, "failed setting cipher list: %s", ciphers); failf(data, "failed setting cipher list: %s", ciphers);

View File

@ -146,7 +146,7 @@ static const struct Curl_OID OIDtable[] = {
{ "2.16.840.1.101.3.4.2.2", "sha384" }, { "2.16.840.1.101.3.4.2.2", "sha384" },
{ "2.16.840.1.101.3.4.2.3", "sha512" }, { "2.16.840.1.101.3.4.2.3", "sha512" },
{ "1.2.840.113549.1.9.2", "unstructuredName" }, { "1.2.840.113549.1.9.2", "unstructuredName" },
{ (const char *)NULL, (const char *)NULL } { NULL, NULL }
}; };
#endif /* WANT_EXTRACT_CERTINFO */ #endif /* WANT_EXTRACT_CERTINFO */
@ -932,7 +932,7 @@ static CURLcode ssl_push_certinfo_dyn(struct Curl_easy *data,
struct dynbuf *ptr) struct dynbuf *ptr)
{ {
size_t valuelen = curlx_dyn_len(ptr); size_t valuelen = curlx_dyn_len(ptr);
char *value = curlx_dyn_ptr(ptr); const char *value = curlx_dyn_ptr(ptr);
CURLcode result = Curl_ssl_push_certinfo_len(data, certnum, label, CURLcode result = Curl_ssl_push_certinfo_len(data, certnum, label,
value, valuelen); value, valuelen);

View File

@ -257,7 +257,7 @@ static const char *disabled[] = {
#endif #endif
}; };
int main(int argc, char **argv) int main(int argc, const char **argv)
{ {
size_t i; size_t i;

View File

@ -66,8 +66,8 @@ static void write_linked_location(CURL *curl, const char *location,
{ {
/* This would so simple if CURLINFO_REDIRECT_URL were available here */ /* This would so simple if CURLINFO_REDIRECT_URL were available here */
CURLU *u = NULL; CURLU *u = NULL;
char *copyloc = NULL, *locurl = NULL, *scheme = NULL, *finalurl = NULL; char *copyloc = NULL, *scheme = NULL, *finalurl = NULL;
const char *loc = location; const char *loc = location, *locurl = NULL;
size_t llen = loclen; size_t llen = loclen;
int space_skipped = 0; int space_skipped = 0;
const char *vver = getenv("VTE_VERSION"); const char *vver = getenv("VTE_VERSION");

View File

@ -96,7 +96,7 @@ int SetHTTPrequest(HttpReq req, HttpReq *store)
return 1; return 1;
} }
void customrequest_helper(HttpReq req, char *method) void customrequest_helper(HttpReq req, const char *method)
{ {
/* this mirrors the HttpReq enum in tool_sdecls.h */ /* this mirrors the HttpReq enum in tool_sdecls.h */
const char *dflt[] = { const char *dflt[] = {

View File

@ -27,6 +27,6 @@
const char *param2text(ParameterError error); const char *param2text(ParameterError error);
int SetHTTPrequest(HttpReq req, HttpReq *store); int SetHTTPrequest(HttpReq req, HttpReq *store);
void customrequest_helper(HttpReq req, char *method); void customrequest_helper(HttpReq req, const char *method);
#endif /* HEADER_CURL_TOOL_HELPERS_H */ #endif /* HEADER_CURL_TOOL_HELPERS_H */

View File

@ -1753,7 +1753,7 @@ static CURLcode check_finished(struct parastate *s)
struct per_transfer *ended; struct per_transfer *ended;
CURL *easy = msg->easy_handle; CURL *easy = msg->easy_handle;
CURLcode tres = msg->data.result; CURLcode tres = msg->data.result;
curl_easy_getinfo(easy, CURLINFO_PRIVATE, (void *)&ended); curl_easy_getinfo(easy, CURLINFO_PRIVATE, &ended);
curl_multi_remove_handle(s->multi, easy); curl_multi_remove_handle(s->multi, easy);
if(ended->abort && (tres == CURLE_ABORTED_BY_CALLBACK)) { if(ended->abort && (tres == CURLE_ABORTED_BY_CALLBACK)) {
@ -2022,7 +2022,7 @@ static CURLcode is_using_schannel(int *pusing)
if(using_schannel == -1) { if(using_schannel == -1) {
CURL *curltls = curl_easy_init(); CURL *curltls = curl_easy_init();
/* The TLS backend remains, so keep the info */ /* The TLS backend remains, so keep the info */
struct curl_tlssessioninfo *tls_backend_info = NULL; const struct curl_tlssessioninfo *tls_backend_info = NULL;
if(!curltls) if(!curltls)
result = CURLE_OUT_OF_MEMORY; result = CURLE_OUT_OF_MEMORY;

View File

@ -34,7 +34,7 @@ struct per_transfer {
struct per_transfer *next; struct per_transfer *next;
struct per_transfer *prev; struct per_transfer *prev;
struct OperationConfig *config; /* for this transfer */ struct OperationConfig *config; /* for this transfer */
struct curl_certinfo *certinfo; const struct curl_certinfo *certinfo;
CURL *curl; CURL *curl;
long retry_remaining; long retry_remaining;
long retry_sleep_default; long retry_sleep_default;

View File

@ -277,7 +277,7 @@ static bool get_line(FILE *input, struct dynbuf *buf, bool *error)
char buffer[128]; char buffer[128];
curlx_dyn_reset(buf); curlx_dyn_reset(buf);
while(1) { while(1) {
char *b = fgets(buffer, sizeof(buffer), input); const char *b = fgets(buffer, sizeof(buffer), input);
if(b) { if(b) {
size_t rlen = strlen(b); size_t rlen = strlen(b);

View File

@ -86,7 +86,7 @@ static int urlpart(struct per_transfer *per, writeoutid vid,
if(uh) { if(uh) {
CURLUPart cpart = CURLUPART_HOST; CURLUPart cpart = CURLUPART_HOST;
char *part = NULL; char *part = NULL;
const char *url = NULL; char *url = NULL;
if(vid >= VAR_INPUT_URLESCHEME) { if(vid >= VAR_INPUT_URLESCHEME) {
if(curl_easy_getinfo(per->curl, CURLINFO_EFFECTIVE_URL, &url)) if(curl_easy_getinfo(per->curl, CURLINFO_EFFECTIVE_URL, &url))
@ -162,7 +162,7 @@ static int urlpart(struct per_transfer *per, writeoutid vid,
static void certinfo(struct per_transfer *per) static void certinfo(struct per_transfer *per)
{ {
if(!per->certinfo) { if(!per->certinfo) {
struct curl_certinfo *certinfo; const struct curl_certinfo *certinfo;
CURLcode result = curl_easy_getinfo(per->curl, CURLINFO_CERTINFO, CURLcode result = curl_easy_getinfo(per->curl, CURLINFO_CERTINFO,
&certinfo); &certinfo);
per->certinfo = (!result && certinfo) ? certinfo : NULL; per->certinfo = (!result && certinfo) ? certinfo : NULL;

View File

@ -24,7 +24,7 @@
#include "curl/curl.h" #include "curl/curl.h"
#include <stdio.h> #include <stdio.h>
int main(int argc, char **argv) int main(int argc, const char **argv)
{ {
(void)argc; (void)argc;
puts("libcurl test:"); puts("libcurl test:");

View File

@ -60,7 +60,7 @@ static int server_push_callback(CURL *parent,
struct curl_pushheaders *headers, struct curl_pushheaders *headers,
void *userp) void *userp)
{ {
char *headp; const char *headp;
size_t i; size_t i;
int *transfers = (int *)userp; int *transfers = (int *)userp;
char filename[128]; char filename[128];

View File

@ -211,7 +211,7 @@ static int my_progress_d_cb(void *userdata,
static int setup_hx_download(CURL *curl, const char *url, struct transfer_d *t, static int setup_hx_download(CURL *curl, const char *url, struct transfer_d *t,
long http_version, struct curl_slist *host, long http_version, struct curl_slist *host,
CURLSH *share, int use_earlydata, CURLSH *share, int use_earlydata,
int fresh_connect, char *cafile) int fresh_connect, const char *cafile)
{ {
curl_easy_setopt(curl, CURLOPT_SHARE, share); curl_easy_setopt(curl, CURLOPT_SHARE, share);
curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_URL, url);

View File

@ -41,8 +41,8 @@ static CURLcode test_lib1518(const char *URL)
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
long curlResponseCode; long curlResponseCode;
long curlRedirectCount; long curlRedirectCount;
char *effectiveUrl = NULL; const char *effectiveUrl = NULL;
char *redirectUrl = NULL; const char *redirectUrl = NULL;
CURLU *urlu = NULL; CURLU *urlu = NULL;
curl = curl_easy_init(); curl = curl_easy_init();
if(!curl) { if(!curl) {

View File

@ -28,7 +28,7 @@
static CURLcode test_lib1536(const char *URL) static CURLcode test_lib1536(const char *URL)
{ {
CURL *curl, *dupe = NULL; CURL *curl, *dupe = NULL;
char *scheme; const char *scheme;
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
global_init(CURL_GLOBAL_ALL); global_init(CURL_GLOBAL_ALL);

View File

@ -1150,7 +1150,7 @@ static const struct setcase set_parts_list[] = {
{NULL, NULL, NULL, 0, 0, CURLUE_OK, CURLUE_OK} {NULL, NULL, NULL, 0, 0, CURLUE_OK, CURLUE_OK}
}; };
static CURLUPart part2id(char *part) static CURLUPart part2id(const char *part)
{ {
if(!strcmp("url", part)) if(!strcmp("url", part))
return CURLUPART_URL; return CURLUPART_URL;

View File

@ -29,7 +29,7 @@ static CURLcode test_lib1977(const char *URL)
CURLU *curlu = curl_url(); CURLU *curlu = curl_url();
CURLU *curlu_2 = curl_url(); CURLU *curlu_2 = curl_url();
CURL *curl; CURL *curl;
char *effective = NULL; const char *effective = NULL;
global_init(CURL_GLOBAL_ALL); global_init(CURL_GLOBAL_ALL);
easy_init(curl); easy_init(curl);

View File

@ -28,7 +28,7 @@ static CURLcode test_lib3010(const char *URL)
CURLcode result = TEST_ERR_MAJOR_BAD; CURLcode result = TEST_ERR_MAJOR_BAD;
CURL *curl = NULL; CURL *curl = NULL;
curl_off_t retry_after; curl_off_t retry_after;
char *follow_url = NULL; const char *follow_url = NULL;
curl_global_init(CURL_GLOBAL_ALL); curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init(); curl = curl_easy_init();

View File

@ -29,7 +29,7 @@
*/ */
static bool is_chain_in_order(struct curl_certinfo *cert_info) static bool is_chain_in_order(struct curl_certinfo *cert_info)
{ {
char *last_issuer = NULL; const char *last_issuer = NULL;
int cert; int cert;
/* Chains with only a single certificate are always in order */ /* Chains with only a single certificate are always in order */
@ -39,8 +39,8 @@ static bool is_chain_in_order(struct curl_certinfo *cert_info)
/* Enumerate each certificate in the chain */ /* Enumerate each certificate in the chain */
for(cert = 0; cert < cert_info->num_of_certs; cert++) { for(cert = 0; cert < cert_info->num_of_certs; cert++) {
struct curl_slist *slist = cert_info->certinfo[cert]; struct curl_slist *slist = cert_info->certinfo[cert];
char *issuer = NULL; const char *issuer = NULL;
char *subject = NULL; const char *subject = NULL;
/* Find the certificate issuer and subject by enumerating each field */ /* Find the certificate issuer and subject by enumerating each field */
for(; slist && (!issuer || !subject); slist = slist->next) { for(; slist && (!issuer || !subject); slist = slist->next) {

View File

@ -46,7 +46,7 @@ static size_t write_memory_callback(char *contents, size_t size,
/* append the data to contents */ /* append the data to contents */
size_t realsize = size * nmemb; size_t realsize = size * nmemb;
struct Ctx *mem = (struct Ctx *)userp; struct Ctx *mem = (struct Ctx *)userp;
char *data = (char *)curlx_malloc(realsize + 1); char *data = curlx_malloc(realsize + 1);
struct curl_slist *item_append = NULL; struct curl_slist *item_append = NULL;
if(!data) { if(!data) {
curl_mprintf("not enough memory (malloc returned NULL)\n"); curl_mprintf("not enough memory (malloc returned NULL)\n");

View File

@ -55,7 +55,7 @@ static CURLcode test_lib500(const char *URL)
{ {
CURLcode result; CURLcode result;
CURL *curl; CURL *curl;
char *ipstr = NULL; const char *ipstr = NULL;
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
curl_mfprintf(stderr, "curl_global_init() failed\n"); curl_mfprintf(stderr, "curl_global_init() failed\n");

View File

@ -33,7 +33,6 @@ static CURLcode test_lib569(const char *URL)
CURLcode result; CURLcode result;
CURL *curl; CURL *curl;
char *stream_uri = NULL; char *stream_uri = NULL;
char *rtsp_session_id;
int request = 1; int request = 1;
int i; int i;
@ -74,6 +73,7 @@ static CURLcode test_lib569(const char *URL)
/* Go through the various Session IDs */ /* Go through the various Session IDs */
for(i = 0; i < 3; i++) { for(i = 0; i < 3; i++) {
const char *rtsp_session_id;
stream_uri = tutil_suburl(URL, request++); stream_uri = tutil_suburl(URL, request++);
if(!stream_uri) { if(!stream_uri) {
result = TEST_ERR_MAJOR_BAD; result = TEST_ERR_MAJOR_BAD;

View File

@ -209,7 +209,7 @@ print $fh <<HEADER
/* This source code is generated by mk-lib1521.pl ! */ /* This source code is generated by mk-lib1521.pl ! */
struct t1521_testdata { struct t1521_testdata {
char *blaha; const char *blaha;
}; };
#define LO $minlong #define LO $minlong
@ -364,12 +364,12 @@ static CURLcode test_lib1521(const char *URL)
FILE *stream = stderr; FILE *stream = stderr;
struct t1521_testdata object; struct t1521_testdata object;
CURLU *curlu = (CURLU *)&object; CURLU *curlu = (CURLU *)&object;
char *charp; const char *charp;
long val; long val;
curl_off_t oval; curl_off_t oval;
double dval; double dval;
curl_socket_t sockfd; curl_socket_t sockfd;
struct curl_certinfo *certinfo; const struct curl_certinfo *certinfo;
struct curl_tlssessioninfo *tlssession; struct curl_tlssessioninfo *tlssession;
struct curl_blob blob = { CURL_UNCONST("silly"), 5, 0}; struct curl_blob blob = { CURL_UNCONST("silly"), 5, 0};
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;

View File

@ -87,7 +87,7 @@ int libtest_debug_cb(CURL *curl, curl_infotype type,
struct libtest_trace_cfg *trace_cfg = userp; struct libtest_trace_cfg *trace_cfg = userp;
const char *text; const char *text;
char timebuf[20]; char timebuf[20];
char *timestr; const char *timestr;
(void)curl; (void)curl;

View File

@ -233,7 +233,7 @@ static unsigned char ancount_aaaa;
/* this is an answer to a question */ /* this is an answer to a question */
static int send_response(curl_socket_t sock, static int send_response(curl_socket_t sock,
const struct sockaddr *addr, curl_socklen_t addrlen, const struct sockaddr *addr, curl_socklen_t addrlen,
unsigned char *qbuf, size_t qlen, const unsigned char *qbuf, size_t qlen,
unsigned short qtype, unsigned short id) unsigned short qtype, unsigned short id)
{ {
ssize_t rc; ssize_t rc;
@ -378,7 +378,7 @@ static void read_instructions(void)
logmsg("Error opening file '%s'", file); logmsg("Error opening file '%s'", file);
} }
static int test_dnsd(int argc, char **argv) static int test_dnsd(int argc, const char **argv)
{ {
srvr_sockaddr_union_t me; srvr_sockaddr_union_t me;
ssize_t n = 0; ssize_t n = 0;

View File

@ -25,10 +25,10 @@
#include <stdio.h> #include <stdio.h>
int main(int argc, char **argv) int main(int argc, const char **argv)
{ {
entry_func_t entry_func; entry_func_t entry_func;
char *entry_name; const char *entry_name;
size_t tmp; size_t tmp;
if(argc < 2) { if(argc < 2) {

View File

@ -39,7 +39,7 @@
#include "curl_setup.h" #include "curl_setup.h"
typedef int (*entry_func_t)(int, char **); typedef int (*entry_func_t)(int, const char **);
struct entry_s { struct entry_s {
const char *name; const char *name;
@ -125,9 +125,8 @@ extern int getpart(char **outbuf, size_t *outlen,
const char *main, const char *sub, FILE *stream); const char *main, const char *sub, FILE *stream);
/* utility functions */ /* utility functions */
extern char *data_to_hex(char *data, size_t len);
extern void logmsg(const char *msg, ...) CURL_PRINTF(1, 2); extern void logmsg(const char *msg, ...) CURL_PRINTF(1, 2);
extern void loghex(unsigned char *buffer, ssize_t len); extern void loghex(const unsigned char *buffer, ssize_t len);
extern int win32_init(void); extern int win32_init(void);
extern FILE *test2fopen(long testno, const char *logdir2); extern FILE *test2fopen(long testno, const char *logdir2);
extern curl_off_t our_getpid(void); extern curl_off_t our_getpid(void);

View File

@ -141,12 +141,13 @@ static int readline(char **buffer, size_t *bufsize, size_t *length,
* GPE_OUT_OF_MEMORY * GPE_OUT_OF_MEMORY
* GPE_OK * GPE_OK
*/ */
static int appenddata(char **dst_buf, /* dest buffer */ static int appenddata(char **dst_buf, /* dest buffer */
size_t *dst_len, /* dest buffer data length */ size_t *dst_len, /* dest buffer data length */
size_t *dst_alloc, /* dest buffer allocated size */ size_t *dst_alloc, /* dest buffer allocated size */
char *src_buf, /* source buffer */ const char *src_buf, /* source buffer */
size_t src_len, /* source buffer length */ size_t src_len, /* source buffer length */
int src_b64) /* != 0 if source is base64 encoded */ int src_b64) /* != 0 if source is base64
encoded */
{ {
size_t need_alloc = 0; size_t need_alloc = 0;
@ -182,7 +183,7 @@ static int appenddata(char **dst_buf, /* dest buffer */
return GPE_OK; return GPE_OK;
} }
static int decodedata(char **buf, /* dest buffer */ static int decodedata(char **buf, /* dest buffer */
size_t *len) /* dest buffer data length */ size_t *len) /* dest buffer data length */
{ {
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;

View File

@ -131,11 +131,11 @@ typedef enum {
static void logprotocol(mqttdir dir, static void logprotocol(mqttdir dir,
const char *prefix, size_t remlen, const char *prefix, size_t remlen,
FILE *output, FILE *output,
unsigned char *buffer, ssize_t len) const unsigned char *buffer, ssize_t len)
{ {
char data[12000] = ""; char data[12000] = "";
ssize_t i; ssize_t i;
unsigned char *ptr = buffer; const unsigned char *ptr = buffer;
char *optr = data; char *optr = data;
int left = sizeof(data); int left = sizeof(data);
@ -279,7 +279,7 @@ static size_t encode_length(size_t packetlen,
return bytes; return bytes;
} }
static size_t decode_length(unsigned char *buffer, static size_t decode_length(const unsigned char *buffer,
size_t buflen, size_t *lenbytes) size_t buflen, size_t *lenbytes)
{ {
size_t len = 0; size_t len = 0;
@ -712,7 +712,7 @@ static bool mqttd_incoming(curl_socket_t listenfd)
return TRUE; return TRUE;
} }
static int test_mqttd(int argc, char *argv[]) static int test_mqttd(int argc, const char *argv[])
{ {
curl_socket_t sock = CURL_SOCKET_BAD; curl_socket_t sock = CURL_SOCKET_BAD;
curl_socket_t msgsock = CURL_SOCKET_BAD; curl_socket_t msgsock = CURL_SOCKET_BAD;

View File

@ -33,7 +33,7 @@
* *
*/ */
static int test_resolve(int argc, char *argv[]) static int test_resolve(int argc, const char *argv[])
{ {
int arg = 1; int arg = 1;
const char *host = NULL; const char *host = NULL;

View File

@ -143,7 +143,7 @@ static const char *RTP_DATA = "$_1234\n\0Rsdf";
static int rtspd_ProcessRequest(struct rtspd_httprequest *req) static int rtspd_ProcessRequest(struct rtspd_httprequest *req)
{ {
char *line = &req->reqbuf[req->checkindex]; const char *line = &req->reqbuf[req->checkindex];
bool chunked = FALSE; bool chunked = FALSE;
static char request[REQUEST_KEYWORD_SIZE]; static char request[REQUEST_KEYWORD_SIZE];
static char doc[MAXDOCNAMELEN]; static char doc[MAXDOCNAMELEN];
@ -539,7 +539,7 @@ static int rtspd_ProcessRequest(struct rtspd_httprequest *req)
} }
/* store the entire request in a file */ /* store the entire request in a file */
static void rtspd_storerequest(char *reqbuf, size_t totalsize) static void rtspd_storerequest(const char *reqbuf, size_t totalsize)
{ {
int res; int res;
int error = 0; int error = 0;
@ -997,7 +997,7 @@ static int rtspd_send_doc(curl_socket_t sock, struct rtspd_httprequest *req)
return 0; return 0;
} }
static int test_rtspd(int argc, char *argv[]) static int test_rtspd(int argc, const char *argv[])
{ {
srvr_sockaddr_union_t me; srvr_sockaddr_union_t me;
curl_socket_t sock = CURL_SOCKET_BAD; curl_socket_t sock = CURL_SOCKET_BAD;

View File

@ -313,11 +313,11 @@ static bool write_stdout(const void *buffer, size_t nbytes)
return TRUE; return TRUE;
} }
static void lograw(unsigned char *buffer, ssize_t len) static void lograw(const unsigned char *buffer, ssize_t len)
{ {
char data[120]; char data[120];
ssize_t i; ssize_t i;
unsigned char *ptr = buffer; const unsigned char *ptr = buffer;
char *optr = data; char *optr = data;
ssize_t width = 0; ssize_t width = 0;
int left = sizeof(data); int left = sizeof(data);
@ -372,7 +372,7 @@ static bool read_data_block(unsigned char *buffer, ssize_t maxlen,
buffer[5] = '\0'; buffer[5] = '\0';
endp = (char *)buffer; endp = (const char *)buffer;
if(curlx_str_hex(&endp, &value, 0xfffff)) { if(curlx_str_hex(&endp, &value, 0xfffff)) {
logmsg("Failed to decode buffer size"); logmsg("Failed to decode buffer size");
return FALSE; return FALSE;
@ -1066,7 +1066,7 @@ static bool juggle(curl_socket_t *sockfdp,
Replies to PORT with "IPv[num]/[port]" */ Replies to PORT with "IPv[num]/[port]" */
snprintf((char *)buffer, sizeof(buffer), "%s/%hu\n", snprintf((char *)buffer, sizeof(buffer), "%s/%hu\n",
ipv_inuse, server_port); ipv_inuse, server_port);
buffer_len = (ssize_t)strlen((char *)buffer); buffer_len = (ssize_t)strlen((const char *)buffer);
snprintf(data, sizeof(data), "PORT\n%04x\n", (int)buffer_len); snprintf(data, sizeof(data), "PORT\n%04x\n", (int)buffer_len);
if(!write_stdout(data, 10)) if(!write_stdout(data, 10))
return FALSE; return FALSE;
@ -1171,7 +1171,7 @@ static bool juggle(curl_socket_t *sockfdp,
return TRUE; return TRUE;
} }
static int test_sockfilt(int argc, char *argv[]) static int test_sockfilt(int argc, const char *argv[])
{ {
srvr_sockaddr_union_t me; srvr_sockaddr_union_t me;
curl_socket_t sock = CURL_SOCKET_BAD; curl_socket_t sock = CURL_SOCKET_BAD;

View File

@ -238,7 +238,7 @@ static curl_socket_t socksconnect(unsigned short connectport,
} }
static curl_socket_t socks4(curl_socket_t fd, static curl_socket_t socks4(curl_socket_t fd,
unsigned char *buffer, const unsigned char *buffer,
ssize_t rc) ssize_t rc)
{ {
unsigned char response[256 + 16]; unsigned char response[256 + 16];
@ -299,7 +299,7 @@ static curl_socket_t sockit(curl_socket_t fd)
unsigned char len; unsigned char len;
unsigned char type; unsigned char type;
unsigned char rep = 0; unsigned char rep = 0;
unsigned char *address; const unsigned char *address;
unsigned short socksport; unsigned short socksport;
curl_socket_t connfd = CURL_SOCKET_BAD; curl_socket_t connfd = CURL_SOCKET_BAD;
unsigned short s5port; unsigned short s5port;
@ -502,7 +502,7 @@ static curl_socket_t sockit(curl_socket_t fd)
} }
if(!s_config.port) { if(!s_config.port) {
unsigned char *portp = &buffer[SOCKS5_DSTADDR + len]; const unsigned char *portp = &buffer[SOCKS5_DSTADDR + len];
s5port = (unsigned short)((portp[0] << 8) | (portp[1])); s5port = (unsigned short)((portp[0] << 8) | (portp[1]));
} }
else else
@ -726,7 +726,7 @@ static bool socksd_incoming(curl_socket_t listenfd)
return TRUE; return TRUE;
} }
static int test_socksd(int argc, char *argv[]) static int test_socksd(int argc, const char *argv[])
{ {
curl_socket_t sock = CURL_SOCKET_BAD; curl_socket_t sock = CURL_SOCKET_BAD;
curl_socket_t msgsock = CURL_SOCKET_BAD; curl_socket_t msgsock = CURL_SOCKET_BAD;

View File

@ -156,6 +156,33 @@ static const char *doc404 =
"<P><HR><ADDRESS>" SWSVERSION "</ADDRESS>\n" "<P><HR><ADDRESS>" SWSVERSION "</ADDRESS>\n"
"</BODY></HTML>\n"; "</BODY></HTML>\n";
/* This function returns a pointer to STATIC memory. It converts the given
* binary lump to a hex formatted string usable for output in logs or
* whatever.
*/
static char *data_to_hex(const char *data, size_t len)
{
static char buf[256 * 3];
size_t i;
char *optr = buf;
const char *iptr = data;
if(len > 255)
len = 255;
for(i = 0; i < len; i++) {
if((data[i] >= 0x20) && (data[i] < 0x7f))
*optr++ = *iptr++;
else {
snprintf(optr, 4, "%%%02x", (unsigned char)*iptr++);
optr += 3;
}
}
*optr = 0; /* in case no sprintf was used */
return buf;
}
/* work around for handling trailing headers */ /* work around for handling trailing headers */
static int already_recv_zeroed_chunk = FALSE; static int already_recv_zeroed_chunk = FALSE;
@ -303,7 +330,7 @@ static int sws_parse_servercmd(struct sws_httprequest *req)
static int sws_ProcessRequest(struct sws_httprequest *req) static int sws_ProcessRequest(struct sws_httprequest *req)
{ {
char *line = &req->reqbuf[req->checkindex]; const char *line = &req->reqbuf[req->checkindex];
bool chunked = FALSE; bool chunked = FALSE;
static char request[REQUEST_KEYWORD_SIZE]; static char request[REQUEST_KEYWORD_SIZE];
int prot_major = 0; int prot_major = 0;
@ -331,7 +358,7 @@ static int sws_ProcessRequest(struct sws_httprequest *req)
else if(req->testno == DOCNUMBER_NOTHING) { else if(req->testno == DOCNUMBER_NOTHING) {
const char *http; const char *http;
bool fine = FALSE; bool fine = FALSE;
char *httppath = NULL; const char *httppath = NULL;
size_t npath = 0; /* httppath length */ size_t npath = 0; /* httppath length */
if(sscanf(line, "%" REQUEST_KEYWORD_SIZE_TXT "s ", request) == 1) { if(sscanf(line, "%" REQUEST_KEYWORD_SIZE_TXT "s ", request) == 1) {
@ -357,7 +384,7 @@ static int sws_ProcessRequest(struct sws_httprequest *req)
} }
if(fine) { if(fine) {
char *ptr; const char *ptr;
req->prot_version = prot_major * 10 + prot_minor; req->prot_version = prot_major * 10 + prot_minor;
@ -476,7 +503,7 @@ static int sws_ProcessRequest(struct sws_httprequest *req)
sws_parse_servercmd(req); sws_parse_servercmd(req);
} }
else if((req->offset >= 3)) { else if((req->offset >= 3)) {
unsigned char *l = (unsigned char *)line; const unsigned char *l = (const unsigned char *)line;
logmsg("** Unusual request. Starts with %02x %02x %02x (%c%c%c)", logmsg("** Unusual request. Starts with %02x %02x %02x (%c%c%c)",
l[0], l[1], l[2], l[0], l[1], l[2]); l[0], l[1], l[2], l[0], l[1], l[2]);
} }
@ -1934,7 +1961,7 @@ static int service_connection(curl_socket_t *msgsock,
return -1; return -1;
} }
static int test_sws(int argc, char *argv[]) static int test_sws(int argc, const char *argv[])
{ {
srvr_sockaddr_union_t me; srvr_sockaddr_union_t me;
curl_socket_t sock = CURL_SOCKET_BAD; curl_socket_t sock = CURL_SOCKET_BAD;

View File

@ -111,14 +111,14 @@ struct tftphdr {
*****************************************************************************/ *****************************************************************************/
struct testcase { struct testcase {
char *buffer; /* holds the file data to send to the client */ char *buffer; /* holds the file data to send to the client */
size_t bufsize; /* size of the data in buffer */ size_t bufsize; /* size of the data in buffer */
char *rptr; /* read pointer into the buffer */ const char *rptr; /* read pointer into the buffer */
size_t rcount; /* amount of data left to read of the file */ size_t rcount; /* amount of data left to read of the file */
long testno; /* test case number */ long testno; /* test case number */
int ofile; /* file descriptor for output file when uploading to us */ int ofile; /* file descriptor for output file when uploading to us */
int writedelay; /* number of seconds between each packet */ int writedelay; /* number of seconds between each packet */
}; };
struct formats { struct formats {
@ -889,7 +889,8 @@ static int do_tftp(struct testcase *test, struct tftphdr *tp, ssize_t size)
char *cp; char *cp;
int first = 1, ecode; int first = 1, ecode;
const struct formats *pf; const struct formats *pf;
char *filename, *mode = NULL; const char *filename;
char *mode = NULL;
#ifdef USE_WINSOCK #ifdef USE_WINSOCK
DWORD recvtimeout, recvtimeoutbak; DWORD recvtimeout, recvtimeoutbak;
#endif #endif
@ -1004,7 +1005,7 @@ static int do_tftp(struct testcase *test, struct tftphdr *tp, ssize_t size)
return 0; return 0;
} }
static int test_tftpd(int argc, char **argv) static int test_tftpd(int argc, const char **argv)
{ {
srvr_sockaddr_union_t me; srvr_sockaddr_union_t me;
struct tftphdr *tp; struct tftphdr *tp;

View File

@ -33,38 +33,11 @@
#include <share.h> #include <share.h>
#endif #endif
/* This function returns a pointer to STATIC memory. It converts the given void loghex(const unsigned char *buffer, ssize_t len)
* binary lump to a hex formatted string usable for output in logs or
* whatever.
*/
char *data_to_hex(char *data, size_t len)
{
static char buf[256 * 3];
size_t i;
char *optr = buf;
char *iptr = data;
if(len > 255)
len = 255;
for(i = 0; i < len; i++) {
if((data[i] >= 0x20) && (data[i] < 0x7f))
*optr++ = *iptr++;
else {
snprintf(optr, 4, "%%%02x", (unsigned char)*iptr++);
optr += 3;
}
}
*optr = 0; /* in case no sprintf was used */
return buf;
}
void loghex(unsigned char *buffer, ssize_t len)
{ {
char data[12000]; char data[12000];
ssize_t i; ssize_t i;
unsigned char *ptr = buffer; const unsigned char *ptr = buffer;
char *optr = data; char *optr = data;
ssize_t width = 0; ssize_t width = 0;
int left = sizeof(data); int left = sizeof(data);

View File

@ -125,7 +125,7 @@ static CURLcode test_unit1302(const char *arg)
}; };
for(i = 0; i < CURL_ARRAYSIZE(encode); i++) { for(i = 0; i < CURL_ARRAYSIZE(encode); i++) {
struct etest *e = &encode[i]; const struct etest *e = &encode[i];
char *out; char *out;
unsigned char *decoded; unsigned char *decoded;
size_t olen; size_t olen;
@ -164,7 +164,7 @@ static CURLcode test_unit1302(const char *arg)
} }
for(i = 0; i < CURL_ARRAYSIZE(url); i++) { for(i = 0; i < CURL_ARRAYSIZE(url); i++) {
struct etest *e = &url[i]; const struct etest *e = &url[i];
char *out; char *out;
size_t olen; size_t olen;
result = curlx_base64url_encode((const uint8_t *)e->input, e->ilen, result = curlx_base64url_encode((const uint8_t *)e->input, e->ilen,

View File

@ -54,7 +54,8 @@ static CURLcode test_unit1600(const char *arg)
#if defined(USE_NTLM) && \ #if defined(USE_NTLM) && \
(!defined(USE_WINDOWS_SSPI) || defined(USE_WIN32_CRYPTO)) (!defined(USE_WINDOWS_SSPI) || defined(USE_WIN32_CRYPTO))
unsigned char output[21]; unsigned char output[21];
unsigned char *testp = output; const unsigned char *testp = output;
Curl_ntlm_core_mk_nt_hash("1", output); Curl_ntlm_core_mk_nt_hash("1", output);
verify_memory(testp, verify_memory(testp,

View File

@ -35,7 +35,7 @@ static CURLcode test_unit1601(const char *arg)
static const char string1[] = "1"; static const char string1[] = "1";
static const char string2[] = "hello-you-fool"; static const char string2[] = "hello-you-fool";
unsigned char output[MD5_DIGEST_LEN]; unsigned char output[MD5_DIGEST_LEN];
unsigned char *testp = output; const unsigned char *testp = output;
Curl_md5it(output, (const unsigned char *)string1, strlen(string1)); Curl_md5it(output, (const unsigned char *)string1, strlen(string1));

View File

@ -66,7 +66,7 @@ static CURLcode test_unit1603(const char *arg)
char key3[] = "key3"; char key3[] = "key3";
char key4[] = "key4"; char key4[] = "key4";
char notakey[] = "notakey"; char notakey[] = "notakey";
char *nodep; const char *nodep;
int rc; int rc;
/* Ensure the key hashes are as expected in order to test both hash /* Ensure the key hashes are as expected in order to test both hash

Some files were not shown because too many files have changed in this diff Show More