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

1.1       misho       1: .\" **************************************************************************
                      2: .\" *                                  _   _ ____  _
                      3: .\" *  Project                     ___| | | |  _ \| |
                      4: .\" *                             / __| | | | |_) | |
                      5: .\" *                            | (__| |_| |  _ <| |___
                      6: .\" *                             \___|\___/|_| \_\_____|
                      7: .\" *
                      8: .\" * Copyright (C) 1998 - 2017, 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 CURLMOPT_TIMERDATA 3 "May 27, 2017" "libcurl 7.70.0" "curl_multi_setopt options"
                     24: 
                     25: .SH NAME
                     26: CURLMOPT_TIMERDATA \- custom pointer to pass to timer callback
                     27: .SH SYNOPSIS
                     28: .nf
                     29: #include <curl/curl.h>
                     30: 
                     31: CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_TIMERDATA, void *pointer);
                     32: .SH DESCRIPTION
                     33: A data \fBpointer\fP to pass to the timer callback set with the
                     34: \fICURLMOPT_TIMERFUNCTION(3)\fP option.
                     35: 
                     36: This pointer will not be touched by libcurl but will only be passed in to the
                     37: timer callbacks's \fBuserp\fP argument.
                     38: .SH DEFAULT
                     39: NULL
                     40: .SH PROTOCOLS
                     41: All
                     42: .SH EXAMPLE
                     43: .nf
                     44: static gboolean timeout_cb(gpointer user_data)
                     45: {
                     46:   int running;
                     47:   if(user_data) {
                     48:     g_free(user_data);
                     49:     curl_multi_setopt(curl_handle, CURLMOPT_TIMERDATA, NULL);
                     50:   }
                     51:   curl_multi_socket_action(multi, CURL_SOCKET_TIMEOUT, 0, &running);
                     52:   return G_SOURCE_REMOVE;
                     53: }
                     54: 
                     55: static int timerfunc(CURLM *multi, long timeout_ms, void *userp)
                     56: {
                     57:   guint *id = userp;
                     58: 
                     59:   if(id)
                     60:     g_source_remove(*id);
                     61: 
                     62:   /* -1 means we should just delete our timer. */
                     63:   if(timeout_ms == -1) {
                     64:     g_free(id);
                     65:     id = NULL;
                     66:   }
                     67:   else {
                     68:     if(!id)
                     69:       id = g_new(guint, 1);
                     70:     *id = g_timeout_add(timeout_ms, timeout_cb, id);
                     71:   }
                     72:   curl_multi_setopt(multi, CURLMOPT_TIMERDATA, id);
                     73:   return 0;
                     74: }
                     75: 
                     76: curl_multi_setopt(multi, CURLMOPT_TIMERFUNCTION, timerfunc);
                     77: .fi
                     78: .SH AVAILABILITY
                     79: Added in 7.16.0
                     80: .SH RETURN VALUE
                     81: Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not.
                     82: .SH "SEE ALSO"
                     83: .BR CURLMOPT_TIMERFUNCTION "(3), " CURLMOPT_SOCKETFUNCTION "(3), "

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