Commit 271c6374 authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

opts: examples added to 8 more libcurl option man pages

parent a8e388dd
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
.\" *                            | (__| |_| |  _ <| |___
.\" *                             \___|\___/|_| \_\_____|
.\" *
.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" *
.\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms
@@ -34,7 +34,24 @@ Pass a pointer to a double to receive the specified size of the upload. Since
.SH PROTOCOLS
All
.SH EXAMPLE
TODO
.nf
CURL *curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");

  /* Perform the upload */
  res = curl_easy_perform(curl);

  if(!res) {
    /* check the size */
    double cl;
    res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &cl);
    if(!res) {
      printf("Size: %.0f\n", cl);
    }
  }
}
.fi
.SH AVAILABILITY
Added in 7.6.1
.SH RETURN VALUE
+19 −2
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
.\" *                            | (__| |_| |  _ <| |___
.\" *                             \___|\___/|_| \_\_____|
.\" *
.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" *
.\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms
@@ -39,7 +39,24 @@ corresponding CURL handle.
.SH PROTOCOLS
HTTP(S)
.SH EXAMPLE
TODO
.nf
CURL *curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");

  res = curl_easy_perform(curl);

  if(!res) {
    /* extract the content-type */
    char *ct = NULL;
    res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct);
    if(!res && ct) {
      printf("Content-Type: %s\n", ct);
    }
  }
  curl_easy_cleanup(curl);
}
.fi
.SH AVAILABILITY
Added in 7.9.4
.SH RETURN VALUE
+28 −2
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
.\" *                            | (__| |_| |  _ <| |___
.\" *                             \___|\___/|_| \_\_____|
.\" *
.\" * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" *
.\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms
@@ -40,7 +40,33 @@ domain name are not exported by this option.
.SH PROTOCOLS
HTTP(S)
.SH EXAMPLE
TODO
.nf
CURL *curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");

  /* enable the cookie engine with a non-existing file */
  curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "-");

  res = curl_easy_perform(curl);

  if(!res) {
    /* extract all known cookies */
    struct curl_slist *cookies = NULL;
    res = curl_easy_getinfo(curl, CURLINFO_COOKIELIST, &cookies);
    if(!res && cookies) {
      /* a linked list of cookies in cookie file format */
      while(cookies) {
        printf("%s", cookies->data);
        cookies = cookies->next;
      }
      /* we must free these cookies when we're done */
      curl_slist_free_all(cookies);
    }
  }
  curl_easy_cleanup(curl);
}
.fi
.SH AVAILABILITY
Added in 7.14.1
.SH RETURN VALUE
+19 −2
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
.\" *                            | (__| |_| |  _ <| |___
.\" *                             \___|\___/|_| \_\_____|
.\" *
.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" *
.\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms
@@ -39,7 +39,24 @@ corresponding CURL handle.
.SH PROTOCOLS
FTP(S) and SFTP
.SH EXAMPLE
TODO
.nf
CURL *curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com");

  res = curl_easy_perform(curl);

  if(!res) {
    /* extract the entry path */
    char *ep = NULL;
    res = curl_easy_getinfo(curl, CURLINFO_FTP_ENTRY_PATH, &ep);
    if(!res && ep) {
      printf("Entry path was: %s\n", ep);
    }
  }
  curl_easy_cleanup(curl);
}
.fi
.SH AVAILABILITY
Added in 7.15.4. Works for SFTP since 7.21.4
.SH RETURN VALUE
+16 −2
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
.\" *                            | (__| |_| |  _ <| |___
.\" *                             \___|\___/|_| \_\_____|
.\" *
.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" *
.\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms
@@ -36,7 +36,21 @@ The total includes the size of any received headers suppressed by
.SH PROTOCOLS
All
.SH EXAMPLE
TODO
.nf
CURL *curl = curl_easy_init();
if(curl) {
  CURLcode res;
  curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
  res = curl_easy_perform(curl);
  if(res == CURLE_OK) {
    long size;
    res = curl_easy_getinfo(curl, CURLINFO_HEADER_SIZE, &size);
    if(!res)
      printf("Header size: %ld bytes\n", size);
  }
  curl_easy_cleanup(curl);
}
.fi
.SH AVAILABILITY
Added in 7.4.1
.SH RETURN VALUE
Loading