quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

CURLOPT_SSH_HOSTKEYDATA.md (1663B)


      1 ---
      2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
      3 SPDX-License-Identifier: curl
      4 Title: CURLOPT_SSH_HOSTKEYDATA
      5 Section: 3
      6 Source: libcurl
      7 See-also:
      8   - CURLOPT_SSH_HOSTKEYFUNCTION (3)
      9 Protocol:
     10   - SFTP
     11   - SCP
     12 Added-in: 7.84.0
     13 ---
     14 
     15 # NAME
     16 
     17 CURLOPT_SSH_HOSTKEYDATA - pointer to pass to the SSH host key callback
     18 
     19 # SYNOPSIS
     20 
     21 ~~~c
     22 #include <curl/curl.h>
     23 
     24 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_HOSTKEYDATA, void *pointer);
     25 ~~~
     26 
     27 # DESCRIPTION
     28 
     29 Pass a void * as parameter. This *pointer* is passed along untouched to
     30 the callback set with CURLOPT_SSH_HOSTKEYFUNCTION(3).
     31 
     32 # DEFAULT
     33 
     34 NULL
     35 
     36 # %PROTOCOLS%
     37 
     38 # EXAMPLE
     39 
     40 ~~~c
     41 struct mine {
     42   void *custom;
     43 };
     44 
     45 static int hostkeycb(void *clientp,   /* CURLOPT_SSH_HOSTKEYDATA */
     46                      int keytype,     /* CURLKHTYPE */
     47                      const char *key, /* host key to check */
     48                      size_t keylen)   /* length of the key */
     49 {
     50   /* 'clientp' points to the callback_data struct */
     51   /* investigate the situation and return the correct value */
     52   return CURLKHMATCH_OK;
     53 }
     54 
     55 int main(void)
     56 {
     57   CURL *curl = curl_easy_init();
     58   if(curl) {
     59     struct mine callback_data;
     60     curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/thisfile.txt");
     61     curl_easy_setopt(curl, CURLOPT_SSH_HOSTKEYFUNCTION, hostkeycb);
     62     curl_easy_setopt(curl, CURLOPT_SSH_HOSTKEYDATA, &callback_data);
     63 
     64     curl_easy_perform(curl);
     65   }
     66 }
     67 ~~~
     68 
     69 # NOTES
     70 
     71 Works only with the libssh2 backend.
     72 
     73 # %AVAILABILITY%
     74 
     75 # RETURN VALUE
     76 
     77 curl_easy_setopt(3) returns a CURLcode indicating success or error.
     78 
     79 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see
     80 libcurl-errors(3).