Annotation of embedaddon/curl/docs/libcurl/opts/CURLOPT_SEEKFUNCTION.3, revision 1.1.1.1

1.1       misho       1: .\" **************************************************************************
                      2: .\" *                                  _   _ ____  _
                      3: .\" *  Project                     ___| | | |  _ \| |
                      4: .\" *                             / __| | | | |_) | |
                      5: .\" *                            | (__| |_| |  _ <| |___
                      6: .\" *                             \___|\___/|_| \_\_____|
                      7: .\" *
                      8: .\" * Copyright (C) 1998 - 2020, 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: .\"
                     23: .TH CURLOPT_SEEKFUNCTION 3 "March 23, 2020" "libcurl 7.70.0" "curl_easy_setopt options"
                     24: 
                     25: .SH NAME
                     26: CURLOPT_SEEKFUNCTION \- user callback for seeking in input stream
                     27: .SH SYNOPSIS
                     28: .nf
                     29: #include <curl/curl.h>
                     30: 
                     31: /* These are the return codes for the seek callbacks */
                     32: #define CURL_SEEKFUNC_OK       0
                     33: #define CURL_SEEKFUNC_FAIL     1 /* fail the entire transfer */
                     34: #define CURL_SEEKFUNC_CANTSEEK 2 /* tell libcurl seeking can't be done, so
                     35:                                     libcurl might try other means instead */
                     36: 
                     37: int seek_callback(void *userp, curl_off_t offset, int origin);
                     38: 
                     39: CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SEEKFUNCTION, seek_callback);
                     40: .SH DESCRIPTION
                     41: Pass a pointer to your callback function, which should match the prototype
                     42: shown above.
                     43: 
                     44: This function gets called by libcurl to seek to a certain position in the
                     45: input stream and can be used to fast forward a file in a resumed upload
                     46: (instead of reading all uploaded bytes with the normal read
                     47: function/callback). It is also called to rewind a stream when data has already
                     48: been sent to the server and needs to be sent again. This may happen when doing
                     49: an HTTP PUT or POST with a multi-pass authentication method, or when an
                     50: existing HTTP connection is reused too late and the server closes the
                     51: connection. The function shall work like fseek(3) or lseek(3) and it gets
                     52: SEEK_SET, SEEK_CUR or SEEK_END as argument for \fIorigin\fP, although libcurl
                     53: currently only passes SEEK_SET.
                     54: 
                     55: \fIuserp\fP is the pointer you set with \fICURLOPT_SEEKDATA(3)\fP.
                     56: 
                     57: The callback function must return \fICURL_SEEKFUNC_OK\fP on success,
                     58: \fICURL_SEEKFUNC_FAIL\fP to cause the upload operation to fail or
                     59: \fICURL_SEEKFUNC_CANTSEEK\fP to indicate that while the seek failed, libcurl
                     60: is free to work around the problem if possible. The latter can sometimes be
                     61: done by instead reading from the input or similar.
                     62: 
                     63: If you forward the input arguments directly to fseek(3) or lseek(3), note that
                     64: the data type for \fIoffset\fP is not the same as defined for curl_off_t on
                     65: many systems!
                     66: .SH DEFAULT
                     67: By default, this is NULL and unused.
                     68: .SH PROTOCOLS
                     69: HTTP, FTP, SFTP
                     70: .SH EXAMPLE
                     71: .nf
                     72: static int seek_cb(void *userp, curl_off_t offset, int origin)
                     73: {
                     74:   struct data *d = (struct data *)userp;
                     75:   lseek(our_fd, offset, origin);
                     76:   return CURL_SEEKFUNC_OK;
                     77: }
                     78: 
                     79: {
                     80:   struct data seek_data;
                     81:   curl_easy_setopt(CURL *handle, CURLOPT_SEEKFUNCTION, seek_cb);
                     82:   curl_easy_setopt(CURL *handle, CURLOPT_SEEKDATA, &seek_data);
                     83: }
                     84: .fi
                     85: .SH AVAILABILITY
                     86: Added in 7.18.0
                     87: .SH RETURN VALUE
                     88: Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
                     89: .SH "SEE ALSO"
                     90: .BR CURLOPT_SEEKDATA "(3), " CURLOPT_IOCTLFUNCTION "(3), "

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>