1
0

formdata.h 2.8 KB

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