aboutsummaryrefslogtreecommitdiff
path: root/src/tool_formparse.h
diff options
context:
space:
mode:
authorPatrick Monnerat <patrick@monnerat.net>2019-02-11 19:10:41 +0100
committerPatrick Monnerat <patrick@monnerat.net>2019-02-11 19:10:41 +0100
commitcac0e4a6ad14b42471ebc62e82ecdb7dad164702 (patch)
tree46e38a8e2da72fd2b621982f882dd6b1969a6161 /src/tool_formparse.h
parentb75fb9b5a6ee02beb9e2c6ed43556603f4ef64cf (diff)
cli tool: do not use mime.h private structures.
Option -F generates an intermediate representation of the mime structure that is used later to create the libcurl mime structure and generate the --libcurl statements. Reported-by: Daniel Stenberg Fixes #3532 Closes #3546
Diffstat (limited to 'src/tool_formparse.h')
-rw-r--r--src/tool_formparse.h46
1 files changed, 43 insertions, 3 deletions
diff --git a/src/tool_formparse.h b/src/tool_formparse.h
index cdf02d028..203f5ab30 100644
--- a/src/tool_formparse.h
+++ b/src/tool_formparse.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, 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
@@ -23,10 +23,50 @@
***************************************************************************/
#include "tool_setup.h"
+/* Private structure for mime/parts. */
+
+typedef enum {
+ TOOLMIME_NONE = 0,
+ TOOLMIME_PARTS,
+ TOOLMIME_DATA,
+ TOOLMIME_FILE,
+ TOOLMIME_FILEDATA,
+ TOOLMIME_STDIN,
+ 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). */
+ /* Common fields. */
+ const char *data; /* Actual data or data filename. */
+ const char *name; /* Part name. */
+ const char *filename; /* Part's filename. */
+ const char *type; /* Part's mime type. */
+ const char *encoder; /* Part's requested encoding. */
+ struct curl_slist *headers; /* User-defined headers. */
+ /* TOOLMIME_PARTS fields. */
+ tool_mime *subparts; /* Part's subparts. */
+ curl_mime *handle; /* Libcurl mime handle. */
+ /* TOOLMIME_STDIN/TOOLMIME_STDINDATA fields. */
+ curl_off_t origin; /* Stdin read origin offset. */
+ curl_off_t size; /* Stdin data size. */
+ curl_off_t curpos; /* Stdin current read position. */
+ struct GlobalConfig *config; /* For access from callback. */
+};
+
+size_t tool_mime_stdin_read(char *buffer,
+ size_t size, size_t nitems, void *arg);
+int tool_mime_stdin_seek(void *instream, curl_off_t offset, int whence);
+
int formparse(struct OperationConfig *config,
const char *input,
- curl_mime **mimepost,
- curl_mime **mimecurrent,
+ tool_mime **mimepost,
+ tool_mime **mimecurrent,
bool literal_value);
+void tool_mime_free(tool_mime *mime);
#endif /* HEADER_CURL_TOOL_FORMPARSE_H */