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