]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
docs/libcurl: fix C formatting nits
authorViktor Szakats <commit@vsz.me>
Thu, 4 Dec 2025 19:11:45 +0000 (20:11 +0100)
committerViktor Szakats <commit@vsz.me>
Thu, 4 Dec 2025 21:49:03 +0000 (22:49 +0100)
Closes #19844

13 files changed:
docs/libcurl/curl_easy_nextheader.md
docs/libcurl/curl_easy_pause.md
docs/libcurl/curl_formadd.md
docs/libcurl/curl_formget.md
docs/libcurl/curl_mime_data_cb.md
docs/libcurl/curl_mprintf.md
docs/libcurl/curl_multi_fdset.md
docs/libcurl/curl_ws_meta.md
docs/libcurl/libcurl-tutorial.md
docs/libcurl/opts/CURLINFO_USED_PROXY.md
docs/libcurl/opts/CURLOPT_COOKIELIST.md
docs/libcurl/opts/CURLOPT_SOCKS5_AUTH.md
docs/libcurl/opts/CURLOPT_WRITEFUNCTION.md

index 2dbdf61ccdbdcf35bb2c156e4800b0ca012dcbed..c3dd223b8c8cffb4b3bfb44e1ce9cdd0672c1055 100644 (file)
@@ -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;
index 2f47c4ef3f7f18abaaa9c8c559a213fc93192b9a..b6390058e89a184fb57e360f63741ddef743b4d0 100644 (file)
@@ -109,7 +109,6 @@ int main(void)
   if(curl) {
     /* pause a transfer in both directions */
     curl_easy_pause(curl, CURLPAUSE_RECV | CURLPAUSE_SEND);
-
   }
 }
 ~~~
index f35e50eab7546ee299151031b05db820540ecfbe..ca05f4310aff752706d8f0bf88ce23402ea87702 100644 (file)
@@ -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 */
index 264eb5cbcbb3e5ec609b0ef1c3e36d2dcbad9b24..316609e93a97b912b3cd620cbd0a41dfe306d8fa 100644 (file)
@@ -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;
 }
index 9b3fdd5593bd9674d7688cdad39da44c63332369..bed7c5d78f47be88f226736933361be933ab5524 100644 (file)
@@ -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;
index a592cfb3e6615ffeeba8671e4f59cb6690fce394..508dece91974f3192453db0880e585a6f69f7785 100644 (file)
@@ -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);
 }
 ~~~
 
index 1396738014c366d6e433ea9da4882c770a785be9..24d6664f4998e719ed10af57d7c0d29239681982 100644 (file)
@@ -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();
 
index e34e5476764a71df576538a5a13f0a552bf31477..978520afd8d028dbd92faf9d8e3b14cf052ac404 100644 (file)
@@ -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;
 }
index e515b3b7b0674fab608d066d7cb07a235fe98f9d..7b01d234c4c9c9a52a4fc15a70490fd04f1fa908 100644 (file)
@@ -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 \<form\> 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");
index 01ef3610db0e58aff372129630bba246ccba47bd..3d652c73b016d5f0c1c9bc495e76d312c2729a86 100644 (file)
@@ -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);
index a2c43d8dfe2d2bc7d506ae964d0d1125e1a74edc..5124a53e64b6dec63338ce3ddf1f20130fe237fe 100644 (file)
@@ -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)
 {
index a9adf6b77d5a4bf72be4a039688321e2616db14b..826fc4c1f2b35c7947e52cf4e5cf61e7592327a7 100644 (file)
@@ -35,7 +35,7 @@ password with the CURLOPT_PROXYUSERPWD(3) option.
 
 # DEFAULT
 
-CURLAUTH_BASIC|CURLAUTH_GSSAPI
+CURLAUTH_BASIC | CURLAUTH_GSSAPI
 
 # %PROTOCOLS%
 
index 973a0aea754e8f89f1fce621e633c3741619b813..ad4b4e0360f369d6ec31e337bfc1aa3ae2934fc8 100644 (file)
@@ -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) {