mirror of
https://github.com/curl/curl.git
synced 2026-01-26 15:03:21 +00:00
parent
df70a68984
commit
9f52458e7d
@ -46,10 +46,10 @@ struct priv {
|
||||
void *ours;
|
||||
};
|
||||
|
||||
static void ntfy_cb(CURLM *multi, unsigned int notification,
|
||||
CURL *easy, void *ntfyp)
|
||||
static void notify_cb(CURLM *multi, unsigned int notification,
|
||||
CURL *easy, void *notifyp)
|
||||
{
|
||||
struct priv *p = ntfyp;
|
||||
struct priv *p = notifyp;
|
||||
printf("my ptr: %p\n", p->ours);
|
||||
/* ... */
|
||||
}
|
||||
@ -59,7 +59,7 @@ int main(void)
|
||||
struct priv setup;
|
||||
CURLM *multi = curl_multi_init();
|
||||
/* ... use socket callback and custom pointer */
|
||||
curl_multi_setopt(multi, CURLMOPT_NOTIFYFUNCTION, ntfy_cb);
|
||||
curl_multi_setopt(multi, CURLMOPT_NOTIFYFUNCTION, notify_cb);
|
||||
curl_multi_setopt(multi, CURLMOPT_NOTIFYDATA, &setup);
|
||||
curl_multi_notify_enable(multi, CURLMNOTIFY_INFO_READ);
|
||||
}
|
||||
|
||||
@ -23,12 +23,12 @@ CURLMOPT_NOTIFYFUNCTION - callback receiving notifications
|
||||
~~~c
|
||||
#include <curl/curl.h>
|
||||
|
||||
void ntfy_callback(CURLM *multi, /* multi handle */
|
||||
unsigned int notification, /* notification type */
|
||||
CURL *easy, /* easy handle */
|
||||
void *ntfyp); /* private ntfy pointer */
|
||||
void notify_callback(CURLM *multi, /* multi handle */
|
||||
unsigned int notification, /* notification type */
|
||||
CURL *easy, /* easy handle */
|
||||
void *notifyp); /* private notify pointer */
|
||||
|
||||
CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_NOTIFYFUNCTION, ntfy_callback);
|
||||
CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_NOTIFYFUNCTION, notify_callback);
|
||||
~~~
|
||||
|
||||
# DESCRIPTION
|
||||
@ -89,7 +89,7 @@ an internal handle when DoH or other features are used.
|
||||
*easy* identifies the transfer involved. This may be one of the
|
||||
application's own easy handle or an internal handle.
|
||||
|
||||
**ntfyp** is set with CURLMOPT_NOTIFYDATA(3).
|
||||
**notifyp** is set with CURLMOPT_NOTIFYDATA(3).
|
||||
|
||||
# DEFAULT
|
||||
|
||||
@ -104,10 +104,10 @@ struct priv {
|
||||
void *ours;
|
||||
};
|
||||
|
||||
static void ntfy_cb(CURLM *multi, unsigned int notification,
|
||||
CURL *easy, void *ntfyp)
|
||||
static void notify_cb(CURLM *multi, unsigned int notification,
|
||||
CURL *easy, void *notifyp)
|
||||
{
|
||||
struct priv *p = ntfyp;
|
||||
struct priv *p = notifyp;
|
||||
printf("my ptr: %p\n", p->ours);
|
||||
/* ... */
|
||||
}
|
||||
@ -117,7 +117,7 @@ int main(void)
|
||||
struct priv setup;
|
||||
CURLM *multi = curl_multi_init();
|
||||
/* ... use socket callback and custom pointer */
|
||||
curl_multi_setopt(multi, CURLMOPT_NOTIFYFUNCTION, ntfy_cb);
|
||||
curl_multi_setopt(multi, CURLMOPT_NOTIFYFUNCTION, notify_cb);
|
||||
curl_multi_setopt(multi, CURLMOPT_NOTIFYDATA, &setup);
|
||||
curl_multi_notify_enable(multi, CURLMNOTIFY_INFO_READ);
|
||||
}
|
||||
|
||||
@ -208,9 +208,9 @@
|
||||
if(curlcheck_charpp_option(option)) \
|
||||
if(!curlcheck_ptrptr(value, char)) \
|
||||
Wcurl_multi_setopt_err_charpp(); \
|
||||
if((option) == CURLMOPT_NOTIFYFUNCTION) \
|
||||
if(!curlcheck_multintfy_cb(value)) \
|
||||
Wcurl_multi_setopt_err_ntfycb(); \
|
||||
if((option) == CURLMOPT_NOTIFYFUNCTION) \
|
||||
if(!curlcheck_multinotify_cb(value)) \
|
||||
Wcurl_multi_setopt_err_notifycb(); \
|
||||
if((option) == CURLMOPT_PUSHFUNCTION) \
|
||||
if(!curlcheck_multipush_cb(value)) \
|
||||
Wcurl_multi_setopt_err_pushcb(); \
|
||||
@ -227,7 +227,7 @@
|
||||
/* evaluates to true if the option takes a data argument to pass to a
|
||||
callback */
|
||||
#define curlcheck_multicb_data_option(option) \
|
||||
((option) == CURLMOPT_NOTIFYDATA || \
|
||||
((option) == CURLMOPT_NOTIFYDATA || \
|
||||
(option) == CURLMOPT_PUSHDATA || \
|
||||
(option) == CURLMOPT_SOCKETDATA || \
|
||||
(option) == CURLMOPT_TIMERDATA || \
|
||||
@ -250,13 +250,13 @@
|
||||
curlcheck_cb_compatible((expr), curl_socket_callback))
|
||||
|
||||
/* evaluates to true if expr is of type curl_push_callback */
|
||||
#define curlcheck_multipush_cb(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
#define curlcheck_multipush_cb(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
curlcheck_cb_compatible((expr), curl_push_callback))
|
||||
|
||||
/* evaluates to true if expr is of type curl_push_callback */
|
||||
#define curlcheck_multintfy_cb(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
#define curlcheck_multinotify_cb(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
curlcheck_cb_compatible((expr), curl_notify_callback))
|
||||
|
||||
/*
|
||||
@ -284,7 +284,7 @@ CURLWARNING(Wcurl_multi_setopt_err_charpp,
|
||||
"curl_multi_setopt expects a 'char **' argument")
|
||||
CURLWARNING(Wcurl_multi_setopt_err_pushcb,
|
||||
"curl_multi_setopt expects a curl_push_callback argument")
|
||||
CURLWARNING(Wcurl_multi_setopt_err_ntfycb,
|
||||
CURLWARNING(Wcurl_multi_setopt_err_notifycb,
|
||||
"curl_multi_setopt expects a curl_notify_callback argument")
|
||||
CURLWARNING(Wcurl_multi_setopt_err_socketcb,
|
||||
"curl_multi_setopt expects a curl_socket_callback argument")
|
||||
@ -392,16 +392,16 @@ CURLWARNING(Wcurl_easy_getinfo_err_curl_off_t,
|
||||
/* groups of curl_easy_setops options that take the same type of argument */
|
||||
|
||||
/* evaluates to true if option takes a long argument */
|
||||
#define curlcheck_long_option(option) \
|
||||
#define curlcheck_long_option(option) \
|
||||
(0 < (option) && (option) < CURLOPTTYPE_OBJECTPOINT)
|
||||
|
||||
#define curlcheck_off_t_option(option) \
|
||||
(((option) > CURLOPTTYPE_OFF_T) && ((option) < CURLOPTTYPE_BLOB))
|
||||
|
||||
/* option takes a CURL * argument */
|
||||
#define curlcheck_curl_option(option) \
|
||||
((option) == CURLOPT_STREAM_DEPENDS || \
|
||||
(option) == CURLOPT_STREAM_DEPENDS_E || \
|
||||
#define curlcheck_curl_option(option) \
|
||||
((option) == CURLOPT_STREAM_DEPENDS || \
|
||||
(option) == CURLOPT_STREAM_DEPENDS_E || \
|
||||
0)
|
||||
|
||||
/* evaluates to true if option takes a char* argument */
|
||||
@ -684,7 +684,7 @@ CURLWARNING(Wcurl_easy_getinfo_err_curl_off_t,
|
||||
(curlcheck_ptr((expr), void) || \
|
||||
curlcheck_ptr((expr), FILE))
|
||||
#else /* be less strict */
|
||||
#define curlcheck_cb_data(expr) \
|
||||
#define curlcheck_cb_data(expr) \
|
||||
curlcheck_any_ptr(expr)
|
||||
#endif
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user