tool_formparse.h 2.8 KB

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