1 | #ifndef HEADER_CURL_TOOL_FORMPARSE_H |
2 | #define |
3 | /*************************************************************************** |
4 | * _ _ ____ _ |
5 | * Project ___| | | | _ \| | |
6 | * / __| | | | |_) | | |
7 | * | (__| |_| | _ <| |___ |
8 | * \___|\___/|_| \_\_____| |
9 | * |
10 | * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al. |
11 | * |
12 | * This software is licensed as described in the file COPYING, which |
13 | * you should have received as part of this distribution. The terms |
14 | * are also available at https://curl.haxx.se/docs/copyright.html. |
15 | * |
16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell |
17 | * copies of the Software, and permit persons to whom the Software is |
18 | * furnished to do so, under the terms of the COPYING file. |
19 | * |
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
21 | * KIND, either express or implied. |
22 | * |
23 | ***************************************************************************/ |
24 | #include "tool_setup.h" |
25 | |
26 | /* Private structure for mime/parts. */ |
27 | |
28 | typedef enum { |
29 | TOOLMIME_NONE = 0, |
30 | TOOLMIME_PARTS, |
31 | TOOLMIME_DATA, |
32 | TOOLMIME_FILE, |
33 | TOOLMIME_FILEDATA, |
34 | TOOLMIME_STDIN, |
35 | TOOLMIME_STDINDATA |
36 | } toolmimekind; |
37 | |
38 | typedef struct tool_mime tool_mime; |
39 | struct tool_mime { |
40 | /* Structural fields. */ |
41 | toolmimekind kind; /* Part kind. */ |
42 | tool_mime *parent; /* Parent item. */ |
43 | tool_mime *prev; /* Previous sibling (reverse order link). */ |
44 | /* Common fields. */ |
45 | const char *data; /* Actual data or data filename. */ |
46 | const char *name; /* Part name. */ |
47 | const char *filename; /* Part's filename. */ |
48 | const char *type; /* Part's mime type. */ |
49 | const char *encoder; /* Part's requested encoding. */ |
50 | struct curl_slist *; /* User-defined headers. */ |
51 | /* TOOLMIME_PARTS fields. */ |
52 | tool_mime *subparts; /* Part's subparts. */ |
53 | /* TOOLMIME_STDIN/TOOLMIME_STDINDATA fields. */ |
54 | curl_off_t origin; /* Stdin read origin offset. */ |
55 | curl_off_t size; /* Stdin data size. */ |
56 | curl_off_t curpos; /* Stdin current read position. */ |
57 | struct GlobalConfig *config; /* For access from callback. */ |
58 | }; |
59 | |
60 | size_t tool_mime_stdin_read(char *buffer, |
61 | size_t size, size_t nitems, void *arg); |
62 | int tool_mime_stdin_seek(void *instream, curl_off_t offset, int whence); |
63 | |
64 | int formparse(struct OperationConfig *config, |
65 | const char *input, |
66 | tool_mime **mimeroot, |
67 | tool_mime **mimecurrent, |
68 | bool literal_value); |
69 | CURLcode tool2curlmime(CURL *curl, tool_mime *m, curl_mime **mime); |
70 | void tool_mime_free(tool_mime *mime); |
71 | |
72 | #endif /* HEADER_CURL_TOOL_FORMPARSE_H */ |
73 | |