curl_formget.3 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
  9. .\" *
  10. .\" * This software is licensed as described in the file COPYING, which
  11. .\" * you should have received as part of this distribution. The terms
  12. .\" * are also available at https://curl.se/docs/copyright.html.
  13. .\" *
  14. .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. .\" * copies of the Software, and permit persons to whom the Software is
  16. .\" * furnished to do so, under the terms of the COPYING file.
  17. .\" *
  18. .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. .\" * KIND, either express or implied.
  20. .\" *
  21. .\" * SPDX-License-Identifier: curl
  22. .\" *
  23. .\" **************************************************************************
  24. .TH curl_formget 3 "20 June 2006" "libcurl 7.15.5" "libcurl Manual"
  25. .SH NAME
  26. curl_formget - serialize a previously built multipart form POST chain
  27. .SH SYNOPSIS
  28. .nf
  29. .B #include <curl/curl.h>
  30. int curl_formget(struct curl_httppost * form, void *userp,
  31. curl_formget_callback append );
  32. .SH DESCRIPTION
  33. curl_formget() is used to serialize data previously built/appended with
  34. \fIcurl_formadd(3)\fP. Accepts a void pointer as second argument named
  35. \fIuserp\fP which will be passed as the first argument to the
  36. curl_formget_callback function.
  37. .BI "typedef size_t (*curl_formget_callback)(void *" userp, " const char *" buf,
  38. .BI " size_t " len ");"
  39. The curl_formget_callback will be executed for each part of the HTTP POST
  40. chain. The character buffer passed to the callback must not be freed. The
  41. callback should return the buffer length passed to it on success.
  42. If the \fBCURLFORM_STREAM\fP option is used in the formpost, it will prevent
  43. \fIcurl_formget(3)\fP from working until you have performed the actual HTTP
  44. request as only then will libcurl get the actual read callback to use!
  45. .SH EXAMPLE
  46. .nf
  47. size_t print_httppost_callback(void *arg, const char *buf, size_t len)
  48. {
  49. fwrite(buf, len, 1, stdout);
  50. (*(size_t *) arg) += len;
  51. return len;
  52. }
  53. size_t print_httppost(struct curl_httppost *post)
  54. {
  55. size_t total_size = 0;
  56. if(curl_formget(post, &total_size, print_httppost_callback)) {
  57. return (size_t) -1;
  58. }
  59. return total_size;
  60. }
  61. .SH AVAILABILITY
  62. This function was added in libcurl 7.15.5. The form API is deprecated in
  63. libcurl 7.56.0.
  64. .SH RETURN VALUE
  65. 0 means everything was OK, non-zero means an error occurred
  66. .SH "SEE ALSO"
  67. .BR curl_formadd "(3), " curl_mime_init "(3)"