1 #ifndef HEADER_CURL_TOOL_FORMPARSE_H 2 #define HEADER_CURL_TOOL_FORMPARSE_H 3 /*************************************************************************** 4 * _ _ ____ _ 5 * Project ___| | | | _ \| | 6 * / __| | | | |_) | | 7 * | (__| |_| | _ <| |___ 8 * \___|\___/|_| \_\_____| 9 * 10 * Copyright (C) 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.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 * SPDX-License-Identifier: curl 24 * 25 ***************************************************************************/ 26 #include "tool_setup.h" 27 28 /* Private structure for mime/parts. */ 29 30 typedef enum { 31 TOOLMIME_NONE = 0, 32 TOOLMIME_PARTS, 33 TOOLMIME_DATA, 34 TOOLMIME_FILE, 35 TOOLMIME_FILEDATA, 36 TOOLMIME_STDIN, 37 TOOLMIME_STDINDATA 38 } toolmimekind; 39 40 struct tool_mime { 41 /* Structural fields. */ 42 toolmimekind kind; /* Part kind. */ 43 struct tool_mime *parent; /* Parent item. */ 44 struct tool_mime *prev; /* Previous sibling (reverse order link). */ 45 /* Common fields. */ 46 char *data; /* Actual data or data filename. */ 47 char *name; /* Part name. */ 48 char *filename; /* Part's filename. */ 49 char *type; /* Part's mime type. */ 50 char *encoder; /* Part's requested encoding. */ 51 struct curl_slist *headers; /* User-defined headers. */ 52 /* TOOLMIME_PARTS fields. */ 53 struct tool_mime *subparts; /* Part's subparts. */ 54 /* TOOLMIME_STDIN/TOOLMIME_STDINDATA fields. */ 55 curl_off_t origin; /* Stdin read origin offset. */ 56 curl_off_t size; /* Stdin data size. */ 57 curl_off_t curpos; /* Stdin current read position. */ 58 struct GlobalConfig *config; /* For access from callback. */ 59 }; 60 61 size_t tool_mime_stdin_read(char *buffer, 62 size_t size, size_t nitems, void *arg); 63 int tool_mime_stdin_seek(void *instream, curl_off_t offset, int whence); 64 65 int formparse(struct OperationConfig *config, 66 const char *input, 67 struct tool_mime **mimeroot, 68 struct tool_mime **mimecurrent, 69 bool literal_value); 70 CURLcode tool2curlmime(CURL *curl, struct tool_mime *m, curl_mime **mime); 71 void tool_mime_free(struct tool_mime *mime); 72 73 #endif /* HEADER_CURL_TOOL_FORMPARSE_H */ 74