examples: consistent variable naming across examples

- 'CURL *' handles are called 'curl'
- 'CURLM *' handles are called 'multi'
- write callbacks are called 'write_cb'
- read callbacs are called 'read_cb'
- CURLcode variables are called 'res'

It makes the examples look and feel more consistent. It allows for
easier copy and pasting between examples.

Closes #19299
This commit is contained in:
Daniel Stenberg 2025-10-31 14:42:30 +01:00
parent 0313223853
commit 928363f28c
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
59 changed files with 715 additions and 725 deletions

View file

@ -37,34 +37,34 @@
*/
int main(void)
{
CURL *http_handle;
CURL *curl;
CURLcode res = curl_global_init(CURL_GLOBAL_ALL);
if(res)
return (int)res;
http_handle = curl_easy_init();
if(http_handle) {
curl = curl_easy_init();
if(curl) {
CURLM *multi_handle;
CURLM *multi;
int still_running = 1; /* keep number of running handles */
/* set the options (I left out a few, you get the point anyway) */
curl_easy_setopt(http_handle, CURLOPT_URL, "https://www.example.com/");
curl_easy_setopt(curl, CURLOPT_URL, "https://www.example.com/");
/* init a multi stack */
multi_handle = curl_multi_init();
if(multi_handle) {
multi = curl_multi_init();
if(multi) {
/* add the individual transfers */
curl_multi_add_handle(multi_handle, http_handle);
curl_multi_add_handle(multi, curl);
do {
CURLMcode mc = curl_multi_perform(multi_handle, &still_running);
CURLMcode mc = curl_multi_perform(multi, &still_running);
if(!mc)
/* wait for activity, timeout or "nothing" */
mc = curl_multi_poll(multi_handle, NULL, 0, 1000, NULL);
mc = curl_multi_poll(multi, NULL, 0, 1000, NULL);
if(mc) {
fprintf(stderr, "curl_multi_poll() failed, code %d.\n", (int)mc);
@ -73,12 +73,12 @@ int main(void)
} while(still_running);
curl_multi_remove_handle(multi_handle, http_handle);
curl_multi_remove_handle(multi, curl);
curl_multi_cleanup(multi_handle);
curl_multi_cleanup(multi);
}
curl_easy_cleanup(http_handle);
curl_easy_cleanup(curl);
}
curl_global_cleanup();