tool_formparse.h 2.8 KB

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