mirror of
https://github.com/curl/curl.git
synced 2026-07-28 09:13:07 +03:00
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:
parent
5d54b5e697
commit
8df455479f
71 changed files with 718 additions and 672 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue