diff options
author | Patrick Monnerat <patrick@monnerat.net> | 2017-09-05 18:20:06 +0100 |
---|---|---|
committer | Patrick Monnerat <patrick@monnerat.net> | 2017-09-05 18:20:06 +0100 |
commit | c1d0b6f98e1645f0b32d9132e073e8e1965efce7 (patch) | |
tree | d91ef8898edd6861512c41aff3f8056b1ed9085c | |
parent | 63ef436ea15dd93343a2040ffb7c3bb2c9681b87 (diff) |
mime: replace 'struct Curl_mimepart' by 'curl_mimepart' in encoder code.
mime_state is now a typedef.
-rw-r--r-- | lib/mime.c | 37 | ||||
-rw-r--r-- | lib/mime.h | 8 |
2 files changed, 22 insertions, 23 deletions
diff --git a/lib/mime.c b/lib/mime.c index 38a20ed2d..89fbfc81e 100644 --- a/lib/mime.c +++ b/lib/mime.c @@ -57,16 +57,16 @@ /* Encoders. */ static size_t encoder_nop_read(char *buffer, size_t size, bool ateof, - struct Curl_mimepart *part); -static curl_off_t encoder_nop_size(struct Curl_mimepart *part); + curl_mimepart *part); +static curl_off_t encoder_nop_size(curl_mimepart *part); static size_t encoder_7bit_read(char *buffer, size_t size, bool ateof, - struct Curl_mimepart *part); + curl_mimepart *part); static size_t encoder_base64_read(char *buffer, size_t size, bool ateof, - struct Curl_mimepart *part); -static curl_off_t encoder_base64_size(struct Curl_mimepart *part); + curl_mimepart *part); +static curl_off_t encoder_base64_size(curl_mimepart *part); static size_t encoder_qp_read(char *buffer, size_t size, bool ateof, - struct Curl_mimepart *part); -static curl_off_t encoder_qp_size(struct Curl_mimepart *part); + curl_mimepart *part); +static curl_off_t encoder_qp_size(curl_mimepart *part); static const mime_encoder encoders[] = { {"binary", encoder_nop_read, encoder_nop_size}, @@ -266,8 +266,7 @@ static char *Curl_basename(char *path) /* Set readback state. */ -static void mimesetstate(struct mime_state *state, - enum mimestate tok, void *ptr) +static void mimesetstate(mime_state *state, enum mimestate tok, void *ptr) { state->state = tok; state->ptr = ptr; @@ -355,7 +354,7 @@ static void cleanup_encoder_state(mime_encoder_state *p) /* Dummy encoder. This is used for 8bit and binary content encodings. */ static size_t encoder_nop_read(char *buffer, size_t size, bool ateof, - struct Curl_mimepart *part) + curl_mimepart *part) { mime_encoder_state *st = &part->encstate; size_t insize = st->bufend - st->bufbeg; @@ -370,7 +369,7 @@ static size_t encoder_nop_read(char *buffer, size_t size, bool ateof, return size; } -static curl_off_t encoder_nop_size(struct Curl_mimepart *part) +static curl_off_t encoder_nop_size(curl_mimepart *part) { return part->datasize; } @@ -378,7 +377,7 @@ static curl_off_t encoder_nop_size(struct Curl_mimepart *part) /* 7bit encoder: the encoder is just a data validity check. */ static size_t encoder_7bit_read(char *buffer, size_t size, bool ateof, - struct Curl_mimepart *part) + curl_mimepart *part) { size_t i; mime_encoder_state *st = &part->encstate; @@ -402,7 +401,7 @@ static size_t encoder_7bit_read(char *buffer, size_t size, bool ateof, /* Base64 content encoder. */ static size_t encoder_base64_read(char *buffer, size_t size, bool ateof, - struct Curl_mimepart *part) + curl_mimepart *part) { mime_encoder_state *st = &part->encstate; size_t cursize = 0; @@ -474,7 +473,7 @@ static size_t encoder_base64_read(char *buffer, size_t size, bool ateof, return cursize; } -static curl_off_t encoder_base64_size(struct Curl_mimepart *part) +static curl_off_t encoder_base64_size(curl_mimepart *part) { curl_off_t size = part->datasize; @@ -509,7 +508,7 @@ static int qp_lookahead_eol(mime_encoder_state *st, int ateof, size_t n) /* Quoted-printable encoder. */ static size_t encoder_qp_read(char *buffer, size_t size, bool ateof, - struct Curl_mimepart *part) + curl_mimepart *part) { mime_encoder_state *st = &part->encstate; char *ptr = buffer; @@ -610,7 +609,7 @@ static size_t encoder_qp_read(char *buffer, size_t size, bool ateof, return cursize; } -static curl_off_t encoder_qp_size(struct Curl_mimepart *part) +static curl_off_t encoder_qp_size(curl_mimepart *part) { /* Determining the size can only be done by reading the data: unless the data size is 0, we return it as unknown (-1). */ @@ -744,7 +743,7 @@ static void mime_namedfile_free(void *ptr) /* Argument is a pointer to the mime structure. */ /* Readback a byte string segment. */ -static size_t readback_bytes(struct mime_state *state, +static size_t readback_bytes(mime_state *state, char *buffer, size_t bufsize, const char *bytes, size_t numbytes, const char *trail) @@ -776,7 +775,7 @@ static size_t readback_bytes(struct mime_state *state, } /* Read a non-encoded part content. */ -static size_t read_part_content(struct Curl_mimepart *part, +static size_t read_part_content(curl_mimepart *part, char *buffer, size_t bufsize) { size_t sz = 0; @@ -787,7 +786,7 @@ static size_t read_part_content(struct Curl_mimepart *part, } /* Read and encode part content. */ -static size_t read_encoded_part_content(struct Curl_mimepart *part, +static size_t read_encoded_part_content(curl_mimepart *part, char *buffer, size_t bufsize) { mime_encoder_state *st = &part->encstate; diff --git a/lib/mime.h b/lib/mime.h index 5d2e9477b..0ca4f69c9 100644 --- a/lib/mime.h +++ b/lib/mime.h @@ -79,11 +79,11 @@ typedef struct { } mime_encoder_state; /* Mime readback state. */ -struct mime_state { +typedef struct { enum mimestate state; /* Current state token. */ void *ptr; /* State-dependent pointer. */ size_t offset; /* State-dependent offset. */ -}; +} mime_state; /* A mime multipart. */ struct curl_mime_s { @@ -92,7 +92,7 @@ struct curl_mime_s { curl_mimepart *firstpart; /* First part. */ curl_mimepart *lastpart; /* Last part. */ char *boundary; /* The part boundary. */ - struct mime_state state; /* Current readback state. */ + mime_state state; /* Current readback state. */ }; /* A mime part. */ @@ -116,7 +116,7 @@ struct curl_mimepart_s { curl_off_t origin; /* Origin file offset. */ curl_off_t datasize; /* Expected data size. */ unsigned int flags; /* Flags. */ - struct mime_state state; /* Current readback state. */ + mime_state state; /* Current readback state. */ const mime_encoder *encoder; /* Content data encoder. */ mime_encoder_state encstate; /* Data encoder state. */ }; |