]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
lib: fix formatting nits (part 3)
authorViktor Szakats <commit@vsz.me>
Tue, 2 Dec 2025 06:25:18 +0000 (07:25 +0100)
committerViktor Szakats <commit@vsz.me>
Wed, 3 Dec 2025 13:50:16 +0000 (14:50 +0100)
From `lib/h` to `lib/w`.

part 1: 47a1ab2ebecb21485c0e955316d90511e80a3c43 #19764
part 2: 86b346443b68cde7ef33e1ab770e6c8ab641d2b1 #19800

Closes #19811

102 files changed:
lib/hash.c
lib/hash.h
lib/headers.c
lib/headers.h
lib/hmac.c
lib/hostip.c
lib/hostip.h
lib/hostip4.c
lib/hsts.c
lib/hsts.h
lib/http.c
lib/http.h
lib/http1.c
lib/http2.c
lib/http2.h
lib/http_aws_sigv4.c
lib/http_aws_sigv4.h
lib/http_chunks.c
lib/http_digest.c
lib/http_negotiate.c
lib/http_ntlm.c
lib/http_proxy.c
lib/http_proxy.h
lib/httpsrr.c
lib/httpsrr.h
lib/idn.c
lib/if2ip.c
lib/if2ip.h
lib/imap.c
lib/imap.h
lib/ldap.c
lib/llist.c
lib/llist.h
lib/md4.c
lib/md5.c
lib/memdebug.c
lib/mime.c
lib/mime.h
lib/mprintf.c
lib/mqtt.c
lib/multi.c
lib/multi_ev.c
lib/multi_ntfy.c
lib/multi_ntfy.h
lib/multiif.h
lib/netrc.c
lib/netrc.h
lib/noproxy.c
lib/openldap.c
lib/parsedate.c
lib/pingpong.c
lib/pingpong.h
lib/pop3.c
lib/progress.c
lib/psl.c
lib/rand.c
lib/rand.h
lib/ratelimit.c
lib/request.c
lib/request.h
lib/rtsp.c
lib/rtsp.h
lib/select.c
lib/select.h
lib/sendf.c
lib/sendf.h
lib/setopt.c
lib/setopt.h
lib/setup-os400.h
lib/setup-vms.h
lib/sha256.c
lib/sigpipe.h
lib/slist.c
lib/smb.c
lib/smtp.c
lib/socketpair.h
lib/socks.c
lib/socks.h
lib/socks_gssapi.c
lib/socks_sspi.c
lib/splay.c
lib/strcase.c
lib/strcase.h
lib/strdup.h
lib/strerror.c
lib/system_win32.c
lib/telnet.c
lib/tftp.c
lib/transfer.c
lib/transfer.h
lib/uint-bset.c
lib/uint-bset.h
lib/uint-hash.c
lib/uint-hash.h
lib/uint-spbset.c
lib/uint-table.c
lib/url.c
lib/urlapi.c
lib/urldata.h
lib/version.c
lib/ws.c
lib/ws.h

index 2d91c855e614bceac9f98f1667c97135cce17613..b9e9d702e3ccdd6f092791403679f42efead61e0 100644 (file)
@@ -37,8 +37,7 @@
 
 
 #if 0 /* useful function for debugging hashes and their contents */
-void Curl_hash_print(struct Curl_hash *h,
-                     void (*func)(void *))
+void Curl_hash_print(struct Curl_hash *h, void (*func)(void *))
 {
   struct Curl_hash_iterator iter;
   struct Curl_hash_element *he;
@@ -80,12 +79,11 @@ void Curl_hash_print(struct Curl_hash *h,
  * @unittest: 1602
  * @unittest: 1603
  */
-void
-Curl_hash_init(struct Curl_hash *h,
-               size_t slots,
-               hash_function hfunc,
-               comp_function comparator,
-               Curl_hash_dtor dtor)
+void Curl_hash_init(struct Curl_hash *h,
+                    size_t slots,
+                    hash_function hfunc,
+                    comp_function comparator,
+                    Curl_hash_dtor dtor)
 {
   DEBUGASSERT(h);
   DEBUGASSERT(slots);
@@ -104,9 +102,10 @@ Curl_hash_init(struct Curl_hash *h,
 #endif
 }
 
-static struct Curl_hash_element *
-hash_elem_create(const void *key, size_t key_len, const void *p,
-                 Curl_hash_elem_dtor dtor)
+static struct Curl_hash_element *hash_elem_create(const void *key,
+                                                  size_t key_len,
+                                                  const void *p,
+                                                  Curl_hash_elem_dtor dtor)
 {
   struct Curl_hash_element *he;
 
@@ -161,8 +160,8 @@ static void hash_elem_link(struct Curl_hash *h,
   ++h->size;
 }
 
-#define CURL_HASH_SLOT(x,y,z)      x->table[x->hash_func(y, z, x->slots)]
-#define CURL_HASH_SLOT_ADDR(x,y,z) &CURL_HASH_SLOT(x,y,z)
+#define CURL_HASH_SLOT(x, y, z)      x->table[x->hash_func(y, z, x->slots)]
+#define CURL_HASH_SLOT_ADDR(x, y, z) &CURL_HASH_SLOT(x, y, z)
 
 void *Curl_hash_add2(struct Curl_hash *h, void *key, size_t key_len, void *p,
                      Curl_hash_elem_dtor dtor)
@@ -205,8 +204,7 @@ void *Curl_hash_add2(struct Curl_hash *h, void *key, size_t key_len, void *p,
  * @unittest: 1602
  * @unittest: 1603
  */
-void *
-Curl_hash_add(struct Curl_hash *h, void *key, size_t key_len, void *p)
+void *Curl_hash_add(struct Curl_hash *h, void *key, size_t key_len, void *p)
 {
   return Curl_hash_add2(h, key, key_len, p, NULL);
 }
@@ -242,8 +240,7 @@ int Curl_hash_delete(struct Curl_hash *h, void *key, size_t key_len)
  *
  * @unittest: 1603
  */
-void *
-Curl_hash_pick(struct Curl_hash *h, void *key, size_t key_len)
+void *Curl_hash_pick(struct Curl_hash *h, void *key, size_t key_len)
 {
   DEBUGASSERT(h);
   DEBUGASSERT(h->init == HASHINIT);
@@ -268,8 +265,7 @@ Curl_hash_pick(struct Curl_hash *h, void *key, size_t key_len)
  * @unittest: 1602
  * @unittest: 1603
  */
-void
-Curl_hash_destroy(struct Curl_hash *h)
+void Curl_hash_destroy(struct Curl_hash *h)
 {
   DEBUGASSERT(h->init == HASHINIT);
   if(h->table) {
@@ -308,9 +304,8 @@ size_t Curl_hash_count(struct Curl_hash *h)
 }
 
 /* Cleans all entries that pass the comp function criteria. */
-void
-Curl_hash_clean_with_criterium(struct Curl_hash *h, void *user,
-                               int (*comp)(void *, void *))
+void Curl_hash_clean_with_criterium(struct Curl_hash *h, void *user,
+                                    int (*comp)(void *, void *))
 {
   size_t i;
 
@@ -335,7 +330,7 @@ Curl_hash_clean_with_criterium(struct Curl_hash *h, void *user,
 
 size_t Curl_hash_str(void *key, size_t key_length, size_t slots_num)
 {
-  const char *key_str = (const char *) key;
+  const char *key_str = (const char *)key;
   const char *end = key_str + key_length;
   size_t h = 5381;
 
index fcd92db6645dbe6c14ef2386e94c7d2357a8d6a1..b9974826b03cfc4e7655c22d017e44eddc8e20b0 100644 (file)
 #include "llist.h"
 
 /* Hash function prototype */
-typedef size_t (*hash_function) (void *key,
-                                 size_t key_length,
-                                 size_t slots_num);
+typedef size_t (*hash_function)(void *key,
+                                size_t key_length,
+                                size_t slots_num);
 
 /*
    Comparator function prototype. Compares two keys.
 */
-typedef size_t (*comp_function) (void *key1,
-                                 size_t key1_len,
-                                 void *key2,
-                                 size_t key2_len);
+typedef size_t (*comp_function)(void *key1,
+                                size_t key1_len,
+                                void *key2,
+                                size_t key2_len);
 
 typedef void (*Curl_hash_dtor)(void *);
 
@@ -49,10 +49,10 @@ typedef void (*Curl_hash_elem_dtor)(void *key, size_t key_len, void *p);
 
 struct Curl_hash_element {
   struct Curl_hash_element *next;
-  void   *ptr;
+  void *ptr;
   Curl_hash_elem_dtor dtor;
   size_t key_len;
-  char   key[1]; /* allocated memory following the struct */
+  char key[1]; /* allocated memory following the struct */
 };
 
 struct Curl_hash {
@@ -63,7 +63,7 @@ struct Curl_hash {
   /* Comparator function to compare keys */
   comp_function comp_func;
   /* General element construct, unless element itself carries one */
-  Curl_hash_dtor   dtor;
+  Curl_hash_dtor dtor;
   size_t slots;
   size_t size;
 #ifdef DEBUGBUILD
@@ -105,7 +105,6 @@ void Curl_hash_start_iterate(struct Curl_hash *hash,
 struct Curl_hash_element *
 Curl_hash_next_element(struct Curl_hash_iterator *iter);
 
-void Curl_hash_print(struct Curl_hash *h,
-                     void (*func)(void *));
+void Curl_hash_print(struct Curl_hash *h, void (*func)(void *));
 
 #endif /* HEADER_CURL_HASH_H */
index 91715fd51d3a3cd63bc1b3c1b4454886206f0d1b..7cf215c0800ebacb07b0c88c4f5199d6dd44a3aa 100644 (file)
@@ -69,7 +69,7 @@ CURLHcode curl_easy_header(CURL *easy,
   struct Curl_header_store *hs = NULL;
   struct Curl_header_store *pick = NULL;
   if(!name || !hout || !data ||
-     (type > (CURLH_HEADER|CURLH_TRAILER|CURLH_CONNECT|CURLH_1XX|
+     (type > (CURLH_HEADER | CURLH_TRAILER | CURLH_CONNECT | CURLH_1XX |
               CURLH_PSEUDO)) || !type || (request < -1))
     return CURLHE_BAD_ARGUMENT;
   if(!Curl_llist_count(&data->state.httphdrs))
@@ -264,7 +264,6 @@ static CURLcode unfold_value(struct Curl_easy *data, const char *value,
   return CURLE_OK;
 }
 
-
 /*
  * Curl_headers_push() gets passed a full HTTP header to store. It gets called
  * immediately before the header callback. The header is CRLF terminated.
index e11fe9804e5129cd43b26235b98435139cd7d840..7249355f0ccd24e49c8c2ac955e630fcf5d4160c 100644 (file)
@@ -54,9 +54,9 @@ CURLcode Curl_headers_push(struct Curl_easy *data, const char *header,
 CURLcode Curl_headers_cleanup(struct Curl_easy *data);
 
 #else
-#define Curl_headers_init(x) CURLE_OK
-#define Curl_headers_push(x,y,z) CURLE_OK
-#define Curl_headers_cleanup(x) Curl_nop_stmt
+#define Curl_headers_init(x)       CURLE_OK
+#define Curl_headers_push(x, y, z) CURLE_OK
+#define Curl_headers_cleanup(x)    Curl_nop_stmt
 #endif
 
 #endif /* HEADER_CURL_HEADER_H */
index 4f226e6434f8c9d4313d829926b952a762089c9c..fdde19717539182f108d25ea1f948160e5f5bff6 100644 (file)
 static const unsigned char hmac_ipad = 0x36;
 static const unsigned char hmac_opad = 0x5C;
 
-struct HMAC_context *
-Curl_HMAC_init(const struct HMAC_params *hashparams,
-               const unsigned char *key,
-               unsigned int keylen)
+struct HMAC_context *Curl_HMAC_init(const struct HMAC_params *hashparams,
+                                    const unsigned char *key,
+                                    unsigned int keylen)
 {
   size_t i;
   struct HMAC_context *ctxt;
@@ -64,15 +63,15 @@ Curl_HMAC_init(const struct HMAC_params *hashparams,
     return ctxt;
 
   ctxt->hash = hashparams;
-  ctxt->hashctxt1 = (void *) (ctxt + 1);
-  ctxt->hashctxt2 = (void *) ((char *) ctxt->hashctxt1 + hashparams->ctxtsize);
+  ctxt->hashctxt1 = (void *)(ctxt + 1);
+  ctxt->hashctxt2 = (void *)((char *)ctxt->hashctxt1 + hashparams->ctxtsize);
 
   /* If the key is too long, replace it by its hash digest. */
   if(keylen > hashparams->maxkeylen) {
     if(hashparams->hinit(ctxt->hashctxt1))
       goto fail;
     hashparams->hupdate(ctxt->hashctxt1, key, keylen);
-    hkey = (unsigned char *) ctxt->hashctxt2 + hashparams->ctxtsize;
+    hkey = (unsigned char *)ctxt->hashctxt2 + hashparams->ctxtsize;
     hashparams->hfinal(hkey, ctxt->hashctxt1);
     key = hkey;
     keylen = hashparams->resultlen;
@@ -112,7 +111,6 @@ int Curl_HMAC_update(struct HMAC_context *ctxt,
   return 0;
 }
 
-
 int Curl_HMAC_final(struct HMAC_context *ctxt, unsigned char *output)
 {
   const struct HMAC_params *hashparams = ctxt->hash;
@@ -121,7 +119,7 @@ int Curl_HMAC_final(struct HMAC_context *ctxt, unsigned char *output)
      storage. */
 
   if(!output)
-    output = (unsigned char *) ctxt->hashctxt2 + ctxt->hash->ctxtsize;
+    output = (unsigned char *)ctxt->hashctxt2 + ctxt->hash->ctxtsize;
 
   hashparams->hfinal(output, ctxt->hashctxt1);
   hashparams->hupdate(ctxt->hashctxt2, output, hashparams->resultlen);
index e81886995eda2eab29e7d7642c688eed565bdca4..ba9e3ddd7ac99fee7792f57c37dc0a90e9af9391 100644 (file)
@@ -118,7 +118,7 @@ static void dnscache_entry_free(struct Curl_dns_entry *dns);
 static void show_resolve_info(struct Curl_easy *data,
                               struct Curl_dns_entry *dns);
 #else
-#define show_resolve_info(x,y) Curl_nop_stmt
+#define show_resolve_info(x, y) Curl_nop_stmt
 #endif
 
 /*
@@ -158,10 +158,9 @@ void Curl_printable_address(const struct Curl_addrinfo *ai, char *buf,
  * Create a hostcache id string for the provided host + port, to be used by
  * the DNS caching. Without alloc. Return length of the id string.
  */
-static size_t
-create_dnscache_id(const char *name,
-                   size_t nlen, /* 0 or actual name length */
-                   int port, char *ptr, size_t buflen)
+static size_t create_dnscache_id(const char *name,
+                                 size_t nlen, /* 0 or actual name length */
+                                 int port, char *ptr, size_t buflen)
 {
   size_t len = nlen ? nlen : strlen(name);
   DEBUGASSERT(buflen >= MAX_HOSTCACHE_LEN);
@@ -185,12 +184,10 @@ struct dnscache_prune_data {
  * Returning non-zero means remove the entry, return 0 to keep it in the
  * cache.
  */
-static int
-dnscache_entry_is_stale(void *datap, void *hc)
+static int dnscache_entry_is_stale(void *datap, void *hc)
 {
-  struct dnscache_prune_data *prune =
-    (struct dnscache_prune_data *) datap;
-  struct Curl_dns_entry *dns = (struct Curl_dns_entry *) hc;
+  struct dnscache_prune_data *prune = (struct dnscache_prune_data *)datap;
+  struct Curl_dns_entry *dns = (struct Curl_dns_entry *)hc;
 
   if(dns->timestamp.tv_sec || dns->timestamp.tv_usec) {
     /* get age in milliseconds */
@@ -209,9 +206,9 @@ dnscache_entry_is_stale(void *datap, void *hc)
  * Prune the DNS cache. This assumes that a lock has already been taken.
  * Returns the 'age' of the oldest still kept entry - in milliseconds.
  */
-static timediff_t
-dnscache_prune(struct Curl_hash *hostcache, timediff_t cache_timeout_ms,
-               struct curltime now)
+static timediff_t dnscache_prune(struct Curl_hash *hostcache,
+                                 timediff_t cache_timeout_ms,
+                                 struct curltime now)
 {
   struct dnscache_prune_data user;
 
@@ -389,11 +386,10 @@ static struct Curl_dns_entry *fetch_addr(struct Curl_easy *data,
  * The returned data *MUST* be "released" with Curl_resolv_unlink() after
  * use, or we will leak memory!
  */
-struct Curl_dns_entry *
-Curl_dnscache_get(struct Curl_easy *data,
-                  const char *hostname,
-                  int port,
-                  int ip_version)
+struct Curl_dns_entry *Curl_dnscache_get(struct Curl_easy *data,
+                                         const char *hostname,
+                                         int port,
+                                         int ip_version)
 {
   struct Curl_dnscache *dnscache = dnscache_get(data);
   struct Curl_dns_entry *dns = NULL;
@@ -447,7 +443,7 @@ UNITTEST CURLcode Curl_shuffle_addr(struct Curl_easy *data,
     struct Curl_addrinfo **nodes;
     infof(data, "Shuffling %i addresses", num_addrs);
 
-    nodes = curlx_malloc(num_addrs*sizeof(*nodes));
+    nodes = curlx_malloc(num_addrs * sizeof(*nodes));
     if(nodes) {
       int i;
       unsigned int *rnd;
@@ -456,7 +452,7 @@ UNITTEST CURLcode Curl_shuffle_addr(struct Curl_easy *data,
       /* build a plain array of Curl_addrinfo pointers */
       nodes[0] = *addr;
       for(i = 1; i < num_addrs; i++) {
-        nodes[i] = nodes[i-1]->ai_next;
+        nodes[i] = nodes[i - 1]->ai_next;
       }
 
       rnd = curlx_malloc(rnd_size);
@@ -472,10 +468,10 @@ UNITTEST CURLcode Curl_shuffle_addr(struct Curl_easy *data,
 
           /* relink list in the new order */
           for(i = 1; i < num_addrs; i++) {
-            nodes[i-1]->ai_next = nodes[i];
+            nodes[i - 1]->ai_next = nodes[i];
           }
 
-          nodes[num_addrs-1]->ai_next = NULL;
+          nodes[num_addrs - 1]->ai_next = NULL;
           *addr = nodes[0];
         }
         curlx_free(rnd);
@@ -632,7 +628,7 @@ static struct Curl_addrinfo *get_localhost6(int port, const char *name)
   return ca;
 }
 #else
-#define get_localhost6(x,y) NULL
+#define get_localhost6(x, y) NULL
 #endif
 
 /* return a static IPv4 127.0.0.1 for the given name */
@@ -727,7 +723,6 @@ bool Curl_host_is_ipnum(const char *hostname)
   return FALSE;
 }
 
-
 /* return TRUE if 'part' is a case insensitive tail of 'full' */
 static bool tailmatch(const char *full, size_t flen,
                       const char *part, size_t plen)
@@ -980,8 +975,7 @@ CURLcode Curl_resolv_blocking(struct Curl_easy *data,
  * execution. This effectively causes the remainder of the application to run
  * within a signal handler which is nonportable and could lead to problems.
  */
-CURL_NORETURN static
-void alarmfunc(int sig)
+CURL_NORETURN static void alarmfunc(int sig)
 {
   (void)sig;
   siglongjmp(curl_jmpenv, 1);
@@ -1018,7 +1012,7 @@ CURLcode Curl_resolv_timeout(struct Curl_easy *data,
 {
 #ifdef USE_ALARM_TIMEOUT
 #ifdef HAVE_SIGACTION
-  struct sigaction keep_sigact;   /* store the old struct here */
+  struct sigaction keep_sigact; /* store the old struct here */
   volatile bool keep_copysig = FALSE; /* whether old sigact has been saved */
   struct sigaction sigact;
 #else
@@ -1058,8 +1052,8 @@ CURLcode Curl_resolv_timeout(struct Curl_easy *data,
     /* The alarm() function only provides integer second resolution, so if
        we want to wait less than one second we must bail out already now. */
     failf(data,
-        "remaining timeout of %ld too small to resolve via SIGALRM method",
-        timeout);
+          "remaining timeout of %ld too small to resolve via SIGALRM method",
+          timeout);
     return CURLE_OPERATION_TIMEDOUT;
   }
   /* This allows us to time-out from the name resolver, as the timeout
@@ -1101,7 +1095,7 @@ CURLcode Curl_resolv_timeout(struct Curl_easy *data,
 
     /* alarm() makes a signal get sent when the timeout fires off, and that
        will abort system calls */
-    prev_alarm = alarm(curlx_sltoui(timeout/1000L));
+    prev_alarm = alarm(curlx_sltoui(timeout / 1000L));
   }
 
 #else /* !USE_ALARM_TIMEOUT */
@@ -1151,7 +1145,7 @@ clean_up:
     unsigned long alarm_set = (unsigned long)(prev_alarm - elapsed_secs);
 
     if(!alarm_set ||
-       ((alarm_set >= 0x80000000) && (prev_alarm < 0x80000000)) ) {
+       ((alarm_set >= 0x80000000) && (prev_alarm < 0x80000000))) {
       /* if the alarm time-left reached zero or turned "negative" (counted
          with unsigned values), we should fire off a SIGALRM here, but we
          will not, and zero would be to switch it off so we never set it to
@@ -1203,7 +1197,7 @@ void Curl_resolv_unlink(struct Curl_easy *data, struct Curl_dns_entry **pdns)
 
 static void dnscache_entry_dtor(void *entry)
 {
-  struct Curl_dns_entry *dns = (struct Curl_dns_entry *) entry;
+  struct Curl_dns_entry *dns = (struct Curl_dns_entry *)entry;
   DEBUGASSERT(dns && (dns->refcount > 0));
   dns->refcount--;
   if(dns->refcount == 0)
@@ -1361,8 +1355,7 @@ CURLcode Curl_loadhostpairs(struct Curl_easy *data)
       error = FALSE;
 err:
       if(error) {
-        failf(data, "Could not parse CURLOPT_RESOLVE entry '%s'",
-              hostp->data);
+        failf(data, "Could not parse CURLOPT_RESOLVE entry '%s'", hostp->data);
         Curl_freeaddrinfo(head);
         return CURLE_SETOPT_OPTION_SYNTAX;
       }
index 3eb82cd1498a72e0711459edc5faca22174945d4..780d93038f9399d3584b1af0160f1c57ea7d9cd9 100644 (file)
@@ -175,10 +175,9 @@ Curl_dnscache_mk_entry(struct Curl_easy *data,
  * The returned data *MUST* be "released" with Curl_resolv_unlink() after
  * use, or we will leak memory!
  */
-struct Curl_dns_entry *
-Curl_dnscache_get(struct Curl_easy *data,
-                  const char *hostname,
-                  int port, int ip_version);
+struct Curl_dns_entry *Curl_dnscache_get(struct Curl_easy *data,
+                                         const char *hostname, int port,
+                                         int ip_version);
 
 /*
  * Curl_dnscache_addr() adds `entry` to the cache, increasing its
@@ -196,7 +195,7 @@ CURLcode Curl_loadhostpairs(struct Curl_easy *data);
 CURLcode Curl_resolv_check(struct Curl_easy *data,
                            struct Curl_dns_entry **dns);
 #else
-#define Curl_resolv_check(x,y) CURLE_NOT_BUILT_IN
+#define Curl_resolv_check(x, y) CURLE_NOT_BUILT_IN
 #endif
 CURLcode Curl_resolv_pollset(struct Curl_easy *data,
                              struct easy_pollset *ps);
index f01e902fd6842dd31975aaf0409d25bbe0d2ee1d..ada021176983bedc4238823879b63ec17537e13f 100644 (file)
@@ -166,11 +166,11 @@ struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname,
   /* Linux */
 
   (void)gethostbyname_r(hostname,
-                      (struct hostent *)buf,
-                      (char *)buf + sizeof(struct hostent),
-                      CURL_HOSTENT_SIZE - sizeof(struct hostent),
-                      &h, /* DIFFERENCE */
-                      &h_errnop);
+                        (struct hostent *)buf,
+                        (char *)buf + sizeof(struct hostent),
+                        CURL_HOSTENT_SIZE - sizeof(struct hostent),
+                        &h, /* DIFFERENCE */
+                        &h_errnop);
   /* Redhat 8, using glibc 2.2.93 changed the behavior. Now all of a
    * sudden this function returns EAGAIN if the given buffer size is too
    * small. Previous versions are known to return ERANGE for the same
index 22add039573239cbc86f71bd440fcc424080129e..66f983e493fba40f2da106758a144ddb32a019c9 100644 (file)
 #include "strdup.h"
 #include "curlx/strparse.h"
 
-#define MAX_HSTS_LINE 4095
+#define MAX_HSTS_LINE    4095
 #define MAX_HSTS_HOSTLEN 2048
 #define MAX_HSTS_DATELEN 256
-#define UNLIMITED "unlimited"
+#define UNLIMITED        "unlimited"
 
 #if defined(DEBUGBUILD) || defined(UNITTESTS)
 /* to play well with debug builds, we can *set* a fixed time this will
@@ -248,7 +248,7 @@ struct stsentry *Curl_hsts(struct hsts *h, const char *hostname,
 
     if((hlen > MAX_HSTS_HOSTLEN) || !hlen)
       return NULL;
-    if(hostname[hlen-1] == '.')
+    if(hostname[hlen - 1] == '.')
       /* remove the trailing dot */
       --hlen;
 
@@ -265,7 +265,7 @@ struct stsentry *Curl_hsts(struct hsts *h, const char *hostname,
       ntail = strlen(sts->host);
       if((subdomain && sts->includeSubDomains) && (ntail < hlen)) {
         size_t offs = hlen - ntail;
-        if((hostname[offs-1] == '.') &&
+        if((hostname[offs - 1] == '.') &&
            curl_strnequal(&hostname[offs], sts->host, ntail) &&
            (ntail > blen)) {
           /* save the tail match with the longest tail */
@@ -310,8 +310,7 @@ static CURLcode hsts_push(struct Curl_easy *data,
   else
     strcpy(e.expire, UNLIMITED);
 
-  sc = data->set.hsts_write(data, &e, i,
-                            data->set.hsts_write_userp);
+  sc = data->set.hsts_write(data, &e, i, data->set.hsts_write_userp);
   *stop = (sc != CURLSTS_OK);
   return sc == CURLSTS_FAIL ? CURLE_BAD_FUNCTION_ARGUMENT : CURLE_OK;
 }
@@ -327,7 +326,7 @@ static CURLcode hsts_out(struct stsentry *sts, FILE *fp)
     if(result)
       return result;
     curl_mfprintf(fp, "%s%s \"%d%02d%02d %02d:%02d:%02d\"\n",
-                  sts->includeSubDomains ? ".": "", sts->host,
+                  sts->includeSubDomains ? "." : "", sts->host,
                   stamp.tm_year + 1900, stamp.tm_mon + 1, stamp.tm_mday,
                   stamp.tm_hour, stamp.tm_min, stamp.tm_sec);
   }
@@ -337,7 +336,6 @@ static CURLcode hsts_out(struct stsentry *sts, FILE *fp)
   return CURLE_OK;
 }
 
-
 /*
  * Curl_https_save() writes the HSTS cache to file and callback.
  */
@@ -469,7 +467,7 @@ static CURLcode hsts_pull(struct Curl_easy *data, struct hsts *h)
       char buffer[MAX_HSTS_HOSTLEN + 1];
       struct curl_hstsentry e;
       e.name = buffer;
-      e.namelen = sizeof(buffer)-1;
+      e.namelen = sizeof(buffer) - 1;
       e.includeSubDomains = FALSE; /* default */
       e.expire[0] = 0;
       e.name[0] = 0; /* just to make it clean */
index cb83ada79043d5ea876d6dd11c628cf3f9da4f16..91fe778788c717162809dad75ed6ea614c14706a 100644 (file)
@@ -62,8 +62,8 @@ CURLcode Curl_hsts_loadcb(struct Curl_easy *data,
 CURLcode Curl_hsts_loadfiles(struct Curl_easy *data);
 #else
 #define Curl_hsts_cleanup(x)
-#define Curl_hsts_loadcb(x,y) CURLE_OK
-#define Curl_hsts_save(x,y,z)
+#define Curl_hsts_loadcb(x, y) CURLE_OK
+#define Curl_hsts_save(x, y, z)
 #define Curl_hsts_loadfiles(x) CURLE_OK
 #endif /* CURL_DISABLE_HTTP || CURL_DISABLE_HSTS */
 #endif /* HEADER_CURL_HSTS_H */
index fcae0a57c25c7e8f3654e46cc00fff737f5f31b7..3178ca59e99328158af95db806645b1e84fc5965 100644 (file)
@@ -111,7 +111,6 @@ static CURLcode http_statusline(struct Curl_easy *data,
 static CURLcode http_target(struct Curl_easy *data, struct dynbuf *req);
 static CURLcode http_useragent(struct Curl_easy *data);
 
-
 /*
  * HTTP handler interface.
  */
@@ -138,7 +137,7 @@ const struct Curl_handler Curl_handler_http = {
   CURLPROTO_HTTP,                       /* protocol */
   CURLPROTO_HTTP,                       /* family */
   PROTOPT_CREDSPERREQUEST |             /* flags */
-  PROTOPT_USERPWDCTRL | PROTOPT_CONN_REUSE
+    PROTOPT_USERPWDCTRL | PROTOPT_CONN_REUSE
 
 };
 
@@ -169,7 +168,7 @@ const struct Curl_handler Curl_handler_https = {
   CURLPROTO_HTTPS,                      /* protocol */
   CURLPROTO_HTTP,                       /* family */
   PROTOPT_SSL | PROTOPT_CREDSPERREQUEST | PROTOPT_ALPN | /* flags */
-  PROTOPT_USERPWDCTRL | PROTOPT_CONN_REUSE
+    PROTOPT_USERPWDCTRL | PROTOPT_CONN_REUSE
 };
 
 #endif
@@ -255,7 +254,7 @@ char *Curl_checkProxyheaders(struct Curl_easy *data,
 }
 #else
 /* disabled */
-#define Curl_checkProxyheaders(x,y,z,a) NULL
+#define Curl_checkProxyheaders(x, y, z, a) NULL
 #endif
 
 static bool http_header_is_empty(const char *header)
@@ -599,7 +598,6 @@ CURLcode Curl_http_auth_act(struct Curl_easy *data)
       data->state.authproblem = TRUE;
     else
       data->info.proxyauthpicked = data->state.authproxy.picked;
-
   }
 #endif
 
@@ -617,7 +615,7 @@ CURLcode Curl_http_auth_act(struct Curl_easy *data)
       return CURLE_OUT_OF_MEMORY;
   }
   else if((data->req.httpcode < 300) &&
-          (!data->state.authhost.done) &&
+          !data->state.authhost.done &&
           data->req.authneg) {
     /* no (known) authentication available,
        authentication is not "done" yet and
@@ -645,13 +643,12 @@ CURLcode Curl_http_auth_act(struct Curl_easy *data)
  * Output the correct authentication header depending on the auth type
  * and whether or not it is to a proxy.
  */
-static CURLcode
-output_auth_headers(struct Curl_easy *data,
-                    struct connectdata *conn,
-                    struct auth *authstatus,
-                    const char *request,
-                    const char *path,
-                    bool proxy)
+static CURLcode output_auth_headers(struct Curl_easy *data,
+                                    struct connectdata *conn,
+                                    struct auth *authstatus,
+                                    const char *request,
+                                    const char *path,
+                                    bool proxy)
 {
   const char *auth = NULL;
   CURLcode result = CURLE_OK;
@@ -865,13 +862,12 @@ Curl_http_output_auth(struct Curl_easy *data,
 
 #else
 /* when disabled */
-CURLcode
-Curl_http_output_auth(struct Curl_easy *data,
-                      struct connectdata *conn,
-                      const char *request,
-                      Curl_HttpReq httpreq,
-                      const char *path,
-                      bool proxytunnel)
+CURLcode Curl_http_output_auth(struct Curl_easy *data,
+                               struct connectdata *conn,
+                               const char *request,
+                               Curl_HttpReq httpreq,
+                               const char *path,
+                               bool proxytunnel)
 {
   (void)data;
   (void)conn;
@@ -1398,7 +1394,7 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl,
     /* 300 - Multiple Choices */
     /* 306 - Not used */
     /* 307 - Temporary Redirect */
-  default:  /* for all above (and the unknown ones) */
+  default: /* for all above (and the unknown ones) */
     /* Some codes are explicitly mentioned since I have checked RFC2616 and
      * they seem to be OK to POST to.
      */
@@ -1420,10 +1416,10 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl,
      * This behavior is forbidden by RFC1945 and the obsolete RFC2616, and
      * can be overridden with CURLOPT_POSTREDIR.
      */
-    if((data->state.httpreq == HTTPREQ_POST
-        || data->state.httpreq == HTTPREQ_POST_FORM
-        || data->state.httpreq == HTTPREQ_POST_MIME)
-       && !(data->set.keep_post & CURL_REDIR_POST_301)) {
+    if((data->state.httpreq == HTTPREQ_POST ||
+        data->state.httpreq == HTTPREQ_POST_FORM ||
+        data->state.httpreq == HTTPREQ_POST_MIME) &&
+       !(data->set.keep_post & CURL_REDIR_POST_301)) {
       http_switch_to_get(data, 301);
       switch_to_get = TRUE;
     }
@@ -1445,10 +1441,10 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl,
      * This behavior is forbidden by RFC1945 and the obsolete RFC2616, and
      * can be overridden with CURLOPT_POSTREDIR.
      */
-    if((data->state.httpreq == HTTPREQ_POST
-        || data->state.httpreq == HTTPREQ_POST_FORM
-        || data->state.httpreq == HTTPREQ_POST_MIME)
-       && !(data->set.keep_post & CURL_REDIR_POST_302)) {
+    if((data->state.httpreq == HTTPREQ_POST ||
+        data->state.httpreq == HTTPREQ_POST_FORM ||
+        data->state.httpreq == HTTPREQ_POST_MIME) &&
+       !(data->set.keep_post & CURL_REDIR_POST_302)) {
       http_switch_to_get(data, 302);
       switch_to_get = TRUE;
     }
@@ -1502,12 +1498,11 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl,
  * Returns TRUE if 'headerline' contains the 'header' with given 'content'.
  * Pass headers WITH the colon.
  */
-bool
-Curl_compareheader(const char *headerline, /* line to check */
-                   const char *header,  /* header keyword _with_ colon */
-                   const size_t hlen,   /* len of the keyword in bytes */
-                   const char *content, /* content string to find */
-                   const size_t clen)   /* len of the content in bytes */
+bool Curl_compareheader(const char *headerline, /* line to check */
+                        const char *header, /* header keyword _with_ colon */
+                        const size_t hlen, /* len of the keyword in bytes */
+                        const char *content, /* content string to find */
+                        const size_t clen) /* len of the content in bytes */
 {
   /* RFC2616, section 4.2 says: "Each header field consists of a name followed
    * by a colon (":") and the field value. Field names are case-insensitive.
@@ -1651,14 +1646,14 @@ static unsigned char http_request_version(struct Curl_easy *data)
 static const char *get_http_string(int httpversion)
 {
   switch(httpversion) {
-    case 30:
-      return "3";
-    case 20:
-      return "2";
-    case 11:
-      return "1.1";
-    default:
-      return "1.0";
+  case 30:
+    return "3";
+  case 20:
+    return "2";
+  case 11:
+    return "1.1";
+  default:
+    return "1.0";
   }
 }
 
@@ -1841,7 +1836,7 @@ CURLcode Curl_add_timecondition(struct Curl_easy *data,
   curl_msnprintf(datestr, sizeof(datestr),
                  "%s: %s, %02d %s %4d %02d:%02d:%02d GMT\r\n",
                  condp,
-                 Curl_wkday[tm->tm_wday ? tm->tm_wday-1 : 6],
+                 Curl_wkday[tm->tm_wday ? tm->tm_wday - 1 : 6],
                  tm->tm_mday,
                  Curl_month[tm->tm_mon],
                  tm->tm_year + 1900,
@@ -1869,11 +1864,11 @@ void Curl_http_method(struct Curl_easy *data,
   Curl_HttpReq httpreq = (Curl_HttpReq)data->state.httpreq;
   const char *request;
 #ifndef CURL_DISABLE_WEBSOCKETS
-  if(data->conn->handler->protocol&(CURLPROTO_WS|CURLPROTO_WSS))
+  if(data->conn->handler->protocol & (CURLPROTO_WS | CURLPROTO_WSS))
     httpreq = HTTPREQ_GET;
   else
 #endif
-  if((data->conn->handler->protocol&(PROTO_FAMILY_HTTP|CURLPROTO_FTP)) &&
+  if((data->conn->handler->protocol & (PROTO_FAMILY_HTTP | CURLPROTO_FTP)) &&
      data->state.upload)
     httpreq = HTTPREQ_PUT;
 
@@ -1923,7 +1918,6 @@ static CURLcode http_useragent(struct Curl_easy *data)
   return CURLE_OK;
 }
 
-
 static CURLcode http_set_aptr_host(struct Curl_easy *data)
 {
   struct connectdata *conn = data->conn;
@@ -1993,10 +1987,10 @@ static CURLcode http_set_aptr_host(struct Curl_easy *data)
        [brackets] if the hostname is a plain IPv6-address. RFC2732-style. */
     const char *host = conn->host.name;
 
-    if(((conn->given->protocol&(CURLPROTO_HTTPS|CURLPROTO_WSS)) &&
+    if(((conn->given->protocol & (CURLPROTO_HTTPS | CURLPROTO_WSS)) &&
         (conn->remote_port == PORT_HTTPS)) ||
-       ((conn->given->protocol&(CURLPROTO_HTTP|CURLPROTO_WS)) &&
-        (conn->remote_port == PORT_HTTP)) )
+       ((conn->given->protocol & (CURLPROTO_HTTP | CURLPROTO_WS)) &&
+        (conn->remote_port == PORT_HTTP)))
       /* if(HTTPS on port 443) OR (HTTP on port 80) then do not include
          the port number in the host string */
       aptr->host = curl_maprintf("Host: %s%s%s\r\n",
@@ -2532,7 +2526,7 @@ static CURLcode http_cookies(struct Curl_easy *data,
   return result;
 }
 #else
-#define http_cookies(a,b) CURLE_OK
+#define http_cookies(a, b) CURLE_OK
 #endif
 
 static CURLcode http_range(struct Curl_easy *data,
@@ -2579,7 +2573,7 @@ static CURLcode http_range(struct Curl_easy *data,
         data->state.aptr.rangeline =
           curl_maprintf("Content-Range: bytes %s%" FMT_OFF_T "/"
                         "%" FMT_OFF_T "\r\n",
-                        data->state.range, total_len-1, total_len);
+                        data->state.range, total_len - 1, total_len);
       }
       else {
         /* Range was selected and then we just pass the incoming range and
@@ -2909,7 +2903,7 @@ static CURLcode http_add_hd(struct Curl_easy *data,
       result = Curl_http2_request_upgrade(req, data);
     }
 #ifndef CURL_DISABLE_WEBSOCKETS
-    if(!result && conn->handler->protocol&(CURLPROTO_WS|CURLPROTO_WSS))
+    if(!result && conn->handler->protocol & (CURLPROTO_WS | CURLPROTO_WSS))
       result = Curl_ws_request(data, req);
 #endif
     break;
@@ -3057,7 +3051,6 @@ typedef enum {
   STATUS_BAD /* not a status line */
 } statusline;
 
-
 /* Check a string for a prefix. Check no more than 'len' bytes */
 static bool checkprefixmax(const char *prefix, const char *buffer, size_t len)
 {
@@ -3070,9 +3063,8 @@ static bool checkprefixmax(const char *prefix, const char *buffer, size_t len)
  *
  * Returns TRUE if member of the list matches prefix of string
  */
-static statusline
-checkhttpprefix(struct Curl_easy *data,
-                const char *s, size_t len)
+static statusline checkhttpprefix(struct Curl_easy *data,
+                                  const char *s, size_t len)
 {
   struct curl_slist *head = data->set.http200aliases;
   statusline rc = STATUS_BAD;
@@ -3093,9 +3085,8 @@ checkhttpprefix(struct Curl_easy *data,
 }
 
 #ifndef CURL_DISABLE_RTSP
-static statusline
-checkrtspprefix(struct Curl_easy *data,
-                const char *s, size_t len)
+static statusline checkrtspprefix(struct Curl_easy *data,
+                                  const char *s, size_t len)
 {
   statusline result = STATUS_BAD;
   statusline onmatch = len >= 5 ? STATUS_DONE : STATUS_UNKNOWN;
@@ -3107,9 +3098,9 @@ checkrtspprefix(struct Curl_easy *data,
 }
 #endif /* CURL_DISABLE_RTSP */
 
-static statusline
-checkprotoprefix(struct Curl_easy *data, struct connectdata *conn,
-                 const char *s, size_t len)
+static statusline checkprotoprefix(struct Curl_easy *data,
+                                   struct connectdata *conn,
+                                   const char *s, size_t len)
 {
 #ifndef CURL_DISABLE_RTSP
   if(conn->handler->protocol & CURLPROTO_RTSP)
@@ -3123,17 +3114,17 @@ checkprotoprefix(struct Curl_easy *data, struct connectdata *conn,
 
 /* HTTP header has field name `n` (a string constant) */
 #define HD_IS(hd, hdlen, n) \
-  (((hdlen) >= (sizeof(n)-1)) && curl_strnequal((n), (hd), (sizeof(n)-1)))
+  (((hdlen) >= (sizeof(n) - 1)) && curl_strnequal((n), (hd), (sizeof(n) - 1)))
 
 #define HD_VAL(hd, hdlen, n) \
-  ((((hdlen) >= (sizeof(n)-1)) && \
-    curl_strnequal((n), (hd), (sizeof(n)-1)))? (hd + (sizeof(n)-1)) : NULL)
+  ((((hdlen) >= (sizeof(n) - 1)) && \
+    curl_strnequal((n), (hd), (sizeof(n) - 1)))? (hd + (sizeof(n) - 1)) : NULL)
 
 /* HTTP header has field name `n` (a string constant) and contains `v`
  * (a string constant) in its value(s) */
 #define HD_IS_AND_SAYS(hd, hdlen, n, v) \
   (HD_IS(hd, hdlen, n) && \
-   ((hdlen) > ((sizeof(n)-1) + (sizeof(v)-1))) && \
+   ((hdlen) > ((sizeof(n) - 1) + (sizeof(v) - 1))) && \
    Curl_compareheader(hd, STRCONST(n), STRCONST(v)))
 
 /*
@@ -3664,15 +3655,15 @@ static CURLcode http_statusline(struct Curl_easy *data,
 #endif
     /* no major version switch mid-connection */
     if(k->httpversion_sent &&
-       (k->httpversion/10 != k->httpversion_sent/10)) {
+       (k->httpversion / 10 != k->httpversion_sent / 10)) {
       failf(data, "Version mismatch (from HTTP/%u to HTTP/%u)",
-            k->httpversion_sent/10, k->httpversion/10);
+            k->httpversion_sent / 10, k->httpversion / 10);
       return CURLE_WEIRD_SERVER_REPLY;
     }
     break;
   default:
     failf(data, "Unsupported HTTP version (%u.%d) in response",
-          k->httpversion/10, k->httpversion%10);
+          k->httpversion / 10, k->httpversion % 10);
     return CURLE_UNSUPPORTED_PROTOCOL;
   }
 
@@ -3825,7 +3816,7 @@ static CURLcode http_write_header(struct Curl_easy *data,
   Curl_debug(data, CURLINFO_HEADER_IN, hd, hdlen);
 
   writetype = CLIENTWRITE_HEADER |
-    ((data->req.httpcode/100 == 1) ? CLIENTWRITE_1XX : 0);
+    ((data->req.httpcode / 100 == 1) ? CLIENTWRITE_1XX : 0);
 
   result = Curl_client_write(data, writetype, hd, hdlen);
   if(result)
@@ -4011,8 +4002,7 @@ static CURLcode http_on_response(struct Curl_easy *data,
 
   /* Check if this response means the transfer errored. */
   if(http_should_fail(data, data->req.httpcode)) {
-    failf(data, "The requested URL returned error: %d",
-          k->httpcode);
+    failf(data, "The requested URL returned error: %d", k->httpcode);
     result = CURLE_HTTP_RETURNED_ERROR;
     goto out;
   }
@@ -4056,8 +4046,7 @@ static CURLcode http_on_response(struct Curl_easy *data,
             }
             else {
               infof(data, "Got HTTP failure 417 while sending data");
-              streamclose(conn,
-                          "Stop sending data before everything sent");
+              streamclose(conn, "Stop sending data before everything sent");
               result = http_perhapsrewind(data, conn);
               if(result)
                 goto out;
@@ -4095,7 +4084,6 @@ static CURLcode http_on_response(struct Curl_easy *data,
       infof(data, "Keep sending data to get tossed away");
       k->keepon |= KEEP_SEND;
     }
-
   }
 
   /* If we requested a "no body", this is a good time to get
@@ -4291,7 +4279,7 @@ static CURLcode http_rw_hd(struct Curl_easy *data,
    */
   Curl_debug(data, CURLINFO_HEADER_IN, hd, hdlen);
 
-  if(k->httpcode/100 == 1)
+  if(k->httpcode / 100 == 1)
     writetype |= CLIENTWRITE_1XX;
   result = Curl_client_write(data, writetype, hd, hdlen);
   if(result)
@@ -4785,8 +4773,7 @@ CURLcode Curl_http_req_to_h2(struct dynhds *h2_headers,
       infof(data, "set pseudo header %s to %s", HTTP_PSEUDO_SCHEME, scheme);
     }
     else {
-      scheme = Curl_conn_is_ssl(data->conn, FIRSTSOCKET) ?
-        "https" : "http";
+      scheme = Curl_conn_is_ssl(data->conn, FIRSTSOCKET) ? "https" : "http";
     }
   }
 
@@ -4969,8 +4956,7 @@ static CURLcode http_exp100_add_reader(struct Curl_easy *data)
   struct Curl_creader *reader = NULL;
   CURLcode result;
 
-  result = Curl_creader_create(&reader, data, &cr_exp100,
-                               CURL_CR_PROTOCOL);
+  result = Curl_creader_create(&reader, data, &cr_exp100, CURL_CR_PROTOCOL);
   if(!result)
     result = Curl_creader_add(data, reader);
   if(!result) {
index ef41d7bb22493c55fd8cfeebda691e3ca0fb11b3..1c7ebdf8d7f10839867546f03302f7ee50e15ed6 100644 (file)
@@ -38,7 +38,6 @@ typedef enum {
   HTTPREQ_HEAD
 } Curl_HttpReq;
 
-
 /* When redirecting transfers. */
 typedef enum {
   FOLLOW_NONE,  /* not used within the function, just a placeholder to
@@ -55,7 +54,6 @@ typedef enum {
 /* bitmask of CURL_HTTP_V* values */
 typedef unsigned char http_majors;
 
-
 #ifndef CURL_DISABLE_HTTP
 
 #ifdef USE_HTTP3
@@ -140,7 +138,7 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl,
    selected to use no auth at all. Ie, we actively select no auth, as opposed
    to not having one selected. The other CURLAUTH_* defines are present in the
    public curl/curl.h header. */
-#define CURLAUTH_PICKNONE (1<<30) /* do not use auth */
+#define CURLAUTH_PICKNONE (1 << 30) /* do not use auth */
 
 /* MAX_INITIAL_POST_SIZE indicates the number of bytes that will make the POST
    data get included in the initial data chunk sent to the server. If the
@@ -155,7 +153,7 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl,
    It must not be greater than 64K to work on VMS.
 */
 #ifndef MAX_INITIAL_POST_SIZE
-#define MAX_INITIAL_POST_SIZE (64*1024)
+#define MAX_INITIAL_POST_SIZE (64 * 1024)
 #endif
 
 /* EXPECT_100_THRESHOLD is the request body size limit for when libcurl will
@@ -164,13 +162,13 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl,
  *
  */
 #ifndef EXPECT_100_THRESHOLD
-#define EXPECT_100_THRESHOLD (1024*1024)
+#define EXPECT_100_THRESHOLD (1024 * 1024)
 #endif
 
 /* MAX_HTTP_RESP_HEADER_SIZE is the maximum size of all response headers
    combined that libcurl allows for a single HTTP response, any HTTP
    version. This count includes CONNECT response headers. */
-#define MAX_HTTP_RESP_HEADER_SIZE (300*1024)
+#define MAX_HTTP_RESP_HEADER_SIZE (300 * 1024)
 
 /* MAX_HTTP_RESP_HEADER_COUNT is the maximum number of response headers that
    libcurl allows for a single HTTP response, including CONNECT and
@@ -243,11 +241,11 @@ CURLcode Curl_http_req_make2(struct httpreq **preq,
 
 void Curl_http_req_free(struct httpreq *req);
 
-#define HTTP_PSEUDO_METHOD ":method"
-#define HTTP_PSEUDO_SCHEME ":scheme"
+#define HTTP_PSEUDO_METHOD    ":method"
+#define HTTP_PSEUDO_SCHEME    ":scheme"
 #define HTTP_PSEUDO_AUTHORITY ":authority"
-#define HTTP_PSEUDO_PATH ":path"
-#define HTTP_PSEUDO_STATUS ":status"
+#define HTTP_PSEUDO_PATH      ":path"
+#define HTTP_PSEUDO_STATUS    ":status"
 
 /**
  * Create the list of HTTP/2 headers which represent the request,
index 657a674105fa4ce807ae283c15a26434b6e99929..693a0dd7ef6d832f12d75ad9c742b378cb77a141 100644 (file)
@@ -33,7 +33,7 @@
 #include "urlapi-int.h"
 
 
-#define H1_MAX_URL_LEN   (8*1024)
+#define H1_MAX_URL_LEN (8 * 1024)
 
 void Curl_h1_req_parse_init(struct h1_req_parser *parser, size_t max_line_len)
 {
@@ -227,8 +227,8 @@ static CURLcode start_req(struct h1_req_parser *parser,
         result = CURLE_OUT_OF_MEMORY;
         goto out;
       }
-      url_options = (CURLU_NON_SUPPORT_SCHEME|
-                     CURLU_PATH_AS_IS|
+      url_options = (CURLU_NON_SUPPORT_SCHEME |
+                     CURLU_PATH_AS_IS |
                      CURLU_NO_DEFAULT_PORT);
       if(!(options & H1_PARSE_OPT_STRICT))
         url_options |= CURLU_ALLOW_SPACE;
index 38c7d82785fed94956a48ff641106f7e31fb367a..a3ff8c85294e04a4b606706701f52dd859b006e4 100644 (file)
@@ -53,7 +53,7 @@
 #endif
 
 #ifdef CURL_DISABLE_VERBOSE_STRINGS
-#define nghttp2_session_callbacks_set_error_callback(x,y)
+#define nghttp2_session_callbacks_set_error_callback(x, y)
 #endif
 
 #if (NGHTTP2_VERSION_NUM >= 0x010c00)
@@ -91,7 +91,7 @@
  * is blocked from sending us any data. See #10988 for an issue with this. */
 #define HTTP2_HUGE_WINDOW_SIZE (100 * H2_STREAM_WINDOW_SIZE_MAX)
 
-#define H2_SETTINGS_IV_LEN  3
+#define H2_SETTINGS_IV_LEN 3
 #define H2_BINSETTINGS_LEN 80
 
 struct cf_h2_ctx {
@@ -122,8 +122,7 @@ struct cf_h2_ctx {
 
 /* How to access `call_data` from a cf_h2 filter */
 #undef CF_CTX_CALL_DATA
-#define CF_CTX_CALL_DATA(cf)  \
-  ((struct cf_h2_ctx *)(cf)->ctx)->call_data
+#define CF_CTX_CALL_DATA(cf) ((struct cf_h2_ctx *)(cf)->ctx)->call_data
 
 static void h2_stream_hash_free(unsigned int id, void *stream);
 
@@ -248,7 +247,7 @@ struct h2_stream_ctx {
   BIT(write_paused);  /* stream write is paused */
 };
 
-#define H2_STREAM_CTX(ctx,data)                                         \
+#define H2_STREAM_CTX(ctx, data)                                        \
   ((struct h2_stream_ctx *)(                                            \
     data? Curl_uint32_hash_get(&(ctx)->streams, (data)->mid) : NULL))
 
@@ -305,8 +304,7 @@ static void h2_stream_hash_free(unsigned int id, void *stream)
 static int32_t cf_h2_get_desired_local_win(struct Curl_cfilter *cf,
                                            struct Curl_easy *data)
 {
-  curl_off_t avail = Curl_rlimit_avail(&data->progress.dl.rlimit,
-                                       curlx_now());
+  curl_off_t avail = Curl_rlimit_avail(&data->progress.dl.rlimit, curlx_now());
 
   (void)cf;
   if(avail < CURL_OFF_T_MAX) { /* limit in place */
@@ -379,7 +377,6 @@ static CURLcode cf_h2_update_local_win(struct Curl_cfilter *cf,
 }
 #endif /* !NGHTTP2_HAS_SET_LOCAL_WINDOW_SIZE */
 
-
 static CURLcode http2_data_setup(struct Curl_cfilter *cf,
                                  struct Curl_easy *data,
                                  struct h2_stream_ctx **pstream)
@@ -447,8 +444,8 @@ static int h2_client_new(struct Curl_cfilter *cf,
 {
   struct cf_h2_ctx *ctx = cf->ctx;
   nghttp2_option *o;
-  nghttp2_mem mem = {NULL, Curl_nghttp2_malloc, Curl_nghttp2_free,
-    Curl_nghttp2_calloc, Curl_nghttp2_realloc};
+  nghttp2_mem mem = { NULL, Curl_nghttp2_malloc, Curl_nghttp2_free,
+                      Curl_nghttp2_calloc, Curl_nghttp2_realloc };
 
   int rc = nghttp2_option_new(&o);
   if(rc)
@@ -806,7 +803,6 @@ static ssize_t send_callback(nghttp2_session *h2,
     NGHTTP2_ERR_CALLBACK_FAILURE : (ssize_t)nwritten;
 }
 
-
 /* We pass a pointer to this struct in the push callback, but the contents of
    the struct are hidden from the user. */
 struct curl_pushheaders {
@@ -1217,72 +1213,72 @@ static CURLcode on_stream_frame(struct Curl_cfilter *cf,
 static int fr_print(const nghttp2_frame *frame, char *buffer, size_t blen)
 {
   switch(frame->hd.type) {
-    case NGHTTP2_DATA: {
-      return curl_msnprintf(buffer, blen,
-                            "FRAME[DATA, len=%d, eos=%d, padlen=%d]",
-                            (int)frame->hd.length,
-                            !!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM),
-                            (int)frame->data.padlen);
-    }
-    case NGHTTP2_HEADERS: {
-      return curl_msnprintf(buffer, blen,
-                            "FRAME[HEADERS, len=%d, hend=%d, eos=%d]",
-                            (int)frame->hd.length,
-                            !!(frame->hd.flags & NGHTTP2_FLAG_END_HEADERS),
-                            !!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM));
-    }
-    case NGHTTP2_PRIORITY: {
-      return curl_msnprintf(buffer, blen,
-                            "FRAME[PRIORITY, len=%d, flags=%d]",
-                            (int)frame->hd.length, frame->hd.flags);
-    }
-    case NGHTTP2_RST_STREAM: {
-      return curl_msnprintf(buffer, blen,
-                            "FRAME[RST_STREAM, len=%d, flags=%d, error=%u]",
-                            (int)frame->hd.length, frame->hd.flags,
-                            frame->rst_stream.error_code);
-    }
-    case NGHTTP2_SETTINGS: {
-      if(frame->hd.flags & NGHTTP2_FLAG_ACK) {
-        return curl_msnprintf(buffer, blen, "FRAME[SETTINGS, ack=1]");
-      }
-      return curl_msnprintf(buffer, blen,
-                            "FRAME[SETTINGS, len=%d]", (int)frame->hd.length);
-    }
-    case NGHTTP2_PUSH_PROMISE: {
-      return curl_msnprintf(buffer, blen,
-                            "FRAME[PUSH_PROMISE, len=%d, hend=%d]",
-                            (int)frame->hd.length,
-                            !!(frame->hd.flags & NGHTTP2_FLAG_END_HEADERS));
-    }
-    case NGHTTP2_PING: {
-      return curl_msnprintf(buffer, blen,
-                            "FRAME[PING, len=%d, ack=%d]",
-                            (int)frame->hd.length,
-                            frame->hd.flags&NGHTTP2_FLAG_ACK);
-    }
-    case NGHTTP2_GOAWAY: {
-      char scratch[128];
-      size_t s_len = CURL_ARRAYSIZE(scratch);
-      size_t len = (frame->goaway.opaque_data_len < s_len) ?
-        frame->goaway.opaque_data_len : s_len-1;
-      if(len)
-        memcpy(scratch, frame->goaway.opaque_data, len);
-      scratch[len] = '\0';
-      return curl_msnprintf(buffer, blen,
-                            "FRAME[GOAWAY, error=%d, reason='%s', "
-                            "last_stream=%d]", frame->goaway.error_code,
-                            scratch, frame->goaway.last_stream_id);
-    }
-    case NGHTTP2_WINDOW_UPDATE: {
-      return curl_msnprintf(buffer, blen,
-                            "FRAME[WINDOW_UPDATE, incr=%d]",
-                            frame->window_update.window_size_increment);
-    }
-    default:
-      return curl_msnprintf(buffer, blen, "FRAME[%d, len=%d, flags=%d]",
-                            frame->hd.type, (int)frame->hd.length,
-                            frame->hd.flags);
+  case NGHTTP2_DATA: {
+    return curl_msnprintf(buffer, blen,
+                          "FRAME[DATA, len=%d, eos=%d, padlen=%d]",
+                          (int)frame->hd.length,
+                          !!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM),
+                          (int)frame->data.padlen);
+  }
+  case NGHTTP2_HEADERS: {
+    return curl_msnprintf(buffer, blen,
+                          "FRAME[HEADERS, len=%d, hend=%d, eos=%d]",
+                          (int)frame->hd.length,
+                          !!(frame->hd.flags & NGHTTP2_FLAG_END_HEADERS),
+                          !!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM));
+  }
+  case NGHTTP2_PRIORITY: {
+    return curl_msnprintf(buffer, blen,
+                          "FRAME[PRIORITY, len=%d, flags=%d]",
+                          (int)frame->hd.length, frame->hd.flags);
+  }
+  case NGHTTP2_RST_STREAM: {
+    return curl_msnprintf(buffer, blen,
+                          "FRAME[RST_STREAM, len=%d, flags=%d, error=%u]",
+                          (int)frame->hd.length, frame->hd.flags,
+                          frame->rst_stream.error_code);
+  }
+  case NGHTTP2_SETTINGS: {
+    if(frame->hd.flags & NGHTTP2_FLAG_ACK) {
+      return curl_msnprintf(buffer, blen, "FRAME[SETTINGS, ack=1]");
+    }
+    return curl_msnprintf(buffer, blen,
+                          "FRAME[SETTINGS, len=%d]", (int)frame->hd.length);
+  }
+  case NGHTTP2_PUSH_PROMISE: {
+    return curl_msnprintf(buffer, blen,
+                          "FRAME[PUSH_PROMISE, len=%d, hend=%d]",
+                          (int)frame->hd.length,
+                          !!(frame->hd.flags & NGHTTP2_FLAG_END_HEADERS));
+  }
+  case NGHTTP2_PING: {
+    return curl_msnprintf(buffer, blen,
+                          "FRAME[PING, len=%d, ack=%d]",
+                          (int)frame->hd.length,
+                          frame->hd.flags & NGHTTP2_FLAG_ACK);
+  }
+  case NGHTTP2_GOAWAY: {
+    char scratch[128];
+    size_t s_len = CURL_ARRAYSIZE(scratch);
+    size_t len = (frame->goaway.opaque_data_len < s_len) ?
+      frame->goaway.opaque_data_len : s_len - 1;
+    if(len)
+      memcpy(scratch, frame->goaway.opaque_data, len);
+    scratch[len] = '\0';
+    return curl_msnprintf(buffer, blen,
+                          "FRAME[GOAWAY, error=%d, reason='%s', "
+                          "last_stream=%d]", frame->goaway.error_code,
+                          scratch, frame->goaway.last_stream_id);
+  }
+  case NGHTTP2_WINDOW_UPDATE: {
+    return curl_msnprintf(buffer, blen,
+                          "FRAME[WINDOW_UPDATE, incr=%d]",
+                          frame->window_update.window_size_increment);
+  }
+  default:
+    return curl_msnprintf(buffer, blen, "FRAME[%d, len=%d, flags=%d]",
+                          frame->hd.type, (int)frame->hd.length,
+                          frame->hd.flags);
   }
 }
 
@@ -1298,7 +1294,7 @@ static int on_frame_send(nghttp2_session *session, const nghttp2_frame *frame,
   if(data && Curl_trc_cf_is_verbose(cf, data)) {
     char buffer[256];
     int len;
-    len = fr_print(frame, buffer, sizeof(buffer)-1);
+    len = fr_print(frame, buffer, sizeof(buffer) - 1);
     buffer[len] = 0;
     CURL_TRC_CF(data, cf, "[%d] -> %s", frame->hd.stream_id, buffer);
   }
@@ -1326,9 +1322,9 @@ static int on_frame_recv(nghttp2_session *session, const nghttp2_frame *frame,
   if(Curl_trc_cf_is_verbose(cf, data)) {
     char buffer[256];
     int len;
-    len = fr_print(frame, buffer, sizeof(buffer)-1);
+    len = fr_print(frame, buffer, sizeof(buffer) - 1);
     buffer[len] = 0;
-    CURL_TRC_CF(data, cf, "[%d] <- %s",frame->hd.stream_id, buffer);
+    CURL_TRC_CF(data, cf, "[%d] <- %s", frame->hd.stream_id, buffer);
   }
 #endif /* !CURL_DISABLE_VERBOSE_STRINGS */
 
@@ -1340,9 +1336,9 @@ static int on_frame_recv(nghttp2_session *session, const nghttp2_frame *frame,
       if(!(frame->hd.flags & NGHTTP2_FLAG_ACK)) {
         uint32_t max_conn = ctx->max_concurrent_streams;
         ctx->max_concurrent_streams = nghttp2_session_get_remote_settings(
-            session, NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS);
+          session, NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS);
         ctx->enable_push = nghttp2_session_get_remote_settings(
-            session, NGHTTP2_SETTINGS_ENABLE_PUSH) != 0;
+          session, NGHTTP2_SETTINGS_ENABLE_PUSH) != 0;
         CURL_TRC_CF(data, cf, "[0] MAX_CONCURRENT_STREAMS: %d",
                     ctx->max_concurrent_streams);
         CURL_TRC_CF(data, cf, "[0] ENABLE_PUSH: %s",
@@ -1369,7 +1365,7 @@ static int on_frame_recv(nghttp2_session *session, const nghttp2_frame *frame,
       ctx->remote_max_sid = frame->goaway.last_stream_id;
       if(data) {
         infof(data, "received GOAWAY, error=%u, last_stream=%u",
-                    ctx->goaway_error, ctx->remote_max_sid);
+              ctx->goaway_error, ctx->remote_max_sid);
         Curl_multi_connchanged(data->multi);
       }
       break;
@@ -1403,7 +1399,7 @@ static int cf_h2_on_invalid_frame_recv(nghttp2_session *session,
 #ifndef CURL_DISABLE_VERBOSE_STRINGS
     char buffer[256];
     int len;
-    len = fr_print(frame, buffer, sizeof(buffer)-1);
+    len = fr_print(frame, buffer, sizeof(buffer) - 1);
     buffer[len] = 0;
     failf(data, "[HTTP2] [%d] received invalid frame: %s, error %d: %s",
           stream_id, buffer, ngerr, nghttp2_strerror(ngerr));
@@ -1440,8 +1436,7 @@ static int on_data_chunk_recv(nghttp2_session *session, uint8_t flags,
     /* Receiving a Stream ID not in the hash should not happen - unless
        we have aborted a transfer artificially and there were more data
        in the pipeline. Silently ignore. */
-    CURL_TRC_CF(CF_DATA_CURRENT(cf), cf, "[%d] Data for unknown",
-                stream_id);
+    CURL_TRC_CF(CF_DATA_CURRENT(cf), cf, "[%d] Data for unknown", stream_id);
     /* consumed explicitly as no one will read it */
     nghttp2_session_consume(session, stream_id, len);
     return 0;
@@ -1594,7 +1589,7 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,
   if(frame->hd.type == NGHTTP2_PUSH_PROMISE) {
     char *h;
 
-    if((namelen == (sizeof(HTTP_PSEUDO_AUTHORITY)-1)) &&
+    if((namelen == (sizeof(HTTP_PSEUDO_AUTHORITY) - 1)) &&
        !strncmp(HTTP_PSEUDO_AUTHORITY, (const char *)name, namelen)) {
       /* pseudo headers are lower case */
       int rc = 0;
@@ -1900,7 +1895,8 @@ static CURLcode http2_handle_stream_close(struct Curl_cfilter *cf,
         break;
       Curl_debug(data, CURLINFO_HEADER_IN, curlx_dyn_ptr(&dbuf),
                  curlx_dyn_len(&dbuf));
-      result = Curl_client_write(data, CLIENTWRITE_HEADER|CLIENTWRITE_TRAILER,
+      result = Curl_client_write(data,
+                                 CLIENTWRITE_HEADER | CLIENTWRITE_TRAILER,
                                  curlx_dyn_ptr(&dbuf), curlx_dyn_len(&dbuf));
       if(result)
         break;
@@ -1967,7 +1963,7 @@ static CURLcode h2_progress_egress(struct Curl_cfilter *cf,
   if(stream && stream->id > 0 &&
      ((sweight_wanted(data) != sweight_in_effect(data)) ||
       (data->set.priority.exclusive != data->state.priority.exclusive) ||
-      (data->set.priority.parent != data->state.priority.parent)) ) {
+      (data->set.priority.parent != data->state.priority.parent))) {
     /* send new weight and/or dependency */
     nghttp2_priority_spec pri_spec;
 
index 93cc2d44f2592c62a99bb2b3e94a30f0641b0dc8..147d7f76d5389d44bc3421c2e0c3f3ae19ec035c 100644 (file)
@@ -65,10 +65,10 @@ extern struct Curl_cftype Curl_cft_nghttp2;
 
 #define Curl_http2_may_switch(a) FALSE
 
-#define Curl_http2_request_upgrade(x,y) CURLE_UNSUPPORTED_PROTOCOL
-#define Curl_http2_switch(a)            CURLE_UNSUPPORTED_PROTOCOL
-#define Curl_http2_upgrade(a,b,c,d,e)   CURLE_UNSUPPORTED_PROTOCOL
-#define Curl_h2_http_1_1_error(x) 0
+#define Curl_http2_request_upgrade(x, y)  CURLE_UNSUPPORTED_PROTOCOL
+#define Curl_http2_switch(a)              CURLE_UNSUPPORTED_PROTOCOL
+#define Curl_http2_upgrade(a, b, c, d, e) CURLE_UNSUPPORTED_PROTOCOL
+#define Curl_h2_http_1_1_error(x)         0
 #endif
 
 #endif /* HEADER_CURL_HTTP2_H */
index 0ef18b6feabec42c93d446f9093faa644167b478..da80f19658097e21a4df75c3fb337a0fd5b03146 100644 (file)
@@ -133,7 +133,7 @@ static void trim_headers(struct curl_slist *head)
 }
 
 /* maximum length for the aws sivg4 parts */
-#define MAX_SIGV4_LEN 64
+#define MAX_SIGV4_LEN    64
 #define DATE_HDR_KEY_LEN (MAX_SIGV4_LEN + sizeof("X--Date"))
 
 /* string been x-PROVIDER-date:TIMESTAMP, I need +1 for ':' */
@@ -400,8 +400,7 @@ fail:
 
 #define CONTENT_SHA256_KEY_LEN (MAX_SIGV4_LEN + sizeof("X--Content-Sha256"))
 /* add 2 for ": " between header name and value */
-#define CONTENT_SHA256_HDR_LEN (CONTENT_SHA256_KEY_LEN + 2 + \
-                                SHA256_HEX_LENGTH)
+#define CONTENT_SHA256_HDR_LEN (CONTENT_SHA256_KEY_LEN + 2 + SHA256_HEX_LENGTH)
 
 /* try to parse a payload hash from the content-sha256 header */
 static const char *parse_content_sha_hdr(struct Curl_easy *data,
@@ -429,7 +428,7 @@ static const char *parse_content_sha_hdr(struct Curl_easy *data,
   curlx_str_passblanks(&value);
 
   len = strlen(value);
-  while(len > 0 && ISBLANK(value[len-1]))
+  while(len > 0 && ISBLANK(value[len - 1]))
     --len;
 
   *value_len = len;
@@ -530,7 +529,6 @@ static int compare_func(const void *a, const void *b)
   compare = strcmp(curlx_dyn_ptr(&aa->value), curlx_dyn_ptr(&bb->value));
 
   return compare;
-
 }
 
 UNITTEST CURLcode canon_path(const char *q, size_t len,
@@ -572,14 +570,13 @@ UNITTEST CURLcode canon_query(const char *query, struct dynbuf *dq)
   if(!query)
     return result;
 
-  result = split_to_dyn_array(query, &query_array[0],
-                              &num_query_components);
+  result = split_to_dyn_array(query, &query_array[0], &num_query_components);
   if(result) {
     goto fail;
   }
 
   /* Create list of pairs, each pair containing an encoded query
-    * component */
+   * component */
 
   for(index = 0; index < num_query_components; index++) {
     const char *in_key;
@@ -599,8 +596,8 @@ UNITTEST CURLcode canon_query(const char *query, struct dynbuf *dq)
       in_key_len = offset - in_key;
     }
 
-    curlx_dyn_init(&encoded_query_array[index].key, query_part_len*3 + 1);
-    curlx_dyn_init(&encoded_query_array[index].value, query_part_len*3 + 1);
+    curlx_dyn_init(&encoded_query_array[index].key, query_part_len * 3 + 1);
+    curlx_dyn_init(&encoded_query_array[index].value, query_part_len * 3 + 1);
     counted_query_components++;
 
     /* Decode/encode the key */
@@ -672,8 +669,8 @@ CURLcode Curl_output_aws_sigv4(struct Curl_easy *data)
   const char *line;
   struct Curl_str provider0;
   struct Curl_str provider1;
-  struct Curl_str region = { NULL, 0};
-  struct Curl_str service = { NULL, 0};
+  struct Curl_str region = { NULL, 0 };
+  struct Curl_str service = { NULL, 0 };
   const char *hostname = conn->host.name;
   time_t clock;
   struct tm tm;
@@ -697,8 +694,8 @@ CURLcode Curl_output_aws_sigv4(struct Curl_easy *data)
   char *str_to_sign = NULL;
   const char *user = data->state.aptr.user ? data->state.aptr.user : "";
   char *secret = NULL;
-  unsigned char sign0[CURL_SHA256_DIGEST_LENGTH] = {0};
-  unsigned char sign1[CURL_SHA256_DIGEST_LENGTH] = {0};
+  unsigned char sign0[CURL_SHA256_DIGEST_LENGTH] = { 0 };
+  unsigned char sign1[CURL_SHA256_DIGEST_LENGTH] = { 0 };
   char *auth_headers = NULL;
 
   if(data->set.path_as_is) {
@@ -782,7 +779,7 @@ CURLcode Curl_output_aws_sigv4(struct Curl_easy *data)
     /* AWS S3 requires a x-amz-content-sha256 header, and supports special
      * values like UNSIGNED-PAYLOAD */
     bool sign_as_s3 = curlx_str_casecompare(&provider0, "aws") &&
-      curlx_str_casecompare(&service, "s3");
+                      curlx_str_casecompare(&service, "s3");
 
     if(sign_as_s3)
       result = calc_s3_payload_hash(data, httpreq, curlx_str(&provider1),
@@ -864,7 +861,7 @@ CURLcode Curl_output_aws_sigv4(struct Curl_easy *data)
     goto fail;
 
   infof(data, "aws_sigv4: Canonical request (enclosed in []) - [%s]",
-    canonical_request);
+        canonical_request);
 
   request_type = curl_maprintf("%.*s4_request",
                                (int)curlx_strlen(&provider0),
@@ -885,7 +882,7 @@ CURLcode Curl_output_aws_sigv4(struct Curl_easy *data)
   if(!credential_scope)
     goto fail;
 
-  if(Curl_sha256it(sha_hash, (unsigned char *) canonical_request,
+  if(Curl_sha256it(sha_hash, (unsigned char *)canonical_request,
                    strlen(canonical_request)))
     goto fail;
 
@@ -912,7 +909,7 @@ CURLcode Curl_output_aws_sigv4(struct Curl_easy *data)
                    curlx_strlen(&provider0));
 
   infof(data, "aws_sigv4: String to sign (enclosed in []) - [%s]",
-    str_to_sign);
+        str_to_sign);
 
   secret = curl_maprintf("%.*s4%s", (int)curlx_strlen(&provider0),
                          curlx_str(&provider0), data->state.aptr.passwd ?
@@ -980,8 +977,8 @@ fail:
 }
 
 /*
-* Frees all allocated strings in a dynbuf pair array, and the dynbuf itself
-*/
+ * Frees all allocated strings in a dynbuf pair array, and the dynbuf itself
+ */
 
 static void pair_array_free(struct pair *pair_array, size_t num_elements)
 {
@@ -991,12 +988,11 @@ static void pair_array_free(struct pair *pair_array, size_t num_elements)
     curlx_dyn_free(&pair_array[index].key);
     curlx_dyn_free(&pair_array[index].value);
   }
-
 }
 
 /*
-* Frees all allocated strings in a split dynbuf, and the dynbuf itself
-*/
+ * Frees all allocated strings in a split dynbuf, and the dynbuf itself
+ */
 
 static void dyn_array_free(struct dynbuf *db, size_t num_elements)
 {
@@ -1007,10 +1003,10 @@ static void dyn_array_free(struct dynbuf *db, size_t num_elements)
 }
 
 /*
-* Splits source string by SPLIT_BY, and creates an array of dynbuf in db.
-* db is initialized by this function.
-* Caller is responsible for freeing the array elements with dyn_array_free
-*/
+ * Splits source string by SPLIT_BY, and creates an array of dynbuf in db.
+ * db is initialized by this function.
+ * Caller is responsible for freeing the array elements with dyn_array_free
+ */
 
 #define SPLIT_BY '&'
 
@@ -1032,8 +1028,7 @@ static CURLcode split_to_dyn_array(const char *source,
     if(source[pos] == SPLIT_BY) {
       if(segment_length) {
         curlx_dyn_init(&db[index], segment_length + 1);
-        result = curlx_dyn_addn(&db[index], &source[start],
-                                segment_length);
+        result = curlx_dyn_addn(&db[index], &source[start], segment_length);
         if(result)
           goto fail;
 
@@ -1064,7 +1059,6 @@ fail:
   return result;
 }
 
-
 static bool is_reserved_char(const char c)
 {
   return (ISALNUM(c) || ISURLPUNTCS(c));
@@ -1091,7 +1085,6 @@ static CURLcode uri_encode_path(struct Curl_str *original_path,
   return CURLE_OK;
 }
 
-
 static CURLcode encode_query_component(char *component, size_t len,
                                        struct dynbuf *db)
 {
@@ -1116,8 +1109,8 @@ static CURLcode encode_query_component(char *component, size_t len,
 }
 
 /*
-* Populates a dynbuf containing url_encode(url_decode(in))
-*/
+ * Populates a dynbuf containing url_encode(url_decode(in))
+ */
 
 static CURLcode http_aws_decode_encode(const char *in, size_t in_len,
                                        struct dynbuf *out)
index 9747c948a69dbf96fa08bec25104314784164c8f..ea7651896e502d014cb23aaf5560e2a038b14e78 100644 (file)
@@ -33,8 +33,7 @@ CURLcode Curl_output_aws_sigv4(struct Curl_easy *data);
 
 #ifdef UNITTESTS
 UNITTEST CURLcode canon_path(const char *q, size_t len,
-    struct dynbuf *new_path,
-    bool normalize);
+                             struct dynbuf *new_path, bool normalize);
 UNITTEST CURLcode canon_query(const char *query, struct dynbuf *dq);
 #endif
 
index 9d0a0b324cdd9418a3b0ea6eda08ed4bfc7bae30..76aab85ce2332e38a700aa795012e2f1a6e292e5 100644 (file)
@@ -357,7 +357,6 @@ static CURLcode httpchunk_readwrite(struct Curl_easy *data,
     case CHUNK_FAILED:
       return CURLE_RECV_ERROR;
     }
-
   }
   return CURLE_OK;
 }
@@ -528,8 +527,7 @@ static CURLcode add_last_chunk(struct Curl_easy *data,
       continue;
     }
 
-    result = Curl_bufq_cwrite(&ctx->chunkbuf, tr->data,
-                              strlen(tr->data), &n);
+    result = Curl_bufq_cwrite(&ctx->chunkbuf, tr->data, strlen(tr->data), &n);
     if(!result)
       result = Curl_bufq_cwrite(&ctx->chunkbuf, STRCONST("\r\n"), &n);
     if(result)
index 2ca1a12d5dafa39ccf56d4c15e2e004168100d3a..34aba0e3ba2fe603bac7e8d14b2f97eb58733043 100644 (file)
@@ -148,7 +148,7 @@ CURLcode Curl_output_digest(struct Curl_easy *data,
     }
   }
   if(!tmp)
-    path = (unsigned char *)curlx_strdup((const char *) uripath);
+    path = (unsigned char *)curlx_strdup((const char *)uripath);
 
   if(!path)
     return CURLE_OUT_OF_MEMORY;
index f31e59c2ca6d27e713fce51b6c8f0a0ddd051046..2929f7980affdf6227824dce1fc88efba79c639d 100644 (file)
@@ -47,7 +47,6 @@ static void http_auth_nego_reset(struct connectdata *conn,
     Curl_auth_cleanup_spnego(neg_ctx);
 }
 
-
 CURLcode Curl_input_negotiate(struct Curl_easy *data, struct connectdata *conn,
                               bool proxy, const char *header)
 {
@@ -124,8 +123,8 @@ CURLcode Curl_input_negotiate(struct Curl_easy *data, struct connectdata *conn,
 #ifdef USE_SSL
   curlx_dyn_init(&neg_ctx->channel_binding_data, SSL_CB_MAX_SIZE + 1);
   if(Curl_conn_is_ssl(conn, FIRSTSOCKET)) {
-    result = Curl_ssl_get_channel_binding(
-      data, FIRSTSOCKET, &neg_ctx->channel_binding_data);
+    result = Curl_ssl_get_channel_binding(data, FIRSTSOCKET,
+                                          &neg_ctx->channel_binding_data);
     if(result) {
       http_auth_nego_reset(conn, neg_ctx, proxy);
       return result;
index 6c79bcac1b9750e66d2f21a983a3e26c4aa3c863..e1b48d76759d306a3d2bed192361f273705588fa 100644 (file)
@@ -144,7 +144,7 @@ CURLcode Curl_output_ntlm(struct Curl_easy *data, bool proxy)
     userp = data->state.aptr.proxyuser;
     passwdp = data->state.aptr.proxypasswd;
     service = data->set.str[STRING_PROXY_SERVICE_NAME] ?
-      data->set.str[STRING_PROXY_SERVICE_NAME] : "HTTP";
+              data->set.str[STRING_PROXY_SERVICE_NAME] : "HTTP";
     hostname = conn->http_proxy.host.name;
     state = &conn->proxy_ntlm_state;
     authp = &data->state.authproxy;
@@ -157,7 +157,7 @@ CURLcode Curl_output_ntlm(struct Curl_easy *data, bool proxy)
     userp = data->state.aptr.user;
     passwdp = data->state.aptr.passwd;
     service = data->set.str[STRING_SERVICE_NAME] ?
-      data->set.str[STRING_SERVICE_NAME] : "HTTP";
+              data->set.str[STRING_SERVICE_NAME] : "HTTP";
     hostname = conn->host.name;
     state = &conn->http_ntlm_state;
     authp = &data->state.authhost;
@@ -202,12 +202,11 @@ CURLcode Curl_output_ntlm(struct Curl_easy *data, bool proxy)
     if(!result) {
       DEBUGASSERT(Curl_bufref_len(&ntlmmsg) != 0);
       result = curlx_base64_encode(Curl_bufref_ptr(&ntlmmsg),
-                                  Curl_bufref_len(&ntlmmsg), &base64, &len);
+                                   Curl_bufref_len(&ntlmmsg), &base64, &len);
       if(!result) {
         curlx_free(*allocuserpwd);
         *allocuserpwd = curl_maprintf("%sAuthorization: NTLM %s\r\n",
-                                      proxy ? "Proxy-" : "",
-                                      base64);
+                                      proxy ? "Proxy-" : "", base64);
         curlx_free(base64);
         if(!*allocuserpwd)
           result = CURLE_OUT_OF_MEMORY;
@@ -225,8 +224,7 @@ CURLcode Curl_output_ntlm(struct Curl_easy *data, bool proxy)
       if(!result) {
         curlx_free(*allocuserpwd);
         *allocuserpwd = curl_maprintf("%sAuthorization: NTLM %s\r\n",
-                                      proxy ? "Proxy-" : "",
-                                      base64);
+                                      proxy ? "Proxy-" : "", base64);
         curlx_free(base64);
         if(!*allocuserpwd)
           result = CURLE_OUT_OF_MEMORY;
index 21f0cc6211c18d12b30c7c451139161ebab174d2..d1d043bfb245028b7228a11a4439d2c78b11fcaf 100644 (file)
@@ -131,25 +131,31 @@ static CURLcode dynhds_add_custom(struct Curl_easy *data,
       if(data->state.aptr.host &&
          /* a Host: header was sent already, do not pass on any custom Host:
             header as that will produce *two* in the same request! */
-         curlx_str_casecompare(&name, "Host"));
+         curlx_str_casecompare(&name, "Host"))
+        ;
       else if(data->state.httpreq == HTTPREQ_POST_FORM &&
               /* this header (extended by formdata.c) is sent later */
-              curlx_str_casecompare(&name, "Content-Type"));
+              curlx_str_casecompare(&name, "Content-Type"))
+        ;
       else if(data->state.httpreq == HTTPREQ_POST_MIME &&
               /* this header is sent later */
-              curlx_str_casecompare(&name, "Content-Type"));
+              curlx_str_casecompare(&name, "Content-Type"))
+        ;
       else if(data->req.authneg &&
               /* while doing auth neg, do not allow the custom length since
                  we will force length zero then */
-              curlx_str_casecompare(&name, "Content-Length"));
+              curlx_str_casecompare(&name, "Content-Length"))
+        ;
       else if((httpversion >= 20) &&
-              curlx_str_casecompare(&name, "Transfer-Encoding"));
+              curlx_str_casecompare(&name, "Transfer-Encoding"))
+        ;
       /* HTTP/2 and HTTP/3 do not support chunked requests */
       else if((curlx_str_casecompare(&name, "Authorization") ||
                curlx_str_casecompare(&name, "Cookie")) &&
               /* be careful of sending this potentially sensitive header to
                  other hosts */
-              !Curl_auth_allowed_to_host(data));
+              !Curl_auth_allowed_to_host(data))
+        ;
       else {
         CURLcode result =
           Curl_dynhds_add(hds, curlx_str(&name), curlx_strlen(&name),
@@ -211,13 +217,13 @@ CURLcode Curl_http_proxy_create_CONNECT(struct httpreq **preq,
   Curl_http_proxy_get_destination(cf, &hostname, &port, &ipv6_ip);
 
   authority = curl_maprintf("%s%s%s:%d", ipv6_ip ? "[" : "", hostname,
-                            ipv6_ip ?"]" : "", port);
+                            ipv6_ip ? "]" : "", port);
   if(!authority) {
     result = CURLE_OUT_OF_MEMORY;
     goto out;
   }
 
-  result = Curl_http_req_make(&req, "CONNECT", sizeof("CONNECT")-1,
+  result = Curl_http_req_make(&req, "CONNECT", sizeof("CONNECT") - 1,
                               NULL, 0, authority, strlen(authority),
                               NULL, 0);
   if(result)
@@ -253,7 +259,7 @@ CURLcode Curl_http_proxy_create_CONNECT(struct httpreq **preq,
   }
 
   if(http_version_major == 1 &&
-    !Curl_checkProxyheaders(data, cf->conn, STRCONST("Proxy-Connection"))) {
+     !Curl_checkProxyheaders(data, cf->conn, STRCONST("Proxy-Connection"))) {
     result = Curl_dynhds_cadd(&req->headers, "Proxy-Connection", "Keep-Alive");
     if(result)
       goto out;
@@ -394,10 +400,9 @@ static void http_proxy_cf_close(struct Curl_cfilter *cf,
     cf->next->cft->do_close(cf->next, data);
 }
 
-
 struct Curl_cftype Curl_cft_http_proxy = {
   "HTTP-PROXY",
-  CF_TYPE_IP_CONNECT|CF_TYPE_PROXY,
+  CF_TYPE_IP_CONNECT | CF_TYPE_PROXY,
   0,
   http_proxy_cf_destroy,
   http_proxy_cf_connect,
index 17f7e10488e1077d6d79065382842dbf4efa083d..7af2ebb284c9cfd42a5ba0293d4a3c1e110642df 100644 (file)
@@ -46,7 +46,7 @@ CURLcode Curl_http_proxy_create_CONNECT(struct httpreq **preq,
                                         int http_version_major);
 
 /* Default proxy timeout in milliseconds */
-#define PROXY_TIMEOUT (3600*1000)
+#define PROXY_TIMEOUT (3600 * 1000)
 
 CURLcode Curl_cf_http_proxy_query(struct Curl_cfilter *cf,
                                   struct Curl_easy *data,
index 34d081b50264b7d958e7531edb8fc281eb96ac43..3acb16ac3a714f14137896dd991ce5ce7554061f 100644 (file)
@@ -151,7 +151,6 @@ void Curl_httpsrr_cleanup(struct Curl_https_rrinfo *rrinfo)
   Curl_safefree(rrinfo->rrname);
 }
 
-
 #ifdef USE_ARES
 
 static CURLcode httpsrr_opt(struct Curl_easy *data,
index 9b7831f75cbcb522ef141172b1815c66fde04986..4259a03262f330f678849fe111d773ffd0334da8 100644 (file)
@@ -33,7 +33,7 @@
 #ifdef USE_HTTPSRR
 
 #define CURL_MAXLEN_host_name 253
-#define MAX_HTTPSRR_ALPNS 4
+#define MAX_HTTPSRR_ALPNS     4
 
 struct Curl_easy;
 
index 0b1a4a36ccc0e14391a3bd45997fc0e996664334..8f4c3e03f712c9040e88c32e87b0cd95575962ec 100644 (file)
--- a/lib/idn.c
+++ b/lib/idn.c
@@ -22,9 +22,9 @@
  *
  ***************************************************************************/
 
- /*
 * IDN conversions
 */
+/*
+ * IDN conversions
+ */
 
 #include "curl_setup.h"
 #include "urldata.h"
@@ -87,18 +87,18 @@ static CURLcode mac_idn_to_ascii(const char *in, char **out)
 {
   size_t inlen = strlen(in);
   if(inlen < MAX_HOST_LENGTH) {
-    char iconv_buffer[MAX_HOST_LENGTH] = {0};
+    char iconv_buffer[MAX_HOST_LENGTH] = { 0 };
     char *iconv_outptr = iconv_buffer;
     size_t iconv_outlen = sizeof(iconv_buffer);
     CURLcode iconv_result = iconv_to_utf8(in, inlen,
                                           &iconv_outptr, &iconv_outlen);
     if(!iconv_result) {
       UErrorCode err = U_ZERO_ERROR;
-      UIDNAidna = uidna_openUTS46(
-        UIDNA_CHECK_BIDI|UIDNA_NONTRANSITIONAL_TO_ASCII, &err);
+      UIDNA *idna = uidna_openUTS46(
+        UIDNA_CHECK_BIDI | UIDNA_NONTRANSITIONAL_TO_ASCII, &err);
       if(!U_FAILURE(err)) {
         UIDNAInfo info = UIDNA_INFO_INITIALIZER;
-        char buffer[MAX_HOST_LENGTH] = {0};
+        char buffer[MAX_HOST_LENGTH] = { 0 };
         (void)uidna_nameToASCII_UTF8(idna, iconv_buffer, (int)iconv_outlen,
                                      buffer, sizeof(buffer) - 1, &info, &err);
         uidna_close(idna);
@@ -122,11 +122,11 @@ static CURLcode mac_ascii_to_idn(const char *in, char **out)
   size_t inlen = strlen(in);
   if(inlen < MAX_HOST_LENGTH) {
     UErrorCode err = U_ZERO_ERROR;
-    UIDNAidna = uidna_openUTS46(
-      UIDNA_CHECK_BIDI|UIDNA_NONTRANSITIONAL_TO_UNICODE, &err);
+    UIDNA *idna = uidna_openUTS46(
+      UIDNA_CHECK_BIDI | UIDNA_NONTRANSITIONAL_TO_UNICODE, &err);
     if(!U_FAILURE(err)) {
       UIDNAInfo info = UIDNA_INFO_INITIALIZER;
-      char buffer[MAX_HOST_LENGTH] = {0};
+      char buffer[MAX_HOST_LENGTH] = { 0 };
       (void)uidna_nameToUnicodeUTF8(idna, in, -1, buffer,
                                     sizeof(buffer) - 1, &info, &err);
       uidna_close(idna);
index c2b8aafc4d7edaba200a0ea1db6c23e715d5d647..ef2bfe2b0a4885258cbf99a4bb7ca53beffd39e0 100644 (file)
 unsigned int Curl_ipv6_scope(const struct sockaddr *sa)
 {
   if(sa->sa_family == AF_INET6) {
-    const struct sockaddr_in6 * sa6 =
-      (const struct sockaddr_in6 *)(const void *) sa;
+    const struct sockaddr_in6 *sa6 =
+      (const struct sockaddr_in6 *)(const void *)sa;
     const unsigned char *b = sa6->sin6_addr.s6_addr;
-    unsigned short w = (unsigned short) ((b[0] << 8) | b[1]);
+    unsigned short w = (unsigned short)((b[0] << 8) | b[1]);
 
     if((b[0] & 0xFE) == 0xFC) /* Handle ULAs */
       return IPV6_SCOPE_UNIQUELOCAL;
@@ -103,8 +103,7 @@ if2ip_result_t Curl_if2ip(int af,
   struct ifaddrs *iface, *head;
   if2ip_result_t res = IF2IP_NOT_FOUND;
 
-#if defined(USE_IPV6) && \
-    !defined(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID)
+#if defined(USE_IPV6) && !defined(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID)
   (void)local_scope_id;
 #endif
 
@@ -138,7 +137,7 @@ if2ip_result_t Curl_if2ip(int af,
 #ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
               /* Include the scope of this interface as part of the address */
               scopeid = ((struct sockaddr_in6 *)(void *)iface->ifa_addr)
-                            ->sin6_scope_id;
+                          ->sin6_scope_id;
 
               /* If given, scope id should match. */
               if(local_scope_id && scopeid != local_scope_id) {
@@ -248,15 +247,15 @@ if2ip_result_t Curl_if2ip(int af,
                           const char *interf,
                           char *buf, size_t buf_size)
 {
-    (void)af;
+  (void)af;
 #ifdef USE_IPV6
-    (void)remote_scope;
-    (void)local_scope_id;
+  (void)remote_scope;
+  (void)local_scope_id;
 #endif
-    (void)interf;
-    (void)buf;
-    (void)buf_size;
-    return IF2IP_NOT_FOUND;
+  (void)interf;
+  (void)buf;
+  (void)buf_size;
+  return IF2IP_NOT_FOUND;
 }
 
 #endif
index 42ec7b033a8cc0b5569c165dfd66975bc7dae42e..12fdaabd736abee95313b8a4c7112a57bf615f99 100644 (file)
@@ -56,7 +56,7 @@ if2ip_result_t Curl_if2ip(int af,
 
 /* Nedelcho Stanev's work-around for SFU 3.0 */
 struct ifreq {
-#define IFNAMSIZ 16
+#define IFNAMSIZ    16
 #define IFHWADDRLEN 6
   union {
     char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */
@@ -75,14 +75,14 @@ struct ifreq {
 
 /* This define exists to avoid an extra #ifdef INTERIX in the C code. */
 
-#define ifr_name ifr_ifrn.ifrn_name /* interface name */
-#define ifr_addr ifr_ifru.ifru_addr /* address */
+#define ifr_name      ifr_ifrn.ifrn_name /* interface name */
+#define ifr_addr      ifr_ifru.ifru_addr /* address */
 #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
-#define ifr_netmask ifr_ifru.ifru_netmask /* interface net mask */
-#define ifr_flags ifr_ifru.ifru_flags /* flags */
-#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */
-#define ifr_metric ifr_ifru.ifru_metric /* metric */
-#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */
+#define ifr_netmask   ifr_ifru.ifru_netmask /* interface net mask */
+#define ifr_flags     ifr_ifru.ifru_flags /* flags */
+#define ifr_hwaddr    ifr_ifru.ifru_hwaddr /* MAC address */
+#define ifr_metric    ifr_ifru.ifru_metric /* metric */
+#define ifr_mtu       ifr_ifru.ifru_mtu /* mtu */
 
 #define SIOCGIFADDR _IOW('s', 102, struct ifreq) /* Get if addr */
 
index 9d58bec4ec81e64bb7b99cabc5c2d86ba82a9c57..ec5e654cfae933f8d565a11ce7f59733a77d23d9 100644 (file)
@@ -347,46 +347,46 @@ static bool imap_endofresp(struct Curl_easy *data, struct connectdata *conn,
   /* Do we have an untagged command response? */
   if(len >= 2 && !memcmp("* ", line, 2)) {
     switch(imapc->state) {
-      /* States which are interested in untagged responses */
-      case IMAP_CAPABILITY:
-        if(!imap_matchresp(line, len, "CAPABILITY"))
-          return FALSE;
-        break;
-
-      case IMAP_LIST:
-        if((!imap->custom && !imap_matchresp(line, len, "LIST")) ||
-           (imap->custom && !imap_matchresp(line, len, imap->custom) &&
-            (!curl_strequal(imap->custom, "STORE") ||
-             !imap_matchresp(line, len, "FETCH")) &&
-            !curl_strequal(imap->custom, "SELECT") &&
-            !curl_strequal(imap->custom, "EXAMINE") &&
-            !curl_strequal(imap->custom, "SEARCH") &&
-            !curl_strequal(imap->custom, "EXPUNGE") &&
-            !curl_strequal(imap->custom, "LSUB") &&
-            !curl_strequal(imap->custom, "UID") &&
-            !curl_strequal(imap->custom, "GETQUOTAROOT") &&
-            !curl_strequal(imap->custom, "NOOP")))
-          return FALSE;
-        break;
+    /* States which are interested in untagged responses */
+    case IMAP_CAPABILITY:
+      if(!imap_matchresp(line, len, "CAPABILITY"))
+        return FALSE;
+      break;
 
-      case IMAP_SELECT:
-        /* SELECT is special in that its untagged responses do not have a
-           common prefix so accept anything! */
-        break;
+    case IMAP_LIST:
+      if((!imap->custom && !imap_matchresp(line, len, "LIST")) ||
+         (imap->custom && !imap_matchresp(line, len, imap->custom) &&
+          (!curl_strequal(imap->custom, "STORE") ||
+           !imap_matchresp(line, len, "FETCH")) &&
+          !curl_strequal(imap->custom, "SELECT") &&
+          !curl_strequal(imap->custom, "EXAMINE") &&
+          !curl_strequal(imap->custom, "SEARCH") &&
+          !curl_strequal(imap->custom, "EXPUNGE") &&
+          !curl_strequal(imap->custom, "LSUB") &&
+          !curl_strequal(imap->custom, "UID") &&
+          !curl_strequal(imap->custom, "GETQUOTAROOT") &&
+          !curl_strequal(imap->custom, "NOOP")))
+        return FALSE;
+      break;
 
-      case IMAP_FETCH:
-        if(!imap_matchresp(line, len, "FETCH"))
-          return FALSE;
-        break;
+    case IMAP_SELECT:
+      /* SELECT is special in that its untagged responses do not have a
+         common prefix so accept anything! */
+      break;
 
-      case IMAP_SEARCH:
-        if(!imap_matchresp(line, len, "SEARCH"))
-          return FALSE;
-        break;
+    case IMAP_FETCH:
+      if(!imap_matchresp(line, len, "FETCH"))
+        return FALSE;
+      break;
 
-      /* Ignore other untagged responses */
-      default:
+    case IMAP_SEARCH:
+      if(!imap_matchresp(line, len, "SEARCH"))
         return FALSE;
+      break;
+
+    /* Ignore other untagged responses */
+    default:
+      return FALSE;
     }
 
     *resp = '*';
@@ -400,16 +400,16 @@ static bool imap_endofresp(struct Curl_easy *data, struct connectdata *conn,
   if(!imap->custom && ((len == 3 && line[0] == '+') ||
                        (len >= 2 && !memcmp("+ ", line, 2)))) {
     switch(imapc->state) {
-      /* States which are interested in continuation responses */
-      case IMAP_AUTHENTICATE:
-      case IMAP_APPEND:
-        *resp = '+';
-        break;
+    /* States which are interested in continuation responses */
+    case IMAP_AUTHENTICATE:
+    case IMAP_APPEND:
+      *resp = '+';
+      break;
 
-      default:
-        failf(data, "Unexpected continuation response");
-        *resp = -1;
-        break;
+    default:
+      failf(data, "Unexpected continuation response");
+      *resp = -1;
+      break;
     }
 
     return TRUE;
@@ -471,7 +471,7 @@ static void imap_state(struct Curl_easy *data,
 {
 #if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
   /* for debug purposes */
-  static const char * const names[]={
+  static const char * const names[] = {
     "STOP",
     "SERVERGREET",
     "CAPABILITY",
@@ -570,8 +570,8 @@ static CURLcode imap_perform_upgrade_tls(struct Curl_easy *data,
          result, ssldone));
   if(!result && ssldone) {
     imapc->ssldone = ssldone;
-     /* perform CAPA now, changes imapc->state out of IMAP_UPGRADETLS */
-     result = imap_perform_capability(data, imapc);
+    /* perform CAPA now, changes imapc->state out of IMAP_UPGRADETLS */
+    result = imap_perform_capability(data, imapc);
   }
 out:
   return result;
@@ -636,7 +636,7 @@ static CURLcode imap_perform_authenticate(struct Curl_easy *data,
   struct imap_conn *imapc =
     Curl_conn_meta_get(data->conn, CURL_META_IMAP_CONN);
   CURLcode result = CURLE_OK;
-  const char *ir = (const char *) Curl_bufref_ptr(initresp);
+  const char *ir = (const char *)Curl_bufref_ptr(initresp);
 
   if(!imapc)
     return CURLE_FAILED_INIT;
@@ -669,7 +669,7 @@ static CURLcode imap_continue_authenticate(struct Curl_easy *data,
   if(!imapc)
     return CURLE_FAILED_INIT;
   return Curl_pp_sendf(data, &imapc->pp,
-                       "%s", (const char *) Curl_bufref_ptr(resp));
+                       "%s", (const char *)Curl_bufref_ptr(resp));
 }
 
 /***********************************************************************
@@ -1048,8 +1048,8 @@ static CURLcode imap_state_capability_resp(struct Curl_easy *data,
 
       /* Extract the word */
       for(wordlen = 0; line[wordlen] && line[wordlen] != ' ' &&
-            line[wordlen] != '\t' && line[wordlen] != '\r' &&
-            line[wordlen] != '\n';)
+                       line[wordlen] != '\t' && line[wordlen] != '\r' &&
+                       line[wordlen] != '\n';)
         wordlen++;
 
       /* Does the server support the STARTTLS capability? */
@@ -1322,7 +1322,6 @@ static CURLcode imap_state_select_resp(struct Curl_easy *data,
         imapc->mb_uidvalidity = (unsigned int)value;
         imapc->mb_uidvalidity_set = TRUE;
       }
-
     }
   }
   else if(imapcode == IMAP_RESP_OK) {
@@ -1797,7 +1796,7 @@ static CURLcode imap_perform(struct Curl_easy *data, bool *connected,
     /* SEARCH the current mailbox */
     result = imap_perform_search(data, imapc, imap);
   else if(imap->mailbox && !selected &&
-         (imap->custom || imap->uid || imap->mindex || imap->query))
+          (imap->custom || imap->uid || imap->mindex || imap->query))
     /* SELECT the mailbox */
     result = imap_perform_select(data, imapc, imap);
   else
@@ -2112,21 +2111,33 @@ static bool imap_is_bchar(char ch)
     return TRUE;
 
   switch(ch) {
-    /* bchar */
-    case ':': case '@': case '/':
-    /* bchar -> achar */
-    case '&': case '=':
-    /* bchar -> achar -> uchar -> unreserved (without alphanumeric) */
-    case '-': case '.': case '_': case '~':
-    /* bchar -> achar -> uchar -> sub-delims-sh */
-    case '!': case '$': case '\'': case '(': case ')': case '*':
-    case '+': case ',':
-    /* bchar -> achar -> uchar -> pct-encoded */
-    case '%': /* HEXDIG chars are already included above */
-      return TRUE;
+  /* bchar */
+  case ':':
+  case '@':
+  case '/':
+  /* bchar -> achar */
+  case '&':
+  case '=':
+  /* bchar -> achar -> uchar -> unreserved (without alphanumeric) */
+  case '-':
+  case '.':
+  case '_':
+  case '~':
+  /* bchar -> achar -> uchar -> sub-delims-sh */
+  case '!':
+  case '$':
+  case '\'':
+  case '(':
+  case ')':
+  case '*':
+  case '+':
+  case ',':
+  /* bchar -> achar -> uchar -> pct-encoded */
+  case '%': /* HEXDIG chars are already included above */
+    return TRUE;
 
-    default:
-      return FALSE;
+  default:
+    return FALSE;
   }
 }
 
index f802ed5c0c723e4ac82180cfa495b25b445cf654..2bab0b4ddea7887621ca8f6f9a5ffd1b1b40038c 100644 (file)
@@ -27,7 +27,6 @@
 #include "pingpong.h"
 #include "curl_sasl.h"
 
-
 extern const struct Curl_handler Curl_handler_imap;
 extern const struct Curl_handler Curl_handler_imaps;
 
@@ -37,6 +36,6 @@ extern const struct Curl_handler Curl_handler_imaps;
 
 /* Authentication type values */
 #define IMAP_TYPE_NONE      0
-#define IMAP_TYPE_ANY       (IMAP_TYPE_CLEARTEXT|IMAP_TYPE_SASL)
+#define IMAP_TYPE_ANY       (IMAP_TYPE_CLEARTEXT | IMAP_TYPE_SASL)
 
 #endif /* HEADER_CURL_IMAP_H */
index 522bf3ad586036e02b8d22420e279fd2d948970d..63b2cbc414f62d492fb4bb832a301cf96d73667b 100644 (file)
@@ -96,7 +96,7 @@
 
 #ifdef USE_WIN32_LDAP
 #define FREE_ON_WINLDAP(x) curlx_unicodefree(x)
-#define curl_ldap_num_t ULONG
+#define curl_ldap_num_t    ULONG
 #else
 #define FREE_ON_WINLDAP(x)
 #define curl_ldap_num_t int
@@ -142,14 +142,15 @@ static void ldap_free_urldesc_low(LDAPURLDesc *ludp);
 #endif /* !HAVE_LDAP_URL_PARSE */
 
 #ifdef DEBUG_LDAP
-  #define LDAP_TRACE(x)   do { \
-                            ldap_trace_low("%u: ", __LINE__); \
-                            ldap_trace_low x; \
-                          } while(0)
+#define LDAP_TRACE(x)               \
+do {                                \
+  ldap_trace_low("%u: ", __LINE__); \
+  ldap_trace_low x;                 \
+} while(0)
 
-  static void ldap_trace_low(const char *fmt, ...) CURL_PRINTF(1, 2);
+static void ldap_trace_low(const char *fmt, ...) CURL_PRINTF(1, 2);
 #else
-  #define LDAP_TRACE(x)   Curl_nop_stmt
+#define LDAP_TRACE(x) Curl_nop_stmt
 #endif
 
 #if defined(USE_WIN32_LDAP) && defined(ldap_err2string)
@@ -172,7 +173,6 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done);
 /*
  * LDAP protocol handler.
  */
-
 const struct Curl_handler Curl_handler_ldap = {
   "ldap",                               /* scheme */
   ZERO_NULL,                            /* setup_connection */
@@ -202,7 +202,6 @@ const struct Curl_handler Curl_handler_ldap = {
 /*
  * LDAPS protocol handler.
  */
-
 const struct Curl_handler Curl_handler_ldaps = {
   "ldaps",                              /* scheme */
   ZERO_NULL,                            /* setup_connection */
@@ -619,7 +618,7 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done)
           }
 
           if((attr_len > 7) &&
-             curl_strequal(";binary", attr + (attr_len - 7)) ) {
+             curl_strequal(";binary", attr + (attr_len - 7))) {
             /* Binary attribute, encode to base64. */
             if(vals[i]->bv_len) {
               result = curlx_base64_encode((uint8_t *)vals[i]->bv_val,
@@ -886,8 +885,7 @@ static curl_ldap_num_t ldap_url_parse2_low(struct Curl_easy *data,
       LDAP_TRACE(("attr[%zu] '%.*s'\n", i, (int)out.len, out.str));
 
       /* Unescape the attribute */
-      result = Curl_urldecode(out.str, out.len, &unescaped, NULL,
-                              REJECT_ZERO);
+      result = Curl_urldecode(out.str, out.len, &unescaped, NULL, REJECT_ZERO);
       if(result) {
         rc = LDAP_NO_MEMORY;
         goto quit;
index ebcda82a04ed152d397b2ff15bb23a792e82f387..3c70905df25088aad53b5ef930c7ff5dd5cbdc1a 100644 (file)
@@ -45,8 +45,7 @@ static struct Curl_llist_node *verifynode(struct Curl_llist_node *n)
 /*
  * @unittest: 1300
  */
-void
-Curl_llist_init(struct Curl_llist *l, Curl_llist_dtor dtor)
+void Curl_llist_init(struct Curl_llist *l, Curl_llist_dtor dtor)
 {
   l->_size = 0;
   l->_dtor = dtor;
@@ -68,11 +67,10 @@ Curl_llist_init(struct Curl_llist *l, Curl_llist_dtor dtor)
  *
  * @unittest: 1300
  */
-void
-Curl_llist_insert_next(struct Curl_llist *list,
-                       struct Curl_llist_node *e, /* may be NULL */
-                       const void *p,
-                       struct Curl_llist_node *ne)
+void Curl_llist_insert_next(struct Curl_llist *list,
+                            struct Curl_llist_node *e, /* may be NULL */
+                            const void *p,
+                            struct Curl_llist_node *ne)
 {
   DEBUGASSERT(list);
   DEBUGASSERT(list->_init == LLISTINIT);
@@ -119,9 +117,8 @@ Curl_llist_insert_next(struct Curl_llist *list,
  *
  * @unittest: 1300
  */
-void
-Curl_llist_append(struct Curl_llist *list, const void *p,
-                  struct Curl_llist_node *ne)
+void Curl_llist_append(struct Curl_llist *list, const void *p,
+                       struct Curl_llist_node *ne)
 {
   DEBUGASSERT(list);
   DEBUGASSERT(list->_init == LLISTINIT);
@@ -177,9 +174,8 @@ void *Curl_node_take_elem(struct Curl_llist_node *e)
 /*
  * @unittest: 1300
  */
-UNITTEST void Curl_node_uremove(struct Curl_llist_node *, void *);
-UNITTEST void
-Curl_node_uremove(struct Curl_llist_node *e, void *user)
+UNITTEST void Curl_node_uremove(struct Curl_llist_node *e, void *user);
+UNITTEST void Curl_node_uremove(struct Curl_llist_node *e, void *user)
 {
   struct Curl_llist *list;
   void *ptr;
@@ -200,8 +196,7 @@ void Curl_node_remove(struct Curl_llist_node *e)
   Curl_node_uremove(e, NULL);
 }
 
-void
-Curl_llist_destroy(struct Curl_llist *list, void *user)
+void Curl_llist_destroy(struct Curl_llist *list, void *user)
 {
   if(list) {
     DEBUGASSERT(list->_init == LLISTINIT);
index 0a2bc9a62f477bd321642e9b8c77a28fe8dcbce2..0a4a68516362aef32ebeb0eaa0f9feff9e85c391 100644 (file)
@@ -55,8 +55,8 @@ struct Curl_llist_node {
 void Curl_llist_init(struct Curl_llist *, Curl_llist_dtor);
 void Curl_llist_insert_next(struct Curl_llist *, struct Curl_llist_node *,
                             const void *, struct Curl_llist_node *node);
-void Curl_llist_append(struct Curl_llist *,
-                       const void *, struct Curl_llist_node *node);
+void Curl_llist_append(struct Curl_llist *, const void *,
+                       struct Curl_llist_node *node);
 void Curl_node_remove(struct Curl_llist_node *);
 void Curl_llist_destroy(struct Curl_llist *, void *);
 
index 7929e57f65c0a596b5943a11db4b04a41c3ef892..befaeab68bcda1d7ce003503a51ff8ec09347332 100644 (file)
--- a/lib/md4.c
+++ b/lib/md4.c
 #include <nettle/md4.h>
 #endif
 
-
 #if defined(USE_WOLFSSL) && !defined(WOLFSSL_NO_MD4)
 
 #ifdef OPENSSL_COEXIST
-  #define MD4_CTX WOLFSSL_MD4_CTX
-  #define MD4_Init wolfSSL_MD4_Init
+  #define MD4_CTX    WOLFSSL_MD4_CTX
+  #define MD4_Init   wolfSSL_MD4_Init
   #define MD4_Update wolfSSL_MD4_Update
-  #define MD4_Final wolfSSL_MD4_Final
+  #define MD4_Final  wolfSSL_MD4_Final
 #endif
 
 #elif defined(USE_OPENSSL) && !defined(OPENSSL_NO_MD4)
@@ -129,7 +128,7 @@ static int MD4_Init(MD4_CTX *ctx)
 
 static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size)
 {
-  CryptHashData(ctx->hHash, (const BYTE *)data, (unsigned int) size, 0);
+  CryptHashData(ctx->hHash, (const BYTE *)data, (unsigned int)size, 0);
 }
 
 static void MD4_Final(unsigned char *result, MD4_CTX *ctx)
@@ -224,8 +223,8 @@ static void MD4_Final(unsigned char *result, MD4_CTX *ctx);
  * The MD4 transformation for all three rounds.
  */
 #define MD4_STEP(f, a, b, c, d, x, s) \
-        (a) += f((b), (c), (d)) + (x); \
-        (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s))));
+  (a) += f((b), (c), (d)) + (x); \
+  (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s))));
 
 /*
  * SET reads 4 input bytes in little-endian byte order and stores them
@@ -236,19 +235,15 @@ static void MD4_Final(unsigned char *result, MD4_CTX *ctx);
  * does not work.
  */
 #if defined(__i386__) || defined(__x86_64__) || defined(__vax__)
-#define MD4_SET(n) \
-        (*(const MD4_u32plus *)(const void *)&ptr[(n) * 4])
-#define MD4_GET(n) \
-        MD4_SET(n)
+#define MD4_SET(n) (*(const MD4_u32plus *)(const void *)&ptr[(n) * 4])
+#define MD4_GET(n) MD4_SET(n)
 #else
-#define MD4_SET(n) \
-        (ctx->block[(n)] = \
-          (MD4_u32plus)ptr[(n) * 4] | \
-          ((MD4_u32plus)ptr[(n) * 4 + 1] << 8) | \
-          ((MD4_u32plus)ptr[(n) * 4 + 2] << 16) | \
-          ((MD4_u32plus)ptr[(n) * 4 + 3] << 24))
-#define MD4_GET(n) \
-        (ctx->block[(n)])
+#define MD4_SET(n) (ctx->block[(n)] = \
+   (MD4_u32plus)ptr[(n) * 4] | \
+  ((MD4_u32plus)ptr[(n) * 4 + 1] <<  8) | \
+  ((MD4_u32plus)ptr[(n) * 4 + 2] << 16) | \
+  ((MD4_u32plus)ptr[(n) * 4 + 3] << 24))
+#define MD4_GET(n) (ctx->block[(n)])
 #endif
 
 /*
@@ -413,32 +408,32 @@ static void MD4_Final(unsigned char *result, MD4_CTX *ctx)
   memset(&ctx->buffer[used], 0, available - 8);
 
   ctx->lo <<= 3;
-  ctx->buffer[56] = curlx_ultouc((ctx->lo)&0xff);
-  ctx->buffer[57] = curlx_ultouc((ctx->lo >> 8)&0xff);
-  ctx->buffer[58] = curlx_ultouc((ctx->lo >> 16)&0xff);
-  ctx->buffer[59] = curlx_ultouc((ctx->lo >> 24)&0xff);
-  ctx->buffer[60] = curlx_ultouc((ctx->hi)&0xff);
-  ctx->buffer[61] = curlx_ultouc((ctx->hi >> 8)&0xff);
-  ctx->buffer[62] = curlx_ultouc((ctx->hi >> 16)&0xff);
+  ctx->buffer[56] = curlx_ultouc((ctx->lo) & 0xff);
+  ctx->buffer[57] = curlx_ultouc((ctx->lo >> 8) & 0xff);
+  ctx->buffer[58] = curlx_ultouc((ctx->lo >> 16) & 0xff);
+  ctx->buffer[59] = curlx_ultouc((ctx->lo >> 24) & 0xff);
+  ctx->buffer[60] = curlx_ultouc((ctx->hi) & 0xff);
+  ctx->buffer[61] = curlx_ultouc((ctx->hi >> 8) & 0xff);
+  ctx->buffer[62] = curlx_ultouc((ctx->hi >> 16) & 0xff);
   ctx->buffer[63] = curlx_ultouc(ctx->hi >> 24);
 
   my_md4_body(ctx, ctx->buffer, 64);
 
-  result[0] = curlx_ultouc((ctx->a)&0xff);
-  result[1] = curlx_ultouc((ctx->a >> 8)&0xff);
-  result[2] = curlx_ultouc((ctx->a >> 16)&0xff);
+  result[0] = curlx_ultouc((ctx->a) & 0xff);
+  result[1] = curlx_ultouc((ctx->a >> 8) & 0xff);
+  result[2] = curlx_ultouc((ctx->a >> 16) & 0xff);
   result[3] = curlx_ultouc(ctx->a >> 24);
-  result[4] = curlx_ultouc((ctx->b)&0xff);
-  result[5] = curlx_ultouc((ctx->b >> 8)&0xff);
-  result[6] = curlx_ultouc((ctx->b >> 16)&0xff);
+  result[4] = curlx_ultouc((ctx->b) & 0xff);
+  result[5] = curlx_ultouc((ctx->b >> 8) & 0xff);
+  result[6] = curlx_ultouc((ctx->b >> 16) & 0xff);
   result[7] = curlx_ultouc(ctx->b >> 24);
-  result[8] = curlx_ultouc((ctx->c)&0xff);
-  result[9] = curlx_ultouc((ctx->c >> 8)&0xff);
-  result[10] = curlx_ultouc((ctx->c >> 16)&0xff);
+  result[8] = curlx_ultouc((ctx->c) & 0xff);
+  result[9] = curlx_ultouc((ctx->c >> 8) & 0xff);
+  result[10] = curlx_ultouc((ctx->c >> 16) & 0xff);
   result[11] = curlx_ultouc(ctx->c >> 24);
-  result[12] = curlx_ultouc((ctx->d)&0xff);
-  result[13] = curlx_ultouc((ctx->d >> 8)&0xff);
-  result[14] = curlx_ultouc((ctx->d >> 16)&0xff);
+  result[12] = curlx_ultouc((ctx->d) & 0xff);
+  result[13] = curlx_ultouc((ctx->d >> 8) & 0xff);
+  result[14] = curlx_ultouc((ctx->d >> 16) & 0xff);
   result[15] = curlx_ultouc(ctx->d >> 24);
 
   memset(ctx, 0, sizeof(*ctx));
index a579b02c63aec0fa2693f0c9a96ce55ad0dee7c0..e1a443c9236a5ad54c332ac5c5c9bc2134b82e44 100644 (file)
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -314,9 +314,9 @@ static void my_md5_final(unsigned char *result, void *ctx);
  * The MD5 transformation for all four rounds.
  */
 #define MD5_STEP(f, a, b, c, d, x, t, s) \
-        (a) += f((b), (c), (d)) + (x) + (t); \
-        (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); \
-        (a) += (b);
+  (a) += f((b), (c), (d)) + (x) + (t); \
+  (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); \
+  (a) += (b);
 
 /*
  * SET reads 4 input bytes in little-endian byte order and stores them
@@ -327,19 +327,15 @@ static void my_md5_final(unsigned char *result, void *ctx);
  * does not work.
  */
 #if defined(__i386__) || defined(__x86_64__) || defined(__vax__)
-#define MD5_SET(n) \
-        (*(const MD5_u32plus *)(const void *)&ptr[(n) * 4])
-#define MD5_GET(n) \
-        MD5_SET(n)
+#define MD5_SET(n) (*(const MD5_u32plus *)(const void *)&ptr[(n) * 4])
+#define MD5_GET(n) MD5_SET(n)
 #else
-#define MD5_SET(n) \
-        (ctx->block[(n)] = \
-        (MD5_u32plus)ptr[(n) * 4] | \
-        ((MD5_u32plus)ptr[(n) * 4 + 1] << 8) | \
-        ((MD5_u32plus)ptr[(n) * 4 + 2] << 16) | \
-        ((MD5_u32plus)ptr[(n) * 4 + 3] << 24))
-#define MD5_GET(n) \
-        (ctx->block[(n)])
+#define MD5_SET(n) (ctx->block[(n)] = \
+   (MD5_u32plus)ptr[(n) * 4] | \
+  ((MD5_u32plus)ptr[(n) * 4 + 1] <<  8) | \
+  ((MD5_u32plus)ptr[(n) * 4 + 2] << 16) | \
+  ((MD5_u32plus)ptr[(n) * 4 + 3] << 24))
+#define MD5_GET(n) (ctx->block[(n)])
 #endif
 
 /*
@@ -527,32 +523,32 @@ static void my_md5_final(unsigned char *result, void *in)
   memset(&ctx->buffer[used], 0, available - 8);
 
   ctx->lo <<= 3;
-  ctx->buffer[56] = curlx_ultouc((ctx->lo)&0xff);
-  ctx->buffer[57] = curlx_ultouc((ctx->lo >> 8)&0xff);
-  ctx->buffer[58] = curlx_ultouc((ctx->lo >> 16)&0xff);
+  ctx->buffer[56] = curlx_ultouc((ctx->lo) & 0xff);
+  ctx->buffer[57] = curlx_ultouc((ctx->lo >> 8) & 0xff);
+  ctx->buffer[58] = curlx_ultouc((ctx->lo >> 16) & 0xff);
   ctx->buffer[59] = curlx_ultouc(ctx->lo >> 24);
-  ctx->buffer[60] = curlx_ultouc((ctx->hi)&0xff);
-  ctx->buffer[61] = curlx_ultouc((ctx->hi >> 8)&0xff);
-  ctx->buffer[62] = curlx_ultouc((ctx->hi >> 16)&0xff);
+  ctx->buffer[60] = curlx_ultouc((ctx->hi) & 0xff);
+  ctx->buffer[61] = curlx_ultouc((ctx->hi >> 8) & 0xff);
+  ctx->buffer[62] = curlx_ultouc((ctx->hi >> 16) & 0xff);
   ctx->buffer[63] = curlx_ultouc(ctx->hi >> 24);
 
   my_md5_body(ctx, ctx->buffer, 64);
 
-  result[0] = curlx_ultouc((ctx->a)&0xff);
-  result[1] = curlx_ultouc((ctx->a >> 8)&0xff);
-  result[2] = curlx_ultouc((ctx->a >> 16)&0xff);
+  result[0] = curlx_ultouc((ctx->a) & 0xff);
+  result[1] = curlx_ultouc((ctx->a >> 8) & 0xff);
+  result[2] = curlx_ultouc((ctx->a >> 16) & 0xff);
   result[3] = curlx_ultouc(ctx->a >> 24);
-  result[4] = curlx_ultouc((ctx->b)&0xff);
-  result[5] = curlx_ultouc((ctx->b >> 8)&0xff);
-  result[6] = curlx_ultouc((ctx->b >> 16)&0xff);
+  result[4] = curlx_ultouc((ctx->b) & 0xff);
+  result[5] = curlx_ultouc((ctx->b >> 8) & 0xff);
+  result[6] = curlx_ultouc((ctx->b >> 16) & 0xff);
   result[7] = curlx_ultouc(ctx->b >> 24);
-  result[8] = curlx_ultouc((ctx->c)&0xff);
-  result[9] = curlx_ultouc((ctx->c >> 8)&0xff);
-  result[10] = curlx_ultouc((ctx->c >> 16)&0xff);
+  result[8] = curlx_ultouc((ctx->c) & 0xff);
+  result[9] = curlx_ultouc((ctx->c >> 8) & 0xff);
+  result[10] = curlx_ultouc((ctx->c >> 16) & 0xff);
   result[11] = curlx_ultouc(ctx->c >> 24);
-  result[12] = curlx_ultouc((ctx->d)&0xff);
-  result[13] = curlx_ultouc((ctx->d >> 8)&0xff);
-  result[14] = curlx_ultouc((ctx->d >> 16)&0xff);
+  result[12] = curlx_ultouc((ctx->d) & 0xff);
+  result[13] = curlx_ultouc((ctx->d >> 8) & 0xff);
+  result[14] = curlx_ultouc((ctx->d >> 16) & 0xff);
   result[15] = curlx_ultouc(ctx->d >> 24);
 
   memset(ctx, 0, sizeof(*ctx));
index 7eae1708b7de295ec9849004b8865fe637af1541..991c9eb921c387b2e4c6771e163c5f6d0dce5989 100644 (file)
@@ -165,8 +165,7 @@ static bool countcheck(const char *func, int line, const char *source)
   if(memlimit && source) {
     if(!memsize) {
       /* log to file */
-      curl_dbg_log("LIMIT %s:%d %s reached memlimit\n",
-                   source, line, func);
+      curl_dbg_log("LIMIT %s:%d %s reached memlimit\n", source, line, func);
       /* log to stderr also */
       curl_mfprintf(stderr, "LIMIT %s:%d %s reached memlimit\n",
                     source, line, func);
@@ -336,8 +335,8 @@ void curl_dbg_free(void *ptr, int line, const char *source)
   if(ptr) {
     struct memdebug *mem;
 
-  if(source)
-    curl_dbg_log("MEM %s:%d free(%p)\n", source, line, (void *)ptr);
+    if(source)
+      curl_dbg_log("MEM %s:%d free(%p)\n", source, line, (void *)ptr);
 
 #ifdef __INTEL_COMPILER
 #  pragma warning(push)
@@ -386,7 +385,7 @@ SEND_TYPE_RETV curl_dbg_send(SEND_TYPE_ARG1 sockfd,
   rc = send(sockfd, buf, len, flags);
   if(source)
     curl_dbg_log("SEND %s:%d send(%lu) = %ld\n",
-                source, line, (unsigned long)len, (long)rc);
+                 source, line, (unsigned long)len, (long)rc);
   return rc;
 }
 
@@ -401,7 +400,7 @@ RECV_TYPE_RETV curl_dbg_recv(RECV_TYPE_ARG1 sockfd, RECV_TYPE_ARG2 buf,
   rc = recv(sockfd, buf, len, flags);
   if(source)
     curl_dbg_log("RECV %s:%d recv(%lu) = %ld\n",
-                source, line, (unsigned long)len, (long)rc);
+                 source, line, (unsigned long)len, (long)rc);
   return rc;
 }
 
@@ -515,8 +514,7 @@ int curl_dbg_fclose(FILE *file, int line, const char *source)
   DEBUGASSERT(file != NULL);
 
   if(source)
-    curl_dbg_log("FILE %s:%d fclose(%p)\n",
-                 source, line, (void *)file);
+    curl_dbg_log("FILE %s:%d fclose(%p)\n", source, line, (void *)file);
 
   /* !checksrc! disable BANNEDFUNC 1 */
   res = fclose(file);
index 7ebe47315de99fc4c6fc23b8b7533786f7e36f2e..92edd78878c808756c6869a25c93cd022bc2dd5c 100644 (file)
@@ -56,8 +56,8 @@ struct Curl_easy;
 #  endif
 #endif
 
-#define READ_ERROR    ((size_t) -1)
-#define STOP_FILLING  ((size_t) -2)
+#define READ_ERROR   ((size_t)-1)
+#define STOP_FILLING ((size_t)-2)
 
 static size_t mime_subparts_read(char *buffer, size_t size, size_t nitems,
                                  void *instream, bool *hasread);
@@ -77,12 +77,12 @@ static curl_off_t encoder_qp_size(curl_mimepart *part);
 static curl_off_t mime_size(curl_mimepart *part);
 
 static const struct mime_encoder encoders[] = {
-  {"binary", encoder_nop_read, encoder_nop_size},
-  {"8bit", encoder_nop_read, encoder_nop_size},
-  {"7bit", encoder_7bit_read, encoder_nop_size},
-  {"base64", encoder_base64_read, encoder_base64_size},
-  {"quoted-printable", encoder_qp_read, encoder_qp_size},
-  {ZERO_NULL, ZERO_NULL, ZERO_NULL}
+  { "binary", encoder_nop_read, encoder_nop_size },
+  { "8bit", encoder_nop_read, encoder_nop_size },
+  { "7bit", encoder_7bit_read, encoder_nop_size },
+  { "base64", encoder_base64_read, encoder_base64_size },
+  { "quoted-printable", encoder_qp_read, encoder_qp_size },
+  { ZERO_NULL, ZERO_NULL, ZERO_NULL }
 };
 
 /* Quoted-printable character class table.
@@ -120,15 +120,13 @@ static const unsigned char qp_class[] = {
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0                 /* F0 - FF */
 };
 
-
 /* Binary --> hexadecimal ASCII table. */
 static const char aschex[] =
   "\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x41\x42\x43\x44\x45\x46";
 
-
 #ifndef __VMS
 #define filesize(name, stat_data) (stat_data.st_size)
-#define fopen_read curlx_fopen
+#define fopen_read                curlx_fopen
 
 #else
 
@@ -143,13 +141,12 @@ static const char aschex[] =
  * and CD/DVD images should be either a STREAM_LF format or a fixed format.
  *
  */
-curl_off_t VmsRealFileSize(const char *name,
-                           const struct_stat *stat_buf)
+curl_off_t VmsRealFileSize(const char *name, const struct_stat *stat_buf)
 {
   char buffer[8192];
   curl_off_t count;
   int ret_stat;
-  FILE * file;
+  FILE *file;
 
   file = curlx_fopen(name, FOPEN_READTEXT); /* VMS */
   if(!file)
@@ -173,8 +170,7 @@ curl_off_t VmsRealFileSize(const char *name,
  *  if not to call a routine to get the correct size.
  *
  */
-static curl_off_t VmsSpecialSize(const char *name,
-                                 const struct_stat *stat_buf)
+static curl_off_t VmsSpecialSize(const char *name, const struct_stat *stat_buf)
 {
   switch(stat_buf->st_fab_rfm) {
   case FAB$C_VAR:
@@ -196,7 +192,7 @@ static curl_off_t VmsSpecialSize(const char *name,
  * record format of the file.
  *
  */
-static FILE * vmsfopenread(const char *file, const char *mode)
+static FILE *vmsfopenread(const char *file, const char *mode)
 {
   struct_stat statbuf;
   int result;
@@ -217,7 +213,6 @@ static FILE * vmsfopenread(const char *file, const char *mode)
 #define fopen_read vmsfopenread
 #endif
 
-
 #ifndef HAVE_BASENAME
 /*
   (Quote from The Open Group Base Specifications Issue 6 IEEE Std 1003.1, 2004
@@ -264,7 +259,7 @@ static char *Curl_basename(char *path)
   return path;
 }
 
-#define basename(x)  Curl_basename((x))
+#define basename(x)  Curl_basename(x)
 #endif
 
 
@@ -372,7 +367,6 @@ static void cleanup_encoder_state(struct mime_encoder_state *p)
   p->bufend = 0;
 }
 
-
 /* Dummy encoder. This is used for 8bit and binary content encodings. */
 static size_t encoder_nop_read(char *buffer, size_t size, bool ateof,
                                struct curl_mimepart *part)
@@ -400,7 +394,6 @@ static curl_off_t encoder_nop_size(curl_mimepart *part)
   return part->datasize;
 }
 
-
 /* 7bit encoder: the encoder is just a data validity check. */
 static size_t encoder_7bit_read(char *buffer, size_t size, bool ateof,
                                 curl_mimepart *part)
@@ -426,7 +419,6 @@ static size_t encoder_7bit_read(char *buffer, size_t size, bool ateof,
   return cursize;
 }
 
-
 /* Base64 content encoder. */
 static size_t encoder_base64_read(char *buffer, size_t size, bool ateof,
                                   curl_mimepart *part)
@@ -521,7 +513,6 @@ static curl_off_t encoder_base64_size(curl_mimepart *part)
   return size + 2 * ((size - 1) / MAX_ENCODED_LINE_LENGTH);
 }
 
-
 /* Quoted-printable lookahead.
  *
  * Check if a CRLF or end of data is in input buffer at current position + n.
@@ -558,7 +549,7 @@ static size_t encoder_qp_read(char *buffer, size_t size, bool ateof,
     size_t len = 1;
     size_t consumed = 1;
     int i = st->buf[st->bufbeg];
-    buf[0] = (char) i;
+    buf[0] = (char)i;
     buf[1] = aschex[(i >> 4) & 0xF];
     buf[2] = aschex[i & 0xF];
 
@@ -649,13 +640,12 @@ static curl_off_t encoder_qp_size(curl_mimepart *part)
   return part->datasize ? -1 : 0;
 }
 
-
 /* In-memory data callbacks. */
 /* Argument is a pointer to the mime part. */
 static size_t mime_mem_read(char *buffer, size_t size, size_t nitems,
                             void *instream)
 {
-  curl_mimepart *part = (curl_mimepart *) instream;
+  curl_mimepart *part = (curl_mimepart *)instream;
   size_t sz = curlx_sotouz(part->datasize - part->state.offset);
   (void)size;  /* Always 1 */
 
@@ -673,7 +663,7 @@ static size_t mime_mem_read(char *buffer, size_t size, size_t nitems,
 
 static int mime_mem_seek(void *instream, curl_off_t offset, int whence)
 {
-  curl_mimepart *part = (curl_mimepart *) instream;
+  curl_mimepart *part = (curl_mimepart *)instream;
 
   switch(whence) {
   case SEEK_CUR:
@@ -693,10 +683,9 @@ static int mime_mem_seek(void *instream, curl_off_t offset, int whence)
 
 static void mime_mem_free(void *ptr)
 {
-  Curl_safefree(((curl_mimepart *) ptr)->data);
+  Curl_safefree(((curl_mimepart *)ptr)->data);
 }
 
-
 /* Named file callbacks. */
 /* Argument is a pointer to the mime part. */
 static bool mime_open_file(curl_mimepart *part)
@@ -712,7 +701,7 @@ static bool mime_open_file(curl_mimepart *part)
 static size_t mime_file_read(char *buffer, size_t size, size_t nitems,
                              void *instream)
 {
-  curl_mimepart *part = (curl_mimepart *) instream;
+  curl_mimepart *part = (curl_mimepart *)instream;
 
   if(!nitems)
     return STOP_FILLING;
@@ -725,7 +714,7 @@ static size_t mime_file_read(char *buffer, size_t size, size_t nitems,
 
 static int mime_file_seek(void *instream, curl_off_t offset, int whence)
 {
-  curl_mimepart *part = (curl_mimepart *) instream;
+  curl_mimepart *part = (curl_mimepart *)instream;
 
   if(whence == SEEK_SET && !offset && !part->fp)
     return CURL_SEEKFUNC_OK;   /* Not open: implicitly already at BOF. */
@@ -739,7 +728,7 @@ static int mime_file_seek(void *instream, curl_off_t offset, int whence)
 
 static void mime_file_free(void *ptr)
 {
-  curl_mimepart *part = (curl_mimepart *) ptr;
+  curl_mimepart *part = (curl_mimepart *)ptr;
 
   if(part->fp) {
     curlx_fclose(part->fp);
@@ -748,7 +737,6 @@ static void mime_file_free(void *ptr)
   Curl_safefree(part->data);
 }
 
-
 /* Subparts callbacks. */
 /* Argument is a pointer to the mime structure. */
 
@@ -798,7 +786,7 @@ static size_t read_part_content(curl_mimepart *part,
   }
 
   /* If we can determine we are at end of part data, spare a read. */
-  if(part->datasize != (curl_off_t) -1 &&
+  if(part->datasize != (curl_off_t)-1 &&
      part->state.offset >= part->datasize) {
     /* sz is already zero. */
   }
@@ -809,8 +797,8 @@ static size_t read_part_content(curl_mimepart *part,
        * Cannot be processed as other kinds since read function requires
        * an additional parameter and is highly recursive.
        */
-       sz = mime_subparts_read(buffer, 1, bufsize, part->arg, hasread);
-       break;
+      sz = mime_subparts_read(buffer, 1, bufsize, part->arg, hasread);
+      break;
     case MIMEKIND_FILE:
       if(part->fp && feof(part->fp))
         break;  /* At EOF. */
@@ -916,7 +904,7 @@ static size_t readback_part(curl_mimepart *part,
 
   while(bufsize) {
     size_t sz = 0;
-    struct curl_slist *hdr = (struct curl_slist *) part->state.ptr;
+    struct curl_slist *hdr = (struct curl_slist *)part->state.ptr;
     switch(part->state.state) {
     case MIMESTATE_BEGIN:
       mimesetstate(&part->state,
@@ -994,7 +982,7 @@ static size_t readback_part(curl_mimepart *part,
 static size_t mime_subparts_read(char *buffer, size_t size, size_t nitems,
                                  void *instream, bool *hasread)
 {
-  curl_mime *mime = (curl_mime *) instream;
+  curl_mime *mime = (curl_mime *)instream;
   size_t cursize = 0;
   (void)size;  /* Always 1 */
 
@@ -1070,7 +1058,7 @@ static int mime_part_rewind(curl_mimepart *part)
   if(part->state.state > targetstate) {
     res = CURL_SEEKFUNC_CANTSEEK;
     if(part->seekfunc) {
-      res = part->seekfunc(part->arg, (curl_off_t) 0, SEEK_SET);
+      res = part->seekfunc(part->arg, (curl_off_t)0, SEEK_SET);
       switch(res) {
       case CURL_SEEKFUNC_OK:
       case CURL_SEEKFUNC_FAIL:
@@ -1095,7 +1083,7 @@ static int mime_part_rewind(curl_mimepart *part)
 
 static int mime_subparts_seek(void *instream, curl_off_t offset, int whence)
 {
-  curl_mime *mime = (curl_mime *) instream;
+  curl_mime *mime = (curl_mime *)instream;
   curl_mimepart *part;
   int result = CURL_SEEKFUNC_OK;
 
@@ -1126,10 +1114,10 @@ static void cleanup_part_content(curl_mimepart *part)
   part->readfunc = NULL;
   part->seekfunc = NULL;
   part->freefunc = NULL;
-  part->arg = (void *) part;          /* Defaults to part itself. */
+  part->arg = (void *)part;           /* Defaults to part itself. */
   part->data = NULL;
   part->fp = NULL;
-  part->datasize = (curl_off_t) 0;    /* No size yet. */
+  part->datasize = (curl_off_t)0;     /* No size yet. */
   cleanup_encoder_state(&part->encstate);
   part->kind = MIMEKIND_NONE;
   part->flags &= ~(unsigned int)MIME_FAST_READ;
@@ -1139,7 +1127,7 @@ static void cleanup_part_content(curl_mimepart *part)
 
 static void mime_subparts_free(void *ptr)
 {
-  curl_mime *mime = (curl_mime *) ptr;
+  curl_mime *mime = (curl_mime *)ptr;
 
   if(mime && mime->parent) {
     mime->parent->freefunc = NULL;  /* Be sure we will not be called again. */
@@ -1151,7 +1139,7 @@ static void mime_subparts_free(void *ptr)
 /* Do not free subparts: unbind them. This is used for the top level only. */
 static void mime_subparts_unbind(void *ptr)
 {
-  curl_mime *mime = (curl_mime *) ptr;
+  curl_mime *mime = (curl_mime *)ptr;
 
   if(mime && mime->parent) {
     mime->parent->freefunc = NULL;  /* Be sure we will not be called again. */
@@ -1160,7 +1148,6 @@ static void mime_subparts_unbind(void *ptr)
   }
 }
 
-
 void Curl_mime_cleanpart(curl_mimepart *part)
 {
   if(part) {
@@ -1207,7 +1194,7 @@ CURLcode Curl_mime_duppart(struct Curl_easy *data,
   case MIMEKIND_NONE:
     break;
   case MIMEKIND_DATA:
-    res = curl_mime_data(dst, src->data, (size_t) src->datasize);
+    res = curl_mime_data(dst, src->data, (size_t)src->datasize);
     break;
   case MIMEKIND_FILE:
     res = curl_mime_filedata(dst, src->data);
@@ -1226,7 +1213,7 @@ CURLcode Curl_mime_duppart(struct Curl_easy *data,
     res = mime ? curl_mime_subparts(dst, mime) : CURLE_OUT_OF_MEMORY;
 
     /* Duplicate subparts. */
-    for(s = ((curl_mime *) src->arg)->firstpart; !res && s; s = s->nextpart) {
+    for(s = ((curl_mime *)src->arg)->firstpart; !res && s; s = s->nextpart) {
       d = curl_mime_addpart(mime);
       res = d ? Curl_mime_duppart(data, d, s) : CURLE_OUT_OF_MEMORY;
     }
@@ -1287,7 +1274,7 @@ curl_mime *curl_mime_init(void *easy)
 
     memset(mime->boundary, '-', MIME_BOUNDARY_DASHES);
     if(Curl_rand_alnum(easy,
-                       (unsigned char *) &mime->boundary[MIME_BOUNDARY_DASHES],
+                       (unsigned char *)&mime->boundary[MIME_BOUNDARY_DASHES],
                        MIME_RAND_BOUNDARY_CHARS + 1)) {
       /* failed to get random separator, bail out */
       curlx_free(mime);
@@ -1302,7 +1289,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((char *)part, 0, sizeof(*part));
   part->lastreadstatus = 1; /* Successful read status. */
   mimesetstate(&part->state, MIMESTATE_BEGIN, NULL);
 }
@@ -1367,8 +1354,7 @@ CURLcode curl_mime_filename(curl_mimepart *part, const char *filename)
 }
 
 /* Set mime part content from memory data. */
-CURLcode curl_mime_data(curl_mimepart *part,
-                        const char *ptr, size_t datasize)
+CURLcode curl_mime_data(curl_mimepart *part, const char *ptr, size_t datasize)
 {
   if(!part)
     return CURLE_BAD_FUNCTION_ARGUMENT;
@@ -1558,7 +1544,7 @@ CURLcode Curl_mime_set_subparts(curl_mimepart *part,
        they might not be positioned at start. Rewind them now, as
        a future check while rewinding the parent may cause this
        content to be skipped. */
-    if(mime_subparts_seek(subparts, (curl_off_t) 0, SEEK_SET) !=
+    if(mime_subparts_seek(subparts, (curl_off_t)0, SEEK_SET) !=
        CURL_SEEKFUNC_OK)
       return CURLE_SEND_FAIL_REWIND;
 
@@ -1580,12 +1566,11 @@ CURLcode curl_mime_subparts(curl_mimepart *part, curl_mime *subparts)
   return Curl_mime_set_subparts(part, subparts, TRUE);
 }
 
-
 /* Readback from top mime. */
 /* Argument is the dummy top part. */
 size_t Curl_mime_read(char *buffer, size_t size, size_t nitems, void *instream)
 {
-  curl_mimepart *part = (curl_mimepart *) instream;
+  curl_mimepart *part = (curl_mimepart *)instream;
   size_t ret;
   bool hasread;
 
@@ -1668,8 +1653,7 @@ static curl_off_t mime_size(curl_mimepart *part)
   if(size >= 0 && !(part->flags & MIME_BODY_ONLY)) {
     /* Compute total part size. */
     size += slist_size(part->curlheaders, 2, NULL, 0);
-    size += slist_size(part->userheaders, 2,
-                       STRCONST("Content-Type"));
+    size += slist_size(part->userheaders, 2, STRCONST("Content-Type"));
     size += 2;    /* CRLF after headers. */
   }
   return size;
@@ -1718,16 +1702,16 @@ const char *Curl_mime_contenttype(const char *filename)
     const char *type;
   };
   static const struct ContentType ctts[] = {
-    {".gif",  "image/gif"},
-    {".jpg",  "image/jpeg"},
-    {".jpeg", "image/jpeg"},
-    {".png",  "image/png"},
-    {".svg",  "image/svg+xml"},
-    {".txt",  "text/plain"},
-    {".htm",  "text/html"},
-    {".html", "text/html"},
-    {".pdf",  "application/pdf"},
-    {".xml",  "application/xml"}
+    { ".gif",  "image/gif" },
+    { ".jpg",  "image/jpeg" },
+    { ".jpeg", "image/jpeg" },
+    { ".png",  "image/png" },
+    { ".svg",  "image/svg+xml" },
+    { ".txt",  "text/plain" },
+    { ".htm",  "text/html" },
+    { ".html", "text/html" },
+    { ".pdf",  "application/pdf" },
+    { ".xml",  "application/xml" }
   };
 
   if(filename) {
@@ -1808,7 +1792,7 @@ CURLcode Curl_mime_prepare_headers(struct Curl_easy *data,
   }
 
   if(part->kind == MIMEKIND_MULTIPART) {
-    mime = (curl_mime *) part->arg;
+    mime = (curl_mime *)part->arg;
     if(mime)
       boundary = mime->boundary;
   }
@@ -1821,10 +1805,10 @@ CURLcode Curl_mime_prepare_headers(struct Curl_easy *data,
   if(!search_header(part->userheaders, STRCONST("Content-Disposition"))) {
     if(!disposition)
       if(part->filename || part->name ||
-        (contenttype && !curl_strnequal(contenttype, "multipart/", 10)))
-          disposition = DISPOSITION_DEFAULT;
+         (contenttype && !curl_strnequal(contenttype, "multipart/", 10)))
+        disposition = DISPOSITION_DEFAULT;
     if(disposition && curl_strequal(disposition, "attachment") &&
-     !part->name && !part->filename)
+       !part->name && !part->filename)
       disposition = NULL;
     if(disposition) {
       char *name = NULL;
@@ -1854,8 +1838,8 @@ CURLcode Curl_mime_prepare_headers(struct Curl_easy *data,
       Curl_safefree(filename);
       if(ret)
         return ret;
-      }
     }
+  }
 
   /* Issue Content-Type header. */
   if(contenttype) {
@@ -1870,7 +1854,7 @@ CURLcode Curl_mime_prepare_headers(struct Curl_easy *data,
     if(part->encoder)
       cte = part->encoder->name;
     else if(contenttype && strategy == MIMESTRATEGY_MAIL &&
-     part->kind != MIMEKIND_MULTIPART)
+            part->kind != MIMEKIND_MULTIPART)
       cte = "8bit";
     if(cte) {
       ret = Curl_mime_add_header(&part->curlheaders,
@@ -1909,7 +1893,7 @@ static void mime_unpause(curl_mimepart *part)
     if(part->lastreadstatus == CURL_READFUNC_PAUSE)
       part->lastreadstatus = 1; /* Successful read status. */
     if(part->kind == MIMEKIND_MULTIPART) {
-      curl_mime *mime = (curl_mime *) part->arg;
+      curl_mime *mime = (curl_mime *)part->arg;
 
       if(mime) {
         curl_mimepart *subpart;
@@ -2113,7 +2097,7 @@ static CURLcode cr_mime_resume_from(struct Curl_easy *data,
     curl_off_t passed = 0;
 
     do {
-      char scratch[4*1024];
+      char scratch[4 * 1024];
       size_t readthisamountnow =
         (offset - passed > (curl_off_t)sizeof(scratch)) ?
         sizeof(scratch) :
@@ -2262,8 +2246,7 @@ CURLcode curl_mime_encoder(curl_mimepart *part, const char *encoding)
   return CURLE_NOT_BUILT_IN;
 }
 
-CURLcode curl_mime_data(curl_mimepart *part,
-                        const char *data, size_t datasize)
+CURLcode curl_mime_data(curl_mimepart *part, const char *data, size_t datasize)
 {
   (void)part;
   (void)data;
@@ -2278,8 +2261,7 @@ CURLcode curl_mime_filedata(curl_mimepart *part, const char *filename)
   return CURLE_NOT_BUILT_IN;
 }
 
-CURLcode curl_mime_data_cb(curl_mimepart *part,
-                           curl_off_t datasize,
+CURLcode curl_mime_data_cb(curl_mimepart *part, curl_off_t datasize,
                            curl_read_callback readfunc,
                            curl_seek_callback seekfunc,
                            curl_free_callback freefunc,
index 5073a38f709a03b8c910a477303f44a13d973c23..3ac196180bff5a63caac30a907c0659f59425d7d 100644 (file)
@@ -165,12 +165,11 @@ CURLcode Curl_creader_set_mime(struct Curl_easy *data, curl_mimepart *part);
 /* if disabled */
 #define Curl_mime_initpart(x)
 #define Curl_mime_cleanpart(x)
-#define Curl_mime_duppart(x,y,z) CURLE_OK /* Nothing to duplicate. Succeed */
-#define Curl_mime_set_subparts(a,b,c) CURLE_NOT_BUILT_IN
-#define Curl_mime_prepare_headers(a,b,c,d,e) CURLE_NOT_BUILT_IN
-#define Curl_mime_read NULL
-#define Curl_creader_set_mime(x,y) ((void)x, CURLE_NOT_BUILT_IN)
+#define Curl_mime_duppart(x, y, z) CURLE_OK /* Nothing to duplicate. Succeed */
+#define Curl_mime_set_subparts(a, b, c)          CURLE_NOT_BUILT_IN
+#define Curl_mime_prepare_headers(a, b, c, d, e) CURLE_NOT_BUILT_IN
+#define Curl_mime_read                           NULL
+#define Curl_creader_set_mime(x, y)              ((void)x, CURLE_NOT_BUILT_IN)
 #endif
 
-
 #endif /* HEADER_CURL_MIME_H */
index 046917aeb5f0ede468ef0fd6e52f07d4af9db55f..5c58e907b4b5ad3a9bb97711677585577e6b9c5c 100644 (file)
@@ -171,8 +171,8 @@ static int dollarstring(const char *p, const char **end)
   return (int)num - 1;
 }
 
-#define is_arg_used(x,y) ((x)[(y)/8] & (1 << ((y)&7)))
-#define mark_arg_used(x,y) ((x)[y/8] |= (unsigned char)(1 << ((y)&7)))
+#define is_arg_used(x, y)   ((x)[(y) / 8] & (1 << ((y) & 7)))
+#define mark_arg_used(x, y) ((x)[y / 8] |= (unsigned char)(1 << ((y) & 7)))
 
 /*
  * Parse the format string.
@@ -206,7 +206,7 @@ static int parsefmt(const char *format,
   int max_param = -1;
   int i;
   int ocount = 0;
-  unsigned char usedinput[MAX_PARAMETERS/8];
+  unsigned char usedinput[MAX_PARAMETERS / 8];
   size_t outlen = 0;
   struct outsegment *optr;
   int use_dollar = DOLLAR_UNKNOWN;
@@ -364,8 +364,15 @@ static int parsefmt(const char *format,
           if(!(flags & FLAGS_LEFT))
             flags |= FLAGS_PAD_NIL;
           FALLTHROUGH();
-        case '1': case '2': case '3': case '4':
-        case '5': case '6': case '7': case '8': case '9': {
+        case '1':
+        case '2':
+        case '3':
+        case '4':
+        case '5':
+        case '6':
+        case '7':
+        case '8':
+        case '9': {
           curl_off_t num;
           flags |= FLAGS_WIDTH;
           fmt--;
@@ -431,7 +438,7 @@ static int parsefmt(const char *format,
           type = FORMAT_LONGU;
         else
           type = FORMAT_INTU;
-        flags |= FLAGS_OCTAL|FLAGS_UNSIGNED;
+        flags |= FLAGS_OCTAL | FLAGS_UNSIGNED;
         break;
       case 'x':
         if(flags & FLAGS_LONGLONG)
@@ -440,7 +447,7 @@ static int parsefmt(const char *format,
           type = FORMAT_LONGU;
         else
           type = FORMAT_INTU;
-        flags |= FLAGS_HEX|FLAGS_UNSIGNED;
+        flags |= FLAGS_HEX | FLAGS_UNSIGNED;
         break;
       case 'X':
         if(flags & FLAGS_LONGLONG)
@@ -449,7 +456,7 @@ static int parsefmt(const char *format,
           type = FORMAT_LONGU;
         else
           type = FORMAT_INTU;
-        flags |= FLAGS_HEX|FLAGS_UPPER|FLAGS_UNSIGNED;
+        flags |= FLAGS_HEX | FLAGS_UPPER | FLAGS_UNSIGNED;
         break;
       case 'c':
         type = FORMAT_INT;
@@ -464,7 +471,7 @@ static int parsefmt(const char *format,
         break;
       case 'E':
         type = FORMAT_DOUBLE;
-        flags |= FLAGS_FLOATE|FLAGS_UPPER;
+        flags |= FLAGS_FLOATE | FLAGS_UPPER;
         break;
       case 'g':
         type = FORMAT_DOUBLE;
@@ -472,7 +479,7 @@ static int parsefmt(const char *format,
         break;
       case 'G':
         type = FORMAT_DOUBLE;
-        flags |= FLAGS_FLOATG|FLAGS_UPPER;
+        flags |= FLAGS_FLOATG | FLAGS_UPPER;
         break;
       default:
         /* invalid instruction, disregard and continue */
@@ -627,9 +634,9 @@ static bool out_double(void *userp,
                        double dnum,
                        char *work, int *donep)
 {
-  char formatbuf[32]="%";
+  char formatbuf[32] = "%";
   char *fptr = &formatbuf[1];
-  size_t left = sizeof(formatbuf)-strlen(formatbuf);
+  size_t left = sizeof(formatbuf) - strlen(formatbuf);
   int flags = p->flags;
   int width = p->width;
   int prec = p->prec;
@@ -745,7 +752,7 @@ static bool out_number(void *userp,
     if(!(flags & FLAGS_LEFT))
       while(--width > 0)
         OUTCHAR(' ');
-    OUTCHAR((char) num);
+    OUTCHAR((char)num);
     if(flags & FLAGS_LEFT)
       while(--width > 0)
         OUTCHAR(' ');
@@ -868,7 +875,7 @@ static bool out_string(void *userp,
 
   if(!str) {
     /* Write null string if there is space.  */
-    if(prec == -1 || prec >= (int) sizeof(nilstr) - 1) {
+    if(prec == -1 || prec >= (int)sizeof(nilstr) - 1) {
       str = nilstr;
       len = sizeof(nilstr) - 1;
       /* Disable quotes around (nil) */
@@ -916,10 +923,10 @@ static bool out_pointer(void *userp,
 {
   /* Generic pointer.  */
   if(ptr) {
-    size_t num = (size_t) ptr;
+    size_t num = (size_t)ptr;
 
     /* If the pointer is not NULL, write it as a %#x spec.  */
-    p->flags |= FLAGS_HEX|FLAGS_ALT;
+    p->flags |= FLAGS_HEX | FLAGS_ALT;
     if(out_number(userp, stream, p, num, 0, work, donep))
       return TRUE;
   }
@@ -958,13 +965,12 @@ static bool out_pointer(void *userp,
  * All output is sent to the 'stream()' callback, one byte at a time.
  */
 
-static int formatf(
-  void *userp, /* untouched by format(), just sent to the stream() function in
-                  the second argument */
-  /* function pointer called for each output character */
-  int (*stream)(unsigned char, void *),
-  const char *format,    /* %-formatted string */
-  va_list ap_save) /* list of parameters */
+static int formatf(void *userp, /* untouched by format(), just sent to the
+                                   stream() function in the second argument */
+                   /* function pointer called for each output character */
+                   int (*stream)(unsigned char, void *),
+                   const char *format, /* %-formatted string */
+                   va_list ap_save) /* list of parameters */
 {
   int done = 0;   /* number of characters written  */
   int i;
@@ -1065,15 +1071,15 @@ static int formatf(
       /* Answer the count of characters written.  */
 #ifdef HAVE_LONG_LONG_TYPE
       if(p.flags & FLAGS_LONGLONG)
-        *(LONG_LONG_TYPE *) iptr->val.ptr = (LONG_LONG_TYPE)done;
+        *(LONG_LONG_TYPE *)iptr->val.ptr = (LONG_LONG_TYPE)done;
       else
 #endif
         if(p.flags & FLAGS_LONG)
-          *(long *) iptr->val.ptr = (long)done;
+          *(long *)iptr->val.ptr = (long)done;
       else if(!(p.flags & FLAGS_SHORT))
-        *(int *) iptr->val.ptr = (int)done;
+        *(int *)iptr->val.ptr = (int)done;
       else
-        *(short *) iptr->val.ptr = (short)done;
+        *(short *)iptr->val.ptr = (short)done;
       break;
 
     default:
@@ -1138,7 +1144,7 @@ static int alloc_addbyter(unsigned char outc, void *f)
   CURLcode result = curlx_dyn_addn(infop->b, &outc, 1);
   if(result) {
     infop->merr = result == CURLE_TOO_LARGE ? MERR_TOO_LARGE : MERR_MEM;
-    return 1 ; /* fail */
+    return 1; /* fail */
   }
   return 0;
 }
index a8975d53919b5da6fa791ef9db7778c64e00afdc..df5f37775f4fb664e956fcda5bd9d01745935053 100644 (file)
@@ -51,8 +51,8 @@
 /* #define MQTT_MSG_PINGREQ    0xC0 */
 #define MQTT_MSG_PINGRESP   0xD0
 
-#define MQTT_CONNACK_LEN 2
-#define MQTT_SUBACK_LEN 3
+#define MQTT_CONNACK_LEN  2
+#define MQTT_SUBACK_LEN   3
 #define MQTT_CLIENTID_LEN 12 /* "curl0123abcd" */
 
 /* meta key for storing protocol meta at easy handle */
@@ -92,7 +92,6 @@ struct MQTT {
   BIT(pingsent); /* 1 while we wait for ping response */
 };
 
-
 /*
  * Forward declarations.
  */
@@ -315,7 +314,7 @@ static CURLcode mqtt_connect(struct Curl_easy *data)
   int rc = 0;
   /* remain length */
   int remain_pos = 0;
-  char remain[4] = {0};
+  char remain[4] = { 0 };
   size_t packetlen = 0;
   size_t start_user = 0;
   size_t start_pwd = 0;
@@ -324,12 +323,10 @@ static CURLcode mqtt_connect(struct Curl_easy *data)
   char *packet = NULL;
 
   /* extracting username from request */
-  const char *username = data->state.aptr.user ?
-    data->state.aptr.user : "";
+  const char *username = data->state.aptr.user ? data->state.aptr.user : "";
   const size_t ulen = strlen(username);
   /* extracting password from request */
-  const char *passwd = data->state.aptr.passwd ?
-    data->state.aptr.passwd : "";
+  const char *passwd = data->state.aptr.passwd ? data->state.aptr.passwd : "";
   const size_t plen = strlen(passwd);
   const size_t payloadlen = ulen + plen + MQTT_CLIENTID_LEN + 2 +
   /* The plus 2s below are for the MSB and LSB describing the length of the
@@ -531,7 +528,7 @@ static CURLcode mqtt_subscribe(struct Curl_easy *data)
   packet[1 + n] = (mqtt->packetid >> 8) & 0xff;
   packet[2 + n] = mqtt->packetid & 0xff;
   packet[3 + n] = (topiclen >> 8) & 0xff;
-  packet[4 + n ] = topiclen & 0xff;
+  packet[4 + n] = topiclen & 0xff;
   memcpy(&packet[5 + n], topic, topiclen);
   packet[5 + n + topiclen] = 0; /* QoS zero */
 
@@ -661,7 +658,7 @@ static size_t mqtt_decode_len(unsigned char *buf,
 }
 
 #ifdef DEBUGBUILD
-static const char *statenames[]={
+static const char *statenames[] = {
   "MQTT_FIRST",
   "MQTT_REMAINING_LENGTH",
   "MQTT_CONNACK",
@@ -695,7 +692,6 @@ static void mqstate(struct Curl_easy *data,
     mqtt->nextstate = nextstate;
 }
 
-
 static CURLcode mqtt_read_publish(struct Curl_easy *data, bool *done)
 {
   CURLcode result = CURLE_OK;
@@ -756,7 +752,7 @@ MQTT_SUBACK_COMING:
     FALLTHROUGH();
   case MQTT_PUB_REMAIN: {
     /* read rest of packet, but no more. Cap to buffer size */
-    char buffer[4*1024];
+    char buffer[4 * 1024];
     size_t rest = mq->npacket;
     if(rest > sizeof(buffer))
       rest = sizeof(buffer);
@@ -886,7 +882,7 @@ static CURLcode mqtt_doing(struct Curl_easy *data, bool *done)
   if(result)
     return result;
 
-  infof(data, "mqtt_doing: state [%d]", (int) mqtt->state);
+  infof(data, "mqtt_doing: state [%d]", (int)mqtt->state);
   switch(mqtt->state) {
   case MQTT_FIRST:
     /* Read the initial byte only */
index c5b78f53e446735e0eb1ce49b2a8792ce83718df..b912f7a212f2aad8f0475cde286a8d819ec1c670 100644 (file)
@@ -55,7 +55,7 @@
 #include "urlapi-int.h"
 
 /* initial multi->xfers table size for a full multi */
-#define CURL_XFER_TABLE_SIZE    512
+#define CURL_XFER_TABLE_SIZE 512
 
 /*
   CURL_SOCKET_HASH_TABLE_SIZE should be a prime number. Increasing it from 97
@@ -195,12 +195,11 @@ static void mstate(struct Curl_easy *data, CURLMstate state
 }
 
 #ifndef DEBUGBUILD
-#define multistate(x,y) mstate(x,y)
+#define multistate(x, y) mstate(x, y)
 #else
-#define multistate(x,y) mstate(x,y, __LINE__)
+#define multistate(x, y) mstate(x, y, __LINE__)
 #endif
 
-
 /* multi->proto_hash destructor. Should never be called as elements
  * MUST be added with their own destructor */
 static void ph_freeentry(void *p)
@@ -343,15 +342,14 @@ static void multi_warn_debug(struct Curl_multi *multi, struct Curl_easy *data)
   if(!multi->warned) {
     infof(data, "!!! WARNING !!!");
     infof(data, "This is a debug build of libcurl, "
-          "do not use in production.");
+                "do not use in production.");
     multi->warned = TRUE;
   }
 }
 #else
-#define multi_warn_debug(x,y) Curl_nop_stmt
+#define multi_warn_debug(x, y) Curl_nop_stmt
 #endif
 
-
 static CURLMcode multi_xfers_add(struct Curl_multi *multi,
                                  struct Curl_easy *data)
 {
@@ -380,8 +378,8 @@ static CURLMcode multi_xfers_add(struct Curl_multi *multi,
         new_size = max_capacity; /* can not be larger than this */
       }
       else {
-         /* make it a 64 multiple, since our bitsets frow by that and
-          * small (easy_multi) grows to at least 64 on first resize. */
+        /* make it a 64 multiple, since our bitsets frow by that and
+         * small (easy_multi) grows to at least 64 on first resize. */
         new_size = (((used + min_unused) + 63) / 64) * 64;
       }
     }
@@ -564,7 +562,7 @@ static bool multi_conn_should_close(struct connectdata *conn,
      && !(conn->http_negotiate_state == GSS_AUTHRECV ||
           conn->proxy_negotiate_state == GSS_AUTHRECV)
 #endif
-     )
+    )
     return TRUE;
 
   /* Unless this connection is for a "connect-only" transfer, it
@@ -842,7 +840,7 @@ CURLMcode curl_multi_remove_handle(CURLM *m, CURL *d)
   if(data->state.lastconnect_id != -1) {
     /* Mark any connect-only connection for closure */
     Curl_cpool_do_by_id(data, data->state.lastconnect_id,
-                            close_connect_only, NULL);
+                        close_connect_only, NULL);
   }
 
 #ifdef USE_LIBPSL
@@ -1076,14 +1074,12 @@ static CURLcode mstate_perform_pollset(struct Curl_easy *data,
   else {
     /* Default is to obey the data->req.keepon flags for send/recv */
     if(CURL_WANT_RECV(data) && CONN_SOCK_IDX_VALID(conn->recv_idx)) {
-      result = Curl_pollset_add_in(
-        data, ps, conn->sock[conn->recv_idx]);
+      result = Curl_pollset_add_in(data, ps, conn->sock[conn->recv_idx]);
     }
 
     if(!result && Curl_req_want_send(data) &&
        CONN_SOCK_IDX_VALID(conn->send_idx)) {
-      result = Curl_pollset_add_out(
-        data, ps, conn->sock[conn->send_idx]);
+      result = Curl_pollset_add_out(data, ps, conn->sock[conn->send_idx]);
     }
   }
   if(!result)
@@ -1174,34 +1170,33 @@ CURLMcode Curl_multi_pollset(struct Curl_easy *data,
   if(CURL_TRC_M_is_verbose(data)) {
     size_t timeout_count = Curl_llist_count(&data->state.timeoutlist);
     switch(ps->n) {
-      case 0:
-        CURL_TRC_M(data, "pollset[], timeouts=%zu, paused %d/%d (r/w)",
-                   timeout_count,
-                   Curl_xfer_send_is_paused(data),
-                   Curl_xfer_recv_is_paused(data));
-        break;
-      case 1:
-        CURL_TRC_M(data, "pollset[fd=%" FMT_SOCKET_T " %s%s], timeouts=%zu",
-                   ps->sockets[0],
-                   (ps->actions[0] & CURL_POLL_IN) ? "IN" : "",
-                   (ps->actions[0] & CURL_POLL_OUT) ? "OUT" : "",
-                   timeout_count);
-        break;
-      case 2:
-        CURL_TRC_M(data, "pollset[fd=%" FMT_SOCKET_T " %s%s, "
-                   "fd=%" FMT_SOCKET_T " %s%s], timeouts=%zu",
-                   ps->sockets[0],
-                   (ps->actions[0] & CURL_POLL_IN) ? "IN" : "",
-                   (ps->actions[0] & CURL_POLL_OUT) ? "OUT" : "",
-                   ps->sockets[1],
-                   (ps->actions[1] & CURL_POLL_IN) ? "IN" : "",
-                   (ps->actions[1] & CURL_POLL_OUT) ? "OUT" : "",
-                   timeout_count);
-        break;
-      default:
-        CURL_TRC_M(data, "pollset[fds=%u], timeouts=%zu",
-                   ps->n, timeout_count);
-        break;
+    case 0:
+      CURL_TRC_M(data, "pollset[], timeouts=%zu, paused %d/%d (r/w)",
+                 timeout_count,
+                 Curl_xfer_send_is_paused(data),
+                 Curl_xfer_recv_is_paused(data));
+      break;
+    case 1:
+      CURL_TRC_M(data, "pollset[fd=%" FMT_SOCKET_T " %s%s], timeouts=%zu",
+                 ps->sockets[0],
+                 (ps->actions[0] & CURL_POLL_IN) ? "IN" : "",
+                 (ps->actions[0] & CURL_POLL_OUT) ? "OUT" : "",
+                 timeout_count);
+      break;
+    case 2:
+      CURL_TRC_M(data, "pollset[fd=%" FMT_SOCKET_T " %s%s, "
+                 "fd=%" FMT_SOCKET_T " %s%s], timeouts=%zu",
+                 ps->sockets[0],
+                 (ps->actions[0] & CURL_POLL_IN) ? "IN" : "",
+                 (ps->actions[0] & CURL_POLL_OUT) ? "OUT" : "",
+                 ps->sockets[1],
+                 (ps->actions[1] & CURL_POLL_IN) ? "IN" : "",
+                 (ps->actions[1] & CURL_POLL_OUT) ? "OUT" : "",
+                 timeout_count);
+      break;
+    default:
+      CURL_TRC_M(data, "pollset[fds=%u], timeouts=%zu", ps->n, timeout_count);
+      break;
     }
     CURL_TRC_EASY_TIMERS(data);
   }
@@ -1259,8 +1254,7 @@ CURLMcode curl_multi_fdset(CURLM *m,
         if((int)ps.sockets[i] > this_max_fd)
           this_max_fd = (int)ps.sockets[i];
       }
-    }
-    while(Curl_uint32_bset_next(&multi->process, mid, &mid));
+    } while(Curl_uint32_bset_next(&multi->process, mid, &mid));
   }
 
   Curl_cshutdn_setfds(&multi->cshutdn, multi->admin,
@@ -1305,8 +1299,7 @@ CURLMcode curl_multi_waitfds(CURLM *m,
       }
       Curl_multi_pollset(data, &ps);
       need += Curl_waitfds_add_ps(&cwfds, &ps);
-    }
-    while(Curl_uint32_bset_next(&multi->process, mid, &mid));
+    } while(Curl_uint32_bset_next(&multi->process, mid, &mid));
   }
 
   need += Curl_cshutdn_add_waitfds(&multi->cshutdn, multi->admin, &cwfds);
@@ -1394,8 +1387,7 @@ static CURLMcode multi_wait(struct Curl_multi *multi,
         result = CURLM_OUT_OF_MEMORY;
         goto out;
       }
-    }
-    while(Curl_uint32_bset_next(&multi->process, mid, &mid));
+    } while(Curl_uint32_bset_next(&multi->process, mid, &mid));
   }
 
   if(Curl_cshutdn_add_pollfds(&multi->cshutdn, multi->admin, &cpfds)) {
@@ -1424,11 +1416,11 @@ static CURLMcode multi_wait(struct Curl_multi *multi,
   for(i = 0; i < cpfds.n; i++) {
     long mask = 0;
     if(cpfds.pfds[i].events & POLLIN)
-      mask |= FD_READ|FD_ACCEPT|FD_CLOSE;
+      mask |= FD_READ | FD_ACCEPT | FD_CLOSE;
     if(cpfds.pfds[i].events & POLLPRI)
       mask |= FD_OOB;
     if(cpfds.pfds[i].events & POLLOUT) {
-      mask |= FD_WRITE|FD_CONNECT|FD_CLOSE;
+      mask |= FD_WRITE | FD_CONNECT | FD_CLOSE;
       reset_socket_fdwrite(cpfds.pfds[i].fd);
     }
     if(mask) {
@@ -1503,9 +1495,9 @@ static CURLMcode multi_wait(struct Curl_multi *multi,
         curl_socket_t s = extra_fds[i].fd;
         wsa_events.lNetworkEvents = 0;
         if(WSAEnumNetworkEvents(s, NULL, &wsa_events) == 0) {
-          if(wsa_events.lNetworkEvents & (FD_READ|FD_ACCEPT|FD_CLOSE))
+          if(wsa_events.lNetworkEvents & (FD_READ | FD_ACCEPT | FD_CLOSE))
             mask |= CURL_WAIT_POLLIN;
-          if(wsa_events.lNetworkEvents & (FD_WRITE|FD_CONNECT|FD_CLOSE))
+          if(wsa_events.lNetworkEvents & (FD_WRITE | FD_CONNECT | FD_CLOSE))
             mask |= CURL_WAIT_POLLOUT;
           if(wsa_events.lNetworkEvents & FD_OOB)
             mask |= CURL_WAIT_POLLPRI;
@@ -1610,8 +1602,7 @@ CURLMcode curl_multi_poll(CURLM *multi,
                           int timeout_ms,
                           int *ret)
 {
-  return multi_wait(multi, extra_fds, extra_nfds, timeout_ms, ret, TRUE,
-                    TRUE);
+  return multi_wait(multi, extra_fds, extra_nfds, timeout_ms, ret, TRUE, TRUE);
 }
 
 CURLMcode curl_multi_wakeup(CURLM *m)
@@ -1864,8 +1855,7 @@ static CURLcode protocol_doing(struct Curl_easy *data, bool *done)
  * proceed with some action.
  *
  */
-static CURLcode protocol_connect(struct Curl_easy *data,
-                                 bool *protocol_done)
+static CURLcode protocol_connect(struct Curl_easy *data, bool *protocol_done)
 {
   CURLcode result = CURLE_OK;
   struct connectdata *conn = data->conn;
@@ -1874,8 +1864,7 @@ static CURLcode protocol_connect(struct Curl_easy *data,
 
   *protocol_done = FALSE;
 
-  if(Curl_conn_is_connected(conn, FIRSTSOCKET)
-     && conn->bits.protoconnstart) {
+  if(Curl_conn_is_connected(conn, FIRSTSOCKET) && conn->bits.protoconnstart) {
     /* We already are connected, get back. This may happen when the connect
        worked fine in the first call, like when we connect to a local server
        or proxy. Note that we do not know if the protocol is actually done.
@@ -1942,8 +1931,7 @@ static CURLcode multi_follow(struct Curl_easy *data,
   return CURLE_TOO_MANY_REDIRECTS;
 }
 
-static CURLcode mspeed_check(struct Curl_easy *data,
-                             struct curltime now)
+static CURLcode mspeed_check(struct Curl_easy *data, struct curltime now)
 {
   timediff_t recv_wait_ms = 0;
   timediff_t send_wait_ms = 0;
@@ -2160,8 +2148,7 @@ static CURLMcode state_do(struct Curl_easy *data,
             multi_done(data, CURLE_OK, FALSE);
 
             /* if there is no connection left, skip the DONE state */
-            multistate(data, data->conn ?
-                       MSTATE_DONE : MSTATE_COMPLETED);
+            multistate(data, data->conn ? MSTATE_DONE : MSTATE_COMPLETED);
             rc = CURLM_CALL_MULTI_PERFORM;
             goto end;
           }
@@ -2597,8 +2584,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
         if(control) {
           /* if positive, advance to DO_DONE
              if negative, go back to DOING */
-          multistate(data, control == 1 ?
-                     MSTATE_DID : MSTATE_DOING);
+          multistate(data, control == 1 ? MSTATE_DID : MSTATE_DOING);
           rc = CURLM_CALL_MULTI_PERFORM;
         }
         /* else
@@ -2796,7 +2782,6 @@ statemachine_end:
   return rc;
 }
 
-
 CURLMcode curl_multi_perform(CURLM *m, int *running_handles)
 {
   CURLMcode returncode = CURLM_OK;
@@ -2832,8 +2817,7 @@ CURLMcode curl_multi_perform(CURLM *m, int *running_handles)
       result = multi_runsingle(multi, &now, data);
       if(result)
         returncode = result;
-    }
-    while(Curl_uint32_bset_next(&multi->process, mid, &mid));
+    } while(Curl_uint32_bset_next(&multi->process, mid, &mid));
   }
   sigpipe_restore(&pipe_st);
 
@@ -2925,8 +2909,7 @@ CURLMcode curl_multi_cleanup(CURLM *m)
 #endif
         if(data->state.internal)
           Curl_close(&data);
-      }
-      while(Curl_uint32_tbl_next(&multi->xfers, mid, &mid, &entry));
+      } while(Curl_uint32_tbl_next(&multi->xfers, mid, &mid, &entry));
     }
 
     Curl_cpool_destroy(&multi->cpool);
@@ -3017,7 +3000,6 @@ CURLMsg *curl_multi_info_read(CURLM *m, int *msgs_in_queue)
   return NULL;
 }
 
-
 void Curl_multi_will_close(struct Curl_easy *data, curl_socket_t s)
 {
   if(data) {
@@ -3160,8 +3142,7 @@ static CURLMcode multi_run_dirty(struct multi_run_ctx *mrc)
         CURL_TRC_M(multi->admin, "multi_run_dirty, %u no longer found", mid);
         Curl_uint32_bset_remove(&multi->dirty, mid);
       }
-    }
-    while(Curl_uint32_bset_next(&multi->dirty, mid, &mid));
+    } while(Curl_uint32_bset_next(&multi->dirty, mid, &mid));
   }
 
 out:
@@ -3243,8 +3224,7 @@ out:
 }
 
 #undef curl_multi_setopt
-CURLMcode curl_multi_setopt(CURLM *m,
-                            CURLMoption option, ...)
+CURLMcode curl_multi_setopt(CURLM *m, CURLMoption option, ...)
 {
   CURLMcode res = CURLM_OK;
   va_list param;
@@ -3305,14 +3285,13 @@ CURLMcode curl_multi_setopt(CURLM *m,
     break;
   case CURLMOPT_PIPELINING_SERVER_BL:
     break;
-  case CURLMOPT_MAX_CONCURRENT_STREAMS:
-    {
-      long streams = va_arg(param, long);
-      if((streams < 1) || (streams > INT_MAX))
-        streams = 100;
-      multi->max_concurrent_streams = (unsigned int)streams;
-    }
+  case CURLMOPT_MAX_CONCURRENT_STREAMS: {
+    long streams = va_arg(param, long);
+    if((streams < 1) || (streams > INT_MAX))
+      streams = 100;
+    multi->max_concurrent_streams = (unsigned int)streams;
     break;
+  }
   case CURLMOPT_NETWORK_CHANGED: {
     long val = va_arg(param, long);
     if(val & CURLMNWC_CLEAR_DNS) {
@@ -3371,7 +3350,6 @@ CURLMcode curl_multi_socket_all(CURLM *m, int *running_handles)
   return multi_socket(multi, TRUE, CURL_SOCKET_BAD, 0, running_handles);
 }
 
-
 static bool multi_has_dirties(struct Curl_multi *multi)
 {
   uint32_t mid;
@@ -3388,8 +3366,7 @@ static bool multi_has_dirties(struct Curl_multi *multi)
         CURL_TRC_M(multi->admin, "dirty transfer %u no longer found", mid);
         Curl_uint32_bset_remove(&multi->dirty, mid);
       }
-    }
-    while(Curl_uint32_bset_next(&multi->dirty, mid, &mid));
+    } while(Curl_uint32_bset_next(&multi->dirty, mid, &mid));
   }
   return FALSE;
 }
@@ -3398,7 +3375,7 @@ static void multi_timeout(struct Curl_multi *multi,
                           struct curltime *expire_time,
                           long *timeout_ms)
 {
-  static const struct curltime tv_zero = {0, 0};
+  static const struct curltime tv_zero = { 0, 0 };
 #ifndef CURL_DISABLE_VERBOSE_STRINGS
   struct Curl_easy *data = NULL;
 #endif
@@ -3453,8 +3430,7 @@ static void multi_timeout(struct Curl_multi *multi,
 
 #ifndef CURL_DISABLE_VERBOSE_STRINGS
   if(data && CURL_TRC_TIMER_is_verbose(data)) {
-    struct Curl_llist_node *e =
-      Curl_llist_head(&data->state.timeoutlist);
+    struct Curl_llist_node *e = Curl_llist_head(&data->state.timeoutlist);
     if(e) {
       struct time_node *n = Curl_node_elem(e);
       CURL_TRC_TIMER(data, n->eid, "gives multi timeout in %ldms",
@@ -3506,8 +3482,7 @@ CURLMcode Curl_update_timer(struct Curl_multi *multi)
     set_value = TRUE;
   }
   else if(multi->last_timeout_ms < 0) {
-    CURL_TRC_M(multi->admin, "[TIMER] set %ldms, none before",
-               timeout_ms);
+    CURL_TRC_M(multi->admin, "[TIMER] set %ldms, none before", timeout_ms);
     set_value = TRUE;
   }
   else if(curlx_timediff_us(multi->last_expire_ts, expire_ts)) {
@@ -3543,8 +3518,7 @@ CURLMcode Curl_update_timer(struct Curl_multi *multi)
  *
  * Remove a given timestamp from the list of timeouts.
  */
-static void
-multi_deltimeout(struct Curl_easy *data, expire_id eid)
+static void multi_deltimeout(struct Curl_easy *data, expire_id eid)
 {
   struct Curl_llist_node *e;
   struct Curl_llist *timeoutlist = &data->state.timeoutlist;
@@ -3565,11 +3539,10 @@ multi_deltimeout(struct Curl_easy *data, expire_id eid)
  * of list is always the timeout nearest in time.
  *
  */
-static CURLMcode
-multi_addtimeout(struct Curl_easy *data,
-                 struct curltime *stamp,
-                 expire_id eid,
-                 const struct curltime *nowp)
+static CURLMcode multi_addtimeout(struct Curl_easy *data,
+                                  struct curltime *stamp,
+                                  expire_id eid,
+                                  const struct curltime *nowp)
 {
   struct Curl_llist_node *e;
   struct time_node *node;
@@ -3594,7 +3567,6 @@ multi_addtimeout(struct Curl_easy *data,
         break;
       prev = e;
     }
-
   }
   /* else
      this is the first timeout on the list */
@@ -3621,8 +3593,8 @@ void Curl_expire_ex(struct Curl_easy *data,
   DEBUGASSERT(id < EXPIRE_LAST);
 
   set = *nowp;
-  set.tv_sec += (time_t)(milli/1000); /* might be a 64 to 32 bits conversion */
-  set.tv_usec += (int)(milli%1000)*1000;
+  set.tv_sec += (time_t)(milli / 1000); /* may be a 64 to 32-bit conversion */
+  set.tv_usec += (int)(milli % 1000) * 1000;
 
   if(set.tv_usec >= 1000000) {
     set.tv_sec++;
@@ -3783,8 +3755,7 @@ static void process_pending_handles(struct Curl_multi *multi)
       /* transfer no longer known, should not happen */
       Curl_uint32_bset_remove(&multi->pending, mid);
       DEBUGASSERT(0);
-    }
-    while(Curl_uint32_bset_next(&multi->pending, mid, &mid));
+    } while(Curl_uint32_bset_next(&multi->pending, mid, &mid));
   }
 }
 
@@ -3820,8 +3791,7 @@ CURL **curl_multi_get_handles(CURLM *m)
         DEBUGASSERT(i < count);
         if(!data->state.internal)
           a[i++] = data;
-      }
-      while(Curl_uint32_tbl_next(&multi->xfers, mid, &mid, &entry));
+      } while(Curl_uint32_tbl_next(&multi->xfers, mid, &mid, &entry));
     }
     a[i] = NULL; /* last entry is a NULL */
   }
index 026cbd29968e46a7f9c41dacd6d0cdcd09484a8a..40b49da85d95f391fd9c13f7ec4fcaf20e307b37 100644 (file)
@@ -64,7 +64,7 @@ struct mev_sh_entry {
 
 static size_t mev_sh_entry_hash(void *key, size_t key_length, size_t slots_num)
 {
-  curl_socket_t fd = *((curl_socket_t *) key);
+  curl_socket_t fd = *((curl_socket_t *)key);
   (void)key_length;
   return (fd % (curl_socket_t)slots_num);
 }
@@ -72,8 +72,9 @@ static size_t mev_sh_entry_hash(void *key, size_t key_length, size_t slots_num)
 static size_t mev_sh_entry_compare(void *k1, size_t k1_len,
                                    void *k2, size_t k2_len)
 {
-  (void)k1_len; (void)k2_len;
-  return (*((curl_socket_t *) k1)) == (*((curl_socket_t *) k2));
+  (void)k1_len;
+  (void)k2_len;
+  return (*((curl_socket_t *)k1)) == (*((curl_socket_t *)k2));
 }
 
 /* sockhash entry destructor callback */
@@ -85,8 +86,8 @@ static void mev_sh_entry_dtor(void *freethis)
 }
 
 /* look up a given socket in the socket hash, skip invalid sockets */
-static struct mev_sh_entry *
-mev_sh_entry_get(struct Curl_hash *sh, curl_socket_t s)
+static struct mev_sh_entry *mev_sh_entry_get(struct Curl_hash *sh,
+                                             curl_socket_t s)
 {
   if(s != CURL_SOCKET_BAD) {
     /* only look for proper sockets */
@@ -96,8 +97,8 @@ mev_sh_entry_get(struct Curl_hash *sh, curl_socket_t s)
 }
 
 /* make sure this socket is present in the hash for this handle */
-static struct mev_sh_entry *
-mev_sh_entry_add(struct Curl_hash *sh, curl_socket_t s)
+static struct mev_sh_entry *mev_sh_entry_add(struct Curl_hash *sh,
+                                             curl_socket_t s)
 {
   struct mev_sh_entry *there = mev_sh_entry_get(sh, s);
   struct mev_sh_entry *check;
@@ -166,7 +167,6 @@ static bool mev_sh_entry_conn_add(struct mev_sh_entry *e,
   return TRUE;
 }
 
-
 static bool mev_sh_entry_xfer_remove(struct mev_sh_entry *e,
                                      struct Curl_easy *data)
 {
@@ -202,8 +202,7 @@ static CURLMcode mev_forget_socket(struct Curl_multi *multi,
 
   /* We managed this socket before, tell the socket callback to forget it. */
   if(entry->announced && multi->socket_cb) {
-    CURL_TRC_M(data, "ev %s, call(fd=%" FMT_SOCKET_T ", ev=REMOVE)",
-               cause, s);
+    CURL_TRC_M(data, "ev %s, call(fd=%" FMT_SOCKET_T ", ev=REMOVE)", cause, s);
     mev_in_callback(multi, TRUE);
     rc = multi->socket_cb(data, s, CURL_POLL_REMOVE,
                           multi->socket_userp, entry->user_data);
@@ -446,8 +445,7 @@ static void mev_pollset_dtor(void *key, size_t klen, void *entry)
   }
 }
 
-static struct easy_pollset*
-mev_add_new_conn_pollset(struct connectdata *conn)
+static struct easy_pollset *mev_add_new_conn_pollset(struct connectdata *conn)
 {
   struct easy_pollset *ps;
 
@@ -459,8 +457,7 @@ mev_add_new_conn_pollset(struct connectdata *conn)
   return ps;
 }
 
-static struct easy_pollset*
-mev_add_new_xfer_pollset(struct Curl_easy *data)
+static struct easy_pollset *mev_add_new_xfer_pollset(struct Curl_easy *data)
 {
   struct easy_pollset *ps;
 
@@ -472,9 +469,8 @@ mev_add_new_xfer_pollset(struct Curl_easy *data)
   return ps;
 }
 
-static struct easy_pollset *
-mev_get_last_pollset(struct Curl_easy *data,
-                     struct connectdata *conn)
+static struct easy_pollset *mev_get_last_pollset(struct Curl_easy *data,
+                                                 struct connectdata *conn)
 {
   if(data) {
     if(conn)
@@ -484,8 +480,7 @@ mev_get_last_pollset(struct Curl_easy *data,
   return NULL;
 }
 
-static CURLMcode mev_assess(struct Curl_multi *multi,
-                            struct Curl_easy *data,
+static CURLMcode mev_assess(struct Curl_multi *multi, struct Curl_easy *data,
                             struct connectdata *conn)
 {
   struct easy_pollset ps, *last_ps;
@@ -551,13 +546,11 @@ CURLMcode Curl_multi_ev_assess_xfer_bset(struct Curl_multi *multi,
       struct Curl_easy *data = Curl_multi_get_easy(multi, mid);
       if(data)
         result = Curl_multi_ev_assess_xfer(multi, data);
-    }
-    while(!result && Curl_uint32_bset_next(set, mid, &mid));
+    } while(!result && Curl_uint32_bset_next(set, mid, &mid));
   }
   return result;
 }
 
-
 CURLMcode Curl_multi_ev_assign(struct Curl_multi *multi,
                                curl_socket_t s,
                                void *user_data)
@@ -596,8 +589,7 @@ void Curl_multi_ev_dirty_xfers(struct Curl_multi *multi,
           CURL_TRC_M(multi->admin, "socket transfer %u no longer found", mid);
           Curl_uint32_spbset_remove(&entry->xfers, mid);
         }
-      }
-      while(Curl_uint32_spbset_next(&entry->xfers, mid, &mid));
+      } while(Curl_uint32_spbset_next(&entry->xfers, mid, &mid));
     }
 
     if(entry->conn)
index 43e4db9e8270679e6b7a21efae7689f47645b8c7..4fdbe7400a4ae08d430c5ff9e4c4d97c6366065f 100644 (file)
@@ -38,7 +38,7 @@ struct mntfy_entry {
   uint32_t type;
 };
 
-#define CURL_MNTFY_CHUNK_SIZE   128
+#define CURL_MNTFY_CHUNK_SIZE 128
 
 struct mntfy_chunk {
   struct mntfy_chunk *next;
@@ -171,7 +171,7 @@ void Curl_mntfy_add(struct Curl_easy *data, unsigned int type)
      Curl_uint32_bset_contains(&multi->ntfy.enabled, (uint32_t)type)) {
     /* append to list of outstanding notifications */
     struct mntfy_chunk *tail = mntfy_non_full_tail(&multi->ntfy);
-  CURL_TRC_M(data, "[NTFY] add %d for xfer %u", type, data->mid);
+    CURL_TRC_M(data, "[NTFY] add %d for xfer %u", type, data->mid);
     if(tail)
       mntfy_chunk_append(tail, data, (uint32_t)type);
     else
index c3094a9ebe7148322fdf151330952ae1c59ced17..144d0319d0e6ddc5515b4bc3efef0ff97153ad77 100644 (file)
@@ -47,11 +47,12 @@ CURLMcode Curl_mntfy_disable(struct Curl_multi *multi, unsigned int type);
 
 void Curl_mntfy_add(struct Curl_easy *data, unsigned int type);
 
-#define CURLM_NTFY(d,t) \
-  do { if((d) && (d)->multi && (d)->multi->ntfy.ntfy_cb) \
-       Curl_mntfy_add((d), (t)); } while(0)
+#define CURLM_NTFY(d, t)                              \
+  do {                                                \
+    if((d) && (d)->multi && (d)->multi->ntfy.ntfy_cb) \
+      Curl_mntfy_add((d), (t));                       \
+  } while(0)
 
 CURLMcode Curl_mntfy_dispatch_all(struct Curl_multi *multi);
 
-
 #endif /* HEADER_CURL_MULTI_NTFY_H */
index 62c68c9cedf3478cd54dba6331d4856ee3e97e76..9db5b0100029ee1f63d09340c4a467276bf5020d 100644 (file)
@@ -68,7 +68,6 @@ CURLMcode Curl_multi_add_perform(struct Curl_multi *multi,
                                  struct Curl_easy *data,
                                  struct connectdata *conn);
 
-
 /* Return the value of the CURLMOPT_MAX_CONCURRENT_STREAMS option */
 unsigned int Curl_multi_max_concurrent_streams(struct Curl_multi *multi);
 
index f8de4082972cf27dea7e60b5695355f1367ec13e..d26d194fe2d9bab4e0fa04ca463d6726883f214d 100644 (file)
@@ -60,8 +60,8 @@ enum found_state {
 #define FOUND_LOGIN    1
 #define FOUND_PASSWORD 2
 
-#define MAX_NETRC_LINE 16384
-#define MAX_NETRC_FILE (128*1024)
+#define MAX_NETRC_LINE  16384
+#define MAX_NETRC_FILE  (128 * 1024)
 #define MAX_NETRC_TOKEN 4096
 
 /* convert a dynbuf call CURLcode error to a NETRCcode error */
@@ -318,7 +318,7 @@ static NETRCcode parsenetrc(struct store_netrc *store,
           if(!specific_login)
             Curl_safefree(login);
         }
-        if((found == (FOUND_PASSWORD|FOUND_LOGIN)) && our_login) {
+        if((found == (FOUND_PASSWORD | FOUND_LOGIN)) && our_login) {
           done = TRUE;
           break;
         }
@@ -412,8 +412,8 @@ NETRCcode Curl_parsenetrc(struct store_netrc *store, const char *host,
       }
       else {
         struct passwd pw, *pw_res;
-        if(!getpwuid_r(geteuid(), &pw, pwbuf, sizeof(pwbuf), &pw_res)
-           && pw_res) {
+        if(!getpwuid_r(geteuid(), &pw, pwbuf, sizeof(pwbuf), &pw_res) &&
+           pw_res) {
           home = pw.pw_dir;
         }
 #elif defined(HAVE_GETPWUID) && defined(HAVE_GETEUID)
index 0d6d081bfbb9e618b91e79d24ef65f3cdec21a2c..81012d0d97e6267f79b730f62fe1a223ae613a91 100644 (file)
@@ -50,14 +50,14 @@ void Curl_netrc_cleanup(struct store_netrc *s);
 NETRCcode Curl_parsenetrc(struct store_netrc *s, const char *host,
                           char **loginp, char **passwordp,
                           const char *filename);
-  /* Assume: (*passwordp)[0]=0, host[0] != 0.
  * If (*loginp)[0] = 0, search for login and password within a machine
  * section in the netrc.
  * If (*loginp)[0] != 0, search for password within machine and login.
  */
+/* Assume: (*passwordp)[0]=0, host[0] != 0.
+ * If (*loginp)[0] = 0, search for login and password within a machine
+ * section in the netrc.
+ * If (*loginp)[0] != 0, search for password within machine and login.
+ */
 #else
 /* disabled */
-#define Curl_parsenetrc(a,b,c,d,e,f) 1
+#define Curl_parsenetrc(a, b, c, d, e, f) 1
 #define Curl_netrc_init(x)
 #define Curl_netrc_cleanup(x)
 #endif
index 1e19c369c0d9cec4b690b859780dc15d926c91ad..569466fb62ecb8d7f73323fdd16d6dfb01c70541 100644 (file)
@@ -141,8 +141,7 @@ static bool match_host(const char *token, size_t tokenlen,
   else if(tokenlen < namelen) {
     /* case B, tailmatch domain */
     match = (name[namelen - tokenlen - 1] == '.') &&
-      curl_strnequal(token, name + (namelen - tokenlen),
-                     tokenlen);
+            curl_strnequal(token, name + (namelen - tokenlen), tokenlen);
   }
   /* case C passes through, not a match */
   return match;
@@ -180,11 +179,10 @@ static bool match_ip(int type, const char *token, size_t tokenlen,
     return Curl_cidr4_match(name, check, bits);
 }
 
-
 /****************************************************************
-* Checks if the host is in the noproxy list. returns TRUE if it matches and
-* therefore the proxy should NOT be used.
-****************************************************************/
+ * Checks if the host is in the noproxy list. returns TRUE if it matches and
+ * therefore the proxy should NOT be used.
+ ****************************************************************/
 bool Curl_check_noproxy(const char *name, const char *no_proxy)
 {
   char hostip[128];
index bb48edd32f2c112ea74ce312bd21d22283d83406..ba1a39181f386d9f257e20ac772d191670aed32d 100644 (file)
@@ -112,7 +112,6 @@ static Curl_recv oldap_recv;
 /*
  * LDAP protocol handler.
  */
-
 const struct Curl_handler Curl_handler_ldap = {
   "ldap",                               /* scheme */
   oldap_setup_connection,               /* setup_connection */
@@ -136,14 +135,13 @@ const struct Curl_handler Curl_handler_ldap = {
   CURLPROTO_LDAP,                       /* protocol */
   CURLPROTO_LDAP,                       /* family */
   PROTOPT_SSL_REUSE |                   /* flags */
-  PROTOPT_CONN_REUSE
+    PROTOPT_CONN_REUSE
 };
 
 #ifdef USE_SSL
 /*
  * LDAPS protocol handler.
  */
-
 const struct Curl_handler Curl_handler_ldaps = {
   "ldaps",                              /* scheme */
   oldap_setup_connection,               /* setup_connection */
@@ -167,7 +165,7 @@ const struct Curl_handler Curl_handler_ldaps = {
   CURLPROTO_LDAPS,                      /* protocol */
   CURLPROTO_LDAP,                       /* family */
   PROTOPT_SSL |                         /* flags */
-  PROTOPT_CONN_REUSE
+    PROTOPT_CONN_REUSE
 };
 #endif
 
@@ -281,7 +279,7 @@ static CURLcode oldap_url_parse(struct Curl_easy *data, LDAPURLDesc **ludp)
     result = rc == LDAP_URL_ERR_MEM ? CURLE_OUT_OF_MEMORY :
       CURLE_URL_MALFORMAT;
     rc -= LDAP_URL_SUCCESS;
-    if((size_t) rc < CURL_ARRAYSIZE(url_errs))
+    if((size_t)rc < CURL_ARRAYSIZE(url_errs))
       msg = url_errs[rc];
     failf(data, "LDAP local: %s", msg);
   }
@@ -507,8 +505,7 @@ static ber_slen_t ldapsb_tls_write(Sockbuf_IO_Desc *sbiod, void *buf,
                                    ber_len_t len);
 static int ldapsb_tls_close(Sockbuf_IO_Desc *sbiod);
 
-static Sockbuf_IO ldapsb_tls =
-{
+static Sockbuf_IO ldapsb_tls = {
   ldapsb_tls_setup,
   ldapsb_tls_remove,
   ldapsb_tls_ctrl,
@@ -658,7 +655,7 @@ static CURLcode oldap_connect(struct Curl_easy *data, bool *done)
   ldap_set_option(li->ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF);
 
   {
-    ber_len_t max = 256*1024;
+    ber_len_t max = 256 * 1024;
     Sockbuf *sb;
     if((ldap_get_option(li->ld, LDAP_OPT_SOCKBUF, &sb) != LDAP_OPT_SUCCESS) ||
        /* Set the maximum allowed size of an incoming message, which to
@@ -730,7 +727,7 @@ 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,
+          unsigned short mech = Curl_sasl_decode_mech((char *)bvals[i].bv_val,
                                                       bvals[i].bv_len, &llen);
           if(bvals[i].bv_len == llen)
             li->sasl.authmechs |= mech;
@@ -829,7 +826,7 @@ static CURLcode oldap_connecting(struct Curl_easy *data, bool *done)
   struct connectdata *conn = data->conn;
   struct ldapconninfo *li = Curl_conn_meta_get(conn, CURL_META_LDAP_CONN);
   LDAPMessage *msg = NULL;
-  struct timeval tv = {0, 0};
+  struct timeval tv = { 0, 0 };
   int code = LDAP_SUCCESS;
   int rc;
 
@@ -1091,7 +1088,7 @@ static CURLcode oldap_recv(struct Curl_easy *data, int sockindex, char *buf,
   int rc;
   LDAPMessage *msg = NULL;
   BerElement *ber = NULL;
-  struct timeval tv = {0, 0};
+  struct timeval tv = { 0, 0 };
   struct berval bv, *bvals;
   CURLcode result = CURLE_AGAIN;
   int code;
@@ -1246,30 +1243,26 @@ static CURLcode oldap_recv(struct Curl_easy *data, int sockindex, char *buf,
 }
 
 #ifdef USE_SSL
-static int
-ldapsb_tls_setup(Sockbuf_IO_Desc *sbiod, void *arg)
+static int ldapsb_tls_setup(Sockbuf_IO_Desc *sbiod, void *arg)
 {
   sbiod->sbiod_pvt = arg;
   return 0;
 }
 
-static int
-ldapsb_tls_remove(Sockbuf_IO_Desc *sbiod)
+static int ldapsb_tls_remove(Sockbuf_IO_Desc *sbiod)
 {
   sbiod->sbiod_pvt = NULL;
   return 0;
 }
 
 /* We do not need to do anything because libcurl does it already */
-static int
-ldapsb_tls_close(Sockbuf_IO_Desc *sbiod)
+static int ldapsb_tls_close(Sockbuf_IO_Desc *sbiod)
 {
   (void)sbiod;
   return 0;
 }
 
-static int
-ldapsb_tls_ctrl(Sockbuf_IO_Desc *sbiod, int opt, void *arg)
+static int ldapsb_tls_ctrl(Sockbuf_IO_Desc *sbiod, int opt, void *arg)
 {
   (void)arg;
   if(opt == LBER_SB_OPT_DATA_READY) {
@@ -1279,8 +1272,8 @@ ldapsb_tls_ctrl(Sockbuf_IO_Desc *sbiod, int opt, void *arg)
   return 0;
 }
 
-static ber_slen_t
-ldapsb_tls_read(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len)
+static ber_slen_t ldapsb_tls_read(Sockbuf_IO_Desc *sbiod, void *buf,
+                                  ber_len_t len)
 {
   struct Curl_easy *data = sbiod->sbiod_pvt;
   ber_slen_t ret = 0;
@@ -1304,8 +1297,8 @@ ldapsb_tls_read(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len)
   }
   return ret;
 }
-static ber_slen_t
-ldapsb_tls_write(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len)
+static ber_slen_t ldapsb_tls_write(Sockbuf_IO_Desc *sbiod, void *buf,
+                                   ber_len_t len)
 {
   struct Curl_easy *data = sbiod->sbiod_pvt;
   ber_slen_t ret = 0;
index 2c3eb67fd2e67976b7b1371141eceb7518992c49..0649de454b4c3dcaff537d88226635d2d71ae77b 100644 (file)
@@ -107,17 +107,19 @@ static int parsedate(const char *date, time_t *output);
 #if !defined(CURL_DISABLE_PARSEDATE) || !defined(CURL_DISABLE_FTP) || \
   !defined(CURL_DISABLE_FILE) || defined(USE_GNUTLS)
 /* These names are also used by FTP and FILE code */
-const char * const Curl_wkday[] =
-{"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
-const char * const Curl_month[]=
-{ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
-  "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
+const char * const Curl_wkday[] = {
+  "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"
+};
+const char * const Curl_month[] = {
+  "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+  "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+};
 #endif
 
 #ifndef CURL_DISABLE_PARSEDATE
-static const char * const weekday[] =
-{ "Monday", "Tuesday", "Wednesday", "Thursday",
-  "Friday", "Saturday", "Sunday" };
+static const char * const weekday[] = {
+  "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"
+};
 
 struct tzinfo {
   char name[5];
@@ -127,83 +129,83 @@ struct tzinfo {
 /* Here's a bunch of frequently used time zone names. These were supported
    by the old getdate parser. */
 #define tDAYZONE -60       /* offset for daylight savings time */
-static const struct tzinfo tz[]= {
-  {"GMT", 0},              /* Greenwich Mean */
-  {"UT",  0},              /* Universal Time */
-  {"UTC", 0},              /* Universal (Coordinated) */
-  {"WET", 0},              /* Western European */
-  {"BST", 0 tDAYZONE},     /* British Summer */
-  {"WAT", 60},             /* West Africa */
-  {"AST", 240},            /* Atlantic Standard */
-  {"ADT", 240 tDAYZONE},   /* Atlantic Daylight */
-  {"EST", 300},            /* Eastern Standard */
-  {"EDT", 300 tDAYZONE},   /* Eastern Daylight */
-  {"CST", 360},            /* Central Standard */
-  {"CDT", 360 tDAYZONE},   /* Central Daylight */
-  {"MST", 420},            /* Mountain Standard */
-  {"MDT", 420 tDAYZONE},   /* Mountain Daylight */
-  {"PST", 480},            /* Pacific Standard */
-  {"PDT", 480 tDAYZONE},   /* Pacific Daylight */
-  {"YST", 540},            /* Yukon Standard */
-  {"YDT", 540 tDAYZONE},   /* Yukon Daylight */
-  {"HST", 600},            /* Hawaii Standard */
-  {"HDT", 600 tDAYZONE},   /* Hawaii Daylight */
-  {"CAT", 600},            /* Central Alaska */
-  {"AHST", 600},           /* Alaska-Hawaii Standard */
-  {"NT",  660},            /* Nome */ /* spellchecker:disable-line */
-  {"IDLW", 720},           /* International Date Line West */
-  {"CET", -60},            /* Central European */
-  {"MET", -60},            /* Middle European */
-  {"MEWT", -60},           /* Middle European Winter */
-  {"MEST", -60 tDAYZONE},  /* Middle European Summer */
-  {"CEST", -60 tDAYZONE},  /* Central European Summer */
-  {"MESZ", -60 tDAYZONE},  /* Middle European Summer */
-  {"FWT", -60},            /* French Winter */
-  {"FST", -60 tDAYZONE},   /* French Summer */
-  {"EET", -120},           /* Eastern Europe, USSR Zone 1 */
-  {"WAST", -420}, /* spellchecker:disable-line */
-                           /* West Australian Standard */
-  {"WADT", -420 tDAYZONE}, /* West Australian Daylight */
-  {"CCT", -480},           /* China Coast, USSR Zone 7 */
-  {"JST", -540},           /* Japan Standard, USSR Zone 8 */
-  {"EAST", -600},          /* Eastern Australian Standard */
-  {"EADT", -600 tDAYZONE}, /* Eastern Australian Daylight */
-  {"GST", -600},           /* Guam Standard, USSR Zone 9 */
-  {"NZT", -720},           /* New Zealand */
-  {"NZST", -720},          /* New Zealand Standard */
-  {"NZDT", -720 tDAYZONE}, /* New Zealand Daylight */
-  {"IDLE", -720},          /* International Date Line East */
+static const struct tzinfo tz[] = {
+  { "GMT",     0 },          /* Greenwich Mean */
+  { "UT",      0 },          /* Universal Time */
+  { "UTC",     0 },          /* Universal (Coordinated) */
+  { "WET",     0 },          /* Western European */
+  { "BST",     0 tDAYZONE }, /* British Summer */
+  { "WAT",    60 },          /* West Africa */
+  { "AST",   240 },          /* Atlantic Standard */
+  { "ADT",   240 tDAYZONE }, /* Atlantic Daylight */
+  { "EST",   300 },          /* Eastern Standard */
+  { "EDT",   300 tDAYZONE }, /* Eastern Daylight */
+  { "CST",   360 },          /* Central Standard */
+  { "CDT",   360 tDAYZONE }, /* Central Daylight */
+  { "MST",   420 },          /* Mountain Standard */
+  { "MDT",   420 tDAYZONE }, /* Mountain Daylight */
+  { "PST",   480 },          /* Pacific Standard */
+  { "PDT",   480 tDAYZONE }, /* Pacific Daylight */
+  { "YST",   540 },          /* Yukon Standard */
+  { "YDT",   540 tDAYZONE }, /* Yukon Daylight */
+  { "HST",   600 },          /* Hawaii Standard */
+  { "HDT",   600 tDAYZONE }, /* Hawaii Daylight */
+  { "CAT",   600 },          /* Central Alaska */
+  { "AHST",  600 },          /* Alaska-Hawaii Standard */
+  { "NT",    660 },          /* Nome */ /* spellchecker:disable-line */
+  { "IDLW",  720 },          /* International Date Line West */
+  { "CET",   -60 },          /* Central European */
+  { "MET",   -60 },          /* Middle European */
+  { "MEWT",  -60 },          /* Middle European Winter */
+  { "MEST",  -60 tDAYZONE }, /* Middle European Summer */
+  { "CEST",  -60 tDAYZONE }, /* Central European Summer */
+  { "MESZ",  -60 tDAYZONE }, /* Middle European Summer */
+  { "FWT",   -60 },          /* French Winter */
+  { "FST",   -60 tDAYZONE }, /* French Summer */
+  { "EET",  -120 },          /* Eastern Europe, USSR Zone 1 */
+  { "WAST", -420 }, /* spellchecker:disable-line */
+                             /* West Australian Standard */
+  { "WADT", -420 tDAYZONE }, /* West Australian Daylight */
+  { "CCT",  -480 },          /* China Coast, USSR Zone 7 */
+  { "JST",  -540 },          /* Japan Standard, USSR Zone 8 */
+  { "EAST", -600 },          /* Eastern Australian Standard */
+  { "EADT", -600 tDAYZONE }, /* Eastern Australian Daylight */
+  { "GST",  -600 },          /* Guam Standard, USSR Zone 9 */
+  { "NZT",  -720 },          /* New Zealand */
+  { "NZST", -720 },          /* New Zealand Standard */
+  { "NZDT", -720 tDAYZONE }, /* New Zealand Daylight */
+  { "IDLE", -720 },          /* International Date Line East */
   /* Next up: Military timezone names. RFC822 allowed these, but (as noted in
      RFC 1123) had their signs wrong. Here we use the correct signs to match
      actual military usage.
    */
-  {"A",  1 * 60},         /* Alpha */
-  {"B",  2 * 60},         /* Bravo */
-  {"C",  3 * 60},         /* Charlie */
-  {"D",  4 * 60},         /* Delta */
-  {"E",  5 * 60},         /* Echo */
-  {"F",  6 * 60},         /* Foxtrot */
-  {"G",  7 * 60},         /* Golf */
-  {"H",  8 * 60},         /* Hotel */
-  {"I",  9 * 60},         /* India */
+  { "A",   1 * 60 },         /* Alpha */
+  { "B",   2 * 60 },         /* Bravo */
+  { "C",   3 * 60 },         /* Charlie */
+  { "D",   4 * 60 },         /* Delta */
+  { "E",   5 * 60 },         /* Echo */
+  { "F",   6 * 60 },         /* Foxtrot */
+  { "G",   7 * 60 },         /* Golf */
+  { "H",   8 * 60 },         /* Hotel */
+  { "I",   9 * 60 },         /* India */
   /* "J", Juliet is not used as a timezone, to indicate the observer's local
      time */
-  {"K", 10 * 60},         /* Kilo */
-  {"L", 11 * 60},         /* Lima */
-  {"M", 12 * 60},         /* Mike */
-  {"N",  -1 * 60},         /* November */
-  {"O",  -2 * 60},         /* Oscar */
-  {"P",  -3 * 60},         /* Papa */
-  {"Q",  -4 * 60},         /* Quebec */
-  {"R",  -5 * 60},         /* Romeo */
-  {"S",  -6 * 60},         /* Sierra */
-  {"T",  -7 * 60},         /* Tango */
-  {"U",  -8 * 60},         /* Uniform */
-  {"V",  -9 * 60},         /* Victor */
-  {"W", -10 * 60},         /* Whiskey */
-  {"X", -11 * 60},         /* X-ray */
-  {"Y", -12 * 60},         /* Yankee */
-  {"Z", 0},                /* Zulu, zero meridian, a.k.a. UTC */
+  { "K",  10 * 60 },         /* Kilo */
+  { "L",  11 * 60 },         /* Lima */
+  { "M",  12 * 60 },         /* Mike */
+  { "N",  -1 * 60 },         /* November */
+  { "O",  -2 * 60 },         /* Oscar */
+  { "P",  -3 * 60 },         /* Papa */
+  { "Q",  -4 * 60 },         /* Quebec */
+  { "R",  -5 * 60 },         /* Romeo */
+  { "S",  -6 * 60 },         /* Sierra */
+  { "T",  -7 * 60 },         /* Tango */
+  { "U",  -8 * 60 },         /* Uniform */
+  { "V",  -9 * 60 },         /* Victor */
+  { "W", -10 * 60 },         /* Whiskey */
+  { "X", -11 * 60 },         /* X-ray */
+  { "Y", -12 * 60 },         /* Yankee */
+  { "Z", 0 },                /* Zulu, zero meridian, a.k.a. UTC */
 };
 
 /* returns:
@@ -260,7 +262,7 @@ static int checktz(const char *check, size_t len)
     size_t ilen = strlen(what->name);
     if((ilen == len) &&
        curl_strnequal(check, what->name, len))
-      return what->offset*60;
+      return what->offset * 60;
     what++;
   }
   return -1;
@@ -286,12 +288,13 @@ enum assume {
 static time_t time2epoch(int sec, int min, int hour,
                          int mday, int mon, int year)
 {
-  static const int month_days_cumulative[12] =
-    { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
+  static const int month_days_cumulative[12] = {
+    0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
+  };
   int leap_days = year - (mon <= 1);
   leap_days = ((leap_days / 4) - (leap_days / 100) + (leap_days / 400)
                - (1969 / 4) + (1969 / 100) - (1969 / 400));
-  return ((((time_t) (year - 1970) * 365
+  return ((((time_t)(year - 1970) * 365
             + leap_days + month_days_cumulative[mon] + mday - 1) * 24
            + hour) * 60 + min) * 60 + sec;
 }
@@ -304,13 +307,12 @@ static int oneortwodigit(const char *date, const char **endp)
   int num = date[0] - '0';
   if(ISDIGIT(date[1])) {
     *endp = &date[2];
-    return num*10 + (date[1] - '0');
+    return num * 10 + (date[1] - '0');
   }
   *endp = &date[1];
   return num;
 }
 
-
 /* HH:MM:SS or HH:MM and accept single-digits too */
 static bool match_time(const char *date,
                        int *h, int *m, int *s, char **endp)
@@ -444,11 +446,11 @@ static int parsedate(const char *date, time_t *output)
              anyone has a more authoritative source for the exact maximum time
              zone offsets, please speak up! */
           found = TRUE;
-          tzoff = (val/100 * 60 + val%100)*60;
+          tzoff = (val / 100 * 60 + val % 100) * 60;
 
           /* the + and - prefix indicates the local time compared to GMT,
              this we need their reversed math to get what we want */
-          tzoff = date[-1]=='+' ? -tzoff : tzoff;
+          tzoff = date[-1] == '+' ? -tzoff : tzoff;
         }
 
         else if((num_digits == 8) &&
@@ -457,9 +459,9 @@ static int parsedate(const char *date, time_t *output)
                 (mdaynum == -1)) {
           /* 8 digits, no year, month or day yet. This is YYYYMMDD */
           found = TRUE;
-          yearnum = val/10000;
-          monnum = (val%10000)/100-1; /* month is 0 - 11 */
-          mdaynum = val%100;
+          yearnum = val / 10000;
+          monnum = (val % 10000) / 100 - 1; /* month is 0 - 11 */
+          mdaynum = val % 100;
         }
 
         if(!found && (dignext == DATE_MDAY) && (mdaynum == -1)) {
index 7ac321af7244568a74f222af6a63cdd8e812bf6e..36acc34a36689faa5095be4991d50073d6ac891c 100644 (file)
@@ -214,7 +214,6 @@ CURLcode Curl_pp_vsendf(struct Curl_easy *data,
   return CURLE_OK;
 }
 
-
 /***********************************************************************
  *
  * Curl_pp_sendf()
index bd723b1c9bf4aa8da7d9aadfeafa70492dc2a3be..5492453d84591720c4372e7f40335d85bd6714b0 100644 (file)
@@ -71,10 +71,10 @@ struct pingpong {
                          read */
 };
 
-#define PINGPONG_SETUP(pp,s,e)                   \
-  do {                                           \
-    (pp)->statemachine = s;                      \
-    (pp)->endofresp = e;                         \
+#define PINGPONG_SETUP(pp, s, e) \
+  do {                           \
+    (pp)->statemachine = s;      \
+    (pp)->endofresp = e;         \
   } while(0)
 
 /*
@@ -94,7 +94,6 @@ void Curl_pp_init(struct pingpong *pp);
 timediff_t Curl_pp_state_timeout(struct Curl_easy *data,
                                  struct pingpong *pp, bool disconnecting);
 
-
 /***********************************************************************
  *
  * Curl_pp_sendf()
@@ -148,7 +147,6 @@ CURLcode Curl_pp_pollset(struct Curl_easy *data,
                          struct pingpong *pp,
                          struct easy_pollset *ps);
 
-
 /***********************************************************************
  *
  * Curl_pp_moredata()
index f10108229b6a5d53d4c8eec94cf83e76721f0fdf..771069b3d434d1cba1b8125baecfcf0acc7c386e 100644 (file)
 #define POP3_TYPE_SASL      (1 << 2)
 
 /* Authentication type values */
-#define POP3_TYPE_NONE      0
-#define POP3_TYPE_ANY       (POP3_TYPE_CLEARTEXT|POP3_TYPE_APOP|POP3_TYPE_SASL)
+#define POP3_TYPE_NONE 0
+#define POP3_TYPE_ANY  (POP3_TYPE_CLEARTEXT | POP3_TYPE_APOP | POP3_TYPE_SASL)
 
 /* This is the 5-bytes End-Of-Body marker for POP3 */
-#define POP3_EOB "\x0d\x0a\x2e\x0d\x0a"
+#define POP3_EOB     "\x0d\x0a\x2e\x0d\x0a"
 #define POP3_EOB_LEN 5
 
 /* meta key for storing protocol meta at easy handle */
@@ -196,8 +196,7 @@ const struct Curl_handler Curl_handler_pop3 = {
   CURLPROTO_POP3,                   /* protocol */
   CURLPROTO_POP3,                   /* family */
   PROTOPT_CLOSEACTION | PROTOPT_NOURLQUERY | /* flags */
-  PROTOPT_URLOPTIONS | PROTOPT_SSL_REUSE |
-  PROTOPT_CONN_REUSE
+    PROTOPT_URLOPTIONS | PROTOPT_SSL_REUSE | PROTOPT_CONN_REUSE
 };
 
 #ifdef USE_SSL
@@ -228,8 +227,7 @@ const struct Curl_handler Curl_handler_pop3s = {
   CURLPROTO_POP3S,                  /* protocol */
   CURLPROTO_POP3,                   /* family */
   PROTOPT_CLOSEACTION | PROTOPT_SSL | /* flags */
-  PROTOPT_NOURLQUERY | PROTOPT_URLOPTIONS |
-  PROTOPT_CONN_REUSE
+    PROTOPT_NOURLQUERY | PROTOPT_URLOPTIONS | PROTOPT_CONN_REUSE
 };
 #endif
 
@@ -512,7 +510,7 @@ static CURLcode pop3_perform_upgrade_tls(struct Curl_easy *data,
          result, ssldone));
   if(!result && ssldone) {
     pop3c->ssldone = ssldone;
-     /* perform CAPA now, changes pop3c->state out of POP3_UPGRADETLS */
+    /* perform CAPA now, changes pop3c->state out of POP3_UPGRADETLS */
     result = pop3_perform_capa(data, conn);
   }
 out:
@@ -589,10 +587,10 @@ static CURLcode pop3_perform_apop(struct Curl_easy *data,
   if(!ctxt)
     return CURLE_OUT_OF_MEMORY;
 
-  Curl_MD5_update(ctxt, (const unsigned char *) pop3c->apoptimestamp,
+  Curl_MD5_update(ctxt, (const unsigned char *)pop3c->apoptimestamp,
                   curlx_uztoui(strlen(pop3c->apoptimestamp)));
 
-  Curl_MD5_update(ctxt, (const unsigned char *) conn->passwd,
+  Curl_MD5_update(ctxt, (const unsigned char *)conn->passwd,
                   curlx_uztoui(strlen(conn->passwd)));
 
   /* Finalise the digest */
@@ -625,7 +623,7 @@ static CURLcode pop3_perform_auth(struct Curl_easy *data,
   struct pop3_conn *pop3c =
     Curl_conn_meta_get(data->conn, CURL_META_POP3_CONN);
   CURLcode result = CURLE_OK;
-  const char *ir = (const char *) Curl_bufref_ptr(initresp);
+  const char *ir = (const char *)Curl_bufref_ptr(initresp);
 
   if(!pop3c)
     return CURLE_FAILED_INIT;
index 7124a307d1f5fed0d41ba32de7c31586d20e9c30..1ae8b5801d016cc77622786c8d603e859f8320ba 100644 (file)
@@ -87,7 +87,7 @@ static char *max6data(curl_off_t bytes, char *max6)
     /* xxx.yU */
     curl_msnprintf(max6, 7, "%3" CURL_FORMAT_CURL_OFF_T
                    ".%" CURL_FORMAT_CURL_OFF_T "%c", nbytes,
-                   (bytes%1024) / (1024/10), unit[k]);
+                   (bytes % 1024) / (1024 / 10), unit[k]);
   }
   return max6;
 }
@@ -351,7 +351,7 @@ void Curl_pgrsSetUploadSize(struct Curl_easy *data, curl_off_t size)
 
 void Curl_pgrsEarlyData(struct Curl_easy *data, curl_off_t sent)
 {
-    data->progress.earlydata_sent = sent;
+  data->progress.earlydata_sent = sent;
 }
 
 /* returns the average speed in bytes / second */
@@ -360,7 +360,7 @@ static curl_off_t trspeed(curl_off_t size, /* number of bytes */
 {
   if(us < 1)
     return size * 1000000;
-  else if(size < CURL_OFF_T_MAX/1000000)
+  else if(size < CURL_OFF_T_MAX / 1000000)
     return (size * 1000000) / us;
   else if(us >= 1000000)
     return size / (us / 1000000);
@@ -422,18 +422,18 @@ static bool progress_calc(struct Curl_easy *data, struct curltime *pnow)
              ((i_latest + 1) % CURL_SPEED_RECORDS);
 
   /* How much we transferred between oldest and current records */
-  amount = p->speed_amount[i_latest]- p->speed_amount[i_oldest];
+  amount = p->speed_amount[i_latest] - p->speed_amount[i_oldest];
   /* How long this took */
   duration_ms = curlx_timediff_ms(p->speed_time[i_latest],
                                   p->speed_time[i_oldest]);
   if(duration_ms <= 0)
     duration_ms = 1;
 
-  if(amount > (CURL_OFF_T_MAX/1000)) {
+  if(amount > (CURL_OFF_T_MAX / 1000)) {
     /* the 'amount' value is bigger than would fit in 64 bits if
        multiplied with 1000, so we use the double math for this */
-    p->current_speed = (curl_off_t)
-      (((double)amount * 1000.0)/(double)duration_ms);
+    p->current_speed =
+      (curl_off_t)(((double)amount * 1000.0) / (double)duration_ms);
   }
   else {
     /* the 'amount' value is small enough to fit within 32 bits even
@@ -459,7 +459,7 @@ static curl_off_t pgrs_est_percent(curl_off_t total, curl_off_t cur)
   if(total > 10000)
     return cur / (total / 100);
   else if(total > 0)
-    return (cur*100) / total;
+    return (cur * 100) / total;
   return 0;
 }
 
@@ -488,7 +488,7 @@ static void progress_meter(struct Curl_easy *data)
   char time_left[10];
   char time_total[10];
   char time_spent[10];
-  curl_off_t cur_secs = (curl_off_t)p->timespent/1000000; /* seconds */
+  curl_off_t cur_secs = (curl_off_t)p->timespent / 1000000; /* seconds */
 
   if(!p->headers_out) {
     if(data->state.resume_from) {
@@ -516,11 +516,9 @@ static void progress_meter(struct Curl_easy *data)
   time2str(time_spent, cur_secs);
 
   /* Get the total amount of data expected to get transferred */
-  total_expected_size =
-    p->ul_size_known ? p->ul.total_size : p->ul.cur_size;
+  total_expected_size = p->ul_size_known ? p->ul.total_size : p->ul.cur_size;
 
-  dl_size =
-    p->dl_size_known ? p->dl.total_size : p->dl.cur_size;
+  dl_size = p->dl_size_known ? p->dl.total_size : p->dl.cur_size;
 
   /* integer overflow check */
   if((CURL_OFF_T_MAX - total_expected_size) < dl_size)
@@ -561,7 +559,6 @@ static void progress_meter(struct Curl_easy *data)
 #define progress_meter(x) Curl_nop_stmt
 #endif
 
-
 /*
  * Curl_pgrsUpdate() returns 0 for success or the value returned by the
  * progress callback!
index 5bf96d09bd88c9d7c3f9dd4f00c5e7f60e2b9345..0be51e44020a690cb72cef2992c39c8a33be1fd6 100644 (file)
--- a/lib/psl.c
+++ b/lib/psl.c
@@ -91,7 +91,7 @@ const psl_ctx_t *Curl_psl_use(struct Curl_easy *easy)
         pslcache->expires = expires;
       }
     }
-    Curl_share_unlock(easy, CURL_LOCK_DATA_PSL);  /* Release exclusive lock. */
+    Curl_share_unlock(easy, CURL_LOCK_DATA_PSL); /* Release exclusive lock. */
     Curl_share_lock(easy, CURL_LOCK_DATA_PSL, CURL_LOCK_ACCESS_SHARED);
   }
   psl = pslcache->psl;
index 8c5a2cf71e445e88f37d33a33aa620a2c585b619..88324e918ae9c4aea1abc00c4163fbe99ae18b3d 100644 (file)
@@ -227,8 +227,7 @@ CURLcode Curl_rand_bytes(struct Curl_easy *data,
  * size.
  */
 
-CURLcode Curl_rand_hex(struct Curl_easy *data, unsigned char *rnd,
-                       size_t num)
+CURLcode Curl_rand_hex(struct Curl_easy *data, unsigned char *rnd, size_t num)
 {
   CURLcode result = CURLE_BAD_FUNCTION_ARGUMENT;
   unsigned char buffer[128];
@@ -240,7 +239,7 @@ CURLcode Curl_rand_hex(struct Curl_easy *data, unsigned char *rnd,
   memset(buffer, 0, sizeof(buffer));
 #endif
 
-  if((num/2 >= sizeof(buffer)) || !(num&1)) {
+  if((num / 2 >= sizeof(buffer)) || !(num & 1)) {
     /* make sure it fits in the local buffer and that it is an odd number! */
     DEBUGF(infof(data, "invalid buffer size with Curl_rand_hex"));
     return CURLE_BAD_FUNCTION_ARGUMENT;
@@ -248,11 +247,11 @@ CURLcode Curl_rand_hex(struct Curl_easy *data, unsigned char *rnd,
 
   num--; /* save one for null-termination */
 
-  result = Curl_rand(data, buffer, num/2);
+  result = Curl_rand(data, buffer, num / 2);
   if(result)
     return result;
 
-  Curl_hexencode(buffer, num/2, rnd, num + 1);
+  Curl_hexencode(buffer, num / 2, rnd, num + 1);
   return result;
 }
 
index 2ba60e72976ed9c440483f5d7ff8e9d6d839ed0c..674cb6ee2025511c92c940ce857486ff5ab00fa3 100644 (file)
@@ -31,9 +31,9 @@ CURLcode Curl_rand_bytes(struct Curl_easy *data,
                          unsigned char *rnd, size_t num);
 
 #ifdef DEBUGBUILD
-#define Curl_rand(a,b,c)   Curl_rand_bytes((a), TRUE, (b), (c))
+#define Curl_rand(a, b, c) Curl_rand_bytes((a), TRUE, (b), (c))
 #else
-#define Curl_rand(a,b,c)   Curl_rand_bytes((a), (b), (c))
+#define Curl_rand(a, b, c) Curl_rand_bytes((a), (b), (c))
 #endif
 
 /*
@@ -41,8 +41,7 @@ CURLcode Curl_rand_bytes(struct Curl_easy *data,
  * hexadecimal digits PLUS a null-terminating byte. It must be an odd number
  * size.
  */
-CURLcode Curl_rand_hex(struct Curl_easy *data, unsigned char *rnd,
-                       size_t num);
+CURLcode Curl_rand_hex(struct Curl_easy *data, unsigned char *rnd, size_t num);
 
 /*
  * Curl_rand_alnum() fills the 'rnd' buffer with a given 'num' size with random
index c3593d59375623bafc49726fa7ed81c93252d5ed..7e3592506aa87f17b7f435e1c51a34e0049a79ab 100644 (file)
@@ -28,7 +28,7 @@
 #include "ratelimit.h"
 
 
-#define CURL_US_PER_SEC      1000000
+#define CURL_US_PER_SEC       1000000
 #define CURL_RLIMIT_MIN_CHUNK (16 * 1024)
 #define CURL_RLIMIT_MAX_STEPS 2   /* 500ms interval */
 
index 581d7d14537ae0a5b08316584b8eea8f447f6a56..fa83380878ad1ec47a14a86306b5da56e2580e9b 100644 (file)
@@ -111,7 +111,7 @@ CURLcode Curl_req_done(struct SingleRequest *req,
 
 void Curl_req_hard_reset(struct SingleRequest *req, struct Curl_easy *data)
 {
-  struct curltime t0 = {0, 0};
+  struct curltime t0 = { 0, 0 };
 
   Curl_safefree(req->newurl);
   Curl_client_reset(data);
@@ -473,6 +473,6 @@ CURLcode Curl_req_stop_send_recv(struct Curl_easy *data)
   CURLcode result = CURLE_OK;
   if(data->req.keepon & KEEP_SEND)
     result = Curl_req_abort_sending(data);
-  data->req.keepon &= ~(KEEP_RECV|KEEP_SEND);
+  data->req.keepon &= ~(KEEP_RECV | KEEP_SEND);
   return result;
 }
index 0f9e0a6ff4fc3bf2457ecb48d9ed01e196fbe39d..5b0d1460283b3a5f0ce01fed123bbaeebd00d272 100644 (file)
@@ -48,7 +48,6 @@ enum upgrade101 {
   UPGR101_RECEIVED            /* 101 response received */
 };
 
-
 /*
  * Request specific data in the easy handle (Curl_easy). Previously,
  * these members were on the connectdata struct but since a conn struct may
index 5a46dc62c407ba0afc67c761146d866805a4f529..ee5d822a5404cb629377eb4a738753b675a814a5 100644 (file)
@@ -117,11 +117,10 @@ static CURLcode rtsp_do_pollset(struct Curl_easy *data,
   return Curl_pollset_add_out(data, ps, data->conn->sock[FIRSTSOCKET]);
 }
 
-static
-CURLcode rtp_client_write(struct Curl_easy *data, const char *ptr, size_t len);
-static
-CURLcode rtsp_parse_transport(struct Curl_easy *data, const char *transport);
-
+static CURLcode rtp_client_write(struct Curl_easy *data, const char *ptr,
+                                 size_t len);
+static CURLcode rtsp_parse_transport(struct Curl_easy *data,
+                                     const char *transport);
 
 /*
  * RTSP handler interface.
@@ -191,7 +190,6 @@ static CURLcode rtsp_setup_connection(struct Curl_easy *data,
   return CURLE_OK;
 }
 
-
 /*
  * Function to check on various aspects of a connection.
  */
@@ -211,7 +209,6 @@ static unsigned int rtsp_conncheck(struct Curl_easy *data,
   return ret_val;
 }
 
-
 static CURLcode rtsp_connect(struct Curl_easy *data, bool *done)
 {
   struct rtsp_conn *rtspc =
@@ -274,7 +271,6 @@ static CURLcode rtsp_done(struct Curl_easy *data,
   return httpStatus;
 }
 
-
 static CURLcode rtsp_setup_body(struct Curl_easy *data,
                                 Curl_RtspReq rtspreq,
                                 struct dynbuf *reqp)
@@ -324,9 +320,8 @@ static CURLcode rtsp_setup_body(struct Curl_easy *data,
       if(rtspreq == RTSPREQ_SET_PARAMETER ||
          rtspreq == RTSPREQ_GET_PARAMETER) {
         if(!Curl_checkheaders(data, STRCONST("Content-Type"))) {
-          result = curlx_dyn_addn(reqp,
-                                  STRCONST("Content-Type: "
-                                           "text/parameters\r\n"));
+          result = curlx_dyn_addn(reqp, STRCONST("Content-Type: "
+                                                 "text/parameters\r\n"));
           if(result)
             return result;
         }
@@ -334,9 +329,8 @@ static CURLcode rtsp_setup_body(struct Curl_easy *data,
 
       if(rtspreq == RTSPREQ_ANNOUNCE) {
         if(!Curl_checkheaders(data, STRCONST("Content-Type"))) {
-          result = curlx_dyn_addn(reqp,
-                                  STRCONST("Content-Type: "
-                                           "application/sdp\r\n"));
+          result = curlx_dyn_addn(reqp, STRCONST("Content-Type: "
+                                                 "application/sdp\r\n"));
           if(result)
             return result;
         }
@@ -931,7 +925,7 @@ static CURLcode rtsp_rtp_write_resp(struct Curl_easy *data,
                blen, rtspc->in_header, data->req.done, rtspc->state,
                data->req.size));
   if(!result && (is_eos || blen)) {
-    result = Curl_client_write(data, CLIENTWRITE_BODY|
+    result = Curl_client_write(data, CLIENTWRITE_BODY |
                                (is_eos ? CLIENTWRITE_EOS : 0), buf, blen);
   }
 
@@ -954,8 +948,8 @@ static CURLcode rtsp_rtp_write_resp_hd(struct Curl_easy *data,
   return rtsp_rtp_write_resp(data, buf, blen, is_eos);
 }
 
-static
-CURLcode rtp_client_write(struct Curl_easy *data, const char *ptr, size_t len)
+static CURLcode rtp_client_write(struct Curl_easy *data, const char *ptr,
+                                 size_t len)
 {
   size_t wrote;
   curl_write_callback writeit;
@@ -1066,8 +1060,8 @@ CURLcode Curl_rtsp_parseheader(struct Curl_easy *data, const char *header)
   return CURLE_OK;
 }
 
-static
-CURLcode rtsp_parse_transport(struct Curl_easy *data, const char *transport)
+static CURLcode rtsp_parse_transport(struct Curl_easy *data,
+                                     const char *transport)
 {
   /* If we receive multiple Transport response-headers, the linterleaved
      channels of each response header is recorded and used together for
@@ -1109,5 +1103,4 @@ CURLcode rtsp_parse_transport(struct Curl_easy *data, const char *transport)
   return CURLE_OK;
 }
 
-
 #endif /* CURL_DISABLE_RTSP */
index 59f20a9f1672923ccb1c98a997aaf35a6e0b3b94..7b42efde2860277351ec32ea87756f7285617cc3 100644 (file)
@@ -32,7 +32,7 @@ CURLcode Curl_rtsp_parseheader(struct Curl_easy *data, const char *header);
 
 #else
 /* disabled */
-#define Curl_rtsp_parseheader(x,y) CURLE_NOT_BUILT_IN
+#define Curl_rtsp_parseheader(x, y) CURLE_NOT_BUILT_IN
 
 #endif /* CURL_DISABLE_RTSP */
 
index 5692fc020d1ff3c9e48062c3c71792edd3759d6e..52dfa7376d0a9d14264048c7ca1b7130129d577d 100644 (file)
@@ -146,19 +146,19 @@ int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */
   num = 0;
   if(readfd0 != CURL_SOCKET_BAD) {
     pfd[num].fd = readfd0;
-    pfd[num].events = POLLRDNORM|POLLIN|POLLRDBAND|POLLPRI;
+    pfd[num].events = POLLRDNORM | POLLIN | POLLRDBAND | POLLPRI;
     pfd[num].revents = 0;
     num++;
   }
   if(readfd1 != CURL_SOCKET_BAD) {
     pfd[num].fd = readfd1;
-    pfd[num].events = POLLRDNORM|POLLIN|POLLRDBAND|POLLPRI;
+    pfd[num].events = POLLRDNORM | POLLIN | POLLRDBAND | POLLPRI;
     pfd[num].revents = 0;
     num++;
   }
   if(writefd != CURL_SOCKET_BAD) {
     pfd[num].fd = writefd;
-    pfd[num].events = POLLWRNORM|POLLOUT|POLLPRI;
+    pfd[num].events = POLLWRNORM | POLLOUT | POLLPRI;
     pfd[num].revents = 0;
     num++;
   }
@@ -170,23 +170,23 @@ int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */
   r = 0;
   num = 0;
   if(readfd0 != CURL_SOCKET_BAD) {
-    if(pfd[num].revents & (POLLRDNORM|POLLIN|POLLERR|POLLHUP))
+    if(pfd[num].revents & (POLLRDNORM | POLLIN | POLLERR | POLLHUP))
       r |= CURL_CSELECT_IN;
-    if(pfd[num].revents & (POLLPRI|POLLNVAL))
+    if(pfd[num].revents & (POLLPRI | POLLNVAL))
       r |= CURL_CSELECT_ERR;
     num++;
   }
   if(readfd1 != CURL_SOCKET_BAD) {
-    if(pfd[num].revents & (POLLRDNORM|POLLIN|POLLERR|POLLHUP))
+    if(pfd[num].revents & (POLLRDNORM | POLLIN | POLLERR | POLLHUP))
       r |= CURL_CSELECT_IN2;
-    if(pfd[num].revents & (POLLPRI|POLLNVAL))
+    if(pfd[num].revents & (POLLPRI | POLLNVAL))
       r |= CURL_CSELECT_ERR;
     num++;
   }
   if(writefd != CURL_SOCKET_BAD) {
-    if(pfd[num].revents & (POLLWRNORM|POLLOUT))
+    if(pfd[num].revents & (POLLWRNORM | POLLOUT))
       r |= CURL_CSELECT_OUT;
-    if(pfd[num].revents & (POLLERR|POLLHUP|POLLPRI|POLLNVAL))
+    if(pfd[num].revents & (POLLERR | POLLHUP | POLLPRI | POLLNVAL))
       r |= CURL_CSELECT_ERR;
   }
 
@@ -265,7 +265,7 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, timediff_t timeout_ms)
     if(ufds[i].revents & POLLHUP)
       ufds[i].revents |= POLLIN;
     if(ufds[i].revents & POLLERR)
-      ufds[i].revents |= POLLIN|POLLOUT;
+      ufds[i].revents |= POLLIN | POLLOUT;
   }
 
 #else  /* HAVE_POLL */
@@ -280,15 +280,15 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, timediff_t timeout_ms)
     if(ufds[i].fd == CURL_SOCKET_BAD)
       continue;
     VERIFY_SOCK(ufds[i].fd);
-    if(ufds[i].events & (POLLIN|POLLOUT|POLLPRI|
-                         POLLRDNORM|POLLWRNORM|POLLRDBAND)) {
+    if(ufds[i].events & (POLLIN |POLLOUT |POLLPRI |
+                         POLLRDNORM | POLLWRNORM | POLLRDBAND)) {
       if(ufds[i].fd > maxfd)
         maxfd = ufds[i].fd;
-      if(ufds[i].events & (POLLRDNORM|POLLIN))
+      if(ufds[i].events & (POLLRDNORM | POLLIN))
         FD_SET(ufds[i].fd, &fds_read);
-      if(ufds[i].events & (POLLWRNORM|POLLOUT))
+      if(ufds[i].events & (POLLWRNORM | POLLOUT))
         FD_SET(ufds[i].fd, &fds_write);
-      if(ufds[i].events & (POLLRDBAND|POLLPRI))
+      if(ufds[i].events & (POLLRDBAND | POLLPRI))
         FD_SET(ufds[i].fd, &fds_err);
     }
   }
@@ -579,9 +579,9 @@ CURLcode Curl_pollset_change(struct Curl_easy *data,
   if(!VALID_SOCK(sock))
     return CURLE_BAD_FUNCTION_ARGUMENT;
 
-  DEBUGASSERT(add_flags <= (CURL_POLL_IN|CURL_POLL_OUT));
-  DEBUGASSERT(remove_flags <= (CURL_POLL_IN|CURL_POLL_OUT));
-  DEBUGASSERT((add_flags&remove_flags) == 0); /* no overlap */
+  DEBUGASSERT(add_flags <= (CURL_POLL_IN | CURL_POLL_OUT));
+  DEBUGASSERT(remove_flags <= (CURL_POLL_IN | CURL_POLL_OUT));
+  DEBUGASSERT((add_flags & remove_flags) == 0); /* no overlap */
   for(i = 0; i < ps->n; ++i) {
     if(ps->sockets[i] == sock) {
       ps->actions[i] &= (unsigned char)(~remove_flags);
index fb54686af3e22f0064c6ae760573ac852f1c18e5..c5f1c59be02ff9d89d6cf1834e6da9dbe3d82d0b 100644 (file)
 #define POLLHUP     0x10
 #define POLLNVAL    0x20
 
-struct pollfd
-{
-    curl_socket_t fd;
-    short   events;
-    short   revents;
+struct pollfd {
+  curl_socket_t fd;
+  short events;
+  short revents;
 };
 
 #endif
@@ -76,9 +75,9 @@ struct pollfd
 int Curl_socket_check(curl_socket_t readfd, curl_socket_t readfd2,
                       curl_socket_t writefd,
                       timediff_t timeout_ms);
-#define SOCKET_READABLE(x,z) \
+#define SOCKET_READABLE(x, z)                               \
   Curl_socket_check(x, CURL_SOCKET_BAD, CURL_SOCKET_BAD, z)
-#define SOCKET_WRITABLE(x,z) \
+#define SOCKET_WRITABLE(x, z)                               \
   Curl_socket_check(CURL_SOCKET_BAD, CURL_SOCKET_BAD, x, z)
 
 int Curl_poll(struct pollfd ufds[], unsigned int nfds, timediff_t timeout_ms);
@@ -90,32 +89,33 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, timediff_t timeout_ms);
 #ifdef USE_WINSOCK
 #define VALID_SOCK(s) ((s) < INVALID_SOCKET)
 #define FDSET_SOCK(x) 1
-#define VERIFY_SOCK(x) do { \
-  if(!VALID_SOCK(x)) { \
-    SET_SOCKERRNO(SOCKEINVAL); \
-    return -1; \
-  } \
-} while(0)
+#define VERIFY_SOCK(x)           \
+  do {                           \
+    if(!VALID_SOCK(x)) {         \
+      SET_SOCKERRNO(SOCKEINVAL); \
+      return -1;                 \
+    }                            \
+  } while(0)
 #else
 #define VALID_SOCK(s) ((s) >= 0)
 
 /* If the socket is small enough to get set or read from an fdset */
 #define FDSET_SOCK(s) ((s) < FD_SETSIZE)
 
-#define VERIFY_SOCK(x) do {                     \
-    if(!VALID_SOCK(x) || !FDSET_SOCK(x)) {      \
-      SET_SOCKERRNO(SOCKEINVAL);                \
-      return -1;                                \
-    }                                           \
+#define VERIFY_SOCK(x)                     \
+  do {                                     \
+    if(!VALID_SOCK(x) || !FDSET_SOCK(x)) { \
+      SET_SOCKERRNO(SOCKEINVAL);           \
+      return -1;                           \
+    }                                      \
   } while(0)
 #endif
 
-
 /* Keep the sockets to poll for an easy handle.
  * `actions` are bitmaps of CURL_POLL_IN and CURL_POLL_OUT.
  * Starts with small capacity, grows on demand.
  */
-#define EZ_POLLSET_DEF_COUNT    2
+#define EZ_POLLSET_DEF_COUNT 2
 
 struct easy_pollset {
   curl_socket_t *sockets;
@@ -133,7 +133,6 @@ struct easy_pollset {
 #define CURL_EASY_POLLSET_MAGIC  0x7a657370
 #endif
 
-
 /* allocate and initialise */
 struct easy_pollset *Curl_pollset_create(void);
 
@@ -162,22 +161,22 @@ CURLcode Curl_pollset_set(struct Curl_easy *data,
                           bool do_in, bool do_out) WARN_UNUSED_RESULT;
 
 #define Curl_pollset_add_in(data, ps, sock) \
-          Curl_pollset_change((data), (ps), (sock), CURL_POLL_IN, 0)
+  Curl_pollset_change((data), (ps), (sock), CURL_POLL_IN, 0)
 #define Curl_pollset_remove_in(data, ps, sock) \
-          Curl_pollset_change((data), (ps), (sock), 0, CURL_POLL_IN)
+  Curl_pollset_change((data), (ps), (sock), 0, CURL_POLL_IN)
 #define Curl_pollset_add_out(data, ps, sock) \
-          Curl_pollset_change((data), (ps), (sock), CURL_POLL_OUT, 0)
+  Curl_pollset_change((data), (ps), (sock), CURL_POLL_OUT, 0)
 #define Curl_pollset_remove_out(data, ps, sock) \
-          Curl_pollset_change((data), (ps), (sock), 0, CURL_POLL_OUT)
+  Curl_pollset_change((data), (ps), (sock), 0, CURL_POLL_OUT)
 #define Curl_pollset_add_inout(data, ps, sock) \
-          Curl_pollset_change((data), (ps), (sock), \
-                               CURL_POLL_IN|CURL_POLL_OUT, 0)
+  Curl_pollset_change((data), (ps), (sock), \
+                       CURL_POLL_IN | CURL_POLL_OUT, 0)
 #define Curl_pollset_set_in_only(data, ps, sock) \
-          Curl_pollset_change((data), (ps), (sock), \
-                               CURL_POLL_IN, CURL_POLL_OUT)
+  Curl_pollset_change((data), (ps), (sock), \
+                       CURL_POLL_IN, CURL_POLL_OUT)
 #define Curl_pollset_set_out_only(data, ps, sock) \
-          Curl_pollset_change((data), (ps), (sock), \
-                               CURL_POLL_OUT, CURL_POLL_IN)
+  Curl_pollset_change((data), (ps), (sock), \
+                       CURL_POLL_OUT, CURL_POLL_IN)
 
 /* return < = on error, 0 on timeout or how many sockets are ready */
 int Curl_pollset_poll(struct Curl_easy *data,
index 1d73291c92d209bf4e83500ddc50b0e3385d126c..f4a816e23173d6b187007e48fd4b798e413b8a23 100644 (file)
@@ -69,13 +69,14 @@ CURLcode Curl_client_write(struct Curl_easy *data,
   CURLcode result;
 
   /* it is one of those, at least */
-  DEBUGASSERT(type & (CLIENTWRITE_BODY|CLIENTWRITE_HEADER|CLIENTWRITE_INFO));
+  DEBUGASSERT(type &
+              (CLIENTWRITE_BODY | CLIENTWRITE_HEADER | CLIENTWRITE_INFO));
   /* BODY is only BODY (with optional EOS) */
   DEBUGASSERT(!(type & CLIENTWRITE_BODY) ||
-              ((type & ~(CLIENTWRITE_BODY|CLIENTWRITE_EOS)) == 0));
+              ((type & ~(CLIENTWRITE_BODY | CLIENTWRITE_EOS)) == 0));
   /* INFO is only INFO (with optional EOS) */
   DEBUGASSERT(!(type & CLIENTWRITE_INFO) ||
-              ((type & ~(CLIENTWRITE_INFO|CLIENTWRITE_EOS)) == 0));
+              ((type & ~(CLIENTWRITE_INFO | CLIENTWRITE_EOS)) == 0));
 
   if(!data->req.writer_stack) {
     result = do_init_writer_stack(data);
@@ -227,7 +228,7 @@ static CURLcode cw_download_write(struct Curl_easy *data,
   bool is_connect = !!(type & CLIENTWRITE_CONNECT);
 
   if(!ctx->started_response &&
-     !(type & (CLIENTWRITE_INFO|CLIENTWRITE_CONNECT))) {
+     !(type & (CLIENTWRITE_INFO | CLIENTWRITE_CONNECT))) {
     Curl_pgrsTime(data, TIMER_STARTTRANSFER);
     Curl_rlimit_start(&data->progress.dl.rlimit, curlx_now());
     ctx->started_response = TRUE;
@@ -784,7 +785,7 @@ static CURLcode cr_in_resume_from(struct Curl_easy *data,
     }
     /* when seekerr == CURL_SEEKFUNC_CANTSEEK (cannot seek to offset) */
     do {
-      char scratch[4*1024];
+      char scratch[4 * 1024];
       size_t readthisamountnow =
         (offset - passed > (curl_off_t)sizeof(scratch)) ?
         sizeof(scratch) :
@@ -1089,8 +1090,7 @@ static CURLcode cr_lc_add(struct Curl_easy *data)
   struct Curl_creader *reader = NULL;
   CURLcode result;
 
-  result = Curl_creader_create(&reader, data, &cr_lc,
-                               CURL_CR_CONTENT_ENCODE);
+  result = Curl_creader_create(&reader, data, &cr_lc, CURL_CR_CONTENT_ENCODE);
   if(!result)
     result = Curl_creader_add(data, reader);
 
@@ -1481,5 +1481,4 @@ struct Curl_creader *Curl_creader_get_by_type(struct Curl_easy *data,
       return r;
   }
   return NULL;
-
 }
index 3a6dccba6a3dc3d6f9e7c044ad5729447c8f36ba..7b983c5271b22cf43f961d49eb75a98b918394e3 100644 (file)
  * BODY, INFO and HEADER should not be mixed, as this would lead to
  * confusion on how to interpret/format/convert the data.
  */
-#define CLIENTWRITE_BODY    (1<<0) /* non-meta information, BODY */
-#define CLIENTWRITE_INFO    (1<<1) /* meta information, not a HEADER */
-#define CLIENTWRITE_HEADER  (1<<2) /* meta information, HEADER */
-#define CLIENTWRITE_STATUS  (1<<3) /* a special status HEADER */
-#define CLIENTWRITE_CONNECT (1<<4) /* a CONNECT related HEADER */
-#define CLIENTWRITE_1XX     (1<<5) /* a 1xx response related HEADER */
-#define CLIENTWRITE_TRAILER (1<<6) /* a trailer HEADER */
-#define CLIENTWRITE_EOS     (1<<7) /* End Of transfer download Stream */
-#define CLIENTWRITE_0LEN    (1<<8) /* write even 0-length buffers */
+#define CLIENTWRITE_BODY    (1 << 0) /* non-meta information, BODY */
+#define CLIENTWRITE_INFO    (1 << 1) /* meta information, not a HEADER */
+#define CLIENTWRITE_HEADER  (1 << 2) /* meta information, HEADER */
+#define CLIENTWRITE_STATUS  (1 << 3) /* a special status HEADER */
+#define CLIENTWRITE_CONNECT (1 << 4) /* a CONNECT related HEADER */
+#define CLIENTWRITE_1XX     (1 << 5) /* a 1xx response related HEADER */
+#define CLIENTWRITE_TRAILER (1 << 6) /* a trailer HEADER */
+#define CLIENTWRITE_EOS     (1 << 7) /* End Of transfer download Stream */
+#define CLIENTWRITE_0LEN    (1 << 8) /* write even 0-length buffers */
 
 /* Forward declarations */
 struct Curl_creader;
@@ -206,7 +206,6 @@ CURLcode Curl_cwriter_def_write(struct Curl_easy *data,
 void Curl_cwriter_def_close(struct Curl_easy *data,
                             struct Curl_cwriter *writer);
 
-
 typedef enum {
   CURL_CRCNTRL_REWIND,
   CURL_CRCNTRL_UNPAUSE,
@@ -407,7 +406,6 @@ void Curl_creader_done(struct Curl_easy *data, int premature);
 struct Curl_creader *Curl_creader_get_by_type(struct Curl_easy *data,
                                               const struct Curl_crtype *crt);
 
-
 /**
  * Set the client reader to provide 0 bytes, immediate EOS.
  */
index b4ca361ce35f8029560547841e9a7fac7f7296ec..0a377be1f165b78eb13ecc4a08d5d539cff66289 100644 (file)
@@ -59,8 +59,8 @@ static CURLcode setopt_set_timeout_sec(timediff_t *ptimeout_ms, long secs)
 {
   if(secs < 0)
     return CURLE_BAD_FUNCTION_ARGUMENT;
-#if LONG_MAX > (TIMEDIFF_T_MAX/1000)
-  if(secs > (TIMEDIFF_T_MAX/1000)) {
+#if LONG_MAX > (TIMEDIFF_T_MAX / 1000)
+  if(secs > (TIMEDIFF_T_MAX / 1000)) {
     *ptimeout_ms = TIMEDIFF_T_MAX;
     return CURLE_OK;
   }
@@ -193,7 +193,7 @@ static CURLcode setstropt_interface(char *option, char **devp,
   return CURLE_OK;
 }
 
-#define C_SSLVERSION_VALUE(x) (x & 0xffff)
+#define C_SSLVERSION_VALUE(x)     (x & 0xffff)
 #define C_SSLVERSION_MAX_VALUE(x) ((unsigned long)x & 0xffff0000)
 
 static CURLcode protocol2num(const char *str, curl_prot_t *val)
@@ -208,7 +208,7 @@ static CURLcode protocol2num(const char *str, curl_prot_t *val)
     return CURLE_BAD_FUNCTION_ARGUMENT;
 
   if(curl_strequal(str, "all")) {
-    *val = ~(curl_prot_t) 0;
+    *val = ~(curl_prot_t)0;
     return CURLE_OK;
   }
 
@@ -217,7 +217,7 @@ static CURLcode protocol2num(const char *str, curl_prot_t *val)
     size_t tlen;
 
     str = strchr(str, ',');
-    tlen = str ? (size_t) (str - token) : strlen(token);
+    tlen = str ? (size_t)(str - token) : strlen(token);
     if(tlen) {
       const struct Curl_handler *h = Curl_getn_scheme_handler(token, tlen);
 
@@ -256,7 +256,7 @@ static CURLcode httpauth(struct Curl_easy *data, bool proxy,
 
     /* switch off bits we cannot support */
 #ifndef USE_NTLM
-    auth &= ~CURLAUTH_NTLM;    /* no NTLM support */
+    auth &= ~CURLAUTH_NTLM; /* no NTLM support */
 #endif
 #ifndef USE_SPNEGO
     auth &= ~CURLAUTH_NEGOTIATE; /* no Negotiate (SPNEGO) auth without GSS-API
@@ -787,8 +787,7 @@ static CURLcode setopt_bool(struct Curl_easy *data, CURLoption option,
   case CURLOPT_SSL_SESSIONID_CACHE:
     s->ssl.primary.cache_session = enabled;
 #ifndef CURL_DISABLE_PROXY
-    s->proxy_ssl.primary.cache_session =
-      s->ssl.primary.cache_session;
+    s->proxy_ssl.primary.cache_session = s->ssl.primary.cache_session;
 #endif
     break;
 #ifdef USE_SSH
@@ -810,7 +809,7 @@ static CURLcode setopt_bool(struct Curl_easy *data, CURLoption option,
     s->tcp_keepalive = enabled;
     break;
   case CURLOPT_TCP_FASTOPEN:
-#if defined(CONNECT_DATA_IDEMPOTENT) || defined(MSG_FASTOPEN) ||        \
+#if defined(CONNECT_DATA_IDEMPOTENT) || defined(MSG_FASTOPEN) || \
   defined(TCP_FASTOPEN_CONNECT)
     s->tcp_fastopen = enabled;
     break;
@@ -1099,7 +1098,7 @@ static CURLcode setopt_long(struct Curl_easy *data, CURLoption option,
 #ifdef HAVE_GSSAPI
   case CURLOPT_GSSAPI_DELEGATION:
     s->gssapi_delegation = (unsigned char)uarg &
-      (CURLGSSAPI_DELEGATION_POLICY_FLAG|CURLGSSAPI_DELEGATION_FLAG);
+      (CURLGSSAPI_DELEGATION_POLICY_FLAG | CURLGSSAPI_DELEGATION_FLAG);
     break;
 #endif
 
@@ -1145,7 +1144,7 @@ static CURLcode setopt_long(struct Curl_easy *data, CURLoption option,
   case CURLOPT_IPRESOLVE:
     if((arg < CURL_IPRESOLVE_WHATEVER) || (arg > CURL_IPRESOLVE_V6))
       return CURLE_BAD_FUNCTION_ARGUMENT;
-    s->ipver = (unsigned char) arg;
+    s->ipver = (unsigned char)arg;
     break;
 
   case CURLOPT_CONNECT_ONLY:
@@ -1413,8 +1412,8 @@ static CURLcode setopt_pointers(struct Curl_easy *data, CURLoption option,
     break;
 #endif /* ! CURL_DISABLE_FORM_API */
 #endif /* ! CURL_DISABLE_HTTP */
-#if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_SMTP) ||       \
-    !defined(CURL_DISABLE_IMAP)
+#if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_SMTP) || \
+  !defined(CURL_DISABLE_IMAP)
 # ifndef CURL_DISABLE_MIME
   case CURLOPT_MIMEPOST:
     /*
@@ -1444,8 +1443,7 @@ static CURLcode setopt_pointers(struct Curl_easy *data, CURLoption option,
     if(!s->err)
       s->err = stderr;
     break;
-  case CURLOPT_SHARE:
-  {
+  case CURLOPT_SHARE: {
     struct Curl_share *set = va_arg(param, struct Curl_share *);
 
     /* disconnect from old share, if any */
@@ -1492,7 +1490,7 @@ static CURLcode setopt_pointers(struct Curl_easy *data, CURLoption option,
         /* enable cookies since we now use a share that uses cookies! */
         data->cookies = data->share->cookies;
       }
-#endif   /* CURL_DISABLE_HTTP */
+#endif /* CURL_DISABLE_HTTP */
 #ifndef CURL_DISABLE_HSTS
       if(data->share->hsts) {
         /* first free the private one if any */
@@ -1509,8 +1507,8 @@ static CURLcode setopt_pointers(struct Curl_easy *data, CURLoption option,
     }
     /* check for host cache not needed,
      * it will be done by curl_easy_perform */
+    break;
   }
-  break;
 
 #ifdef USE_HTTP2
   case CURLOPT_STREAM_DEPENDS:
@@ -1530,8 +1528,7 @@ static CURLcode setopt_pointers(struct Curl_easy *data, CURLoption option,
 }
 
 #ifndef CURL_DISABLE_COOKIES
-static CURLcode cookielist(struct Curl_easy *data,
-                           const char *ptr)
+static CURLcode cookielist(struct Curl_easy *data, const char *ptr)
 {
   CURLcode result = CURLE_OK;
   if(!ptr)
@@ -1584,8 +1581,7 @@ static CURLcode cookielist(struct Curl_easy *data,
   return result;
 }
 
-static CURLcode cookiefile(struct Curl_easy *data,
-                           const char *ptr)
+static CURLcode cookiefile(struct Curl_easy *data, const char *ptr)
 {
   /*
    * Set cookie file to read and parse. Can be used multiple times.
@@ -1639,8 +1635,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
   case CURLOPT_PROXY_SSL_CIPHER_LIST:
     if(Curl_ssl_supports(data, SSLSUPP_CIPHER_LIST)) {
       /* set a list of cipher we want to use in the SSL connection for proxy */
-      return Curl_setstropt(&s->str[STRING_SSL_CIPHER_LIST_PROXY],
-                            ptr);
+      return Curl_setstropt(&s->str[STRING_SSL_CIPHER_LIST_PROXY], ptr);
     }
     else
       return CURLE_NOT_BUILT_IN;
@@ -1656,8 +1651,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
   case CURLOPT_PROXY_TLS13_CIPHERS:
     if(Curl_ssl_supports(data, SSLSUPP_TLS13_CIPHERSUITES))
       /* set preferred list of TLS 1.3 cipher suites for proxy */
-      return Curl_setstropt(&s->str[STRING_SSL_CIPHER13_LIST_PROXY],
-                            ptr);
+      return Curl_setstropt(&s->str[STRING_SSL_CIPHER13_LIST_PROXY], ptr);
     else
       return CURLE_NOT_BUILT_IN;
 #endif
@@ -1841,7 +1835,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
      * to use the socks proxy.
      */
     return Curl_setstropt(&s->str[STRING_PRE_PROXY], ptr);
-#endif   /* CURL_DISABLE_PROXY */
+#endif /* CURL_DISABLE_PROXY */
 
 #ifndef CURL_DISABLE_PROXY
   case CURLOPT_SOCKS5_GSSAPI_SERVICE:
@@ -2038,8 +2032,8 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
     }
     curlx_free(u);
     curlx_free(p);
-  }
     break;
+  }
   case CURLOPT_PROXYUSERNAME:
     /*
      * authentication username to use in the operation
@@ -2201,8 +2195,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
      */
 #ifdef USE_SSL
     if(Curl_ssl_supports(data, SSLSUPP_PINNEDPUBKEY))
-      return Curl_setstropt(&s->str[STRING_SSL_PINNEDPUBLICKEY_PROXY],
-                            ptr);
+      return Curl_setstropt(&s->str[STRING_SSL_PINNEDPUBLICKEY_PROXY], ptr);
 #endif
     return CURLE_NOT_BUILT_IN;
 #endif
@@ -2304,8 +2297,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
      * Specify colon-delimited list of signature scheme names.
      */
     if(Curl_ssl_supports(data, SSLSUPP_SIGNATURE_ALGORITHMS))
-      return Curl_setstropt(&s->str[STRING_SSL_SIGNATURE_ALGORITHMS],
-                            ptr);
+      return Curl_setstropt(&s->str[STRING_SSL_SIGNATURE_ALGORITHMS], ptr);
     return CURLE_NOT_BUILT_IN;
 #endif
 #ifdef USE_SSH
@@ -2347,8 +2339,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
      * Option to allow for the SHA256 of the host public key to be checked
      * for validation purposes.
      */
-    return Curl_setstropt(&s->str[STRING_SSH_HOST_PUBLIC_KEY_SHA256],
-                          ptr);
+    return Curl_setstropt(&s->str[STRING_SSH_HOST_PUBLIC_KEY_SHA256], ptr);
 
   case CURLOPT_SSH_HOSTKEYDATA:
     /*
@@ -2367,7 +2358,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
     }
     else
       /* make a NULL argument reset to default */
-      s->allowed_protocols = (curl_prot_t) CURLPROTO_ALL;
+      s->allowed_protocols = (curl_prot_t)CURLPROTO_ALL;
     break;
 
   case CURLOPT_REDIR_PROTOCOLS_STR:
@@ -2379,7 +2370,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
     }
     else
       /* make a NULL argument reset to default */
-      s->redir_protocols = (curl_prot_t) CURLPROTO_REDIR;
+      s->redir_protocols = (curl_prot_t)CURLPROTO_REDIR;
     break;
 
   case CURLOPT_DEFAULT_PROTOCOL:
@@ -2571,17 +2562,13 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
     }
     /* set tls_ech flag value, preserving CLA_CFG bit */
     if(!strcmp(ptr, "false"))
-      s->tls_ech = CURLECH_DISABLE |
-        (s->tls_ech & CURLECH_CLA_CFG);
+      s->tls_ech = (s->tls_ech & CURLECH_CLA_CFG) | CURLECH_DISABLE;
     else if(!strcmp(ptr, "grease"))
-      s->tls_ech = CURLECH_GREASE |
-        (s->tls_ech & CURLECH_CLA_CFG);
+      s->tls_ech = (s->tls_ech & CURLECH_CLA_CFG) | CURLECH_GREASE;
     else if(!strcmp(ptr, "true"))
-      s->tls_ech = CURLECH_ENABLE |
-        (s->tls_ech & CURLECH_CLA_CFG);
+      s->tls_ech = (s->tls_ech & CURLECH_CLA_CFG) | CURLECH_ENABLE;
     else if(!strcmp(ptr, "hard"))
-      s->tls_ech = CURLECH_HARD |
-        (s->tls_ech & CURLECH_CLA_CFG);
+      s->tls_ech = (s->tls_ech & CURLECH_CLA_CFG) | CURLECH_HARD;
     else if(plen > 5 && !strncmp(ptr, "ecl:", 4)) {
       result = Curl_setstropt(&s->str[STRING_ECH_CONFIG], ptr + 4);
       if(result)
@@ -2908,8 +2895,7 @@ static CURLcode setopt_blob(struct Curl_easy *data, CURLoption option,
     /*
      * Blob that holds Issuer certificate to check certificates issuer
      */
-    return Curl_setblobopt(&s->blobs[BLOB_SSL_ISSUERCERT_PROXY],
-                           blob);
+    return Curl_setblobopt(&s->blobs[BLOB_SSL_ISSUERCERT_PROXY], blob);
 #endif
   case CURLOPT_SSLKEY_BLOB:
     /*
index c323dd74a37936b93747722e7ec05e1af55caf14..0dd60c785f939b50563a053d5286b19f150c9a7c 100644 (file)
@@ -28,7 +28,7 @@
 CURLcode Curl_setopt_SSLVERSION(struct Curl_easy *data, CURLoption option,
                                 long arg);
 #else
-#define Curl_setopt_SSLVERSION(a,b,c) CURLE_NOT_BUILT_IN
+#define Curl_setopt_SSLVERSION(a, b, c) CURLE_NOT_BUILT_IN
 #endif
 
 CURLcode Curl_setstropt(char **charp, const char *s) WARN_UNUSED_RESULT;
index ef7baca67efff4022e5de3ceabff04d37e3dfba2..01f93995100824706edc4c51c5bc906bc7d9b56e 100644 (file)
@@ -24,7 +24,6 @@
  *
  ***************************************************************************/
 
-
 /* OS/400 netdb.h does not define NI_MAXHOST. */
 #define NI_MAXHOST      1025
 
@@ -37,15 +36,13 @@ typedef unsigned long   u_int32_t;
 /* OS/400 has no idea of a tty! */
 #define isatty(fd)      0
 
-
 /* Workaround bug in IBM QADRT runtime library:
  * function puts() does not output the implicit trailing newline.
  */
 
 #include <stdio.h>      /* Be sure it is loaded. */
 #undef puts
-#define puts(s) (fputs((s), stdout) == EOF? EOF: putchar('\n'))
-
+#define puts(s) (fputs((s), stdout) == EOF ? EOF : putchar('\n'))
 
 /* System API wrapper prototypes & definitions to support ASCII parameters. */
 
@@ -105,8 +102,8 @@ extern OM_uint32 Curl_gss_init_sec_context_a(OM_uint32 * minor_status,
 #define gss_init_sec_context    Curl_gss_init_sec_context_a
 
 
-extern OM_uint32 Curl_gss_delete_sec_context_a(OM_uint32 * minor_status,
-                                               gss_ctx_id_t * context_handle,
+extern OM_uint32 Curl_gss_delete_sec_context_a(OM_uint32 *minor_status,
+                                               gss_ctx_id_t *context_handle,
                                                gss_buffer_t output_token);
 #define gss_delete_sec_context  Curl_gss_delete_sec_context_a
 
index e3777ded6e10d5ab26f33ccebe3389e350195397..17bf5a07a26db87f8c16b5539756900497695210 100644 (file)
@@ -38,9 +38,9 @@
 /* Hide the stuff we are overriding */
 #define getenv decc_getenv
 #ifdef __DECC
-#   if __INITIAL_POINTER_SIZE != 64
-#       define getpwuid decc_getpwuid
-#   endif
+#  if __INITIAL_POINTER_SIZE != 64
+#    define getpwuid decc_getpwuid
+#  endif
 #endif
 #include <stdlib.h>
 char *decc$getenv(const char *__name);
@@ -51,34 +51,34 @@ char *decc$getenv(const char *__name);
 
 #undef getenv
 #undef getpwuid
-#define getenv vms_getenv
+#define getenv   vms_getenv
 #define getpwuid vms_getpwuid
 
 /* VAX needs these in upper case when compiling exact case */
 #define sys$assign SYS$ASSIGN
 #define sys$dassgn SYS$DASSGN
-#define sys$qiow SYS$QIOW
+#define sys$qiow   SYS$QIOW
 
 #ifdef __DECC
-#   if __INITIAL_POINTER_SIZE
-#       pragma __pointer_size __save
-#   endif
+#  if __INITIAL_POINTER_SIZE
+#    pragma __pointer_size __save
+#  endif
 #endif
 
 #if __USE_LONG_GID_T
-#   define decc_getpwuid DECC$__LONG_GID_GETPWUID
+#  define decc_getpwuid DECC$__LONG_GID_GETPWUID
 #else
-#   if __INITIAL_POINTER_SIZE
-#       define decc_getpwuid decc$__32_getpwuid
-#   else
-#       define decc_getpwuid decc$getpwuid
-#   endif
+#  if __INITIAL_POINTER_SIZE
+#    define decc_getpwuid decc$__32_getpwuid
+#  else
+#    define decc_getpwuid decc$getpwuid
+#  endif
 #endif
 
-    struct passwd *decc_getpwuid(uid_t uid);
+struct passwd *decc_getpwuid(uid_t uid);
 
 #ifdef __DECC
-#   if __INITIAL_POINTER_SIZE == 32
+#  if __INITIAL_POINTER_SIZE == 32
 /* Translate the path, but only if the path is a VMS file specification */
 /* The translation is usually only needed for older versions of VMS */
 static char *vms_translate_path(const char *path)
@@ -100,18 +100,18 @@ static char *vms_translate_path(const char *path)
     return (char *)path;
   }
 }
-#   else
-    /* VMS translate path is actually not needed on the current 64-bit */
-    /* VMS platforms, so instead of figuring out the pointer settings */
-    /* Change it to a noop */
-#   define vms_translate_path(__path) __path
-#   endif
+#  else
+   /* VMS translate path is actually not needed on the current 64-bit */
+   /* VMS platforms, so instead of figuring out the pointer settings */
+   /* Change it to a noop */
+#  define vms_translate_path(__path) __path
+#  endif
 #endif
 
 #ifdef __DECC
-#   if __INITIAL_POINTER_SIZE
-#       pragma __pointer_size __restore
-#   endif
+#  if __INITIAL_POINTER_SIZE
+#    pragma __pointer_size __restore
+#  endif
 #endif
 
 static char *vms_getenv(const char *envvar)
@@ -137,7 +137,6 @@ static char *vms_getenv(const char *envvar)
   return result;
 }
 
-
 static struct passwd vms_passwd_cache;
 
 static struct passwd *vms_getpwuid(uid_t uid)
@@ -146,11 +145,11 @@ static struct passwd *vms_getpwuid(uid_t uid)
 
 /* Hack needed to support 64-bit builds, decc_getpwnam is 32-bit only */
 #ifdef __DECC
-#   if __INITIAL_POINTER_SIZE
+#  if __INITIAL_POINTER_SIZE
   __char_ptr32 unix_path;
-#   else
+#  else
   char *unix_path;
-#   endif
+#  endif
 #else
   char *unix_path;
 #endif
@@ -191,181 +190,181 @@ static struct passwd *vms_getpwuid(uid_t uid)
 /* Bug - VMS OpenSSL and Kerberos universal symbols are in uppercase only */
 /* VMS libraries should have universal symbols in exact and uppercase */
 
-#define ASN1_INTEGER_get ASN1_INTEGER_GET
-#define ASN1_STRING_data ASN1_STRING_DATA
-#define ASN1_STRING_length ASN1_STRING_LENGTH
-#define ASN1_STRING_print ASN1_STRING_PRINT
-#define ASN1_STRING_to_UTF8 ASN1_STRING_TO_UTF8
-#define ASN1_STRING_type ASN1_STRING_TYPE
-#define BIO_ctrl BIO_CTRL
-#define BIO_free BIO_FREE
-#define BIO_new BIO_NEW
-#define BIO_s_mem BIO_S_MEM
-#define BN_bn2bin BN_BN2BIN
-#define BN_num_bits BN_NUM_BITS
+#define ASN1_INTEGER_get           ASN1_INTEGER_GET
+#define ASN1_STRING_data           ASN1_STRING_DATA
+#define ASN1_STRING_length         ASN1_STRING_LENGTH
+#define ASN1_STRING_print          ASN1_STRING_PRINT
+#define ASN1_STRING_to_UTF8        ASN1_STRING_TO_UTF8
+#define ASN1_STRING_type           ASN1_STRING_TYPE
+#define BIO_ctrl                   BIO_CTRL
+#define BIO_free                   BIO_FREE
+#define BIO_new                    BIO_NEW
+#define BIO_s_mem                  BIO_S_MEM
+#define BN_bn2bin                  BN_BN2BIN
+#define BN_num_bits                BN_NUM_BITS
 #define CRYPTO_cleanup_all_ex_data CRYPTO_CLEANUP_ALL_EX_DATA
-#define CRYPTO_free CRYPTO_FREE
-#define CRYPTO_malloc CRYPTO_MALLOC
-#define CONF_modules_load_file CONF_MODULES_LOAD_FILE
+#define CRYPTO_free                CRYPTO_FREE
+#define CRYPTO_malloc              CRYPTO_MALLOC
+#define CONF_modules_load_file     CONF_MODULES_LOAD_FILE
 #ifdef __VAX
 #  ifdef VMS_OLD_SSL
   /* Ancient OpenSSL on VAX/VMS missing this constant */
 #    define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10
 #    undef CONF_modules_load_file
-     static int CONF_modules_load_file(const char *filename,
-                                       const char *appname,
-                                       unsigned long flags) {
-             return 1;
-     }
+static int CONF_modules_load_file(const char *filename,
+                                  const char *appname,
+                                  unsigned long flags) {
+  return 1;
+}
 #  endif
 #endif
-#define DES_ecb_encrypt DES_ECB_ENCRYPT
-#define DES_set_key DES_SET_KEY
-#define DES_set_odd_parity DES_SET_ODD_PARITY
-#define ENGINE_ctrl ENGINE_CTRL
-#define ENGINE_ctrl_cmd ENGINE_CTRL_CMD
-#define ENGINE_finish ENGINE_FINISH
-#define ENGINE_free ENGINE_FREE
-#define ENGINE_get_first ENGINE_GET_FIRST
-#define ENGINE_get_id ENGINE_GET_ID
-#define ENGINE_get_next ENGINE_GET_NEXT
-#define ENGINE_init ENGINE_INIT
+#define DES_ecb_encrypt             DES_ECB_ENCRYPT
+#define DES_set_key                 DES_SET_KEY
+#define DES_set_odd_parity          DES_SET_ODD_PARITY
+#define ENGINE_ctrl                 ENGINE_CTRL
+#define ENGINE_ctrl_cmd             ENGINE_CTRL_CMD
+#define ENGINE_finish               ENGINE_FINISH
+#define ENGINE_free                 ENGINE_FREE
+#define ENGINE_get_first            ENGINE_GET_FIRST
+#define ENGINE_get_id               ENGINE_GET_ID
+#define ENGINE_get_next             ENGINE_GET_NEXT
+#define ENGINE_init                 ENGINE_INIT
 #define ENGINE_load_builtin_engines ENGINE_LOAD_BUILTIN_ENGINES
-#define ENGINE_load_private_key ENGINE_LOAD_PRIVATE_KEY
-#define ENGINE_set_default ENGINE_SET_DEFAULT
-#define ERR_clear_error ERR_CLEAR_ERROR
-#define ERR_error_string ERR_ERROR_STRING
-#define ERR_error_string_n ERR_ERROR_STRING_N
-#define ERR_free_strings ERR_FREE_STRINGS
-#define ERR_get_error ERR_GET_ERROR
-#define ERR_peek_error ERR_PEEK_ERROR
-#define ERR_remove_state ERR_REMOVE_STATE
-#define EVP_PKEY_copy_parameters EVP_PKEY_COPY_PARAMETERS
-#define EVP_PKEY_free EVP_PKEY_FREE
-#define EVP_cleanup EVP_CLEANUP
-#define GENERAL_NAMES_free GENERAL_NAMES_FREE
-#define i2d_X509_PUBKEY I2D_X509_PUBKEY
-#define MD4_Final MD4_FINAL
-#define MD4_Init MD4_INIT
-#define MD4_Update MD4_UPDATE
-#define MD5_Final MD5_FINAL
-#define MD5_Init MD5_INIT
-#define MD5_Update MD5_UPDATE
+#define ENGINE_load_private_key     ENGINE_LOAD_PRIVATE_KEY
+#define ENGINE_set_default          ENGINE_SET_DEFAULT
+#define ERR_clear_error             ERR_CLEAR_ERROR
+#define ERR_error_string            ERR_ERROR_STRING
+#define ERR_error_string_n          ERR_ERROR_STRING_N
+#define ERR_free_strings            ERR_FREE_STRINGS
+#define ERR_get_error               ERR_GET_ERROR
+#define ERR_peek_error              ERR_PEEK_ERROR
+#define ERR_remove_state            ERR_REMOVE_STATE
+#define EVP_PKEY_copy_parameters    EVP_PKEY_COPY_PARAMETERS
+#define EVP_PKEY_free               EVP_PKEY_FREE
+#define EVP_cleanup                 EVP_CLEANUP
+#define GENERAL_NAMES_free          GENERAL_NAMES_FREE
+#define i2d_X509_PUBKEY             I2D_X509_PUBKEY
+#define MD4_Final                   MD4_FINAL
+#define MD4_Init                    MD4_INIT
+#define MD4_Update                  MD4_UPDATE
+#define MD5_Final                   MD5_FINAL
+#define MD5_Init                    MD5_INIT
+#define MD5_Update                  MD5_UPDATE
 #define OPENSSL_add_all_algo_noconf OPENSSL_ADD_ALL_ALGO_NOCONF
 #ifndef __VAX
 #define OPENSSL_load_builtin_modules OPENSSL_LOAD_BUILTIN_MODULES
 #endif
-#define PEM_read_X509 PEM_READ_X509
-#define PEM_write_bio_X509 PEM_WRITE_BIO_X509
-#define PKCS12_free PKCS12_FREE
-#define PKCS12_parse PKCS12_PARSE
-#define RAND_add RAND_ADD
-#define RAND_bytes RAND_BYTES
-#define RAND_file_name RAND_FILE_NAME
-#define RAND_load_file RAND_LOAD_FILE
-#define RAND_status RAND_STATUS
-#define SSL_CIPHER_get_name SSL_CIPHER_GET_NAME
-#define SSL_CTX_add_client_CA SSL_CTX_ADD_CLIENT_CA
-#define SSL_CTX_callback_ctrl SSL_CTX_CALLBACK_CTRL
-#define SSL_CTX_check_private_key SSL_CTX_CHECK_PRIVATE_KEY
-#define SSL_CTX_ctrl SSL_CTX_CTRL
-#define SSL_CTX_free SSL_CTX_FREE
-#define SSL_CTX_get_cert_store SSL_CTX_GET_CERT_STORE
-#define SSL_CTX_load_verify_locations SSL_CTX_LOAD_VERIFY_LOCATIONS
-#define SSL_CTX_new SSL_CTX_NEW
-#define SSL_CTX_set_cipher_list SSL_CTX_SET_CIPHER_LIST
-#define SSL_CTX_set_def_passwd_cb_ud SSL_CTX_SET_DEF_PASSWD_CB_UD
-#define SSL_CTX_set_default_passwd_cb SSL_CTX_SET_DEFAULT_PASSWD_CB
-#define SSL_CTX_set_msg_callback SSL_CTX_SET_MSG_CALLBACK
-#define SSL_CTX_set_verify SSL_CTX_SET_VERIFY
-#define SSL_CTX_use_PrivateKey SSL_CTX_USE_PRIVATEKEY
-#define SSL_CTX_use_PrivateKey_file SSL_CTX_USE_PRIVATEKEY_FILE
-#define SSL_CTX_use_cert_chain_file SSL_CTX_USE_CERT_CHAIN_FILE
-#define SSL_CTX_use_certificate SSL_CTX_USE_CERTIFICATE
-#define SSL_CTX_use_certificate_file SSL_CTX_USE_CERTIFICATE_FILE
-#define SSL_SESSION_free SSL_SESSION_FREE
-#define SSL_connect SSL_CONNECT
-#define SSL_free SSL_FREE
-#define SSL_get1_session SSL_GET1_SESSION
-#define SSL_get_certificate SSL_GET_CERTIFICATE
-#define SSL_get_current_cipher SSL_GET_CURRENT_CIPHER
-#define SSL_get_error SSL_GET_ERROR
-#define SSL_get_peer_cert_chain SSL_GET_PEER_CERT_CHAIN
-#define SSL_get_peer_certificate SSL_GET_PEER_CERTIFICATE
-#define SSL_get_privatekey SSL_GET_PRIVATEKEY
-#define SSL_get_session SSL_GET_SESSION
-#define SSL_get_shutdown SSL_GET_SHUTDOWN
-#define SSL_get_verify_result SSL_GET_VERIFY_RESULT
-#define SSL_library_init SSL_LIBRARY_INIT
-#define SSL_load_error_strings SSL_LOAD_ERROR_STRINGS
-#define SSL_new SSL_NEW
-#define SSL_peek SSL_PEEK
-#define SSL_pending SSL_PENDING
-#define SSL_read SSL_READ
-#define SSL_set_connect_state SSL_SET_CONNECT_STATE
-#define SSL_set_fd SSL_SET_FD
-#define SSL_set_session SSL_SET_SESSION
-#define SSL_shutdown SSL_SHUTDOWN
-#define SSL_version SSL_VERSION
-#define SSL_write SSL_WRITE
-#define SSLeay SSLEAY
-#define SSLv23_client_method SSLV23_CLIENT_METHOD
-#define SSLv3_client_method SSLV3_CLIENT_METHOD
-#define TLSv1_client_method TLSV1_CLIENT_METHOD
-#define UI_create_method UI_CREATE_METHOD
-#define UI_destroy_method UI_DESTROY_METHOD
-#define UI_get0_user_data UI_GET0_USER_DATA
-#define UI_get_input_flags UI_GET_INPUT_FLAGS
-#define UI_get_string_type UI_GET_STRING_TYPE
-#define UI_create_method UI_CREATE_METHOD
-#define UI_destroy_method UI_DESTROY_METHOD
-#define UI_method_get_closer UI_METHOD_GET_CLOSER
-#define UI_method_get_opener UI_METHOD_GET_OPENER
-#define UI_method_get_reader UI_METHOD_GET_READER
-#define UI_method_get_writer UI_METHOD_GET_WRITER
-#define UI_method_set_closer UI_METHOD_SET_CLOSER
-#define UI_method_set_opener UI_METHOD_SET_OPENER
-#define UI_method_set_reader UI_METHOD_SET_READER
-#define UI_method_set_writer UI_METHOD_SET_WRITER
-#define UI_OpenSSL UI_OPENSSL
-#define UI_set_result UI_SET_RESULT
-#define X509V3_EXT_print X509V3_EXT_PRINT
-#define X509_EXTENSION_get_critical X509_EXTENSION_GET_CRITICAL
-#define X509_EXTENSION_get_data X509_EXTENSION_GET_DATA
-#define X509_EXTENSION_get_object X509_EXTENSION_GET_OBJECT
-#define X509_LOOKUP_file X509_LOOKUP_FILE
-#define X509_NAME_ENTRY_get_data X509_NAME_ENTRY_GET_DATA
-#define X509_NAME_get_entry X509_NAME_GET_ENTRY
-#define X509_NAME_get_index_by_NID X509_NAME_GET_INDEX_BY_NID
-#define X509_NAME_print_ex X509_NAME_PRINT_EX
+#define PEM_read_X509                   PEM_READ_X509
+#define PEM_write_bio_X509              PEM_WRITE_BIO_X509
+#define PKCS12_free                     PKCS12_FREE
+#define PKCS12_parse                    PKCS12_PARSE
+#define RAND_add                        RAND_ADD
+#define RAND_bytes                      RAND_BYTES
+#define RAND_file_name                  RAND_FILE_NAME
+#define RAND_load_file                  RAND_LOAD_FILE
+#define RAND_status                     RAND_STATUS
+#define SSL_CIPHER_get_name             SSL_CIPHER_GET_NAME
+#define SSL_CTX_add_client_CA           SSL_CTX_ADD_CLIENT_CA
+#define SSL_CTX_callback_ctrl           SSL_CTX_CALLBACK_CTRL
+#define SSL_CTX_check_private_key       SSL_CTX_CHECK_PRIVATE_KEY
+#define SSL_CTX_ctrl                    SSL_CTX_CTRL
+#define SSL_CTX_free                    SSL_CTX_FREE
+#define SSL_CTX_get_cert_store          SSL_CTX_GET_CERT_STORE
+#define SSL_CTX_load_verify_locations   SSL_CTX_LOAD_VERIFY_LOCATIONS
+#define SSL_CTX_new                     SSL_CTX_NEW
+#define SSL_CTX_set_cipher_list         SSL_CTX_SET_CIPHER_LIST
+#define SSL_CTX_set_def_passwd_cb_ud    SSL_CTX_SET_DEF_PASSWD_CB_UD
+#define SSL_CTX_set_default_passwd_cb   SSL_CTX_SET_DEFAULT_PASSWD_CB
+#define SSL_CTX_set_msg_callback        SSL_CTX_SET_MSG_CALLBACK
+#define SSL_CTX_set_verify              SSL_CTX_SET_VERIFY
+#define SSL_CTX_use_PrivateKey          SSL_CTX_USE_PRIVATEKEY
+#define SSL_CTX_use_PrivateKey_file     SSL_CTX_USE_PRIVATEKEY_FILE
+#define SSL_CTX_use_cert_chain_file     SSL_CTX_USE_CERT_CHAIN_FILE
+#define SSL_CTX_use_certificate         SSL_CTX_USE_CERTIFICATE
+#define SSL_CTX_use_certificate_file    SSL_CTX_USE_CERTIFICATE_FILE
+#define SSL_SESSION_free                SSL_SESSION_FREE
+#define SSL_connect                     SSL_CONNECT
+#define SSL_free                        SSL_FREE
+#define SSL_get1_session                SSL_GET1_SESSION
+#define SSL_get_certificate             SSL_GET_CERTIFICATE
+#define SSL_get_current_cipher          SSL_GET_CURRENT_CIPHER
+#define SSL_get_error                   SSL_GET_ERROR
+#define SSL_get_peer_cert_chain         SSL_GET_PEER_CERT_CHAIN
+#define SSL_get_peer_certificate        SSL_GET_PEER_CERTIFICATE
+#define SSL_get_privatekey              SSL_GET_PRIVATEKEY
+#define SSL_get_session                 SSL_GET_SESSION
+#define SSL_get_shutdown                SSL_GET_SHUTDOWN
+#define SSL_get_verify_result           SSL_GET_VERIFY_RESULT
+#define SSL_library_init                SSL_LIBRARY_INIT
+#define SSL_load_error_strings          SSL_LOAD_ERROR_STRINGS
+#define SSL_new                         SSL_NEW
+#define SSL_peek                        SSL_PEEK
+#define SSL_pending                     SSL_PENDING
+#define SSL_read                        SSL_READ
+#define SSL_set_connect_state           SSL_SET_CONNECT_STATE
+#define SSL_set_fd                      SSL_SET_FD
+#define SSL_set_session                 SSL_SET_SESSION
+#define SSL_shutdown                    SSL_SHUTDOWN
+#define SSL_version                     SSL_VERSION
+#define SSL_write                       SSL_WRITE
+#define SSLeay                          SSLEAY
+#define SSLv23_client_method            SSLV23_CLIENT_METHOD
+#define SSLv3_client_method             SSLV3_CLIENT_METHOD
+#define TLSv1_client_method             TLSV1_CLIENT_METHOD
+#define UI_create_method                UI_CREATE_METHOD
+#define UI_destroy_method               UI_DESTROY_METHOD
+#define UI_get0_user_data               UI_GET0_USER_DATA
+#define UI_get_input_flags              UI_GET_INPUT_FLAGS
+#define UI_get_string_type              UI_GET_STRING_TYPE
+#define UI_create_method                UI_CREATE_METHOD
+#define UI_destroy_method               UI_DESTROY_METHOD
+#define UI_method_get_closer            UI_METHOD_GET_CLOSER
+#define UI_method_get_opener            UI_METHOD_GET_OPENER
+#define UI_method_get_reader            UI_METHOD_GET_READER
+#define UI_method_get_writer            UI_METHOD_GET_WRITER
+#define UI_method_set_closer            UI_METHOD_SET_CLOSER
+#define UI_method_set_opener            UI_METHOD_SET_OPENER
+#define UI_method_set_reader            UI_METHOD_SET_READER
+#define UI_method_set_writer            UI_METHOD_SET_WRITER
+#define UI_OpenSSL                      UI_OPENSSL
+#define UI_set_result                   UI_SET_RESULT
+#define X509V3_EXT_print                X509V3_EXT_PRINT
+#define X509_EXTENSION_get_critical     X509_EXTENSION_GET_CRITICAL
+#define X509_EXTENSION_get_data         X509_EXTENSION_GET_DATA
+#define X509_EXTENSION_get_object       X509_EXTENSION_GET_OBJECT
+#define X509_LOOKUP_file                X509_LOOKUP_FILE
+#define X509_NAME_ENTRY_get_data        X509_NAME_ENTRY_GET_DATA
+#define X509_NAME_get_entry             X509_NAME_GET_ENTRY
+#define X509_NAME_get_index_by_NID      X509_NAME_GET_INDEX_BY_NID
+#define X509_NAME_print_ex              X509_NAME_PRINT_EX
 #define X509_STORE_CTX_get_current_cert X509_STORE_CTX_GET_CURRENT_CERT
-#define X509_STORE_add_lookup X509_STORE_ADD_LOOKUP
-#define X509_STORE_set_flags X509_STORE_SET_FLAGS
-#define X509_check_issued X509_CHECK_ISSUED
-#define X509_free X509_FREE
-#define X509_get_ext_d2i X509_GET_EXT_D2I
-#define X509_get_issuer_name X509_GET_ISSUER_NAME
-#define X509_get_pubkey X509_GET_PUBKEY
-#define X509_get_serialNumber X509_GET_SERIALNUMBER
-#define X509_get_subject_name X509_GET_SUBJECT_NAME
-#define X509_load_crl_file X509_LOAD_CRL_FILE
-#define X509_verify_cert_error_string X509_VERIFY_CERT_ERROR_STRING
-#define d2i_PKCS12_fp D2I_PKCS12_FP
-#define i2t_ASN1_OBJECT I2T_ASN1_OBJECT
-#define sk_num SK_NUM
-#define sk_pop SK_POP
-#define sk_pop_free SK_POP_FREE
-#define sk_value SK_VALUE
+#define X509_STORE_add_lookup           X509_STORE_ADD_LOOKUP
+#define X509_STORE_set_flags            X509_STORE_SET_FLAGS
+#define X509_check_issued               X509_CHECK_ISSUED
+#define X509_free                       X509_FREE
+#define X509_get_ext_d2i                X509_GET_EXT_D2I
+#define X509_get_issuer_name            X509_GET_ISSUER_NAME
+#define X509_get_pubkey                 X509_GET_PUBKEY
+#define X509_get_serialNumber           X509_GET_SERIALNUMBER
+#define X509_get_subject_name           X509_GET_SUBJECT_NAME
+#define X509_load_crl_file              X509_LOAD_CRL_FILE
+#define X509_verify_cert_error_string   X509_VERIFY_CERT_ERROR_STRING
+#define d2i_PKCS12_fp                   D2I_PKCS12_FP
+#define i2t_ASN1_OBJECT                 I2T_ASN1_OBJECT
+#define sk_num                          SK_NUM
+#define sk_pop                          SK_POP
+#define sk_pop_free                     SK_POP_FREE
+#define sk_value                        SK_VALUE
 #ifdef __VAX
 #define OPENSSL_NO_SHA256
 #endif
-#define SHA256_Final SHA256_FINAL
-#define SHA256_Init SHA256_INIT
+#define SHA256_Final  SHA256_FINAL
+#define SHA256_Init   SHA256_INIT
 #define SHA256_Update SHA256_UPDATE
 
 #define USE_UPPERCASE_GSSAPI 1
-#define gss_seal GSS_SEAL
-#define gss_unseal GSS_UNSEAL
+#define gss_seal             GSS_SEAL
+#define gss_unseal           GSS_UNSEAL
 
 #define USE_UPPERCASE_KRBAPI 1
 
@@ -379,11 +378,11 @@ static struct passwd *vms_getpwuid(uid_t uid)
 
 /* VAX symbols are always in uppercase */
 #ifdef __VAX
-#define inflate INFLATE
-#define inflateEnd INFLATEEND
+#define inflate       INFLATE
+#define inflateEnd    INFLATEEND
 #define inflateInit2_ INFLATEINIT2_
-#define inflateInit_ INFLATEINIT_
-#define zlibVersion ZLIBVERSION
+#define inflateInit_  INFLATEINIT_
+#define zlibVersion   ZLIBVERSION
 #endif
 
 /* Older VAX OpenSSL port defines these as Macros */
@@ -391,11 +390,11 @@ static struct passwd *vms_getpwuid(uid_t uid)
 /* that way a newer port will also work if some one has one */
 #ifdef __VAX
 
-#   include <openssl/evp.h>
-#   ifndef OpenSSL_add_all_algorithms
-#       define OpenSSL_add_all_algorithms OPENSSL_ADD_ALL_ALGORITHMS
-        void OPENSSL_ADD_ALL_ALGORITHMS(void);
-#   endif
+#  include <openssl/evp.h>
+#  ifndef OpenSSL_add_all_algorithms
+#    define OpenSSL_add_all_algorithms OPENSSL_ADD_ALL_ALGORITHMS
+     void OPENSSL_ADD_ALL_ALGORITHMS(void);
+#  endif
 #endif
 
 #endif /* HEADER_CURL_SETUP_VMS_H */
index 977ad3edc402c2210380f20820d0b9e0df358876..9c3b60ec18853ecdc6dfef669e33b363ffc9ba03 100644 (file)
@@ -193,7 +193,7 @@ static CURLcode my_sha256_init(void *in)
 {
   my_sha256_ctx *ctx = (my_sha256_ctx *)in;
   if(!CryptAcquireContext(&ctx->hCryptProv, NULL, NULL, PROV_RSA_AES,
-                         CRYPT_VERIFYCONTEXT | CRYPT_SILENT))
+                          CRYPT_VERIFYCONTEXT | CRYPT_SILENT))
     return CURLE_OUT_OF_MEMORY;
 
   if(!CryptCreateHash(ctx->hCryptProv, CALG_SHA_256, 0, 0, &ctx->hHash)) {
@@ -236,42 +236,43 @@ static void my_sha256_final(unsigned char *digest, void *in)
 /* This is based on the SHA256 implementation in LibTomCrypt that was released
  * into public domain. */
 
-#define WPA_GET_BE32(a) ((((unsigned long)(a)[0]) << 24) | \
-                         (((unsigned long)(a)[1]) << 16) | \
-                         (((unsigned long)(a)[2]) <<  8) | \
-                          ((unsigned long)(a)[3]))
-#define WPA_PUT_BE32(a, val)                                        \
-do {                                                                \
-  (a)[0] = (unsigned char)((((unsigned long) (val)) >> 24) & 0xff); \
-  (a)[1] = (unsigned char)((((unsigned long) (val)) >> 16) & 0xff); \
-  (a)[2] = (unsigned char)((((unsigned long) (val)) >> 8) & 0xff);  \
-  (a)[3] = (unsigned char)(((unsigned long) (val)) & 0xff);         \
-} while(0)
+#define WPA_GET_BE32(a)              \
+  ((((unsigned long)(a)[0]) << 24) | \
+   (((unsigned long)(a)[1]) << 16) | \
+   (((unsigned long)(a)[2]) <<  8) | \
+    ((unsigned long)(a)[3]))
+#define WPA_PUT_BE32(a, val)                                         \
+  do {                                                               \
+    (a)[0] = (unsigned char)((((unsigned long)(val)) >> 24) & 0xff); \
+    (a)[1] = (unsigned char)((((unsigned long)(val)) >> 16) & 0xff); \
+    (a)[2] = (unsigned char)((((unsigned long)(val)) >>  8) & 0xff); \
+    (a)[3] = (unsigned char) (((unsigned long)(val)) & 0xff);        \
+  } while(0)
 
 #ifdef HAVE_LONGLONG
-#define WPA_PUT_BE64(a, val)                                    \
-do {                                                            \
-  (a)[0] = (unsigned char)(((unsigned long long)(val)) >> 56);  \
-  (a)[1] = (unsigned char)(((unsigned long long)(val)) >> 48);  \
-  (a)[2] = (unsigned char)(((unsigned long long)(val)) >> 40);  \
-  (a)[3] = (unsigned char)(((unsigned long long)(val)) >> 32);  \
-  (a)[4] = (unsigned char)(((unsigned long long)(val)) >> 24);  \
-  (a)[5] = (unsigned char)(((unsigned long long)(val)) >> 16);  \
-  (a)[6] = (unsigned char)(((unsigned long long)(val)) >> 8);   \
-  (a)[7] = (unsigned char)(((unsigned long long)(val)) & 0xff); \
-} while(0)
+#define WPA_PUT_BE64(a, val)                                      \
+  do {                                                            \
+    (a)[0] = (unsigned char)(((unsigned long long)(val)) >> 56);  \
+    (a)[1] = (unsigned char)(((unsigned long long)(val)) >> 48);  \
+    (a)[2] = (unsigned char)(((unsigned long long)(val)) >> 40);  \
+    (a)[3] = (unsigned char)(((unsigned long long)(val)) >> 32);  \
+    (a)[4] = (unsigned char)(((unsigned long long)(val)) >> 24);  \
+    (a)[5] = (unsigned char)(((unsigned long long)(val)) >> 16);  \
+    (a)[6] = (unsigned char)(((unsigned long long)(val)) >>  8);  \
+    (a)[7] = (unsigned char)(((unsigned long long)(val)) & 0xff); \
+  } while(0)
 #else
-#define WPA_PUT_BE64(a, val)                                  \
-do {                                                          \
-  (a)[0] = (unsigned char)(((unsigned __int64)(val)) >> 56);  \
-  (a)[1] = (unsigned char)(((unsigned __int64)(val)) >> 48);  \
-  (a)[2] = (unsigned char)(((unsigned __int64)(val)) >> 40);  \
-  (a)[3] = (unsigned char)(((unsigned __int64)(val)) >> 32);  \
-  (a)[4] = (unsigned char)(((unsigned __int64)(val)) >> 24);  \
-  (a)[5] = (unsigned char)(((unsigned __int64)(val)) >> 16);  \
-  (a)[6] = (unsigned char)(((unsigned __int64)(val)) >> 8);   \
-  (a)[7] = (unsigned char)(((unsigned __int64)(val)) & 0xff); \
-} while(0)
+#define WPA_PUT_BE64(a, val)                                    \
+  do {                                                          \
+    (a)[0] = (unsigned char)(((unsigned __int64)(val)) >> 56);  \
+    (a)[1] = (unsigned char)(((unsigned __int64)(val)) >> 48);  \
+    (a)[2] = (unsigned char)(((unsigned __int64)(val)) >> 40);  \
+    (a)[3] = (unsigned char)(((unsigned __int64)(val)) >> 32);  \
+    (a)[4] = (unsigned char)(((unsigned __int64)(val)) >> 24);  \
+    (a)[5] = (unsigned char)(((unsigned __int64)(val)) >> 16);  \
+    (a)[6] = (unsigned char)(((unsigned __int64)(val)) >>  8);  \
+    (a)[7] = (unsigned char)(((unsigned __int64)(val)) & 0xff); \
+  } while(0)
 #endif
 
 struct sha256_state {
@@ -304,20 +305,21 @@ static const unsigned long K[64] = {
 
 /* Various logical functions */
 #define RORc(x, y) \
-(((((unsigned long)(x) & 0xFFFFFFFFUL) >> (unsigned long)((y) & 31)) | \
-   ((unsigned long)(x) << (unsigned long)(32 - ((y) & 31)))) & 0xFFFFFFFFUL)
-#define Sha256_Ch(x,y,z)  (z ^ (x & (y ^ z)))
-#define Sha256_Maj(x,y,z) (((x | y) & z) | (x & y))
-#define Sha256_S(x, n)    RORc((x), (n))
-#define Sha256_R(x, n)    (((x)&0xFFFFFFFFUL)>>(n))
+  (((((unsigned long)(x) & 0xFFFFFFFFUL) >> (unsigned long)((y) & 31)) | \
+     ((unsigned long)(x) << (unsigned long)(32 - ((y) & 31)))) & 0xFFFFFFFFUL)
+
+#define Sha256_Ch(x, y, z)  (z ^ (x & (y ^ z)))
+#define Sha256_Maj(x, y, z) (((x | y) & z) | (x & y))
+#define Sha256_S(x, n)      RORc((x), (n))
+#define Sha256_R(x, n)      (((x) & 0xFFFFFFFFUL) >> (n))
+
 #define Sigma0(x)         (Sha256_S(x, 2) ^ Sha256_S(x, 13) ^ Sha256_S(x, 22))
 #define Sigma1(x)         (Sha256_S(x, 6) ^ Sha256_S(x, 11) ^ Sha256_S(x, 25))
 #define Gamma0(x)         (Sha256_S(x, 7) ^ Sha256_S(x, 18) ^ Sha256_R(x, 3))
 #define Gamma1(x)         (Sha256_S(x, 17) ^ Sha256_S(x, 19) ^ Sha256_R(x, 10))
 
 /* Compress 512-bits */
-static int sha256_compress(struct sha256_state *md,
-                           const unsigned char *buf)
+static int sha256_compress(struct sha256_state *md, const unsigned char *buf)
 {
   unsigned long S[8], W[64];
   int i;
@@ -331,12 +333,11 @@ static int sha256_compress(struct sha256_state *md,
     W[i] = WPA_GET_BE32(buf + (4 * i));
   /* fill W[16..63] */
   for(i = 16; i < 64; i++) {
-    W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) +
-      W[i - 16];
+    W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) + W[i - 16];
   }
 
   /* Compress */
-#define RND(a,b,c,d,e,f,g,h,i)                                           \
+#define RND(a, b, c, d, e, f, g, h, i)                                   \
   do {                                                                   \
     unsigned long t0 = h + Sigma1(e) + Sha256_Ch(e, f, g) + K[i] + W[i]; \
     unsigned long t1 = Sigma0(a) + Sha256_Maj(a, b, c);                  \
@@ -347,8 +348,15 @@ static int sha256_compress(struct sha256_state *md,
   for(i = 0; i < 64; ++i) {
     unsigned long t;
     RND(S[0], S[1], S[2], S[3], S[4], S[5], S[6], S[7], i);
-    t = S[7]; S[7] = S[6]; S[6] = S[5]; S[5] = S[4];
-    S[4] = S[3]; S[3] = S[2]; S[2] = S[1]; S[1] = S[0]; S[0] = t;
+    t = S[7];
+    S[7] = S[6];
+    S[6] = S[5];
+    S[5] = S[4];
+    S[4] = S[3];
+    S[3] = S[2];
+    S[2] = S[1];
+    S[1] = S[0];
+    S[0] = t;
   }
 
   /* Feedback */
@@ -492,7 +500,6 @@ CURLcode Curl_sha256it(unsigned char *output, const unsigned char *input,
   return result;
 }
 
-
 const struct HMAC_params Curl_HMAC_SHA256 = {
   my_sha256_init,        /* Hash initialization function. */
   my_sha256_update,      /* Hash update function. */
index 1be3a111e9580028f314ae10aa58ce53aa95283a..5d2c78a2713ce16419ac84f69dae1879794d9b39 100644 (file)
@@ -25,7 +25,7 @@
  ***************************************************************************/
 #include "curl_setup.h"
 
-#if defined(HAVE_SIGACTION) &&        \
+#if defined(HAVE_SIGACTION) && \
   (defined(USE_OPENSSL) || defined(USE_MBEDTLS) || defined(USE_WOLFSSL))
 #include <signal.h>
 
@@ -88,12 +88,12 @@ static void sigpipe_apply(struct Curl_easy *data,
 
 #else
 /* for systems without sigaction */
-#define sigpipe_ignore(x,y) Curl_nop_stmt
-#define sigpipe_apply(x,y) Curl_nop_stmt
-#define sigpipe_init(x)  Curl_nop_stmt
-#define sigpipe_restore(x)  Curl_nop_stmt
+#define sigpipe_ignore(x, y) Curl_nop_stmt
+#define sigpipe_apply(x, y)  Curl_nop_stmt
+#define sigpipe_init(x)      Curl_nop_stmt
+#define sigpipe_restore(x)   Curl_nop_stmt
 #define SIGPIPE_VARIABLE(x)
-#define SIGPIPE_MEMBER(x)   bool x
+#define SIGPIPE_MEMBER(x)    bool x
 #endif
 
 #endif /* HEADER_CURL_SIGPIPE_H */
index 469ee0ef3b5b5ab903ba9e194311df4abe0ca47c..9b7f11d4261996b547e4919384692d9a90433302 100644 (file)
@@ -31,7 +31,7 @@
 /* returns last node in linked list */
 static struct curl_slist *slist_get_last(struct curl_slist *list)
 {
-  struct curl_slist     *item;
+  struct curl_slist *item;
 
   /* if caller passed us a NULL, return now */
   if(!list)
@@ -57,8 +57,8 @@ static struct curl_slist *slist_get_last(struct curl_slist *list)
 struct curl_slist *Curl_slist_append_nodup(struct curl_slist *list,
                                            const char *data)
 {
-  struct curl_slist     *last;
-  struct curl_slist     *new_item;
+  struct curl_slist *last;
+  struct curl_slist *new_item;
 
   DEBUGASSERT(data);
 
@@ -85,8 +85,7 @@ struct curl_slist *Curl_slist_append_nodup(struct curl_slist *list,
  * bothersome, then simply create a separate _init function and call it
  * appropriately from within the program.
  */
-struct curl_slist *curl_slist_append(struct curl_slist *list,
-                                     const char *data)
+struct curl_slist *curl_slist_append(struct curl_slist *list, const char *data)
 {
   char *dupdata = curlx_strdup(data);
 
@@ -127,8 +126,8 @@ struct curl_slist *Curl_slist_duplicate(struct curl_slist *inlist)
 /* be nice and clean up resources */
 void curl_slist_free_all(struct curl_slist *list)
 {
-  struct curl_slist     *next;
-  struct curl_slist     *item;
+  struct curl_slist *next;
+  struct curl_slist *item;
 
   if(!list)
     return;
index 338464961b2184a24e537956c690b3d1e6dd6e4c..c52d4eca57af95d738836c1ee28f26a0437e0858 100644 (file)
--- a/lib/smb.c
+++ b/lib/smb.c
@@ -368,7 +368,7 @@ const struct Curl_handler Curl_handler_smbs = {
   defined(__OS400__)
 static unsigned short smb_swap16(unsigned short x)
 {
-  return (unsigned short) ((x << 8) | ((x >> 8) & 0xff));
+  return (unsigned short)((x << 8) | ((x >> 8) & 0xff));
 }
 
 static unsigned int smb_swap32(unsigned int x)
@@ -379,8 +379,8 @@ static unsigned int smb_swap32(unsigned int x)
 
 static curl_off_t smb_swap64(curl_off_t x)
 {
-  return ((curl_off_t) smb_swap32((unsigned int) x) << 32) |
-    smb_swap32((unsigned int) (x >> 32));
+  return ((curl_off_t)smb_swap32((unsigned int)x) << 32) |
+    smb_swap32((unsigned int)(x >> 32));
 }
 
 #else
@@ -573,7 +573,7 @@ static CURLcode smb_recv_message(struct Curl_easy *data,
 
   if(nbt_size >= msg_size + 1) {
     /* Add the word count */
-    msg_size += 1 + ((unsigned char) buf[msg_size]) * sizeof(unsigned short);
+    msg_size += 1 + ((unsigned char)buf[msg_size]) * sizeof(unsigned short);
     if(nbt_size >= msg_size + sizeof(unsigned short)) {
       /* Add the byte count */
       msg_size += sizeof(unsigned short) +
@@ -601,8 +601,8 @@ static void smb_format_message(struct smb_conn *smbc,
   const unsigned int pid = 0xbad71d; /* made up */
 
   memset(h, 0, sizeof(*h));
-  h->nbt_length = htons((unsigned short) (sizeof(*h) - sizeof(unsigned int) +
-                                          len));
+  h->nbt_length = htons((unsigned short)(sizeof(*h) - sizeof(unsigned int) +
+                                         len));
   memcpy((char *)h->magic, "\xffSMB", 4);
   h->command = cmd;
   h->flags = SMB_FLAGS_CANONICAL_PATHNAMES | SMB_FLAGS_CASELESS_PATHNAMES;
@@ -610,7 +610,7 @@ static void smb_format_message(struct smb_conn *smbc,
   h->uid = smb_swap16(smbc->uid);
   h->tid = smb_swap16(req->tid);
   h->pid_high = smb_swap16((unsigned short)(pid >> 16));
-  h->pid = smb_swap16((unsigned short) pid);
+  h->pid = smb_swap16((unsigned short)pid);
 }
 
 static CURLcode smb_send(struct Curl_easy *data, struct smb_conn *smbc,
@@ -790,7 +790,7 @@ static CURLcode smb_send_open(struct Curl_easy *data,
     msg.access = smb_swap32(SMB_GENERIC_READ);
     msg.create_disposition = smb_swap32(SMB_FILE_OPEN);
   }
-  msg.byte_count = smb_swap16((unsigned short) byte_count);
+  msg.byte_count = smb_swap16((unsigned short)byte_count);
   strcpy(msg.bytes, req->path);
 
   return smb_send_message(data, smbc, req, SMB_COM_NT_CREATE_ANDX, &msg,
@@ -831,8 +831,8 @@ static CURLcode smb_send_read(struct Curl_easy *data,
   msg.word_count = SMB_WC_READ_ANDX;
   msg.andx.command = SMB_COM_NO_ANDX_COMMAND;
   msg.fid = smb_swap16(req->fid);
-  msg.offset = smb_swap32((unsigned int) offset);
-  msg.offset_high = smb_swap32((unsigned int) (offset >> 32));
+  msg.offset = smb_swap32((unsigned int)offset);
+  msg.offset_high = smb_swap32((unsigned int)(offset >> 32));
   msg.min_bytes = smb_swap16(MAX_PAYLOAD_SIZE);
   msg.max_bytes = smb_swap16(MAX_PAYLOAD_SIZE);
 
@@ -856,16 +856,16 @@ static CURLcode smb_send_write(struct Curl_easy *data,
   msg->word_count = SMB_WC_WRITE_ANDX;
   msg->andx.command = SMB_COM_NO_ANDX_COMMAND;
   msg->fid = smb_swap16(req->fid);
-  msg->offset = smb_swap32((unsigned int) offset);
-  msg->offset_high = smb_swap32((unsigned int) (offset >> 32));
-  msg->data_length = smb_swap16((unsigned short) upload_size);
+  msg->offset = smb_swap32((unsigned int)offset);
+  msg->offset_high = smb_swap32((unsigned int)(offset >> 32));
+  msg->data_length = smb_swap16((unsigned short)upload_size);
   msg->data_offset = smb_swap16(sizeof(*msg) - sizeof(unsigned int));
-  msg->byte_count = smb_swap16((unsigned short) (upload_size + 1));
+  msg->byte_count = smb_swap16((unsigned short)(upload_size + 1));
 
   smb_format_message(smbc, req, &msg->h, SMB_COM_WRITE_ANDX,
-                     sizeof(*msg) - sizeof(msg->h) + (size_t) upload_size);
+                     sizeof(*msg) - sizeof(msg->h) + (size_t)upload_size);
 
-  return smb_send(data, smbc, sizeof(*msg), (size_t) upload_size);
+  return smb_send(data, smbc, sizeof(*msg), (size_t)upload_size);
 }
 
 static CURLcode smb_send_and_recv(struct Curl_easy *data,
@@ -1014,7 +1014,7 @@ static void get_posix_time(time_t *out, curl_off_t timestamp)
       *out = TIME_T_MIN;
     else
 #endif
-      *out = (time_t) timestamp;
+      *out = (time_t)timestamp;
   }
   else
     *out = 0;
@@ -1084,7 +1084,7 @@ static CURLcode smb_request_state(struct Curl_easy *data, bool *done)
       next_state = SMB_TREE_DISCONNECT;
       break;
     }
-    smb_m = (const struct smb_nt_create_response*) msg;
+    smb_m = (const struct smb_nt_create_response *)msg;
     req->fid = smb_swap16(smb_m->fid);
     data->req.offset = 0;
     if(data->state.upload) {
@@ -1113,9 +1113,9 @@ static CURLcode smb_request_state(struct Curl_easy *data, bool *done)
       next_state = SMB_CLOSE;
       break;
     }
-    len = Curl_read16_le(((const unsigned char *) msg) +
+    len = Curl_read16_le(((const unsigned char *)msg) +
                          sizeof(struct smb_header) + 11);
-    off = Curl_read16_le(((const unsigned char *) msg) +
+    off = Curl_read16_le(((const unsigned char *)msg) +
                          sizeof(struct smb_header) + 13);
     if(len > 0) {
       if(off + sizeof(unsigned int) + len > smbc->got) {
@@ -1142,7 +1142,7 @@ static CURLcode smb_request_state(struct Curl_easy *data, bool *done)
       next_state = SMB_CLOSE;
       break;
     }
-    len = Curl_read16_le(((const unsigned char *) msg) +
+    len = Curl_read16_le(((const unsigned char *)msg) +
                          sizeof(struct smb_header) + 5);
     data->req.bytecount += len;
     data->req.offset += len;
index 55a15b36c08d31b3966e438c443479aa0d012fff..5aab391e379a16f6e44e3a0900974d3b01f66067 100644 (file)
@@ -201,8 +201,7 @@ const struct Curl_handler Curl_handler_smtp = {
   CURLPROTO_SMTP,                   /* protocol */
   CURLPROTO_SMTP,                   /* family */
   PROTOPT_CLOSEACTION | PROTOPT_NOURLQUERY | /* flags */
-  PROTOPT_URLOPTIONS | PROTOPT_SSL_REUSE |
-  PROTOPT_CONN_REUSE
+    PROTOPT_URLOPTIONS | PROTOPT_SSL_REUSE | PROTOPT_CONN_REUSE
 };
 
 #ifdef USE_SSL
@@ -233,8 +232,7 @@ const struct Curl_handler Curl_handler_smtps = {
   CURLPROTO_SMTPS,                  /* protocol */
   CURLPROTO_SMTP,                   /* family */
   PROTOPT_CLOSEACTION | PROTOPT_SSL | /* flags */
-  PROTOPT_NOURLQUERY | PROTOPT_URLOPTIONS |
-  PROTOPT_CONN_REUSE
+    PROTOPT_NOURLQUERY | PROTOPT_URLOPTIONS | PROTOPT_CONN_REUSE
 };
 #endif
 
@@ -285,10 +283,10 @@ static bool smtp_endofresp(struct Curl_easy *data, struct connectdata *conn,
     const char *p = tmpline;
     result = TRUE;
     memcpy(tmpline, line, (len == 5 ? 5 : 3));
-    tmpline[len == 5 ? 5 : 3 ] = 0;
+    tmpline[len == 5 ? 5 : 3] = 0;
     if(curlx_str_number(&p, &code, len == 5 ? 99999 : 999))
       return FALSE;
-    *resp = (int) code;
+    *resp = (int)code;
 
     /* Make sure real server never sends internal value */
     if(*resp == 1)
@@ -508,7 +506,7 @@ static CURLcode smtp_perform_auth(struct Curl_easy *data,
   CURLcode result = CURLE_OK;
   struct smtp_conn *smtpc =
     Curl_conn_meta_get(data->conn, CURL_META_SMTP_CONN);
-  const char *ir = (const char *) Curl_bufref_ptr(initresp);
+  const char *ir = (const char *)Curl_bufref_ptr(initresp);
 
   if(!smtpc)
     return CURLE_FAILED_INIT;
@@ -542,7 +540,7 @@ static CURLcode smtp_continue_auth(struct Curl_easy *data,
   if(!smtpc)
     return CURLE_FAILED_INIT;
   return Curl_pp_sendf(data, &smtpc->pp,
-                       "%s", (const char *) Curl_bufref_ptr(resp));
+                       "%s", (const char *)Curl_bufref_ptr(resp));
 }
 
 /***********************************************************************
@@ -923,7 +921,7 @@ static CURLcode smtp_state_servergreet_resp(struct Curl_easy *data,
   CURLcode result = CURLE_OK;
   (void)instate;
 
-  if(smtpcode/100 != 2) {
+  if(smtpcode / 100 != 2) {
     failf(data, "Got unexpected smtp-server response: %d", smtpcode);
     result = CURLE_WEIRD_SERVER_REPLY;
   }
@@ -972,9 +970,9 @@ static CURLcode smtp_state_ehlo_resp(struct Curl_easy *data,
 
   (void)instate;
 
-  if(smtpcode/100 != 2 && smtpcode != 1) {
-    if(data->set.use_ssl <= CURLUSESSL_TRY
-       || Curl_conn_is_ssl(data->conn, FIRSTSOCKET))
+  if(smtpcode / 100 != 2 && smtpcode != 1) {
+    if(data->set.use_ssl <= CURLUSESSL_TRY ||
+       Curl_conn_is_ssl(data->conn, FIRSTSOCKET))
       result = smtp_perform_helo(data, smtpc);
     else {
       failf(data, "Remote access denied: %d", smtpcode);
@@ -1073,7 +1071,7 @@ static CURLcode smtp_state_helo_resp(struct Curl_easy *data,
   CURLcode result = CURLE_OK;
   (void)instate;
 
-  if(smtpcode/100 != 2) {
+  if(smtpcode / 100 != 2) {
     failf(data, "Remote access denied: %d", smtpcode);
     result = CURLE_REMOTE_ACCESS_DENIED;
   }
@@ -1125,8 +1123,8 @@ static CURLcode smtp_state_command_resp(struct Curl_easy *data,
 
   (void)instate;
 
-  if((smtp->rcpt && smtpcode/100 != 2 && smtpcode != 553 && smtpcode != 1) ||
-     (!smtp->rcpt && smtpcode/100 != 2 && smtpcode != 1)) {
+  if((smtp->rcpt && smtpcode / 100 != 2 && smtpcode != 553 && smtpcode != 1) ||
+     (!smtp->rcpt && smtpcode / 100 != 2 && smtpcode != 1)) {
     failf(data, "Command failed: %d", smtpcode);
     result = CURLE_WEIRD_SERVER_REPLY;
   }
@@ -1165,7 +1163,7 @@ static CURLcode smtp_state_mail_resp(struct Curl_easy *data,
   CURLcode result = CURLE_OK;
   (void)instate;
 
-  if(smtpcode/100 != 2) {
+  if(smtpcode / 100 != 2) {
     failf(data, "MAIL failed: %d", smtpcode);
     result = CURLE_SEND_ERROR;
   }
@@ -1189,7 +1187,7 @@ static CURLcode smtp_state_rcpt_resp(struct Curl_easy *data,
 
   (void)instate;
 
-  is_smtp_err = (smtpcode/100 != 2);
+  is_smtp_err = (smtpcode / 100 != 2);
 
   /* If there is multiple RCPT TO to be issued, it is possible to ignore errors
      and proceed with only the valid addresses. */
@@ -1735,8 +1733,8 @@ static CURLcode smtp_setup_connection(struct Curl_easy *data,
   smtpc = curlx_calloc(1, sizeof(*smtpc));
   if(!smtpc ||
      Curl_conn_meta_set(conn, CURL_META_SMTP_CONN, smtpc, smtp_conn_dtor)) {
-     result = CURLE_OUT_OF_MEMORY;
-     goto out;
+    result = CURLE_OUT_OF_MEMORY;
+    goto out;
   }
 
   smtp = curlx_calloc(1, sizeof(*smtp));
@@ -1943,7 +1941,7 @@ static void cr_eob_close(struct Curl_easy *data, struct Curl_creader *reader)
 }
 
 /* this is the 5-bytes End-Of-Body marker for SMTP */
-#define SMTP_EOB "\r\n.\r\n"
+#define SMTP_EOB          "\r\n.\r\n"
 #define SMTP_EOB_FIND_LEN 3
 
 /* client reader doing SMTP End-Of-Body escaping. */
@@ -2016,16 +2014,16 @@ static CURLcode cr_eob_read(struct Curl_easy *data,
     const char *eob = SMTP_EOB;
     CURL_TRC_SMTP(data, "auto-ending mail body with '\\r\\n.\\r\\n'");
     switch(ctx->n_eob) {
-      case 2:
-        /* seen a CRLF at the end, just add the remainder */
-        eob = &SMTP_EOB[2];
-        break;
-      case 3:
-        /* ended with '\r\n.', we should escape the last '.' */
-        eob = "." SMTP_EOB;
-        break;
-      default:
-        break;
+    case 2:
+      /* seen a CRLF at the end, just add the remainder */
+      eob = &SMTP_EOB[2];
+      break;
+    case 3:
+      /* ended with '\r\n.', we should escape the last '.' */
+      eob = "." SMTP_EOB;
+      break;
+    default:
+      break;
     }
     result = Curl_bufq_cwrite(&ctx->buf, eob, strlen(eob), &n);
     if(result)
@@ -2078,8 +2076,7 @@ static CURLcode cr_eob_add(struct Curl_easy *data)
   struct Curl_creader *reader = NULL;
   CURLcode result;
 
-  result = Curl_creader_create(&reader, data, &cr_eob,
-                               CURL_CR_CONTENT_ENCODE);
+  result = Curl_creader_create(&reader, data, &cr_eob, CURL_CR_CONTENT_ENCODE);
   if(!result)
     result = Curl_creader_add(data, reader);
 
index e601f5f71beef75f63931c0cf209fe60a57ee228..5387c09340fb7e3e06e428ce8aedfa66336897f4 100644 (file)
 
 #ifdef USE_EVENTFD
 
-#define wakeup_write  write
-#define wakeup_read   read
-#define wakeup_close  close
-#define wakeup_create(p,nb) Curl_eventfd(p,nb)
+#define wakeup_write         write
+#define wakeup_read          read
+#define wakeup_close         close
+#define wakeup_create(p, nb) Curl_eventfd(p, nb)
 
 #include <curl/curl.h>
 int Curl_eventfd(curl_socket_t socks[2], bool nonblocking);
 
 #elif defined(HAVE_PIPE)
 
-#define wakeup_write  write
-#define wakeup_read   read
-#define wakeup_close  close
-#define wakeup_create(p,nb) Curl_pipe(p,nb)
+#define wakeup_write         write
+#define wakeup_read          read
+#define wakeup_close         close
+#define wakeup_create(p, nb) Curl_pipe(p, nb)
 
 #include <curl/curl.h>
 int Curl_pipe(curl_socket_t socks[2], bool nonblocking);
@@ -67,7 +67,7 @@ int Curl_pipe(curl_socket_t socks[2], bool nonblocking);
 #endif
 
 #define USE_SOCKETPAIR
-#define wakeup_create(p,nb)                                     \
+#define wakeup_create(p, nb)                                    \
   Curl_socketpair(SOCKETPAIR_FAMILY, SOCKETPAIR_TYPE, 0, p, nb)
 
 #endif /* USE_EVENTFD */
index 7160dd1506984f29b5ee2e6153622c38665a67b5..46208506527ca2b5e889e023d3e296b186b541d2 100644 (file)
@@ -164,9 +164,9 @@ CURLcode Curl_blockread_all(struct Curl_cfilter *cf,
 
 #if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
 #define DEBUG_AND_VERBOSE
-#define sxstate(x,c,d,y) socksstate(x,c,d,y, __LINE__)
+#define sxstate(x, c, d, y) socksstate(x, c, d, y, __LINE__)
 #else
-#define sxstate(x,c,d,y) socksstate(x,c,d,y)
+#define sxstate(x, c, d, y) socksstate(x, c, d, y)
 #endif
 
 /* always use this function to change state, to make debugging easier */
@@ -206,9 +206,9 @@ static CURLproxycode socks_failed(struct socks_state *sx,
 }
 
 static CURLproxycode socks_flush(struct socks_state *sx,
-                                  struct Curl_cfilter *cf,
-                                  struct Curl_easy *data,
-                                  bool *done)
+                                 struct Curl_cfilter *cf,
+                                 struct Curl_easy *data,
+                                 bool *done)
 {
   CURLcode result;
   size_t nwritten;
@@ -332,8 +332,7 @@ static CURLproxycode socks4_resolving(struct socks_state *sx,
     result = Curl_resolv(data, sx->hostname, sx->remote_port,
                          cf->conn->ip_version, TRUE, &dns);
     if(result == CURLE_AGAIN) {
-      CURL_TRC_CF(data, cf, "SOCKS4 non-blocking resolve of %s",
-                  sx->hostname);
+      CURL_TRC_CF(data, cf, "SOCKS4 non-blocking resolve of %s", sx->hostname);
       return CURLPX_OK;
     }
     else if(result)
@@ -347,8 +346,7 @@ static CURLproxycode socks4_resolving(struct socks_state *sx,
   }
 
   if(result || !dns) {
-    failf(data, "Failed to resolve \"%s\" for SOCKS4 connect.",
-          sx->hostname);
+    failf(data, "Failed to resolve \"%s\" for SOCKS4 connect.", sx->hostname);
     return CURLPX_RESOLVE_HOST;
   }
 
@@ -465,16 +463,16 @@ static CURLproxycode socks4_check_resp(struct socks_state *sx,
 }
 
 /*
-* This function logs in to a SOCKS4 proxy and sends the specifics to the final
-* destination server.
-*
-* Reference :
-*   https://www.openssh.com/txt/socks4.protocol
-*
-* Note :
-*   Set protocol4a=true for  "SOCKS 4A (Simple Extension to SOCKS 4 Protocol)"
-*   Nonsupport "Identification Protocol (RFC1413)"
-*/
+ * This function logs in to a SOCKS4 proxy and sends the specifics to the final
+ * destination server.
+ *
+ * Reference :
+ *   https://www.openssh.com/txt/socks4.protocol
+ *
+ * Note :
+ *   Set protocol4a=true for  "SOCKS 4A (Simple Extension to SOCKS 4 Protocol)"
+ *   Nonsupport "Identification Protocol (RFC1413)"
+ */
 static CURLproxycode socks4_connect(struct Curl_cfilter *cf,
                                     struct socks_state *sx,
                                     struct Curl_easy *data)
@@ -733,7 +731,7 @@ static CURLproxycode socks5_auth_init(struct Curl_cfilter *cf,
     if(result || (nwritten != ulen))
       return CURLPX_SEND_REQUEST;
   }
-  buf[0] = (unsigned char) plen;
+  buf[0] = (unsigned char)plen;
   result = Curl_bufq_write(&sx->iobuf, buf, 1, &nwritten);
   if(result || (nwritten != 1))
     return CURLPX_SEND_REQUEST;
@@ -813,7 +811,7 @@ static CURLproxycode socks5_req1_init(struct socks_state *sx,
     const size_t hostname_len = strlen(sx->hostname);
     desttype = 3;
     destination = (const unsigned char *)sx->hostname;
-    destlen = (unsigned char) hostname_len; /* one byte length */
+    destlen = (unsigned char)hostname_len; /* one byte length */
   }
 
   req[3] = desttype;
@@ -860,8 +858,7 @@ static CURLproxycode socks5_resolving(struct socks_state *sx,
     result = Curl_resolv(data, sx->hostname, sx->remote_port,
                          cf->conn->ip_version, TRUE, &dns);
     if(result == CURLE_AGAIN) {
-      CURL_TRC_CF(data, cf, "SOCKS5 non-blocking resolve of %s",
-                  sx->hostname);
+      CURL_TRC_CF(data, cf, "SOCKS5 non-blocking resolve of %s", sx->hostname);
       return CURLPX_OK;
     }
     else if(result)
@@ -875,8 +872,7 @@ static CURLproxycode socks5_resolving(struct socks_state *sx,
   }
 
   if(result || !dns) {
-    failf(data, "Failed to resolve \"%s\" for SOCKS5 connect.",
-          sx->hostname);
+    failf(data, "Failed to resolve \"%s\" for SOCKS5 connect.", sx->hostname);
     presult = CURLPX_RESOLVE_HOST;
     goto out;
   }
@@ -893,8 +889,7 @@ static CURLproxycode socks5_resolving(struct socks_state *sx,
   }
 #endif
   if(!hp) {
-    failf(data, "Failed to resolve \"%s\" for SOCKS5 connect.",
-          sx->hostname);
+    failf(data, "Failed to resolve \"%s\" for SOCKS5 connect.", sx->hostname);
     presult = CURLPX_RESOLVE_HOST;
     goto out;
   }
@@ -1394,7 +1389,7 @@ static CURLcode socks_cf_query(struct Curl_cfilter *cf,
 
 struct Curl_cftype Curl_cft_socks_proxy = {
   "SOCKS",
-  CF_TYPE_IP_CONNECT|CF_TYPE_PROXY,
+  CF_TYPE_IP_CONNECT | CF_TYPE_PROXY,
   0,
   socks_proxy_cf_destroy,
   socks_proxy_cf_connect,
index f76bddc5f4e1adfd306d1a54ad03f280dfb22828..eb9088f530c7ffe4e06992b2cc31c68c77eb01e1 100644 (file)
@@ -27,9 +27,9 @@
 #include "curl_setup.h"
 
 #ifdef CURL_DISABLE_PROXY
-#define Curl_SOCKS4(a,b,c,d,e) CURLE_NOT_BUILT_IN
-#define Curl_SOCKS5(a,b,c,d,e,f) CURLE_NOT_BUILT_IN
-#define Curl_SOCKS_getsock(x,y,z) 0
+#define Curl_SOCKS4(a, b, c, d, e)    CURLE_NOT_BUILT_IN
+#define Curl_SOCKS5(a, b, c, d, e, f) CURLE_NOT_BUILT_IN
+#define Curl_SOCKS_getsock(x, y, z)   0
 #else
 /*
  * Helper read-from-socket functions. Does the same as Curl_read() but it
index 6f8a90139ded87096d9676b3846ba65db55680d1..3bee643e41084848c428ce9d672e6c3d72d95350 100644 (file)
@@ -67,8 +67,7 @@ static int check_gss_err(struct Curl_easy *data,
                                     GSS_C_NULL_OID,
                                     &msg_ctx, &status_string);
       if(maj_stat == GSS_S_COMPLETE) {
-        if(curlx_dyn_addn(&dbuf, status_string.value,
-                         status_string.length))
+        if(curlx_dyn_addn(&dbuf, status_string.value, status_string.length))
           return 1; /* error */
         gss_release_buffer(&min_stat, &status_string);
         break;
@@ -85,8 +84,7 @@ static int check_gss_err(struct Curl_easy *data,
                                     GSS_C_NULL_OID,
                                     &msg_ctx, &status_string);
       if(maj_stat == GSS_S_COMPLETE) {
-        if(curlx_dyn_addn(&dbuf, status_string.value,
-                         status_string.length))
+        if(curlx_dyn_addn(&dbuf, status_string.value, status_string.length))
           return 1; /* error */
         gss_release_buffer(&min_stat, &status_string);
         break;
@@ -144,7 +142,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf,
       return CURLE_OUT_OF_MEMORY;
 
     gss_major_status = gss_import_name(&gss_minor_status, &service,
-                                       (gss_OID) GSS_C_NULL_OID, &server);
+                                       (gss_OID)GSS_C_NULL_OID, &server);
   }
   else {
     service.value = curlx_malloc(serviceptr_length +
@@ -207,8 +205,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf,
       us_length = htons((unsigned short)gss_send_token.length);
       memcpy(socksreq + 2, &us_length, sizeof(short));
 
-      code = Curl_conn_cf_send(cf->next, data, socksreq, 4,
-                               FALSE, &nwritten);
+      code = Curl_conn_cf_send(cf->next, data, socksreq, 4, FALSE, &nwritten);
       if(code || (nwritten != 4)) {
         failf(data, "Failed to send GSS-API authentication request.");
         gss_release_name(&gss_status, &server);
@@ -227,7 +224,6 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf,
         Curl_gss_delete_sec_context(&gss_status, &gss_context, NULL);
         return CURLE_COULDNT_CONNECT;
       }
-
     }
 
     gss_release_buffer(&gss_status, &gss_send_token);
index 92592c5ce00774a25ab382cd5927d89797597155..17e875557eea4ce82181351d7360f244030c6bf4 100644 (file)
@@ -187,8 +187,8 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf,
     }
 
     if(sspi_send_token.cbBuffer) {
-      socksreq[0] = 1;    /* GSS-API subnegotiation version */
-      socksreq[1] = 1;    /* authentication message type */
+      socksreq[0] = 1; /* GSS-API subnegotiation version */
+      socksreq[1] = 1; /* authentication message type */
       if(sspi_send_token.cbBuffer > 0xffff) {
         /* needs to fit in an unsigned 16 bit field */
         result = CURLE_COULDNT_CONNECT;
@@ -305,8 +305,8 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf,
   }
 
   /* Do encryption */
-  socksreq[0] = 1;    /* GSS-API subnegotiation version */
-  socksreq[1] = 2;    /* encryption message type */
+  socksreq[0] = 1; /* GSS-API subnegotiation version */
+  socksreq[1] = 2; /* encryption message type */
 
   gss_enc = 0; /* no data protection */
   /* do confidentiality protection if supported */
@@ -318,7 +318,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf,
 
   infof(data, "SOCKS5 server supports GSS-API %s data protection.",
         (gss_enc == 0) ? "no" :
-        ((gss_enc == 1) ? "integrity":"confidentiality") );
+        ((gss_enc == 1) ? "integrity" : "confidentiality") );
 
   /*
    * Sending the encryption type in clear seems wrong. It should be
@@ -399,7 +399,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf,
     }
 
     etbuf_size = sspi_w_token[0].cbBuffer + sspi_w_token[1].cbBuffer +
-      sspi_w_token[2].cbBuffer;
+                 sspi_w_token[2].cbBuffer;
     if(etbuf_size > 0xffff) {
       /* needs to fit in an unsigned 16 bit field */
       result = CURLE_COULDNT_CONNECT;
index 3ca8678b2b2fcb3788b7a61eb673d3335242ace0..d036d27f548e526867e3ef98bec11a1f2eddfdad 100644 (file)
@@ -34,7 +34,7 @@
  *  zero          : when i is equal   to   j
  *  positive when : when i is larger  than j
  */
-#define compare(i,j) curlx_timediff_us(i,j)
+#define compare(i, j) curlx_timediff_us(i, j)
 
 /*
  * Splay using the key i (which may or may not be in the tree.) The starting
@@ -134,7 +134,6 @@ struct Curl_tree *Curl_splayinsert(struct curltime i,
     node->smaller = t->smaller;
     node->larger = t;
     t->smaller = NULL;
-
   }
   else {
     node->larger = t->larger;
@@ -156,7 +155,7 @@ struct Curl_tree *Curl_splaygetbest(struct curltime i,
                                     struct Curl_tree *t,
                                     struct Curl_tree **removed)
 {
-  static const struct curltime tv_zero = {0, 0};
+  static const struct curltime tv_zero = { 0, 0 };
   struct Curl_tree *x;
 
   if(!t) {
@@ -197,7 +196,6 @@ struct Curl_tree *Curl_splaygetbest(struct curltime i,
   return x;
 }
 
-
 /* Deletes the node we point out from the tree if it is there. Stores a
  * pointer to the new resulting tree in 'newroot'.
  *
index 78d4dc5b3d93a8d29b72f3c2be980a6a57fc7e36..e8424fa61732e71b0bc3bc773157927496d42103 100644 (file)
 
 /* Mapping table to go from lowercase to uppercase for plain ASCII.*/
 static const unsigned char touppermap[256] = {
-  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
-  22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
-  41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
-  60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
-  79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 65,
-  66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
-  85, 86, 87, 88, 89, 90, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132,
-  133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
-  148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162,
-  163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177,
-  178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192,
-  193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
-  208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222,
-  223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237,
-  238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252,
-  253, 254, 255
+  0,   1,   2,   3,   4,   5,   6,   7,   8,   9,   10,  11,  12,  13,  14,
+  15,  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,
+  30,  31,  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,
+  45,  46,  47,  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,
+  60,  61,  62,  63,  64,  65,  66,  67,  68,  69,  70,  71,  72,  73,  74,
+  75,  76,  77,  78,  79,  80,  81,  82,  83,  84,  85,  86,  87,  88,  89,
+  90,  91,  92,  93,  94,  95,  96,  65,  66,  67,  68,  69,  70,  71,  72,
+  73,  74,  75,  76,  77,  78,  79,  80,  81,  82,  83,  84,  85,  86,  87,
+  88,  89,  90,  123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
+  135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
+  150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
+  165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
+  180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
+  195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
+  210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224,
+  225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
+  240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254,
+  255
 };
 
 /* Mapping table to go from uppercase to lowercase for plain ASCII.*/
 static const unsigned char tolowermap[256] = {
-  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
-  22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
-  41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
-  60, 61, 62, 63, 64, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
-  109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 91, 92,
-  93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
-  110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
-  125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
-  140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
-  155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169,
-  170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184,
-  185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199,
-  200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214,
-  215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229,
-  230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244,
-  245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
+  0,   1,   2,   3,   4,   5,   6,   7,   8,   9,   10,  11,  12,  13,  14,
+  15,  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,
+  30,  31,  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,
+  45,  46,  47,  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,
+  60,  61,  62,  63,  64,  97,  98,  99,  100, 101, 102, 103, 104, 105, 106,
+  107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
+  122, 91,  92,  93,  94,  95,  96,  97,  98,  99,  100, 101, 102, 103, 104,
+  105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
+  120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
+  135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
+  150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
+  165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
+  180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
+  195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
+  210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224,
+  225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
+  240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254,
+  255
 };
 
-
 /* Portable, consistent toupper. Do not use toupper() because its behavior is
    altered by the current locale. */
 char Curl_raw_toupper(char in)
 {
-  return (char)touppermap[(unsigned char) in];
+  return (char)touppermap[(unsigned char)in];
 }
 
-
 /* Portable, consistent tolower. Do not use tolower() because its behavior is
    altered by the current locale. */
 char Curl_raw_tolower(char in)
 {
-  return (char)tolowermap[(unsigned char) in];
+  return (char)tolowermap[(unsigned char)in];
 }
 
 /* Copy an upper case version of the string from src to dest. The
@@ -135,7 +137,7 @@ int Curl_timestrcmp(const char *a, const char *b)
 
   if(a && b) {
     while(1) {
-      match |= a[i]^b[i];
+      match |= a[i] ^ b[i];
       if(!a[i] || !b[i])
         break;
       i++;
index 915c996926d0e982dc9588862276d42dacc6d14e..56839c2f3eaac1bf4ea69c5e4ccf69cfb469050a 100644 (file)
@@ -31,7 +31,7 @@ char Curl_raw_tolower(char in);
 
 /* checkprefix() is a shorter version of the above, used when the first
    argument is the string literal */
-#define checkprefix(a,b)    curl_strnequal(b, STRCONST(a))
+#define checkprefix(a, b) curl_strnequal(b, STRCONST(a))
 
 void Curl_strntoupper(char *dest, const char *src, size_t n);
 void Curl_strntolower(char *dest, const char *src, size_t n);
index 238a2611f645471d5d50023b11454484c9be37ec..22ade4d7ffad67d06e5b272dc9229bf570c1bd75 100644 (file)
@@ -29,7 +29,7 @@
 char *Curl_strdup(const char *str);
 #endif
 #ifdef _WIN32
-wchar_t* Curl_wcsdup(const wchar_t* src);
+wchar_t *Curl_wcsdup(const wchar_t *src);
 #endif
 void *Curl_memdup(const void *src, size_t buffer_length);
 void *Curl_saferealloc(void *ptr, size_t size);
index 4b957bef23124246a0d3faf4f54caa6b14d2b49a..899db8c61d7717be0df7a4d9784dd89add7d5f37 100644 (file)
@@ -34,8 +34,7 @@
 #include "curlx/winapi.h"
 #include "strerror.h"
 
-const char *
-curl_easy_strerror(CURLcode error)
+const char *curl_easy_strerror(CURLcode error)
 {
 #ifndef CURL_DISABLE_VERBOSE_STRINGS
   switch(error) {
@@ -53,7 +52,7 @@ curl_easy_strerror(CURLcode error)
 
   case CURLE_NOT_BUILT_IN:
     return "A requested feature, protocol or option was not found built-in in"
-      " this libcurl due to a build-time decision.";
+           " this libcurl due to a build-time decision.";
 
   case CURLE_COULDNT_RESOLVE_PROXY:
     return "Could not resolve proxy name";
@@ -327,8 +326,7 @@ curl_easy_strerror(CURLcode error)
 #endif
 }
 
-const char *
-curl_multi_strerror(CURLMcode error)
+const char *curl_multi_strerror(CURLMcode error)
 {
 #ifndef CURL_DISABLE_VERBOSE_STRINGS
   switch(error) {
@@ -387,8 +385,7 @@ curl_multi_strerror(CURLMcode error)
 #endif
 }
 
-const char *
-curl_share_strerror(CURLSHcode error)
+const char *curl_share_strerror(CURLSHcode error)
 {
 #ifndef CURL_DISABLE_VERBOSE_STRINGS
   switch(error) {
@@ -423,8 +420,7 @@ curl_share_strerror(CURLSHcode error)
 #endif
 }
 
-const char *
-curl_url_strerror(CURLUcode error)
+const char *curl_url_strerror(CURLUcode error)
 {
 #ifndef CURL_DISABLE_VERBOSE_STRINGS
   switch(error) {
@@ -558,96 +554,96 @@ const char *Curl_sspi_strerror(SECURITY_STATUS err, char *buf, size_t buflen)
 #ifndef CURL_DISABLE_VERBOSE_STRINGS
 
   switch(err) {
-    case SEC_E_OK:
-      txt = "No error";
-      break;
+  case SEC_E_OK:
+    txt = "No error";
+    break;
 #define SEC2TXT(sec) case sec: txt = #sec; break
-    SEC2TXT(CRYPT_E_REVOKED);
-    SEC2TXT(CRYPT_E_NO_REVOCATION_DLL);
-    SEC2TXT(CRYPT_E_NO_REVOCATION_CHECK);
-    SEC2TXT(CRYPT_E_REVOCATION_OFFLINE);
-    SEC2TXT(CRYPT_E_NOT_IN_REVOCATION_DATABASE);
-    SEC2TXT(SEC_E_ALGORITHM_MISMATCH);
-    SEC2TXT(SEC_E_BAD_BINDINGS);
-    SEC2TXT(SEC_E_BAD_PKGID);
-    SEC2TXT(SEC_E_BUFFER_TOO_SMALL);
-    SEC2TXT(SEC_E_CANNOT_INSTALL);
-    SEC2TXT(SEC_E_CANNOT_PACK);
-    SEC2TXT(SEC_E_CERT_EXPIRED);
-    SEC2TXT(SEC_E_CERT_UNKNOWN);
-    SEC2TXT(SEC_E_CERT_WRONG_USAGE);
-    SEC2TXT(SEC_E_CONTEXT_EXPIRED);
-    SEC2TXT(SEC_E_CROSSREALM_DELEGATION_FAILURE);
-    SEC2TXT(SEC_E_CRYPTO_SYSTEM_INVALID);
-    SEC2TXT(SEC_E_DECRYPT_FAILURE);
-    SEC2TXT(SEC_E_DELEGATION_POLICY);
-    SEC2TXT(SEC_E_DELEGATION_REQUIRED);
-    SEC2TXT(SEC_E_DOWNGRADE_DETECTED);
-    SEC2TXT(SEC_E_ENCRYPT_FAILURE);
-    SEC2TXT(SEC_E_ILLEGAL_MESSAGE);
-    SEC2TXT(SEC_E_INCOMPLETE_CREDENTIALS);
-    SEC2TXT(SEC_E_INCOMPLETE_MESSAGE);
-    SEC2TXT(SEC_E_INSUFFICIENT_MEMORY);
-    SEC2TXT(SEC_E_INTERNAL_ERROR);
-    SEC2TXT(SEC_E_INVALID_HANDLE);
-    SEC2TXT(SEC_E_INVALID_PARAMETER);
-    SEC2TXT(SEC_E_INVALID_TOKEN);
-    SEC2TXT(SEC_E_ISSUING_CA_UNTRUSTED);
-    SEC2TXT(SEC_E_ISSUING_CA_UNTRUSTED_KDC);
-    SEC2TXT(SEC_E_KDC_CERT_EXPIRED);
-    SEC2TXT(SEC_E_KDC_CERT_REVOKED);
-    SEC2TXT(SEC_E_KDC_INVALID_REQUEST);
-    SEC2TXT(SEC_E_KDC_UNABLE_TO_REFER);
-    SEC2TXT(SEC_E_KDC_UNKNOWN_ETYPE);
-    SEC2TXT(SEC_E_LOGON_DENIED);
-    SEC2TXT(SEC_E_MAX_REFERRALS_EXCEEDED);
-    SEC2TXT(SEC_E_MESSAGE_ALTERED);
-    SEC2TXT(SEC_E_MULTIPLE_ACCOUNTS);
-    SEC2TXT(SEC_E_MUST_BE_KDC);
-    SEC2TXT(SEC_E_NOT_OWNER);
-    SEC2TXT(SEC_E_NO_AUTHENTICATING_AUTHORITY);
-    SEC2TXT(SEC_E_NO_CREDENTIALS);
-    SEC2TXT(SEC_E_NO_IMPERSONATION);
-    SEC2TXT(SEC_E_NO_IP_ADDRESSES);
-    SEC2TXT(SEC_E_NO_KERB_KEY);
-    SEC2TXT(SEC_E_NO_PA_DATA);
-    SEC2TXT(SEC_E_NO_S4U_PROT_SUPPORT);
-    SEC2TXT(SEC_E_NO_TGT_REPLY);
-    SEC2TXT(SEC_E_OUT_OF_SEQUENCE);
-    SEC2TXT(SEC_E_PKINIT_CLIENT_FAILURE);
-    SEC2TXT(SEC_E_PKINIT_NAME_MISMATCH);
-    SEC2TXT(SEC_E_POLICY_NLTM_ONLY);
-    SEC2TXT(SEC_E_QOP_NOT_SUPPORTED);
-    SEC2TXT(SEC_E_REVOCATION_OFFLINE_C);
-    SEC2TXT(SEC_E_REVOCATION_OFFLINE_KDC);
-    SEC2TXT(SEC_E_SECPKG_NOT_FOUND);
-    SEC2TXT(SEC_E_SECURITY_QOS_FAILED);
-    SEC2TXT(SEC_E_SHUTDOWN_IN_PROGRESS);
-    SEC2TXT(SEC_E_SMARTCARD_CERT_EXPIRED);
-    SEC2TXT(SEC_E_SMARTCARD_CERT_REVOKED);
-    SEC2TXT(SEC_E_SMARTCARD_LOGON_REQUIRED);
-    SEC2TXT(SEC_E_STRONG_CRYPTO_NOT_SUPPORTED);
-    SEC2TXT(SEC_E_TARGET_UNKNOWN);
-    SEC2TXT(SEC_E_TIME_SKEW);
-    SEC2TXT(SEC_E_TOO_MANY_PRINCIPALS);
-    SEC2TXT(SEC_E_UNFINISHED_CONTEXT_DELETED);
-    SEC2TXT(SEC_E_UNKNOWN_CREDENTIALS);
-    SEC2TXT(SEC_E_UNSUPPORTED_FUNCTION);
-    SEC2TXT(SEC_E_UNSUPPORTED_PREAUTH);
-    SEC2TXT(SEC_E_UNTRUSTED_ROOT);
-    SEC2TXT(SEC_E_WRONG_CREDENTIAL_HANDLE);
-    SEC2TXT(SEC_E_WRONG_PRINCIPAL);
-    SEC2TXT(SEC_I_COMPLETE_AND_CONTINUE);
-    SEC2TXT(SEC_I_COMPLETE_NEEDED);
-    SEC2TXT(SEC_I_CONTEXT_EXPIRED);
-    SEC2TXT(SEC_I_CONTINUE_NEEDED);
-    SEC2TXT(SEC_I_INCOMPLETE_CREDENTIALS);
-    SEC2TXT(SEC_I_LOCAL_LOGON);
-    SEC2TXT(SEC_I_NO_LSA_CONTEXT);
-    SEC2TXT(SEC_I_RENEGOTIATE);
-    SEC2TXT(SEC_I_SIGNATURE_NEEDED);
-    default:
-      txt = "Unknown error";
+  SEC2TXT(CRYPT_E_REVOKED);
+  SEC2TXT(CRYPT_E_NO_REVOCATION_DLL);
+  SEC2TXT(CRYPT_E_NO_REVOCATION_CHECK);
+  SEC2TXT(CRYPT_E_REVOCATION_OFFLINE);
+  SEC2TXT(CRYPT_E_NOT_IN_REVOCATION_DATABASE);
+  SEC2TXT(SEC_E_ALGORITHM_MISMATCH);
+  SEC2TXT(SEC_E_BAD_BINDINGS);
+  SEC2TXT(SEC_E_BAD_PKGID);
+  SEC2TXT(SEC_E_BUFFER_TOO_SMALL);
+  SEC2TXT(SEC_E_CANNOT_INSTALL);
+  SEC2TXT(SEC_E_CANNOT_PACK);
+  SEC2TXT(SEC_E_CERT_EXPIRED);
+  SEC2TXT(SEC_E_CERT_UNKNOWN);
+  SEC2TXT(SEC_E_CERT_WRONG_USAGE);
+  SEC2TXT(SEC_E_CONTEXT_EXPIRED);
+  SEC2TXT(SEC_E_CROSSREALM_DELEGATION_FAILURE);
+  SEC2TXT(SEC_E_CRYPTO_SYSTEM_INVALID);
+  SEC2TXT(SEC_E_DECRYPT_FAILURE);
+  SEC2TXT(SEC_E_DELEGATION_POLICY);
+  SEC2TXT(SEC_E_DELEGATION_REQUIRED);
+  SEC2TXT(SEC_E_DOWNGRADE_DETECTED);
+  SEC2TXT(SEC_E_ENCRYPT_FAILURE);
+  SEC2TXT(SEC_E_ILLEGAL_MESSAGE);
+  SEC2TXT(SEC_E_INCOMPLETE_CREDENTIALS);
+  SEC2TXT(SEC_E_INCOMPLETE_MESSAGE);
+  SEC2TXT(SEC_E_INSUFFICIENT_MEMORY);
+  SEC2TXT(SEC_E_INTERNAL_ERROR);
+  SEC2TXT(SEC_E_INVALID_HANDLE);
+  SEC2TXT(SEC_E_INVALID_PARAMETER);
+  SEC2TXT(SEC_E_INVALID_TOKEN);
+  SEC2TXT(SEC_E_ISSUING_CA_UNTRUSTED);
+  SEC2TXT(SEC_E_ISSUING_CA_UNTRUSTED_KDC);
+  SEC2TXT(SEC_E_KDC_CERT_EXPIRED);
+  SEC2TXT(SEC_E_KDC_CERT_REVOKED);
+  SEC2TXT(SEC_E_KDC_INVALID_REQUEST);
+  SEC2TXT(SEC_E_KDC_UNABLE_TO_REFER);
+  SEC2TXT(SEC_E_KDC_UNKNOWN_ETYPE);
+  SEC2TXT(SEC_E_LOGON_DENIED);
+  SEC2TXT(SEC_E_MAX_REFERRALS_EXCEEDED);
+  SEC2TXT(SEC_E_MESSAGE_ALTERED);
+  SEC2TXT(SEC_E_MULTIPLE_ACCOUNTS);
+  SEC2TXT(SEC_E_MUST_BE_KDC);
+  SEC2TXT(SEC_E_NOT_OWNER);
+  SEC2TXT(SEC_E_NO_AUTHENTICATING_AUTHORITY);
+  SEC2TXT(SEC_E_NO_CREDENTIALS);
+  SEC2TXT(SEC_E_NO_IMPERSONATION);
+  SEC2TXT(SEC_E_NO_IP_ADDRESSES);
+  SEC2TXT(SEC_E_NO_KERB_KEY);
+  SEC2TXT(SEC_E_NO_PA_DATA);
+  SEC2TXT(SEC_E_NO_S4U_PROT_SUPPORT);
+  SEC2TXT(SEC_E_NO_TGT_REPLY);
+  SEC2TXT(SEC_E_OUT_OF_SEQUENCE);
+  SEC2TXT(SEC_E_PKINIT_CLIENT_FAILURE);
+  SEC2TXT(SEC_E_PKINIT_NAME_MISMATCH);
+  SEC2TXT(SEC_E_POLICY_NLTM_ONLY);
+  SEC2TXT(SEC_E_QOP_NOT_SUPPORTED);
+  SEC2TXT(SEC_E_REVOCATION_OFFLINE_C);
+  SEC2TXT(SEC_E_REVOCATION_OFFLINE_KDC);
+  SEC2TXT(SEC_E_SECPKG_NOT_FOUND);
+  SEC2TXT(SEC_E_SECURITY_QOS_FAILED);
+  SEC2TXT(SEC_E_SHUTDOWN_IN_PROGRESS);
+  SEC2TXT(SEC_E_SMARTCARD_CERT_EXPIRED);
+  SEC2TXT(SEC_E_SMARTCARD_CERT_REVOKED);
+  SEC2TXT(SEC_E_SMARTCARD_LOGON_REQUIRED);
+  SEC2TXT(SEC_E_STRONG_CRYPTO_NOT_SUPPORTED);
+  SEC2TXT(SEC_E_TARGET_UNKNOWN);
+  SEC2TXT(SEC_E_TIME_SKEW);
+  SEC2TXT(SEC_E_TOO_MANY_PRINCIPALS);
+  SEC2TXT(SEC_E_UNFINISHED_CONTEXT_DELETED);
+  SEC2TXT(SEC_E_UNKNOWN_CREDENTIALS);
+  SEC2TXT(SEC_E_UNSUPPORTED_FUNCTION);
+  SEC2TXT(SEC_E_UNSUPPORTED_PREAUTH);
+  SEC2TXT(SEC_E_UNTRUSTED_ROOT);
+  SEC2TXT(SEC_E_WRONG_CREDENTIAL_HANDLE);
+  SEC2TXT(SEC_E_WRONG_PRINCIPAL);
+  SEC2TXT(SEC_I_COMPLETE_AND_CONTINUE);
+  SEC2TXT(SEC_I_COMPLETE_NEEDED);
+  SEC2TXT(SEC_I_CONTEXT_EXPIRED);
+  SEC2TXT(SEC_I_CONTINUE_NEEDED);
+  SEC2TXT(SEC_I_INCOMPLETE_CREDENTIALS);
+  SEC2TXT(SEC_I_LOCAL_LOGON);
+  SEC2TXT(SEC_I_NO_LSA_CONTEXT);
+  SEC2TXT(SEC_I_RENEGOTIATE);
+  SEC2TXT(SEC_I_SIGNATURE_NEEDED);
+  default:
+    txt = "Unknown error";
   }
 
   if(err == SEC_E_ILLEGAL_MESSAGE) {
index f8a6cbfcccd6edd00a7f4ca7ee758b402a185e46..42db33a3edfa19e1ec81ad54ddda0f5288d2b0a7 100644 (file)
@@ -70,7 +70,7 @@ CURLcode Curl_win32_init(long flags)
     /* highest supported version. */
 
     if(LOBYTE(wsaData.wVersion) != LOBYTE(wVersionRequested) ||
-       HIBYTE(wsaData.wVersion) != HIBYTE(wVersionRequested) ) {
+       HIBYTE(wsaData.wVersion) != HIBYTE(wVersionRequested)) {
       /* Tell the user that we could not find a usable */
 
       /* winsock.dll. */
index 5319130b90f37174cd48a07a22ce78080895f95e..3153a392f67908f007d48b24187bb3a74a32013c 100644 (file)
 
 #define SUBBUFSIZE 512
 
-#define CURL_SB_CLEAR(x)  x->subpointer = x->subbuffer
-#define CURL_SB_TERM(x)                                 \
-  do {                                                  \
-    x->subend = x->subpointer;                          \
-    CURL_SB_CLEAR(x);                                   \
+#define CURL_SB_CLEAR(x) x->subpointer = x->subbuffer
+#define CURL_SB_TERM(x)        \
+  do {                         \
+    x->subend = x->subpointer; \
+    CURL_SB_CLEAR(x);          \
   } while(0)
-#define CURL_SB_ACCUM(x,c)                                      \
-  do {                                                          \
-    if(x->subpointer < (x->subbuffer + sizeof(x->subbuffer)))   \
-      *x->subpointer++ = (c);                                   \
+#define CURL_SB_ACCUM(x, c)                                   \
+  do {                                                        \
+    if(x->subpointer < (x->subbuffer + sizeof(x->subbuffer))) \
+      *x->subpointer++ = (c);                                 \
   } while(0)
 
-#define  CURL_SB_GET(x) ((*x->subpointer++)&0xff)
-#define  CURL_SB_LEN(x) (x->subend - x->subpointer)
+#define CURL_SB_GET(x) ((*x->subpointer++) & 0xff)
+#define CURL_SB_LEN(x) (x->subend - x->subpointer)
 
 /* For posterity:
 #define  CURL_SB_PEEK(x) ((*x->subpointer)&0xff)
 #define  CURL_SB_EOF(x) (x->subpointer >= x->subend) */
 
 #ifdef CURL_DISABLE_VERBOSE_STRINGS
-#define printoption(a,b,c,d)  Curl_nop_stmt
+#define printoption(a, b, c, d) Curl_nop_stmt
 #endif
 
 /* For negotiation compliant to RFC 1143 */
 /*
  * Telnet receiver states for fsm
  */
-typedef enum
-{
+typedef enum {
   CURL_TS_DATA = 0,
   CURL_TS_IAC,
   CURL_TS_WILL,
@@ -137,12 +136,12 @@ struct TELNET {
   unsigned char *subpointer, *subend;      /* buffer for sub-options */
 };
 
-
-static
-CURLcode telrcv(struct Curl_easy *data,
-                struct TELNET *tn,
-                const unsigned char *inbuf, /* Data received from socket */
-                ssize_t count);             /* Number of bytes received */
+static CURLcode telrcv(struct Curl_easy *data,
+                       struct TELNET *tn,
+                       const unsigned char *inbuf, /* Data received from
+                                                      socket */
+                       ssize_t count);             /* Number of bytes
+                                                      received */
 
 #ifndef CURL_DISABLE_VERBOSE_STRINGS
 static void printoption(struct Curl_easy *data,
@@ -199,7 +198,6 @@ const struct Curl_handler Curl_handler_telnet = {
   PROTOPT_NONE | PROTOPT_NOURLQUERY     /* flags */
 };
 
-
 static void telnet_easy_dtor(void *key, size_t klen, void *entry)
 {
   struct TELNET *tn = entry;
@@ -210,8 +208,7 @@ static void telnet_easy_dtor(void *key, size_t klen, void *entry)
   curlx_free(tn);
 }
 
-static
-CURLcode init_telnet(struct Curl_easy *data)
+static CURLcode init_telnet(struct Curl_easy *data)
 {
   struct TELNET *tn;
 
@@ -328,15 +325,14 @@ static void send_negotiation(struct Curl_easy *data, int cmd, int option)
   bytes_written = swrite(conn->sock[FIRSTSOCKET], buf, 3);
   if(bytes_written < 0) {
     int err = SOCKERRNO;
-    failf(data,"Sending data failed (%d)",err);
+    failf(data, "Sending data failed (%d)", err);
   }
 
   printoption(data, "SENT", cmd, option);
 }
 
-static
-void set_remote_option(struct Curl_easy *data, struct TELNET *tn,
-                       int option, int newstate)
+static void set_remote_option(struct Curl_easy *data, struct TELNET *tn,
+                              int option, int newstate)
 {
   if(newstate == CURL_YES) {
     switch(tn->him[option]) {
@@ -408,8 +404,7 @@ void set_remote_option(struct Curl_easy *data, struct TELNET *tn,
   }
 }
 
-static
-void rec_will(struct Curl_easy *data, struct TELNET *tn, int option)
+static void rec_will(struct Curl_easy *data, struct TELNET *tn, int option)
 {
   switch(tn->him[option]) {
   case CURL_NO:
@@ -455,8 +450,7 @@ void rec_will(struct Curl_easy *data, struct TELNET *tn, int option)
   }
 }
 
-static
-void rec_wont(struct Curl_easy *data, struct TELNET *tn, int option)
+static void rec_wont(struct Curl_easy *data, struct TELNET *tn, int option)
 {
   switch(tn->him[option]) {
   case CURL_NO:
@@ -496,9 +490,8 @@ void rec_wont(struct Curl_easy *data, struct TELNET *tn, int option)
   }
 }
 
-static void
-set_local_option(struct Curl_easy *data, struct TELNET *tn,
-                 int option, int newstate)
+static void set_local_option(struct Curl_easy *data, struct TELNET *tn,
+                             int option, int newstate)
 {
   if(newstate == CURL_YES) {
     switch(tn->us[option]) {
@@ -570,8 +563,7 @@ set_local_option(struct Curl_easy *data, struct TELNET *tn,
   }
 }
 
-static
-void rec_do(struct Curl_easy *data, struct TELNET *tn, int option)
+static void rec_do(struct Curl_easy *data, struct TELNET *tn, int option)
 {
   switch(tn->us[option]) {
   case CURL_NO:
@@ -629,8 +621,7 @@ void rec_do(struct Curl_easy *data, struct TELNET *tn, int option)
   }
 }
 
-static
-void rec_dont(struct Curl_easy *data, struct TELNET *tn, int option)
+static void rec_dont(struct Curl_easy *data, struct TELNET *tn, int option)
 {
   switch(tn->us[option]) {
   case CURL_NO:
@@ -670,7 +661,6 @@ void rec_dont(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 */
@@ -683,8 +673,8 @@ static void printsub(struct Curl_easy *data,
       if(length >= 3) {
         int j;
 
-        i = pointer[length-2];
-        j = pointer[length-1];
+        i = pointer[length - 2];
+        j = pointer[length - 1];
 
         if(i != CURL_IAC || j != CURL_SE) {
           infof(data, "(terminated by ");
@@ -950,77 +940,77 @@ static CURLcode suboption(struct Curl_easy *data, struct TELNET *tn)
 
   printsub(data, '<', (unsigned char *)tn->subbuffer, CURL_SB_LEN(tn) + 2);
   switch(CURL_SB_GET(tn)) {
-    case CURL_TELOPT_TTYPE:
-      if(bad_option(tn->subopt_ttype))
-        return CURLE_BAD_FUNCTION_ARGUMENT;
-      if(strlen(tn->subopt_ttype) > 1000) {
-        failf(data, "Tool long telnet TTYPE");
-        return CURLE_SEND_ERROR;
-      }
-      len = curl_msnprintf((char *)temp, sizeof(temp), "%c%c%c%c%s%c%c",
-                           CURL_IAC, CURL_SB, CURL_TELOPT_TTYPE,
-                           CURL_TELQUAL_IS, tn->subopt_ttype, CURL_IAC,
-                           CURL_SE);
-      bytes_written = swrite(conn->sock[FIRSTSOCKET], temp, len);
+  case CURL_TELOPT_TTYPE:
+    if(bad_option(tn->subopt_ttype))
+      return CURLE_BAD_FUNCTION_ARGUMENT;
+    if(strlen(tn->subopt_ttype) > 1000) {
+      failf(data, "Tool long telnet TTYPE");
+      return CURLE_SEND_ERROR;
+    }
+    len = curl_msnprintf((char *)temp, sizeof(temp), "%c%c%c%c%s%c%c",
+                         CURL_IAC, CURL_SB, CURL_TELOPT_TTYPE,
+                         CURL_TELQUAL_IS, tn->subopt_ttype, CURL_IAC,
+                         CURL_SE);
+    bytes_written = swrite(conn->sock[FIRSTSOCKET], temp, len);
 
-      if(bytes_written < 0) {
-        err = SOCKERRNO;
-        failf(data, "Sending data failed (%d)", err);
-        return CURLE_SEND_ERROR;
-      }
-      printsub(data, '>', &temp[2], len-2);
-      break;
-    case CURL_TELOPT_XDISPLOC:
-      if(bad_option(tn->subopt_xdisploc))
+    if(bytes_written < 0) {
+      err = SOCKERRNO;
+      failf(data, "Sending data failed (%d)", err);
+      return CURLE_SEND_ERROR;
+    }
+    printsub(data, '>', &temp[2], len-2);
+    break;
+  case CURL_TELOPT_XDISPLOC:
+    if(bad_option(tn->subopt_xdisploc))
+      return CURLE_BAD_FUNCTION_ARGUMENT;
+    if(strlen(tn->subopt_xdisploc) > 1000) {
+      failf(data, "Tool long telnet XDISPLOC");
+      return CURLE_SEND_ERROR;
+    }
+    len = curl_msnprintf((char *)temp, sizeof(temp), "%c%c%c%c%s%c%c",
+                         CURL_IAC, CURL_SB, CURL_TELOPT_XDISPLOC,
+                         CURL_TELQUAL_IS, tn->subopt_xdisploc, CURL_IAC,
+                         CURL_SE);
+    bytes_written = swrite(conn->sock[FIRSTSOCKET], temp, len);
+    if(bytes_written < 0) {
+      err = SOCKERRNO;
+      failf(data, "Sending data failed (%d)", err);
+      return CURLE_SEND_ERROR;
+    }
+    printsub(data, '>', &temp[2], len - 2);
+    break;
+  case CURL_TELOPT_NEW_ENVIRON:
+    len = curl_msnprintf((char *)temp, sizeof(temp), "%c%c%c%c",
+                         CURL_IAC, CURL_SB, CURL_TELOPT_NEW_ENVIRON,
+                         CURL_TELQUAL_IS);
+    for(v = tn->telnet_vars; v; v = v->next) {
+      size_t tmplen = (strlen(v->data) + 1);
+      if(bad_option(v->data))
         return CURLE_BAD_FUNCTION_ARGUMENT;
-      if(strlen(tn->subopt_xdisploc) > 1000) {
-        failf(data, "Tool long telnet XDISPLOC");
-        return CURLE_SEND_ERROR;
-      }
-      len = curl_msnprintf((char *)temp, sizeof(temp), "%c%c%c%c%s%c%c",
-                           CURL_IAC, CURL_SB, CURL_TELOPT_XDISPLOC,
-                           CURL_TELQUAL_IS, tn->subopt_xdisploc, CURL_IAC,
-                           CURL_SE);
-      bytes_written = swrite(conn->sock[FIRSTSOCKET], temp, len);
-      if(bytes_written < 0) {
-        err = SOCKERRNO;
-        failf(data,"Sending data failed (%d)",err);
-        return CURLE_SEND_ERROR;
-      }
-      printsub(data, '>', &temp[2], len-2);
-      break;
-    case CURL_TELOPT_NEW_ENVIRON:
-      len = curl_msnprintf((char *)temp, sizeof(temp), "%c%c%c%c",
-                           CURL_IAC, CURL_SB, CURL_TELOPT_NEW_ENVIRON,
-                           CURL_TELQUAL_IS);
-      for(v = tn->telnet_vars; v; v = v->next) {
-        size_t tmplen = (strlen(v->data) + 1);
-        if(bad_option(v->data))
-          return CURLE_BAD_FUNCTION_ARGUMENT;
-        /* Add the variable if it fits */
-        if(len + tmplen < (int)sizeof(temp)-6) {
-          char *s = strchr(v->data, ',');
-          if(!s)
-            len += curl_msnprintf((char *)&temp[len], sizeof(temp) - len,
-                                  "%c%s", CURL_NEW_ENV_VAR, v->data);
-          else {
-            size_t vlen = s - v->data;
-            len += curl_msnprintf((char *)&temp[len], sizeof(temp) - len,
-                                  "%c%.*s%c%s", CURL_NEW_ENV_VAR,
-                                  (int)vlen, v->data, CURL_NEW_ENV_VALUE, ++s);
-          }
+      /* Add the variable if it fits */
+      if(len + tmplen < (int)sizeof(temp) - 6) {
+        char *s = strchr(v->data, ',');
+        if(!s)
+          len += curl_msnprintf((char *)&temp[len], sizeof(temp) - len,
+                                "%c%s", CURL_NEW_ENV_VAR, v->data);
+        else {
+          size_t vlen = s - v->data;
+          len += curl_msnprintf((char *)&temp[len], sizeof(temp) - len,
+                                "%c%.*s%c%s", CURL_NEW_ENV_VAR,
+                                (int)vlen, v->data, CURL_NEW_ENV_VALUE, ++s);
         }
       }
-      curl_msnprintf((char *)&temp[len], sizeof(temp) - len,
-                     "%c%c", CURL_IAC, CURL_SE);
-      len += 2;
-      bytes_written = swrite(conn->sock[FIRSTSOCKET], temp, len);
-      if(bytes_written < 0) {
-        err = SOCKERRNO;
-        failf(data,"Sending data failed (%d)",err);
-      }
-      printsub(data, '>', &temp[2], len-2);
-      break;
+    }
+    curl_msnprintf((char *)&temp[len], sizeof(temp) - len,
+                   "%c%c", CURL_IAC, CURL_SE);
+    len += 2;
+    bytes_written = swrite(conn->sock[FIRSTSOCKET], temp, len);
+    if(bytes_written < 0) {
+      err = SOCKERRNO;
+      failf(data, "Sending data failed (%d)", err);
+    }
+    printsub(data, '>', &temp[2], len - 2);
+    break;
   }
   return CURLE_OK;
 }
@@ -1063,7 +1053,7 @@ static void sendsuboption(struct Curl_easy *data,
     /* data suboption is now ready */
 
     printsub(data, '>', (unsigned char *)tn->subbuffer + 2,
-             CURL_SB_LEN(tn)-2);
+             CURL_SB_LEN(tn) - 2);
 
     /* we send the header of the suboption... */
     bytes_written = swrite(conn->sock[FIRSTSOCKET], tn->subbuffer, 3);
@@ -1084,11 +1074,12 @@ static void sendsuboption(struct Curl_easy *data,
   }
 }
 
-static
-CURLcode telrcv(struct Curl_easy *data,
-                struct TELNET *tn,
-                const unsigned char *inbuf, /* Data received from socket */
-                ssize_t count)              /* Number of bytes received */
+static CURLcode telrcv(struct Curl_easy *data,
+                       struct TELNET *tn,
+                       const unsigned char *inbuf, /* Data received from
+                                                      socket */
+                       ssize_t count)              /* Number of bytes
+                                                      received */
 {
   unsigned char c;
   CURLcode result;
@@ -1106,9 +1097,9 @@ CURLcode telrcv(struct Curl_easy *data,
   }                                                              \
   startwrite = -1
 
-#define writebyte() \
-    if(startwrite < 0) \
-      startwrite = in
+#define writebyte()  \
+  if(startwrite < 0) \
+    startwrite = in
 
 #define bufferflush() startskipping()
 
@@ -1170,79 +1161,79 @@ process_iac:
       }
       break;
 
-      case CURL_TS_WILL:
-        printoption(data, "RCVD", CURL_WILL, c);
-        tn->please_negotiate = 1;
-        rec_will(data, tn, c);
-        tn->telrcv_state = CURL_TS_DATA;
-        break;
+    case CURL_TS_WILL:
+      printoption(data, "RCVD", CURL_WILL, c);
+      tn->please_negotiate = 1;
+      rec_will(data, tn, c);
+      tn->telrcv_state = CURL_TS_DATA;
+      break;
 
-      case CURL_TS_WONT:
-        printoption(data, "RCVD", CURL_WONT, c);
-        tn->please_negotiate = 1;
-        rec_wont(data, tn, c);
-        tn->telrcv_state = CURL_TS_DATA;
-        break;
+    case CURL_TS_WONT:
+      printoption(data, "RCVD", CURL_WONT, c);
+      tn->please_negotiate = 1;
+      rec_wont(data, tn, c);
+      tn->telrcv_state = CURL_TS_DATA;
+      break;
 
-      case CURL_TS_DO:
-        printoption(data, "RCVD", CURL_DO, c);
-        tn->please_negotiate = 1;
-        rec_do(data, tn, c);
-        tn->telrcv_state = CURL_TS_DATA;
-        break;
+    case CURL_TS_DO:
+      printoption(data, "RCVD", CURL_DO, c);
+      tn->please_negotiate = 1;
+      rec_do(data, tn, c);
+      tn->telrcv_state = CURL_TS_DATA;
+      break;
 
-      case CURL_TS_DONT:
-        printoption(data, "RCVD", CURL_DONT, c);
-        tn->please_negotiate = 1;
-        rec_dont(data, tn, c);
-        tn->telrcv_state = CURL_TS_DATA;
-        break;
+    case CURL_TS_DONT:
+      printoption(data, "RCVD", CURL_DONT, c);
+      tn->please_negotiate = 1;
+      rec_dont(data, tn, c);
+      tn->telrcv_state = CURL_TS_DATA;
+      break;
 
-      case CURL_TS_SB:
-        if(c == CURL_IAC)
-          tn->telrcv_state = CURL_TS_SE;
-        else
-          CURL_SB_ACCUM(tn, c);
-        break;
+    case CURL_TS_SB:
+      if(c == CURL_IAC)
+        tn->telrcv_state = CURL_TS_SE;
+      else
+        CURL_SB_ACCUM(tn, c);
+      break;
 
-      case CURL_TS_SE:
-        if(c != CURL_SE) {
-          if(c != CURL_IAC) {
-            /*
-             * This is an error. We only expect to get "IAC IAC" or "IAC SE".
-             * Several things may have happened. An IAC was not doubled, the
-             * IAC SE was left off, or another option got inserted into the
-             * suboption are all possibilities. If we assume that the IAC was
-             * not doubled, and really the IAC SE was left off, we could get
-             * into an infinite loop here. So, instead, we terminate the
-             * suboption, and process the partial suboption if we can.
-             */
-            CURL_SB_ACCUM(tn, CURL_IAC);
-            CURL_SB_ACCUM(tn, c);
-            tn->subpointer -= 2;
-            CURL_SB_TERM(tn);
-
-            printoption(data, "In SUBOPTION processing, RCVD", CURL_IAC, c);
-            result = suboption(data, tn);   /* handle sub-option */
-            if(result)
-              return result;
-            tn->telrcv_state = CURL_TS_IAC;
-            goto process_iac;
-          }
-          CURL_SB_ACCUM(tn, c);
-          tn->telrcv_state = CURL_TS_SB;
-        }
-        else {
+    case CURL_TS_SE:
+      if(c != CURL_SE) {
+        if(c != CURL_IAC) {
+          /*
+           * This is an error. We only expect to get "IAC IAC" or "IAC SE".
+           * Several things may have happened. An IAC was not doubled, the
+           * IAC SE was left off, or another option got inserted into the
+           * suboption are all possibilities. If we assume that the IAC was
+           * not doubled, and really the IAC SE was left off, we could get
+           * into an infinite loop here. So, instead, we terminate the
+           * suboption, and process the partial suboption if we can.
+           */
           CURL_SB_ACCUM(tn, CURL_IAC);
-          CURL_SB_ACCUM(tn, CURL_SE);
+          CURL_SB_ACCUM(tn, c);
           tn->subpointer -= 2;
           CURL_SB_TERM(tn);
+
+          printoption(data, "In SUBOPTION processing, RCVD", CURL_IAC, c);
           result = suboption(data, tn);   /* handle sub-option */
           if(result)
             return result;
-          tn->telrcv_state = CURL_TS_DATA;
+          tn->telrcv_state = CURL_TS_IAC;
+          goto process_iac;
         }
-        break;
+        CURL_SB_ACCUM(tn, c);
+        tn->telrcv_state = CURL_TS_SB;
+      }
+      else {
+        CURL_SB_ACCUM(tn, CURL_IAC);
+        CURL_SB_ACCUM(tn, CURL_SE);
+        tn->subpointer -= 2;
+        CURL_SB_TERM(tn);
+        result = suboption(data, tn);   /* handle sub-option */
+        if(result)
+          return result;
+        tn->telrcv_state = CURL_TS_DATA;
+      }
+      break;
     }
     ++in;
   }
@@ -1291,16 +1282,16 @@ static CURLcode send_telnet_data(struct Curl_easy *data,
     pfd[0].fd = conn->sock[FIRSTSOCKET];
     pfd[0].events = POLLOUT;
     switch(Curl_poll(pfd, 1, -1)) {
-      case -1:                    /* error, abort writing */
-      case 0:                     /* timeout (will never happen) */
-        result = CURLE_SEND_ERROR;
-        break;
-      default:                    /* write! */
-        bytes_written = 0;
-        result = Curl_xfer_send(data, outbuf + total_written,
-                                outlen - total_written, FALSE, &bytes_written);
-        total_written += bytes_written;
-        break;
+    case -1:                    /* error, abort writing */
+    case 0:                     /* timeout (will never happen) */
+      result = CURLE_SEND_ERROR;
+      break;
+    default:                    /* write! */
+      bytes_written = 0;
+      result = Curl_xfer_send(data, outbuf + total_written,
+                              outlen - total_written, FALSE, &bytes_written);
+      total_written += bytes_written;
+      break;
     }
   }
 
@@ -1326,8 +1317,8 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done)
   WSANETWORKEVENTS events;
   HANDLE stdin_handle;
   HANDLE objs[2];
-  DWORD  obj_count;
-  DWORD  wait_timeout;
+  DWORD obj_count;
+  DWORD wait_timeout;
   DWORD readfile_read;
   int err;
 #else
@@ -1340,7 +1331,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done)
 #endif
   struct curltime now;
   bool keepon = TRUE;
-  char buffer[4*1024];
+  char buffer[4 * 1024];
   struct TELNET *tn;
 
   *done = TRUE; /* unconditionally */
@@ -1371,7 +1362,8 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done)
   }
 
   /* Tell Winsock what events we want to listen to */
-  if(WSAEventSelect(sockfd, event_handle, FD_READ|FD_CLOSE) == SOCKET_ERROR) {
+  if(WSAEventSelect(sockfd, event_handle, FD_READ | FD_CLOSE) ==
+     SOCKET_ERROR) {
     WSACloseEvent(event_handle);
     return CURLE_RECV_ERROR;
   }
@@ -1385,8 +1377,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done)
 
   /* If stdin_handle is a pipe, use PeekNamedPipe() method to check it,
      else use the old WaitForMultipleObjects() way */
-  if(GetFileType(stdin_handle) == FILE_TYPE_PIPE ||
-     data->set.is_fread_set) {
+  if(GetFileType(stdin_handle) == FILE_TYPE_PIPE || data->set.is_fread_set) {
     /* Do not wait for stdin_handle, just wait for event_handle */
     obj_count = 1;
     /* Check stdin_handle per 100 milliseconds */
@@ -1404,8 +1395,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done)
                                            FALSE, wait_timeout);
     switch(waitret) {
 
-    case WAIT_TIMEOUT:
-    {
+    case WAIT_TIMEOUT: {
       for(;;) {
         if(data->set.is_fread_set) {
           size_t n;
@@ -1438,8 +1428,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done)
           if(!readfile_read)
             break;
 
-          if(!ReadFile(stdin_handle, buffer, buf_size,
-                       &readfile_read, NULL)) {
+          if(!ReadFile(stdin_handle, buffer, buf_size, &readfile_read, NULL)) {
             keepon = FALSE;
             result = CURLE_READ_ERROR;
             break;
@@ -1455,10 +1444,8 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done)
     }
     break;
 
-    case WAIT_OBJECT_0 + 1:
-    {
-      if(!ReadFile(stdin_handle, buffer, buf_size,
-                   &readfile_read, NULL)) {
+    case WAIT_OBJECT_0 + 1: {
+      if(!ReadFile(stdin_handle, buffer, buf_size, &readfile_read, NULL)) {
         keepon = FALSE;
         result = CURLE_READ_ERROR;
         break;
@@ -1472,8 +1459,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done)
     }
     break;
 
-    case WAIT_OBJECT_0:
-    {
+    case WAIT_OBJECT_0: {
       events.lNetworkEvents = 0;
       if(WSAEnumNetworkEvents(sockfd, event_handle, &events) == SOCKET_ERROR) {
         err = SOCKERRNO;
@@ -1503,7 +1489,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done)
           break;
         }
 
-        result = telrcv(data, tn, (unsigned char *) buffer, nread);
+        result = telrcv(data, tn, (unsigned char *)buffer, nread);
         if(result) {
           keepon = FALSE;
           break;
@@ -1520,10 +1506,9 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done)
       if(events.lNetworkEvents & FD_CLOSE) {
         keepon = FALSE;
       }
+      break;
     }
-    break;
-
-    }
+    } /* switch */
 
     if(data->set.timeout) {
       now = curlx_now();
@@ -1622,7 +1607,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done)
       else {
         /* read from user-supplied method */
         snread = (int)data->state.fread_func(buffer, 1, sizeof(buffer),
-                                            data->state.in);
+                                             data->state.in);
         if(snread == CURL_READFUNC_ABORT) {
           keepon = FALSE;
           break;
index 5311a4c683a253e190c5caaa165ca361de8dcee1..58e9696fb2c20e74b8d3e0b55018546b97501f6e 100644 (file)
@@ -66,7 +66,7 @@
 
 /* RFC2348 allows the block size to be negotiated */
 #define TFTP_BLKSIZE_DEFAULT 512
-#define TFTP_OPTION_BLKSIZE "blksize"
+#define TFTP_OPTION_BLKSIZE  "blksize"
 
 /* from RFC2349: */
 #define TFTP_OPTION_TSIZE    "tsize"
@@ -159,7 +159,6 @@ static CURLcode tftp_pollset(struct Curl_easy *data,
                              struct easy_pollset *ps);
 static CURLcode tftp_translate_code(tftp_error_t error);
 
-
 /*
  * TFTP protocol handler.
  */
@@ -221,7 +220,7 @@ static CURLcode tftp_set_timeouts(struct tftp_conn *state)
     timeout = 15;
 
   /* Average reposting an ACK after 5 seconds */
-  state->retry_max = (int)timeout/5;
+  state->retry_max = (int)timeout / 5;
 
   /* But bound the total number */
   if(state->retry_max < 3)
@@ -231,7 +230,7 @@ static CURLcode tftp_set_timeouts(struct tftp_conn *state)
     state->retry_max = 50;
 
   /* Compute the re-ACK interval to suit the timeout */
-  state->retry_time = (int)(timeout/state->retry_max);
+  state->retry_time = (int)(timeout / state->retry_max);
   if(state->retry_time < 1)
     state->retry_time = 1;
 
@@ -259,7 +258,6 @@ static void setpacketevent(struct tftp_packet *packet, unsigned short num)
   packet->data[1] = (unsigned char)(num & 0xff);
 }
 
-
 static void setpacketblock(struct tftp_packet *packet, unsigned short num)
 {
   packet->data[2] = (unsigned char)(num >> 8);
@@ -279,7 +277,7 @@ static unsigned short getrpacketblock(const struct tftp_packet *packet)
 static size_t tftp_strnlen(const char *string, size_t maxlen)
 {
   const char *end = memchr(string, '\0', maxlen);
-  return end ? (size_t) (end - string) : maxlen;
+  return end ? (size_t)(end - string) : maxlen;
 }
 
 static const char *tftp_option_get(const char *buf, size_t len,
@@ -294,7 +292,7 @@ static const char *tftp_option_get(const char *buf, size_t len,
     return NULL;
   *option = buf;
 
-  loc += tftp_strnlen(buf + loc, len-loc);
+  loc += tftp_strnlen(buf + loc, len - loc);
   loc++; /* NULL term */
 
   if(loc > len)
@@ -570,7 +568,7 @@ static CURLcode tftp_send_first(struct tftp_conn *state,
 
 /* the next blocknum is x + 1 but it needs to wrap at an unsigned 16bit
    boundary */
-#define NEXT_BLOCKNUM(x) (((x) + 1)&0xffff)
+#define NEXT_BLOCKNUM(x) (((x) + 1) & 0xffff)
 
 /**********************************************************
  *
@@ -784,7 +782,7 @@ static CURLcode tftp_tx(struct tftp_conn *state, tftp_event_t event)
       bufptr += cb;
     } while(state->sbytes < state->blksize && cb);
 
-    sbytes = sendto(state->sockfd, (void *) state->spacket.data,
+    sbytes = sendto(state->sockfd, (void *)state->spacket.data,
                     4 + (SEND_TYPE_ARG3)state->sbytes, SEND_4TH_ARG,
                     (struct sockaddr *)&state->remote_addr,
                     state->remote_addrlen);
@@ -1136,15 +1134,14 @@ static CURLcode tftp_receive_packet(struct Curl_easy *data,
          (NEXT_BLOCKNUM(state->block) == getrpacketblock(&state->rpacket))) {
         result = Curl_client_write(data, CLIENTWRITE_BODY,
                                    (char *)state->rpacket.data + 4,
-                                   state->rbytes-4);
+                                   state->rbytes - 4);
         if(result) {
           tftp_state_machine(state, TFTP_EVENT_ERROR);
           return result;
         }
       }
       break;
-    case TFTP_EVENT_ERROR:
-    {
+    case TFTP_EVENT_ERROR: {
       unsigned short error = getrpacketblock(&state->rpacket);
       char *str = (char *)state->rpacket.data + 4;
       size_t strn = state->rbytes - 4;
@@ -1328,7 +1325,6 @@ static CURLcode tftp_perform(struct Curl_easy *data, bool *dophase_done)
   return result;
 }
 
-
 /**********************************************************
  *
  * tftp_do
index d8a0d6c0ba2efd585cd90ac8985b27955aafd3e2..a8a66f86c7b91f74e54940b0ccbe93073a97b19d 100644 (file)
@@ -82,7 +82,7 @@
 #include "curlx/warnless.h"
 
 #if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_SMTP) || \
-    !defined(CURL_DISABLE_IMAP)
+  !defined(CURL_DISABLE_IMAP)
 /*
  * checkheaders() checks the linked list of custom headers for a
  * particular header (prefix). Provide the prefix without colon!
@@ -95,11 +95,11 @@ char *Curl_checkheaders(const struct Curl_easy *data,
 {
   struct curl_slist *head;
   DEBUGASSERT(thislen);
-  DEBUGASSERT(thisheader[thislen-1] != ':');
+  DEBUGASSERT(thisheader[thislen - 1] != ':');
 
   for(head = data->set.headers; head; head = head->next) {
     if(curl_strnequal(head->data, thisheader, thislen) &&
-       Curl_headersep(head->data[thislen]) )
+       Curl_headersep(head->data[thislen]))
       return head->data;
   }
 
@@ -111,13 +111,13 @@ static int data_pending(struct Curl_easy *data, bool rcvd_eagain)
 {
   struct connectdata *conn = data->conn;
 
-  if(conn->handler->protocol&PROTO_FAMILY_FTP)
+  if(conn->handler->protocol & PROTO_FAMILY_FTP)
     return Curl_conn_data_pending(data, SECONDARYSOCKET);
 
   /* in the case of libssh2, we can never be really sure that we have emptied
      its internal buffers so we MUST always try until we get EAGAIN back */
   return (!rcvd_eagain &&
-          conn->handler->protocol&(CURLPROTO_SCP|CURLPROTO_SFTP)) ||
+          conn->handler->protocol & (CURLPROTO_SCP | CURLPROTO_SFTP)) ||
          Curl_conn_data_pending(data, FIRSTSOCKET);
 }
 
@@ -329,7 +329,7 @@ static CURLcode sendrecv_dl(struct Curl_easy *data,
     CURL_TRC_M(data, "sendrecv_dl() no EAGAIN/pending data, mark as dirty");
   }
 
-  if(((k->keepon & (KEEP_RECV|KEEP_SEND)) == KEEP_SEND) &&
+  if(((k->keepon & (KEEP_RECV | KEEP_SEND)) == KEEP_SEND) &&
      (conn->bits.close || is_multiplex)) {
     /* When we have read the entire thing and the close bit is set, the server
        may now close the connection. If there is now any kind of sending going
@@ -428,7 +428,7 @@ CURLcode Curl_sendrecv(struct Curl_easy *data, struct curltime *nowp)
   }
 
   /* If there is nothing more to send/recv, the request is done */
-  if((k->keepon & (KEEP_RECV|KEEP_SEND)) == 0)
+  if((k->keepon & (KEEP_RECV | KEEP_SEND)) == 0)
     data->req.done = TRUE;
 
   result = Curl_pgrsUpdate(data);
@@ -636,7 +636,7 @@ CURLcode Curl_retry_request(struct Curl_easy *data, char **url)
      protocol is HTTP as when uploading over HTTP we will still get a
      response */
   if(data->state.upload &&
-     !(conn->handler->protocol&(PROTO_FAMILY_HTTP|CURLPROTO_RTSP)))
+     !(conn->handler->protocol & (PROTO_FAMILY_HTTP | CURLPROTO_RTSP)))
     return CURLE_OK;
 
   if(conn->bits.reuse &&
@@ -656,7 +656,7 @@ CURLcode Curl_retry_request(struct Curl_easy *data, char **url)
        it again. Bad luck. Retry the same request on a fresh connect! */
     retry = TRUE;
   else if(data->state.refused_stream &&
-          (data->req.bytecount + data->req.headerbytecount == 0) ) {
+          (data->req.bytecount + data->req.headerbytecount == 0)) {
     /* This was sent on a refused stream, safe to rerun. A refused stream
        error can typically only happen on HTTP/2 level if the stream is safe
        to issue again, but the nghttp2 API can deliver the message to other
index b96629d979688bf2559aa0d998baaf299e02d876..3da5e2445139dc0ca2dfed5edccc017fade9470f 100644 (file)
@@ -24,7 +24,8 @@
  *
  ***************************************************************************/
 
-#define Curl_headersep(x) ((((x)==':') || ((x)==';')))
+#define Curl_headersep(x) ((((x) == ':') || ((x) == ';')))
+
 char *Curl_checkheaders(const struct Curl_easy *data,
                         const char *thisheader,
                         const size_t thislen);
index dcad94e42a6e7f0ab8a623fae1f00545b4c87b74..d41d982b3a23725591302dd5202e1e28b3792118 100644 (file)
@@ -37,10 +37,9 @@ void Curl_uint32_bset_init(struct uint32_bset *bset)
 #endif
 }
 
-
 CURLcode Curl_uint32_bset_resize(struct uint32_bset *bset, uint32_t nmax)
 {
-  uint32_t nslots = (nmax < (UINT32_MAX-63)) ?
+  uint32_t nslots = (nmax < (UINT32_MAX - 63)) ?
                     ((nmax + 63) / 64) : (UINT32_MAX / 64);
 
   DEBUGASSERT(bset->init == CURL_UINT32_BSET_MAGIC);
@@ -61,7 +60,6 @@ CURLcode Curl_uint32_bset_resize(struct uint32_bset *bset, uint32_t nmax)
   return CURLE_OK;
 }
 
-
 void Curl_uint32_bset_destroy(struct uint32_bset *bset)
 {
   DEBUGASSERT(bset->init == CURL_UINT32_BSET_MAGIC);
@@ -97,7 +95,6 @@ bool Curl_uint32_bset_empty(struct uint32_bset *bset)
   return TRUE;
 }
 
-
 void Curl_uint32_bset_clear(struct uint32_bset *bset)
 {
   if(bset->nslots) {
@@ -106,7 +103,6 @@ void Curl_uint32_bset_clear(struct uint32_bset *bset)
   }
 }
 
-
 bool Curl_uint32_bset_add(struct uint32_bset *bset, uint32_t i)
 {
   uint32_t islot = i / 64;
@@ -118,7 +114,6 @@ bool Curl_uint32_bset_add(struct uint32_bset *bset, uint32_t i)
   return TRUE;
 }
 
-
 void Curl_uint32_bset_remove(struct uint32_bset *bset, uint32_t i)
 {
   size_t islot = i / 64;
@@ -126,7 +121,6 @@ void Curl_uint32_bset_remove(struct uint32_bset *bset, uint32_t i)
     bset->slots[islot] &= ~((uint64_t)1 << (i % 64));
 }
 
-
 bool Curl_uint32_bset_contains(struct uint32_bset *bset, uint32_t i)
 {
   uint32_t islot = i / 64;
@@ -135,7 +129,6 @@ bool Curl_uint32_bset_contains(struct uint32_bset *bset, uint32_t i)
   return (bset->slots[islot] & ((uint64_t)1 << (i % 64))) != 0;
 }
 
-
 bool Curl_uint32_bset_first(struct uint32_bset *bset, uint32_t *pfirst)
 {
   uint32_t i;
@@ -198,7 +191,6 @@ uint32_t Curl_popcount64(uint64_t x)
 }
 #endif /* CURL_POPCOUNT64_IMPLEMENT */
 
-
 #ifdef CURL_CTZ64_IMPLEMENT
 uint32_t Curl_ctz64(uint64_t x)
 {
index 5e5bbdb8fc0b03053437a7aa9b7936fd5af9b92c..ff814bb5e6ad06bc2352d577a2ff4a79ae844264 100644 (file)
@@ -99,9 +99,8 @@ bool Curl_uint32_bset_first(struct uint32_bset *bset, uint32_t *pfirst);
 bool Curl_uint32_bset_next(struct uint32_bset *bset, uint32_t last,
                            uint32_t *pnext);
 
-
 #ifndef CURL_POPCOUNT64
-#define CURL_POPCOUNT64(x)   Curl_popcount64(x)
+#define CURL_POPCOUNT64(x)  Curl_popcount64(x)
 #define CURL_POPCOUNT64_IMPLEMENT
 uint32_t Curl_popcount64(uint64_t x);
 #endif /* !CURL_POPCOUNT64 */
index 166a9ab99ba5027d30732c7cc2c6cf9479c585f6..43de42a19c8bf6098ee9ea64cdfe71f9f525a6b1 100644 (file)
@@ -38,10 +38,9 @@ static uint32_t uint32_hash_hash(uint32_t id, uint32_t slots)
   return (id % slots);
 }
 
-
 struct uint_hash_entry {
   struct uint_hash_entry *next;
-  void   *value;
+  void *value;
   uint32_t id;
 };
 
@@ -111,8 +110,8 @@ static void uint32_hash_elem_link(struct uint_hash *h,
   ++h->size;
 }
 
-#define CURL_UINT32_HASH_SLOT(h,id) h->table[uint32_hash_hash(id, h->slots)]
-#define CURL_UINT32_HASH_SLOT_ADDR(h,id) &CURL_UINT32_HASH_SLOT(h,id)
+#define CURL_UINT32_HASH_SLOT(h, id) h->table[uint32_hash_hash(id, h->slots)]
+#define CURL_UINT32_HASH_SLOT_ADDR(h, id) &CURL_UINT32_HASH_SLOT(h, id)
 
 bool Curl_uint32_hash_set(struct uint_hash *h, uint32_t id, void *value)
 {
index 330f61208bfa1d10ad00d1dc631ae2cf7075d53a..3e09a6234821983b76a6c0f94851b46c2ac1b3f6 100644 (file)
@@ -45,7 +45,6 @@ struct uint_hash {
 #endif
 };
 
-
 void Curl_uint32_hash_init(struct uint_hash *h,
                            uint32_t slots,
                            Curl_uint32_hash_dtor *dtor);
@@ -57,7 +56,6 @@ bool Curl_uint32_hash_remove(struct uint_hash *h, uint32_t id);
 void *Curl_uint32_hash_get(struct uint_hash *h, uint32_t id);
 uint32_t Curl_uint32_hash_count(struct uint_hash *h);
 
-
 typedef bool Curl_uint32_hash_visit_cb(uint32_t id, void *value,
                                        void *user_data);
 
index c726bfb900c1d0de03edf191ecdbd16265018ed8..84a893e85f5abc076207545a9fc9289b9cc307ba 100644 (file)
@@ -86,7 +86,6 @@ UNITTEST void Curl_uint32_spbset_clear(struct uint32_spbset *bset)
   memset(&bset->head, 0, sizeof(bset->head));
 }
 
-
 static struct uint32_spbset_chunk *
 uint32_spbset_get_chunk(struct uint32_spbset *bset, uint32_t i, bool grow)
 {
@@ -129,7 +128,6 @@ uint32_spbset_get_chunk(struct uint32_spbset *bset, uint32_t i, bool grow)
   return chunk;
 }
 
-
 bool Curl_uint32_spbset_add(struct uint32_spbset *bset, uint32_t i)
 {
   struct uint32_spbset_chunk *chunk;
@@ -146,7 +144,6 @@ bool Curl_uint32_spbset_add(struct uint32_spbset *bset, uint32_t i)
   return TRUE;
 }
 
-
 void Curl_uint32_spbset_remove(struct uint32_spbset *bset, uint32_t i)
 {
   struct uint32_spbset_chunk *chunk;
@@ -161,7 +158,6 @@ void Curl_uint32_spbset_remove(struct uint32_spbset *bset, uint32_t i)
   }
 }
 
-
 bool Curl_uint32_spbset_contains(struct uint32_spbset *bset, uint32_t i)
 {
   struct uint32_spbset_chunk *chunk;
@@ -195,7 +191,6 @@ bool Curl_uint32_spbset_first(struct uint32_spbset *bset, uint32_t *pfirst)
   return FALSE;
 }
 
-
 static bool uint32_spbset_chunk_first(struct uint32_spbset_chunk *chunk,
                                       uint32_t *pfirst)
 {
@@ -210,7 +205,6 @@ static bool uint32_spbset_chunk_first(struct uint32_spbset_chunk *chunk,
   return FALSE;
 }
 
-
 static bool uint32_spbset_chunk_next(struct uint32_spbset_chunk *chunk,
                                      uint32_t last,
                                      uint32_t *pnext)
index 05b53766f30a55a2ab2b861b9f9f041e65bae7c7..b4d5d94a3a3600fb8faec28ad624d43ce66a4c1d 100644 (file)
@@ -43,7 +43,6 @@ void Curl_uint32_tbl_init(struct uint32_tbl *tbl,
 #endif
 }
 
-
 static void uint32_tbl_clear_rows(struct uint32_tbl *tbl,
                                   uint32_t from,
                                   uint32_t upto_excluding)
@@ -61,7 +60,6 @@ static void uint32_tbl_clear_rows(struct uint32_tbl *tbl,
   }
 }
 
-
 CURLcode Curl_uint32_tbl_resize(struct uint32_tbl *tbl, uint32_t nrows)
 {
   /* we use `tbl->nrows + 1` during iteration, want that to work */
@@ -84,7 +82,6 @@ CURLcode Curl_uint32_tbl_resize(struct uint32_tbl *tbl, uint32_t nrows)
   return CURLE_OK;
 }
 
-
 void Curl_uint32_tbl_destroy(struct uint32_tbl *tbl)
 {
   DEBUGASSERT(tbl->init == CURL_UINT32_TBL_MAGIC);
@@ -101,25 +98,21 @@ UNITTEST void Curl_uint32_tbl_clear(struct uint32_tbl *tbl)
   tbl->last_key_added = UINT32_MAX;
 }
 
-
 uint32_t Curl_uint32_tbl_capacity(struct uint32_tbl *tbl)
 {
   return tbl->nrows;
 }
 
-
 uint32_t Curl_uint32_tbl_count(struct uint32_tbl *tbl)
 {
   return tbl->nentries;
 }
 
-
 void *Curl_uint32_tbl_get(struct uint32_tbl *tbl, uint32_t key)
 {
   return (key < tbl->nrows) ? tbl->rows[key] : NULL;
 }
 
-
 bool Curl_uint32_tbl_add(struct uint32_tbl *tbl, void *entry, uint32_t *pkey)
 {
   uint32_t key, start_pos;
@@ -156,19 +149,16 @@ bool Curl_uint32_tbl_add(struct uint32_tbl *tbl, void *entry, uint32_t *pkey)
   return FALSE;
 }
 
-
 void Curl_uint32_tbl_remove(struct uint32_tbl *tbl, uint32_t key)
 {
   uint32_tbl_clear_rows(tbl, key, key + 1);
 }
 
-
 bool Curl_uint32_tbl_contains(struct uint32_tbl *tbl, uint32_t key)
 {
   return (key < tbl->nrows) ? !!tbl->rows[key] : FALSE;
 }
 
-
 static bool uint32_tbl_next_at(struct uint32_tbl *tbl, uint32_t key,
                                uint32_t *pkey, void **pentry)
 {
@@ -197,7 +187,6 @@ bool Curl_uint32_tbl_first(struct uint32_tbl *tbl,
   return FALSE;
 }
 
-
 bool Curl_uint32_tbl_next(struct uint32_tbl *tbl, uint32_t last_key,
                           uint32_t *pkey, void **pentry)
 {
index 84909f037238b9cfbe3f948547c264e04fba5ff7..f646b74ed4a7d86f5c6387b89d4e5d77b3cd5da4 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -148,16 +148,16 @@ static void data_priority_cleanup(struct Curl_easy *data);
 #define MAX_URL_LEN 0xffff
 
 /*
-* get_protocol_family()
-*
-* This is used to return the protocol family for a given protocol.
-*
-* Parameters:
-*
-* 'h'  [in]  - struct Curl_handler pointer.
-*
-* Returns the family as a single bit protocol identifier.
-*/
+ * get_protocol_family()
+ *
+ * This is used to return the protocol family for a given protocol.
+ *
+ * Parameters:
+ *
+ * 'h'  [in]  - struct Curl_handler pointer.
+ *
+ * Returns the family as a single bit protocol identifier.
+ */
 static curl_prot_t get_protocol_family(const struct Curl_handler *h)
 {
   DEBUGASSERT(h);
@@ -460,8 +460,7 @@ void Curl_init_userdefined(struct Curl_easy *data)
   set->conn_max_idle_ms = 118 * 1000;
   set->conn_max_age_ms = 24 * 3600 * 1000;
   set->http09_allowed = FALSE;
-  set->httpwant = CURL_HTTP_VERSION_NONE
-    ;
+  set->httpwant = CURL_HTTP_VERSION_NONE;
 #if defined(USE_HTTP2) || defined(USE_HTTP3)
   memset(&set->priority, 0, sizeof(set->priority));
 #endif
@@ -592,7 +591,7 @@ static bool xfer_may_multiplex(const struct Curl_easy *data,
      (!conn->bits.protoconnstart || !conn->bits.close)) {
 
     if(Curl_multiplex_wanted(data->multi) &&
-       (data->state.http_neg.allowed & (CURL_HTTP_V2x|CURL_HTTP_V3x)))
+       (data->state.http_neg.allowed & (CURL_HTTP_V2x | CURL_HTTP_V3x)))
       /* allows HTTP/2 or newer */
       return TRUE;
   }
@@ -604,9 +603,8 @@ static bool xfer_may_multiplex(const struct Curl_easy *data,
 }
 
 #ifndef CURL_DISABLE_PROXY
-static bool
-proxy_info_matches(const struct proxy_info *data,
-                   const struct proxy_info *needle)
+static bool proxy_info_matches(const struct proxy_info *data,
+                               const struct proxy_info *needle)
 {
   if((data->proxytype == needle->proxytype) &&
      (data->port == needle->port) &&
@@ -616,9 +614,8 @@ proxy_info_matches(const struct proxy_info *data,
   return FALSE;
 }
 
-static bool
-socks_proxy_info_matches(const struct proxy_info *data,
-                         const struct proxy_info *needle)
+static bool socks_proxy_info_matches(const struct proxy_info *data,
+                                     const struct proxy_info *needle)
 {
   if(!proxy_info_matches(data, needle))
     return FALSE;
@@ -636,8 +633,8 @@ socks_proxy_info_matches(const struct proxy_info *data,
 }
 #else
 /* disabled, will not get called */
-#define proxy_info_matches(x,y) FALSE
-#define socks_proxy_info_matches(x,y) FALSE
+#define proxy_info_matches(x, y)       FALSE
+#define socks_proxy_info_matches(x, y) FALSE
 #endif
 
 /* A connection has to have been idle for less than 'conn_max_idle_ms'
@@ -708,7 +705,6 @@ bool Curl_conn_seems_dead(struct connectdata *conn,
       dead = (state & CONNRESULT_DEAD);
       /* detach the connection again */
       Curl_detach_connection(data);
-
     }
     else {
       bool input_pending = FALSE;
@@ -803,8 +799,8 @@ static bool url_match_connect_config(struct connectdata *conn,
     return FALSE;
 
   /* ip_version must match */
-  if(m->data->set.ipver != CURL_IPRESOLVE_WHATEVER
-     && m->data->set.ipver != conn->ip_version)
+  if(m->data->set.ipver != CURL_IPRESOLVE_WHATEVER &&
+     m->data->set.ipver != conn->ip_version)
     return FALSE;
 
   if(m->needle->localdev || m->needle->localport) {
@@ -913,7 +909,7 @@ static bool url_match_multiplex_limits(struct connectdata *conn,
       return FALSE;
     }
     if(CONN_ATTACHED(conn) >=
-            Curl_conn_get_max_concurrent(m->data, conn, FIRSTSOCKET)) {
+       Curl_conn_get_max_concurrent(m->data, conn, FIRSTSOCKET)) {
       infof(m->data, "MAX_CONCURRENT_STREAMS reached, skip (%u)",
             CONN_ATTACHED(conn));
       return FALSE;
@@ -951,8 +947,7 @@ static bool url_match_proxy_use(struct connectdata *conn,
     return FALSE;
 
   if(m->needle->bits.socksproxy &&
-    !socks_proxy_info_matches(&m->needle->socks_proxy,
-                              &conn->socks_proxy))
+     !socks_proxy_info_matches(&m->needle->socks_proxy, &conn->socks_proxy))
     return FALSE;
 
   if(m->needle->bits.httpproxy) {
@@ -969,9 +964,9 @@ static bool url_match_proxy_use(struct connectdata *conn,
       /* match SSL config to proxy */
       if(!Curl_ssl_conn_config_match(m->data, conn, TRUE)) {
         DEBUGF(infof(m->data,
-          "Connection #%" FMT_OFF_T
-          " has different SSL proxy parameters, cannot reuse",
-          conn->connection_id));
+                     "Connection #%" FMT_OFF_T
+                     " has different SSL proxy parameters, cannot reuse",
+                     conn->connection_id));
         return FALSE;
       }
       /* the SSL config to the server, which may apply here is checked
@@ -981,7 +976,7 @@ static bool url_match_proxy_use(struct connectdata *conn,
   return TRUE;
 }
 #else
-#define url_match_proxy_use(c,m)    ((void)c, (void)m, TRUE)
+#define url_match_proxy_use(c, m) ((void)c, (void)m, TRUE)
 #endif
 
 #ifndef CURL_DISABLE_HTTP
@@ -989,7 +984,7 @@ static bool url_match_http_multiplex(struct connectdata *conn,
                                      struct url_conn_match *m)
 {
   if(m->may_multiplex &&
-     (m->data->state.http_neg.allowed & (CURL_HTTP_V2x|CURL_HTTP_V3x)) &&
+     (m->data->state.http_neg.allowed & (CURL_HTTP_V2x | CURL_HTTP_V3x)) &&
      (m->needle->handler->protocol & CURLPROTO_HTTP) &&
      !conn->httpversion_seen) {
     if(m->data->set.pipewait) {
@@ -1037,8 +1032,8 @@ static bool url_match_http_version(struct connectdata *conn,
   return TRUE;
 }
 #else
-#define url_match_http_multiplex(c,m)    ((void)c, (void)m, TRUE)
-#define url_match_http_version(c,m)      ((void)c, (void)m, TRUE)
+#define url_match_http_multiplex(c, m) ((void)c, (void)m, TRUE)
+#define url_match_http_version(c, m)   ((void)c, (void)m, TRUE)
 #endif
 
 static bool url_match_proto_config(struct connectdata *conn,
@@ -1091,7 +1086,7 @@ static bool url_match_destination(struct connectdata *conn,
 {
   /* Additional match requirements if talking TLS OR
    * not talking to an HTTP proxy OR using a tunnel through a proxy */
-  if((m->needle->handler->flags&PROTOPT_SSL)
+  if((m->needle->handler->flags & PROTOPT_SSL)
 #ifndef CURL_DISABLE_PROXY
      || !m->needle->bits.httpproxy || m->needle->bits.tunnel_proxy
 #endif
@@ -1116,7 +1111,7 @@ static bool url_match_destination(struct connectdata *conn,
     if((m->needle->bits.conn_to_host && !curl_strequal(
         m->needle->conn_to_host.name, conn->conn_to_host.name)) ||
        (m->needle->bits.conn_to_port &&
-         m->needle->conn_to_port != conn->conn_to_port))
+        m->needle->conn_to_port != conn->conn_to_port))
       return FALSE;
 
     /* hostname and port must match */
@@ -1207,7 +1202,7 @@ static bool url_match_auth_ntlm(struct connectdata *conn,
   return TRUE;
 }
 #else
-#define url_match_auth_ntlm(c,m)    ((void)c, (void)m, TRUE)
+#define url_match_auth_ntlm(c, m) ((void)c, (void)m, TRUE)
 #endif
 
 static bool url_match_conn(struct connectdata *conn, void *userdata)
@@ -1303,12 +1298,11 @@ static bool url_match_result(bool result, void *userdata)
  *
  * The force_reuse flag is set if the connection must be used.
  */
-static bool
-ConnectionExists(struct Curl_easy *data,
-                 struct connectdata *needle,
-                 struct connectdata **usethis,
-                 bool *force_reuse,
-                 bool *waitpipe)
+static bool ConnectionExists(struct Curl_easy *data,
+                             struct connectdata *needle,
+                             struct connectdata **usethis,
+                             bool *force_reuse,
+                             bool *waitpipe)
 {
   struct url_conn_match match;
   bool result;
@@ -1676,12 +1670,11 @@ static CURLcode findprotocol(struct Curl_easy *data,
      create_conn() function when the connectdata struct is allocated. */
   failf(data, "Protocol \"%s\" %s%s", protostr,
         p ? "disabled" : "not supported",
-        data->state.this_is_a_follow ? " (in redirect)":"");
+        data->state.this_is_a_follow ? " (in redirect)" : "");
 
   return CURLE_UNSUPPORTED_PROTOCOL;
 }
 
-
 CURLcode Curl_uc_to_curlcode(CURLUcode uc)
 {
   switch(uc) {
@@ -1747,7 +1740,7 @@ static void zonefrom_url(CURLU *uh, struct Curl_easy *data,
   }
 }
 #else
-#define zonefrom_url(a,b,c) Curl_nop_stmt
+#define zonefrom_url(a, b, c) Curl_nop_stmt
 #endif
 
 /*
@@ -1940,8 +1933,7 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data,
   else if(uc != CURLUE_NO_OPTIONS)
     return Curl_uc_to_curlcode(uc);
 
-  uc = curl_url_get(uh, CURLUPART_PATH, &data->state.up.path,
-                    CURLU_URLENCODE);
+  uc = curl_url_get(uh, CURLUPART_PATH, &data->state.up.path, CURLU_URLENCODE);
   if(uc)
     return Curl_uc_to_curlcode(uc);
 
@@ -1978,7 +1970,6 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data,
   return CURLE_OK;
 }
 
-
 /*
  * If we are doing a resumed transfer, we need to setup our stuff
  * properly.
@@ -2010,7 +2001,6 @@ static CURLcode setup_range(struct Curl_easy *data)
   return CURLE_OK;
 }
 
-
 /*
  * setup_connection_internals() -
  *
@@ -2066,15 +2056,14 @@ static CURLcode setup_connection_internals(struct Curl_easy *data,
   return CURLE_OK;
 }
 
-
 #ifndef CURL_DISABLE_PROXY
 
 #ifndef CURL_DISABLE_HTTP
 /****************************************************************
-* Detect what (if any) proxy to use. Remember that this selects a host
-* name and is not limited to HTTP proxies only.
-* The returned pointer must be freed by the caller (unless NULL)
-****************************************************************/
+ * Detect what (if any) proxy to use. Remember that this selects a host
+ * name and is not limited to HTTP proxies only.
+ * The returned pointer must be freed by the caller (unless NULL)
+ ****************************************************************/
 static char *detect_proxy(struct Curl_easy *data,
                           struct connectdata *conn)
 {
@@ -2189,7 +2178,7 @@ static CURLcode parse_proxy(struct Curl_easy *data,
   /* When parsing the proxy, allowing non-supported schemes since we have
      these made up ones for proxies. Guess scheme for URLs without it. */
   uc = curl_url_set(uhp, CURLUPART_URL, proxy,
-                    CURLU_NON_SUPPORT_SCHEME|CURLU_GUESS_SCHEME);
+                    CURLU_NON_SUPPORT_SCHEME | CURLU_GUESS_SCHEME);
   if(!uc) {
     /* parsed okay as a URL */
     uc = curl_url_get(uhp, CURLUPART_SCHEME, &scheme, 0);
@@ -2327,7 +2316,7 @@ static CURLcode parse_proxy(struct Curl_easy *data,
     if(strcmp("/", path)) {
       is_unix_proxy = TRUE;
       curlx_free(host);
-      host = curl_maprintf(UNIX_SOCKET_PREFIX"%s", path);
+      host = curl_maprintf(UNIX_SOCKET_PREFIX "%s", path);
       if(!host) {
         result = CURLE_OUT_OF_MEMORY;
         goto error;
@@ -2346,7 +2335,7 @@ static CURLcode parse_proxy(struct Curl_easy *data,
     if(host[0] == '[') {
       /* this is a numerical IPv6, strip off the brackets */
       size_t len = strlen(host);
-      host[len-1] = 0; /* clear the trailing bracket */
+      host[len - 1] = 0; /* clear the trailing bracket */
       host++;
       zonefrom_url(uhp, data, conn);
     }
@@ -2753,7 +2742,7 @@ static CURLcode override_login(struct Curl_easy *data,
         return CURLE_READ_ERROR;
       }
       else {
-        if(!(conn->handler->flags&PROTOPT_USERPWDCTRL)) {
+        if(!(conn->handler->flags & PROTOPT_USERPWDCTRL)) {
           /* if the protocol cannot handle control codes in credentials, make
              sure there are none */
           if(str_has_ctrl(*userp) || str_has_ctrl(*passwdp)) {
@@ -3475,7 +3464,7 @@ static CURLcode create_conn(struct Curl_easy *data,
    * If the protocol is using SSL and HTTP proxy is used, we set
    * the tunnel_proxy bit.
    *************************************************************/
-  if((conn->given->flags&PROTOPT_SSL) && conn->bits.httpproxy)
+  if((conn->given->flags & PROTOPT_SSL) && conn->bits.httpproxy)
     conn->bits.tunnel_proxy = TRUE;
 #endif
 
@@ -3548,7 +3537,7 @@ static CURLcode create_conn(struct Curl_easy *data,
    * we set the tunnel_proxy bit.
    *************************************************************/
   if((conn->bits.conn_to_host || conn->bits.conn_to_port) &&
-      conn->bits.httpproxy)
+     conn->bits.httpproxy)
     conn->bits.tunnel_proxy = TRUE;
 #endif
 
@@ -4006,7 +3995,6 @@ void Curl_data_priority_clear_state(struct Curl_easy *data)
 
 #endif /* USE_HTTP2 || USE_HTTP3 */
 
-
 CURLcode Curl_conn_meta_set(struct connectdata *conn, const char *key,
                             void *meta_data, Curl_meta_dtor *meta_dtor)
 {
index ad4d367dc34cf707db974748b745950e0e85c126..b8814cf85284e86c16c01c9928b319a64f1d7626 100644 (file)
 #include "curl_memrchr.h"
 
 #ifdef _WIN32
-  /* MS-DOS/Windows style drive prefix, eg c: in c:foo */
-#define STARTS_WITH_DRIVE_PREFIX(str) \
-  ((('a' <= str[0] && str[0] <= 'z') || \
+/* MS-DOS/Windows style drive prefix, eg c: in c:foo */
+#define STARTS_WITH_DRIVE_PREFIX(str)    \
+  ((('a' <= str[0] && str[0] <= 'z') ||  \
     ('A' <= str[0] && str[0] <= 'Z')) && \
    (str[1] == ':'))
 #endif
 
-  /* MS-DOS/Windows style drive prefix, optionally with
  * a '|' instead of ':', followed by a slash or NUL */
-#define STARTS_WITH_URL_DRIVE_PREFIX(str) \
-  ((('a' <= (str)[0] && (str)[0] <= 'z') || \
-    ('A' <= (str)[0] && (str)[0] <= 'Z')) && \
-   ((str)[1] == ':' || (str)[1] == '|') && \
+/* MS-DOS/Windows style drive prefix, optionally with
+ * a '|' instead of ':', followed by a slash or NUL */
+#define STARTS_WITH_URL_DRIVE_PREFIX(str)                  \
+  ((('a' <= (str)[0] && (str)[0] <= 'z') ||                \
+    ('A' <= (str)[0] && (str)[0] <= 'Z')) &&               \
+   ((str)[1] == ':' || (str)[1] == '|') &&                 \
    ((str)[2] == '/' || (str)[2] == '\\' || (str)[2] == 0))
 
 /* scheme is not URL encoded, the longest libcurl supported ones are... */
@@ -139,12 +139,12 @@ static CURLUcode urlencode_str(struct dynbuf *o, const char *url,
   /* we must add this with whitespace-replacing */
   bool left = !query;
   const unsigned char *iptr;
-  const unsigned char *host_sep = (const unsigned char *) url;
+  const unsigned char *host_sep = (const unsigned char *)url;
   CURLcode result = CURLE_OK;
 
   if(!relative) {
     size_t n;
-    host_sep = (const unsigned char *) find_host_sep(url);
+    host_sep = (const unsigned char *)find_host_sep(url);
 
     /* output the first piece as-is */
     n = (const char *)host_sep - url;
@@ -160,7 +160,7 @@ static CURLUcode urlencode_str(struct dynbuf *o, const char *url,
         result = curlx_dyn_addn(o, "+", 1);
     }
     else if((*iptr < ' ') || (*iptr >= 0x7f)) {
-      unsigned char out[3]={'%'};
+      unsigned char out[3] = { '%' };
       Curl_hexbyte(&out[1], *iptr);
       result = curlx_dyn_addn(o, out, 3);
     }
@@ -199,7 +199,7 @@ size_t Curl_is_absolute_url(const char *url, char *buf, size_t buflen,
   if(ISALPHA(url[0]))
     for(i = 1; i < MAX_SCHEME_LEN; ++i) {
       char s = url[i];
-      if(s && (ISALNUM(s) || (s == '+') || (s == '-') || (s == '.') )) {
+      if(s && (ISALNUM(s) || (s == '+') || (s == '-') || (s == '.'))) {
         /* RFC 3986 3.1 explains:
            scheme      = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
         */
@@ -453,7 +453,7 @@ UNITTEST CURLUcode Curl_parse_port(struct Curl_URL *u, struct dynbuf *host,
     if(curlx_str_number(&portptr, &port, 0xffff) || *portptr)
       return CURLUE_BAD_PORT_NUMBER;
 
-    u->portnum = (unsigned short) port;
+    u->portnum = (unsigned short)port;
     /* generate a new port number string to get rid of leading zeroes etc */
     curlx_free(u->port);
     u->port = curl_maprintf("%" CURL_FORMAT_CURL_OFF_T, port);
@@ -563,7 +563,7 @@ static int ipv4_normalize(struct dynbuf *host)
   bool done = FALSE;
   int n = 0;
   const char *c = curlx_dyn_ptr(host);
-  unsigned int parts[4] = {0, 0, 0, 0};
+  unsigned int parts[4] = { 0, 0, 0, 0 };
   CURLcode result = CURLE_OK;
 
   if(*c == '[')
@@ -920,7 +920,7 @@ static CURLUcode parseurl(const char *url, CURLU *u, unsigned int flags)
     goto fail;
 
   schemelen = Curl_is_absolute_url(url, schemebuf, sizeof(schemebuf),
-                                   flags & (CURLU_GUESS_SCHEME|
+                                   flags & (CURLU_GUESS_SCHEME |
                                             CURLU_DEFAULT_SCHEME));
 
   /* handle the file: scheme */
@@ -1036,7 +1036,6 @@ static CURLUcode parseurl(const char *url, CURLU *u, unsigned int flags)
       pathlen--;
     }
 #endif
-
   }
   else {
     /* clear path */
@@ -1069,7 +1068,7 @@ static CURLUcode parseurl(const char *url, CURLU *u, unsigned int flags)
     else {
       /* no scheme! */
 
-      if(!(flags & (CURLU_DEFAULT_SCHEME|CURLU_GUESS_SCHEME))) {
+      if(!(flags & (CURLU_DEFAULT_SCHEME | CURLU_GUESS_SCHEME))) {
         result = CURLUE_BAD_SCHEME;
         goto fail;
       }
@@ -1318,8 +1317,8 @@ fail:
 }
 
 #ifndef USE_IDN
-#define host_decode(x,y) CURLUE_LACKS_IDN
-#define host_encode(x,y) CURLUE_LACKS_IDN
+#define host_decode(x, y) CURLUE_LACKS_IDN
+#define host_encode(x, y) CURLUE_LACKS_IDN
 #else
 static CURLUcode host_decode(const char *host, char **allochost)
 {
@@ -1697,7 +1696,7 @@ static CURLUcode set_url(CURLU *u, const char *url, size_t part_size,
 
   /* if the new URL is absolute replace the existing with the new. */
   if(Curl_is_absolute_url(url, NULL, 0,
-                          flags & (CURLU_GUESS_SCHEME|CURLU_DEFAULT_SCHEME)))
+                          flags & (CURLU_GUESS_SCHEME | CURLU_DEFAULT_SCHEME)))
     return parseurl_and_replace(url, u, flags);
 
   /* if the old URL is incomplete (we cannot get an absolute URL in
@@ -1765,11 +1764,24 @@ static CURLUcode urlset_clear(CURLU *u, CURLUPart what)
 static bool allowed_in_path(unsigned char x)
 {
   switch(x) {
-  case '!': case '$': case '&': case '\'':
-  case '(': case ')': case '{': case '}':
-  case '[': case ']': case '*': case '+':
-  case ',': case ';': case '=': case ':':
-  case '@': case '/':
+  case '!':
+  case '$':
+  case '&':
+  case '\'':
+  case '(':
+  case ')':
+  case '{':
+  case '}':
+  case '[':
+  case ']':
+  case '*':
+  case '+':
+  case ',':
+  case ';':
+  case '=':
+  case ':':
+  case '@':
+  case '/':
     return TRUE;
   }
   return FALSE;
@@ -1878,7 +1890,7 @@ CURLUcode curl_url_set(CURLU *u, CURLUPart what,
             return cc2cu(result);
         }
         else {
-          unsigned char out[3]={'%'};
+          unsigned char out[3] = { '%' };
           Curl_hexbyte(&out[1], *i);
           result = curlx_dyn_addn(&enc, out, 3);
           if(result)
@@ -1911,7 +1923,7 @@ CURLUcode curl_url_set(CURLU *u, CURLUPart what,
          none is present at the end of the existing query already */
 
       size_t querylen = u->query ? strlen(u->query) : 0;
-      bool addamperand = querylen && (u->query[querylen -1] != '&');
+      bool addamperand = querylen && (u->query[querylen - 1] != '&');
       if(querylen) {
         struct dynbuf qbuf;
         curlx_dyn_init(&qbuf, CURL_MAX_INPUT_LENGTH);
index 1c91099d153d733abd6290edd5ee09f0b16fa229..aa1326d2a6456a55472b2672870591c2bf167059 100644 (file)
 
 #include "curl_setup.h"
 
-#define PORT_FTP 21
-#define PORT_FTPS 990
+#define PORT_FTP    21
+#define PORT_FTPS   990
 #define PORT_TELNET 23
-#define PORT_HTTP 80
-#define PORT_HTTPS 443
-#define PORT_DICT 2628
-#define PORT_LDAP 389
-#define PORT_LDAPS 636
-#define PORT_TFTP 69
-#define PORT_SSH 22
-#define PORT_IMAP 143
-#define PORT_IMAPS 993
-#define PORT_POP3 110
-#define PORT_POP3S 995
-#define PORT_SMB 445
-#define PORT_SMBS 445
-#define PORT_SMTP 25
-#define PORT_SMTPS 465 /* sometimes called SSMTP */
-#define PORT_RTSP 554
-#define PORT_RTMP 1935
-#define PORT_RTMPT PORT_HTTP
-#define PORT_RTMPS PORT_HTTPS
+#define PORT_HTTP   80
+#define PORT_HTTPS  443
+#define PORT_DICT   2628
+#define PORT_LDAP   389
+#define PORT_LDAPS  636
+#define PORT_TFTP   69
+#define PORT_SSH    22
+#define PORT_IMAP   143
+#define PORT_IMAPS  993
+#define PORT_POP3   110
+#define PORT_POP3S  995
+#define PORT_SMB    445
+#define PORT_SMBS   445
+#define PORT_SMTP   25
+#define PORT_SMTPS  465 /* sometimes called SSMTP */
+#define PORT_RTSP   554
+#define PORT_RTMP   1935
+#define PORT_RTMPT  PORT_HTTP
+#define PORT_RTMPS  PORT_HTTPS
 #define PORT_GOPHER 70
-#define PORT_MQTT 1883
+#define PORT_MQTT   1883
 
 struct curl_trc_featt;
 
 #ifdef USE_ECH
 /* CURLECH_ bits for the tls_ech option */
-# define CURLECH_DISABLE    (1<<0)
-# define CURLECH_GREASE     (1<<1)
-# define CURLECH_ENABLE     (1<<2)
-# define CURLECH_HARD       (1<<3)
-# define CURLECH_CLA_CFG    (1<<4)
+# define CURLECH_DISABLE    (1 << 0)
+# define CURLECH_GREASE     (1 << 1)
+# define CURLECH_ENABLE     (1 << 2)
+# define CURLECH_HARD       (1 << 3)
+# define CURLECH_CLA_CFG    (1 << 4)
 #endif
 
 #ifndef CURL_DISABLE_WEBSOCKETS
@@ -70,8 +70,8 @@ struct curl_trc_featt;
  * platforms that have a >= 64-bit type and then we use such a type for the
  * protocol fields in the protocol handler.
  */
-#define CURLPROTO_WS     (1L<<30)
-#define CURLPROTO_WSS    ((curl_prot_t)1<<31)
+#define CURLPROTO_WS     (1L << 30)
+#define CURLPROTO_WSS    ((curl_prot_t)1 << 31)
 #else
 #define CURLPROTO_WS     0L
 #define CURLPROTO_WSS    0L
@@ -107,15 +107,15 @@ typedef unsigned int curl_prot_t;
 /* Convenience defines for checking protocols or their SSL based version. Each
    protocol handler should only ever have a single CURLPROTO_ in its protocol
    field. */
-#define PROTO_FAMILY_HTTP (CURLPROTO_HTTP|CURLPROTO_HTTPS|CURLPROTO_WS| \
+#define PROTO_FAMILY_HTTP (CURLPROTO_HTTP | CURLPROTO_HTTPS | CURLPROTO_WS | \
                            CURLPROTO_WSS)
-#define PROTO_FAMILY_FTP  (CURLPROTO_FTP|CURLPROTO_FTPS)
-#define PROTO_FAMILY_POP3 (CURLPROTO_POP3|CURLPROTO_POP3S)
-#define PROTO_FAMILY_SMB  (CURLPROTO_SMB|CURLPROTO_SMBS)
-#define PROTO_FAMILY_SMTP (CURLPROTO_SMTP|CURLPROTO_SMTPS)
-#define PROTO_FAMILY_SSH  (CURLPROTO_SCP|CURLPROTO_SFTP)
+#define PROTO_FAMILY_FTP  (CURLPROTO_FTP | CURLPROTO_FTPS)
+#define PROTO_FAMILY_POP3 (CURLPROTO_POP3 | CURLPROTO_POP3S)
+#define PROTO_FAMILY_SMB  (CURLPROTO_SMB | CURLPROTO_SMBS)
+#define PROTO_FAMILY_SMTP (CURLPROTO_SMTP | CURLPROTO_SMTPS)
+#define PROTO_FAMILY_SSH  (CURLPROTO_SCP | CURLPROTO_SFTP)
 
-#if !defined(CURL_DISABLE_FTP) || defined(USE_SSH) ||   \
+#if !defined(CURL_DISABLE_FTP) || defined(USE_SSH) || \
   !defined(CURL_DISABLE_POP3)
 /* these protocols support CURLOPT_DIRLISTONLY */
 #define CURL_LIST_ONLY_PROTOCOL 1
@@ -127,7 +127,7 @@ typedef unsigned int curl_prot_t;
 #define MAX_IPADR_LEN sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")
 
 /* Default FTP/IMAP etc response timeout in milliseconds */
-#define RESP_TIMEOUT (60*1000)
+#define RESP_TIMEOUT (60 * 1000)
 
 /* Max string input length is a precaution against abuse and to detect junk
    input easier and better. */
@@ -217,8 +217,8 @@ typedef CURLcode (Curl_recv)(struct Curl_easy *data,   /* transfer */
    larger buffers can help further, but this is deemed a fair memory/speed
    compromise. */
 #define UPLOADBUFFER_DEFAULT 65536
-#define UPLOADBUFFER_MAX (2*1024*1024)
-#define UPLOADBUFFER_MIN CURL_MAX_WRITE_SIZE
+#define UPLOADBUFFER_MAX     (2 * 1024 * 1024)
+#define UPLOADBUFFER_MIN     CURL_MAX_WRITE_SIZE
 
 #define CURLEASY_MAGIC_NUMBER 0xc0dedbadU
 #ifdef DEBUGBUILD
@@ -226,7 +226,7 @@ typedef CURLcode (Curl_recv)(struct Curl_easy *data,   /* transfer */
  * are not NULL, but no longer have the MAGIC touch. This gives
  * us early warning on things only discovered by valgrind otherwise. */
 #define GOOD_EASY_HANDLE(x) \
-  (((x) && ((x)->magic == CURLEASY_MAGIC_NUMBER))? TRUE: \
+  (((x) && ((x)->magic == CURLEASY_MAGIC_NUMBER)) ? TRUE : \
   (DEBUGASSERT(!(x)), FALSE))
 #else
 #define GOOD_EASY_HANDLE(x) \
@@ -269,7 +269,7 @@ struct ssl_config_data {
   long certverifyresult; /* result from the certificate verification */
   curl_ssl_ctx_callback fsslctx; /* function to initialize ssl ctx */
   void *fsslctxp;        /* parameter for call back */
-  char *cert_type; /* format for certificate (default: PEM)*/
+  char *cert_type; /* format for certificate (default: PEM) */
   char *key; /* private key filename */
   struct curl_blob *key_blob;
   char *key_type; /* format for private key (default: PEM) */
@@ -424,8 +424,8 @@ struct hostname {
  */
 
 #define KEEP_NONE       0
-#define KEEP_RECV       (1<<0) /* there is or may be data to read */
-#define KEEP_SEND       (1<<1) /* there is or may be data to write */
+#define KEEP_RECV       (1 << 0) /* there is or may be data to read */
+#define KEEP_SEND       (1 << 1) /* there is or may be data to write */
 
 /* transfer wants to send */
 #define CURL_WANT_SEND(data) ((data)->req.keepon & KEEP_SEND)
@@ -576,8 +576,8 @@ struct Curl_handler {
 #define CONNRESULT_DEAD (1<<0)           /* The connection is dead. */
 
 #define TRNSPRT_NONE 0
-#define TRNSPRT_TCP 3
-#define TRNSPRT_UDP 4
+#define TRNSPRT_TCP  3
+#define TRNSPRT_UDP  4
 #define TRNSPRT_QUIC 5
 #define TRNSPRT_UNIX 6
 
@@ -589,9 +589,10 @@ struct ip_quadruple {
   uint8_t transport;
 };
 
-#define CUR_IP_QUAD_HAS_PORTS(x)  (((x)->transport == TRNSPRT_TCP) || \
-                                   ((x)->transport == TRNSPRT_UDP) || \
-                                   ((x)->transport == TRNSPRT_QUIC))
+#define CUR_IP_QUAD_HAS_PORTS(x)      \
+  (((x)->transport == TRNSPRT_TCP) || \
+   ((x)->transport == TRNSPRT_UDP) || \
+   ((x)->transport == TRNSPRT_QUIC))
 
 struct proxy_info {
   struct hostname host;
@@ -827,8 +828,8 @@ struct Progress {
 
 #define CURL_SPEED_RECORDS (5 + 1) /* 6 entries for 5 seconds */
 
-  curl_off_t speed_amount[ CURL_SPEED_RECORDS ];
-  struct curltime speed_time[ CURL_SPEED_RECORDS ];
+  curl_off_t speed_amount[CURL_SPEED_RECORDS];
+  struct curltime speed_time[CURL_SPEED_RECORDS];
   unsigned char speeder_c;
   BIT(hide);
   BIT(ul_size_known);
@@ -839,19 +840,19 @@ struct Progress {
 };
 
 typedef enum {
-    RTSPREQ_NONE, /* first in list */
-    RTSPREQ_OPTIONS,
-    RTSPREQ_DESCRIBE,
-    RTSPREQ_ANNOUNCE,
-    RTSPREQ_SETUP,
-    RTSPREQ_PLAY,
-    RTSPREQ_PAUSE,
-    RTSPREQ_TEARDOWN,
-    RTSPREQ_GET_PARAMETER,
-    RTSPREQ_SET_PARAMETER,
-    RTSPREQ_RECORD,
-    RTSPREQ_RECEIVE,
-    RTSPREQ_LAST /* last in list */
+  RTSPREQ_NONE, /* first in list */
+  RTSPREQ_OPTIONS,
+  RTSPREQ_DESCRIBE,
+  RTSPREQ_ANNOUNCE,
+  RTSPREQ_SETUP,
+  RTSPREQ_PLAY,
+  RTSPREQ_PAUSE,
+  RTSPREQ_TEARDOWN,
+  RTSPREQ_GET_PARAMETER,
+  RTSPREQ_SET_PARAMETER,
+  RTSPREQ_RECORD,
+  RTSPREQ_RECEIVE,
+  RTSPREQ_LAST /* last in list */
 } Curl_RtspReq;
 
 struct auth {
@@ -911,7 +912,6 @@ typedef enum {
   EXPIRE_LAST /* not an actual timer, used as a marker only */
 } expire_id;
 
-
 typedef enum {
   TRAILERS_NONE,
   TRAILERS_INITIALIZED,
@@ -919,7 +919,6 @@ typedef enum {
   TRAILERS_DONE
 } trailers_state;
 
-
 /*
  * One instance for each timeout an easy handle can set.
  */
@@ -1296,7 +1295,6 @@ enum dupblob {
   BLOB_LAST
 };
 
-
 struct UserDefined {
   FILE *err;         /* the stderr user data goes here */
   void *debugdata;   /* the data that will be passed to fdebug */
index 487dc74ffa158e4193ddaacfe6a5a377cd162dc7..79654fa9755cae7773d19b90715155464daa1e14 100644 (file)
@@ -335,8 +335,8 @@ static const char * const supported_protocols[] = {
 #ifndef CURL_DISABLE_LDAP
   "ldap",
 #if !defined(CURL_DISABLE_LDAPS) && \
-    ((defined(USE_OPENLDAP) && defined(USE_SSL)) || \
-     (!defined(USE_OPENLDAP) && defined(HAVE_LDAP_SSL)))
+  ((defined(USE_OPENLDAP) && defined(USE_SSL)) || \
+   (!defined(USE_OPENLDAP) && defined(HAVE_LDAP_SSL)))
   "ldaps",
 #endif
 #endif
@@ -438,7 +438,7 @@ static int ech_present(curl_version_info_data *info)
  * Use FEATURE() macro to define an entry: this allows documentation check.
  */
 
-#define FEATURE(name, present, bitmask) {(name), (present), (bitmask)}
+#define FEATURE(name, present, bitmask) { (name), (present), (bitmask) }
 
 struct feat {
   const char *name;
index 93e13e1ac1842c5d42222f179d61c16d60e396d2..eab06f4f118c3a61dd63a0c01a03c807bfe3eb93 100644 (file)
--- a/lib/ws.c
+++ b/lib/ws.c
      |N|V|V|V|       |
      | |1|2|3|       |
 */
-#define WSBIT_FIN  (0x80)
-#define WSBIT_RSV1 (0x40)
-#define WSBIT_RSV2 (0x20)
-#define WSBIT_RSV3 (0x10)
-#define WSBIT_RSV_MASK (WSBIT_RSV1 | WSBIT_RSV2 | WSBIT_RSV3)
+#define WSBIT_FIN          (0x80)
+#define WSBIT_RSV1         (0x40)
+#define WSBIT_RSV2         (0x20)
+#define WSBIT_RSV3         (0x10)
+#define WSBIT_RSV_MASK     (WSBIT_RSV1 | WSBIT_RSV2 | WSBIT_RSV3)
 #define WSBIT_OPCODE_CONT  (0x0)
 #define WSBIT_OPCODE_TEXT  (0x1)
 #define WSBIT_OPCODE_BIN   (0x2)
 #define WSBIT_MASK 0x80
 
 /* buffer dimensioning */
-#define WS_CHUNK_SIZE 65535
+#define WS_CHUNK_SIZE  65535
 #define WS_CHUNK_COUNT 2
 
-
 /* a client-side WS frame decoder, parsing frame headers and
  * payload, keeping track of current position and stats */
 enum ws_dec_state {
@@ -126,24 +125,23 @@ struct websocket {
   size_t sendbuf_payload; /* number of payload bytes in sendbuf */
 };
 
-
 static const char *ws_frame_name_of_op(uint8_t firstbyte)
 {
   switch(firstbyte & WSBIT_OPCODE_MASK) {
-    case WSBIT_OPCODE_CONT:
-      return "CONT";
-    case WSBIT_OPCODE_TEXT:
-      return "TEXT";
-    case WSBIT_OPCODE_BIN:
-      return "BIN";
-    case WSBIT_OPCODE_CLOSE:
-      return "CLOSE";
-    case WSBIT_OPCODE_PING:
-      return "PING";
-    case WSBIT_OPCODE_PONG:
-      return "PONG";
-    default:
-      return "???";
+  case WSBIT_OPCODE_CONT:
+    return "CONT";
+  case WSBIT_OPCODE_TEXT:
+    return "TEXT";
+  case WSBIT_OPCODE_BIN:
+    return "BIN";
+  case WSBIT_OPCODE_CLOSE:
+    return "CLOSE";
+  case WSBIT_OPCODE_PING:
+    return "PING";
+  case WSBIT_OPCODE_PONG:
+    return "PONG";
+  default:
+    return "???";
   }
 }
 
@@ -151,78 +149,78 @@ static int ws_frame_firstbyte2flags(struct Curl_easy *data,
                                     uint8_t firstbyte, int cont_flags)
 {
   switch(firstbyte) {
-    /* 0x00 - intermediate TEXT/BINARY fragment */
-    case WSBIT_OPCODE_CONT:
-      if(!(cont_flags & CURLWS_CONT)) {
-        failf(data, "[WS] no ongoing fragmented message to resume");
-        return 0;
-      }
-      return cont_flags | CURLWS_CONT;
-    /* 0x80 - final TEXT/BIN fragment */
-    case (WSBIT_OPCODE_CONT | WSBIT_FIN):
-      if(!(cont_flags & CURLWS_CONT)) {
-        failf(data, "[WS] no ongoing fragmented message to resume");
-        return 0;
-      }
-      return cont_flags & ~CURLWS_CONT;
-    /* 0x01 - first TEXT fragment */
-    case WSBIT_OPCODE_TEXT:
-      if(cont_flags & CURLWS_CONT) {
-        failf(data, "[WS] fragmented message interrupted by new TEXT msg");
-        return 0;
-      }
-      return CURLWS_TEXT | CURLWS_CONT;
-    /* 0x81 - unfragmented TEXT msg */
-    case (WSBIT_OPCODE_TEXT | WSBIT_FIN):
-      if(cont_flags & CURLWS_CONT) {
-        failf(data, "[WS] fragmented message interrupted by new TEXT msg");
-        return 0;
-      }
-      return CURLWS_TEXT;
-    /* 0x02 - first BINARY fragment */
-    case WSBIT_OPCODE_BIN:
-      if(cont_flags & CURLWS_CONT) {
-        failf(data, "[WS] fragmented message interrupted by new BINARY msg");
-        return 0;
-      }
-      return CURLWS_BINARY | CURLWS_CONT;
-    /* 0x82 - unfragmented BINARY msg */
-    case (WSBIT_OPCODE_BIN | WSBIT_FIN):
-      if(cont_flags & CURLWS_CONT) {
-        failf(data, "[WS] fragmented message interrupted by new BINARY msg");
-        return 0;
-      }
-      return CURLWS_BINARY;
-    /* 0x08 - first CLOSE fragment */
-    case WSBIT_OPCODE_CLOSE:
-      failf(data, "[WS] invalid fragmented CLOSE frame");
+  /* 0x00 - intermediate TEXT/BINARY fragment */
+  case WSBIT_OPCODE_CONT:
+    if(!(cont_flags & CURLWS_CONT)) {
+      failf(data, "[WS] no ongoing fragmented message to resume");
       return 0;
-    /* 0x88 - unfragmented CLOSE */
-    case (WSBIT_OPCODE_CLOSE | WSBIT_FIN):
-      return CURLWS_CLOSE;
-    /* 0x09 - first PING fragment */
-    case WSBIT_OPCODE_PING:
-      failf(data, "[WS] invalid fragmented PING frame");
+    }
+    return cont_flags | CURLWS_CONT;
+  /* 0x80 - final TEXT/BIN fragment */
+  case (WSBIT_OPCODE_CONT | WSBIT_FIN):
+    if(!(cont_flags & CURLWS_CONT)) {
+      failf(data, "[WS] no ongoing fragmented message to resume");
       return 0;
-    /* 0x89 - unfragmented PING */
-    case (WSBIT_OPCODE_PING | WSBIT_FIN):
-      return CURLWS_PING;
-    /* 0x0a - first PONG fragment */
-    case WSBIT_OPCODE_PONG:
-      failf(data, "[WS] invalid fragmented PONG frame");
+    }
+    return cont_flags & ~CURLWS_CONT;
+  /* 0x01 - first TEXT fragment */
+  case WSBIT_OPCODE_TEXT:
+    if(cont_flags & CURLWS_CONT) {
+      failf(data, "[WS] fragmented message interrupted by new TEXT msg");
       return 0;
-    /* 0x8a - unfragmented PONG */
-    case (WSBIT_OPCODE_PONG | WSBIT_FIN):
-      return CURLWS_PONG;
-    /* invalid first byte */
-    default:
-      if(firstbyte & WSBIT_RSV_MASK)
-        /* any of the reserved bits 0x40/0x20/0x10 are set */
-        failf(data, "[WS] invalid reserved bits: %02x", firstbyte);
-      else
-        /* any of the reserved opcodes 0x3-0x7 or 0xb-0xf is used */
-        failf(data, "[WS] invalid opcode: %02x", firstbyte);
+    }
+    return CURLWS_TEXT | CURLWS_CONT;
+  /* 0x81 - unfragmented TEXT msg */
+  case (WSBIT_OPCODE_TEXT | WSBIT_FIN):
+    if(cont_flags & CURLWS_CONT) {
+      failf(data, "[WS] fragmented message interrupted by new TEXT msg");
+      return 0;
+    }
+    return CURLWS_TEXT;
+  /* 0x02 - first BINARY fragment */
+  case WSBIT_OPCODE_BIN:
+    if(cont_flags & CURLWS_CONT) {
+      failf(data, "[WS] fragmented message interrupted by new BINARY msg");
+      return 0;
+    }
+    return CURLWS_BINARY | CURLWS_CONT;
+  /* 0x82 - unfragmented BINARY msg */
+  case (WSBIT_OPCODE_BIN | WSBIT_FIN):
+    if(cont_flags & CURLWS_CONT) {
+      failf(data, "[WS] fragmented message interrupted by new BINARY msg");
       return 0;
+    }
+    return CURLWS_BINARY;
+  /* 0x08 - first CLOSE fragment */
+  case WSBIT_OPCODE_CLOSE:
+    failf(data, "[WS] invalid fragmented CLOSE frame");
+    return 0;
+  /* 0x88 - unfragmented CLOSE */
+  case (WSBIT_OPCODE_CLOSE | WSBIT_FIN):
+    return CURLWS_CLOSE;
+  /* 0x09 - first PING fragment */
+  case WSBIT_OPCODE_PING:
+    failf(data, "[WS] invalid fragmented PING frame");
+    return 0;
+  /* 0x89 - unfragmented PING */
+  case (WSBIT_OPCODE_PING | WSBIT_FIN):
+    return CURLWS_PING;
+  /* 0x0a - first PONG fragment */
+  case WSBIT_OPCODE_PONG:
+    failf(data, "[WS] invalid fragmented PONG frame");
+    return 0;
+  /* 0x8a - unfragmented PONG */
+  case (WSBIT_OPCODE_PONG | WSBIT_FIN):
+    return CURLWS_PONG;
+  /* invalid first byte */
+  default:
+    if(firstbyte & WSBIT_RSV_MASK)
+      /* any of the reserved bits 0x40/0x20/0x10 are set */
+      failf(data, "[WS] invalid reserved bits: %02x", firstbyte);
+    else
+      /* any of the reserved opcodes 0x3-0x7 or 0xb-0xf is used */
+      failf(data, "[WS] invalid opcode: %02x", firstbyte);
+    return 0;
   }
 }
 
@@ -233,59 +231,59 @@ static CURLcode ws_frame_flags2firstbyte(struct Curl_easy *data,
 {
   *pfirstbyte = 0;
   switch(flags & ~CURLWS_OFFSET) {
-    case 0:
-      if(contfragment) {
-        CURL_TRC_WS(data, "no flags given; interpreting as continuation "
-                    "fragment for compatibility");
-        *pfirstbyte = (WSBIT_OPCODE_CONT | WSBIT_FIN);
-        return CURLE_OK;
-      }
-      failf(data, "[WS] no flags given");
-      return CURLE_BAD_FUNCTION_ARGUMENT;
-    case CURLWS_CONT:
-      if(contfragment) {
-        infof(data, "[WS] setting CURLWS_CONT flag without message type is "
-                    "supported for compatibility but highly discouraged");
-        *pfirstbyte = WSBIT_OPCODE_CONT;
-        return CURLE_OK;
-      }
-      failf(data, "[WS] No ongoing fragmented message to continue");
-      return CURLE_BAD_FUNCTION_ARGUMENT;
-    case CURLWS_TEXT:
-      *pfirstbyte = contfragment ? (WSBIT_OPCODE_CONT | WSBIT_FIN)
-                                 : (WSBIT_OPCODE_TEXT | WSBIT_FIN);
-      return CURLE_OK;
-    case (CURLWS_TEXT | CURLWS_CONT):
-      *pfirstbyte = contfragment ? WSBIT_OPCODE_CONT : WSBIT_OPCODE_TEXT;
-      return CURLE_OK;
-    case CURLWS_BINARY:
-      *pfirstbyte = contfragment ? (WSBIT_OPCODE_CONT | WSBIT_FIN)
-                                 : (WSBIT_OPCODE_BIN | WSBIT_FIN);
-      return CURLE_OK;
-    case (CURLWS_BINARY | CURLWS_CONT):
-      *pfirstbyte = contfragment ? WSBIT_OPCODE_CONT : WSBIT_OPCODE_BIN;
-      return CURLE_OK;
-    case CURLWS_CLOSE:
-      *pfirstbyte = WSBIT_OPCODE_CLOSE | WSBIT_FIN;
-      return CURLE_OK;
-    case (CURLWS_CLOSE | CURLWS_CONT):
-      failf(data, "[WS] CLOSE frame must not be fragmented");
-      return CURLE_BAD_FUNCTION_ARGUMENT;
-    case CURLWS_PING:
-      *pfirstbyte = WSBIT_OPCODE_PING | WSBIT_FIN;
+  case 0:
+    if(contfragment) {
+      CURL_TRC_WS(data, "no flags given; interpreting as continuation "
+                  "fragment for compatibility");
+      *pfirstbyte = (WSBIT_OPCODE_CONT | WSBIT_FIN);
       return CURLE_OK;
-    case (CURLWS_PING | CURLWS_CONT):
-      failf(data, "[WS] PING frame must not be fragmented");
-      return CURLE_BAD_FUNCTION_ARGUMENT;
-    case CURLWS_PONG:
-      *pfirstbyte = WSBIT_OPCODE_PONG | WSBIT_FIN;
+    }
+    failf(data, "[WS] no flags given");
+    return CURLE_BAD_FUNCTION_ARGUMENT;
+  case CURLWS_CONT:
+    if(contfragment) {
+      infof(data, "[WS] setting CURLWS_CONT flag without message type is "
+                  "supported for compatibility but highly discouraged");
+      *pfirstbyte = WSBIT_OPCODE_CONT;
       return CURLE_OK;
-    case (CURLWS_PONG | CURLWS_CONT):
-      failf(data, "[WS] PONG frame must not be fragmented");
-      return CURLE_BAD_FUNCTION_ARGUMENT;
-    default:
-      failf(data, "[WS] unknown flags: %x", flags);
-      return CURLE_BAD_FUNCTION_ARGUMENT;
+    }
+    failf(data, "[WS] No ongoing fragmented message to continue");
+    return CURLE_BAD_FUNCTION_ARGUMENT;
+  case CURLWS_TEXT:
+    *pfirstbyte = contfragment ? (WSBIT_OPCODE_CONT | WSBIT_FIN)
+                               : (WSBIT_OPCODE_TEXT | WSBIT_FIN);
+    return CURLE_OK;
+  case (CURLWS_TEXT | CURLWS_CONT):
+    *pfirstbyte = contfragment ? WSBIT_OPCODE_CONT : WSBIT_OPCODE_TEXT;
+    return CURLE_OK;
+  case CURLWS_BINARY:
+    *pfirstbyte = contfragment ? (WSBIT_OPCODE_CONT | WSBIT_FIN)
+                               : (WSBIT_OPCODE_BIN | WSBIT_FIN);
+    return CURLE_OK;
+  case (CURLWS_BINARY | CURLWS_CONT):
+    *pfirstbyte = contfragment ? WSBIT_OPCODE_CONT : WSBIT_OPCODE_BIN;
+    return CURLE_OK;
+  case CURLWS_CLOSE:
+    *pfirstbyte = WSBIT_OPCODE_CLOSE | WSBIT_FIN;
+    return CURLE_OK;
+  case (CURLWS_CLOSE | CURLWS_CONT):
+    failf(data, "[WS] CLOSE frame must not be fragmented");
+    return CURLE_BAD_FUNCTION_ARGUMENT;
+  case CURLWS_PING:
+    *pfirstbyte = WSBIT_OPCODE_PING | WSBIT_FIN;
+    return CURLE_OK;
+  case (CURLWS_PING | CURLWS_CONT):
+    failf(data, "[WS] PING frame must not be fragmented");
+    return CURLE_BAD_FUNCTION_ARGUMENT;
+  case CURLWS_PONG:
+    *pfirstbyte = WSBIT_OPCODE_PONG | WSBIT_FIN;
+    return CURLE_OK;
+  case (CURLWS_PONG | CURLWS_CONT):
+    failf(data, "[WS] PONG frame must not be fragmented");
+    return CURLE_BAD_FUNCTION_ARGUMENT;
+  default:
+    failf(data, "[WS] unknown flags: %x", flags);
+    return CURLE_BAD_FUNCTION_ARGUMENT;
   }
 }
 
@@ -452,13 +450,14 @@ static CURLcode ws_dec_read_head(struct ws_decoder *dec,
         failf(data, "[WS] frame length longer than 63 bit not supported");
         return CURLE_RECV_ERROR;
       }
-      dec->payload_len = ((curl_off_t)dec->head[2] << 56) |
+      dec->payload_len =
+        (curl_off_t)dec->head[2] << 56 |
         (curl_off_t)dec->head[3] << 48 |
         (curl_off_t)dec->head[4] << 40 |
         (curl_off_t)dec->head[5] << 32 |
         (curl_off_t)dec->head[6] << 24 |
         (curl_off_t)dec->head[7] << 16 |
-        (curl_off_t)dec->head[8] << 8 |
+        (curl_off_t)dec->head[8] <<  8 |
         dec->head[9];
       break;
     default:
@@ -1230,7 +1229,6 @@ static const struct Curl_crtype ws_cr_encode = {
   sizeof(struct cr_ws_ctx)
 };
 
-
 struct wsfield {
   const char *name;
   const char *val;
@@ -1245,7 +1243,7 @@ CURLcode Curl_ws_request(struct Curl_easy *data, struct dynbuf *req)
   size_t randlen;
   char keyval[40];
   struct SingleRequest *k = &data->req;
-  struct wsfield heads[]= {
+  struct wsfield heads[] = {
     {
       /* The request MUST contain an |Upgrade| header field whose value
          MUST include the "websocket" keyword. */
@@ -1284,8 +1282,7 @@ CURLcode Curl_ws_request(struct Curl_easy *data, struct dynbuf *req)
   curlx_free(randstr);
   for(i = 0; !result && (i < CURL_ARRAYSIZE(heads)); i++) {
     if(!Curl_checkheaders(data, heads[i].name, strlen(heads[i].name))) {
-      result = curlx_dyn_addf(req, "%s: %s\r\n", heads[i].name,
-                              heads[i].val);
+      result = curlx_dyn_addf(req, "%s: %s\r\n", heads[i].name, heads[i].val);
     }
   }
   data->state.http_hd_upgrade = TRUE;
@@ -1329,7 +1326,7 @@ CURLcode Curl_ws_accept(struct Curl_easy *data,
       const char *p = getenv("CURL_WS_CHUNK_SIZE");
       if(p) {
         curl_off_t l;
-        if(!curlx_str_number(&p, &l, 1*1024*1024))
+        if(!curlx_str_number(&p, &l, 1 * 1024 * 1024))
           chunk_size = (size_t)l;
       }
     }
@@ -1633,7 +1630,7 @@ static CURLcode ws_flush(struct Curl_easy *data, struct websocket *ws,
     const char *p = getenv("CURL_WS_CHUNK_EAGAIN");
     if(p) {
       curl_off_t l;
-      if(!curlx_str_number(&p, &l, 1*1024*1024))
+      if(!curlx_str_number(&p, &l, 1 * 1024 * 1024))
         chunk_egain = (size_t)l;
     }
 #endif
@@ -1844,7 +1841,6 @@ static CURLcode ws_setup_conn(struct Curl_easy *data,
   return Curl_http_setup_conn(data, conn);
 }
 
-
 const struct curl_ws_frame *curl_ws_meta(CURL *d)
 {
   /* we only return something for websocket, called from within the callback
@@ -1856,7 +1852,6 @@ const struct curl_ws_frame *curl_ws_meta(CURL *d)
     ws = Curl_conn_meta_get(data->conn, CURL_META_PROTO_WS_CONN);
     if(ws)
       return &ws->recvframe;
-
   }
   return NULL;
 }
@@ -1963,11 +1958,10 @@ const struct Curl_handler Curl_handler_wss = {
   CURLPROTO_WSS,                        /* protocol */
   CURLPROTO_HTTP,                       /* family */
   PROTOPT_SSL | PROTOPT_CREDSPERREQUEST | /* flags */
-  PROTOPT_USERPWDCTRL
+    PROTOPT_USERPWDCTRL
 };
 #endif
 
-
 #else
 
 CURLcode curl_ws_recv(CURL *curl, void *buffer, size_t buflen,
index b7655abbce74954d0f0f7e216aaa8bb616ac69b9..a6e770694deea6ee0c5d14bd75fabc0919207bc8 100644 (file)
--- a/lib/ws.h
+++ b/lib/ws.h
@@ -38,10 +38,9 @@ extern const struct Curl_handler Curl_handler_ws;
 extern const struct Curl_handler Curl_handler_wss;
 #endif
 
-
 #else
-#define Curl_ws_request(x,y) CURLE_OK
-#define Curl_ws_free(x) Curl_nop_stmt
+#define Curl_ws_request(x, y) CURLE_OK
+#define Curl_ws_free(x)       Curl_nop_stmt
 #endif
 
 #endif /* HEADER_CURL_WS_H */