static size_t mime_mem_read(char *buffer, size_t size, size_t nitems,
void *instream)
{
- struct Curl_mimepart *part = (struct Curl_mimepart *) instream;
+ curl_mimepart *part = (curl_mimepart *) instream;
size_t sz = (size_t) part->datasize - part->state.offset;
(void) size; /* Always 1.*/
static int mime_mem_seek(void *instream, curl_off_t offset, int whence)
{
- struct Curl_mimepart *part = (struct Curl_mimepart *) instream;
+ curl_mimepart *part = (curl_mimepart *) instream;
switch(whence) {
case SEEK_CUR:
static void mime_mem_free(void *ptr)
{
- Curl_safefree(((struct Curl_mimepart *) ptr)->data);
+ Curl_safefree(((curl_mimepart *) ptr)->data);
}
/* Named file callbacks. */
/* Argument is a pointer to the mime part. */
-static int mime_open_namedfile(struct Curl_mimepart * part)
+static int mime_open_namedfile(curl_mimepart * part)
{
/* Open a MIMEKIND_NAMEDFILE part. */
static size_t mime_namedfile_read(char *buffer, size_t size, size_t nitems,
void *instream)
{
- struct Curl_mimepart *part = (struct Curl_mimepart *) instream;
+ curl_mimepart *part = (curl_mimepart *) instream;
if(mime_open_namedfile(part))
return READ_ERROR;
static int mime_namedfile_seek(void *instream, curl_off_t offset, int whence)
{
- struct Curl_mimepart *part = (struct Curl_mimepart *) instream;
+ curl_mimepart *part = (curl_mimepart *) instream;
switch(whence) {
case SEEK_CUR:
static void mime_namedfile_free(void *ptr)
{
- struct Curl_mimepart *part = (struct Curl_mimepart *) ptr;
+ curl_mimepart *part = (curl_mimepart *) ptr;
if(part->namedfp) {
fclose(part->namedfp);
}
/* Readback a mime part. */
-static size_t readback_part(struct Curl_mimepart *part,
+static size_t readback_part(curl_mimepart *part,
char *buffer, size_t bufsize)
{
size_t cursize = 0;
static size_t mime_subparts_read(char *buffer, size_t size, size_t nitems,
void *instream)
{
- struct Curl_mime *mime = (struct Curl_mime *) instream;
+ curl_mime *mime = (curl_mime *) instream;
size_t cursize = 0;
size_t sz;
- struct Curl_mimepart *part;
+ curl_mimepart *part;
#ifdef CURL_DOES_CONVERSIONS
char *convbuf = buffer;
#endif
return cursize;
}
-static int mime_part_rewind(struct Curl_mimepart *part)
+static int mime_part_rewind(curl_mimepart *part)
{
int res = CURL_SEEKFUNC_OK;
enum mimestate targetstate = MIMESTATE_BEGIN;
static int mime_subparts_seek(void *instream, curl_off_t offset, int whence)
{
- struct Curl_mime *mime = (struct Curl_mime *) instream;
- struct Curl_mimepart *part;
+ curl_mime *mime = (curl_mime *) instream;
+ curl_mimepart *part;
int result = CURL_SEEKFUNC_OK;
int res;
static void mime_subparts_free(void *ptr)
{
- struct Curl_mime *mime = (struct Curl_mime *) ptr;
+ curl_mime *mime = (curl_mime *) ptr;
curl_mime_free(mime);
}
/* Release part content. */
-static void cleanup_part_content(struct Curl_mimepart *part)
+static void cleanup_part_content(curl_mimepart *part)
{
if(part->freefunc)
part->freefunc(part->arg);
part->kind = MIMEKIND_NONE;
}
-void Curl_mime_cleanpart(struct Curl_mimepart *part)
+void Curl_mime_cleanpart(curl_mimepart *part)
{
cleanup_part_content(part);
curl_slist_free_all(part->curlheaders);
}
/* Recursively delete a mime handle and its parts. */
-void curl_mime_free(struct Curl_mime *mime)
+void curl_mime_free(curl_mime *mime)
{
- struct Curl_mimepart *part;
+ curl_mimepart *part;
if(mime) {
while(mime->firstpart) {
*/
/* Create a mime handle. */
-struct Curl_mime *curl_mime_init(struct Curl_easy *easy)
+curl_mime *curl_mime_init(struct Curl_easy *easy)
{
- struct Curl_mime *mime;
+ curl_mime *mime;
- mime = (struct Curl_mime *) malloc(sizeof *mime);
+ mime = (curl_mime *) malloc(sizeof *mime);
if(mime) {
mime->easy = easy;
}
/* Initialize a mime part. */
-void Curl_mime_initpart(struct Curl_mimepart *part, struct Curl_easy *easy)
+void Curl_mime_initpart(curl_mimepart *part, struct Curl_easy *easy)
{
memset((char *) part, 0, sizeof *part);
part->easy = easy;
}
/* Create a mime part and append it to a mime handle's part list. */
-struct Curl_mimepart *curl_mime_addpart(struct Curl_mime *mime)
+curl_mimepart *curl_mime_addpart(curl_mime *mime)
{
- struct Curl_mimepart *part;
+ curl_mimepart *part;
if(!mime)
return NULL;
- part = (struct Curl_mimepart *) malloc(sizeof *part);
+ part = (curl_mimepart *) malloc(sizeof *part);
if(part) {
Curl_mime_initpart(part, mime->easy);
}
/* Set mime part name. */
-CURLcode curl_mime_name(struct Curl_mimepart *part,
+CURLcode curl_mime_name(curl_mimepart *part,
const char *name, size_t namesize)
{
if(!part)
}
/* Set mime part remote file name. */
-CURLcode curl_mime_filename(struct Curl_mimepart *part, const char *filename)
+CURLcode curl_mime_filename(curl_mimepart *part, const char *filename)
{
if(!part)
return CURLE_BAD_FUNCTION_ARGUMENT;
}
/* Set mime part content from memory data. */
-CURLcode curl_mime_data(struct Curl_mimepart *part,
+CURLcode curl_mime_data(curl_mimepart *part,
const char *data, size_t datasize)
{
if(!part)
}
/* Set mime part content from opened file. */
-CURLcode Curl_mime_file(struct Curl_mimepart *part,
+CURLcode Curl_mime_file(curl_mimepart *part,
FILE *fp, int closewhendone)
{
if(!part || !fp)
}
/* Set mime part content from named local file. */
-CURLcode curl_mime_filedata(struct Curl_mimepart *part, const char *filename)
+CURLcode curl_mime_filedata(curl_mimepart *part, const char *filename)
{
CURLcode result = CURLE_OK;
struct_stat sbuf;
}
/* Set mime part type. */
-CURLcode curl_mime_type(struct Curl_mimepart *part, const char *mimetype)
+CURLcode curl_mime_type(curl_mimepart *part, const char *mimetype)
{
if(!part)
return CURLE_BAD_FUNCTION_ARGUMENT;
}
/* Set mime data transfer encoder. */
-CURLcode curl_mime_encoder(struct Curl_mimepart *part, const char *encoding)
+CURLcode curl_mime_encoder(curl_mimepart *part, const char *encoding)
{
CURLcode result = CURLE_OK;
}
/* Set mime part headers. */
-CURLcode curl_mime_headers(struct Curl_mimepart *part,
+CURLcode curl_mime_headers(curl_mimepart *part,
struct curl_slist *headers, int take_ownership)
{
if(!part)
}
/* Set mime part content from callback. */
-CURLcode curl_mime_data_cb(struct Curl_mimepart *part, curl_off_t datasize,
+CURLcode curl_mime_data_cb(curl_mimepart *part, curl_off_t datasize,
curl_read_callback readfunc,
curl_seek_callback seekfunc,
curl_free_callback freefunc, void *arg)
}
/* Set mime part content from subparts. */
-CURLcode curl_mime_subparts(struct Curl_mimepart *part,
- struct Curl_mime *subparts)
+CURLcode curl_mime_subparts(curl_mimepart *part,
+ curl_mime *subparts)
{
if(!part)
return CURLE_BAD_FUNCTION_ARGUMENT;
/* Argument is the dummy top part. */
size_t Curl_mime_read(char *buffer, size_t size, size_t nitems, void *instream)
{
- struct Curl_mimepart *part = (struct Curl_mimepart *) instream;
+ curl_mimepart *part = (curl_mimepart *) instream;
(void) size; /* Always 1. */
return readback_part(part, buffer, nitems);
}
/* Rewind mime stream. */
-CURLcode Curl_mime_rewind(struct Curl_mimepart *part)
+CURLcode Curl_mime_rewind(curl_mimepart *part)
{
return mime_part_rewind(part) == CURL_SEEKFUNC_OK?
CURLE_OK: CURLE_SEND_FAIL_REWIND;
}
/* Get/compute multipart size. */
-static curl_off_t multipart_size(struct Curl_mime *mime)
+static curl_off_t multipart_size(curl_mime *mime)
{
curl_off_t size;
curl_off_t sz;
size_t boundarysize;
- struct Curl_mimepart *part;
+ curl_mimepart *part;
if(!mime)
return 0; /* Not present -> empty. */
}
/* Get/compute mime size. */
-curl_off_t Curl_mime_size(struct Curl_mimepart *part)
+curl_off_t Curl_mime_size(curl_mimepart *part)
{
curl_off_t size;
return NULL;
}
-CURLcode Curl_mime_prepare_headers(struct Curl_mimepart *part,
+CURLcode Curl_mime_prepare_headers(curl_mimepart *part,
const char *contenttype,
const char *disposition,
enum mimestrategy strategy)
{
- struct Curl_mime *mime = NULL;
+ curl_mime *mime = NULL;
const char *boundary = NULL;
char *s;
CURLcode ret = CURLE_OK;
}
if(part->kind == MIMEKIND_MULTIPART) {
- mime = (struct Curl_mime *) part->arg;
+ mime = (curl_mime *) part->arg;
if(mime)
boundary = mime->boundary;
}
/* Process subparts. */
if(part->kind == MIMEKIND_MULTIPART && mime) {
- struct Curl_mimepart *subpart;
+ curl_mimepart *subpart;
disposition = NULL;
if(strcasecompare(contenttype, "multipart/form-data"))
return CURLE_NOT_BUILT_IN;
}
-CURLcode curl_mime_encoder(struct Curl_mimepart *part, const char *encoding)
+CURLcode curl_mime_encoder(curl_mimepart *part, const char *encoding)
{
(void) part;
(void) encoding;
return CURLE_NOT_BUILT_IN;
}
-void Curl_mime_initpart(struct Curl_mimepart *part, struct Curl_easy *easy)
+void Curl_mime_initpart(curl_mimepart *part, struct Curl_easy *easy)
{
(void) part;
(void) data;
}
-void Curl_mime_cleanpart(struct Curl_mimepart *part)
+void Curl_mime_cleanpart(curl_mimepart *part)
{
(void) part;
}
-CURLcode Curl_mime_prepare_headers(struct Curl_mimepart *part,
+CURLcode Curl_mime_prepare_headers(curl_mimepart *part,
const char *contenttype,
const char *disposition,
enum mimestrategy strategy)
return CURLE_NOT_BUILT_IN;
}
-curl_off_t Curl_mime_size(struct Curl_mimepart *part)
+curl_off_t Curl_mime_size(curl_mimepart *part)
{
(void) part;
return (curl_off_t) -1;
return 0;
}
-CURLcode Curl_mime_rewind(struct Curl_mimepart *part)
+CURLcode Curl_mime_rewind(curl_mimepart *part)
{
(void) part;
return CURLE_NOT_BUILT_IN;
/* Mime readback state. */
struct mime_state {
enum mimestate state; /* Current state token. */
- void * ptr; /* State-dependent pointer. */
- size_t offset; /* State-dependent offset. */
+ void *ptr; /* State-dependent pointer. */
+ size_t offset; /* State-dependent offset. */
};
/* A mime context. */
-struct Curl_mime {
- struct Curl_easy * easy; /* The associated easy handle. */
- struct Curl_mimepart * parent; /* Parent part. */
- struct Curl_mimepart * firstpart; /* First part. */
- struct Curl_mimepart * lastpart; /* Last part. */
- char * boundary; /* The part boundary. */
- struct mime_state state; /* Current readback state. */
+struct curl_mime_s {
+ struct Curl_easy *easy; /* The associated easy handle. */
+ curl_mimepart *parent; /* Parent part. */
+ curl_mimepart *firstpart; /* First part. */
+ curl_mimepart *lastpart; /* Last part. */
+ char *boundary; /* The part boundary. */
+ struct mime_state state; /* Current readback state. */
};
/* A mime part. */
-struct Curl_mimepart {
- struct Curl_easy * easy; /* The associated easy handle. */
- struct Curl_mime * parent; /* Parent mime structure. */
- struct Curl_mimepart * nextpart; /* Forward linked list. */
- enum mimekind kind; /* The part kind. */
- char * data; /* Memory data or file name. */
- curl_read_callback readfunc; /* Read function. */
- curl_seek_callback seekfunc; /* Seek function. */
- curl_free_callback freefunc; /* Argument free function. */
- void * arg; /* Argument to callback functions. */
- FILE * namedfp; /* Named file pointer. */
- struct curl_slist * curlheaders; /* Part headers. */
- struct curl_slist * userheaders; /* Part headers. */
- char * mimetype; /* Part mime type. */
- char * filename; /* Remote file name. */
- char * name; /* Data name. */
- size_t namesize; /* Data name size. */
- 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. */
+struct curl_mimepart_s {
+ struct Curl_easy *easy; /* The associated easy handle. */
+ curl_mime *parent; /* Parent mime structure. */
+ curl_mimepart *nextpart; /* Forward linked list. */
+ enum mimekind kind; /* The part kind. */
+ char *data; /* Memory data or file name. */
+ curl_read_callback readfunc; /* Read function. */
+ curl_seek_callback seekfunc; /* Seek function. */
+ curl_free_callback freefunc; /* Argument free function. */
+ void *arg; /* Argument to callback functions. */
+ FILE *namedfp; /* Named file pointer. */
+ struct curl_slist *curlheaders; /* Part headers. */
+ struct curl_slist *userheaders; /* Part headers. */
+ char *mimetype; /* Part mime type. */
+ char *filename; /* Remote file name. */
+ char *name; /* Data name. */
+ size_t namesize; /* Data name size. */
+ 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. */
};
/* Prototypes. */
-void Curl_mime_initpart(struct Curl_mimepart *part, struct Curl_easy *easy);
-void Curl_mime_cleanpart(struct Curl_mimepart *part);
-CURLcode Curl_mime_prepare_headers(struct Curl_mimepart *part,
+void Curl_mime_initpart(curl_mimepart *part, struct Curl_easy *easy);
+void Curl_mime_cleanpart(curl_mimepart *part);
+CURLcode Curl_mime_prepare_headers(curl_mimepart *part,
const char *contenttype,
const char *disposition,
enum mimestrategy strategy);
-curl_off_t Curl_mime_size(struct Curl_mimepart *part);
+curl_off_t Curl_mime_size(curl_mimepart *part);
size_t Curl_mime_read(char *buffer, size_t size, size_t nitems,
void *instream);
-CURLcode Curl_mime_rewind(struct Curl_mimepart *part);
+CURLcode Curl_mime_rewind(curl_mimepart *part);
CURLcode Curl_mime_add_header(struct curl_slist **slp, const char *fmt, ...);
CURLcode Curl_mime_file(curl_mimepart *part, FILE *fp, int closewhendone);