From 0417d323c96db547e5ed9da733c51aed02be723e Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 3 Dec 2025 15:53:46 +0100 Subject: [PATCH] src: fix formatting nits Closes #19823 --- src/config2setopts.c | 21 ++--- src/curlinfo.c | 2 +- src/slist_wc.c | 3 +- src/terminal.c | 3 +- src/tool_cb_dbg.c | 4 +- src/tool_cb_hdr.c | 17 ++-- src/tool_cb_prg.c | 27 +++--- src/tool_cb_prg.h | 10 +-- src/tool_cb_rea.c | 2 +- src/tool_cb_wrt.c | 6 +- src/tool_cfgable.h | 9 +- src/tool_dirhie.c | 4 +- src/tool_doswin.c | 50 ++++++----- src/tool_doswin.h | 6 +- src/tool_easysrc.c | 4 +- src/tool_filetime.c | 4 +- src/tool_filetime.h | 2 +- src/tool_findfile.c | 2 +- src/tool_formparse.c | 43 ++++----- src/tool_getparam.c | 178 ++++++++++++++++++------------------- src/tool_getparam.h | 10 +-- src/tool_getpass.c | 9 +- src/tool_help.c | 57 ++++++------ src/tool_helpers.c | 4 +- src/tool_ipfs.c | 4 +- src/tool_libinfo.c | 2 +- src/tool_main.c | 2 +- src/tool_main.h | 4 +- src/tool_msgs.c | 12 +-- src/tool_msgs.h | 12 +-- src/tool_operate.c | 59 +++++-------- src/tool_operhlp.c | 2 +- src/tool_paramhlp.c | 27 +++--- src/tool_paramhlp.h | 2 +- src/tool_parsecfg.c | 2 +- src/tool_progress.c | 28 +++--- src/tool_sdecls.h | 2 - src/tool_setopt.c | 19 ++-- src/tool_setopt.h | 104 +++++++++------------- src/tool_setup.h | 4 +- src/tool_ssls.c | 4 +- src/tool_urlglob.c | 12 +-- src/tool_util.c | 2 +- src/tool_version.h | 8 +- src/tool_vms.c | 7 +- src/tool_vms.h | 5 +- src/tool_writeout.c | 186 ++++++++++++++++++++------------------- src/tool_writeout_json.c | 3 +- src/tool_xattr.h | 4 +- src/var.c | 37 ++++---- src/var.h | 3 +- tests/test1486.pl | 2 +- 52 files changed, 491 insertions(+), 544 deletions(-) diff --git a/src/config2setopts.c b/src/config2setopts.c index d3bd39c864..89a003cc96 100644 --- a/src/config2setopts.c +++ b/src/config2setopts.c @@ -142,8 +142,7 @@ static CURLcode url_proto_and_rewrite(char **url, curl_url_set(uh, CURLUPART_URL, *url, CURLU_GUESS_SCHEME | CURLU_NON_SUPPORT_SCHEME); if(!uc) { - uc = curl_url_get(uh, CURLUPART_SCHEME, &schemep, - CURLU_DEFAULT_SCHEME); + uc = curl_url_get(uh, CURLUPART_SCHEME, &schemep, CURLU_DEFAULT_SCHEME); if(!uc) { #ifdef CURL_DISABLE_IPFS (void)config; @@ -339,8 +338,7 @@ static CURLcode ssl_setopts(struct OperationConfig *config, CURL *curl) MY_SETOPT_STR(curl, CURLOPT_PROXY_CRLFILE, config->crlfile); if(config->pinnedpubkey) { - MY_SETOPT_STR(curl, CURLOPT_PINNEDPUBLICKEY, - config->pinnedpubkey); + MY_SETOPT_STR(curl, CURLOPT_PINNEDPUBLICKEY, config->pinnedpubkey); if(result) warnf("ignoring %s, not supported by libcurl with %s", "--pinnedpubkey", ssl_backend()); @@ -417,8 +415,7 @@ static CURLcode ssl_setopts(struct OperationConfig *config, CURL *curl) { long mask = (config->proxy_ssl_allow_beast ? CURLSSLOPT_ALLOW_BEAST : 0) | - (config->proxy_ssl_auto_client_cert ? - CURLSSLOPT_AUTO_CLIENT_CERT : 0) | + (config->proxy_ssl_auto_client_cert ? CURLSSLOPT_AUTO_CLIENT_CERT : 0) | (config->proxy_native_ca_store ? CURLSSLOPT_NATIVE_CA : 0); if(mask) @@ -486,15 +483,13 @@ static CURLcode ssl_setopts(struct OperationConfig *config, CURL *curl) } /* only called for HTTP transfers */ -static CURLcode http_setopts(struct OperationConfig *config, - CURL *curl) +static CURLcode http_setopts(struct OperationConfig *config, CURL *curl) { CURLcode result; long postRedir = 0; my_setopt_long(curl, CURLOPT_FOLLOWLOCATION, config->followlocation); - my_setopt_long(curl, CURLOPT_UNRESTRICTED_AUTH, - config->unrestricted_auth); + my_setopt_long(curl, CURLOPT_UNRESTRICTED_AUTH, config->unrestricted_auth); MY_SETOPT_STR(curl, CURLOPT_AWS_SIGV4, config->aws_sigv4); my_setopt_long(curl, CURLOPT_AUTOREFERER, config->autoreferer); @@ -590,8 +585,7 @@ static void tcp_setopts(struct OperationConfig *config, CURL *curl) my_setopt_long(curl, CURLOPT_TCP_FASTOPEN, 1); if(config->mptcp) - my_setopt_ptr(curl, CURLOPT_OPENSOCKETFUNCTION, - tool_socket_open_mptcp_cb); + my_setopt_ptr(curl, CURLOPT_OPENSOCKETFUNCTION, tool_socket_open_mptcp_cb); /* curl 7.17.1 */ if(!config->nokeepalive) { @@ -946,8 +940,7 @@ CURLcode config2setopts(struct OperationConfig *config, my_setopt_long(curl, CURLOPT_FTP_CREATE_MISSING_DIRS, (config->ftp_create_dirs ? CURLFTP_CREATE_DIR_RETRY : CURLFTP_CREATE_DIR_NONE)); - my_setopt_offt(curl, CURLOPT_MAXFILESIZE_LARGE, - config->max_filesize); + my_setopt_offt(curl, CURLOPT_MAXFILESIZE_LARGE, config->max_filesize); my_setopt_long(curl, CURLOPT_IPRESOLVE, config->ip_version); if(config->socks5_gssapi_nec) my_setopt_long(curl, CURLOPT_SOCKS5_GSSAPI_NEC, 1); diff --git a/src/curlinfo.c b/src/curlinfo.c index 852aee8201..35b8ff56a6 100644 --- a/src/curlinfo.c +++ b/src/curlinfo.c @@ -39,7 +39,7 @@ #include "fake_addrinfo.h" /* for USE_FAKE_GETADDRINFO */ #include -static const char *disabled[]={ +static const char *disabled[] = { "bindlocal: " #ifdef CURL_DISABLE_BINDLOCAL "OFF" diff --git a/src/slist_wc.c b/src/slist_wc.c index 26a91362b8..8a3ff254cc 100644 --- a/src/slist_wc.c +++ b/src/slist_wc.c @@ -32,8 +32,7 @@ * slist_wc_append() appends a string to the linked list. This function can be * used as an initialization function as well as an append function. */ -struct slist_wc *slist_wc_append(struct slist_wc *list, - const char *data) +struct slist_wc *slist_wc_append(struct slist_wc *list, const char *data) { struct curl_slist *new_item = curl_slist_append(NULL, data); diff --git a/src/terminal.c b/src/terminal.c index bb3e2ac611..fe945cfa9c 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -74,8 +74,7 @@ unsigned int get_terminal_columns(void) * Do not use +1 to get the true screen-width since writing a * character at the right edge will cause a line wrap. */ - cols = (int) - (console_info.srWindow.Right - console_info.srWindow.Left); + cols = (int)(console_info.srWindow.Right - console_info.srWindow.Left); } } #endif /* TIOCGSIZE */ diff --git a/src/tool_cb_dbg.c b/src/tool_cb_dbg.c index b858b6688e..2301bd67f5 100644 --- a/src/tool_cb_dbg.c +++ b/src/tool_cb_dbg.c @@ -103,7 +103,7 @@ int tool_debug_cb(CURL *handle, curl_infotype type, if(handle && global->traceids && !curl_easy_getinfo(handle, CURLINFO_XFER_ID, &xfer_id) && xfer_id >= 0) { if(!curl_easy_getinfo(handle, CURLINFO_CONN_ID, &conn_id) && - conn_id >= 0) { + conn_id >= 0) { curl_msnprintf(idsbuf, sizeof(idsbuf), TRC_IDS_FORMAT_IDS_2, xfer_id, conn_id); } @@ -224,7 +224,7 @@ int tool_debug_cb(CURL *handle, curl_infotype type, break; } - dump(timebuf, idsbuf, text, output, (unsigned char *) data, size, + dump(timebuf, idsbuf, text, output, (unsigned char *)data, size, global->tracetype, type); return 0; } diff --git a/src/tool_cb_hdr.c b/src/tool_cb_hdr.c index 7a5a475981..8027ea5421 100644 --- a/src/tool_cb_hdr.c +++ b/src/tool_cb_hdr.c @@ -39,17 +39,17 @@ static char *parse_filename(const char *ptr, size_t len); #ifdef _WIN32 -#define BOLD "\x1b[1m" +#define BOLD "\x1b[1m" #define BOLDOFF "\x1b[22m" #else -#define BOLD "\x1b[1m" +#define BOLD "\x1b[1m" /* Switch off bold by setting "all attributes off" since the explicit bold-off code (21) is not supported everywhere - like in the mac Terminal. */ #define BOLDOFF "\x1b[0m" /* OSC 8 hyperlink escape sequence */ -#define LINK "\x1b]8;;" -#define LINKST "\x1b\\" +#define LINK "\x1b]8;;" +#define LINKST "\x1b\\" #define LINKOFF LINK LINKST #endif @@ -76,7 +76,6 @@ fail: return rc; } - /* ** callback for CURLOPT_HEADERFUNCTION * @@ -131,7 +130,7 @@ size_t tool_header_cb(char *ptr, size_t size, size_t nmemb, void *userdata) long response = 0; curl_easy_getinfo(per->curl, CURLINFO_RESPONSE_CODE, &response); - if((response/100 != 2) && (response/100 != 3)) + if((response / 100 != 2) && (response / 100 != 3)) /* only care about etag and content-disposition headers in 2xx and 3xx responses */ ; @@ -299,7 +298,7 @@ size_t tool_header_cb(char *ptr, size_t size, size_t nmemb, void *userdata) #else if(curl_strnequal("Location", ptr, namelen)) { write_linked_location(per->curl, &value[1], cb - namelen - 1, - outs->stream); + outs->stream); } else fwrite(&value[1], cb - namelen - 1, 1, outs->stream); @@ -320,7 +319,7 @@ static char *parse_filename(const char *ptr, size_t len) char *copy; char *p; char *q; - char stop = '\0'; + char stop = '\0'; copy = memdup0(ptr, len); if(!copy) @@ -426,7 +425,7 @@ static void write_linked_location(CURL *curl, const char *location, } /* Strip the trailing end-of-line characters, normally "\r\n" */ - while(llen && (loc[llen-1] == '\n' || loc[llen-1] == '\r')) + while(llen && (loc[llen - 1] == '\n' || loc[llen - 1] == '\r')) --llen; /* CURLU makes it easy to handle the relative URL case */ diff --git a/src/tool_cb_prg.c b/src/tool_cb_prg.c index 6ae53b3ba2..ca437de501 100644 --- a/src/tool_cb_prg.c +++ b/src/tool_cb_prg.c @@ -54,14 +54,15 @@ static const int sinus[] = { 500046, 484341, 468651, 452993, 437381, 421830, 406357, 390976, 375703, 360552, 345539, 330679, 315985, 301474, 287158, 273052, 259170, 245525, 232132, 219003, 206152, 193590, 181331, 169386, 157768, 146487, 135555, - 124983, 114781, 104959, 95526, 86493, 77868, 69660, 61876, 54525, 47613, - 41147, 35135, 29581, 24491, 19871, 15724, 12056, 8868, 6166, 3951, 2225, - 990, 248, 0, 244, 982, 2212, 3933, 6144, 8842, 12025, 15690, 19832, 24448, - 29534, 35084, 41092, 47554, 54462, 61809, 69589, 77794, 86415, 95445, - 104873, 114692, 124891, 135460, 146389, 157667, 169282, 181224, 193480, - 206039, 218888, 232015, 245406, 259048, 272928, 287032, 301346, 315856, - 330548, 345407, 360419, 375568, 390841, 406221, 421693, 437243, 452854, - 468513, 484202, 499907 + 124983, 114781, 104959, 95526, 86493, 77868, 69660, 61876, 54525, + 47613, 41147, 35135, 29581, 24491, 19871, 15724, 12056, 8868, + 6166, 3951, 2225, 990, 248, 0, 244, 982, 2212, + 3933, 6144, 8842, 12025, 15690, 19832, 24448, 29534, 35084, + 41092, 47554, 54462, 61809, 69589, 77794, 86415, 95445, 104873, + 114692, 124891, 135460, 146389, 157667, 169282, 181224, 193480, 206039, + 218888, 232015, 245406, 259048, 272928, 287032, 301346, 315856, 330548, + 345407, 360419, 375568, 390841, 406221, 421693, 437243, 452854, 468513, + 484202, 499907 }; static void fly(struct ProgressData *bar, bool moved) @@ -78,13 +79,13 @@ static void fly(struct ProgressData *bar, bool moved) memcpy(&buf[bar->bar + 1], "-=O=-", 5); - pos = sinus[bar->tick%200] / (1000000 / check) + 1; + pos = sinus[bar->tick % 200] / (1000000 / check) + 1; buf[pos] = '#'; - pos = sinus[(bar->tick + 5)%200] / (1000000 / check) + 1; + pos = sinus[(bar->tick + 5) % 200] / (1000000 / check) + 1; buf[pos] = '#'; - pos = sinus[(bar->tick + 10)%200] / (1000000 / check) + 1; + pos = sinus[(bar->tick + 10) % 200] / (1000000 / check) + 1; buf[pos] = '#'; - pos = sinus[(bar->tick + 15)%200] / (1000000 / check) + 1; + pos = sinus[(bar->tick + 15) % 200] / (1000000 / check) + 1; buf[pos] = '#'; fputs(buf, bar->out); @@ -201,7 +202,7 @@ int tool_progress_cb(void *clientp, frac = (double)point / (double)total; percent = frac * 100.0; barwidth = bar->width - 7; - num = (size_t) (((double)barwidth) * frac); + num = (size_t)(((double)barwidth) * frac); if(num > MAX_BARLENGTH) num = MAX_BARLENGTH; memset(line, '#', num); diff --git a/src/tool_cb_prg.h b/src/tool_cb_prg.h index 1f005dbfc4..a8b8930616 100644 --- a/src/tool_cb_prg.h +++ b/src/tool_cb_prg.h @@ -29,12 +29,12 @@ #define CURL_PROGRESS_BAR 1 struct ProgressData { - int calls; - curl_off_t prev; + int calls; + curl_off_t prev; struct curltime prevtime; - int width; - FILE *out; /* where to write everything to */ - curl_off_t initial_size; + int width; + FILE *out; /* where to write everything to */ + curl_off_t initial_size; unsigned int tick; int bar; int barmove; diff --git a/src/tool_cb_rea.c b/src/tool_cb_rea.c index 0f2bf81771..1de2277cd0 100644 --- a/src/tool_cb_rea.c +++ b/src/tool_cb_rea.c @@ -137,7 +137,7 @@ size_t tool_read_cb(char *buffer, size_t sz, size_t nmemb, void *userdata) #endif } else { - rc = read(per->infd, buffer, sz*nmemb); + rc = read(per->infd, buffer, sz * nmemb); if(rc < 0) { if(errno == EAGAIN) { errno = 0; diff --git a/src/tool_cb_wrt.c b/src/tool_cb_wrt.c index 5696df2a59..1b76565399 100644 --- a/src/tool_cb_wrt.c +++ b/src/tool_cb_wrt.c @@ -66,7 +66,7 @@ bool tool_create_output_file(struct OutStruct *outs, while(fd == -1 && /* have not successfully opened a file */ (errno == EEXIST || errno == EISDIR) && /* because we keep having files that already exist */ - next_num < 100 /* and we have not reached the retry limit */ ) { + next_num < 100 /* and we have not reached the retry limit */) { curlx_dyn_reset(&fbuffer); if(curlx_dyn_addf(&fbuffer, "%s.%d", fname, next_num)) return FALSE; @@ -158,12 +158,12 @@ static size_t win_console(intptr_t fhnd, struct OutStruct *outs, } if(complete) { - WCHAR prefix[3] = {0}; /* UTF-16 (1-2 WCHARs) + NUL */ + WCHAR prefix[3] = { 0 }; /* UTF-16 (1-2 WCHARs) + NUL */ if(MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)outs->utf8seq, -1, prefix, CURL_ARRAYSIZE(prefix))) { DEBUGASSERT(prefix[2] == L'\0'); - if(!WriteConsoleW((HANDLE) fhnd, prefix, prefix[1] ? 2 : 1, + if(!WriteConsoleW((HANDLE)fhnd, prefix, prefix[1] ? 2 : 1, &chars_written, NULL)) { return CURL_WRITEFUNC_ERROR; } diff --git a/src/tool_cfgable.h b/src/tool_cfgable.h index 0eac0185f2..5652229d4b 100644 --- a/src/tool_cfgable.h +++ b/src/tool_cfgable.h @@ -39,10 +39,13 @@ #endif #endif -#define checkprefix(a,b) curl_strnequal(b, STRCONST(a)) +#define checkprefix(a, b) curl_strnequal(b, STRCONST(a)) -#define tool_safefree(ptr) \ - do { curlx_free((ptr)); (ptr) = NULL;} while(0) +#define tool_safefree(ptr) \ + do { \ + curlx_free(ptr); \ + (ptr) = NULL; \ + } while(0) extern struct GlobalConfig *global; diff --git a/src/tool_dirhie.c b/src/tool_dirhie.c index 31962bd1c5..058403d666 100644 --- a/src/tool_dirhie.c +++ b/src/tool_dirhie.c @@ -31,7 +31,7 @@ #include "tool_msgs.h" #if defined(_WIN32) || (defined(MSDOS) && !defined(__DJGPP__)) -# define mkdir(x,y) (mkdir)((x)) +# define mkdir(x, y) (mkdir)((x)) # ifndef F_OK # define F_OK 0 # endif @@ -112,7 +112,7 @@ CURLcode create_dir_hierarchy(const char *outfile) exist, since we would be creating it erroneously. eg if outfile is X:\foo\bar\filename then do not mkdir X: This logic takes into account unsupported drives !:, 1:, etc. */ - if(len > 1 && (outfile[1]==':')) + if(len > 1 && (outfile[1] == ':')) skip = TRUE; } #endif diff --git a/src/tool_doswin.c b/src/tool_doswin.c index ee236178c2..040792f465 100644 --- a/src/tool_doswin.c +++ b/src/tool_doswin.c @@ -63,14 +63,13 @@ /* only used by msdosify() */ static SANITIZEcode truncate_dryrun(const char *path, const size_t truncate_pos); -static SANITIZEcode msdosify(char **const sanitized, const char *file_name, +static SANITIZEcode msdosify(char ** const sanitized, const char *file_name, int flags); #endif -static SANITIZEcode rename_if_reserved_dos(char **const sanitized, +static SANITIZEcode rename_if_reserved_dos(char ** const sanitized, const char *file_name, int flags); - /* Sanitize a file or path name. @@ -96,7 +95,7 @@ is in a UNC prefixed path. Success: (SANITIZE_ERR_OK) *sanitized points to a sanitized copy of file_name. Failure: (!= SANITIZE_ERR_OK) *sanitized is NULL. */ -SANITIZEcode sanitize_file_name(char **const sanitized, const char *file_name, +SANITIZEcode sanitize_file_name(char ** const sanitized, const char *file_name, int flags) { char *p, *target; @@ -116,16 +115,16 @@ SANITIZEcode sanitize_file_name(char **const sanitized, const char *file_name, #ifndef MSDOS if(file_name[0] == '\\' && file_name[1] == '\\') /* UNC prefixed path \\ (eg \\?\C:\foo) */ - max_sanitized_len = 32767-1; + max_sanitized_len = 32767 - 1; else #endif - max_sanitized_len = PATH_MAX-1; + max_sanitized_len = PATH_MAX - 1; } else /* The maximum length of a filename. FILENAME_MAX is often the same as PATH_MAX, in other words it is 260 and does not discount the path information therefore we should not use it. */ - max_sanitized_len = (PATH_MAX-1 > 255) ? 255 : PATH_MAX-1; + max_sanitized_len = (PATH_MAX - 1 > 255) ? 255 : PATH_MAX - 1; len = strlen(file_name); if(len > max_sanitized_len) @@ -287,17 +286,18 @@ sanitize_file_name. Success: (SANITIZE_ERR_OK) *sanitized points to a sanitized copy of file_name. Failure: (!= SANITIZE_ERR_OK) *sanitized is NULL. */ -static SANITIZEcode msdosify(char **const sanitized, const char *file_name, +static SANITIZEcode msdosify(char ** const sanitized, const char *file_name, int flags) { char dos_name[PATH_MAX]; - static const char illegal_chars_dos[] = ".+, ;=[]" /* illegal in DOS */ + static const char illegal_chars_dos[] = + ".+, ;=[]" /* illegal in DOS */ "|<>/\\\":?*"; /* illegal in DOS & W95 */ static const char *illegal_chars_w95 = &illegal_chars_dos[8]; int idx, dot_idx; const char *s = file_name; char *d = dos_name; - const char *const dlimit = dos_name + sizeof(dos_name) - 1; + const char * const dlimit = dos_name + sizeof(dos_name) - 1; const char *illegal_aliens = illegal_chars_dos; size_t len = sizeof(illegal_chars_dos) - 1; @@ -309,7 +309,7 @@ static SANITIZEcode msdosify(char **const sanitized, const char *file_name, if(!file_name) return SANITIZE_ERR_BAD_ARGUMENT; - if(strlen(file_name) > PATH_MAX-1) + if(strlen(file_name) > PATH_MAX - 1) return SANITIZE_ERR_INVALID_PATH; /* Support for Windows 9X VFAT systems, when available. */ @@ -322,7 +322,8 @@ static SANITIZEcode msdosify(char **const sanitized, const char *file_name, if(s[0] >= 'A' && s[0] <= 'z' && s[1] == ':') { *d++ = *s++; *d = ((flags & SANITIZE_ALLOW_PATH)) ? ':' : '_'; - ++d; ++s; + ++d; + ++s; } for(idx = 0, dot_idx = -1; *s && d < dlimit; s++, d++) { @@ -373,7 +374,7 @@ static SANITIZEcode msdosify(char **const sanitized, const char *file_name, *d++ = 'x'; if(d == dlimit) break; - *d = 'x'; + *d = 'x'; } else { /* libg++ etc. */ @@ -381,7 +382,7 @@ static SANITIZEcode msdosify(char **const sanitized, const char *file_name, *d++ = 'x'; if(d == dlimit) break; - *d = 'x'; + *d = 'x'; } else { memcpy(d, "plus", 4); @@ -431,7 +432,7 @@ sanitize_file_name. Success: (SANITIZE_ERR_OK) *sanitized points to a sanitized copy of file_name. Failure: (!= SANITIZE_ERR_OK) *sanitized is NULL. */ -static SANITIZEcode rename_if_reserved_dos(char **const sanitized, +static SANITIZEcode rename_if_reserved_dos(char ** const sanitized, const char *file_name, int flags) { @@ -462,7 +463,7 @@ static SANITIZEcode rename_if_reserved_dos(char **const sanitized, } #endif - if(len > PATH_MAX-1) + if(len > PATH_MAX - 1) return SANITIZE_ERR_INVALID_PATH; memcpy(fname, file_name, len); @@ -511,7 +512,7 @@ static SANITIZEcode rename_if_reserved_dos(char **const sanitized, p_len = strlen(p); /* Prepend a '_' */ - if(strlen(fname) == PATH_MAX-1) + if(strlen(fname) == PATH_MAX - 1) return SANITIZE_ERR_INVALID_PATH; memmove(p + 1, p, p_len + 1); p[0] = '_'; @@ -534,7 +535,7 @@ static SANITIZEcode rename_if_reserved_dos(char **const sanitized, /* Prepend a '_' */ size_t blen = strlen(base); if(blen) { - if(strlen(fname) >= PATH_MAX-1) + if(strlen(fname) >= PATH_MAX - 1) return SANITIZE_ERR_INVALID_PATH; memmove(base + 1, base, blen + 1); base[0] = '_'; @@ -613,7 +614,7 @@ struct curl_slist *GetLoadedModulePaths(void) struct curl_slist *slist = NULL; #ifndef CURL_WINDOWS_UWP HANDLE hnd = INVALID_HANDLE_VALUE; - MODULEENTRY32 mod = {0}; + MODULEENTRY32 mod = { 0 }; mod.dwSize = sizeof(MODULEENTRY32); @@ -763,7 +764,8 @@ static DWORD WINAPI win_stdin_thread_func(void *thread_data) SOCKADDR_IN clientAddr; int clientAddrLen = sizeof(clientAddr); - curl_socket_t socket_w = CURL_ACCEPT(tdata->socket_l, (SOCKADDR*)&clientAddr, + curl_socket_t socket_w = CURL_ACCEPT(tdata->socket_l, + (SOCKADDR *)&clientAddr, &clientAddrLen); if(socket_w == CURL_SOCKET_BAD) { @@ -822,7 +824,7 @@ curl_socket_t win32_stdin_read_thread(void) do { /* Prepare handles for thread */ - tdata = (struct win_thread_data*) + tdata = (struct win_thread_data *) curlx_calloc(1, sizeof(struct win_thread_data)); if(!tdata) { errorf("curlx_calloc() error"); @@ -841,14 +843,14 @@ curl_socket_t win32_stdin_read_thread(void) selfaddr.sin_family = AF_INET; selfaddr.sin_addr.S_un.S_addr = htonl(INADDR_LOOPBACK); /* Bind to any available loopback port */ - result = bind(tdata->socket_l, (SOCKADDR*)&selfaddr, socksize); + result = bind(tdata->socket_l, (SOCKADDR *)&selfaddr, socksize); if(result == SOCKET_ERROR) { errorf("bind error: %d", SOCKERRNO); break; } /* Bind to any available loopback port */ - result = getsockname(tdata->socket_l, (SOCKADDR*)&selfaddr, &socksize); + result = getsockname(tdata->socket_l, (SOCKADDR *)&selfaddr, &socksize); if(result == SOCKET_ERROR) { errorf("getsockname error: %d", SOCKERRNO); break; @@ -892,7 +894,7 @@ curl_socket_t win32_stdin_read_thread(void) /* Hard close the socket on closesocket() */ setsockopt(socket_r, SOL_SOCKET, SO_DONTLINGER, 0, 0); - if(connect(socket_r, (SOCKADDR*)&selfaddr, socksize) == SOCKET_ERROR) { + if(connect(socket_r, (SOCKADDR *)&selfaddr, socksize) == SOCKET_ERROR) { errorf("connect error: %d", SOCKERRNO); break; } diff --git a/src/tool_doswin.h b/src/tool_doswin.h index 01500bdbf7..75f4bacdb8 100644 --- a/src/tool_doswin.h +++ b/src/tool_doswin.h @@ -27,8 +27,8 @@ #if defined(_WIN32) || defined(MSDOS) -#define SANITIZE_ALLOW_PATH (1<<1) /* Allow path separators and colons */ -#define SANITIZE_ALLOW_RESERVED (1<<2) /* Allow reserved device names */ +#define SANITIZE_ALLOW_PATH (1 << 1) /* Allow path separators and colons */ +#define SANITIZE_ALLOW_RESERVED (1 << 2) /* Allow reserved device names */ typedef enum { SANITIZE_ERR_OK = 0, /* 0 - OK */ @@ -38,7 +38,7 @@ typedef enum { SANITIZE_ERR_LAST /* never use! */ } SANITIZEcode; -SANITIZEcode sanitize_file_name(char **const sanitized, const char *file_name, +SANITIZEcode sanitize_file_name(char ** const sanitized, const char *file_name, int flags); #ifdef __DJGPP__ diff --git a/src/tool_easysrc.c b/src/tool_easysrc.c index 4747f6dfe6..ba9d345645 100644 --- a/src/tool_easysrc.c +++ b/src/tool_easysrc.c @@ -41,7 +41,7 @@ struct slist_wc *easysrc_clean; /* Clean up allocated data */ int easysrc_mime_count; int easysrc_slist_count; -static const char *const srchead[]={ +static const char * const srchead[] = { "/********* Sample code generated by the curl command line tool **********", " * All curl_easy_setopt() options are documented at:", " * https://curl.se/libcurl/c/curl_easy_setopt.html", @@ -57,7 +57,7 @@ static const char *const srchead[]={ /* easysrc_decl declarations come here */ /* easysrc_data initialization come here */ /* easysrc_code statements come here */ -static const char *const srchard[]={ +static const char * const srchard[] = { "/* Here is a list of options the curl code used that cannot get generated", " as source easily. You may choose to either not use them or implement", " them yourself.", diff --git a/src/tool_filetime.c b/src/tool_filetime.c index 041cc4dbd6..2d362b4bb7 100644 --- a/src/tool_filetime.c +++ b/src/tool_filetime.c @@ -51,8 +51,8 @@ int getfiletime(const char *filename, curl_off_t *stamp) if(hfile != INVALID_HANDLE_VALUE) { FILETIME ft; if(GetFileTime(hfile, NULL, NULL, &ft)) { - curl_off_t converted = (curl_off_t)ft.dwLowDateTime - | ((curl_off_t)ft.dwHighDateTime) << 32; + curl_off_t converted = (curl_off_t)ft.dwLowDateTime | + ((curl_off_t)ft.dwHighDateTime) << 32; if(converted < 116444736000000000) warnf("Failed to get filetime: underflow"); diff --git a/src/tool_filetime.h b/src/tool_filetime.h index c3663617b5..fedb7a1957 100644 --- a/src/tool_filetime.h +++ b/src/tool_filetime.h @@ -31,7 +31,7 @@ int getfiletime(const char *filename, curl_off_t *stamp); (defined(_WIN32) && (SIZEOF_CURL_OFF_T >= 8)) void setfiletime(curl_off_t filetime, const char *filename); #else -#define setfiletime(a,b,c) tool_nop_stmt +#define setfiletime(a, b, c) tool_nop_stmt #endif #endif /* HEADER_CURL_TOOL_FILETIME_H */ diff --git a/src/tool_findfile.c b/src/tool_findfile.c index 4dbd7bccb4..c962eb86b8 100644 --- a/src/tool_findfile.c +++ b/src/tool_findfile.c @@ -51,7 +51,7 @@ static const struct finder conf_list[] = { #ifdef _WIN32 { "USERPROFILE", NULL, FALSE }, { "APPDATA", NULL, FALSE }, - { "USERPROFILE", "\\Application Data", FALSE}, + { "USERPROFILE", "\\Application Data", FALSE }, #endif /* these are for .curlrc if XDG_CONFIG_HOME is not defined */ { "CURL_HOME", "/.config", TRUE }, diff --git a/src/tool_formparse.c b/src/tool_formparse.c index 181abf7b86..543f817cc3 100644 --- a/src/tool_formparse.c +++ b/src/tool_formparse.c @@ -86,8 +86,8 @@ static curl_off_t uztoso(size_t uznum) # pragma warning(disable:4310) /* cast truncates constant value */ #endif - DEBUGASSERT(uznum <= (size_t) CURL_MASK_SCOFFT); - return (curl_off_t)(uznum & (size_t) CURL_MASK_SCOFFT); + DEBUGASSERT(uznum <= (size_t)CURL_MASK_SCOFFT); + return (curl_off_t)(uznum & (size_t)CURL_MASK_SCOFFT); #if defined(__INTEL_COMPILER) || defined(_MSC_VER) # pragma warning(pop) @@ -192,12 +192,11 @@ void tool_mime_free(struct tool_mime *mime) } } - /* Mime part callbacks for stdin. */ size_t tool_mime_stdin_read(char *buffer, size_t size, size_t nitems, void *arg) { - struct tool_mime *sip = (struct tool_mime *) arg; + struct tool_mime *sip = (struct tool_mime *)arg; curl_off_t bytesleft; (void)size; /* Always 1: ignored. */ @@ -230,7 +229,7 @@ size_t tool_mime_stdin_read(char *buffer, int tool_mime_stdin_seek(void *instream, curl_off_t offset, int whence) { - struct tool_mime *sip = (struct tool_mime *) instream; + struct tool_mime *sip = (struct tool_mime *)instream; switch(whence) { case SEEK_CUR: @@ -296,8 +295,8 @@ static CURLcode tool2curlparts(CURL *curl, struct tool_mime *m, FALLTHROUGH(); case TOOLMIME_STDINDATA: ret = curl_mime_data_cb(part, m->size, - (curl_read_callback) tool_mime_stdin_read, - (curl_seek_callback) tool_mime_stdin_seek, + (curl_read_callback)tool_mime_stdin_read, + (curl_seek_callback)tool_mime_stdin_seek, NULL, m); break; @@ -372,8 +371,7 @@ static char *get_param_word(char **str, char **end_pos, char endchar) if(*ptr == '\\' && (ptr[1] == '\\' || ptr[1] == '"')) ++ptr; *ptr2++ = *ptr++; - } - while(ptr < *end_pos); + } while(ptr < *end_pos); *end_pos = ptr2; } ++ptr; @@ -428,7 +426,7 @@ static int read_field_headers(FILE *fp, struct curl_slist **pheaders) else if(ptr[0] == ' ') /* a continuation from the line before */ folded = TRUE; /* trim off trailing CRLFs and whitespaces */ - while(len && (ISNEWLINE(ptr[len -1]) || ISBLANK(ptr[len - 1]))) + while(len && (ISNEWLINE(ptr[len - 1]) || ISBLANK(ptr[len - 1]))) len--; if(!len) @@ -658,7 +656,6 @@ static int get_param_part(char endchar, return sep & 0xFF; } - /*************************************************************************** * * formparse() @@ -706,13 +703,13 @@ static int get_param_part(char endchar, * ***************************************************************************/ -#define SET_TOOL_MIME_PTR(m, field) \ - do { \ - if(field) { \ - (m)->field = curlx_strdup(field); \ - if(!(m)->field) \ - goto fail; \ - } \ +#define SET_TOOL_MIME_PTR(m, field) \ + do { \ + if(field) { \ + (m)->field = curlx_strdup(field); \ + if(!(m)->field) \ + goto fail; \ + } \ } while(0) int formparse(const char *input, @@ -811,9 +808,8 @@ int formparse(const char *input, part->headers = headers; headers = NULL; if(res == CURLE_READ_ERROR) { - /* An error occurred while reading stdin: if read has started, - issue the error now. Else, delay it until processed by - libcurl. */ + /* An error occurred while reading stdin: if read has started, + issue the error now. Else, delay it until processed by libcurl. */ if(part->size > 0) { warnf("error while reading standard input"); goto fail; @@ -838,8 +834,7 @@ int formparse(const char *input, if(sep < 0) goto fail; - part = tool_mime_new_filedata(*mimecurrent, data, FALSE, - &res); + part = tool_mime_new_filedata(*mimecurrent, data, FALSE, &res); if(!part) goto fail; part->headers = headers; @@ -879,7 +874,7 @@ int formparse(const char *input, SET_TOOL_MIME_PTR(part, encoder); if(sep) { - *contp = (char) sep; + *contp = (char)sep; warnf("garbage at end of field specification: %s", contp); } } diff --git a/src/tool_getparam.c b/src/tool_getparam.c index 7afb0c5fc0..89385af844 100644 --- a/src/tool_getparam.c +++ b/src/tool_getparam.c @@ -39,7 +39,7 @@ #include "var.h" #define ALLOW_BLANK TRUE -#define DENY_BLANK FALSE +#define DENY_BLANK FALSE static ParameterError getstr(char **str, const char *val, bool allowblank) { @@ -432,22 +432,22 @@ ParameterError parse_cert_parameter(const char *cert_parameter, case '\\': param_place++; switch(*param_place) { - case '\0': - *certname_place++ = '\\'; - break; - case '\\': - *certname_place++ = '\\'; - param_place++; - break; - case ':': - *certname_place++ = ':'; - param_place++; - break; - default: - *certname_place++ = '\\'; - *certname_place++ = *param_place; - param_place++; - break; + case '\0': + *certname_place++ = '\\'; + break; + case '\\': + *certname_place++ = '\\'; + param_place++; + break; + case ':': + *certname_place++ = ':'; + param_place++; + break; + default: + *certname_place++ = '\\'; + *certname_place++ = *param_place; + param_place++; + break; } break; case ':': @@ -459,7 +459,7 @@ ParameterError parse_cert_parameter(const char *cert_parameter, #ifdef _WIN32 if((param_place == &cert_parameter[1]) && (cert_parameter[2] == '\\' || cert_parameter[2] == '/') && - (ISALPHA(cert_parameter[0])) ) { + (ISALPHA(cert_parameter[0]))) { /* colon in the second column, followed by a backslash, and the first character is an alphabetic letter: @@ -503,7 +503,7 @@ static size_t replace_url_encoded_space_by_plus(char *url) url[new_index] = '+'; orig_index += 3; } - else{ + else { if(new_index != orig_index) { url[new_index] = url[orig_index]; } @@ -517,8 +517,8 @@ static size_t replace_url_encoded_space_by_plus(char *url) return new_index; /* new size */ } -static ParameterError -GetFileAndPassword(const char *nextarg, char **file, char **password) +static ParameterError GetFileAndPassword(const char *nextarg, char **file, + char **password) { char *certname, *passphrase; ParameterError err; @@ -558,15 +558,15 @@ static ParameterError GetSizeParameter(const char *arg, switch(*unit) { case 'G': case 'g': - if(value > (CURL_OFF_T_MAX / (1024*1024*1024))) + if(value > (CURL_OFF_T_MAX / (1024 * 1024 * 1024))) return PARAM_NUMBER_TOO_LARGE; - value *= 1024*1024*1024; + value *= 1024 * 1024 * 1024; break; case 'M': case 'm': - if(value > (CURL_OFF_T_MAX / (1024*1024))) + if(value > (CURL_OFF_T_MAX / (1024 * 1024))) return PARAM_NUMBER_TOO_LARGE; - value *= 1024*1024; + value *= 1024 * 1024; break; case 'K': case 'k': @@ -602,7 +602,7 @@ static void cleanarg(char *str) #endif /* the maximum size we allow the dynbuf generated string */ -#define MAX_DATAURLENCODE (500*1024*1024) +#define MAX_DATAURLENCODE (500 * 1024 * 1024) /* --data-urlencode */ static ParameterError data_urlencode(const char *nextarg, @@ -706,8 +706,7 @@ error: return err; } -static void sethttpver(struct OperationConfig *config, - long httpversion) +static void sethttpver(struct OperationConfig *config, long httpversion) { if(config->httpversion && (config->httpversion != httpversion)) @@ -732,20 +731,20 @@ static CURLcode set_trace_config(const char *token) len = strlen(token); switch(*token) { - case '-': - toggle = FALSE; - name = token + 1; - len--; - break; - case '+': - toggle = TRUE; - name = token + 1; - len--; - break; - default: - toggle = TRUE; - name = token; - break; + case '-': + toggle = FALSE; + name = token + 1; + len--; + break; + case '+': + toggle = TRUE; + name = token + 1; + len--; + break; + default: + toggle = TRUE; + name = token; + break; } if((len == 3) && curl_strnequal(name, "all", 3)) { @@ -816,37 +815,37 @@ struct TOSEntry { }; static const struct TOSEntry tos_entries[] = { - {"AF11", 0x28}, - {"AF12", 0x30}, - {"AF13", 0x38}, - {"AF21", 0x48}, - {"AF22", 0x50}, - {"AF23", 0x58}, - {"AF31", 0x68}, - {"AF32", 0x70}, - {"AF33", 0x78}, - {"AF41", 0x88}, - {"AF42", 0x90}, - {"AF43", 0x98}, - {"CE", 0x03}, - {"CS0", 0x00}, - {"CS1", 0x20}, - {"CS2", 0x40}, - {"CS3", 0x60}, - {"CS4", 0x80}, - {"CS5", 0xa0}, - {"CS6", 0xc0}, - {"CS7", 0xe0}, - {"ECT0", 0x02}, - {"ECT1", 0x01}, - {"EF", 0xb8}, - {"LE", 0x04}, - {"LOWCOST", 0x02}, - {"LOWDELAY", 0x10}, - {"MINCOST", 0x02}, - {"RELIABILITY", 0x04}, - {"THROUGHPUT", 0x08}, - {"VOICE-ADMIT", 0xb0} + { "AF11", 0x28 }, + { "AF12", 0x30 }, + { "AF13", 0x38 }, + { "AF21", 0x48 }, + { "AF22", 0x50 }, + { "AF23", 0x58 }, + { "AF31", 0x68 }, + { "AF32", 0x70 }, + { "AF33", 0x78 }, + { "AF41", 0x88 }, + { "AF42", 0x90 }, + { "AF43", 0x98 }, + { "CE", 0x03 }, + { "CS0", 0x00 }, + { "CS1", 0x20 }, + { "CS2", 0x40 }, + { "CS3", 0x60 }, + { "CS4", 0x80 }, + { "CS5", 0xa0 }, + { "CS6", 0xc0 }, + { "CS7", 0xe0 }, + { "ECT0", 0x02 }, + { "ECT1", 0x01 }, + { "EF", 0xb8 }, + { "LE", 0x04 }, + { "LOWCOST", 0x02 }, + { "LOWDELAY", 0x10 }, + { "MINCOST", 0x02 }, + { "RELIABILITY", 0x04 }, + { "THROUGHPUT", 0x08 }, + { "VOICE-ADMIT", 0xb0 } }; static int find_tos(const void *a, const void *b) @@ -986,9 +985,9 @@ static ParameterError set_rate(const char *nextarg) const char *div = strchr(nextarg, '/'); char number[26]; long denominator; - long numerator = 60*60*1000; /* default per hour */ + long numerator = 60 * 60 * 1000; /* default per hour */ size_t numlen = div ? (size_t)(div - nextarg) : strlen(nextarg); - if(numlen > sizeof(number) -1) + if(numlen > sizeof(number) - 1) return PARAM_NUMBER_TOO_LARGE; memcpy(number, nextarg, numlen); @@ -1012,12 +1011,12 @@ static ParameterError set_rate(const char *nextarg) numerator = 1000; break; case 'm': /* per minute */ - numerator = 60*1000; + numerator = 60 * 1000; break; case 'h': /* per hour */ break; case 'd': /* per day */ - numerator = 24*60*60*1000; + numerator = 24 * 60 * 60 * 1000; break; default: errorf("unsupported --rate unit"); @@ -1040,7 +1039,7 @@ static ParameterError set_rate(const char *nextarg) else if(denominator > numerator) err = PARAM_NUMBER_TOO_LARGE; else - global->ms_per_transfer = numerator/denominator; + global->ms_per_transfer = numerator / denominator; return err; } @@ -1133,7 +1132,6 @@ static ParameterError parse_url(struct OperationConfig *config, return add_url(config, nextarg, FALSE); } - static ParameterError parse_localport(struct OperationConfig *config, const char *nextarg) { @@ -1163,7 +1161,7 @@ static ParameterError parse_localport(struct OperationConfig *config, else { if(str2unummax(&config->localportrange, pp, 65535)) return PARAM_BAD_USE; - config->localportrange -= (config->localport-1); + config->localportrange -= (config->localport - 1); if(config->localportrange < 1) return PARAM_BAD_USE; } @@ -1237,7 +1235,7 @@ static ParameterError parse_ech(struct OperationConfig *config, curlx_fclose(file); if(err) return err; - config->ech_config = curl_maprintf("ecl:%s",tmpcfg); + config->ech_config = curl_maprintf("ecl:%s", tmpcfg); curlx_free(tmpcfg); if(!config->ech_config) return PARAM_NO_MEM; @@ -1268,7 +1266,7 @@ static ParameterError parse_header(struct OperationConfig *config, else { struct dynbuf line; bool error = FALSE; - curlx_dyn_init(&line, 1024*100); + curlx_dyn_init(&line, 1024 * 100); while(my_get_line(file, &line, &error)) { const char *ptr = curlx_dyn_ptr(&line); err = add2list(cmd == C_PROXY_HEADER ? /* --proxy-header? */ @@ -1287,7 +1285,7 @@ static ParameterError parse_header(struct OperationConfig *config, else { if(!strchr(nextarg, ':') && !strchr(nextarg, ';')) { warnf("The provided %s header '%s' does not look like a header?", - (cmd == C_PROXY_HEADER) ? "proxy": "HTTP", nextarg); + (cmd == C_PROXY_HEADER) ? "proxy" : "HTTP", nextarg); } if(cmd == C_PROXY_HEADER) /* --proxy-header */ err = add2list(&config->proxyheaders, nextarg); @@ -1629,12 +1627,12 @@ struct flagmap { }; static const struct flagmap flag_table[] = { - {"answered", 8, CURLULFLAG_ANSWERED}, - {"deleted", 7, CURLULFLAG_DELETED}, - {"draft", 5, CURLULFLAG_DRAFT}, - {"flagged", 7, CURLULFLAG_FLAGGED}, - {"seen", 4, CURLULFLAG_SEEN}, - {NULL, 0, 0} + { "answered", 8, CURLULFLAG_ANSWERED }, + { "deleted", 7, CURLULFLAG_DELETED }, + { "draft", 5, CURLULFLAG_DRAFT }, + { "flagged", 7, CURLULFLAG_FLAGGED }, + { "seen", 4, CURLULFLAG_SEEN }, + { NULL, 0, 0 } }; static ParameterError parse_upload_flags(struct OperationConfig *config, @@ -2902,7 +2900,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ p = word; /* is there an '=' ? */ if(!curlx_str_until(&p, &out, MAX_OPTION_LEN, '=') && - !curlx_str_single(&p, '=') ) { + !curlx_str_single(&p, '=')) { /* there is an equal sign */ char tempword[MAX_OPTION_LEN + 1]; memcpy(tempword, curlx_str(&out), curlx_strlen(&out)); diff --git a/src/tool_getparam.h b/src/tool_getparam.h index d4812f6ceb..10b2351874 100644 --- a/src/tool_getparam.h +++ b/src/tool_getparam.h @@ -319,12 +319,12 @@ typedef enum { #define ARG_FILE 3 /* requires an argument, usually a filename */ #define ARG_TYPEMASK 0x03 -#define ARGTYPE(x) ((x) & ARG_TYPEMASK) +#define ARGTYPE(x) ((x) & ARG_TYPEMASK) -#define ARG_DEPR 0x10 /* deprecated option */ +#define ARG_DEPR 0x10 /* deprecated option */ #define ARG_CLEAR 0x20 /* clear cmdline argument */ -#define ARG_TLS 0x40 /* requires TLS support */ -#define ARG_NO 0x80 /* set if the option is documented as --no-* */ +#define ARG_TLS 0x40 /* requires TLS support */ +#define ARG_NO 0x80 /* set if the option is documented as --no-* */ struct LongShort { const char *lname; /* long name option */ @@ -383,7 +383,7 @@ ParameterError parse_args(int argc, argv_item_t argv[]); #define convert_UTF8_to_tchar(ptr) curlx_convert_UTF8_to_wchar((ptr)) #define convert_tchar_to_UTF8(ptr) curlx_convert_wchar_to_UTF8((ptr)) -#define unicodefree(ptr) curlx_unicodefree(ptr) +#define unicodefree(ptr) curlx_unicodefree(ptr) #else diff --git a/src/tool_getpass.c b/src/tool_getpass.c index b0316510bc..f2423790fe 100644 --- a/src/tool_getpass.c +++ b/src/tool_getpass.c @@ -98,17 +98,16 @@ char *getpass_r(const char *prompt, char *buffer, size_t buflen) buffer[i] = '\0'; break; } - else - if(buffer[i] == '\b') - /* remove this letter and if this is not the first key, remove the + else if(buffer[i] == '\b') + /* remove this letter and if this is not the first key, remove the previous one as well */ - i = i - (i >= 1 ? 2 : 1); + i = i - (i >= 1 ? 2 : 1); } /* since echo is disabled, print a newline */ fputs("\n", tool_stderr); /* if user did not hit ENTER, terminate buffer */ if(i == buflen) - buffer[buflen-1] = '\0'; + buffer[buflen - 1] = '\0'; return buffer; /* we always return success */ } diff --git a/src/tool_help.c b/src/tool_help.c index bbe8dc68a4..7355d2a782 100644 --- a/src/tool_help.c +++ b/src/tool_help.c @@ -41,31 +41,31 @@ struct category_descriptors { static const struct category_descriptors categories[] = { /* important is left out because it is the default help page */ - {"auth", "Authentication methods", CURLHELP_AUTH}, - {"connection", "Manage connections", CURLHELP_CONNECTION}, - {"curl", "The command line tool itself", CURLHELP_CURL}, - {"deprecated", "Legacy", CURLHELP_DEPRECATED}, - {"dns", "Names and resolving", CURLHELP_DNS}, - {"file", "FILE protocol", CURLHELP_FILE}, - {"ftp", "FTP protocol", CURLHELP_FTP}, - {"global", "Global options", CURLHELP_GLOBAL}, - {"http", "HTTP and HTTPS protocol", CURLHELP_HTTP}, - {"imap", "IMAP protocol", CURLHELP_IMAP}, - {"ldap", "LDAP protocol", CURLHELP_LDAP}, - {"output", "File system output", CURLHELP_OUTPUT}, - {"pop3", "POP3 protocol", CURLHELP_POP3}, - {"post", "HTTP POST specific", CURLHELP_POST}, - {"proxy", "Options for proxies", CURLHELP_PROXY}, - {"scp", "SCP protocol", CURLHELP_SCP}, - {"sftp", "SFTP protocol", CURLHELP_SFTP}, - {"smtp", "SMTP protocol", CURLHELP_SMTP}, - {"ssh", "SSH protocol", CURLHELP_SSH}, - {"telnet", "TELNET protocol", CURLHELP_TELNET}, - {"tftp", "TFTP protocol", CURLHELP_TFTP}, - {"timeout", "Timeouts and delays", CURLHELP_TIMEOUT}, - {"tls", "TLS/SSL related", CURLHELP_TLS}, - {"upload", "Upload, sending data", CURLHELP_UPLOAD}, - {"verbose", "Tracing, logging etc", CURLHELP_VERBOSE} + { "auth", "Authentication methods", CURLHELP_AUTH }, + { "connection", "Manage connections", CURLHELP_CONNECTION }, + { "curl", "The command line tool itself", CURLHELP_CURL }, + { "deprecated", "Legacy", CURLHELP_DEPRECATED }, + { "dns", "Names and resolving", CURLHELP_DNS }, + { "file", "FILE protocol", CURLHELP_FILE }, + { "ftp", "FTP protocol", CURLHELP_FTP }, + { "global", "Global options", CURLHELP_GLOBAL }, + { "http", "HTTP and HTTPS protocol", CURLHELP_HTTP }, + { "imap", "IMAP protocol", CURLHELP_IMAP }, + { "ldap", "LDAP protocol", CURLHELP_LDAP }, + { "output", "File system output", CURLHELP_OUTPUT }, + { "pop3", "POP3 protocol", CURLHELP_POP3 }, + { "post", "HTTP POST specific", CURLHELP_POST }, + { "proxy", "Options for proxies", CURLHELP_PROXY }, + { "scp", "SCP protocol", CURLHELP_SCP }, + { "sftp", "SFTP protocol", CURLHELP_SFTP }, + { "smtp", "SMTP protocol", CURLHELP_SMTP }, + { "ssh", "SSH protocol", CURLHELP_SSH }, + { "telnet", "TELNET protocol", CURLHELP_TELNET }, + { "tftp", "TFTP protocol", CURLHELP_TFTP }, + { "timeout", "Timeouts and delays", CURLHELP_TIMEOUT }, + { "tls", "TLS/SSL related", CURLHELP_TLS }, + { "upload", "Upload, sending data", CURLHELP_UPLOAD }, + { "verbose", "Tracing, logging etc", CURLHELP_VERBOSE } }; static void print_category(unsigned int category, unsigned int cols) @@ -228,7 +228,8 @@ void tool_help(const char *category) unsigned int cols = get_terminal_columns(); /* If no category was provided */ if(!category) { - const char *category_note = "\nThis is not the full help; this " + const char *category_note = + "\nThis is not the full help; this " "menu is split into categories.\nUse \"--help category\" to get " "an overview of all categories, which are:"; const char *category_note2 = @@ -303,7 +304,7 @@ void tool_help(const char *category) static bool is_debug(void) { - const char *const *builtin; + const char * const *builtin; for(builtin = feature_names; *builtin; ++builtin) if(curl_strequal("debug", *builtin)) return TRUE; @@ -312,7 +313,7 @@ static bool is_debug(void) void tool_version_info(void) { - const char *const *builtin; + const char * const *builtin; if(is_debug()) curl_mfprintf(tool_stderr, "WARNING: this libcurl is Debug-enabled, " "do not use in production\n\n"); diff --git a/src/tool_helpers.c b/src/tool_helpers.c index 2e308a248f..c32e1bbaab 100644 --- a/src/tool_helpers.c +++ b/src/tool_helpers.c @@ -75,7 +75,7 @@ const char *param2text(ParameterError error) int SetHTTPrequest(HttpReq req, HttpReq *store) { /* this mirrors the HttpReq enum in tool_sdecls.h */ - const char *reqname[]= { + const char *reqname[] = { "", /* unspec */ "GET (-G, --get)", "HEAD (-I, --head)", @@ -99,7 +99,7 @@ int SetHTTPrequest(HttpReq req, HttpReq *store) void customrequest_helper(HttpReq req, char *method) { /* this mirrors the HttpReq enum in tool_sdecls.h */ - const char *dflt[]= { + const char *dflt[] = { "GET", "GET", "HEAD", diff --git a/src/tool_ipfs.c b/src/tool_ipfs.c index c1d27fc99b..25bff3152f 100644 --- a/src/tool_ipfs.c +++ b/src/tool_ipfs.c @@ -157,8 +157,8 @@ CURLcode ipfs_url_rewrite(CURLU *uh, const char *protocol, char **url, } /* check for unsupported gateway parts */ - if(curl_url_get(gatewayurl, CURLUPART_QUERY, &gwquery, 0) - != CURLUE_NO_QUERY) { + if(curl_url_get(gatewayurl, CURLUPART_QUERY, &gwquery, 0) != + CURLUE_NO_QUERY) { result = CURLE_URL_MALFORMAT; goto clean; } diff --git a/src/tool_libinfo.c b/src/tool_libinfo.c index 1687005481..18e0d6964e 100644 --- a/src/tool_libinfo.c +++ b/src/tool_libinfo.c @@ -137,7 +137,7 @@ size_t feature_count; CURLcode get_libcurl_info(void) { CURLcode result = CURLE_OK; - const char *const *builtin; + const char * const *builtin; /* Pointer to libcurl's runtime version information */ curlinfo = curl_version_info(CURLVERSION_NOW); diff --git a/src/tool_main.c b/src/tool_main.c index eb15ae740d..3784f280f6 100644 --- a/src/tool_main.c +++ b/src/tool_main.c @@ -109,7 +109,7 @@ static void memory_tracking_init(void) /* use the value as filename */ char fname[512]; if(strlen(env) >= sizeof(fname)) - env[sizeof(fname)-1] = '\0'; + env[sizeof(fname) - 1] = '\0'; strcpy(fname, env); curl_free(env); curl_dbg_memdebug(fname); diff --git a/src/tool_main.h b/src/tool_main.h index 53ee9a3702..7578616320 100644 --- a/src/tool_main.h +++ b/src/tool_main.h @@ -30,10 +30,10 @@ #define RETRY_SLEEP_DEFAULT 1000L /* ms */ #define RETRY_SLEEP_MAX 600000L /* ms == 10 minutes */ -#define MAX_PARALLEL 65535 +#define MAX_PARALLEL 65535 #define PARALLEL_DEFAULT 50 -#define MAX_PARALLEL_HOST 65535 +#define MAX_PARALLEL_HOST 65535 #define PARALLEL_HOST_DEFAULT 0 /* means not used */ #endif /* HEADER_CURL_TOOL_MAIN_H */ diff --git a/src/tool_msgs.c b/src/tool_msgs.c index b385f75cf8..b4fc1fb6fd 100644 --- a/src/tool_msgs.c +++ b/src/tool_msgs.c @@ -28,8 +28,8 @@ #include "tool_cb_prg.h" #include "terminal.h" -#define WARN_PREFIX "Warning: " -#define NOTE_PREFIX "Note: " +#define WARN_PREFIX "Warning: " +#define NOTE_PREFIX "Note: " #define ERROR_PREFIX "curl: " static void voutf(const char *prefix, @@ -53,7 +53,7 @@ static void voutf(const char *prefix, fputs(prefix, tool_stderr); if(len > width) { - size_t cut = width-1; + size_t cut = width - 1; while(!ISBLANK(ptr[cut]) && cut) { cut--; @@ -61,7 +61,7 @@ static void voutf(const char *prefix, if(cut == 0) /* not a single cutting position was found, just cut it at the max text width then! */ - cut = width-1; + cut = width - 1; (void)fwrite(ptr, cut + 1, 1, tool_stderr); fputs("\n", tool_stderr); @@ -121,9 +121,9 @@ void helpf(const char *fmt, ...) } curl_mfprintf(tool_stderr, "curl: try 'curl --help' " #ifdef USE_MANUAL - "or 'curl --manual' " + "or 'curl --manual' " #endif - "for more information\n"); + "for more information\n"); } /* diff --git a/src/tool_msgs.h b/src/tool_msgs.h index 99a980234a..be75d95593 100644 --- a/src/tool_msgs.h +++ b/src/tool_msgs.h @@ -26,13 +26,9 @@ #include "tool_setup.h" #include "tool_cfgable.h" -void warnf(const char *fmt, ...) - CURL_PRINTF(1, 2); -void notef(const char *fmt, ...) - CURL_PRINTF(1, 2); -void helpf(const char *fmt, ...) - CURL_PRINTF(1, 2); -void errorf(const char *fmt, ...) - CURL_PRINTF(1, 2); +void warnf(const char *fmt, ...) CURL_PRINTF(1, 2); +void notef(const char *fmt, ...) CURL_PRINTF(1, 2); +void helpf(const char *fmt, ...) CURL_PRINTF(1, 2); +void errorf(const char *fmt, ...) CURL_PRINTF(1, 2); #endif /* HEADER_CURL_TOOL_MSGS_H */ diff --git a/src/tool_operate.c b/src/tool_operate.c index 71d29af8d8..25c1473b96 100644 --- a/src/tool_operate.c +++ b/src/tool_operate.c @@ -155,7 +155,7 @@ static curl_off_t vms_realfilesize(const char *name, char buffer[8192]; curl_off_t count; int ret_stat; - FILE * file; + FILE *file; /* !checksrc! disable FOPENMODE 1 */ file = curlx_fopen(name, "r"); /* VMS */ @@ -180,8 +180,7 @@ static curl_off_t vms_realfilesize(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: @@ -451,7 +450,7 @@ static CURLcode retrycheck(struct OperationConfig *config, if(retry) { long sleeptime = 0; curl_off_t retry_after = 0; - static const char * const m[]={ + static const char * const m[] = { NULL, "(retrying all errors)", ": timeout", @@ -465,7 +464,7 @@ static CURLcode retrycheck(struct OperationConfig *config, curl_easy_getinfo(curl, CURLINFO_RETRY_AFTER, &retry_after); if(retry_after) { /* store in a 'long', make sure it does not overflow */ - if(retry_after > LONG_MAX/1000) + if(retry_after > LONG_MAX / 1000) sleeptime = LONG_MAX; else if((retry_after * 1000) > sleeptime) sleeptime = (long)retry_after * 1000; /* milliseconds */ @@ -500,10 +499,10 @@ static CURLcode retrycheck(struct OperationConfig *config, warnf("Problem %s. " "Will retry in %ld%s%.*ld second%s. " "%ld retr%s left.", - m[retry], sleeptime/1000L, - (sleeptime%1000L ? "." : ""), - (sleeptime%1000L ? 3 : 0), - sleeptime%1000L, + m[retry], sleeptime / 1000L, + (sleeptime % 1000L ? "." : ""), + (sleeptime % 1000L ? 3 : 0), + sleeptime % 1000L, (sleeptime == 1000L ? "" : "s"), per->retry_remaining, (per->retry_remaining > 1 ? "ies" : "y")); @@ -547,8 +546,7 @@ static CURLcode retrycheck(struct OperationConfig *config, outs->init += outs->bytes; outs->bytes = 0; config->resume_from = outs->init; - curl_easy_setopt(curl, CURLOPT_RESUME_FROM_LARGE, - config->resume_from); + curl_easy_setopt(curl, CURLOPT_RESUME_FROM_LARGE, config->resume_from); } } @@ -562,8 +560,7 @@ static CURLcode retrycheck(struct OperationConfig *config, int rc; /* We have written data to an output file, we truncate file */ fflush(outs->stream); - notef("Throwing away %" CURL_FORMAT_CURL_OFF_T " bytes", - outs->bytes); + notef("Throwing away %" CURL_FORMAT_CURL_OFF_T " bytes", outs->bytes); /* truncate file at the position where we started appending */ #if defined(HAVE_FTRUNCATE) && !defined(__DJGPP__) && !defined(__AMIGA__) if(ftruncate(fileno(outs->stream), outs->init)) { @@ -595,7 +592,6 @@ static CURLcode retrycheck(struct OperationConfig *config, return result; } - /* * Call this after a transfer has completed. */ @@ -706,7 +702,7 @@ static CURLcode post_per_transfer(struct per_transfer *per, if(per->retry_remaining && (!config->retry_maxtime_ms || (curlx_timediff_ms(curlx_now(), per->retrystart) < - config->retry_maxtime_ms)) ) { + config->retry_maxtime_ms))) { result = retrycheck(config, per, result, retryp, delay); if(!result && *retryp) return CURLE_OK; /* retry! */ @@ -735,8 +731,7 @@ static CURLcode post_per_transfer(struct per_transfer *per, warnf("Failed removing: %s", outs->filename); } else - warnf("Skipping removal; not a regular file: %s", - outs->filename); + warnf("Skipping removal; not a regular file: %s", outs->filename); } } @@ -825,8 +820,7 @@ static CURLcode append2query(struct OperationConfig *config, CURLU *uh = curl_url(); if(uh) { CURLUcode uerr; - uerr = curl_url_set(uh, CURLUPART_URL, per->url, - CURLU_GUESS_SCHEME); + uerr = curl_url_set(uh, CURLUPART_URL, per->url, CURLU_GUESS_SCHEME); if(uerr) { result = urlerr_cvt(uerr); errorf("(%d) Could not parse the URL, " @@ -837,8 +831,7 @@ static CURLcode append2query(struct OperationConfig *config, char *updated = NULL; uerr = curl_url_set(uh, CURLUPART_QUERY, q, CURLU_APPENDQUERY); if(!uerr) - uerr = curl_url_get(uh, CURLUPART_URL, &updated, - CURLU_GUESS_SCHEME); + uerr = curl_url_get(uh, CURLUPART_URL, &updated, CURLU_GUESS_SCHEME); if(uerr) result = urlerr_cvt(uerr); else { @@ -1333,8 +1326,7 @@ static CURLcode single_transfer(struct OperationConfig *config, /* * We have specified a file to upload and it is not "-". */ - result = add_file_name_to_url(per->curl, &per->url, - per->uploadfile); + result = add_file_name_to_url(per->curl, &per->url, per->uploadfile); if(result) return result; } @@ -1370,8 +1362,7 @@ static CURLcode single_transfer(struct OperationConfig *config, } /* explicitly passed to stdout means okaying binary gunk */ - config->terminal_binary_ok = - (per->outfile && !strcmp(per->outfile, "-")); + config->terminal_binary_ok = (per->outfile && !strcmp(per->outfile, "-")); hdrcbdata->honor_cd_filename = (config->content_disposition && u->useremote); @@ -1428,7 +1419,7 @@ static CURLcode add_parallel_transfers(CURLM *multi, CURLSH *share, return CURLE_UNKNOWN_OPTION; } - if(nxfers < (curl_off_t)(global->parallel_max*2)) { + if(nxfers < (curl_off_t)(global->parallel_max * 2)) { bool skipped = FALSE; do { result = create_transfer(share, addedp, &skipped); @@ -1513,7 +1504,7 @@ struct parastate { #if defined(DEBUGBUILD) && defined(USE_LIBUV) -#define DEBUG_UV 0 +#define DEBUG_UV 0 /* object to pass to the callbacks */ struct datauv { @@ -1535,7 +1526,7 @@ static void mnotify(CURLM *multi, unsigned int notification, static void on_uv_socket(uv_poll_t *req, int status, int events) { int flags = 0; - struct contextuv *c = (struct contextuv *) req->data; + struct contextuv *c = (struct contextuv *)req->data; (void)status; if(events & UV_READABLE) flags |= CURL_CSELECT_IN; @@ -1550,7 +1541,7 @@ static void on_uv_socket(uv_poll_t *req, int status, int events) /* callback from libuv when timeout expires */ static void on_uv_timeout(uv_timer_t *req) { - struct datauv *uv = (struct datauv *) req->data; + struct datauv *uv = (struct datauv *)req->data; #if DEBUG_UV curl_mfprintf(tool_stderr, "parallel_event: on_uv_timeout\n"); #endif @@ -1599,13 +1590,13 @@ static struct contextuv *create_context(curl_socket_t sockfd, static void close_cb(uv_handle_t *handle) { - struct contextuv *c = (struct contextuv *) handle->data; + struct contextuv *c = (struct contextuv *)handle->data; curlx_free(c); } static void destroy_context(struct contextuv *c) { - uv_close((uv_handle_t *) &c->poll_handle, close_cb); + uv_close((uv_handle_t *)&c->poll_handle, close_cb); } /* callback from libcurl to update socket activity to wait for */ @@ -1625,8 +1616,7 @@ static int cb_socket(CURL *easy, curl_socket_t s, int action, case CURL_POLL_IN: case CURL_POLL_OUT: case CURL_POLL_INOUT: - c = socketp ? - (struct contextuv *) socketp : create_context(s, uv); + c = socketp ? (struct contextuv *)socketp : create_context(s, uv); curl_multi_assign(uv->s->multi, s, c); @@ -1753,7 +1743,7 @@ static CURLcode check_finished(struct parastate *s) if(retry) { ended->added = FALSE; /* add it again */ /* we delay retries in full integer seconds only */ - ended->startat = delay ? time(NULL) + delay/1000 : 0; + ended->startat = delay ? time(NULL) + delay / 1000 : 0; } else { /* result receives this transfer's error unless the transfer was @@ -2222,7 +2212,6 @@ static CURLcode share_setup(CURLSH *share) return result; } - CURLcode operate(int argc, argv_item_t argv[]) { CURLcode result = CURLE_OK; diff --git a/src/tool_operhlp.c b/src/tool_operhlp.c index a8b5e94975..c46f3e3eef 100644 --- a/src/tool_operhlp.c +++ b/src/tool_operhlp.c @@ -91,7 +91,7 @@ CURLcode add_file_name_to_url(CURL *curl, char **inurlp, const char *filename) if(uh) { char *ptr; uerr = curl_url_set(uh, CURLUPART_URL, *inurlp, - CURLU_GUESS_SCHEME|CURLU_NON_SUPPORT_SCHEME); + CURLU_GUESS_SCHEME | CURLU_NON_SUPPORT_SCHEME); if(uerr) { result = urlerr_cvt(uerr); goto fail; diff --git a/src/tool_paramhlp.c b/src/tool_paramhlp.c index b16fc42906..9faf2e4dde 100644 --- a/src/tool_paramhlp.c +++ b/src/tool_paramhlp.c @@ -224,7 +224,7 @@ static ParameterError getnum(long *val, const char *str, int base) *val = (long)num; if(is_neg) *val = -*val; - return PARAM_OK; /* Ok */ + return PARAM_OK; /* Ok */ } } return PARAM_BAD_NUMERIC; /* badness */ @@ -309,7 +309,7 @@ ParameterError secs2ms(long *valp, const char *str) const unsigned int digs[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000 }; if(!str || - curlx_str_number(&str, &secs, LONG_MAX/1000 - 1)) + curlx_str_number(&str, &secs, LONG_MAX / 1000 - 1)) return PARAM_BAD_NUMERIC; if(!curlx_str_single(&str, '.')) { curl_off_t fracs; @@ -319,7 +319,7 @@ ParameterError secs2ms(long *valp, const char *str) return PARAM_NUMBER_TOO_LARGE; /* how many milliseconds are in fracs ? */ len = (str - s); - while((len > CURL_ARRAYSIZE(digs) || (fracs > LONG_MAX/100))) { + while((len > CURL_ARRAYSIZE(digs) || (fracs > LONG_MAX / 100))) { fracs /= 10; len--; } @@ -340,7 +340,7 @@ static size_t protoset_index(const char * const *protoset, const char *proto) { const char * const *p = protoset; - DEBUGASSERT(proto == proto_token(proto)); /* Ensure it is tokenized. */ + DEBUGASSERT(proto == proto_token(proto)); /* Ensure it is tokenized. */ for(; *p; p++) if(proto == *p) @@ -388,7 +388,7 @@ static void protoset_clear(const char **protoset, const char *proto) * data. */ -#define MAX_PROTOSTRING (64*11) /* Enough room for 64 10-chars proto names. */ +#define MAX_PROTOSTRING (64 * 11) /* Room for 64 10-chars proto names. */ ParameterError proto2num(const char * const *val, char **ostr, const char *str) { @@ -452,8 +452,8 @@ ParameterError proto2num(const char * const *val, char **ostr, const char *str) break; case allow: case set: - memcpy((char *) protoset, - built_in_protos, (proto_count + 1) * sizeof(*protoset)); + memcpy((char *)protoset, built_in_protos, + (proto_count + 1) * sizeof(*protoset)); break; } } @@ -491,7 +491,7 @@ ParameterError proto2num(const char * const *val, char **ostr, const char *str) } /* We need the protocols in alphabetic order for CI tests requirements. */ - qsort((char *) protoset, protoset_index(protoset, NULL), sizeof(*protoset), + qsort((char *)protoset, protoset_index(protoset, NULL), sizeof(*protoset), struplocompare4sort); for(proto = 0; protoset[proto] && !result; proto++) @@ -543,7 +543,7 @@ ParameterError str2offset(curl_off_t *val, const char *str) return PARAM_OK; } -#define MAX_USERPWDLENGTH (100*1024) +#define MAX_USERPWDLENGTH (100 * 1024) static CURLcode checkpasswd(const char *kind, /* for what purpose */ const size_t i, /* operation index */ const bool last, /* TRUE if last operation */ @@ -648,22 +648,21 @@ long delegation(const char *str) return CURLGSSAPI_DELEGATION_NONE; } -#define isheadersep(x) ((((x)==':') || ((x)==';'))) +#define isheadersep(x) ((((x) == ':') || ((x) == ';'))) /* * inlist() returns true if the given 'checkfor' header is present in the * header list. */ -static bool inlist(const struct curl_slist *head, - const char *checkfor) +static bool inlist(const struct curl_slist *head, const char *checkfor) { size_t thislen = strlen(checkfor); DEBUGASSERT(thislen); - DEBUGASSERT(checkfor[thislen-1] != ':'); + DEBUGASSERT(checkfor[thislen - 1] != ':'); for(; head; head = head->next) { if(curl_strnequal(head->data, checkfor, thislen) && - isheadersep(head->data[thislen]) ) + isheadersep(head->data[thislen])) return TRUE; } diff --git a/src/tool_paramhlp.h b/src/tool_paramhlp.h index a9e8539cf5..f7c743b7e2 100644 --- a/src/tool_paramhlp.h +++ b/src/tool_paramhlp.h @@ -31,7 +31,7 @@ struct getout *new_getout(struct OperationConfig *config); ParameterError file2string(char **bufp, FILE *file); #if SIZEOF_SIZE_T > 4 -#define MAX_FILE2MEMORY (16LL*1024*1024*1024) +#define MAX_FILE2MEMORY (16LL * 1024 * 1024 * 1024) #else #define MAX_FILE2MEMORY (INT_MAX) #endif diff --git a/src/tool_parsecfg.c b/src/tool_parsecfg.c index f901e69e78..0466c547c3 100644 --- a/src/tool_parsecfg.c +++ b/src/tool_parsecfg.c @@ -33,7 +33,7 @@ /* only acknowledge colon or equals as separators if the option was not specified with an initial dash! */ -#define ISSEP(x,dash) (!dash && (((x) == '=') || ((x) == ':'))) +#define ISSEP(x, dash) (!dash && (((x) == '=') || ((x) == ':'))) /* * Copies the string from line to the param dynbuf, unquoting backslash-quoted diff --git a/src/tool_progress.c b/src/tool_progress.c index f9fbd83574..53ed9bcb3c 100644 --- a/src/tool_progress.c +++ b/src/tool_progress.c @@ -44,8 +44,8 @@ static char *max5data(curl_off_t bytes, char *max5) if(nbytes < 100) { /* display with a decimal */ curl_msnprintf(max5, 6, "%2" CURL_FORMAT_CURL_OFF_T ".%0" - CURL_FORMAT_CURL_OFF_T "%c", bytes/1024, - (bytes%1024) / (1024/10), unit[k]); + CURL_FORMAT_CURL_OFF_T "%c", bytes / 1024, + (bytes % 1024) / (1024 / 10), unit[k]); break; } else if(nbytes < 10000) { @@ -143,9 +143,7 @@ static void add_offt(curl_off_t *val, curl_off_t add) |DL% UL% Dled Uled Xfers Live Total Current Left Speed | 6 -- 9.9G 0 2 2 0:00:40 0:00:02 0:00:37 4087M */ -bool progress_meter(CURLM *multi, - struct curltime *start, - bool final) +bool progress_meter(CURLM *multi, struct curltime *start, bool final) { static struct curltime stamp; static bool header = FALSE; @@ -169,9 +167,9 @@ bool progress_meter(CURLM *multi, char time_total[10]; char time_spent[10]; char buffer[3][6]; - curl_off_t spent = curlx_timediff_ms(now, *start)/1000; - char dlpercen[4]="--"; - char ulpercen[4]="--"; + curl_off_t spent = curlx_timediff_ms(now, *start) / 1000; + char dlpercen[4] = "--"; + char ulpercen[4] = "--"; struct per_transfer *per; curl_off_t all_dlnow = 0; curl_off_t all_ulnow = 0; @@ -207,15 +205,15 @@ bool progress_meter(CURLM *multi, } if(dlknown && all_dltotal) curl_msnprintf(dlpercen, sizeof(dlpercen), "%3" CURL_FORMAT_CURL_OFF_T, - all_dlnow < (CURL_OFF_T_MAX/100) ? + all_dlnow < (CURL_OFF_T_MAX / 100) ? (all_dlnow * 100 / all_dltotal) : - (all_dlnow / (all_dltotal/100))); + (all_dlnow / (all_dltotal / 100))); if(ulknown && all_ultotal) curl_msnprintf(ulpercen, sizeof(ulpercen), "%3" CURL_FORMAT_CURL_OFF_T, - all_ulnow < (CURL_OFF_T_MAX/100) ? + all_ulnow < (CURL_OFF_T_MAX / 100) ? (all_ulnow * 100 / all_ultotal) : - (all_ulnow / (all_ultotal/100))); + (all_ulnow / (all_ultotal / 100))); /* get the transfer speed, the higher of the two */ @@ -248,8 +246,8 @@ bool progress_meter(CURLM *multi, } if(!deltams) /* no division by zero please */ deltams++; - dls = (curl_off_t)((double)dl / ((double)deltams/1000.0)); - uls = (curl_off_t)((double)ul / ((double)deltams/1000.0)); + dls = (curl_off_t)((double)dl / ((double)deltams / 1000.0)); + uls = (curl_off_t)((double)ul / ((double)deltams / 1000.0)); speed = dls > uls ? dls : uls; } @@ -291,7 +289,7 @@ bool progress_meter(CURLM *multi, time_spent, time_left, max5data(speed, buffer[2]), /* speed */ - final ? "\n" :""); + final ? "\n" : ""); return TRUE; } return FALSE; diff --git a/src/tool_sdecls.h b/src/tool_sdecls.h index 45b7bd0c20..9a6f3cc882 100644 --- a/src/tool_sdecls.h +++ b/src/tool_sdecls.h @@ -109,7 +109,6 @@ typedef enum { TRACE_PLAIN /* -v/--verbose type */ } trace; - /* * 'HttpReq' enumeration represents HTTP request types. */ @@ -123,7 +122,6 @@ typedef enum { TOOL_HTTPREQ_PUT } HttpReq; - /* * Complete struct declarations which have OperationConfig struct members, * just in case this header is directly included in some source file. diff --git a/src/tool_setopt.c b/src/tool_setopt.c index 97d469d76d..837f66c9c3 100644 --- a/src/tool_setopt.c +++ b/src/tool_setopt.c @@ -36,9 +36,9 @@ /* For bit masks, put combinations first, then single bits, */ /* and finally any "NONE" value. */ -#define NV(e) {#e, e} -#define NV1(e, v) {#e, (v)} -#define NVEND {NULL, 0} /* sentinel to mark end of list */ +#define NV(e) { #e, e } +#define NV1(e, v) { #e, (v) } +#define NVEND { NULL, 0 } /* sentinel to mark end of list */ const struct NameValue setopt_nv_CURLPROXY[] = { NV(CURLPROXY_HTTP), @@ -101,7 +101,7 @@ const struct NameValue setopt_nv_CURL_SSLVERSION[] = { }; const struct NameValue setopt_nv_CURL_SSLVERSION_MAX[] = { - {"", CURL_SSLVERSION_MAX_NONE}, + { "", CURL_SSLVERSION_MAX_NONE }, NV(CURL_SSLVERSION_MAX_DEFAULT), NV(CURL_SSLVERSION_MAX_TLSv1_0), NV(CURL_SSLVERSION_MAX_TLSv1_1), @@ -174,7 +174,7 @@ static const struct NameValue setopt_nv_CURLNONZERODEFAULTS[] = { /* Escape string to C string syntax. Return NULL if out of memory. */ #define MAX_STRING_LENGTH_OUTPUT 2000 -#define ZERO_TERMINATED -1 +#define ZERO_TERMINATED -1 static char *c_escape(const char *str, curl_off_t len) { @@ -216,7 +216,7 @@ static char *c_escape(const char *str, curl_off_t len) /* Octal escape to avoid >2 digit hex. */ (len > 1 && ISXDIGIT(s[1])) ? "\\%03o" : "\\x%02x", - (unsigned int) *(const unsigned char *) s); + (unsigned int)*(const unsigned char *)s); } } } @@ -337,9 +337,9 @@ CURLcode tool_setopt_bitmask(CURL *curl, const char *name, CURLoption tag, curl_msnprintf(preamble, sizeof(preamble), "curl_easy_setopt(hnd, %s, ", name); for(nv = nvlist; nv->name; nv++) { - if((nv->value & ~ rest) == 0) { + if((nv->value & ~rest) == 0) { /* all value flags contained in rest */ - rest &= ~ nv->value; /* remove bits handled here */ + rest &= ~nv->value; /* remove bits handled here */ ret = easysrc_addf(&easysrc_code, "%s(long)%s%s", preamble, nv->name, rest ? " |" : ");"); if(!rest || ret) @@ -425,8 +425,7 @@ static CURLcode libcurl_generate_mime_part(CURL *curl, mimeno, submimeno); if(!ret) /* Avoid freeing in CLEAN. */ - ret = easysrc_addf(&easysrc_code, - "mime%d = NULL;", submimeno); + ret = easysrc_addf(&easysrc_code, "mime%d = NULL;", submimeno); } break; diff --git a/src/tool_setopt.h b/src/tool_setopt.h index 5ca7188841..fcd56382a7 100644 --- a/src/tool_setopt.h +++ b/src/tool_setopt.h @@ -62,20 +62,20 @@ extern const struct NameValueUnsigned setopt_nv_CURLAUTH[]; extern const struct NameValueUnsigned setopt_nv_CURLHSTS[]; /* Map options to NameValue sets */ -#define setopt_nv_CURLOPT_HSTS_CTRL setopt_nv_CURLHSTS -#define setopt_nv_CURLOPT_HTTP_VERSION setopt_nv_CURL_HTTP_VERSION -#define setopt_nv_CURLOPT_HTTPAUTH setopt_nv_CURLAUTH -#define setopt_nv_CURLOPT_SSLVERSION setopt_nv_CURL_SSLVERSION -#define setopt_nv_CURLOPT_PROXY_SSLVERSION setopt_nv_CURL_SSLVERSION -#define setopt_nv_CURLOPT_TIMECONDITION setopt_nv_CURL_TIMECOND -#define setopt_nv_CURLOPT_FTP_SSL_CCC setopt_nv_CURLFTPSSL_CCC -#define setopt_nv_CURLOPT_USE_SSL setopt_nv_CURLUSESSL -#define setopt_nv_CURLOPT_SSL_OPTIONS setopt_nv_CURLSSLOPT +#define setopt_nv_CURLOPT_HSTS_CTRL setopt_nv_CURLHSTS +#define setopt_nv_CURLOPT_HTTP_VERSION setopt_nv_CURL_HTTP_VERSION +#define setopt_nv_CURLOPT_HTTPAUTH setopt_nv_CURLAUTH +#define setopt_nv_CURLOPT_SSLVERSION setopt_nv_CURL_SSLVERSION +#define setopt_nv_CURLOPT_PROXY_SSLVERSION setopt_nv_CURL_SSLVERSION +#define setopt_nv_CURLOPT_TIMECONDITION setopt_nv_CURL_TIMECOND +#define setopt_nv_CURLOPT_FTP_SSL_CCC setopt_nv_CURLFTPSSL_CCC +#define setopt_nv_CURLOPT_USE_SSL setopt_nv_CURLUSESSL +#define setopt_nv_CURLOPT_SSL_OPTIONS setopt_nv_CURLSSLOPT #define setopt_nv_CURLOPT_PROXY_SSL_OPTIONS setopt_nv_CURLSSLOPT -#define setopt_nv_CURLOPT_NETRC setopt_nv_CURL_NETRC -#define setopt_nv_CURLOPT_PROXYTYPE setopt_nv_CURLPROXY -#define setopt_nv_CURLOPT_PROXYAUTH setopt_nv_CURLAUTH -#define setopt_nv_CURLOPT_SOCKS5_AUTH setopt_nv_CURLAUTH +#define setopt_nv_CURLOPT_NETRC setopt_nv_CURL_NETRC +#define setopt_nv_CURLOPT_PROXYTYPE setopt_nv_CURLPROXY +#define setopt_nv_CURLOPT_PROXYAUTH setopt_nv_CURLAUTH +#define setopt_nv_CURLOPT_SOCKS5_AUTH setopt_nv_CURLAUTH /* Intercept setopt calls for --libcurl */ @@ -103,64 +103,48 @@ CURLcode tool_setopt_str(CURL *curl, struct OperationConfig *config, ...) WARN_UNUSED_RESULT; CURLcode tool_setopt_ptr(CURL *curl, const char *name, CURLoption tag, ...); -#define my_setopt_ptr(x,y,z) \ - tool_setopt_ptr(x, #y, y, z) - -#define my_setopt_long(x,y,z) \ - tool_setopt_long(x, #y, y, z) - -#define my_setopt_offt(x,y,z) \ - tool_setopt_offt(x, #y, y, z) - -#define my_setopt_str(x,y,z) \ - tool_setopt_str(x, config, #y, y, z) +#define my_setopt_long(x, y, z) tool_setopt_long(x, #y, y, z) +#define my_setopt_offt(x, y, z) tool_setopt_offt(x, #y, y, z) +#define my_setopt_ptr(x, y, z) tool_setopt_ptr(x, #y, y, z) +#define my_setopt_str(x, y, z) tool_setopt_str(x, config, #y, y, z) +#define my_setopt_mimepost(x, y, z) tool_setopt_mimepost(x, config, #y, y, z) +#define my_setopt_slist(x, y, z) tool_setopt_slist(x, #y, y, z) +#define my_setopt_SSLVERSION(x, y, z) tool_setopt_SSLVERSION(x, #y, y, z) +#define my_setopt_enum(x, y, z) \ + tool_setopt_enum(x, #y, y, setopt_nv_ ## y, z) +#define my_setopt_bitmask(x, y, z) \ + tool_setopt_bitmask(x, #y, y, setopt_nv_ ## y, z) /* assumes a 'result' variable to use. If the return code is benign it is left in 'result' after this call, otherwise the function returns the error */ -#define MY_SETOPT_STR(x,y,z) \ - do { \ - result = tool_setopt_str(x, config, #y, y, z); \ - if(setopt_bad(result)) \ - return result; \ +#define MY_SETOPT_STR(x, y, z) \ + do { \ + result = tool_setopt_str(x, config, #y, y, z); \ + if(setopt_bad(result)) \ + return result; \ } while(0) -#define my_setopt_enum(x,y,z) \ - tool_setopt_enum(x, #y, y, setopt_nv_ ## y, z) - -#define my_setopt_SSLVERSION(x,y,z) \ - tool_setopt_SSLVERSION(x, #y, y, z) - -#define my_setopt_bitmask(x,y,z) \ - tool_setopt_bitmask(x, #y, y, setopt_nv_ ## y, z) - -#define my_setopt_mimepost(x,y,z) \ - tool_setopt_mimepost(x, config, #y, y, z) - -#define my_setopt_slist(x,y,z) \ - tool_setopt_slist(x, #y, y, z) - #else /* CURL_DISABLE_LIBCURL_OPTION */ /* No --libcurl, so pass options directly to library */ -#define my_setopt_long(x,y,z) curl_easy_setopt(x, y, (long)(z)) -#define my_setopt_offt(x,y,z) curl_easy_setopt(x, y, (curl_off_t)(z)) -#define my_setopt_ptr(x,y,z) curl_easy_setopt(x, y, z) -#define my_setopt_str(x,y,z) curl_easy_setopt(x, y, z) -#define my_setopt_enum(x,y,z) curl_easy_setopt(x, y, z) -#define my_setopt_SSLVERSION(x,y,z) curl_easy_setopt(x, y, z) -#define my_setopt_bitmask(x,y,z) curl_easy_setopt(x, y, (long)z) -#define my_setopt_mimepost(x,y,z) curl_easy_setopt(x, y, z) -#define my_setopt_slist(x,y,z) curl_easy_setopt(x, y, z) - -#define MY_SETOPT_STR(x,y,z) \ - do { \ - result = curl_easy_setopt(x, y, z); \ - if(setopt_bad(result)) \ - return result; \ +#define my_setopt_long(x, y, z) curl_easy_setopt(x, y, (long)(z)) +#define my_setopt_offt(x, y, z) curl_easy_setopt(x, y, (curl_off_t)(z)) +#define my_setopt_ptr(x, y, z) curl_easy_setopt(x, y, z) +#define my_setopt_str(x, y, z) curl_easy_setopt(x, y, z) +#define my_setopt_mimepost(x, y, z) curl_easy_setopt(x, y, z) +#define my_setopt_slist(x, y, z) curl_easy_setopt(x, y, z) +#define my_setopt_SSLVERSION(x, y, z) curl_easy_setopt(x, y, z) +#define my_setopt_enum(x, y, z) curl_easy_setopt(x, y, z) +#define my_setopt_bitmask(x, y, z) curl_easy_setopt(x, y, (long)z) + +#define MY_SETOPT_STR(x, y, z) \ + do { \ + result = curl_easy_setopt(x, y, z); \ + if(setopt_bad(result)) \ + return result; \ } while(0) - #endif /* CURL_DISABLE_LIBCURL_OPTION */ #endif /* HEADER_CURL_TOOL_SETOPT_H */ diff --git a/src/tool_setup.h b/src/tool_setup.h index f693fc1dae..1524e36103 100644 --- a/src/tool_setup.h +++ b/src/tool_setup.h @@ -54,7 +54,7 @@ extern FILE *tool_stderr; */ #ifdef macintosh -# define main(x,y) curl_main(x,y) +# define main(x, y) curl_main(x, y) #endif #ifndef CURL_OS @@ -100,7 +100,7 @@ extern bool tool_term_has_bold; int tool_ftruncate64(int fd, curl_off_t where); #undef ftruncate -#define ftruncate(fd,where) tool_ftruncate64(fd,where) +#define ftruncate(fd, where) tool_ftruncate64(fd, where) #define HAVE_FTRUNCATE 1 #define USE_TOOL_FTRUNCATE 1 diff --git a/src/tool_ssls.c b/src/tool_ssls.c index 7ffd6f7074..6ad5c2475d 100644 --- a/src/tool_ssls.c +++ b/src/tool_ssls.c @@ -33,7 +33,6 @@ /* The maximum line length for an ecoded session ticket */ #define MAX_SSLS_LINE (64 * 1024) - static CURLcode tool_ssls_easy(struct OperationConfig *config, CURLSH *share, CURL **peasy) { @@ -193,8 +192,7 @@ CURLcode tool_ssls_save(struct OperationConfig *config, ctx.exported = 0; ctx.fp = curlx_fopen(filename, FOPEN_WRITETEXT); if(!ctx.fp) { - warnf("Warning: Failed to create SSL session file %s", - filename); + warnf("Warning: Failed to create SSL session file %s", filename); goto out; } diff --git a/src/tool_urlglob.c b/src/tool_urlglob.c index bfa54ab827..ad2e2de9d6 100644 --- a/src/tool_urlglob.c +++ b/src/tool_urlglob.c @@ -80,7 +80,7 @@ static int multiply(curl_off_t *amount, curl_off_t with) return 1; #else sum = *amount * with; - if(sum/with != *amount) + if(sum / with != *amount) return 1; /* did not fit, bail out */ #endif } @@ -99,7 +99,7 @@ static CURLcode glob_set(struct URLGlob *glob, const char **patternp, bool done = FALSE; const char *pattern = *patternp; const char *opattern = pattern; - size_t opos = *posp-1; + size_t opos = *posp - 1; CURLcode result = CURLE_OK; size_t size = 0; char **elem = NULL; @@ -441,7 +441,7 @@ static CURLcode glob_parse(struct URLGlob *glob, const char *pattern, /* only allow \ to escape known "special letters" */ if(*pattern == '\\' && (pattern[1] == '{' || pattern[1] == '[' || - pattern[1] == '}' || pattern[1] == ']') ) { + pattern[1] == '}' || pattern[1] == ']')) { /* escape character, skip '\' */ ++pattern; @@ -463,7 +463,7 @@ static CURLcode glob_parse(struct URLGlob *glob, const char *pattern, else { if(!*pattern) /* done */ break; - else if(*pattern =='{') { + else if(*pattern == '{') { /* process set pattern */ pattern++; pos++; @@ -500,7 +500,7 @@ CURLcode glob_url(struct URLGlob *glob, char *url, curl_off_t *urlnum, CURLcode res; memset(glob, 0, sizeof(struct URLGlob)); - curlx_dyn_init(&glob->buf, 1024*1024); + curlx_dyn_init(&glob->buf, 1024 * 1024); glob->pattern = curlx_malloc(2 * sizeof(struct URLPattern)); if(!glob->pattern) return CURLE_OUT_OF_MEMORY; @@ -634,7 +634,7 @@ CURLcode glob_next_url(char **globbed, struct URLGlob *glob) return CURLE_OK; } -#define MAX_OUTPUT_GLOB_LENGTH (1024*1024) +#define MAX_OUTPUT_GLOB_LENGTH (1024 * 1024) CURLcode glob_match_url(char **output, const char *filename, struct URLGlob *glob) diff --git a/src/tool_util.c b/src/tool_util.c index 43dd096783..96b0715b0a 100644 --- a/src/tool_util.c +++ b/src/tool_util.c @@ -75,7 +75,7 @@ int struplocompare(const char *p1, const char *p2) /* Indirect version to use as qsort callback. */ int struplocompare4sort(const void *p1, const void *p2) { - return struplocompare(* (char * const *) p1, * (char * const *) p2); + return struplocompare(*(char * const *)p1, *(char * const *)p2); } #ifdef USE_TOOL_FTRUNCATE diff --git a/src/tool_version.h b/src/tool_version.h index 00be7799ea..5db625c317 100644 --- a/src/tool_version.h +++ b/src/tool_version.h @@ -25,12 +25,12 @@ ***************************************************************************/ #include -#define CURL_NAME "curl" -#define CURL_COPYRIGHT LIBCURL_COPYRIGHT -#define CURL_VERSION LIBCURL_VERSION +#define CURL_NAME "curl" +#define CURL_COPYRIGHT LIBCURL_COPYRIGHT +#define CURL_VERSION LIBCURL_VERSION #define CURL_VERSION_MAJOR LIBCURL_VERSION_MAJOR #define CURL_VERSION_MINOR LIBCURL_VERSION_MINOR #define CURL_VERSION_PATCH LIBCURL_VERSION_PATCH -#define CURL_ID CURL_NAME " " CURL_VERSION " (" CURL_OS ") " +#define CURL_ID CURL_NAME " " CURL_VERSION " (" CURL_OS ") " #endif /* HEADER_CURL_TOOL_VERSION_H */ diff --git a/src/tool_vms.c b/src/tool_vms.c index 75aa7d5370..71606f3d66 100644 --- a/src/tool_vms.c +++ b/src/tool_vms.c @@ -184,7 +184,6 @@ static void decc_init(void) /* Invalid DECC feature name. */ curl_mprintf(" UNKNOWN DECC FEATURE: %s.\n", decc_feat_array[i].name); } - } } @@ -196,16 +195,16 @@ static void decc_init(void) other attributes. Note that "nopic" is significant only on VAX. */ #pragma extern_model save #pragma extern_model strict_refdef "LIB$INITIALIZ" 2, nopic, nowrt -const int spare[8] = {0}; +const int spare[8] = { 0 }; #pragma extern_model strict_refdef "LIB$INITIALIZE" 2, nopic, nowrt -void (*const x_decc_init)() = decc_init; +void (* const x_decc_init)() = decc_init; #pragma extern_model restore /* Fake reference to ensure loading the LIB$INITIALIZE PSECT. */ #pragma extern_model save int LIB$INITIALIZE(void); #pragma extern_model strict_refdef -int dmy_lib$initialize = (int) LIB$INITIALIZE; +int dmy_lib$initialize = (int)LIB$INITIALIZE; #pragma extern_model restore #pragma standard diff --git a/src/tool_vms.h b/src/tool_vms.h index 3da816cf67..3519628fc1 100644 --- a/src/tool_vms.h +++ b/src/tool_vms.h @@ -40,8 +40,9 @@ void vms_special_exit(int code, int vms_show); #undef exit #define exit(__code) vms_special_exit((__code), (0)) -#define VMS_STS(c,f,e,s) (((c&0xF)<<28)|((f&0xFFF)<<16)|((e&0x1FFF)<3)|(s&7)) -#define VMSSTS_HIDE VMS_STS(1,0,0,0) +#define VMS_STS(c, f, e, s) \ + (((c & 0xF) << 28) | ((f & 0xFFF) << 16) | ((e & 0x1FFF) < 3) | (s & 7)) +#define VMSSTS_HIDE VMS_STS(1, 0, 0, 0) #endif /* __VMS */ diff --git a/src/tool_writeout.c b/src/tool_writeout.c index f846add4e3..358c7b39b3 100644 --- a/src/tool_writeout.c +++ b/src/tool_writeout.c @@ -49,12 +49,12 @@ struct httpmap { }; static const struct httpmap http_version[] = { - { "0", CURL_HTTP_VERSION_NONE}, - { "1", CURL_HTTP_VERSION_1_0}, - { "1.1", CURL_HTTP_VERSION_1_1}, - { "2", CURL_HTTP_VERSION_2}, - { "3", CURL_HTTP_VERSION_3}, - { NULL, 0} /* end of list */ + { "0", CURL_HTTP_VERSION_NONE }, + { "1", CURL_HTTP_VERSION_1_0 }, + { "1.1", CURL_HTTP_VERSION_1_1 }, + { "2", CURL_HTTP_VERSION_2 }, + { "3", CURL_HTTP_VERSION_3 }, + { NULL, 0 } /* end of list */ }; /* The designated write function should be the same as the CURLINFO return type @@ -68,87 +68,90 @@ static const struct httpmap http_version[] = { Variable names MUST be in alphabetical order. */ static const struct writeoutvar variables[] = { - {"certs", VAR_CERT, CURLINFO_NONE, writeString}, - {"conn_id", VAR_CONN_ID, CURLINFO_CONN_ID, writeOffset}, - {"content_type", VAR_CONTENT_TYPE, CURLINFO_CONTENT_TYPE, writeString}, - {"errormsg", VAR_ERRORMSG, CURLINFO_NONE, writeString}, - {"exitcode", VAR_EXITCODE, CURLINFO_NONE, writeLong}, - {"filename_effective", VAR_EFFECTIVE_FILENAME, CURLINFO_NONE, writeString}, - {"ftp_entry_path", VAR_FTP_ENTRY_PATH, CURLINFO_FTP_ENTRY_PATH, writeString}, - {"header_json", VAR_HEADER_JSON, CURLINFO_NONE, NULL}, - {"http_code", VAR_HTTP_CODE, CURLINFO_RESPONSE_CODE, writeLong}, - {"http_connect", VAR_HTTP_CODE_PROXY, CURLINFO_HTTP_CONNECTCODE, writeLong}, - {"http_version", VAR_HTTP_VERSION, CURLINFO_HTTP_VERSION, writeString}, - {"json", VAR_JSON, CURLINFO_NONE, NULL}, - {"local_ip", VAR_LOCAL_IP, CURLINFO_LOCAL_IP, writeString}, - {"local_port", VAR_LOCAL_PORT, CURLINFO_LOCAL_PORT, writeLong}, - {"method", VAR_EFFECTIVE_METHOD, CURLINFO_EFFECTIVE_METHOD, writeString}, - {"num_certs", VAR_NUM_CERTS, CURLINFO_NONE, writeLong}, - {"num_connects", VAR_NUM_CONNECTS, CURLINFO_NUM_CONNECTS, writeLong}, - {"num_headers", VAR_NUM_HEADERS, CURLINFO_NONE, writeLong}, - {"num_redirects", VAR_REDIRECT_COUNT, CURLINFO_REDIRECT_COUNT, writeLong}, - {"num_retries", VAR_NUM_RETRY, CURLINFO_NONE, writeLong}, - {"onerror", VAR_ONERROR, CURLINFO_NONE, NULL}, - {"proxy_ssl_verify_result", VAR_PROXY_SSL_VERIFY_RESULT, - CURLINFO_PROXY_SSL_VERIFYRESULT, writeLong}, - {"proxy_used", VAR_PROXY_USED, CURLINFO_USED_PROXY, writeLong}, - {"redirect_url", VAR_REDIRECT_URL, CURLINFO_REDIRECT_URL, writeString}, - {"referer", VAR_REFERER, CURLINFO_REFERER, writeString}, - {"remote_ip", VAR_PRIMARY_IP, CURLINFO_PRIMARY_IP, writeString}, - {"remote_port", VAR_PRIMARY_PORT, CURLINFO_PRIMARY_PORT, writeLong}, - {"response_code", VAR_HTTP_CODE, CURLINFO_RESPONSE_CODE, writeLong}, - {"scheme", VAR_SCHEME, CURLINFO_SCHEME, writeString}, - {"size_download", VAR_SIZE_DOWNLOAD, CURLINFO_SIZE_DOWNLOAD_T, writeOffset}, - {"size_header", VAR_HEADER_SIZE, CURLINFO_HEADER_SIZE, writeLong}, - {"size_request", VAR_REQUEST_SIZE, CURLINFO_REQUEST_SIZE, writeLong}, - {"size_upload", VAR_SIZE_UPLOAD, CURLINFO_SIZE_UPLOAD_T, writeOffset}, - {"speed_download", VAR_SPEED_DOWNLOAD, CURLINFO_SPEED_DOWNLOAD_T, - writeOffset}, - {"speed_upload", VAR_SPEED_UPLOAD, CURLINFO_SPEED_UPLOAD_T, writeOffset}, - {"ssl_verify_result", VAR_SSL_VERIFY_RESULT, CURLINFO_SSL_VERIFYRESULT, - writeLong}, - {"stderr", VAR_STDERR, CURLINFO_NONE, NULL}, - {"stdout", VAR_STDOUT, CURLINFO_NONE, NULL}, - {"time_appconnect", VAR_APPCONNECT_TIME, CURLINFO_APPCONNECT_TIME_T, - writeTime}, - {"time_connect", VAR_CONNECT_TIME, CURLINFO_CONNECT_TIME_T, writeTime}, - {"time_namelookup", VAR_NAMELOOKUP_TIME, CURLINFO_NAMELOOKUP_TIME_T, - writeTime}, - {"time_posttransfer", VAR_POSTTRANSFER_TIME, CURLINFO_POSTTRANSFER_TIME_T, - writeTime}, - {"time_pretransfer", VAR_PRETRANSFER_TIME, CURLINFO_PRETRANSFER_TIME_T, - writeTime}, - {"time_queue", VAR_QUEUE_TIME, CURLINFO_QUEUE_TIME_T, writeTime}, - {"time_redirect", VAR_REDIRECT_TIME, CURLINFO_REDIRECT_TIME_T, writeTime}, - {"time_starttransfer", VAR_STARTTRANSFER_TIME, CURLINFO_STARTTRANSFER_TIME_T, - writeTime}, - {"time_total", VAR_TOTAL_TIME, CURLINFO_TOTAL_TIME_T, writeTime}, - {"tls_earlydata", VAR_TLS_EARLYDATA_SENT, CURLINFO_EARLYDATA_SENT_T, - writeOffset}, - {"url", VAR_INPUT_URL, CURLINFO_NONE, writeString}, - {"url.fragment", VAR_INPUT_URLFRAGMENT, CURLINFO_NONE, writeString}, - {"url.host", VAR_INPUT_URLHOST, CURLINFO_NONE, writeString}, - {"url.options", VAR_INPUT_URLOPTIONS, CURLINFO_NONE, writeString}, - {"url.password", VAR_INPUT_URLPASSWORD, CURLINFO_NONE, writeString}, - {"url.path", VAR_INPUT_URLPATH, CURLINFO_NONE, writeString}, - {"url.port", VAR_INPUT_URLPORT, CURLINFO_NONE, writeString}, - {"url.query", VAR_INPUT_URLQUERY, CURLINFO_NONE, writeString}, - {"url.scheme", VAR_INPUT_URLSCHEME, CURLINFO_NONE, writeString}, - {"url.user", VAR_INPUT_URLUSER, CURLINFO_NONE, writeString}, - {"url.zoneid", VAR_INPUT_URLZONEID, CURLINFO_NONE, writeString}, - {"url_effective", VAR_EFFECTIVE_URL, CURLINFO_EFFECTIVE_URL, writeString}, - {"urle.fragment", VAR_INPUT_URLEFRAGMENT, CURLINFO_NONE, writeString}, - {"urle.host", VAR_INPUT_URLEHOST, CURLINFO_NONE, writeString}, - {"urle.options", VAR_INPUT_URLEOPTIONS, CURLINFO_NONE, writeString}, - {"urle.password", VAR_INPUT_URLEPASSWORD, CURLINFO_NONE, writeString}, - {"urle.path", VAR_INPUT_URLEPATH, CURLINFO_NONE, writeString}, - {"urle.port", VAR_INPUT_URLEPORT, CURLINFO_NONE, writeString}, - {"urle.query", VAR_INPUT_URLEQUERY, CURLINFO_NONE, writeString}, - {"urle.scheme", VAR_INPUT_URLESCHEME, CURLINFO_NONE, writeString}, - {"urle.user", VAR_INPUT_URLEUSER, CURLINFO_NONE, writeString}, - {"urle.zoneid", VAR_INPUT_URLEZONEID, CURLINFO_NONE, writeString}, - {"urlnum", VAR_URLNUM, CURLINFO_NONE, writeOffset}, - {"xfer_id", VAR_EASY_ID, CURLINFO_XFER_ID, writeOffset} + { "certs", VAR_CERT, CURLINFO_NONE, writeString }, + { "conn_id", VAR_CONN_ID, CURLINFO_CONN_ID, writeOffset }, + { "content_type", VAR_CONTENT_TYPE, CURLINFO_CONTENT_TYPE, writeString }, + { "errormsg", VAR_ERRORMSG, CURLINFO_NONE, writeString }, + { "exitcode", VAR_EXITCODE, CURLINFO_NONE, writeLong }, + { "filename_effective", VAR_EFFECTIVE_FILENAME, CURLINFO_NONE, writeString }, + { "ftp_entry_path", VAR_FTP_ENTRY_PATH, CURLINFO_FTP_ENTRY_PATH, + writeString }, + { "header_json", VAR_HEADER_JSON, CURLINFO_NONE, NULL }, + { "http_code", VAR_HTTP_CODE, CURLINFO_RESPONSE_CODE, writeLong }, + { "http_connect", VAR_HTTP_CODE_PROXY, CURLINFO_HTTP_CONNECTCODE, + writeLong }, + { "http_version", VAR_HTTP_VERSION, CURLINFO_HTTP_VERSION, writeString }, + { "json", VAR_JSON, CURLINFO_NONE, NULL }, + { "local_ip", VAR_LOCAL_IP, CURLINFO_LOCAL_IP, writeString }, + { "local_port", VAR_LOCAL_PORT, CURLINFO_LOCAL_PORT, writeLong }, + { "method", VAR_EFFECTIVE_METHOD, CURLINFO_EFFECTIVE_METHOD, writeString }, + { "num_certs", VAR_NUM_CERTS, CURLINFO_NONE, writeLong }, + { "num_connects", VAR_NUM_CONNECTS, CURLINFO_NUM_CONNECTS, writeLong }, + { "num_headers", VAR_NUM_HEADERS, CURLINFO_NONE, writeLong }, + { "num_redirects", VAR_REDIRECT_COUNT, CURLINFO_REDIRECT_COUNT, writeLong }, + { "num_retries", VAR_NUM_RETRY, CURLINFO_NONE, writeLong }, + { "onerror", VAR_ONERROR, CURLINFO_NONE, NULL }, + { "proxy_ssl_verify_result", VAR_PROXY_SSL_VERIFY_RESULT, + CURLINFO_PROXY_SSL_VERIFYRESULT, writeLong }, + { "proxy_used", VAR_PROXY_USED, CURLINFO_USED_PROXY, writeLong }, + { "redirect_url", VAR_REDIRECT_URL, CURLINFO_REDIRECT_URL, writeString }, + { "referer", VAR_REFERER, CURLINFO_REFERER, writeString }, + { "remote_ip", VAR_PRIMARY_IP, CURLINFO_PRIMARY_IP, writeString }, + { "remote_port", VAR_PRIMARY_PORT, CURLINFO_PRIMARY_PORT, writeLong }, + { "response_code", VAR_HTTP_CODE, CURLINFO_RESPONSE_CODE, writeLong }, + { "scheme", VAR_SCHEME, CURLINFO_SCHEME, writeString }, + { "size_download", VAR_SIZE_DOWNLOAD, CURLINFO_SIZE_DOWNLOAD_T, + writeOffset }, + { "size_header", VAR_HEADER_SIZE, CURLINFO_HEADER_SIZE, writeLong }, + { "size_request", VAR_REQUEST_SIZE, CURLINFO_REQUEST_SIZE, writeLong }, + { "size_upload", VAR_SIZE_UPLOAD, CURLINFO_SIZE_UPLOAD_T, writeOffset }, + { "speed_download", VAR_SPEED_DOWNLOAD, CURLINFO_SPEED_DOWNLOAD_T, + writeOffset }, + { "speed_upload", VAR_SPEED_UPLOAD, CURLINFO_SPEED_UPLOAD_T, writeOffset }, + { "ssl_verify_result", VAR_SSL_VERIFY_RESULT, CURLINFO_SSL_VERIFYRESULT, + writeLong }, + { "stderr", VAR_STDERR, CURLINFO_NONE, NULL }, + { "stdout", VAR_STDOUT, CURLINFO_NONE, NULL }, + { "time_appconnect", VAR_APPCONNECT_TIME, CURLINFO_APPCONNECT_TIME_T, + writeTime }, + { "time_connect", VAR_CONNECT_TIME, CURLINFO_CONNECT_TIME_T, writeTime }, + { "time_namelookup", VAR_NAMELOOKUP_TIME, CURLINFO_NAMELOOKUP_TIME_T, + writeTime }, + { "time_posttransfer", VAR_POSTTRANSFER_TIME, CURLINFO_POSTTRANSFER_TIME_T, + writeTime }, + { "time_pretransfer", VAR_PRETRANSFER_TIME, CURLINFO_PRETRANSFER_TIME_T, + writeTime }, + { "time_queue", VAR_QUEUE_TIME, CURLINFO_QUEUE_TIME_T, writeTime }, + { "time_redirect", VAR_REDIRECT_TIME, CURLINFO_REDIRECT_TIME_T, writeTime }, + { "time_starttransfer", VAR_STARTTRANSFER_TIME, + CURLINFO_STARTTRANSFER_TIME_T, writeTime }, + { "time_total", VAR_TOTAL_TIME, CURLINFO_TOTAL_TIME_T, writeTime }, + { "tls_earlydata", VAR_TLS_EARLYDATA_SENT, CURLINFO_EARLYDATA_SENT_T, + writeOffset }, + { "url", VAR_INPUT_URL, CURLINFO_NONE, writeString }, + { "url.fragment", VAR_INPUT_URLFRAGMENT, CURLINFO_NONE, writeString }, + { "url.host", VAR_INPUT_URLHOST, CURLINFO_NONE, writeString }, + { "url.options", VAR_INPUT_URLOPTIONS, CURLINFO_NONE, writeString }, + { "url.password", VAR_INPUT_URLPASSWORD, CURLINFO_NONE, writeString }, + { "url.path", VAR_INPUT_URLPATH, CURLINFO_NONE, writeString }, + { "url.port", VAR_INPUT_URLPORT, CURLINFO_NONE, writeString }, + { "url.query", VAR_INPUT_URLQUERY, CURLINFO_NONE, writeString }, + { "url.scheme", VAR_INPUT_URLSCHEME, CURLINFO_NONE, writeString }, + { "url.user", VAR_INPUT_URLUSER, CURLINFO_NONE, writeString }, + { "url.zoneid", VAR_INPUT_URLZONEID, CURLINFO_NONE, writeString }, + { "url_effective", VAR_EFFECTIVE_URL, CURLINFO_EFFECTIVE_URL, writeString }, + { "urle.fragment", VAR_INPUT_URLEFRAGMENT, CURLINFO_NONE, writeString }, + { "urle.host", VAR_INPUT_URLEHOST, CURLINFO_NONE, writeString }, + { "urle.options", VAR_INPUT_URLEOPTIONS, CURLINFO_NONE, writeString }, + { "urle.password", VAR_INPUT_URLEPASSWORD, CURLINFO_NONE, writeString }, + { "urle.path", VAR_INPUT_URLEPATH, CURLINFO_NONE, writeString }, + { "urle.port", VAR_INPUT_URLEPORT, CURLINFO_NONE, writeString }, + { "urle.query", VAR_INPUT_URLEQUERY, CURLINFO_NONE, writeString }, + { "urle.scheme", VAR_INPUT_URLESCHEME, CURLINFO_NONE, writeString }, + { "urle.user", VAR_INPUT_URLEUSER, CURLINFO_NONE, writeString }, + { "urle.zoneid", VAR_INPUT_URLEZONEID, CURLINFO_NONE, writeString }, + { "urlnum", VAR_URLNUM, CURLINFO_NONE, writeOffset }, + { "xfer_id", VAR_EASY_ID, CURLINFO_XFER_ID, writeOffset } }; static int writeTime(FILE *stream, const struct writeoutvar *wovar, @@ -254,7 +257,7 @@ static int urlpart(struct per_transfer *per, writeoutid vid, } } if(!rc && curl_url_set(uh, CURLUPART_URL, url, - CURLU_GUESS_SCHEME|CURLU_NON_SUPPORT_SCHEME)) + CURLU_GUESS_SCHEME | CURLU_NON_SUPPORT_SCHEME)) rc = 2; if(!rc && curl_url_get(uh, cpart, &part, CURLU_DEFAULT_PORT)) @@ -286,7 +289,7 @@ static int writeString(FILE *stream, const struct writeoutvar *wovar, const char *strinfo = NULL; const char *freestr = NULL; struct dynbuf buf; - curlx_dyn_init(&buf, 256*1024); + curlx_dyn_init(&buf, 256 * 1024); DEBUGASSERT(wovar->writefunc == writeString); @@ -337,7 +340,7 @@ static int writeString(FILE *stream, const struct writeoutvar *wovar, len = curlx_dyn_len(&buf); if(len) { char *ptr = curlx_dyn_ptr(&buf); - if(ptr[len -1] != '\n') { + if(ptr[len - 1] != '\n') { /* add a newline to make things look better */ if(curlx_dyn_addn(&buf, "\n", 1)) { error = TRUE; @@ -527,8 +530,7 @@ static int writeOffset(FILE *stream, const struct writeoutvar *wovar, return 1; /* return 1 if anything was written */ } -static int -matchvar(const void *m1, const void *m2) +static int matchvar(const void *m1, const void *m2) { const struct writeoutvar *v1 = m1; const struct writeoutvar *v2 = m2; diff --git a/src/tool_writeout_json.c b/src/tool_writeout_json.c index f3175edf95..ee7dda2e9c 100644 --- a/src/tool_writeout_json.c +++ b/src/tool_writeout_json.c @@ -143,8 +143,7 @@ void headerJSON(FILE *stream, struct per_transfer *per) if(++i >= a) break; fputc(',', stream); - if(curl_easy_header(per->curl, name, i, CURLH_HEADER, - -1, &header)) + if(curl_easy_header(per->curl, name, i, CURLH_HEADER, -1, &header)) break; } while(1); fputc(']', stream); diff --git a/src/tool_xattr.h b/src/tool_xattr.h index 31301b3b06..6720ccb2bd 100644 --- a/src/tool_xattr.h +++ b/src/tool_xattr.h @@ -29,7 +29,7 @@ # include /* header from libc, not from libattr */ # define USE_XATTR #elif (defined(__FreeBSD_version) && (__FreeBSD_version > 500000)) || \ - defined(__MidnightBSD_version) + defined(__MidnightBSD_version) # include # include # define USE_XATTR @@ -43,7 +43,7 @@ UNITTEST char *stripcredentials(const char *url); #endif #else -#define fwrite_xattr(a,b,c) 0 +#define fwrite_xattr(a, b, c) 0 #endif #endif /* HEADER_CURL_TOOL_XATTR_H */ diff --git a/src/var.c b/src/var.c index 08269e1db7..e224bf01d5 100644 --- a/src/var.c +++ b/src/var.c @@ -35,7 +35,7 @@ #include "var.h" #define MAX_EXPAND_CONTENT 10000000 -#define MAX_VAR_LEN 128 /* max length of a name */ +#define MAX_VAR_LEN 128 /* max length of a name */ /* free everything */ void varcleanup(void) @@ -53,8 +53,7 @@ static const struct tool_var *varcontent(const char *name, size_t nlen) { struct tool_var *list = global->variables; while(list) { - if((strlen(list->name) == nlen) && - !strncmp(name, list->name, nlen)) { + if((strlen(list->name) == nlen) && !strncmp(name, list->name, nlen)) { return list; } list = list->next; @@ -63,18 +62,18 @@ static const struct tool_var *varcontent(const char *name, size_t nlen) } #define ENDOFFUNC(x) (((x) == '}') || ((x) == ':')) -#define FUNCMATCH(ptr,name,len) \ +#define FUNCMATCH(ptr, name, len) \ (!strncmp(ptr, name, len) && ENDOFFUNC(ptr[len])) -#define FUNC_TRIM "trim" -#define FUNC_TRIM_LEN (sizeof(FUNC_TRIM) - 1) -#define FUNC_JSON "json" -#define FUNC_JSON_LEN (sizeof(FUNC_JSON) - 1) -#define FUNC_URL "url" -#define FUNC_URL_LEN (sizeof(FUNC_URL) - 1) -#define FUNC_B64 "b64" -#define FUNC_B64_LEN (sizeof(FUNC_B64) - 1) -#define FUNC_64DEC "64dec" /* base64 decode */ +#define FUNC_TRIM "trim" +#define FUNC_TRIM_LEN (sizeof(FUNC_TRIM) - 1) +#define FUNC_JSON "json" +#define FUNC_JSON_LEN (sizeof(FUNC_JSON) - 1) +#define FUNC_URL "url" +#define FUNC_URL_LEN (sizeof(FUNC_URL) - 1) +#define FUNC_B64 "b64" +#define FUNC_B64_LEN (sizeof(FUNC_B64) - 1) +#define FUNC_64DEC "64dec" /* base64 decode */ #define FUNC_64DEC_LEN (sizeof(FUNC_64DEC) - 1) static ParameterError varfunc(char *c, /* content */ @@ -105,7 +104,7 @@ static ParameterError varfunc(char *c, /* content */ c++; len--; } - while(len && ISSPACE(c[len-1])) + while(len && ISSPACE(c[len - 1])) len--; } /* put it in the output */ @@ -208,8 +207,7 @@ static ParameterError varfunc(char *c, /* content */ return err; } -ParameterError varexpand(const char *line, struct dynbuf *out, - bool *replaced) +ParameterError varexpand(const char *line, struct dynbuf *out, bool *replaced) { CURLcode result; char *envp; @@ -274,13 +272,12 @@ ParameterError varexpand(const char *line, struct dynbuf *out, name[nlen] = 0; /* verify that the name looks sensible */ - for(i = 0; (i < nlen) && - (ISALNUM(name[i]) || (name[i] == '_')); i++); + for(i = 0; (i < nlen) && (ISALNUM(name[i]) || (name[i] == '_')); i++) + ; if(i != nlen) { warnf("bad variable name: %s", name); /* insert the text as-is since this is not an env variable */ - result = curlx_dyn_addn(out, envp - prefix, - clp - envp + prefix + 2); + result = curlx_dyn_addn(out, envp - prefix, clp - envp + prefix + 2); if(result) return PARAM_NO_MEM; } diff --git a/src/var.h b/src/var.h index 4f1361cf1e..40defea8ac 100644 --- a/src/var.h +++ b/src/var.h @@ -34,8 +34,7 @@ struct tool_var { }; ParameterError setvariable(const char *input); -ParameterError varexpand(const char *line, struct dynbuf *out, - bool *replaced); +ParameterError varexpand(const char *line, struct dynbuf *out, bool *replaced); /* free everything */ void varcleanup(void); diff --git a/tests/test1486.pl b/tests/test1486.pl index 05006ebc63..79f6a856be 100755 --- a/tests/test1486.pl +++ b/tests/test1486.pl @@ -45,7 +45,7 @@ sub getsrcvars { if($_ =~ /^}/) { last; } - if($_ =~ /^ \{\"([^\"]*)/) { + if($_ =~ /^ \{ \"([^\"]*)/) { my $var = $1; $insrc{$var} = $srccount++; } -- 2.47.3