Imported Upstream version 7.59.0
[platform/upstream/curl.git] / docs / libcurl / curl_easy_init.3
1 .\" **************************************************************************
2 .\" *                                  _   _ ____  _
3 .\" *  Project                     ___| | | |  _ \| |
4 .\" *                             / __| | | | |_) | |
5 .\" *                            | (__| |_| |  _ <| |___
6 .\" *                             \___|\___/|_| \_\_____|
7 .\" *
8 .\" * Copyright (C) 1998 - 2014, 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.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_easy_init 3 "February 03, 2016" "libcurl 7.59.0" "libcurl Manual"
23
24 .SH NAME
25 curl_easy_init - Start a libcurl easy session
26 .SH SYNOPSIS
27 .B #include <curl/curl.h>
28
29 .BI "CURL *curl_easy_init( );"
30 .SH DESCRIPTION
31 This function must be the first function to call, and it returns a CURL easy
32 handle that you must use as input to other functions in the easy
33 interface. This call \fBMUST\fP have a corresponding call to
34 \fIcurl_easy_cleanup(3)\fP when the operation is complete.
35
36 If you did not already call \fIcurl_global_init(3)\fP, \fIcurl_easy_init(3)\fP
37 does it automatically.  This may be lethal in multi-threaded cases, since
38 \fIcurl_global_init(3)\fP is not thread-safe, and it may result in resource
39 problems because there is no corresponding cleanup.
40
41 You are strongly advised to not allow this automatic behaviour, by calling
42 \fIcurl_global_init(3)\fP yourself properly.  See the description in
43 \fBlibcurl\fP(3) of global environment requirements for details of how to use
44 this function.
45 .SH RETURN VALUE
46 If this function returns NULL, something went wrong and you cannot use the
47 other curl functions.
48 .SH EXAMPLE
49 .nf
50 CURL *curl = curl_easy_init();
51 if(curl) {
52   CURLcode res;
53   curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
54   res = curl_easy_perform(curl);
55   curl_easy_cleanup(curl);
56 }
57 .fi
58 .SH "SEE ALSO"
59 .BR curl_easy_cleanup "(3), " curl_global_init "(3), " curl_easy_reset "(3), "
60 .BR curl_easy_perform "(3) "