• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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) 1998 - 2020, 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 struct tool_mime {
39   /* Structural fields. */
40   toolmimekind kind;            /* Part kind. */
41   struct tool_mime *parent;     /* Parent item. */
42   struct tool_mime *prev;       /* Previous sibling (reverse order link). */
43   /* Common fields. */
44   const char *data;             /* Actual data or data filename. */
45   const char *name;             /* Part name. */
46   const char *filename;         /* Part's filename. */
47   const char *type;             /* Part's mime type. */
48   const char *encoder;          /* Part's requested encoding. */
49   struct curl_slist *headers;   /* User-defined headers. */
50   /* TOOLMIME_PARTS fields. */
51   struct tool_mime *subparts;   /* Part's subparts. */
52   /* TOOLMIME_STDIN/TOOLMIME_STDINDATA fields. */
53   curl_off_t origin;            /* Stdin read origin offset. */
54   curl_off_t size;              /* Stdin data size. */
55   curl_off_t curpos;            /* Stdin current read position. */
56   struct GlobalConfig *config;  /* For access from callback. */
57 };
58 
59 size_t tool_mime_stdin_read(char *buffer,
60                             size_t size, size_t nitems, void *arg);
61 int tool_mime_stdin_seek(void *instream, curl_off_t offset, int whence);
62 
63 int formparse(struct OperationConfig *config,
64               const char *input,
65               struct tool_mime **mimeroot,
66               struct tool_mime **mimecurrent,
67               bool literal_value);
68 CURLcode tool2curlmime(CURL *curl, struct tool_mime *m, curl_mime **mime);
69 void tool_mime_free(struct tool_mime *mime);
70 
71 #endif /* HEADER_CURL_TOOL_FORMPARSE_H */
72