Imported Upstream version 7.44.0
[platform/upstream/curl.git] / docs / libcurl / curl_formget.3
1 .\" **************************************************************************
2 .\" *                                  _   _ ____  _
3 .\" *  Project                     ___| | | |  _ \| |
4 .\" *                             / __| | | | |_) | |
5 .\" *                            | (__| |_| |  _ <| |___
6 .\" *                             \___|\___/|_| \_\_____|
7 .\" *
8 .\" * Copyright (C) 1998 - 2015, 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 http://curl.haxx.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 .\" **************************************************************************
22 .TH curl_formget 3 "20 June 2006" "libcurl 7.15.5" "libcurl Manual"
23 .SH NAME
24 curl_formget - serialize a previously built multipart/formdata HTTP POST chain
25 .SH SYNOPSIS
26 .nf
27 .B #include <curl/curl.h>
28
29 int curl_formget(struct curl_httppost * form, void *userp,
30                   curl_formget_callback append );
31 .SH DESCRIPTION
32 curl_formget() is used to serialize data previously built/appended with
33 \fIcurl_formadd(3)\fP. Accepts a void pointer as second argument named
34 \fIuserp\fP which will be passed as the first argument to the
35 curl_formget_callback function.
36
37 .BI "typedef size_t (*curl_formget_callback)(void *" userp, " const char *" buf,
38 .BI " size_t " len ");"
39
40 The curl_formget_callback will be executed for each part of the HTTP POST
41 chain. The character buffer passed to the callback must not be freed. The
42 callback should return the buffer length passed to it on success.
43
44 If the \fBCURLFORM_STREAM\fP option is used in the formpost, it will prevent
45 \fIcurl_formget(3)\fP from working until you've performed the actual HTTP
46 request as only then will libcurl get the actual read callback to use!
47 .SH RETURN VALUE
48 0 means everything was ok, non-zero means an error occurred
49 .SH EXAMPLE
50 .nf
51
52  size_t print_httppost_callback(void *arg, const char *buf, size_t len)
53  {
54    fwrite(buf, len, 1, stdout);
55    (*(size_t *) arg) += len;
56    return len;
57  }
58
59  size_t print_httppost(struct curl_httppost *post)
60  {
61    size_t total_size = 0;
62    if(curl_formget(post, &total_size, print_httppost_callback)) {
63      return (size_t) -1;
64    }
65    return total_size;
66  }
67 .SH AVAILABILITY
68 This function was added in libcurl 7.15.5
69 .SH "SEE ALSO"
70 .BR curl_formadd "(3) "