formdata.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #ifndef __FORMDATA_H
  2. #define __FORMDATA_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 1998 - 2007, Daniel Stenberg, <[email protected]>, 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 http://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. * $Id$
  24. ***************************************************************************/
  25. enum formtype {
  26. FORM_DATA, /* form metadata (convert to network encoding if necessary) */
  27. FORM_CONTENT, /* form content (never convert) */
  28. FORM_FILE /* 'line' points to a file name we should read from
  29. to create the form data (never convert) */
  30. };
  31. /* plain and simple linked list with lines to send */
  32. struct FormData {
  33. struct FormData *next;
  34. enum formtype type;
  35. char *line;
  36. size_t length;
  37. };
  38. struct Form {
  39. struct FormData *data; /* current form line to send */
  40. size_t sent; /* number of bytes of the current line that has
  41. already been sent in a previous invoke */
  42. FILE *fp; /* file to read from */
  43. };
  44. /* used by FormAdd for temporary storage */
  45. typedef struct FormInfo {
  46. char *name;
  47. bool name_alloc;
  48. size_t namelength;
  49. char *value;
  50. bool value_alloc;
  51. size_t contentslength;
  52. char *contenttype;
  53. bool contenttype_alloc;
  54. long flags;
  55. char *buffer; /* pointer to existing buffer used for file upload */
  56. size_t bufferlength;
  57. char *showfilename; /* The file name to show. If not set, the actual
  58. file name will be used */
  59. bool showfilename_alloc;
  60. struct curl_slist* contentheader;
  61. struct FormInfo *more;
  62. } FormInfo;
  63. int Curl_FormInit(struct Form *form, struct FormData *formdata );
  64. CURLcode
  65. Curl_getFormData(struct FormData **,
  66. struct curl_httppost *post,
  67. const char *custom_contenttype,
  68. curl_off_t *size);
  69. /* fread() emulation */
  70. size_t Curl_FormReader(char *buffer,
  71. size_t size,
  72. size_t nitems,
  73. FILE *mydata);
  74. /*
  75. * Curl_formpostheader() returns the first line of the formpost, the
  76. * request-header part (which is not part of the request-body like the rest of
  77. * the post).
  78. */
  79. char *Curl_formpostheader(void *formp, size_t *len);
  80. char *Curl_FormBoundary(void);
  81. void Curl_formclean(struct FormData **);
  82. CURLcode Curl_formconvert(struct SessionHandle *, struct FormData *);
  83. #endif