xref: /curl/docs/libcurl/opts/CURLOPT_WRITEDATA.md (revision 5a488251)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_WRITEDATA
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_HEADERDATA (3)
9  - CURLOPT_READDATA (3)
10  - CURLOPT_WRITEFUNCTION (3)
11Protocol:
12  - All
13Added-in: 7.9.7
14---
15
16# NAME
17
18CURLOPT_WRITEDATA - pointer passed to the write callback
19
20# SYNOPSIS
21
22~~~c
23#include <curl/curl.h>
24
25CURLcode curl_easy_setopt(CURL *handle, CURLOPT_WRITEDATA, void *pointer);
26~~~
27
28# DESCRIPTION
29
30A data *pointer* to pass to the write callback. If you use the
31CURLOPT_WRITEFUNCTION(3) option, this is the pointer you get in that
32callback's fourth and last argument. If you do not use a write callback, you
33must make *pointer* a 'FILE *' (cast to 'void *') as libcurl passes this
34to *fwrite(3)* when writing data.
35
36The internal CURLOPT_WRITEFUNCTION(3) writes the data to the FILE *
37given with this option, or to stdout if this option has not been set.
38
39If you are using libcurl as a Windows DLL, you **MUST** use a
40CURLOPT_WRITEFUNCTION(3) if you set this option or you might experience
41crashes.
42
43# DEFAULT
44
45stdout
46
47# %PROTOCOLS%
48
49# EXAMPLE
50
51A common technique is to use the write callback to store the incoming data
52into a dynamically growing allocated buffer, and then this
53CURLOPT_WRITEDATA(3) is used to point to a struct or the buffer to store data
54in. Like in the getinmemory example:
55https://curl.se/libcurl/c/getinmemory.html
56
57# HISTORY
58
59This option was formerly known as CURLOPT_FILE, the name CURLOPT_WRITEDATA(3)
60was added in 7.9.7.
61
62# %AVAILABILITY%
63
64# RETURN VALUE
65
66This returns CURLE_OK.
67