source cleanup: remove all custom typedef structs

- Stick to a single unified way to use structs
 - Make checksrc complain on 'typedef struct {'
 - Allow them in tests, public headers and examples

 - Let MD4_CTX, MD5_CTX, and SHA256_CTX typedefs remain as they actually
   typedef different types/structs depending on build conditions.

Closes #5338
This commit is contained in:
Daniel Stenberg 2020-05-14 00:05:04 +02:00
parent 5d54b5e697
commit 8df455479f
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
71 changed files with 718 additions and 672 deletions

View file

@ -37,8 +37,8 @@ struct GlobalConfig;
struct State {
struct getout *urlnode;
URLGlob *inglob;
URLGlob *urls;
struct URLGlob *inglob;
struct URLGlob *urls;
char *outfiles;
char *httpgetfields;
char *uploadfile;
@ -194,8 +194,8 @@ struct OperationConfig {
curl_off_t condtime;
struct curl_slist *headers;
struct curl_slist *proxyheaders;
tool_mime *mimeroot;
tool_mime *mimecurrent;
struct tool_mime *mimeroot;
struct tool_mime *mimecurrent;
curl_mime *mimepost;
struct curl_slist *telnet_options;
struct curl_slist *resolve;
@ -261,8 +261,8 @@ struct OperationConfig {
bool native_ca_store; /* use the native os ca store */
bool use_metalink; /* process given URLs as metalink XML file */
metalinkfile *metalinkfile_list; /* point to the first node */
metalinkfile *metalinkfile_last; /* point to the last/current node */
struct metalinkfile *metalinkfile_list; /* point to the first node */
struct metalinkfile *metalinkfile_last; /* point to the last/current node */
char *oauth_bearer; /* OAuth 2.0 bearer token */
bool nonpn; /* enable/disable TLS NPN extension */
bool noalpn; /* enable/disable TLS ALPN extension */

View file

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@ -42,9 +42,10 @@
#define CONST_SAFEFREE(x) Curl_safefree(*((void **) &(x)))
/* tool_mime functions. */
static tool_mime *tool_mime_new(tool_mime *parent, toolmimekind kind)
static struct tool_mime *tool_mime_new(struct tool_mime *parent,
toolmimekind kind)
{
tool_mime *m = (tool_mime *) calloc(1, sizeof(*m));
struct tool_mime *m = (struct tool_mime *) calloc(1, sizeof(*m));
if(m) {
m->kind = kind;
@ -57,14 +58,15 @@ static tool_mime *tool_mime_new(tool_mime *parent, toolmimekind kind)
return m;
}
static tool_mime *tool_mime_new_parts(tool_mime *parent)
static struct tool_mime *tool_mime_new_parts(struct tool_mime *parent)
{
return tool_mime_new(parent, TOOLMIME_PARTS);
}
static tool_mime *tool_mime_new_data(tool_mime *parent, const char *data)
static struct tool_mime *tool_mime_new_data(struct tool_mime *parent,
const char *data)
{
tool_mime *m = NULL;
struct tool_mime *m = NULL;
data = strdup(data);
if(data) {
@ -77,13 +79,13 @@ static tool_mime *tool_mime_new_data(tool_mime *parent, const char *data)
return m;
}
static tool_mime *tool_mime_new_filedata(tool_mime *parent,
const char *filename,
bool isremotefile,
CURLcode *errcode)
static struct tool_mime *tool_mime_new_filedata(struct tool_mime *parent,
const char *filename,
bool isremotefile,
CURLcode *errcode)
{
CURLcode result = CURLE_OK;
tool_mime *m = NULL;
struct tool_mime *m = NULL;
*errcode = CURLE_OUT_OF_MEMORY;
if(strcmp(filename, "-")) {
@ -159,7 +161,7 @@ static tool_mime *tool_mime_new_filedata(tool_mime *parent,
return m;
}
void tool_mime_free(tool_mime *mime)
void tool_mime_free(struct tool_mime *mime)
{
if(mime) {
if(mime->subparts)
@ -181,7 +183,7 @@ void tool_mime_free(tool_mime *mime)
size_t tool_mime_stdin_read(char *buffer,
size_t size, size_t nitems, void *arg)
{
tool_mime *sip = (tool_mime *) arg;
struct tool_mime *sip = (struct tool_mime *) arg;
curl_off_t bytesleft;
(void) size; /* Always 1: ignored. */
@ -216,7 +218,7 @@ size_t tool_mime_stdin_read(char *buffer,
int tool_mime_stdin_seek(void *instream, curl_off_t offset, int whence)
{
tool_mime *sip = (tool_mime *) instream;
struct tool_mime *sip = (struct tool_mime *) instream;
switch(whence) {
case SEEK_CUR:
@ -238,7 +240,8 @@ int tool_mime_stdin_seek(void *instream, curl_off_t offset, int whence)
/* Translate an internal mime tree into a libcurl mime tree. */
static CURLcode tool2curlparts(CURL *curl, tool_mime *m, curl_mime *mime)
static CURLcode tool2curlparts(CURL *curl, struct tool_mime *m,
curl_mime *mime)
{
CURLcode ret = CURLE_OK;
curl_mimepart *part = NULL;
@ -323,7 +326,7 @@ static CURLcode tool2curlparts(CURL *curl, tool_mime *m, curl_mime *mime)
return ret;
}
CURLcode tool2curlmime(CURL *curl, tool_mime *m, curl_mime **mime)
CURLcode tool2curlmime(CURL *curl, struct tool_mime *m, curl_mime **mime)
{
CURLcode ret = CURLE_OK;
@ -733,8 +736,8 @@ static int get_param_part(struct OperationConfig *config, char endchar,
int formparse(struct OperationConfig *config,
const char *input,
tool_mime **mimeroot,
tool_mime **mimecurrent,
struct tool_mime **mimeroot,
struct tool_mime **mimecurrent,
bool literal_value)
{
/* input MUST be a string in the format 'name=contents' and we'll
@ -747,7 +750,7 @@ int formparse(struct OperationConfig *config,
char *filename = NULL;
char *encoder = NULL;
struct curl_slist *headers = NULL;
tool_mime *part = NULL;
struct tool_mime *part = NULL;
CURLcode res;
/* Allocate the main mime structure if needed. */
@ -794,7 +797,7 @@ int formparse(struct OperationConfig *config,
/* we use the @-letter to indicate file name(s) */
tool_mime *subparts = NULL;
struct tool_mime *subparts = NULL;
do {
/* since this was a file, it may have a content-type specifier

View file

@ -35,12 +35,11 @@ typedef enum {
TOOLMIME_STDINDATA
} toolmimekind;
typedef struct tool_mime tool_mime;
struct tool_mime {
/* Structural fields. */
toolmimekind kind; /* Part kind. */
tool_mime *parent; /* Parent item. */
tool_mime *prev; /* Previous sibling (reverse order link). */
struct tool_mime *parent; /* Parent item. */
struct tool_mime *prev; /* Previous sibling (reverse order link). */
/* Common fields. */
const char *data; /* Actual data or data filename. */
const char *name; /* Part name. */
@ -49,7 +48,7 @@ struct tool_mime {
const char *encoder; /* Part's requested encoding. */
struct curl_slist *headers; /* User-defined headers. */
/* TOOLMIME_PARTS fields. */
tool_mime *subparts; /* Part's subparts. */
struct tool_mime *subparts; /* Part's subparts. */
/* TOOLMIME_STDIN/TOOLMIME_STDINDATA fields. */
curl_off_t origin; /* Stdin read origin offset. */
curl_off_t size; /* Stdin data size. */
@ -63,10 +62,10 @@ int tool_mime_stdin_seek(void *instream, curl_off_t offset, int whence);
int formparse(struct OperationConfig *config,
const char *input,
tool_mime **mimeroot,
tool_mime **mimecurrent,
struct tool_mime **mimeroot,
struct tool_mime **mimecurrent,
bool literal_value);
CURLcode tool2curlmime(CURL *curl, tool_mime *m, curl_mime **mime);
void tool_mime_free(tool_mime *mime);
CURLcode tool2curlmime(CURL *curl, struct tool_mime *m, curl_mime **mime);
void tool_mime_free(struct tool_mime *mime);
#endif /* HEADER_CURL_TOOL_FORMPARSE_H */

View file

@ -399,7 +399,7 @@ static void SHA256_Final(unsigned char digest[32], SHA256_CTX *ctx)
#endif /* CRYPTO LIBS */
const digest_params MD5_DIGEST_PARAMS[] = {
const struct digest_params MD5_DIGEST_PARAMS[] = {
{
CURLX_FUNCTION_CAST(digest_init_func, MD5_Init),
CURLX_FUNCTION_CAST(digest_update_func, MD5_Update),
@ -409,7 +409,7 @@ const digest_params MD5_DIGEST_PARAMS[] = {
}
};
const digest_params SHA1_DIGEST_PARAMS[] = {
const struct digest_params SHA1_DIGEST_PARAMS[] = {
{
CURLX_FUNCTION_CAST(digest_init_func, SHA1_Init),
CURLX_FUNCTION_CAST(digest_update_func, SHA1_Update),
@ -419,7 +419,7 @@ const digest_params SHA1_DIGEST_PARAMS[] = {
}
};
const digest_params SHA256_DIGEST_PARAMS[] = {
const struct digest_params SHA256_DIGEST_PARAMS[] = {
{
CURLX_FUNCTION_CAST(digest_init_func, SHA256_Init),
CURLX_FUNCTION_CAST(digest_update_func, SHA256_Update),
@ -429,15 +429,15 @@ const digest_params SHA256_DIGEST_PARAMS[] = {
}
};
static const metalink_digest_def SHA256_DIGEST_DEF[] = {
static const struct metalink_digest_def SHA256_DIGEST_DEF[] = {
{"sha-256", SHA256_DIGEST_PARAMS}
};
static const metalink_digest_def SHA1_DIGEST_DEF[] = {
static const struct metalink_digest_def SHA1_DIGEST_DEF[] = {
{"sha-1", SHA1_DIGEST_PARAMS}
};
static const metalink_digest_def MD5_DIGEST_DEF[] = {
static const struct metalink_digest_def MD5_DIGEST_DEF[] = {
{"md5", MD5_DIGEST_PARAMS}
};
@ -448,7 +448,7 @@ static const metalink_digest_def MD5_DIGEST_DEF[] = {
* "Hash Function Textual Names". The latter is widely (and
* historically) used in Metalink version 3.
*/
static const metalink_digest_alias digest_aliases[] = {
static const struct metalink_digest_alias digest_aliases[] = {
{"sha-256", SHA256_DIGEST_DEF},
{"sha256", SHA256_DIGEST_DEF},
{"sha-1", SHA1_DIGEST_DEF},
@ -457,13 +457,9 @@ static const metalink_digest_alias digest_aliases[] = {
{NULL, NULL}
};
static digest_context *digest_init(const digest_params *dparams)
static struct digest_context *digest_init(const struct digest_params *dparams)
{
digest_context *ctxt;
/* Create digest context */
ctxt = malloc(sizeof(*ctxt));
struct digest_context *ctxt = malloc(sizeof(*ctxt));
if(!ctxt)
return ctxt;
@ -485,7 +481,7 @@ static digest_context *digest_init(const digest_params *dparams)
return ctxt;
}
static int digest_update(digest_context *context,
static int digest_update(struct digest_context *context,
const unsigned char *data,
unsigned int len)
{
@ -494,7 +490,7 @@ static int digest_update(digest_context *context,
return 0;
}
static int digest_final(digest_context *context, unsigned char *result)
static int digest_final(struct digest_context *context, unsigned char *result)
{
if(result)
(*context->digest_hash->digest_final)(result, context->digest_hashctx);
@ -531,11 +527,11 @@ static unsigned char hex_to_uint(const char *s)
* Hash algorithm not available.
*/
static int check_hash(const char *filename,
const metalink_digest_def *digest_def,
const struct metalink_digest_def *digest_def,
const unsigned char *digest, FILE *error)
{
unsigned char *result;
digest_context *dctx;
struct digest_context *dctx;
int check_ok, flags, fd;
flags = O_RDONLY;
@ -597,7 +593,7 @@ static int check_hash(const char *filename,
}
int metalink_check_hash(struct GlobalConfig *config,
metalinkfile *mlfile,
struct metalinkfile *mlfile,
const char *filename)
{
int rv;
@ -612,11 +608,11 @@ int metalink_check_hash(struct GlobalConfig *config,
return rv;
}
static metalink_checksum *
checksum_from_hex_digest(const metalink_digest_def *digest_def,
static struct metalink_checksum *
checksum_from_hex_digest(const struct metalink_digest_def *digest_def,
const char *hex_digest)
{
metalink_checksum *chksum;
struct metalink_checksum *chksum;
unsigned char *digest;
size_t i;
size_t len = strlen(hex_digest);
@ -627,7 +623,7 @@ checksum_from_hex_digest(const metalink_digest_def *digest_def,
for(i = 0; i < len; i += 2) {
digest[i/2] = hex_to_uint(hex_digest + i);
}
chksum = malloc(sizeof(metalink_checksum));
chksum = malloc(sizeof(struct metalink_checksum));
if(chksum) {
chksum->digest_def = digest_def;
chksum->digest = digest;
@ -637,10 +633,9 @@ checksum_from_hex_digest(const metalink_digest_def *digest_def,
return chksum;
}
static metalink_resource *new_metalink_resource(const char *url)
static struct metalink_resource *new_metalink_resource(const char *url)
{
metalink_resource *res;
res = malloc(sizeof(metalink_resource));
struct metalink_resource *res = malloc(sizeof(struct metalink_resource));
if(res) {
res->next = NULL;
res->url = strdup(url);
@ -656,7 +651,7 @@ static metalink_resource *new_metalink_resource(const char *url)
letter is in [0-9A-Za-z] and the length of the string equals to the
result length of digest * 2. */
static int check_hex_digest(const char *hex_digest,
const metalink_digest_def *digest_def)
const struct metalink_digest_def *digest_def)
{
size_t i;
for(i = 0; hex_digest[i]; ++i) {
@ -669,10 +664,9 @@ static int check_hex_digest(const char *hex_digest,
return digest_def->dparams->digest_resultlen * 2 == i;
}
static metalinkfile *new_metalinkfile(metalink_file_t *fileinfo)
static struct metalinkfile *new_metalinkfile(metalink_file_t *fileinfo)
{
metalinkfile *f;
f = (metalinkfile*)malloc(sizeof(metalinkfile));
struct metalinkfile *f = malloc(sizeof(struct metalinkfile));
if(!f)
return NULL;
@ -685,7 +679,7 @@ static metalinkfile *new_metalinkfile(metalink_file_t *fileinfo)
f->checksum = NULL;
f->resource = NULL;
if(fileinfo->checksums) {
const metalink_digest_alias *digest_alias;
const struct metalink_digest_alias *digest_alias;
for(digest_alias = digest_aliases; digest_alias->alias_name;
++digest_alias) {
metalink_checksum_t **p;
@ -705,11 +699,11 @@ static metalinkfile *new_metalinkfile(metalink_file_t *fileinfo)
}
if(fileinfo->resources) {
metalink_resource_t **p;
metalink_resource root, *tail;
struct metalink_resource root, *tail;
root.next = NULL;
tail = &root;
for(p = fileinfo->resources; *p; ++p) {
metalink_resource *res;
struct metalink_resource *res;
/* Filter by type if it is non-NULL. In Metalink v3, type
includes the type of the resource. In curl, we are only
interested in HTTP, HTTPS and FTP. In addition to them,
@ -798,7 +792,7 @@ int parse_metalink(struct OperationConfig *config, struct OutStruct *outs,
url = new_getout(config);
if(url) {
metalinkfile *mlfile = new_metalinkfile(*files);
struct metalinkfile *mlfile = new_metalinkfile(*files);
if(!mlfile)
break;
@ -876,24 +870,23 @@ int check_metalink_content_type(const char *content_type)
return check_content_type(content_type, "application/metalink+xml");
}
int count_next_metalink_resource(metalinkfile *mlfile)
int count_next_metalink_resource(struct metalinkfile *mlfile)
{
int count = 0;
metalink_resource *res;
struct metalink_resource *res;
for(res = mlfile->resource; res; res = res->next, ++count);
return count;
}
static void delete_metalink_checksum(metalink_checksum *chksum)
static void delete_metalink_checksum(struct metalink_checksum *chksum)
{
if(chksum == NULL) {
if(!chksum)
return;
}
Curl_safefree(chksum->digest);
Curl_safefree(chksum);
}
static void delete_metalink_resource(metalink_resource *res)
static void delete_metalink_resource(struct metalink_resource *res)
{
if(res == NULL) {
return;
@ -902,16 +895,16 @@ static void delete_metalink_resource(metalink_resource *res)
Curl_safefree(res);
}
void delete_metalinkfile(metalinkfile *mlfile)
void delete_metalinkfile(struct metalinkfile *mlfile)
{
metalink_resource *res;
struct metalink_resource *res;
if(mlfile == NULL) {
return;
}
Curl_safefree(mlfile->filename);
delete_metalink_checksum(mlfile->checksum);
for(res = mlfile->resource; res;) {
metalink_resource *next;
struct metalink_resource *next;
next = res->next;
delete_metalink_resource(res);
res = next;
@ -923,7 +916,7 @@ void clean_metalink(struct OperationConfig *config)
{
if(config) {
while(config->metalinkfile_list) {
metalinkfile *mlfile = config->metalinkfile_list;
struct metalinkfile *mlfile = config->metalinkfile_list;
config->metalinkfile_list = config->metalinkfile_list->next;
delete_metalinkfile(mlfile);
}

View file

@ -35,46 +35,46 @@ typedef void (*digest_update_func)(void *context,
unsigned int len);
typedef void (*digest_final_func)(unsigned char *result, void *context);
typedef struct {
struct digest_params {
digest_init_func digest_init; /* Initialize context procedure */
digest_update_func digest_update; /* Update context with data */
digest_final_func digest_final; /* Get final result procedure */
unsigned int digest_ctxtsize; /* Context structure size */
unsigned int digest_resultlen; /* Result length (bytes) */
} digest_params;
};
typedef struct {
const digest_params *digest_hash; /* Hash function definition */
struct digest_context {
const struct digest_params *digest_hash; /* Hash function definition */
void *digest_hashctx; /* Hash function context */
} digest_context;
};
typedef struct {
struct metalink_digest_def {
const char *hash_name;
const digest_params *dparams;
} metalink_digest_def;
const struct digest_params *dparams;
};
typedef struct {
struct metalink_digest_alias {
const char *alias_name;
const metalink_digest_def *digest_def;
} metalink_digest_alias;
const struct metalink_digest_def *digest_def;
};
typedef struct metalink_checksum {
const metalink_digest_def *digest_def;
struct metalink_checksum {
const struct metalink_digest_def *digest_def;
/* raw digest value, not ascii hex digest */
unsigned char *digest;
} metalink_checksum;
};
typedef struct metalink_resource {
struct metalink_resource {
struct metalink_resource *next;
char *url;
} metalink_resource;
};
typedef struct metalinkfile {
struct metalinkfile {
struct metalinkfile *next;
char *filename;
metalink_checksum *checksum;
metalink_resource *resource;
} metalinkfile;
struct metalink_checksum *checksum;
struct metalink_resource *resource;
};
#ifdef USE_METALINK
@ -89,18 +89,18 @@ typedef struct metalinkfile {
(CURL_REQ_LIBMETALINK_MINOR * 100) + \
CURL_REQ_LIBMETALINK_PATCH)
extern const digest_params MD5_DIGEST_PARAMS[1];
extern const digest_params SHA1_DIGEST_PARAMS[1];
extern const digest_params SHA256_DIGEST_PARAMS[1];
extern const struct digest_params MD5_DIGEST_PARAMS[1];
extern const struct digest_params SHA1_DIGEST_PARAMS[1];
extern const struct digest_params SHA256_DIGEST_PARAMS[1];
#include <metalink/metalink.h>
/*
* Counts the resource in the metalinkfile.
*/
int count_next_metalink_resource(metalinkfile *mlfile);
int count_next_metalink_resource(struct metalinkfile *mlfile);
void delete_metalinkfile(metalinkfile *mlfile);
void delete_metalinkfile(struct metalinkfile *mlfile);
void clean_metalink(struct OperationConfig *config);
/*
@ -143,7 +143,7 @@ int check_metalink_content_type(const char *content_type);
* Metalink does not contain checksum.
*/
int metalink_check_hash(struct GlobalConfig *config,
metalinkfile *mlfile,
struct metalinkfile *mlfile,
const char *filename);
/*

View file

@ -699,7 +699,7 @@ static CURLcode single_transfer(struct GlobalConfig *global,
{
CURLcode result = CURLE_OK;
struct getout *urlnode;
metalinkfile *mlfile_last = NULL;
struct metalinkfile *mlfile_last = NULL;
bool orig_noprogress = global->noprogress;
bool orig_isatty = global->isatty;
struct State *state = &config->state;
@ -740,10 +740,10 @@ static CURLcode single_transfer(struct GlobalConfig *global,
while(config->state.urlnode) {
char *infiles; /* might be a glob pattern */
URLGlob *inglob = state->inglob;
struct URLGlob *inglob = state->inglob;
bool metalink = FALSE; /* metalink download? */
metalinkfile *mlfile;
metalink_resource *mlres;
struct metalinkfile *mlfile;
struct metalink_resource *mlres;
urlnode = config->state.urlnode;
if(urlnode->flags & GETOUT_METALINK) {

View file

@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@ -38,8 +38,8 @@ struct per_transfer {
struct timeval retrystart;
bool metalink; /* nonzero for metalink download. */
bool metalink_next_res;
metalinkfile *mlfile;
metalink_resource *mlres;
struct metalinkfile *mlfile;
struct metalink_resource *mlres;
char *this_url;
char *outfile;
bool infdopen; /* TRUE if infd needs closing */

View file

@ -43,7 +43,7 @@
#define NV1(e, v) {#e, (v)}
#define NVEND {NULL, 0} /* sentinel to mark end of list */
const NameValue setopt_nv_CURLPROXY[] = {
const struct NameValue setopt_nv_CURLPROXY[] = {
NV(CURLPROXY_HTTP),
NV(CURLPROXY_HTTP_1_0),
NV(CURLPROXY_HTTPS),
@ -54,7 +54,7 @@ const NameValue setopt_nv_CURLPROXY[] = {
NVEND,
};
const NameValue setopt_nv_CURL_SOCKS_PROXY[] = {
const struct NameValue setopt_nv_CURL_SOCKS_PROXY[] = {
NV(CURLPROXY_SOCKS4),
NV(CURLPROXY_SOCKS5),
NV(CURLPROXY_SOCKS4A),
@ -62,7 +62,7 @@ const NameValue setopt_nv_CURL_SOCKS_PROXY[] = {
NVEND,
};
const NameValueUnsigned setopt_nv_CURLAUTH[] = {
const struct NameValueUnsigned setopt_nv_CURLAUTH[] = {
NV(CURLAUTH_ANY), /* combination */
NV(CURLAUTH_ANYSAFE), /* combination */
NV(CURLAUTH_BASIC),
@ -76,7 +76,7 @@ const NameValueUnsigned setopt_nv_CURLAUTH[] = {
NVEND,
};
const NameValue setopt_nv_CURL_HTTP_VERSION[] = {
const struct NameValue setopt_nv_CURL_HTTP_VERSION[] = {
NV(CURL_HTTP_VERSION_NONE),
NV(CURL_HTTP_VERSION_1_0),
NV(CURL_HTTP_VERSION_1_1),
@ -86,7 +86,7 @@ const NameValue setopt_nv_CURL_HTTP_VERSION[] = {
NVEND,
};
const NameValue setopt_nv_CURL_SSLVERSION[] = {
const struct NameValue setopt_nv_CURL_SSLVERSION[] = {
NV(CURL_SSLVERSION_DEFAULT),
NV(CURL_SSLVERSION_TLSv1),
NV(CURL_SSLVERSION_SSLv2),
@ -98,7 +98,7 @@ const NameValue setopt_nv_CURL_SSLVERSION[] = {
NVEND,
};
const NameValue setopt_nv_CURL_TIMECOND[] = {
const struct NameValue setopt_nv_CURL_TIMECOND[] = {
NV(CURL_TIMECOND_IFMODSINCE),
NV(CURL_TIMECOND_IFUNMODSINCE),
NV(CURL_TIMECOND_LASTMOD),
@ -106,14 +106,14 @@ const NameValue setopt_nv_CURL_TIMECOND[] = {
NVEND,
};
const NameValue setopt_nv_CURLFTPSSL_CCC[] = {
const struct NameValue setopt_nv_CURLFTPSSL_CCC[] = {
NV(CURLFTPSSL_CCC_NONE),
NV(CURLFTPSSL_CCC_PASSIVE),
NV(CURLFTPSSL_CCC_ACTIVE),
NVEND,
};
const NameValue setopt_nv_CURLUSESSL[] = {
const struct NameValue setopt_nv_CURLUSESSL[] = {
NV(CURLUSESSL_NONE),
NV(CURLUSESSL_TRY),
NV(CURLUSESSL_CONTROL),
@ -121,7 +121,7 @@ const NameValue setopt_nv_CURLUSESSL[] = {
NVEND,
};
const NameValueUnsigned setopt_nv_CURLSSLOPT[] = {
const struct NameValueUnsigned setopt_nv_CURLSSLOPT[] = {
NV(CURLSSLOPT_ALLOW_BEAST),
NV(CURLSSLOPT_NO_REVOKE),
NV(CURLSSLOPT_NO_PARTIALCHAIN),
@ -130,7 +130,7 @@ const NameValueUnsigned setopt_nv_CURLSSLOPT[] = {
NVEND,
};
const NameValue setopt_nv_CURL_NETRC[] = {
const struct NameValue setopt_nv_CURL_NETRC[] = {
NV(CURL_NETRC_IGNORED),
NV(CURL_NETRC_OPTIONAL),
NV(CURL_NETRC_REQUIRED),
@ -139,7 +139,7 @@ const NameValue setopt_nv_CURL_NETRC[] = {
/* These mappings essentially triplicated - see
* tool_libinfo.c and tool_paramhlp.c */
const NameValue setopt_nv_CURLPROTO[] = {
const struct NameValue setopt_nv_CURLPROTO[] = {
NV(CURLPROTO_ALL), /* combination */
NV(CURLPROTO_DICT),
NV(CURLPROTO_FILE),
@ -167,7 +167,7 @@ const NameValue setopt_nv_CURLPROTO[] = {
};
/* These options have non-zero default values. */
static const NameValue setopt_nv_CURLNONZERODEFAULTS[] = {
static const struct NameValue setopt_nv_CURLNONZERODEFAULTS[] = {
NV1(CURLOPT_SSL_VERIFYPEER, 1),
NV1(CURLOPT_SSL_VERIFYHOST, 1),
NV1(CURLOPT_SSL_ENABLE_NPN, 1),
@ -273,7 +273,7 @@ static char *c_escape(const char *str, size_t len)
/* setopt wrapper for enum types */
CURLcode tool_setopt_enum(CURL *curl, struct GlobalConfig *config,
const char *name, CURLoption tag,
const NameValue *nvlist, long lval)
const struct NameValue *nvlist, long lval)
{
CURLcode ret = CURLE_OK;
bool skip = FALSE;
@ -284,7 +284,7 @@ CURLcode tool_setopt_enum(CURL *curl, struct GlobalConfig *config,
if(config->libcurl && !skip && !ret) {
/* we only use this for real if --libcurl was used */
const NameValue *nv = NULL;
const struct NameValue *nv = NULL;
for(nv = nvlist; nv->name; nv++) {
if(nv->value == lval)
break; /* found it */
@ -307,7 +307,7 @@ CURLcode tool_setopt_enum(CURL *curl, struct GlobalConfig *config,
/* setopt wrapper for flags */
CURLcode tool_setopt_flags(CURL *curl, struct GlobalConfig *config,
const char *name, CURLoption tag,
const NameValue *nvlist, long lval)
const struct NameValue *nvlist, long lval)
{
CURLcode ret = CURLE_OK;
bool skip = FALSE;
@ -320,7 +320,7 @@ CURLcode tool_setopt_flags(CURL *curl, struct GlobalConfig *config,
/* we only use this for real if --libcurl was used */
char preamble[80]; /* should accommodate any symbol name */
long rest = lval; /* bits not handled yet */
const NameValue *nv = NULL;
const struct NameValue *nv = NULL;
msnprintf(preamble, sizeof(preamble),
"curl_easy_setopt(hnd, %s, ", name);
for(nv = nvlist; nv->name; nv++) {
@ -349,7 +349,7 @@ CURLcode tool_setopt_flags(CURL *curl, struct GlobalConfig *config,
/* setopt wrapper for bitmasks */
CURLcode tool_setopt_bitmask(CURL *curl, struct GlobalConfig *config,
const char *name, CURLoption tag,
const NameValueUnsigned *nvlist,
const struct NameValueUnsigned *nvlist,
long lval)
{
CURLcode ret = CURLE_OK;
@ -363,7 +363,7 @@ CURLcode tool_setopt_bitmask(CURL *curl, struct GlobalConfig *config,
/* we only use this for real if --libcurl was used */
char preamble[80];
unsigned long rest = (unsigned long)lval;
const NameValueUnsigned *nv = NULL;
const struct NameValueUnsigned *nv = NULL;
msnprintf(preamble, sizeof(preamble),
"curl_easy_setopt(hnd, %s, ", name);
for(nv = nvlist; nv->name; nv++) {
@ -418,13 +418,13 @@ static CURLcode libcurl_generate_slist(struct curl_slist *slist, int *slistno)
static CURLcode libcurl_generate_mime(CURL *curl,
struct GlobalConfig *config,
tool_mime *toolmime,
struct tool_mime *toolmime,
int *mimeno); /* Forward. */
/* Wrapper to generate source code for a mime part. */
static CURLcode libcurl_generate_mime_part(CURL *curl,
struct GlobalConfig *config,
tool_mime *part,
struct tool_mime *part,
int mimeno)
{
CURLcode ret = CURLE_OK;
@ -557,7 +557,7 @@ nomem:
/* Wrapper to generate source code for a mime structure. */
static CURLcode libcurl_generate_mime(CURL *curl,
struct GlobalConfig *config,
tool_mime *toolmime,
struct tool_mime *toolmime,
int *mimeno)
{
CURLcode ret = CURLE_OK;
@ -641,7 +641,7 @@ CURLcode tool_setopt(CURL *curl, bool str, struct GlobalConfig *config,
/* Value is expected to be a long */
long lval = va_arg(arg, long);
long defval = 0L;
const NameValue *nv = NULL;
const struct NameValue *nv = NULL;
for(nv = setopt_nv_CURLNONZERODEFAULTS; nv->name; nv++) {
if(!strcmp(name, nv->name)) {
defval = nv->value;

View file

@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@ -43,27 +43,27 @@ bool tool_setopt_skip(CURLoption tag);
#ifndef CURL_DISABLE_LIBCURL_OPTION
/* Associate symbolic names with option values */
typedef struct {
struct NameValue {
const char *name;
long value;
} NameValue;
};
typedef struct {
struct NameValueUnsigned {
const char *name;
unsigned long value;
} NameValueUnsigned;
};
extern const NameValue setopt_nv_CURLPROXY[];
extern const NameValue setopt_nv_CURL_SOCKS_PROXY[];
extern const NameValue setopt_nv_CURL_HTTP_VERSION[];
extern const NameValue setopt_nv_CURL_SSLVERSION[];
extern const NameValue setopt_nv_CURL_TIMECOND[];
extern const NameValue setopt_nv_CURLFTPSSL_CCC[];
extern const NameValue setopt_nv_CURLUSESSL[];
extern const NameValueUnsigned setopt_nv_CURLSSLOPT[];
extern const NameValue setopt_nv_CURL_NETRC[];
extern const NameValue setopt_nv_CURLPROTO[];
extern const NameValueUnsigned setopt_nv_CURLAUTH[];
extern const struct NameValue setopt_nv_CURLPROXY[];
extern const struct NameValue setopt_nv_CURL_SOCKS_PROXY[];
extern const struct NameValue setopt_nv_CURL_HTTP_VERSION[];
extern const struct NameValue setopt_nv_CURL_SSLVERSION[];
extern const struct NameValue setopt_nv_CURL_TIMECOND[];
extern const struct NameValue setopt_nv_CURLFTPSSL_CCC[];
extern const struct NameValue setopt_nv_CURLUSESSL[];
extern const struct NameValueUnsigned setopt_nv_CURLSSLOPT[];
extern const struct NameValue setopt_nv_CURL_NETRC[];
extern const struct NameValue setopt_nv_CURLPROTO[];
extern const struct NameValueUnsigned setopt_nv_CURLAUTH[];
/* Map options to NameValue sets */
#define setopt_nv_CURLOPT_HTTP_VERSION setopt_nv_CURL_HTTP_VERSION
@ -85,13 +85,13 @@ extern const NameValueUnsigned setopt_nv_CURLAUTH[];
CURLcode tool_setopt_enum(CURL *curl, struct GlobalConfig *config,
const char *name, CURLoption tag,
const NameValue *nv, long lval);
const struct NameValue *nv, long lval);
CURLcode tool_setopt_flags(CURL *curl, struct GlobalConfig *config,
const char *name, CURLoption tag,
const NameValue *nv, long lval);
const struct NameValue *nv, long lval);
CURLcode tool_setopt_bitmask(CURL *curl, struct GlobalConfig *config,
const char *name, CURLoption tag,
const NameValueUnsigned *nv, long lval);
const struct NameValueUnsigned *nv, long lval);
CURLcode tool_setopt_mimepost(CURL *curl, struct GlobalConfig *config,
const char *name, CURLoption tag,
curl_mime *mimepost);

View file

@ -34,9 +34,9 @@
#define GLOBERROR(string, column, code) \
glob->error = string, glob->pos = column, code
static CURLcode glob_fixed(URLGlob *glob, char *fixed, size_t len)
static CURLcode glob_fixed(struct URLGlob *glob, char *fixed, size_t len)
{
URLPattern *pat = &glob->pattern[glob->size];
struct URLPattern *pat = &glob->pattern[glob->size];
pat->type = UPTSet;
pat->content.Set.size = 1;
pat->content.Set.ptr_s = 0;
@ -74,14 +74,14 @@ static int multiply(unsigned long *amount, long with)
return 0;
}
static CURLcode glob_set(URLGlob *glob, char **patternp,
static CURLcode glob_set(struct URLGlob *glob, char **patternp,
size_t *posp, unsigned long *amount,
int globindex)
{
/* processes a set expression with the point behind the opening '{'
','-separated elements are collected until the next closing '}'
*/
URLPattern *pat;
struct URLPattern *pat;
bool done = FALSE;
char *buf = glob->glob_buffer;
char *pattern = *patternp;
@ -168,7 +168,7 @@ static CURLcode glob_set(URLGlob *glob, char **patternp,
return CURLE_OK;
}
static CURLcode glob_range(URLGlob *glob, char **patternp,
static CURLcode glob_range(struct URLGlob *glob, char **patternp,
size_t *posp, unsigned long *amount,
int globindex)
{
@ -178,7 +178,7 @@ static CURLcode glob_range(URLGlob *glob, char **patternp,
- num range with leading zeros: e.g. "001-999]"
expression is checked for well-formedness and collected until the next ']'
*/
URLPattern *pat;
struct URLPattern *pat;
int rc;
char *pattern = *patternp;
char *c;
@ -349,7 +349,7 @@ static bool peek_ipv6(const char *str, size_t *skip)
}
}
static CURLcode glob_parse(URLGlob *glob, char *pattern,
static CURLcode glob_parse(struct URLGlob *glob, char *pattern,
size_t pos, unsigned long *amount)
{
/* processes a literal string component of a URL
@ -427,14 +427,14 @@ static CURLcode glob_parse(URLGlob *glob, char *pattern,
return res;
}
CURLcode glob_url(URLGlob **glob, char *url, unsigned long *urlnum,
CURLcode glob_url(struct URLGlob **glob, char *url, unsigned long *urlnum,
FILE *error)
{
/*
* We can deal with any-size, just make a buffer with the same length
* as the specified URL!
*/
URLGlob *glob_expand;
struct URLGlob *glob_expand;
unsigned long amount = 0;
char *glob_buffer;
CURLcode res;
@ -446,7 +446,7 @@ CURLcode glob_url(URLGlob **glob, char *url, unsigned long *urlnum,
return CURLE_OUT_OF_MEMORY;
glob_buffer[0] = 0;
glob_expand = calloc(1, sizeof(URLGlob));
glob_expand = calloc(1, sizeof(struct URLGlob));
if(!glob_expand) {
Curl_safefree(glob_buffer);
return CURLE_OUT_OF_MEMORY;
@ -483,7 +483,7 @@ CURLcode glob_url(URLGlob **glob, char *url, unsigned long *urlnum,
return CURLE_OK;
}
void glob_cleanup(URLGlob* glob)
void glob_cleanup(struct URLGlob *glob)
{
size_t i;
int elem;
@ -506,9 +506,9 @@ void glob_cleanup(URLGlob* glob)
Curl_safefree(glob);
}
CURLcode glob_next_url(char **globbed, URLGlob *glob)
CURLcode glob_next_url(char **globbed, struct URLGlob *glob)
{
URLPattern *pat;
struct URLPattern *pat;
size_t i;
size_t len;
size_t buflen = glob->urllen + 1;
@ -600,7 +600,7 @@ CURLcode glob_next_url(char **globbed, URLGlob *glob)
return CURLE_OK;
}
CURLcode glob_match_url(char **result, char *filename, URLGlob *glob)
CURLcode glob_match_url(char **result, char *filename, struct URLGlob *glob)
{
char *target;
size_t allocsize;
@ -625,7 +625,7 @@ CURLcode glob_match_url(char **result, char *filename, URLGlob *glob)
if(*filename == '#' && ISDIGIT(filename[1])) {
char *ptr = filename;
unsigned long num = strtoul(&filename[1], &filename, 10);
URLPattern *pat = NULL;
struct URLPattern *pat = NULL;
if(num && (num < glob->size)) {
unsigned long i;

View file

@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@ -29,7 +29,7 @@ typedef enum {
UPTNumRange
} URLPatternType;
typedef struct {
struct URLPattern {
URLPatternType type;
int globindex; /* the number of this particular glob or -1 if not used
within {} or [] */
@ -53,24 +53,24 @@ typedef struct {
unsigned long step;
} NumRange;
} content;
} URLPattern;
};
/* the total number of globs supported */
#define GLOB_PATTERN_NUM 100
typedef struct {
URLPattern pattern[GLOB_PATTERN_NUM];
struct URLGlob {
struct URLPattern pattern[GLOB_PATTERN_NUM];
size_t size;
size_t urllen;
char *glob_buffer;
char beenhere;
const char *error; /* error message */
size_t pos; /* column position of error or 0 */
} URLGlob;
};
CURLcode glob_url(URLGlob**, char *, unsigned long *, FILE *);
CURLcode glob_next_url(char **, URLGlob *);
CURLcode glob_match_url(char **, char *, URLGlob *);
void glob_cleanup(URLGlob* glob);
CURLcode glob_url(struct URLGlob**, char *, unsigned long *, FILE *);
CURLcode glob_next_url(char **, struct URLGlob *);
CURLcode glob_match_url(char **, char *, struct URLGlob *);
void glob_cleanup(struct URLGlob *glob);
#endif /* HEADER_CURL_TOOL_URLGLOB_H */

View file

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@ -122,13 +122,13 @@ void vms_special_exit(int code, int vms_show)
*/
/* Structure to hold a DECC$* feature name and its desired value. */
typedef struct {
struct decc_feat_t {
char *name;
int value;
} decc_feat_t;
};
/* Array of DECC$* feature names and their desired values. */
static decc_feat_t decc_feat_array[] = {
static struct decc_feat_t decc_feat_array[] = {
/* Preserve command-line case with SET PROCESS/PARSE_STYLE=EXTENDED */
{ "DECC$ARGV_PARSE_STYLE", 1 },
/* Preserve case for file names on ODS5 disks. */