113498266Sopenharmony_ci#ifndef HEADER_CURL_TOOL_FORMPARSE_H 213498266Sopenharmony_ci#define HEADER_CURL_TOOL_FORMPARSE_H 313498266Sopenharmony_ci/*************************************************************************** 413498266Sopenharmony_ci * _ _ ____ _ 513498266Sopenharmony_ci * Project ___| | | | _ \| | 613498266Sopenharmony_ci * / __| | | | |_) | | 713498266Sopenharmony_ci * | (__| |_| | _ <| |___ 813498266Sopenharmony_ci * \___|\___/|_| \_\_____| 913498266Sopenharmony_ci * 1013498266Sopenharmony_ci * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 1113498266Sopenharmony_ci * 1213498266Sopenharmony_ci * This software is licensed as described in the file COPYING, which 1313498266Sopenharmony_ci * you should have received as part of this distribution. The terms 1413498266Sopenharmony_ci * are also available at https://curl.se/docs/copyright.html. 1513498266Sopenharmony_ci * 1613498266Sopenharmony_ci * You may opt to use, copy, modify, merge, publish, distribute and/or sell 1713498266Sopenharmony_ci * copies of the Software, and permit persons to whom the Software is 1813498266Sopenharmony_ci * furnished to do so, under the terms of the COPYING file. 1913498266Sopenharmony_ci * 2013498266Sopenharmony_ci * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 2113498266Sopenharmony_ci * KIND, either express or implied. 2213498266Sopenharmony_ci * 2313498266Sopenharmony_ci * SPDX-License-Identifier: curl 2413498266Sopenharmony_ci * 2513498266Sopenharmony_ci ***************************************************************************/ 2613498266Sopenharmony_ci#include "tool_setup.h" 2713498266Sopenharmony_ci 2813498266Sopenharmony_ci/* Private structure for mime/parts. */ 2913498266Sopenharmony_ci 3013498266Sopenharmony_citypedef enum { 3113498266Sopenharmony_ci TOOLMIME_NONE = 0, 3213498266Sopenharmony_ci TOOLMIME_PARTS, 3313498266Sopenharmony_ci TOOLMIME_DATA, 3413498266Sopenharmony_ci TOOLMIME_FILE, 3513498266Sopenharmony_ci TOOLMIME_FILEDATA, 3613498266Sopenharmony_ci TOOLMIME_STDIN, 3713498266Sopenharmony_ci TOOLMIME_STDINDATA 3813498266Sopenharmony_ci} toolmimekind; 3913498266Sopenharmony_ci 4013498266Sopenharmony_cistruct tool_mime { 4113498266Sopenharmony_ci /* Structural fields. */ 4213498266Sopenharmony_ci toolmimekind kind; /* Part kind. */ 4313498266Sopenharmony_ci struct tool_mime *parent; /* Parent item. */ 4413498266Sopenharmony_ci struct tool_mime *prev; /* Previous sibling (reverse order link). */ 4513498266Sopenharmony_ci /* Common fields. */ 4613498266Sopenharmony_ci char *data; /* Actual data or data filename. */ 4713498266Sopenharmony_ci char *name; /* Part name. */ 4813498266Sopenharmony_ci char *filename; /* Part's filename. */ 4913498266Sopenharmony_ci char *type; /* Part's mime type. */ 5013498266Sopenharmony_ci char *encoder; /* Part's requested encoding. */ 5113498266Sopenharmony_ci struct curl_slist *headers; /* User-defined headers. */ 5213498266Sopenharmony_ci /* TOOLMIME_PARTS fields. */ 5313498266Sopenharmony_ci struct tool_mime *subparts; /* Part's subparts. */ 5413498266Sopenharmony_ci /* TOOLMIME_STDIN/TOOLMIME_STDINDATA fields. */ 5513498266Sopenharmony_ci curl_off_t origin; /* Stdin read origin offset. */ 5613498266Sopenharmony_ci curl_off_t size; /* Stdin data size. */ 5713498266Sopenharmony_ci curl_off_t curpos; /* Stdin current read position. */ 5813498266Sopenharmony_ci struct GlobalConfig *config; /* For access from callback. */ 5913498266Sopenharmony_ci}; 6013498266Sopenharmony_ci 6113498266Sopenharmony_cisize_t tool_mime_stdin_read(char *buffer, 6213498266Sopenharmony_ci size_t size, size_t nitems, void *arg); 6313498266Sopenharmony_ciint tool_mime_stdin_seek(void *instream, curl_off_t offset, int whence); 6413498266Sopenharmony_ci 6513498266Sopenharmony_ciint formparse(struct OperationConfig *config, 6613498266Sopenharmony_ci const char *input, 6713498266Sopenharmony_ci struct tool_mime **mimeroot, 6813498266Sopenharmony_ci struct tool_mime **mimecurrent, 6913498266Sopenharmony_ci bool literal_value); 7013498266Sopenharmony_ciCURLcode tool2curlmime(CURL *curl, struct tool_mime *m, curl_mime **mime); 7113498266Sopenharmony_civoid tool_mime_free(struct tool_mime *mime); 7213498266Sopenharmony_ci 7313498266Sopenharmony_ci#endif /* HEADER_CURL_TOOL_FORMPARSE_H */ 74