build: use more `const`
No binary (build failed)
—
(log yok)
| @@ -131,7 +131,7 @@ int main(void) | |
| /* !checksrc! disable EQUALSNULL 1 */ | |
| while((msg = curl_multi_info_read(multi, &msgs_left)) != NULL) { | |
| if(msg->msg == CURLMSG_DONE) { | |
| - | char *url; |
| + | const char *url; |
| CURL *curl = msg->easy_handle; | |
| curl_easy_getinfo(curl, CURLINFO_PRIVATE, &url); | |
| fprintf(stderr, "R: %d - %s <%s>\n", | |
| @@ -88,15 +88,15 @@ static size_t read_cb(char *ptr, size_t size, size_t nmemb, void *stream) | |
| return nread; | |
| } | |
| - | int main(int argc, char **argv) |
| + | int main(int argc, const char **argv) |
| { | |
| CURL *curl; | |
| CURLcode result; | |
| FILE *fp; | |
| struct stat file_info; | |
| - | char *file; |
| - | char *url; |
| + | const char *file; |
| + | const char *url; |
| if(argc < 3) | |
| return 1; | |
| @@ -191,8 +191,8 @@ static int ip_match(struct ip *ip, void *netaddr) | |
| int bytes, tailbits; | |
| const unsigned char *x, *y; | |
| - | x = (unsigned char *)&ip->netaddr; |
| - | y = (unsigned char *)netaddr; |
| + | x = (const unsigned char *)&ip->netaddr; |
| + | y = (const unsigned char *)netaddr; |
| for(bytes = ip->maskbits / 8; bytes; --bytes) { | |
| if(*x++ != *y++) | |
| @@ -214,7 +214,7 @@ static int is_ipv4_mapped_ipv6_address(int family, void *netaddr) | |
| { | |
| if(family == AF_INET6) { | |
| int i; | |
| - | unsigned char *x = (unsigned char *)netaddr; |
| + | const unsigned char *x = (const unsigned char *)netaddr; |
| for(i = 0; i < 12; ++i) { | |
| if(x[i]) | |
| break; | |
| @@ -66,13 +66,13 @@ static size_t write_cb(void *ptr, size_t size, size_t nmemb, void *data) | |
| return (size_t)(size * nmemb); | |
| } | |
| - | int main(int argc, char *argv[]) |
| + | int main(int argc, const char *argv[]) |
| { | |
| CURL *curl; | |
| CURLcode result; | |
| int prtall = 0, prtsep = 0, prttime = 0; | |
| const char *url = URL_1M; | |
| - | char *appname = argv[0]; |
| + | const char *appname = argv[0]; |
| if(argc > 1) { | |
| /* parse input parameters */ | |
| @@ -97,7 +97,7 @@ static size_t write_cb(char *buff, size_t size, size_t nmemb, void *cb_data) | |
| return written; | |
| } | |
| - | int main(int argc, char **argv) |
| + | int main(int argc, const char **argv) |
| { | |
| /* curl easy handle */ | |
| CURL *curl; | |
| @@ -43,7 +43,7 @@ int main(void) | |
| result = curl_easy_perform(curl); | |
| if(CURLE_OK == result) { | |
| - | char *ct; |
| + | const char *ct; |
| /* ask for the content-type */ | |
| result = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct); | |
| @@ -33,8 +33,6 @@ int main(void) | |
| { | |
| CURL *curl; | |
| CURLcode result; | |
| - | char *location; |
| - | long response_code; |
| result = curl_global_init(CURL_GLOBAL_ALL); | |
| if(result) | |
| @@ -53,12 +51,14 @@ int main(void) | |
| fprintf(stderr, "curl_easy_perform() failed: %s\n", | |
| curl_easy_strerror(result)); | |
| else { | |
| + | long response_code; |
| result = curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code); | |
| if((result == CURLE_OK) && ((response_code / 100) != 3)) { | |
| /* a redirect implies a 3xx response code */ | |
| fprintf(stderr, "Not a redirect.\n"); | |
| } | |
| else { | |
| + | const char *location; |
| result = curl_easy_getinfo(curl, CURLINFO_REDIRECT_URL, &location); | |
| if((result == CURLE_OK) && location) { | |
| @@ -49,7 +49,7 @@ int main(void) | |
| fprintf(stderr, "curl_easy_perform() failed: %s\n", | |
| curl_easy_strerror(result)); | |
| else { | |
| - | char *hdr; |
| + | const char *hdr; |
| result = curl_easy_getinfo(curl, CURLINFO_REFERER, &hdr); | |
| if((result == CURLE_OK) && hdr) | |
| printf("Referrer header: %s\n", hdr); | |
| @@ -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; | |
| char curl_errbuf[CURL_ERROR_SIZE]; | |
| @@ -250,7 +250,7 @@ static void parseHtml(const std::string &html, | |
| title = context.title; | |
| } | |
| - | int main(int argc, char *argv[]) |
| + | int main(int argc, const char *argv[]) |
| { | |
| CURL *curl = NULL; | |
| CURLcode result; | |
| @@ -187,7 +187,7 @@ static int setup(struct transfer *t, int num) | |
| /* | |
| * 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; | |
| struct transfer *trans; | |
| @@ -93,7 +93,7 @@ static int server_push_callback(CURL *parent, | |
| struct curl_pushheaders *headers, | |
| void *userp) | |
| { | |
| - | char *headp; |
| + | const char *headp; |
| int *transfers = (int *)userp; | |
| (void)parent; | |
| (void)num_headers; | |
| @@ -172,7 +172,7 @@ static int server_push_callback(CURL *parent, | |
| struct curl_pushheaders *headers, | |
| void *userp) | |
| { | |
| - | char *headp; |
| + | const char *headp; |
| size_t i; | |
| int *transfers = (int *)userp; | |
| 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. | |
| */ | |
| - | int main(int argc, char *argv[]) |
| + | int main(int argc, const char *argv[]) |
| { | |
| CURLcode result; | |
| CURL *curl; | |
| @@ -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! | |
| */ | |
| - | int main(int argc, char **argv) |
| + | int main(int argc, const char **argv) |
| { | |
| CURLcode result; | |
| struct input *trans; | |
| @@ -47,11 +47,11 @@ static const char olivertwist[] = | |
| * CURLOPT_POSTFIELDS to the URL given as an argument. | |
| */ | |
| - | int main(int argc, char **argv) |
| + | int main(int argc, const char **argv) |
| { | |
| CURL *curl; | |
| CURLcode result; | |
| - | char *url; |
| + | const char *url; |
| if(argc < 2) | |
| return 1; | |
| @@ -73,15 +73,15 @@ static size_t read_cb(char *ptr, size_t size, size_t nmemb, void *stream) | |
| return retcode; | |
| } | |
| - | int main(int argc, char **argv) |
| + | int main(int argc, const char **argv) |
| { | |
| CURL *curl; | |
| CURLcode result; | |
| FILE *hd_src; | |
| struct stat file_info; | |
| - | char *file; |
| - | char *url; |
| + | const char *file; |
| + | const char *url; |
| if(argc < 3) | |
| return 1; | |
| @@ -213,7 +213,7 @@ static int handle_socket(CURL *curl, curl_socket_t s, int action, void *userp, | |
| return 0; | |
| } | |
| - | int main(int argc, char **argv) |
| + | int main(int argc, const char **argv) |
| { | |
| CURLcode result; | |
| @@ -227,7 +227,7 @@ static int cb_socket(CURL *curl, curl_socket_t s, int action, | |
| return 0; | |
| } | |
| - | int main(int argc, char **argv) |
| + | int main(int argc, const char **argv) |
| { | |
| CURLcode result; | |
| struct datauv uv = { 0 }; | |
| @@ -45,7 +45,7 @@ | |
| #include <curl/curl.h> | |
| - | int main(int argc, char *argv[]) |
| + | int main(int argc, const char *argv[]) |
| { | |
| CURL *curl; | |
| CURLcode result; | |
| @@ -42,7 +42,7 @@ | |
| #include <curl/curl.h> | |
| - | int main(int argc, char *argv[]) |
| + | int main(int argc, const char *argv[]) |
| { | |
| CURL *curl; | |
| @@ -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); | |
| } | |
| - | static void run_one(gchar *http, int j) |
| + | static void run_one(const gchar *http, int j) |
| { | |
| CURL *curl; | |
| @@ -94,6 +94,7 @@ static void *pull_one_url(void *NaN) | |
| /* protect the reading and increasing of 'j' with a mutex */ | |
| pthread_mutex_lock(&lock); | |
| while(j < num_urls) { | |
| + | gchar *http; |
| int i = j; | |
| j++; | |
| pthread_mutex_unlock(&lock); | |
| @@ -165,7 +166,7 @@ static gboolean cb_delete(GtkWidget *window, gpointer data) | |
| return FALSE; | |
| } | |
| - | int main(int argc, char **argv) |
| + | int main(int argc, const char **argv) |
| { | |
| GtkWidget *top_window, *outside_frame, *inside_frame, *progress_bar; | |
| @@ -40,7 +40,7 @@ | |
| * **** 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"; | |
| CURLsslset result; | |
| @@ -126,7 +126,7 @@ static size_t SyncTime_CURL_WriteHeader(void *ptr, size_t size, size_t nmemb, | |
| if(ShowAllHeader == 1) | |
| 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) | |
| 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." | |
| " Server Date is no longer valid.\n"); | |
| AutoSyncTime = 0; | |
| @@ -226,7 +226,7 @@ static void showUsage(void) | |
| return; | |
| } | |
| - | int main(int argc, char *argv[]) |
| + | int main(int argc, const char *argv[]) |
| { | |
| CURLcode result; | |
| CURL *curl; | |
| @@ -42,7 +42,7 @@ static size_t write_cb(void *ptr, size_t size, size_t nmemb, void *stream) | |
| return written; | |
| } | |
| - | int main(int argc, char *argv[]) |
| + | int main(int argc, const char *argv[]) |
| { | |
| static const char *pagefilename = "page.out"; | |
| @@ -241,7 +241,7 @@ static CURLcode send_CONNECT(struct Curl_cfilter *cf, | |
| struct h1_tunnel_state *ts, | |
| 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 blen = request_len; | |
| CURLcode result = CURLE_OK; | |
| @@ -262,7 +262,7 @@ static CURLcode send_CONNECT(struct Curl_cfilter *cf, | |
| DEBUGASSERT(blen >= nwritten); | |
| ts->nsent += nwritten; | |
| - | Curl_debug(data, CURLINFO_HEADER_OUT, (char *)buf, nwritten); |
| + | Curl_debug(data, CURLINFO_HEADER_OUT, (const char *)buf, nwritten); |
| out: | |
| if(result) | |
| @@ -353,9 +353,9 @@ static CURLcode single_header(struct Curl_cfilter *cf, | |
| struct h1_tunnel_state *ts) | |
| { | |
| 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 */ | |
| - | struct SingleRequest *k = &data->req; |
| + | const struct SingleRequest *k = &data->req; |
| int writetype; | |
| ts->headerlines++; | |
| @@ -531,7 +531,7 @@ static CURLcode recv_CONNECT_resp(struct Curl_cfilter *cf, | |
| if(byte != 0x0a) | |
| continue; | |
| else { | |
| - | char *linep = curlx_dyn_ptr(&ts->rcvbuf); |
| + | const char *linep = curlx_dyn_ptr(&ts->rcvbuf); |
| size_t hlen = curlx_dyn_len(&ts->rcvbuf); | |
| if(hlen && ISNEWLINE(linep[0])) { | |
| /* end of headers */ | |
| @@ -41,7 +41,7 @@ CURLcode Curl_get_line(struct dynbuf *buf, FILE *input, bool *eof) | |
| curlx_dyn_reset(buf); | |
| while(1) { | |
| size_t rlen; | |
| - | char *b = fgets(buffer, sizeof(buffer), input); |
| + | const char *b = fgets(buffer, sizeof(buffer), input); |
| *eof = feof(input); | |
| @@ -551,9 +551,9 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_hash(const char *user, size_t userlen, | |
| * | |
| * Returns CURLE_OK on success. | |
| */ | |
| - | CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash, |
| - | unsigned char *challenge_client, |
| - | struct ntlmdata *ntlm, |
| + | CURLcode Curl_ntlm_core_mk_ntlmv2_resp(const unsigned char *ntlmv2hash, |
| + | const unsigned char *challenge_client, |
| + | const struct ntlmdata *ntlm, |
| unsigned char **ntresp, | |
| unsigned int *ntresp_len) | |
| { | |
| @@ -644,9 +644,9 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash, | |
| * | |
| * Returns CURLE_OK on success. | |
| */ | |
| - | CURLcode Curl_ntlm_core_mk_lmv2_resp(unsigned char *ntlmv2hash, |
| - | unsigned char *challenge_client, |
| - | unsigned char *challenge_server, |
| + | CURLcode Curl_ntlm_core_mk_lmv2_resp(const unsigned char *ntlmv2hash, |
| + | const unsigned char *challenge_client, |
| + | const unsigned char *challenge_server, |
| unsigned char *lmresp) | |
| { | |
| unsigned char data[16]; | |
| @@ -55,15 +55,15 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_hash(const char *user, size_t userlen, | |
| unsigned char *ntlmhash, | |
| unsigned char *ntlmv2hash); | |
| - | CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash, |
| - | unsigned char *challenge_client, |
| - | struct ntlmdata *ntlm, |
| + | CURLcode Curl_ntlm_core_mk_ntlmv2_resp(const unsigned char *ntlmv2hash, |
| + | const unsigned char *challenge_client, |
| + | const struct ntlmdata *ntlm, |
| unsigned char **ntresp, | |
| unsigned int *ntresp_len); | |
| - | CURLcode Curl_ntlm_core_mk_lmv2_resp(unsigned char *ntlmv2hash, |
| - | unsigned char *challenge_client, |
| - | unsigned char *challenge_server, |
| + | CURLcode Curl_ntlm_core_mk_lmv2_resp(const unsigned char *ntlmv2hash, |
| + | const unsigned char *challenge_client, |
| + | const unsigned char *challenge_server, |
| unsigned char *lmresp); | |
| #endif /* !USE_WINDOWS_SSPI */ | |
| @@ -227,13 +227,14 @@ static CURLcode get_server_message(struct SASL *sasl, struct Curl_easy *data, | |
| result = sasl->params->getmessage(data, out); | |
| if(!result && (sasl->params->flags & SASL_FLAG_BASE64)) { | |
| - | unsigned char *msg; |
| - | size_t msglen; |
| const char *serverdata = Curl_bufref_ptr(out); | |
| if(!*serverdata || *serverdata == '=') | |
| Curl_bufref_set(out, NULL, 0, NULL); | |
| else { | |
| + | unsigned char *msg; |
| + | size_t msglen; |
| + | |
| result = curlx_base64_decode(serverdata, &msg, &msglen); | |
| if(!result) | |
| Curl_bufref_set(out, msg, msglen, curl_free); | |
| @@ -292,7 +292,7 @@ const char *curlx_strerror(int err, char *buf, size_t buflen) | |
| */ | |
| { | |
| char buffer[256]; | |
| - | char *msg = strerror_r(err, buffer, sizeof(buffer)); |
| + | const char *msg = strerror_r(err, buffer, sizeof(buffer)); |
| if(msg && buflen > 1) | |
| SNPRINTF(buf, buflen, "%s", msg); | |
| else if(buflen > sizeof("Unknown error ") + 20) | |
| @@ -304,7 +304,7 @@ static CURLFORMcode FormAdd(struct curl_httppost **httppost, | |
| struct FormInfo *first_form, *curr, *form = NULL; | |
| CURLFORMcode retval = CURL_FORMADD_OK; | |
| CURLformoption option; | |
| - | struct curl_forms *forms = NULL; |
| + | const struct curl_forms *forms = NULL; |
| char *avalue = NULL; | |
| struct curl_httppost *newchain = NULL; | |
| struct curl_httppost *lastnode = NULL; | |
| @@ -886,7 +886,7 @@ static CURLcode ftp_state_use_port(struct Curl_easy *data, | |
| char myhost[MAX_IPADR_LEN + 1] = ""; | |
| struct Curl_sockaddr_storage ss; | |
| - | struct Curl_addrinfo *res, *ai; |
| + | const struct Curl_addrinfo *res, *ai; |
| curl_socklen_t sslen; | |
| char hbuf[NI_MAXHOST]; | |
| struct sockaddr *sa = (struct sockaddr *)&ss; | |
| @@ -896,15 +896,15 @@ static CURLcode ftp_state_use_port(struct Curl_easy *data, | |
| #endif | |
| static const char mode[][5] = { "EPRT", "PORT" }; | |
| int error; | |
| - | char *host = NULL; |
| - | char *string_ftpport = data->set.str[STRING_FTPPORT]; |
| + | const char *host = NULL; |
| + | const char *string_ftpport = data->set.str[STRING_FTPPORT]; |
| struct Curl_dns_entry *dns_entry = NULL; | |
| unsigned short port_min = 0; | |
| unsigned short port_max = 0; | |
| unsigned short port; | |
| bool possibly_non_local = TRUE; | |
| char buffer[STRERROR_LEN]; | |
| - | char *addr = NULL; |
| + | const char *addr = NULL; |
| size_t addrlen = 0; | |
| char ipstr[50]; | |
| @@ -920,7 +920,7 @@ static CURLcode ftp_state_use_port(struct Curl_easy *data, | |
| #ifdef USE_IPV6 | |
| if(*string_ftpport == '[') { | |
| /* [ipv6]:port(-range) */ | |
| - | char *ip_start = string_ftpport + 1; |
| + | const char *ip_start = string_ftpport + 1; |
| ip_end = strchr(ip_start, ']'); | |
| if(ip_end) { | |
| addrlen = ip_end - ip_start; | |
| @@ -1214,7 +1214,7 @@ static CURLcode ftp_state_use_port(struct Curl_easy *data, | |
| if(PORT == fcmd) { | |
| /* large enough for [IP address],[num],[num] */ | |
| char target[sizeof(myhost) + 20]; | |
| - | char *source = myhost; |
| + | const char *source = myhost; |
| char *dest = target; | |
| /* translate x.x.x.x to x,x,x,x */ | |
| @@ -1766,7 +1766,7 @@ static CURLcode ftp_state_quote(struct Curl_easy *data, | |
| i++; | |
| } | |
| if(item) { | |
| - | char *cmd = item->data; |
| + | const char *cmd = item->data; |
| if(cmd[0] == '*') { | |
| cmd++; | |
| 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; | |
| struct Curl_dns_entry *dns = NULL; | |
| unsigned short connectport; /* the local port connect() should use! */ | |
| - | struct pingpong *pp = &ftpc->pp; |
| + | const struct pingpong *pp = &ftpc->pp; |
| char *newhost = NULL; | |
| 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) && | |
| (ftpcode == 229)) { | |
| /* 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 */ | |
| int year, month, day, hour, minute, second; | |
| 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; | |
| if(ftp_213_date(resp, &year, &month, &day, &hour, &minute, &second)) { | |
| /* we have a time, reformat it */ | |
| @@ -2561,7 +2561,7 @@ static CURLcode ftp_state_size_resp(struct Curl_easy *data, | |
| { | |
| CURLcode result = CURLE_OK; | |
| 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; | |
| /* 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 | |
| for all the digits at the end of the response and parse only those as a | |
| number. */ | |
| - | char *start = &buf[4]; |
| + | const char *start = &buf[4]; |
| const char *fdigit = memchr(start, '\r', len - 4); | |
| if(fdigit) { | |
| fdigit--; | |
| @@ -2740,7 +2740,7 @@ static CURLcode ftp_state_get_resp(struct Curl_easy *data, | |
| size_t i; | |
| for(i = 0; i < len - 7; i++) { | |
| 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]; | |
| if(!curlx_str_number(&c, &what, CURL_OFF_T_MAX) && | |
| !curlx_str_single(&c, ' ') && | |
| @@ -2910,8 +2910,8 @@ static CURLcode ftp_pwd_resp(struct Curl_easy *data, | |
| CURLcode result; | |
| if(ftpcode == 257) { | |
| - | char *ptr = curlx_dyn_ptr(&pp->recvbuf) + 4; /* start on the first |
| - | letter */ |
| + | const char *ptr = curlx_dyn_ptr(&pp->recvbuf) + 4; /* start on the first |
| + | letter */ |
| bool entry_extracted = FALSE; | |
| struct dynbuf out; | |
| curlx_dyn_init(&out, 1000); | |
| @@ -3183,10 +3183,10 @@ static CURLcode ftp_pp_statemachine(struct Curl_easy *data, | |
| case FTP_SYST: | |
| if(ftpcode == 215) { | |
| - | char *ptr = curlx_dyn_ptr(&pp->recvbuf) + 4; /* start on the first |
| - | letter */ |
| + | const char *ptr = curlx_dyn_ptr(&pp->recvbuf) + 4; /* start on the first |
| + | letter */ |
| + | const char *start; |
| char *os; | |
| - | char *start; |
| /* Reply format is like | |
| 215<space><OS-name><space><commentary> | |
| @@ -3453,7 +3453,7 @@ static CURLcode ftp_sendquote(struct Curl_easy *data, | |
| while(item) { | |
| if(item->data) { | |
| size_t nread; | |
| - | char *cmd = item->data; |
| + | const char *cmd = item->data; |
| bool acceptfail = FALSE; | |
| CURLcode result; | |
| int ftpcode = 0; | |
| @@ -127,7 +127,7 @@ static CURLcode getinfo_char(struct Curl_easy *data, CURLINFO info, | |
| *param_charp = data->info.contenttype; | |
| break; | |
| case CURLINFO_PRIVATE: | |
| - | *param_charp = (char *)data->set.private_data; |
| + | *param_charp = (const char *)data->set.private_data; |
| break; | |
| case CURLINFO_FTP_ENTRY_PATH: | |
| /* Return the entrypath string from the most recent connection. | |
| @@ -63,8 +63,8 @@ static CURLcode gopher_do(struct Curl_easy *data, bool *done) | |
| struct connectdata *conn = data->conn; | |
| curl_socket_t sockfd = conn->sock[FIRSTSOCKET]; | |
| char *gopherpath; | |
| - | char *path = data->state.up.path; |
| - | char *query = data->state.up.query; |
| + | const char *path = data->state.up.path; |
| + | const char *query = data->state.up.query; |
| const char *buf = NULL; | |
| char *buf_alloc = NULL; | |
| size_t nwritten, buf_len; | |
| @@ -91,7 +91,7 @@ static CURLcode gopher_do(struct Curl_easy *data, bool *done) | |
| curlx_free(gopherpath); | |
| } | |
| else { | |
| - | char *newp; |
| + | const char *newp; |
| /* Otherwise, drop / and the first character (i.e., item type) ... */ | |
| newp = gopherpath; | |
| @@ -118,7 +118,7 @@ | |
| static void show_resolve_info(struct Curl_easy *data, | |
| struct Curl_dns_entry *dns) | |
| { | |
| - | struct Curl_addrinfo *a; |
| + | const struct Curl_addrinfo *a; |
| CURLcode result = CURLE_OK; | |
| #ifdef CURLRES_IPV6 | |
| struct dynbuf out[2]; | |
| @@ -4343,7 +4343,7 @@ static CURLcode http_rw_hd(struct Curl_easy *data, | |
| void Curl_http_to_fold(struct dynbuf *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')) | |
| len--; | |
| if(len && (hd[len - 1] == '\r')) | |
| @@ -4397,7 +4397,7 @@ static CURLcode http_parse_headers(struct Curl_easy *data, | |
| while(blen && k->header) { | |
| size_t consumed; | |
| size_t hlen; | |
| - | char *hd; |
| + | const char *hd; |
| size_t unfold_len = 0; | |
| if(data->state.leading_unfold) { | |
| @@ -732,7 +732,7 @@ UNITTEST CURLcode canon_query(const char *query, struct dynbuf *dq) | |
| size_t in_key_len; | |
| const char *offset; | |
| 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; | |
| @@ -788,8 +788,8 @@ UNITTEST CURLcode canon_query(const char *query, struct dynbuf *dq) | |
| if(index) | |
| result = curlx_dyn_addn(dq, "&", 1); | |
| if(!result) { | |
| - | char *key_ptr = curlx_dyn_ptr(&encoded_query_array[index].key); |
| - | char *value_ptr = curlx_dyn_ptr(&encoded_query_array[index].value); |
| + | const char *key_ptr = curlx_dyn_ptr(&encoded_query_array[index].key); |
| + | const char *value_ptr = curlx_dyn_ptr(&encoded_query_array[index].value); |
| size_t vlen = curlx_dyn_len(&encoded_query_array[index].value); | |
| if(value_ptr && vlen) { | |
| result = curlx_dyn_addf(dq, "%s=%s", key_ptr, value_ptr); | |
| @@ -242,7 +242,7 @@ static CURLcode httpchunk_readwrite(struct Curl_easy *data, | |
| case CHUNK_TRAILER: | |
| 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 | |
| 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) { | |
| /* only add correctly formatted trailers */ | |
| - | char *ptr = strchr(tr->data, ':'); |
| + | const char *ptr = strchr(tr->data, ':'); |
| if(!ptr || *(ptr + 1) != ' ') { | |
| infof(data, "Malformatted trailing header, skipping trailer"); | |
| continue; | |
| @@ -1220,7 +1220,7 @@ static CURLcode imap_state_listsearch_resp(struct Curl_easy *data, | |
| imapstate instate) | |
| { | |
| 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; | |
| struct IMAP *imap = Curl_meta_get(data, CURL_META_IMAP_EASY); | |
| @@ -338,7 +338,7 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done) | |
| ldap_set_option(server, LDAP_OPT_SSL, LDAP_OPT_ON); | |
| #else /* !USE_WIN32_LDAP */ | |
| int ldap_option; | |
| - | char *ldap_ca = conn->ssl_config.CAfile; |
| + | const char *ldap_ca = conn->ssl_config.CAfile; |
| #ifdef LDAP_OPT_X_TLS | |
| if(conn->ssl_config.verifypeer) { | |
| /* OpenLDAP SDK supports BASE64 files. */ | |
| @@ -1204,7 +1204,7 @@ curl_mime *curl_mime_init(void *easy) | |
| /* Initialize a mime 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. */ | |
| mimesetstate(&part->state, MIMESTATE_BEGIN, NULL); | |
| } | |
| @@ -403,7 +403,7 @@ static CURLcode mqtt_verify_connack(struct Curl_easy *data) | |
| { | |
| struct MQTT *mq = Curl_meta_get(data, CURL_META_MQTT_EASY); | |
| CURLcode result; | |
| - | char *ptr; |
| + | const char *ptr; |
| DEBUGASSERT(mq); | |
| if(!mq) | |
| @@ -433,7 +433,7 @@ fail: | |
| static CURLcode mqtt_get_topic(struct Curl_easy *data, | |
| char **topic, size_t *topiclen) | |
| { | |
| - | char *path = data->state.up.path; |
| + | const char *path = data->state.up.path; |
| CURLcode result = CURLE_URL_MALFORMAT; | |
| if(strlen(path) > 1) { | |
| 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 mqtt_conn *mqtt = Curl_conn_meta_get(conn, CURL_META_MQTT_CONN); | |
| CURLcode result; | |
| - | char *ptr; |
| + | const char *ptr; |
| if(!mqtt || !mq) | |
| return CURLE_FAILED_INIT; | |
| @@ -595,7 +595,8 @@ fail: | |
| } | |
| /* 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 mult = 1; | |
| @@ -337,7 +337,7 @@ static CURLcode oldap_perform_bind(struct Curl_easy *data, ldapstate newstate) | |
| { | |
| struct connectdata *conn = data->conn; | |
| struct ldapconninfo *li = Curl_conn_meta_get(conn, CURL_META_LDAP_CONN); | |
| - | char *binddn = NULL; |
| + | const char *binddn = NULL; |
| struct berval passwd; | |
| int rc; | |
| @@ -724,8 +724,9 @@ static CURLcode oldap_state_mechs_resp(struct Curl_easy *data, | |
| if(bvals) { | |
| for(i = 0; bvals[i].bv_val; i++) { | |
| size_t llen; | |
| - | unsigned short mech = Curl_sasl_decode_mech((char *)bvals[i].bv_val, |
| - | bvals[i].bv_len, &llen); |
| + | unsigned short mech = |
| + | Curl_sasl_decode_mech((const char *)bvals[i].bv_val, |
| + | bvals[i].bv_len, &llen); |
| if(bvals[i].bv_len == llen) | |
| li->sasl.authmechs |= mech; | |
| } | |
| @@ -1341,7 +1341,7 @@ static CURLcode smtp_state_command_resp(struct Curl_easy *data, | |
| smtpstate instate) | |
| { | |
| 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; | |
| (void)instate; | |
| @@ -837,7 +837,7 @@ static CURLproxycode socks5_resolving(struct socks_state *sx, | |
| struct Curl_dns_entry *dns = NULL; | |
| struct Curl_addrinfo *hp = NULL; | |
| char dest[MAX_IPADR_LEN]; /* printable address */ | |
| - | unsigned char *destination = NULL; |
| + | const unsigned char *destination = NULL; |
| unsigned char desttype = 1, destlen = 4; | |
| unsigned char req[2]; | |
| CURLcode result; | |
| @@ -896,7 +896,7 @@ static CURLproxycode socks5_resolving(struct socks_state *sx, | |
| desttype = 1; /* ATYP: IPv4 = 1 */ | |
| destlen = 4; | |
| 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)", | |
| dest, sx->remote_port); | |
| } | |
| @@ -906,7 +906,7 @@ static CURLproxycode socks5_resolving(struct socks_state *sx, | |
| desttype = 4; /* ATYP: IPv6 = 4 */ | |
| destlen = 16; | |
| 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)", | |
| dest, sx->remote_port); | |
| } | |
| @@ -317,7 +317,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, | |
| } | |
| 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_buffer(&gss_status, &gss_send_token); | |
| @@ -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 | |
| * 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) | |
| return !strcmp(a, b); | |
| @@ -35,7 +35,7 @@ char Curl_raw_tolower(char in); | |
| void Curl_strntoupper(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); | |
| #endif /* HEADER_CURL_STRCASE_H */ | |
| @@ -36,13 +36,13 @@ char *Curl_strdup(const char *str) | |
| char *newstr; | |
| if(!str) | |
| - | return (char *)NULL; |
| + | return NULL; |
| len = strlen(str) + 1; | |
| newstr = curlx_malloc(len); | |
| if(!newstr) | |
| - | return (char *)NULL; |
| + | return NULL; |
| memcpy(newstr, str, len); | |
| return newstr; | |
| @@ -496,9 +496,9 @@ static void rec_wont(struct Curl_easy *data, struct TELNET *tn, int option) | |
| } | |
| static void printsub(struct Curl_easy *data, | |
| - | int direction, /* '<' or '>' */ |
| - | unsigned char *pointer, /* where suboption data is */ |
| - | size_t length) /* length of suboption data */ |
| + | int direction, /* '<' or '>' */ |
| + | const unsigned char *pointer, /* ptr to suboption data */ |
| + | size_t length) /* suboption data length */ |
| { | |
| if(data->set.verbose) { | |
| unsigned int i = 0; | |
| @@ -611,10 +611,10 @@ static void printsub(struct Curl_easy *data, | |
| /* Escape and send a telnet data block */ | |
| static CURLcode send_telnet_data(struct Curl_easy *data, | |
| struct TELNET *tn, | |
| - | char *buffer, ssize_t nread) |
| + | const char *buffer, ssize_t nread) |
| { | |
| size_t i, outlen; | |
| - | unsigned char *outbuf; |
| + | const unsigned char *outbuf; |
| CURLcode result = CURLE_OK; | |
| size_t bytes_written; | |
| size_t total_written = 0; | |
| @@ -641,7 +641,7 @@ static CURLcode send_telnet_data(struct Curl_easy *data, | |
| } | |
| else { | |
| outlen = (size_t)nread; | |
| - | outbuf = (unsigned char *)buffer; |
| + | outbuf = (const unsigned char *)buffer; |
| } | |
| while(!result && total_written < outlen) { | |
| /* Make sure socket is writable to avoid EWOULDBLOCK condition */ | |
| @@ -676,7 +676,7 @@ static void sendsuboption(struct Curl_easy *data, | |
| ssize_t bytes_written; | |
| int err; | |
| unsigned short x, y; | |
| - | unsigned char *uc1, *uc2; |
| + | const unsigned char *uc1, *uc2; |
| struct connectdata *conn = data->conn; | |
| switch(option) { | |
| @@ -690,8 +690,8 @@ static void sendsuboption(struct Curl_easy *data, | |
| /* Window size must be sent according to the 'network order' */ | |
| x = htons(tn->subopt_wsx); | |
| y = htons(tn->subopt_wsy); | |
| - | uc1 = (unsigned char *)&x; |
| - | uc2 = (unsigned char *)&y; |
| + | uc1 = (const unsigned char *)&x; |
| + | uc2 = (const unsigned char *)&y; |
| CURL_SB_ACCUM(tn, uc1[0]); | |
| CURL_SB_ACCUM(tn, uc1[1]); | |
| CURL_SB_ACCUM(tn, uc2[0]); | |
| @@ -702,7 +702,7 @@ static void sendsuboption(struct Curl_easy *data, | |
| CURL_SB_TERM(tn); | |
| /* 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); | |
| /* 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 | |
| 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 */ | |
| bytes_written = swrite(conn->sock[FIRSTSOCKET], tn->subbuffer + 7, 2); | |
| 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 */ | |
| 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)) { | |
| case CURL_TELOPT_TTYPE: | |
| if(bad_option(tn->subopt_ttype)) | |
| @@ -1078,7 +1078,7 @@ static CURLcode tftp_receive_packet(struct Curl_easy *data, | |
| if(state->rbytes > 4 && | |
| (NEXT_BLOCKNUM(state->block) == getrpacketblock(&state->rpacket))) { | |
| result = Curl_client_write(data, CLIENTWRITE_BODY, | |
| - | (char *)state->rpacket.data + 4, |
| + | (const char *)state->rpacket.data + 4, |
| state->rbytes - 4); | |
| if(result) { | |
| tftp_state_machine(state, TFTP_EVENT_ERROR); | |
| @@ -1088,7 +1088,7 @@ static CURLcode tftp_receive_packet(struct Curl_easy *data, | |
| break; | |
| case TFTP_EVENT_ERROR: { | |
| 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; | |
| state->error = (tftp_error_t)error; | |
| if(tftp_strnlen(str, strn) < strn) | |
| @@ -1965,7 +1965,7 @@ static char *detect_proxy(struct Curl_easy *data, | |
| * that may exist registered to the same proxy host. | |
| */ | |
| static CURLcode parse_proxy(struct Curl_easy *data, | |
| - | struct connectdata *conn, char *proxy, |
| + | struct connectdata *conn, const char *proxy, |
| long proxytype) | |
| { | |
| char *portptr = NULL; | |
| @@ -2997,7 +2997,7 @@ static CURLcode parse_connect_to_slist(struct Curl_easy *data, | |
| #ifdef USE_UNIX_SOCKETS | |
| static CURLcode resolve_unix(struct Curl_easy *data, | |
| struct connectdata *conn, | |
| - | char *unix_path, |
| + | const char *unix_path, |
| struct Curl_dns_entry **pdns) | |
| { | |
| struct Curl_dns_entry *hostaddr; | |
| @@ -3047,7 +3047,7 @@ static CURLcode resolve_server(struct Curl_easy *data, | |
| #ifdef USE_UNIX_SOCKETS | |
| { | |
| - | char *unix_path = conn->unix_domain_socket; |
| + | const char *unix_path = conn->unix_domain_socket; |
| #ifndef CURL_DISABLE_PROXY | |
| if(!unix_path && CONN_IS_PROXIED(conn) && conn->socks_proxy.host.name && | |
| @@ -336,7 +336,7 @@ UNITTEST CURLUcode Curl_parse_port(struct Curl_URL *u, struct dynbuf *host, | |
| bool has_scheme) | |
| { | |
| 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. | |
| */ | |
| @@ -130,8 +130,9 @@ bool Curl_auth_digest_get_pair(const char *str, char *value, char *content, | |
| #ifndef USE_WINDOWS_SSPI | |
| /* Convert MD5 chunk to RFC2617 (section 3.1.3) -suitable ASCII string */ | |
| - | static void auth_digest_md5_to_ascii(unsigned char *source, /* 16 bytes */ |
| - | unsigned char *dest) /* 33 bytes */ |
| + | static void auth_digest_md5_to_ascii( |
| + | const unsigned char *source, /* 16 bytes */ |
| + | unsigned char *dest) /* 33 bytes */ |
| { | |
| int 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 */ | |
| - | static void auth_digest_sha256_to_ascii(unsigned char *source, /* 32 bytes */ |
| - | unsigned char *dest) /* 65 bytes */ |
| + | static void auth_digest_sha256_to_ascii( |
| + | const unsigned char *source, /* 32 bytes */ |
| + | unsigned char *dest) /* 65 bytes */ |
| { | |
| int i; | |
| for(i = 0; i < 32; i++) | |
| @@ -670,7 +672,7 @@ static CURLcode auth_create_digest_http_message( | |
| const unsigned char *uripath, | |
| struct digestdata *digest, | |
| 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 result; | |
| @@ -565,7 +565,7 @@ CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data, | |
| unsigned int ntrespoff; | |
| unsigned int ntresplen = 24; | |
| unsigned char ntresp[24]; /* fixed-size */ | |
| - | unsigned char *ptr_ntresp = &ntresp[0]; |
| + | const unsigned char *ptr_ntresp = &ntresp[0]; |
| unsigned char *ntlmv2resp = NULL; | |
| bool unicode = (ntlm->flags & NTLMFLAG_NEGOTIATE_UNICODE); | |
| /* The fixed hostname we provide, in order to not leak our real local host | |
| @@ -1367,7 +1367,7 @@ static int myssh_in_SFTP_QUOTE(struct Curl_easy *data, | |
| /* | |
| * Support some of the "FTP" commands | |
| */ | |
| - | char *cmd = sshc->quote_item->data; |
| + | const char *cmd = sshc->quote_item->data; |
| sshc->acceptfail = FALSE; | |
| /* 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, | |
| struct ssh_conn *sshc) | |
| { | |
| - | char *cmd = sshc->quote_item->data; |
| + | const char *cmd = sshc->quote_item->data; |
| sshc->acceptfail = FALSE; | |
| /* if a command starts with an asterisk, which a legal SFTP command never | |
| @@ -737,7 +737,7 @@ static CURLcode sftp_quote(struct Curl_easy *data, | |
| * 'sshc->quote_item' is already verified to be non-NULL before it | |
| * switched to this state. | |
| */ | |
| - | char *cmd = sshc->quote_item->data; |
| + | const char *cmd = sshc->quote_item->data; |
| sshc->acceptfail = FALSE; | |
| /* 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, | |
| bool *blockp) | |
| { | |
| - | char *cmd = sshc->quote_item->data; |
| + | const char *cmd = sshc->quote_item->data; |
| sshc->acceptfail = FALSE; | |
| /* if a command starts with an asterisk, which a legal SFTP command never | |
| @@ -125,7 +125,7 @@ void Curl_ssh_set_state(struct Curl_easy *data, | |
| /* figure out the path to work with in this particular request */ | |
| 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 | |
| real path to work with */ | |
| { | |
| @@ -28,7 +28,7 @@ | |
| #include "../urldata.h" | |
| CURLcode Curl_getworkingpath(struct Curl_easy *data, | |
| - | char *homedir, |
| + | const char *homedir, |
| char **path); | |
| CURLcode Curl_get_pathname(const char **cpp, char **path, const char *homedir); | |
| @@ -1058,7 +1058,7 @@ static size_t multissl_version(char *buffer, size_t size) | |
| if(current != selected) { | |
| char *p = backends; | |
| - | char *end = backends + sizeof(backends); |
| + | const char *end = backends + sizeof(backends); |
| int i; | |
| selected = current; | |
| @@ -1135,7 +1135,7 @@ CURLcode Curl_wssl_ctx_init(struct wssl_ctx *wctx, | |
| #ifndef WOLFSSL_TLS13 | |
| { | |
| - | char *ciphers = conn_config->cipher_list; |
| + | const char *ciphers = conn_config->cipher_list; |
| if(ciphers) { | |
| if(!SSL_CTX_set_cipher_list(wctx->ssl_ctx, ciphers)) { | |
| failf(data, "failed setting cipher list: %s", ciphers); | |
| @@ -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.3", "sha512" }, | |
| { "1.2.840.113549.1.9.2", "unstructuredName" }, | |
| - | { (const char *)NULL, (const char *)NULL } |
| + | { NULL, NULL } |
| }; | |
| #endif /* WANT_EXTRACT_CERTINFO */ | |
| @@ -932,7 +932,7 @@ static CURLcode ssl_push_certinfo_dyn(struct Curl_easy *data, | |
| struct dynbuf *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, | |
| value, valuelen); | |
| @@ -257,7 +257,7 @@ static const char *disabled[] = { | |
| #endif | |
| }; | |
| - | int main(int argc, char **argv) |
| + | int main(int argc, const char **argv) |
| { | |
| size_t i; | |
| @@ -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 */ | |
| CURLU *u = NULL; | |
| - | char *copyloc = NULL, *locurl = NULL, *scheme = NULL, *finalurl = NULL; |
| - | const char *loc = location; |
| + | char *copyloc = NULL, *scheme = NULL, *finalurl = NULL; |
| + | const char *loc = location, *locurl = NULL; |
| size_t llen = loclen; | |
| int space_skipped = 0; | |
| const char *vver = getenv("VTE_VERSION"); | |
| @@ -96,7 +96,7 @@ int SetHTTPrequest(HttpReq req, HttpReq *store) | |
| 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 */ | |
| const char *dflt[] = { | |
| @@ -27,6 +27,6 @@ | |
| const char *param2text(ParameterError error); | |
| 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 */ | |
| @@ -1753,7 +1753,7 @@ static CURLcode check_finished(struct parastate *s) | |
| struct per_transfer *ended; | |
| CURL *easy = msg->easy_handle; | |
| 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); | |
| if(ended->abort && (tres == CURLE_ABORTED_BY_CALLBACK)) { | |
| @@ -2022,7 +2022,7 @@ static CURLcode is_using_schannel(int *pusing) | |
| if(using_schannel == -1) { | |
| CURL *curltls = curl_easy_init(); | |
| /* 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) | |
| result = CURLE_OUT_OF_MEMORY; | |
| @@ -34,7 +34,7 @@ struct per_transfer { | |
| struct per_transfer *next; | |
| struct per_transfer *prev; | |
| struct OperationConfig *config; /* for this transfer */ | |
| - | struct curl_certinfo *certinfo; |
| + | const struct curl_certinfo *certinfo; |
| CURL *curl; | |
| long retry_remaining; | |
| long retry_sleep_default; | |
| @@ -277,7 +277,7 @@ static bool get_line(FILE *input, struct dynbuf *buf, bool *error) | |
| char buffer[128]; | |
| curlx_dyn_reset(buf); | |
| while(1) { | |
| - | char *b = fgets(buffer, sizeof(buffer), input); |
| + | const char *b = fgets(buffer, sizeof(buffer), input); |
| if(b) { | |
| size_t rlen = strlen(b); | |
| @@ -86,7 +86,7 @@ static int urlpart(struct per_transfer *per, writeoutid vid, | |
| if(uh) { | |
| CURLUPart cpart = CURLUPART_HOST; | |
| char *part = NULL; | |
| - | const char *url = NULL; |
| + | char *url = NULL; |
| if(vid >= VAR_INPUT_URLESCHEME) { | |
| 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) | |
| { | |
| if(!per->certinfo) { | |
| - | struct curl_certinfo *certinfo; |
| + | const struct curl_certinfo *certinfo; |
| CURLcode result = curl_easy_getinfo(per->curl, CURLINFO_CERTINFO, | |
| &certinfo); | |
| per->certinfo = (!result && certinfo) ? certinfo : NULL; | |
| @@ -24,7 +24,7 @@ | |
| #include "curl/curl.h" | |
| #include <stdio.h> | |
| - | int main(int argc, char **argv) |
| + | int main(int argc, const char **argv) |
| { | |
| (void)argc; | |
| puts("libcurl test:"); | |
| @@ -60,7 +60,7 @@ static int server_push_callback(CURL *parent, | |
| struct curl_pushheaders *headers, | |
| void *userp) | |
| { | |
| - | char *headp; |
| + | const char *headp; |
| size_t i; | |
| int *transfers = (int *)userp; | |
| char filename[128]; | |
| @@ -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, | |
| long http_version, struct curl_slist *host, | |
| 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_URL, url); | |
| @@ -41,8 +41,8 @@ static CURLcode test_lib1518(const char *URL) | |
| CURLcode result = CURLE_OK; | |
| long curlResponseCode; | |
| long curlRedirectCount; | |
| - | char *effectiveUrl = NULL; |
| - | char *redirectUrl = NULL; |
| + | const char *effectiveUrl = NULL; |
| + | const char *redirectUrl = NULL; |
| CURLU *urlu = NULL; | |
| curl = curl_easy_init(); | |
| if(!curl) { | |
| @@ -28,7 +28,7 @@ | |
| static CURLcode test_lib1536(const char *URL) | |
| { | |
| CURL *curl, *dupe = NULL; | |
| - | char *scheme; |
| + | const char *scheme; |
| CURLcode result = CURLE_OK; | |
| global_init(CURL_GLOBAL_ALL); | |
| @@ -1150,7 +1150,7 @@ static const struct setcase set_parts_list[] = { | |
| {NULL, NULL, NULL, 0, 0, CURLUE_OK, CURLUE_OK} | |
| }; | |
| - | static CURLUPart part2id(char *part) |
| + | static CURLUPart part2id(const char *part) |
| { | |
| if(!strcmp("url", part)) | |
| return CURLUPART_URL; | |
| @@ -29,7 +29,7 @@ static CURLcode test_lib1977(const char *URL) | |
| CURLU *curlu = curl_url(); | |
| CURLU *curlu_2 = curl_url(); | |
| CURL *curl; | |
| - | char *effective = NULL; |
| + | const char *effective = NULL; |
| global_init(CURL_GLOBAL_ALL); | |
| easy_init(curl); | |
| @@ -28,7 +28,7 @@ static CURLcode test_lib3010(const char *URL) | |
| CURLcode result = TEST_ERR_MAJOR_BAD; | |
| CURL *curl = NULL; | |
| curl_off_t retry_after; | |
| - | char *follow_url = NULL; |
| + | const char *follow_url = NULL; |
| curl_global_init(CURL_GLOBAL_ALL); | |
| curl = curl_easy_init(); | |
| @@ -29,7 +29,7 @@ | |
| */ | |
| static bool is_chain_in_order(struct curl_certinfo *cert_info) | |
| { | |
| - | char *last_issuer = NULL; |
| + | const char *last_issuer = NULL; |
| int cert; | |
| /* 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 */ | |
| for(cert = 0; cert < cert_info->num_of_certs; cert++) { | |
| struct curl_slist *slist = cert_info->certinfo[cert]; | |
| - | char *issuer = NULL; |
| - | char *subject = NULL; |
| + | const char *issuer = NULL; |
| + | const char *subject = NULL; |
| /* Find the certificate issuer and subject by enumerating each field */ | |
| for(; slist && (!issuer || !subject); slist = slist->next) { | |
| @@ -46,7 +46,7 @@ static size_t write_memory_callback(char *contents, size_t size, | |
| /* append the data to contents */ | |
| size_t realsize = size * nmemb; | |
| 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; | |
| if(!data) { | |
| curl_mprintf("not enough memory (malloc returned NULL)\n"); | |
| @@ -55,7 +55,7 @@ static CURLcode test_lib500(const char *URL) | |
| { | |
| CURLcode result; | |
| CURL *curl; | |
| - | char *ipstr = NULL; |
| + | const char *ipstr = NULL; |
| if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { | |
| curl_mfprintf(stderr, "curl_global_init() failed\n"); | |
| @@ -33,7 +33,6 @@ static CURLcode test_lib569(const char *URL) | |
| CURLcode result; | |
| CURL *curl; | |
| char *stream_uri = NULL; | |
| - | char *rtsp_session_id; |
| int request = 1; | |
| int i; | |
| @@ -74,6 +73,7 @@ static CURLcode test_lib569(const char *URL) | |
| /* Go through the various Session IDs */ | |
| for(i = 0; i < 3; i++) { | |
| + | const char *rtsp_session_id; |
| stream_uri = tutil_suburl(URL, request++); | |
| if(!stream_uri) { | |
| result = TEST_ERR_MAJOR_BAD; | |
| @@ -209,7 +209,7 @@ print $fh <<HEADER | |
| /* This source code is generated by mk-lib1521.pl ! */ | |
| struct t1521_testdata { | |
| - | char *blaha; |
| + | const char *blaha; |
| }; | |
| #define LO $minlong | |
| @@ -364,12 +364,12 @@ static CURLcode test_lib1521(const char *URL) | |
| FILE *stream = stderr; | |
| struct t1521_testdata object; | |
| CURLU *curlu = (CURLU *)&object; | |
| - | char *charp; |
| + | const char *charp; |
| long val; | |
| curl_off_t oval; | |
| double dval; | |
| curl_socket_t sockfd; | |
| - | struct curl_certinfo *certinfo; |
| + | const struct curl_certinfo *certinfo; |
| struct curl_tlssessioninfo *tlssession; | |
| struct curl_blob blob = { CURL_UNCONST("silly"), 5, 0}; | |
| CURLcode result = CURLE_OK; | |
| @@ -87,7 +87,7 @@ int libtest_debug_cb(CURL *curl, curl_infotype type, | |
| struct libtest_trace_cfg *trace_cfg = userp; | |
| const char *text; | |
| char timebuf[20]; | |
| - | char *timestr; |
| + | const char *timestr; |
| (void)curl; | |
| @@ -233,7 +233,7 @@ static unsigned char ancount_aaaa; | |
| /* this is an answer to a question */ | |
| static int send_response(curl_socket_t sock, | |
| 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) | |
| { | |
| ssize_t rc; | |
| @@ -378,7 +378,7 @@ static void read_instructions(void) | |
| 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; | |
| ssize_t n = 0; | |
| @@ -25,10 +25,10 @@ | |
| #include <stdio.h> | |
| - | int main(int argc, char **argv) |
| + | int main(int argc, const char **argv) |
| { | |
| entry_func_t entry_func; | |
| - | char *entry_name; |
| + | const char *entry_name; |
| size_t tmp; | |
| if(argc < 2) { | |
| @@ -39,7 +39,7 @@ | |
| #include "curl_setup.h" | |
| - | typedef int (*entry_func_t)(int, char **); |
| + | typedef int (*entry_func_t)(int, const char **); |
| struct entry_s { | |
| const char *name; | |
| @@ -125,9 +125,8 @@ extern int getpart(char **outbuf, size_t *outlen, | |
| const char *main, const char *sub, FILE *stream); | |
| /* utility functions */ | |
| - | extern char *data_to_hex(char *data, size_t len); |
| 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 FILE *test2fopen(long testno, const char *logdir2); | |
| extern curl_off_t our_getpid(void); | |
| @@ -141,12 +141,13 @@ static int readline(char **buffer, size_t *bufsize, size_t *length, | |
| * GPE_OUT_OF_MEMORY | |
| * GPE_OK | |
| */ | |
| - | static int appenddata(char **dst_buf, /* dest buffer */ |
| - | size_t *dst_len, /* dest buffer data length */ |
| - | size_t *dst_alloc, /* dest buffer allocated size */ |
| - | char *src_buf, /* source buffer */ |
| - | size_t src_len, /* source buffer length */ |
| - | int src_b64) /* != 0 if source is base64 encoded */ |
| + | static int appenddata(char **dst_buf, /* dest buffer */ |
| + | size_t *dst_len, /* dest buffer data length */ |
| + | size_t *dst_alloc, /* dest buffer allocated size */ |
| + | const char *src_buf, /* source buffer */ |
| + | size_t src_len, /* source buffer length */ |
| + | int src_b64) /* != 0 if source is base64 |
| + | encoded */ |
| { | |
| size_t need_alloc = 0; | |
| @@ -182,7 +183,7 @@ static int appenddata(char **dst_buf, /* dest buffer */ | |
| return GPE_OK; | |
| } | |
| - | static int decodedata(char **buf, /* dest buffer */ |
| + | static int decodedata(char **buf, /* dest buffer */ |
| size_t *len) /* dest buffer data length */ | |
| { | |
| CURLcode result = CURLE_OK; | |
| @@ -131,11 +131,11 @@ typedef enum { | |
| static void logprotocol(mqttdir dir, | |
| const char *prefix, size_t remlen, | |
| FILE *output, | |
| - | unsigned char *buffer, ssize_t len) |
| + | const unsigned char *buffer, ssize_t len) |
| { | |
| char data[12000] = ""; | |
| ssize_t i; | |
| - | unsigned char *ptr = buffer; |
| + | const unsigned char *ptr = buffer; |
| char *optr = data; | |
| int left = sizeof(data); | |
| @@ -279,7 +279,7 @@ static size_t encode_length(size_t packetlen, | |
| 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 len = 0; | |
| @@ -712,7 +712,7 @@ static bool mqttd_incoming(curl_socket_t listenfd) | |
| 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 msgsock = CURL_SOCKET_BAD; | |
| @@ -33,7 +33,7 @@ | |
| * | |
| */ | |
| - | static int test_resolve(int argc, char *argv[]) |
| + | static int test_resolve(int argc, const char *argv[]) |
| { | |
| int arg = 1; | |
| const char *host = NULL; | |
| @@ -143,7 +143,7 @@ static const char *RTP_DATA = "$_1234\n\0Rsdf"; | |
| static int rtspd_ProcessRequest(struct rtspd_httprequest *req) | |
| { | |
| - | char *line = &req->reqbuf[req->checkindex]; |
| + | const char *line = &req->reqbuf[req->checkindex]; |
| bool chunked = FALSE; | |
| static char request[REQUEST_KEYWORD_SIZE]; | |
| static char doc[MAXDOCNAMELEN]; | |
| @@ -539,7 +539,7 @@ static int rtspd_ProcessRequest(struct rtspd_httprequest *req) | |
| } | |
| /* 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 error = 0; | |
| @@ -997,7 +997,7 @@ static int rtspd_send_doc(curl_socket_t sock, struct rtspd_httprequest *req) | |
| return 0; | |
| } | |
| - | static int test_rtspd(int argc, char *argv[]) |
| + | static int test_rtspd(int argc, const char *argv[]) |
| { | |
| srvr_sockaddr_union_t me; | |
| curl_socket_t sock = CURL_SOCKET_BAD; | |
| @@ -313,11 +313,11 @@ static bool write_stdout(const void *buffer, size_t nbytes) | |
| return TRUE; | |
| } | |
| - | static void lograw(unsigned char *buffer, ssize_t len) |
| + | static void lograw(const unsigned char *buffer, ssize_t len) |
| { | |
| char data[120]; | |
| ssize_t i; | |
| - | unsigned char *ptr = buffer; |
| + | const unsigned char *ptr = buffer; |
| char *optr = data; | |
| ssize_t width = 0; | |
| int left = sizeof(data); | |
| @@ -372,7 +372,7 @@ static bool read_data_block(unsigned char *buffer, ssize_t maxlen, | |
| buffer[5] = '\0'; | |
| - | endp = (char *)buffer; |
| + | endp = (const char *)buffer; |
| if(curlx_str_hex(&endp, &value, 0xfffff)) { | |
| logmsg("Failed to decode buffer size"); | |
| return FALSE; | |
| @@ -1066,7 +1066,7 @@ static bool juggle(curl_socket_t *sockfdp, | |
| Replies to PORT with "IPv[num]/[port]" */ | |
| snprintf((char *)buffer, sizeof(buffer), "%s/%hu\n", | |
| 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); | |
| if(!write_stdout(data, 10)) | |
| return FALSE; | |
| @@ -1171,7 +1171,7 @@ static bool juggle(curl_socket_t *sockfdp, | |
| return TRUE; | |
| } | |
| - | static int test_sockfilt(int argc, char *argv[]) |
| + | static int test_sockfilt(int argc, const char *argv[]) |
| { | |
| srvr_sockaddr_union_t me; | |
| curl_socket_t sock = CURL_SOCKET_BAD; | |
| @@ -238,7 +238,7 @@ static curl_socket_t socksconnect(unsigned short connectport, | |
| } | |
| static curl_socket_t socks4(curl_socket_t fd, | |
| - | unsigned char *buffer, |
| + | const unsigned char *buffer, |
| ssize_t rc) | |
| { | |
| unsigned char response[256 + 16]; | |
| @@ -299,7 +299,7 @@ static curl_socket_t sockit(curl_socket_t fd) | |
| unsigned char len; | |
| unsigned char type; | |
| unsigned char rep = 0; | |
| - | unsigned char *address; |
| + | const unsigned char *address; |
| unsigned short socksport; | |
| curl_socket_t connfd = CURL_SOCKET_BAD; | |
| unsigned short s5port; | |
| @@ -502,7 +502,7 @@ static curl_socket_t sockit(curl_socket_t fd) | |
| } | |
| 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])); | |
| } | |
| else | |
| @@ -726,7 +726,7 @@ static bool socksd_incoming(curl_socket_t listenfd) | |
| 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 msgsock = CURL_SOCKET_BAD; | |
| @@ -156,6 +156,33 @@ static const char *doc404 = | |
| "<P><HR><ADDRESS>" SWSVERSION "</ADDRESS>\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 */ | |
| 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) | |
| { | |
| - | char *line = &req->reqbuf[req->checkindex]; |
| + | const char *line = &req->reqbuf[req->checkindex]; |
| bool chunked = FALSE; | |
| static char request[REQUEST_KEYWORD_SIZE]; | |
| int prot_major = 0; | |
| @@ -331,7 +358,7 @@ static int sws_ProcessRequest(struct sws_httprequest *req) | |
| else if(req->testno == DOCNUMBER_NOTHING) { | |
| const char *http; | |
| bool fine = FALSE; | |
| - | char *httppath = NULL; |
| + | const char *httppath = NULL; |
| size_t npath = 0; /* httppath length */ | |
| if(sscanf(line, "%" REQUEST_KEYWORD_SIZE_TXT "s ", request) == 1) { | |
| @@ -357,7 +384,7 @@ static int sws_ProcessRequest(struct sws_httprequest *req) | |
| } | |
| if(fine) { | |
| - | char *ptr; |
| + | const char *ptr; |
| req->prot_version = prot_major * 10 + prot_minor; | |
| @@ -476,7 +503,7 @@ static int sws_ProcessRequest(struct sws_httprequest *req) | |
| sws_parse_servercmd(req); | |
| } | |
| 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)", | |
| 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; | |
| } | |
| - | static int test_sws(int argc, char *argv[]) |
| + | static int test_sws(int argc, const char *argv[]) |
| { | |
| srvr_sockaddr_union_t me; | |
| curl_socket_t sock = CURL_SOCKET_BAD; | |
| @@ -111,14 +111,14 @@ struct tftphdr { | |
| *****************************************************************************/ | |
| struct testcase { | |
| - | char *buffer; /* holds the file data to send to the client */ |
| - | size_t bufsize; /* size of the data in buffer */ |
| - | char *rptr; /* read pointer into the buffer */ |
| - | size_t rcount; /* amount of data left to read of the file */ |
| - | long testno; /* test case number */ |
| - | int ofile; /* file descriptor for output file when uploading to us */ |
| - | |
| - | int writedelay; /* number of seconds between each packet */ |
| + | char *buffer; /* holds the file data to send to the client */ |
| + | size_t bufsize; /* size of the data in buffer */ |
| + | const char *rptr; /* read pointer into the buffer */ |
| + | size_t rcount; /* amount of data left to read of the file */ |
| + | long testno; /* test case number */ |
| + | int ofile; /* file descriptor for output file when uploading to us */ |
| + | |
| + | int writedelay; /* number of seconds between each packet */ |
| }; | |
| struct formats { | |
| @@ -889,7 +889,8 @@ static int do_tftp(struct testcase *test, struct tftphdr *tp, ssize_t size) | |
| char *cp; | |
| int first = 1, ecode; | |
| const struct formats *pf; | |
| - | char *filename, *mode = NULL; |
| + | const char *filename; |
| + | char *mode = NULL; |
| #ifdef USE_WINSOCK | |
| DWORD recvtimeout, recvtimeoutbak; | |
| #endif | |
| @@ -1004,7 +1005,7 @@ static int do_tftp(struct testcase *test, struct tftphdr *tp, ssize_t size) | |
| return 0; | |
| } | |
| - | static int test_tftpd(int argc, char **argv) |
| + | static int test_tftpd(int argc, const char **argv) |
| { | |
| srvr_sockaddr_union_t me; | |
| struct tftphdr *tp; | |
| @@ -33,38 +33,11 @@ | |
| #include <share.h> | |
| #endif | |
| - | /* 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. |
| - | */ |
| - | 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) |
| + | void loghex(const unsigned char *buffer, ssize_t len) |
| { | |
| char data[12000]; | |
| ssize_t i; | |
| - | unsigned char *ptr = buffer; |
| + | const unsigned char *ptr = buffer; |
| char *optr = data; | |
| ssize_t width = 0; | |
| int left = sizeof(data); | |
| @@ -125,7 +125,7 @@ static CURLcode test_unit1302(const char *arg) | |
| }; | |
| for(i = 0; i < CURL_ARRAYSIZE(encode); i++) { | |
| - | struct etest *e = &encode[i]; |
| + | const struct etest *e = &encode[i]; |
| char *out; | |
| unsigned char *decoded; | |
| size_t olen; | |
| @@ -164,7 +164,7 @@ static CURLcode test_unit1302(const char *arg) | |
| } | |
| for(i = 0; i < CURL_ARRAYSIZE(url); i++) { | |
| - | struct etest *e = &url[i]; |
| + | const struct etest *e = &url[i]; |
| char *out; | |
| size_t olen; | |
| result = curlx_base64url_encode((const uint8_t *)e->input, e->ilen, | |
| @@ -54,7 +54,8 @@ static CURLcode test_unit1600(const char *arg) | |
| #if defined(USE_NTLM) && \ | |
| (!defined(USE_WINDOWS_SSPI) || defined(USE_WIN32_CRYPTO)) | |
| unsigned char output[21]; | |
| - | unsigned char *testp = output; |
| + | const unsigned char *testp = output; |
| + | |
| Curl_ntlm_core_mk_nt_hash("1", output); | |
| verify_memory(testp, | |
| @@ -35,7 +35,7 @@ static CURLcode test_unit1601(const char *arg) | |
| static const char string1[] = "1"; | |
| static const char string2[] = "hello-you-fool"; | |
| unsigned char output[MD5_DIGEST_LEN]; | |
| - | unsigned char *testp = output; |
| + | const unsigned char *testp = output; |
| Curl_md5it(output, (const unsigned char *)string1, strlen(string1)); | |
| @@ -66,7 +66,7 @@ static CURLcode test_unit1603(const char *arg) | |
| char key3[] = "key3"; | |
| char key4[] = "key4"; | |
| char notakey[] = "notakey"; | |
| - | char *nodep; |
| + | const char *nodep; |
| int rc; | |
| /* Ensure the key hashes are as expected in order to test both hash | |
| @@ -42,7 +42,7 @@ static CURLcode test_unit1610(const char *arg) | |
| static const char string1[] = "1"; | |
| static const char string2[] = "hello-you-fool"; | |
| unsigned char output[CURL_SHA256_DIGEST_LENGTH]; | |
| - | unsigned char *testp = output; |
| + | const unsigned char *testp = output; |
| Curl_sha256it(output, (const unsigned char *)string1, strlen(string1)); | |
| @@ -33,7 +33,7 @@ static CURLcode test_unit1611(const char *arg) | |
| static const char string1[] = "1"; | |
| static const char string2[] = "hello-you-fool"; | |
| unsigned char output[MD4_DIGEST_LENGTH]; | |
| - | unsigned char *testp = output; |
| + | const unsigned char *testp = output; |
| Curl_md4it(output, (const unsigned char *)string1, strlen(string1)); | |
| @@ -37,7 +37,7 @@ static CURLcode test_unit1612(const char *arg) | |
| static const char string1[] = "1"; | |
| static const char string2[] = "hello-you-fool"; | |
| unsigned char output[HMAC_MD5_LENGTH]; | |
| - | unsigned char *testp = output; |
| + | const unsigned char *testp = output; |
| Curl_hmacit(&Curl_HMAC_MD5, | |
| (const unsigned char *)password, strlen(password), | |
| @@ -109,7 +109,7 @@ static CURLcode test_unit1615(const char *arg) | |
| }; | |
| unsigned char output_buf[CURL_SHA512_256_DIGEST_LENGTH]; | |
| - | unsigned char *computed_hash; /* Just to mute compiler warning */ |
| + | const unsigned char *computed_hash; /* Just to mute compiler warning */ |
| /* Mute compiler warnings in 'verify_memory' macros below */ | |
| computed_hash = output_buf; | |
| @@ -224,10 +224,11 @@ static CURLcode test_unit1650(const char *arg) | |
| ptr += o; | |
| } | |
| de_cleanup(&d); | |
| - | if(resp[i].out && strcmp((char *)buffer, resp[i].out)) { |
| + | if(resp[i].out && strcmp((const char *)buffer, resp[i].out)) { |
| curl_mfprintf(stderr, "resp %zu: Expected %s got %s\n", i, | |
| resp[i].out, buffer); | |
| - | abort_if(resp[i].out && strcmp((char *)buffer, resp[i].out), "content"); |
| + | abort_if(resp[i].out && strcmp((const char *)buffer, resp[i].out), |
| + | "content"); |
| } | |
| } | |
| @@ -271,9 +272,9 @@ static CURLcode test_unit1650(const char *arg) | |
| p = &a->ip.v4[0]; | |
| curl_msnprintf((char *)buffer, sizeof(buffer), | |
| "%u.%u.%u.%u", p[0], p[1], p[2], p[3]); | |
| - | if(rc || strcmp((char *)buffer, "127.0.0.1")) { |
| + | if(rc || strcmp((const char *)buffer, "127.0.0.1")) { |
| curl_mfprintf(stderr, "bad address decoded: %s, rc == %d\n", buffer, rc); | |
| - | abort_if(rc || strcmp((char *)buffer, "127.0.0.1"), "bad address"); |
| + | abort_if(rc || strcmp((const char *)buffer, "127.0.0.1"), "bad address"); |
| } | |
| fail_if(d.numcname, "bad cname counter"); | |
| } | |
| @@ -27,7 +27,7 @@ | |
| #include "curl/urlapi.h" | |
| #include "urlapi-int.h" | |
| - | static CURLUcode parse_port(CURLU *url, char *h, bool has_scheme) |
| + | static CURLUcode parse_port(CURLU *url, const char *h, bool has_scheme) |
| { | |
| struct dynbuf host; | |
| CURLUcode ret; | |
| @@ -52,7 +52,7 @@ static char rrbuffer[256]; | |
| static void rrresults(struct Curl_https_rrinfo *rr, CURLcode res) | |
| { | |
| char *p = rrbuffer; | |
| - | char *pend = rrbuffer + sizeof(rrbuffer); |
| + | const char *pend = rrbuffer + sizeof(rrbuffer); |
| curl_msnprintf(rrbuffer, sizeof(rrbuffer), "r:%d|", (int)res); | |
| p += strlen(rrbuffer); | |
| @@ -109,7 +109,7 @@ static CURLcode test_unit1979(const char *arg) | |
| struct dynbuf canonical_path; | |
| char buffer[1024]; | |
| - | char *canonical_path_string; |
| + | const char *canonical_path_string; |
| int result; | |
| int msnprintf_result; | |
| @@ -82,7 +82,7 @@ static CURLcode test_unit1980(const char *arg) | |
| struct dynbuf canonical_query; | |
| char buffer[1024]; | |
| - | char *canonical_query_ptr; |
| + | const char *canonical_query_ptr; |
| int result; | |
| int msnprintf_result; | |
| @@ -80,7 +80,7 @@ static CURLcode test_unit3200(const char *arg) | |
| FILE *fp; | |
| struct dynbuf buf; | |
| size_t len = 4096; | |
| - | char *line; |
| + | const char *line; |
| bool eof; | |
| curlx_dyn_init(&buf, len); | |
| @@ -562,11 +562,11 @@ static CURLcode test_unit3205(const char *arg) | |
| if(test->id >= 0x0011 && test->id < 0x0017) { | |
| if(expect && memcmp(expect, "EDH-", 4) == 0) { | |
| curlx_strcopy(alt, sizeof(alt), expect, strlen(expect)); | |
| - | expect = (char *)memcpy(alt, "DHE-", 4); |
| + | expect = (const char *)memcpy(alt, "DHE-", 4); |
| } | |
| if(expect && memcmp(expect + 4, "EDH-", 4) == 0) { | |
| curlx_strcopy(alt, sizeof(alt), expect, strlen(expect)); | |
| - | expect = (char *)memcpy(alt + 4, "DHE-", 4) - 4; |
| + | expect = (const char *)memcpy(alt + 4, "DHE-", 4) - 4; |
| } | |
| } | |