1*6236dae4SAndroid Build Coastguard Worker--- 2*6236dae4SAndroid Build Coastguard Workerc: Copyright (C) Daniel Stenberg, <[email protected]>, et al. 3*6236dae4SAndroid Build Coastguard WorkerSPDX-License-Identifier: curl 4*6236dae4SAndroid Build Coastguard WorkerTitle: curl_formget 5*6236dae4SAndroid Build Coastguard WorkerSection: 3 6*6236dae4SAndroid Build Coastguard WorkerSource: libcurl 7*6236dae4SAndroid Build Coastguard WorkerSee-also: 8*6236dae4SAndroid Build Coastguard Worker - curl_formadd (3) 9*6236dae4SAndroid Build Coastguard Worker - curl_mime_init (3) 10*6236dae4SAndroid Build Coastguard WorkerProtocol: 11*6236dae4SAndroid Build Coastguard Worker - HTTP 12*6236dae4SAndroid Build Coastguard WorkerAdded-in: 7.15.5 13*6236dae4SAndroid Build Coastguard Worker--- 14*6236dae4SAndroid Build Coastguard Worker 15*6236dae4SAndroid Build Coastguard Worker# NAME 16*6236dae4SAndroid Build Coastguard Worker 17*6236dae4SAndroid Build Coastguard Workercurl_formget - serialize a multipart form POST chain 18*6236dae4SAndroid Build Coastguard Worker 19*6236dae4SAndroid Build Coastguard Worker# SYNOPSIS 20*6236dae4SAndroid Build Coastguard Worker 21*6236dae4SAndroid Build Coastguard Worker~~~c 22*6236dae4SAndroid Build Coastguard Worker#include <curl/curl.h> 23*6236dae4SAndroid Build Coastguard Worker 24*6236dae4SAndroid Build Coastguard Workerint curl_formget(struct curl_httppost * form, void *userp, 25*6236dae4SAndroid Build Coastguard Worker curl_formget_callback append); 26*6236dae4SAndroid Build Coastguard Worker~~~ 27*6236dae4SAndroid Build Coastguard Worker 28*6236dae4SAndroid Build Coastguard Worker# DESCRIPTION 29*6236dae4SAndroid Build Coastguard Worker 30*6236dae4SAndroid Build Coastguard WorkerThe form API (including this function) is deprecated since libcurl 7.56.0. 31*6236dae4SAndroid Build Coastguard Worker 32*6236dae4SAndroid Build Coastguard Workercurl_formget() serializes data previously built with curl_formadd(3). It 33*6236dae4SAndroid Build Coastguard Workeraccepts a void pointer as second argument named *userp* which is passed as the 34*6236dae4SAndroid Build Coastguard Workerfirst argument to the curl_formget_callback function. 35*6236dae4SAndroid Build Coastguard Worker 36*6236dae4SAndroid Build Coastguard Worker~~~c 37*6236dae4SAndroid Build Coastguard Worker typedef size_t (*curl_formget_callback)(void *userp, const char *buf, 38*6236dae4SAndroid Build Coastguard Worker size_t len);" 39*6236dae4SAndroid Build Coastguard Worker~~~ 40*6236dae4SAndroid Build Coastguard Worker 41*6236dae4SAndroid Build Coastguard WorkerThe curl_formget_callback is invoked for each part of the HTTP POST chain. The 42*6236dae4SAndroid Build Coastguard Workercharacter buffer passed to the callback must not be freed. The callback should 43*6236dae4SAndroid Build Coastguard Workerreturn the buffer length passed to it on success. 44*6236dae4SAndroid Build Coastguard Worker 45*6236dae4SAndroid Build Coastguard WorkerIf the **CURLFORM_STREAM** option is used in the formpost, it prevents 46*6236dae4SAndroid Build Coastguard Workercurl_formget(3) from working until you have performed the actual HTTP request. 47*6236dae4SAndroid Build Coastguard WorkerThis, because first then does libcurl known which actual read callback to use. 48*6236dae4SAndroid Build Coastguard Worker 49*6236dae4SAndroid Build Coastguard Worker# %PROTOCOLS% 50*6236dae4SAndroid Build Coastguard Worker 51*6236dae4SAndroid Build Coastguard Worker# EXAMPLE 52*6236dae4SAndroid Build Coastguard Worker 53*6236dae4SAndroid Build Coastguard Worker~~~c 54*6236dae4SAndroid Build Coastguard Workersize_t print_httppost_callback(void *arg, const char *buf, size_t len) 55*6236dae4SAndroid Build Coastguard Worker{ 56*6236dae4SAndroid Build Coastguard Worker fwrite(buf, len, 1, stdout); 57*6236dae4SAndroid Build Coastguard Worker (*(size_t *) arg) += len; 58*6236dae4SAndroid Build Coastguard Worker return len; 59*6236dae4SAndroid Build Coastguard Worker} 60*6236dae4SAndroid Build Coastguard Worker 61*6236dae4SAndroid Build Coastguard Workersize_t print_httppost(struct curl_httppost *post) 62*6236dae4SAndroid Build Coastguard Worker{ 63*6236dae4SAndroid Build Coastguard Worker size_t total_size = 0; 64*6236dae4SAndroid Build Coastguard Worker if(curl_formget(post, &total_size, print_httppost_callback)) { 65*6236dae4SAndroid Build Coastguard Worker return (size_t) -1; 66*6236dae4SAndroid Build Coastguard Worker } 67*6236dae4SAndroid Build Coastguard Worker return total_size; 68*6236dae4SAndroid Build Coastguard Worker} 69*6236dae4SAndroid Build Coastguard Worker~~~ 70*6236dae4SAndroid Build Coastguard Worker 71*6236dae4SAndroid Build Coastguard Worker# %AVAILABILITY% 72*6236dae4SAndroid Build Coastguard Worker 73*6236dae4SAndroid Build Coastguard Worker# RETURN VALUE 74*6236dae4SAndroid Build Coastguard Worker 75*6236dae4SAndroid Build Coastguard Worker0 means everything was OK, non-zero means an error occurred 76