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;
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());
{
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)
}
/* 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);
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) {
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);
#include "fake_addrinfo.h" /* for USE_FAKE_GETADDRINFO */
#include <stdio.h>
-static const char *disabled[]={
+static const char *disabled[] = {
"bindlocal: "
#ifdef CURL_DISABLE_BINDLOCAL
"OFF"
* 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);
* 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 */
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);
}
break;
}
- dump(timebuf, idsbuf, text, output, (unsigned char *) data, size,
+ dump(timebuf, idsbuf, text, output, (unsigned char *)data, size,
global->tracetype, type);
return 0;
}
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
return rc;
}
-
/*
** callback for CURLOPT_HEADERFUNCTION
*
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 */
;
#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);
char *copy;
char *p;
char *q;
- char stop = '\0';
+ char stop = '\0';
copy = memdup0(ptr, len);
if(!copy)
}
/* 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 */
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)
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);
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);
#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;
#endif
}
else {
- rc = read(per->infd, buffer, sz*nmemb);
+ rc = read(per->infd, buffer, sz * nmemb);
if(rc < 0) {
if(errno == EAGAIN) {
errno = 0;
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;
}
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;
}
#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;
#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
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
/* 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.
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;
#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)
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;
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. */
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++) {
*d++ = 'x';
if(d == dlimit)
break;
- *d = 'x';
+ *d = 'x';
}
else {
/* libg++ etc. */
*d++ = 'x';
if(d == dlimit)
break;
- *d = 'x';
+ *d = 'x';
}
else {
memcpy(d, "plus", 4);
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)
{
}
#endif
- if(len > PATH_MAX-1)
+ if(len > PATH_MAX - 1)
return SANITIZE_ERR_INVALID_PATH;
memcpy(fname, file_name, len);
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] = '_';
/* 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] = '_';
struct curl_slist *slist = NULL;
#ifndef CURL_WINDOWS_UWP
HANDLE hnd = INVALID_HANDLE_VALUE;
- MODULEENTRY32 mod = {0};
+ MODULEENTRY32 mod = { 0 };
mod.dwSize = sizeof(MODULEENTRY32);
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) {
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");
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;
/* 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;
}
#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 */
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__
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",
/* 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.",
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");
(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 */
#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 },
# 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)
}
}
-
/* 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. */
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:
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;
if(*ptr == '\\' && (ptr[1] == '\\' || ptr[1] == '"'))
++ptr;
*ptr2++ = *ptr++;
- }
- while(ptr < *end_pos);
+ } while(ptr < *end_pos);
*end_pos = ptr2;
}
++ptr;
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)
return sep & 0xFF;
}
-
/***************************************************************************
*
* formparse()
*
***************************************************************************/
-#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,
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;
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;
SET_TOOL_MIME_PTR(part, encoder);
if(sep) {
- *contp = (char) sep;
+ *contp = (char)sep;
warnf("garbage at end of field specification: %s", contp);
}
}
#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)
{
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 ':':
#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:
url[new_index] = '+';
orig_index += 3;
}
- else{
+ else {
if(new_index != orig_index) {
url[new_index] = url[orig_index];
}
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;
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':
#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,
return err;
}
-static void sethttpver(struct OperationConfig *config,
- long httpversion)
+static void sethttpver(struct OperationConfig *config, long httpversion)
{
if(config->httpversion &&
(config->httpversion != httpversion))
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)) {
};
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)
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);
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");
else if(denominator > numerator)
err = PARAM_NUMBER_TOO_LARGE;
else
- global->ms_per_transfer = numerator/denominator;
+ global->ms_per_transfer = numerator / denominator;
return err;
}
return add_url(config, nextarg, FALSE);
}
-
static ParameterError parse_localport(struct OperationConfig *config,
const char *nextarg)
{
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;
}
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;
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? */
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);
};
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,
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));
#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 */
#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
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 */
}
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)
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 =
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;
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");
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)",
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",
}
/* 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;
}
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);
/* 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);
#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 */
#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,
fputs(prefix, tool_stderr);
if(len > width) {
- size_t cut = width-1;
+ size_t cut = width - 1;
while(!ISBLANK(ptr[cut]) && cut) {
cut--;
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);
}
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");
}
/*
#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 */
char buffer[8192];
curl_off_t count;
int ret_stat;
- FILE * file;
+ FILE *file;
/* !checksrc! disable FOPENMODE 1 */
file = curlx_fopen(name, "r"); /* VMS */
* 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:
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",
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 */
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"));
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);
}
}
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)) {
return result;
}
-
/*
* Call this after a transfer has completed.
*/
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! */
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);
}
}
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, "
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 {
/*
* 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;
}
}
/* 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);
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);
#if defined(DEBUGBUILD) && defined(USE_LIBUV)
-#define DEBUG_UV 0
+#define DEBUG_UV 0
/* object to pass to the callbacks */
struct datauv {
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;
/* 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
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 */
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);
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
return result;
}
-
CURLcode operate(int argc, argv_item_t argv[])
{
CURLcode result = CURLE_OK;
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;
*val = (long)num;
if(is_neg)
*val = -*val;
- return PARAM_OK; /* Ok */
+ return PARAM_OK; /* Ok */
}
}
return PARAM_BAD_NUMERIC; /* badness */
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;
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--;
}
{
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)
* 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)
{
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;
}
}
}
/* 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++)
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 */
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;
}
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
/* 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
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) {
|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;
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;
}
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 */
}
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;
}
time_spent,
time_left,
max5data(speed, buffer[2]), /* speed */
- final ? "\n" :"");
+ final ? "\n" : "");
return TRUE;
}
return FALSE;
TRACE_PLAIN /* -v/--verbose type */
} trace;
-
/*
* 'HttpReq' enumeration represents HTTP request types.
*/
TOOL_HTTPREQ_PUT
} HttpReq;
-
/*
* Complete struct declarations which have OperationConfig struct members,
* just in case this header is directly included in some source file.
/* 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),
};
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),
/* 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)
{
/* 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);
}
}
}
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)
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;
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 */
...) 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 */
*/
#ifdef macintosh
-# define main(x,y) curl_main(x,y)
+# define main(x, y) curl_main(x, y)
#endif
#ifndef CURL_OS
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
/* 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)
{
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;
}
return 1;
#else
sum = *amount * with;
- if(sum/with != *amount)
+ if(sum / with != *amount)
return 1; /* did not fit, bail out */
#endif
}
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;
/* 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;
else {
if(!*pattern) /* done */
break;
- else if(*pattern =='{') {
+ else if(*pattern == '{') {
/* process set pattern */
pattern++;
pos++;
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;
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)
/* 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
***************************************************************************/
#include <curl/curlver.h>
-#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 */
/* Invalid DECC feature name. */
curl_mprintf(" UNKNOWN DECC FEATURE: %s.\n", decc_feat_array[i].name);
}
-
}
}
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
#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 */
};
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
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,
}
}
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))
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);
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;
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;
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);
# include <sys/xattr.h> /* header from libc, not from libattr */
# define USE_XATTR
#elif (defined(__FreeBSD_version) && (__FreeBSD_version > 500000)) || \
- defined(__MidnightBSD_version)
+ defined(__MidnightBSD_version)
# include <sys/types.h>
# include <sys/extattr.h>
# define USE_XATTR
#endif
#else
-#define fwrite_xattr(a,b,c) 0
+#define fwrite_xattr(a, b, c) 0
#endif
#endif /* HEADER_CURL_TOOL_XATTR_H */
#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)
{
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;
}
#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 */
c++;
len--;
}
- while(len && ISSPACE(c[len-1]))
+ while(len && ISSPACE(c[len - 1]))
len--;
}
/* put it in the output */
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;
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;
}
};
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);
if($_ =~ /^}/) {
last;
}
- if($_ =~ /^ \{\"([^\"]*)/) {
+ if($_ =~ /^ \{ \"([^\"]*)/) {
my $var = $1;
$insrc{$var} = $srccount++;
}