From: Viktor Szakats Date: Thu, 4 Dec 2025 19:11:45 +0000 (+0100) Subject: docs/libcurl: fix C formatting nits X-Git-Tag: rc-8_18_0-1~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ebe6fa08c9df12aa1c66cacf49a6e503a6e45d02;p=thirdparty%2Fcurl.git docs/libcurl: fix C formatting nits Closes #19844 --- diff --git a/docs/libcurl/curl_easy_nextheader.md b/docs/libcurl/curl_easy_nextheader.md index 2dbdf61ccd..c3dd223b8c 100644 --- a/docs/libcurl/curl_easy_nextheader.md +++ b/docs/libcurl/curl_easy_nextheader.md @@ -83,7 +83,7 @@ int main(void) } /* extract the normal headers + 1xx + trailers from the last request */ - unsigned int origin = CURLH_HEADER| CURLH_1XX | CURLH_TRAILER; + unsigned int origin = CURLH_HEADER | CURLH_1XX | CURLH_TRAILER; while((h = curl_easy_nextheader(curl, origin, -1, prev))) { printf("%s: %s\n", h->name, h->value); prev = h; diff --git a/docs/libcurl/curl_easy_pause.md b/docs/libcurl/curl_easy_pause.md index 2f47c4ef3f..b6390058e8 100644 --- a/docs/libcurl/curl_easy_pause.md +++ b/docs/libcurl/curl_easy_pause.md @@ -109,7 +109,6 @@ int main(void) if(curl) { /* pause a transfer in both directions */ curl_easy_pause(curl, CURLPAUSE_RECV | CURLPAUSE_SEND); - } } ~~~ diff --git a/docs/libcurl/curl_formadd.md b/docs/libcurl/curl_formadd.md index f35e50eab7..ca05f4310a 100644 --- a/docs/libcurl/curl_formadd.md +++ b/docs/libcurl/curl_formadd.md @@ -225,7 +225,7 @@ int main(void) char file2[] = "your-face.jpg"; /* add null character into htmlbuffer, to demonstrate that transfers of buffers containing null characters actually work - */ + */ htmlbuffer[8] = '\0'; /* Add simple name/content section */ diff --git a/docs/libcurl/curl_formget.md b/docs/libcurl/curl_formget.md index 264eb5cbcb..316609e93a 100644 --- a/docs/libcurl/curl_formget.md +++ b/docs/libcurl/curl_formget.md @@ -54,7 +54,7 @@ This, because first then does libcurl known which actual read callback to use. size_t print_httppost_callback(void *arg, const char *buf, size_t len) { fwrite(buf, len, 1, stdout); - (*(size_t *) arg) += len; + (*(size_t *)arg) += len; return len; } @@ -62,7 +62,7 @@ size_t print_httppost(struct curl_httppost *post) { size_t total_size = 0; if(curl_formget(post, &total_size, print_httppost_callback)) { - return (size_t) -1; + return (size_t)-1; } return total_size; } diff --git a/docs/libcurl/curl_mime_data_cb.md b/docs/libcurl/curl_mime_data_cb.md index 9b3fdd5593..bed7c5d78f 100644 --- a/docs/libcurl/curl_mime_data_cb.md +++ b/docs/libcurl/curl_mime_data_cb.md @@ -120,7 +120,7 @@ struct ctl { size_t read_callback(char *buffer, size_t size, size_t nitems, void *arg) { - struct ctl *p = (struct ctl *) arg; + struct ctl *p = (struct ctl *)arg; curl_off_t sz = p->size - p->position; nitems *= size; diff --git a/docs/libcurl/curl_mprintf.md b/docs/libcurl/curl_mprintf.md index a592cfb3e6..508dece919 100644 --- a/docs/libcurl/curl_mprintf.md +++ b/docs/libcurl/curl_mprintf.md @@ -274,7 +274,7 @@ const char *name = "John"; int main(void) { curl_mprintf("My name is %s\n", name); - curl_mprintf("Pi is almost %f\n", (double)25.0/8); + curl_mprintf("Pi is almost %f\n", (double)25.0 / 8); } ~~~ diff --git a/docs/libcurl/curl_multi_fdset.md b/docs/libcurl/curl_multi_fdset.md index 1396738014..24d6664f49 100644 --- a/docs/libcurl/curl_multi_fdset.md +++ b/docs/libcurl/curl_multi_fdset.md @@ -92,7 +92,7 @@ int main(void) int maxfd; int rc; CURLMcode mc; - struct timeval timeout = {1, 0}; + struct timeval timeout = { 1, 0 }; CURLM *multi = curl_multi_init(); diff --git a/docs/libcurl/curl_ws_meta.md b/docs/libcurl/curl_ws_meta.md index e34e547676..978520afd8 100644 --- a/docs/libcurl/curl_ws_meta.md +++ b/docs/libcurl/curl_ws_meta.md @@ -137,8 +137,7 @@ struct customdata { void *ptr; }; -static size_t writecb(char *buffer, - size_t size, size_t nitems, void *p) +static size_t writecb(char *buffer, size_t size, size_t nitems, void *p) { struct customdata *c = (struct customdata *)p; const struct curl_ws_frame *m = curl_ws_meta(c->easy); @@ -158,7 +157,6 @@ int main(void) curl_easy_setopt(curl, CURLOPT_WRITEDATA, &custom); curl_easy_perform(curl); - } return 0; } diff --git a/docs/libcurl/libcurl-tutorial.md b/docs/libcurl/libcurl-tutorial.md index e515b3b7b0..7b01d234c4 100644 --- a/docs/libcurl/libcurl-tutorial.md +++ b/docs/libcurl/libcurl-tutorial.md @@ -448,7 +448,7 @@ claims to support. This method does however add a round-trip since libcurl must first ask the server what it supports: ~~~c - curl_easy_setopt(handle, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST|CURLAUTH_BASIC); + curl_easy_setopt(handle, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST | CURLAUTH_BASIC); ~~~ For convenience, you can use the *CURLAUTH_ANY* define (instead of a list with @@ -468,7 +468,7 @@ pages using the \ tag uses. We provide a pointer to the data and tell libcurl to post it all to the remote site: ~~~c - char *data="name=daniel&project=curl"; + char *data = "name=daniel&project=curl"; curl_easy_setopt(handle, CURLOPT_POSTFIELDS, data); curl_easy_setopt(handle, CURLOPT_URL, "http://posthere.com/"); @@ -487,7 +487,7 @@ done in a generic way, by building a list of our own headers and then passing that list to libcurl. ~~~c - struct curl_slist *headers=NULL; + struct curl_slist *headers = NULL; headers = curl_slist_append(headers, "Content-Type: text/xml"); /* post binary data */ @@ -574,8 +574,8 @@ parts, you post the whole form. The MIME API example above is expressed as follows using this function: ~~~c - struct curl_httppost *post=NULL; - struct curl_httppost *last=NULL; + struct curl_httppost *post = NULL; + struct curl_httppost *last = NULL; curl_formadd(&post, &last, CURLFORM_COPYNAME, "name", CURLFORM_COPYCONTENTS, "daniel", CURLFORM_END); @@ -605,7 +605,7 @@ shows how you set headers to one specific part when you add that to the post handle: ~~~c - struct curl_slist *headers=NULL; + struct curl_slist *headers = NULL; headers = curl_slist_append(headers, "Content-Type: text/xml"); curl_formadd(&post, &last, @@ -675,7 +675,7 @@ becomes: ~~~c part = curl_mime_addpart(multipart); curl_mime_name(part, "logotype-image"); - curl_mime_data_cb(part, (curl_off_t) -1, fread, fseek, NULL, stdin); + curl_mime_data_cb(part, (curl_off_t)-1, fread, fseek, NULL, stdin); ~~~ curl_mime_name(3) always copies the field name. The special filename "-" is @@ -717,7 +717,7 @@ becomes: ~~~c part = curl_mime_addpart(multipart); curl_mime_name(part, "stream"); - curl_mime_data_cb(part, (curl_off_t) datasize, + curl_mime_data_cb(part, (curl_off_t)datasize, myreadfunc, NULL, NULL, arg); curl_mime_filename(part, "archive.zip"); curl_mime_type(part, "application/zip"); @@ -738,7 +738,7 @@ becomes: ~~~c part = curl_mime_addpart(multipart); curl_mime_name(part, "memfile"); - curl_mime_data(part, databuffer, (curl_off_t) sizeof databuffer); + curl_mime_data(part, databuffer, (curl_off_t)sizeof(databuffer)); curl_mime_filename(part, "memfile.bin"); ~~~ @@ -802,12 +802,12 @@ Example C++ code: ~~~c class AClass { - static size_t write_data(void *ptr, size_t size, size_t nmemb, - void *ourpointer) - { - /* do what you want with the data */ - } - } + static size_t write_data(void *ptr, size_t size, size_t nmemb, + void *ourpointer) + { + /* do what you want with the data */ + } +} ~~~ # Proxies @@ -1046,7 +1046,7 @@ request, and you are free to pass any amount of extra headers that you think fit. Adding headers is this easy: ~~~c -struct curl_slist *headers=NULL; /* init to NULL is important */ +struct curl_slist *headers = NULL; /* init to NULL is important */ headers = curl_slist_append(headers, "Hey-server-hey: how are you?"); headers = curl_slist_append(headers, "X-silly-content: yes"); diff --git a/docs/libcurl/opts/CURLINFO_USED_PROXY.md b/docs/libcurl/opts/CURLINFO_USED_PROXY.md index 01ef3610db..3d652c73b0 100644 --- a/docs/libcurl/opts/CURLINFO_USED_PROXY.md +++ b/docs/libcurl/opts/CURLINFO_USED_PROXY.md @@ -53,7 +53,7 @@ int main(int argc, char *argv[]) long used; res = curl_easy_getinfo(curl, CURLINFO_USED_PROXY, &used); if(!res) { - printf("The proxy was %sused\n", used ? "": "NOT "); + printf("The proxy was %sused\n", used ? "" : "NOT "); } } curl_easy_cleanup(curl); diff --git a/docs/libcurl/opts/CURLOPT_COOKIELIST.md b/docs/libcurl/opts/CURLOPT_COOKIELIST.md index a2c43d8dfe..5124a53e64 100644 --- a/docs/libcurl/opts/CURLOPT_COOKIELIST.md +++ b/docs/libcurl/opts/CURLOPT_COOKIELIST.md @@ -77,7 +77,7 @@ NULL ~~~c /* an inline import of a cookie in Netscape format. */ -#define SEP "\t" /* Tab separates the fields */ +#define SEP "\t" /* Tab separates the fields */ int main(void) { diff --git a/docs/libcurl/opts/CURLOPT_SOCKS5_AUTH.md b/docs/libcurl/opts/CURLOPT_SOCKS5_AUTH.md index a9adf6b77d..826fc4c1f2 100644 --- a/docs/libcurl/opts/CURLOPT_SOCKS5_AUTH.md +++ b/docs/libcurl/opts/CURLOPT_SOCKS5_AUTH.md @@ -35,7 +35,7 @@ password with the CURLOPT_PROXYUSERPWD(3) option. # DEFAULT -CURLAUTH_BASIC|CURLAUTH_GSSAPI +CURLAUTH_BASIC | CURLAUTH_GSSAPI # %PROTOCOLS% diff --git a/docs/libcurl/opts/CURLOPT_WRITEFUNCTION.md b/docs/libcurl/opts/CURLOPT_WRITEFUNCTION.md index 973a0aea75..ad4b4e0360 100644 --- a/docs/libcurl/opts/CURLOPT_WRITEFUNCTION.md +++ b/docs/libcurl/opts/CURLOPT_WRITEFUNCTION.md @@ -106,7 +106,7 @@ static size_t cb(char *data, size_t size, size_t nmemb, void *clientp) int main(void) { - struct memory chunk = {0}; + struct memory chunk = { 0 }; CURLcode res; CURL *curl = curl_easy_init(); if(curl) {