repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
kurento | github_2023 | Kurento | c | kms_rtp_endpoint_comedia_on_ssrc_active | static void
kms_rtp_endpoint_comedia_on_ssrc_active(GObject *rtpsession,
GObject *rtpsource, KmsRtpEndpoint *self)
{
GstStructure* source_stats = NULL;
gchar *rtp_from = NULL;
gchar *rtcp_from = NULL;
GNetworkAddress *rtp_addr = NULL;
GNetworkAddress *rtcp_addr = NULL;
gboolean ok;
guint ssrc;
gboolean is_validated;
gboolean is_sender;
// Each session has a minimum of 2 source SSRCs: sender and receiver.
// Here we look for stats from the sender which had COMEDIA enabled
// (by setting "a=direction:active" in the SDP negotiation).
// Property RTPSource::ssrc, doc: GStreamer/rtpsource.c
g_object_get (rtpsource,
"ssrc", &ssrc, "is-validated", &is_validated, "is-sender", &is_sender, NULL);
if (!is_validated || !is_sender) {
GST_DEBUG_OBJECT (rtpsession,
"Ignore uninteresting RTPSource, SSRC: %u", ssrc);
return;
}
GST_INFO_OBJECT (rtpsession, "COMEDIA: Get port info, SSRC: %u", ssrc);
g_object_get (rtpsource, "stats", &source_stats, NULL);
if (!source_stats) {
GST_ERROR_OBJECT (rtpsession, "COMEDIA: RTPSource lacks stats");
return;
}
ok = gst_structure_get (source_stats,
"rtp-from", G_TYPE_STRING, &rtp_from, NULL);
if (!ok) {
GST_WARNING_OBJECT (rtpsession, "COMEDIA: 'rtp-from' not available yet");
goto end;
} else {
GST_INFO_OBJECT (rtpsession, "COMEDIA: 'rtp-from' found: '%s'", rtp_from);
}
ok = gst_structure_get (source_stats,
"rtcp-from", G_TYPE_STRING, &rtcp_from, NULL);
if (!ok) {
GST_WARNING_OBJECT (rtpsession, "COMEDIA: 'rtcp-from' not available yet");
goto end;
} else {
GST_INFO_OBJECT (rtpsession, "COMEDIA: 'rtcp-from' found: '%s'", rtcp_from);
}
rtp_addr = G_NETWORK_ADDRESS (g_network_address_parse (rtp_from, 5004, NULL));
if (!rtp_addr) {
GST_ERROR_OBJECT (rtpsession, "COMEDIA: Cannot parse 'rtp-from'");
goto end;
}
rtcp_addr = G_NETWORK_ADDRESS (
g_network_address_parse (rtcp_from, 5005, NULL));
if (!rtcp_addr) {
GST_ERROR_OBJECT (rtpsession, "COMEDIA: Cannot parse 'rtcp-from'");
goto end;
}
KmsRtpBaseConnection *conn =
g_hash_table_lookup (self->priv->comedia.rtp_conns, rtpsession);
kms_rtp_base_connection_set_remote_info(conn,
g_network_address_get_hostname (rtcp_addr),
g_network_address_get_port (rtp_addr),
g_network_address_get_port (rtcp_addr));
GST_INFO_OBJECT (rtpsession, "COMEDIA: Parsed route: IP: %s, RTP: %u, RTCP: %u",
g_network_address_get_hostname (rtcp_addr),
g_network_address_get_port (rtp_addr),
g_network_address_get_port (rtcp_addr));
gulong signal_id =
GPOINTER_TO_UINT(
g_hash_table_lookup (self->priv->comedia.signal_ids, rtpsession));
GST_INFO_OBJECT (rtpsession, "COMEDIA: Disconnect from signal 'on_ssrc_active'");
g_signal_handler_disconnect (rtpsession, signal_id);
end:
if (rtp_addr) { g_object_unref (rtp_addr); }
if (rtcp_addr) { g_object_unref (rtcp_addr); }
if (rtp_from) { g_free(rtp_from); }
if (rtcp_from) { g_free(rtcp_from); }
gst_structure_free (source_stats);
} | /* Configure media SDP end */ | https://github.com/Kurento/kurento/blob/b04c741488b60a10692f08d01e87b8bb08ef0300/server/module-elements/src/gst-plugins/rtpendpoint/kmsrtpendpoint.c#L784-L878 | b04c741488b60a10692f08d01e87b8bb08ef0300 |
kurento | github_2023 | Kurento | c | kms_rtp_endpoint_init | static void
kms_rtp_endpoint_init (KmsRtpEndpoint * self)
{
self->priv = KMS_RTP_ENDPOINT_GET_PRIVATE (self);
self->priv->sdes_keys = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, (GDestroyNotify) kms_ref_struct_unref);
self->priv->comedia.rtp_conns = g_hash_table_new_full (NULL, NULL,
g_object_unref, NULL);
self->priv->comedia.signal_ids = g_hash_table_new_full (NULL, NULL,
g_object_unref, NULL);
g_object_set (G_OBJECT (self), "bundle",
FALSE, "rtcp-mux", FALSE, "rtcp-nack", TRUE, "rtcp-remb", TRUE,
"max-video-recv-bandwidth", 0, NULL);
/* FIXME: remove max-video-recv-bandwidth when it b=AS:X is in the SDP offer */
} | /* TODO: not add abs-send-time extmap */ | https://github.com/Kurento/kurento/blob/b04c741488b60a10692f08d01e87b8bb08ef0300/server/module-elements/src/gst-plugins/rtpendpoint/kmsrtpendpoint.c#L1160-L1177 | b04c741488b60a10692f08d01e87b8bb08ef0300 |
kurento | github_2023 | Kurento | c | kms_rtp_session_post_constructor | static void
kms_rtp_session_post_constructor (KmsRtpSession * self,
KmsBaseSdpEndpoint * ep, guint id, KmsIRtpSessionManager * manager,
gboolean use_ipv6)
{
KmsBaseRtpSession *base_rtp_session = KMS_BASE_RTP_SESSION (self);
self->use_ipv6 = use_ipv6;
KMS_BASE_RTP_SESSION_CLASS
(kms_rtp_session_parent_class)->post_constructor (base_rtp_session, ep,
id, manager);
} | /* Connection management end */ | https://github.com/Kurento/kurento/blob/b04c741488b60a10692f08d01e87b8bb08ef0300/server/module-elements/src/gst-plugins/rtpendpoint/kmsrtpsession.c#L76-L87 | b04c741488b60a10692f08d01e87b8bb08ef0300 |
kurento | github_2023 | Kurento | c | kms_srtp_session_post_constructor | static void
kms_srtp_session_post_constructor (KmsSrtpSession * self,
KmsBaseSdpEndpoint * ep, guint id, KmsIRtpSessionManager * manager,
gboolean use_ipv6)
{
KmsBaseRtpSession *base_rtp_session = KMS_BASE_RTP_SESSION (self);
self->use_ipv6 = use_ipv6;
KMS_BASE_RTP_SESSION_CLASS (parent_class)->post_constructor (base_rtp_session,
ep, id, manager);
} | /* Connection management end */ | https://github.com/Kurento/kurento/blob/b04c741488b60a10692f08d01e87b8bb08ef0300/server/module-elements/src/gst-plugins/rtpendpoint/kmssrtpsession.c#L77-L87 | b04c741488b60a10692f08d01e87b8bb08ef0300 |
kurento | github_2023 | Kurento | c | kms_ice_nice_agent_new_remote_candidate_full | static void
kms_ice_nice_agent_new_remote_candidate_full (NiceAgent * agent,
NiceCandidate * candidate, KmsIceNiceAgent * self)
{
gchar *stream_id_str = g_strdup_printf ("%u", candidate->stream_id);
KmsIceCandidate *kms_candidate =
kms_ice_nice_agent_create_candidate_from_nice (agent, candidate,
stream_id_str);
GST_DEBUG_OBJECT (self,
"[AddIceCandidate] Found peer-reflexive remote: '%s'",
kms_ice_candidate_get_candidate (kms_candidate));
kms_ice_nice_agent_add_ice_candidate (KMS_ICE_BASE_AGENT (self),
kms_candidate, stream_id_str);
g_free (stream_id_str);
g_object_unref (kms_candidate);
} | // ---------------------------------------------------------------------------- | https://github.com/Kurento/kurento/blob/b04c741488b60a10692f08d01e87b8bb08ef0300/server/module-elements/src/gst-plugins/webrtcendpoint/kmsiceniceagent.c#L135-L153 | b04c741488b60a10692f08d01e87b8bb08ef0300 |
kurento | github_2023 | Kurento | c | kms_ice_nice_agent_nice_to_ice_state | static IceState
kms_ice_nice_agent_nice_to_ice_state (NiceComponentState state)
{
switch (state) {
case NICE_COMPONENT_STATE_DISCONNECTED:
return ICE_STATE_DISCONNECTED;
case NICE_COMPONENT_STATE_GATHERING:
return ICE_STATE_GATHERING;
case NICE_COMPONENT_STATE_CONNECTING:
return ICE_STATE_CONNECTING;
case NICE_COMPONENT_STATE_CONNECTED:
return ICE_STATE_CONNECTED;
case NICE_COMPONENT_STATE_READY:
return ICE_STATE_READY;
case NICE_COMPONENT_STATE_FAILED:
return ICE_STATE_FAILED;
default:
return ICE_STATE_FAILED;
}
} | // ---------------------------------------------------------------------------- | https://github.com/Kurento/kurento/blob/b04c741488b60a10692f08d01e87b8bb08ef0300/server/module-elements/src/gst-plugins/webrtcendpoint/kmsiceniceagent.c#L199-L218 | b04c741488b60a10692f08d01e87b8bb08ef0300 |
kurento | github_2023 | Kurento | c | kms_webrtc_base_connection_agent_add_net_addr | static void
kms_webrtc_base_connection_agent_add_net_addr (const gchar * net_name,
NiceAgent * agent)
{
NiceAddress *nice_address = nice_address_new ();
gchar *ip_address = nice_interfaces_get_ip_for_interface ((gchar *)net_name);
nice_address_set_from_string (nice_address, ip_address);
nice_agent_add_local_address (agent, nice_address);
GST_INFO_OBJECT (agent, "Added local address: %s", ip_address);
nice_address_free (nice_address);
g_free (ip_address);
} | /**
* Add new local IP address to NiceAgent instance.
*/ | https://github.com/Kurento/kurento/blob/b04c741488b60a10692f08d01e87b8bb08ef0300/server/module-elements/src/gst-plugins/webrtcendpoint/kmswebrtcbaseconnection.c#L253-L267 | b04c741488b60a10692f08d01e87b8bb08ef0300 |
kurento | github_2023 | Kurento | c | on_ice_candidate | static void
on_ice_candidate (KmsWebrtcSession * sess, KmsIceCandidate * candidate,
KmsWebrtcEndpoint * self)
{
KmsSdpSession *sdp_sess = KMS_SDP_SESSION (sess);
GST_DEBUG_OBJECT (self,
"[IceCandidateFound] local: '%s', stream_id: %s, component_id: %d, sdpMid: '%s', sdpMLineIndex: %u",
kms_ice_candidate_get_candidate (candidate),
kms_ice_candidate_get_stream_id (candidate),
kms_ice_candidate_get_component (candidate),
kms_ice_candidate_get_sdp_mid (candidate),
kms_ice_candidate_get_sdp_m_line_index (candidate));
g_signal_emit (G_OBJECT (self),
kms_webrtc_endpoint_signals[SIGNAL_ON_ICE_CANDIDATE], 0,
sdp_sess->id_str, candidate);
} | /* Internal session management begin */ | https://github.com/Kurento/kurento/blob/b04c741488b60a10692f08d01e87b8bb08ef0300/server/module-elements/src/gst-plugins/webrtcendpoint/kmswebrtcendpoint.c#L117-L134 | b04c741488b60a10692f08d01e87b8bb08ef0300 |
kurento | github_2023 | Kurento | c | kms_webrtc_endpoint_create_media_handler | static void
kms_webrtc_endpoint_create_media_handler (KmsBaseSdpEndpoint * base_sdp,
const gchar * media, KmsSdpMediaHandler ** handler)
{
if (g_strcmp0 (media, "audio") == 0 || g_strcmp0 (media, "video") == 0) {
*handler = KMS_SDP_MEDIA_HANDLER (kms_sdp_rtp_savpf_media_handler_new ());
} else if (g_strcmp0 (media, "application") == 0) {
*handler = KMS_SDP_MEDIA_HANDLER (kms_sdp_sctp_media_handler_new ());
}
/* Chain up */
KMS_BASE_SDP_ENDPOINT_CLASS
(kms_webrtc_endpoint_parent_class)->create_media_handler (base_sdp, media,
handler);
} | /* Internal session management end */
/* Media handler management begin */ | https://github.com/Kurento/kurento/blob/b04c741488b60a10692f08d01e87b8bb08ef0300/server/module-elements/src/gst-plugins/webrtcendpoint/kmswebrtcendpoint.c#L424-L438 | b04c741488b60a10692f08d01e87b8bb08ef0300 |
kurento | github_2023 | Kurento | c | kms_webrtc_endpoint_configure_media | static gboolean
kms_webrtc_endpoint_configure_media (KmsBaseSdpEndpoint *
base_sdp_endpoint, KmsSdpSession * sess, KmsSdpMediaHandler * handler,
GstSDPMedia * media)
{
KmsWebrtcSession *webrtc_sess = KMS_WEBRTC_SESSION (sess);
gboolean ret;
/* Chain up */
ret = KMS_BASE_SDP_ENDPOINT_CLASS
(kms_webrtc_endpoint_parent_class)->configure_media (base_sdp_endpoint,
sess, handler, media);
if (ret == FALSE) {
return FALSE;
}
if (!kms_webrtc_session_set_ice_credentials (webrtc_sess, handler, media)) {
return FALSE;
}
return kms_webrtc_session_set_crypto_info (webrtc_sess, handler, media);
} | /* Media handler management end */
/* Configure media SDP begin */ | https://github.com/Kurento/kurento/blob/b04c741488b60a10692f08d01e87b8bb08ef0300/server/module-elements/src/gst-plugins/webrtcendpoint/kmswebrtcendpoint.c#L444-L465 | b04c741488b60a10692f08d01e87b8bb08ef0300 |
kurento | github_2023 | Kurento | c | kms_webrtc_endpoint_start_transport_send | static void
kms_webrtc_endpoint_start_transport_send (KmsBaseSdpEndpoint *
base_sdp_endpoint, KmsSdpSession * sess, gboolean offerer)
{
KmsWebrtcSession *webrtc_sess = KMS_WEBRTC_SESSION (sess);
/* Chain up */
KMS_BASE_SDP_ENDPOINT_CLASS
(kms_webrtc_endpoint_parent_class)->start_transport_send
(base_sdp_endpoint, sess, offerer);
kms_webrtc_session_start_transport_send (webrtc_sess, offerer);
} | /* Configure media SDP end */ | https://github.com/Kurento/kurento/blob/b04c741488b60a10692f08d01e87b8bb08ef0300/server/module-elements/src/gst-plugins/webrtcendpoint/kmswebrtcendpoint.c#L469-L481 | b04c741488b60a10692f08d01e87b8bb08ef0300 |
kurento | github_2023 | Kurento | c | kms_webrtc_endpoint_gather_candidates | static gboolean
kms_webrtc_endpoint_gather_candidates (KmsWebrtcEndpoint * self,
const gchar * sess_id)
{
KmsBaseSdpEndpoint *base_sdp_ep = KMS_BASE_SDP_ENDPOINT (self);
KmsSdpSession *sess;
KmsWebrtcSession *webrtc_sess;
gboolean ret = TRUE;
sess = kms_base_sdp_endpoint_get_session (base_sdp_ep, sess_id);
if (sess == NULL) {
GST_ERROR_OBJECT (self, "[IceGatheringStarted] No session: '%s'", sess_id);
return FALSE;
}
GST_DEBUG_OBJECT (self, "[IceGatheringStarted] session: '%s'", sess_id);
webrtc_sess = KMS_WEBRTC_SESSION (sess);
g_signal_emit_by_name (webrtc_sess, "gather-candidates", &ret);
return ret;
} | /* ICE candidates management begin */ | https://github.com/Kurento/kurento/blob/b04c741488b60a10692f08d01e87b8bb08ef0300/server/module-elements/src/gst-plugins/webrtcendpoint/kmswebrtcendpoint.c#L485-L506 | b04c741488b60a10692f08d01e87b8bb08ef0300 |
kurento | github_2023 | Kurento | c | kms_webrtc_endpoint_set_property | static void
kms_webrtc_endpoint_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
KmsWebrtcEndpoint *self = KMS_WEBRTC_ENDPOINT (object);
KMS_ELEMENT_LOCK (self);
switch (prop_id) {
case PROP_STUN_SERVER_IP:
g_free (self->priv->stun_server_ip);
self->priv->stun_server_ip = g_value_dup_string (value);
break;
case PROP_STUN_SERVER_PORT:
self->priv->stun_server_port = g_value_get_uint (value);
break;
case PROP_TURN_URL:
g_free (self->priv->turn_url);
self->priv->turn_url = g_value_dup_string (value);
break;
case PROP_PEM_CERTIFICATE:
g_free (self->priv->pem_certificate);
self->priv->pem_certificate = g_value_dup_string (value);
break;
case PROP_NETWORK_INTERFACES:
g_free (self->priv->network_interfaces);
self->priv->network_interfaces = g_value_dup_string (value);
break;
case PROP_EXTERNAL_IPV4:
g_free (self->priv->external_ipv4);
self->priv->external_ipv4 = g_value_dup_string (value);
break;
case PROP_EXTERNAL_IPV6:
g_free (self->priv->external_ipv6);
self->priv->external_ipv6 = g_value_dup_string (value);
break;
case PROP_ICE_TCP:
self->priv->ice_tcp = g_value_get_boolean (value);
break;
case PROP_QOS_DSCP:
self->priv->qos_dscp = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
KMS_ELEMENT_UNLOCK (self);
} | /* ICE candidates management end */ | https://github.com/Kurento/kurento/blob/b04c741488b60a10692f08d01e87b8bb08ef0300/server/module-elements/src/gst-plugins/webrtcendpoint/kmswebrtcendpoint.c#L539-L587 | b04c741488b60a10692f08d01e87b8bb08ef0300 |
kurento | github_2023 | Kurento | c | gst_media_add_remote_candidates | static void
gst_media_add_remote_candidates (KmsWebrtcSession * self,
guint index, const GstSDPMedia * media, KmsWebRtcBaseConnection * conn,
const gchar * msg_ufrag, const gchar * msg_pwd)
{
KmsIceBaseAgent *agent = conn->agent;
gchar *stream_id = conn->stream_id;
const gchar *ufrag, *pwd, *mid;
guint len, i;
ufrag = gst_sdp_media_get_attribute_val (media, SDP_ICE_UFRAG_ATTR);
pwd = gst_sdp_media_get_attribute_val (media, SDP_ICE_PWD_ATTR);
if (!kms_ice_base_agent_set_remote_credentials (agent, stream_id, ufrag, pwd)) {
GST_WARNING ("Cannot set remote media credentials (%s, %s).", ufrag, pwd);
if (!kms_ice_base_agent_set_remote_credentials (agent, stream_id, msg_ufrag,
msg_pwd)) {
GST_WARNING ("Cannot set remote message credentials (%s, %s).", ufrag,
pwd);
return;
} else {
GST_LOG ("Set remote message credentials OK (%s, %s).", ufrag, pwd);
}
} else {
GST_LOG ("Set remote media credentials OK (%s, %s).", ufrag, pwd);
}
mid = gst_sdp_media_get_attribute_val (media, "mid");
if (mid == NULL) {
GST_ERROR_OBJECT (self, "No mid attribute got for media %u", index);
return;
}
len = gst_sdp_media_attributes_len (media);
for (i = 0; i < len; i++) {
const GstSDPAttribute *attr;
gchar *candidate_str;
KmsIceCandidate *candidate;
attr = gst_sdp_media_get_attribute (media, i);
if (g_strcmp0 (SDP_CANDIDATE_ATTR, attr->key) != 0) {
continue;
}
candidate_str = g_strdup_printf ("%s:%s", SDP_CANDIDATE_ATTR, attr->value);
candidate = kms_ice_candidate_new (candidate_str, mid, index, stream_id);
g_free (candidate_str);
if (candidate) {
kms_webrtc_session_add_ice_candidate (self, candidate);
g_object_unref (candidate);
}
}
} | /* Start Transport begin */ | https://github.com/Kurento/kurento/blob/b04c741488b60a10692f08d01e87b8bb08ef0300/server/module-elements/src/gst-plugins/webrtcendpoint/kmswebrtcsession.c#L1045-L1097 | b04c741488b60a10692f08d01e87b8bb08ef0300 |
kurento | github_2023 | Kurento | c | kms_webrtc_session_add_data_channels_stats | void
kms_webrtc_session_add_data_channels_stats (KmsWebrtcSession * self,
GstStructure * stats, const gchar * selector)
{
GstStructure *data_stats;
const gchar *id;
if (self->data_session == NULL || (selector != NULL &&
g_strcmp0 (selector, DATA_STREAM_NAME) != 0)) {
return;
}
id = kms_utils_get_uuid (G_OBJECT (self->data_session));
if (id == NULL) {
kms_utils_set_uuid (G_OBJECT (self->data_session));
id = kms_utils_get_uuid (G_OBJECT (self->data_session));
}
g_signal_emit_by_name (self->data_session, "stats", &data_stats);
gst_structure_set (data_stats, "id", G_TYPE_STRING, id, NULL);
gst_structure_set (stats, KMS_DATA_SESSION_STATISTICS_FIELD,
GST_TYPE_STRUCTURE, data_stats, NULL);
gst_structure_free (data_stats);
} | /* Start Transport end */ | https://github.com/Kurento/kurento/blob/b04c741488b60a10692f08d01e87b8bb08ef0300/server/module-elements/src/gst-plugins/webrtcendpoint/kmswebrtcsession.c#L1667-L1691 | b04c741488b60a10692f08d01e87b8bb08ef0300 |
kurento | github_2023 | Kurento | c | store_pending_dtls_buffer | static gboolean
store_pending_dtls_buffer (GstBuffer **buffer, guint idx, gpointer user_data)
{
if (gst_buffer_is_dtls (*buffer)) {
KmsWebrtcTransportSrcNice *self = KMS_WEBRTC_TRANSPORT_SRC_NICE (user_data);
GST_DEBUG_OBJECT (self, "Storing DTLS buffer until ICE is CONNECTED");
self->priv->pending_buffers = g_list_append (self->priv->pending_buffers, *buffer);
// Side effect: Remove the buffer from its buffer list, if any.
*buffer = NULL;
}
return TRUE;
} | // Stores DTLS buffers for later use.
// `buffer` is unref and set to NULL only if stored; otherwise left as-is. | https://github.com/Kurento/kurento/blob/b04c741488b60a10692f08d01e87b8bb08ef0300/server/module-elements/src/gst-plugins/webrtcendpoint/kmswebrtctransportsrcnice.c#L85-L99 | b04c741488b60a10692f08d01e87b8bb08ef0300 |
kurento | github_2023 | Kurento | c | kms_webrtc_transport_src_nice_block_dtls_until_ice_connected | static GstPadProbeReturn
kms_webrtc_transport_src_nice_block_dtls_until_ice_connected (GstPad *pad, GstPadProbeInfo *info, gpointer user_data)
{
KmsWebrtcTransportSrcNice *self = KMS_WEBRTC_TRANSPORT_SRC_NICE(user_data);
GstPadProbeReturn ret = GST_PAD_PROBE_OK;
KMS_WEBRTC_TRANSPORT_SRC_NICE_LOCK (self);
if (self->priv->pending_buffers_delivered) {
KMS_WEBRTC_TRANSPORT_SRC_NICE_UNLOCK (self);
GST_DEBUG_OBJECT (self, "No more possible buffers pending, removing probe");
return GST_PAD_PROBE_REMOVE;
}
if (GST_PAD_PROBE_INFO_TYPE(info) & GST_PAD_PROBE_TYPE_BUFFER) {
GstBuffer *buffer = gst_pad_probe_info_get_buffer (info);
if (buffer != NULL) {
store_pending_dtls_buffer (&buffer, 0, self);
if (buffer == NULL) {
ret = GST_PAD_PROBE_HANDLED;
}
}
}
if (GST_PAD_PROBE_INFO_TYPE(info) & GST_PAD_PROBE_TYPE_BUFFER_LIST) {
GstBufferList *buffer_list = gst_pad_probe_info_get_buffer_list (info);
if (buffer_list != NULL) {
gst_buffer_list_foreach (buffer_list, store_pending_dtls_buffer, self);
if (gst_buffer_list_length (buffer_list) == 0) {
ret = GST_PAD_PROBE_HANDLED;
}
}
}
KMS_WEBRTC_TRANSPORT_SRC_NICE_UNLOCK (self);
return ret;
} | // Store DTLS buffers for later delivery when ICE gets to CONNECTED. | https://github.com/Kurento/kurento/blob/b04c741488b60a10692f08d01e87b8bb08ef0300/server/module-elements/src/gst-plugins/webrtcendpoint/kmswebrtctransportsrcnice.c#L222-L261 | b04c741488b60a10692f08d01e87b8bb08ef0300 |
kurento | github_2023 | Kurento | c | bus_msg | static void
bus_msg (GstBus * bus, GstMessage * msg, gpointer pipe)
{
switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_ERROR:{
gchar *error_file = g_strdup_printf ("error-%s", GST_OBJECT_NAME (pipe));
GST_ERROR ("Error: %" GST_PTR_FORMAT, msg);
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipe),
GST_DEBUG_GRAPH_SHOW_ALL, error_file);
g_free (error_file);
fail ("Error received on bus");
break;
}
case GST_MESSAGE_WARNING:{
gchar *warn_file = g_strdup_printf ("warning-%s", GST_OBJECT_NAME (pipe));
GST_WARNING ("Warning: %" GST_PTR_FORMAT, msg);
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipe),
GST_DEBUG_GRAPH_SHOW_ALL, warn_file);
g_free (warn_file);
break;
}
default:
break;
}
} | /* Temporaly disabled */ | https://github.com/Kurento/kurento/blob/b04c741488b60a10692f08d01e87b8bb08ef0300/server/module-elements/tests/check/element/dtls.c#L42-L68 | b04c741488b60a10692f08d01e87b8bb08ef0300 |
kurento | github_2023 | Kurento | c | bus_msg | static void
bus_msg (GstBus * bus, GstMessage * msg, gpointer pipe)
{
switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_ERROR:{
GST_ERROR ("Error: %" GST_PTR_FORMAT, msg);
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipe),
GST_DEBUG_GRAPH_SHOW_ALL, "error");
fail ("Error received on bus");
break;
}
case GST_MESSAGE_WARNING:{
GST_WARNING ("Warning: %" GST_PTR_FORMAT, msg);
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipe),
GST_DEBUG_GRAPH_SHOW_ALL, "warning");
break;
}
default:
break;
}
} | // TODO: create a generic bus_msg | https://github.com/Kurento/kurento/blob/b04c741488b60a10692f08d01e87b8bb08ef0300/server/module-elements/tests/check/element/rtpendpoint_audio.c#L102-L122 | b04c741488b60a10692f08d01e87b8bb08ef0300 |
kurento | github_2023 | Kurento | c | bus_msg | static void
bus_msg (GstBus * bus, GstMessage * msg, gpointer pipe)
{
switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_ERROR:{
GST_ERROR ("Error: %" GST_PTR_FORMAT, msg);
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipe),
GST_DEBUG_GRAPH_SHOW_ALL, "error");
fail ("Error received on bus");
break;
}
case GST_MESSAGE_WARNING:{
GST_WARNING ("Warning: %" GST_PTR_FORMAT, msg);
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipe),
GST_DEBUG_GRAPH_SHOW_ALL, "warning");
break;
}
default:
break;
}
} | // TODO: create a generic bus_msg | https://github.com/Kurento/kurento/blob/b04c741488b60a10692f08d01e87b8bb08ef0300/server/module-elements/tests/check/element/rtpendpoint_video.c#L41-L61 | b04c741488b60a10692f08d01e87b8bb08ef0300 |
kurento | github_2023 | Kurento | c | test_video_sendonly | static void
test_video_sendonly (const gchar * video_enc_name, GstStaticCaps expected_caps,
const gchar * pattern_sdp_sendonly_str,
const gchar * pattern_sdp_recvonly_str, gboolean play_after_negotiation)
{
HandOffData *hod;
GMainLoop *loop = g_main_loop_new (NULL, TRUE);
GstSDPMessage *pattern_sdp, *offer, *answer;
GstElement *pipeline = gst_pipeline_new (NULL);
GstElement *videotestsrc = gst_element_factory_make ("videotestsrc", NULL);
GstElement *video_enc = gst_element_factory_make (video_enc_name, NULL);
GstElement *rtpendpointsender =
gst_element_factory_make ("rtpendpoint", NULL);
GstElement *rtpendpointreceiver =
gst_element_factory_make ("rtpendpoint", NULL);
GstElement *outputfakesink = gst_element_factory_make ("fakesink", NULL);
GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
gst_bus_add_watch (bus, gst_bus_async_signal_func, NULL);
g_signal_connect (bus, "message", G_CALLBACK (bus_msg), pipeline);
g_object_unref (bus);
fail_unless (gst_sdp_message_new (&pattern_sdp) == GST_SDP_OK);
fail_unless (gst_sdp_message_parse_buffer ((const guint8 *)
pattern_sdp_sendonly_str, -1, pattern_sdp) == GST_SDP_OK);
g_object_set (rtpendpointsender, "pattern-sdp", pattern_sdp, NULL);
fail_unless (gst_sdp_message_free (pattern_sdp) == GST_SDP_OK);
fail_unless (gst_sdp_message_new (&pattern_sdp) == GST_SDP_OK);
fail_unless (gst_sdp_message_parse_buffer ((const guint8 *)
pattern_sdp_recvonly_str, -1, pattern_sdp) == GST_SDP_OK);
g_object_set (rtpendpointreceiver, "pattern-sdp", pattern_sdp, NULL);
fail_unless (gst_sdp_message_free (pattern_sdp) == GST_SDP_OK);
hod = g_slice_new (HandOffData);
hod->expected_caps = expected_caps;
hod->loop = loop;
g_object_set (G_OBJECT (outputfakesink), "signal-handoffs", TRUE, NULL);
g_signal_connect (G_OBJECT (outputfakesink), "handoff",
G_CALLBACK (fakesink_hand_off), hod);
/* Add elements */
gst_bin_add_many (GST_BIN (pipeline), videotestsrc, video_enc,
rtpendpointsender, NULL);
gst_element_link (videotestsrc, video_enc);
gst_element_link_pads (video_enc, NULL, rtpendpointsender, "video_sink");
gst_bin_add_many (GST_BIN (pipeline), rtpendpointreceiver, outputfakesink,
NULL);
kms_element_link_pads (rtpendpointreceiver, "video_src_%u", outputfakesink,
"sink");
if (!play_after_negotiation)
gst_element_set_state (pipeline, GST_STATE_PLAYING);
/* SDP negotiation */
mark_point ();
g_signal_emit_by_name (rtpendpointsender, "generate-offer", &offer);
fail_unless (offer != NULL);
mark_point ();
g_signal_emit_by_name (rtpendpointreceiver, "process-offer", offer, &answer);
fail_unless (answer != NULL);
mark_point ();
g_signal_emit_by_name (rtpendpointsender, "process-answer", answer);
gst_sdp_message_free (offer);
gst_sdp_message_free (answer);
if (play_after_negotiation)
gst_element_set_state (pipeline, GST_STATE_PLAYING);
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
GST_DEBUG_GRAPH_SHOW_ALL, "test_sendonly_before_entering_loop");
mark_point ();
g_main_loop_run (loop);
mark_point ();
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
GST_DEBUG_GRAPH_SHOW_ALL, "test_sendonly_end");
gst_element_set_state (pipeline, GST_STATE_NULL);
g_object_unref (pipeline);
g_slice_free (HandOffData, hod);
g_main_loop_unref (loop);
} | // FIXME: if agnosticbin is used, the test fails | https://github.com/Kurento/kurento/blob/b04c741488b60a10692f08d01e87b8bb08ef0300/server/module-elements/tests/check/element/rtpendpoint_video.c#L105-L194 | b04c741488b60a10692f08d01e87b8bb08ef0300 |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | main | int
main ()
{
if(0 != setsockopt(0, SOL_SOCKET, SO_NONBLOCK, 0, 0))
return 1;
;
return 0;
} | /* includes end */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/CMake/CurlTests.c#L674-L681 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | my_ioctl | static curlioerr my_ioctl(CURL *handle, curliocmd cmd, void *userp)
{
intptr_t fd = (intptr_t)userp;
(void)handle; /* not used in here */
switch(cmd) {
case CURLIOCMD_RESTARTREAD:
/* mr libcurl kindly asks as to rewind the read data stream to start */
if(-1 == lseek(fd, 0, SEEK_SET))
/* couldn't rewind */
return CURLIOE_FAILRESTART;
break;
default: /* ignore unknown commands */
return CURLIOE_UNKNOWNCMD;
}
return CURLIOE_OK; /* success! */
} | /*
* This example shows a HTTP PUT operation with authentiction using "any"
* type. It PUTs a file given as a command line argument to the URL also given
* on the command line.
*
* Since libcurl 7.12.3, using "any" auth and POST/PUT requires a set ioctl
* function.
*
* This example also uses its own read callback.
*/
/* ioctl callback function */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/anyauthput.c#L74-L93 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | read_callback | static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream)
{
size_t retcode;
curl_off_t nread;
intptr_t fd = (intptr_t)stream;
retcode = read(fd, ptr, size * nmemb);
nread = (curl_off_t)retcode;
fprintf(stderr, "*** We read %" CURL_FORMAT_CURL_OFF_T
" bytes from file\n", nread);
return retcode;
} | /* read callback function, fread() look alike */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/anyauthput.c#L96-L111 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | ssl_app_verify_callback | static int ssl_app_verify_callback(X509_STORE_CTX *ctx, void *arg)
{
sslctxparm * p = (sslctxparm *) arg;
int ok;
if (p->verbose > 2)
BIO_printf(p->errorbio,"entering ssl_app_verify_callback\n");
if ((ok= X509_verify_cert(ctx)) && ctx->cert) {
unsigned char * accessinfo ;
if (p->verbose > 1)
X509_print_ex(p->errorbio,ctx->cert,0,0);
if (accessinfo = my_get_ext(ctx->cert,p->accesstype ,NID_sinfo_access)) {
if (p->verbose)
BIO_printf(p->errorbio,"Setting URL from SIA to: %s\n", accessinfo);
curl_easy_setopt(p->curl, CURLOPT_URL,accessinfo);
}
else if (accessinfo = my_get_ext(ctx->cert,p->accesstype,
NID_info_access)) {
if (p->verbose)
BIO_printf(p->errorbio,"Setting URL from AIA to: %s\n", accessinfo);
curl_easy_setopt(p->curl, CURLOPT_URL,accessinfo);
}
}
if (p->verbose > 2)
BIO_printf(p->errorbio,"leaving ssl_app_verify_callback with %d\n", ok);
return(ok);
} | /* This is an application verification call back, it does not
perform any addition verification but tries to find a URL
in the presented certificat. If found, this will become
the URL to be used in the POST.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/curlx.c#L182-L212 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | sslctxfun | static CURLcode sslctxfun(CURL * curl, void * sslctx, void * parm) {
sslctxparm * p = (sslctxparm *) parm;
SSL_CTX * ctx = (SSL_CTX *) sslctx ;
if (!SSL_CTX_use_certificate(ctx,p->usercert)) {
BIO_printf(p->errorbio, "SSL_CTX_use_certificate problem\n"); goto err;
}
if (!SSL_CTX_use_PrivateKey(ctx,p->pkey)) {
BIO_printf(p->errorbio, "SSL_CTX_use_PrivateKey\n"); goto err;
}
if (!SSL_CTX_check_private_key(ctx)) {
BIO_printf(p->errorbio, "SSL_CTX_check_private_key\n"); goto err;
}
SSL_CTX_set_quiet_shutdown(ctx,1);
SSL_CTX_set_cipher_list(ctx,"RC4-MD5");
SSL_CTX_set_mode(ctx, SSL_MODE_AUTO_RETRY);
X509_STORE_add_cert(SSL_CTX_get_cert_store(ctx), sk_X509_value(p->ca, sk_X509_num(p->ca)-1));
SSL_CTX_set_verify_depth(ctx,2);
SSL_CTX_set_verify(ctx,SSL_VERIFY_PEER,ZERO_NULL);
SSL_CTX_set_cert_verify_callback(ctx, ssl_app_verify_callback, parm);
return CURLE_OK ;
err:
ERR_print_errors(p->errorbio);
return CURLE_SSL_CERTPROBLEM;
} | /* This is an example of an curl SSL initialisation call back. The callback sets:
- a private key and certificate
- a trusted ca certificate
- a preferred cipherlist
- an application verification callback (the function above)
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/curlx.c#L222-L256 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | multi_timer_cb | static int multi_timer_cb(CURLM *multi, long timeout_ms, GlobalInfo *g)
{
DPRINT("%s %li\n", __PRETTY_FUNCTION__, timeout_ms);
ev_timer_stop(g->loop, &g->timer_event);
if (timeout_ms > 0)
{
double t = timeout_ms / 1000;
ev_timer_init(&g->timer_event, timer_cb, t, 0.);
ev_timer_start(g->loop, &g->timer_event);
}else
timer_cb(g->loop, &g->timer_event, 0);
return 0;
} | /* Update the event timer after curl_multi library calls */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/evhiperfifo.c#L114-L126 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | mcode_or_die | static void mcode_or_die(const char *where, CURLMcode code)
{
if ( CURLM_OK != code )
{
const char *s;
switch ( code )
{
case CURLM_CALL_MULTI_PERFORM: s="CURLM_CALL_MULTI_PERFORM"; break;
case CURLM_BAD_HANDLE: s="CURLM_BAD_HANDLE"; break;
case CURLM_BAD_EASY_HANDLE: s="CURLM_BAD_EASY_HANDLE"; break;
case CURLM_OUT_OF_MEMORY: s="CURLM_OUT_OF_MEMORY"; break;
case CURLM_INTERNAL_ERROR: s="CURLM_INTERNAL_ERROR"; break;
case CURLM_UNKNOWN_OPTION: s="CURLM_UNKNOWN_OPTION"; break;
case CURLM_LAST: s="CURLM_LAST"; break;
default: s="CURLM_unknown";
break;
case CURLM_BAD_SOCKET: s="CURLM_BAD_SOCKET";
fprintf(MSG_OUT, "ERROR: %s returns %s\n", where, s);
/* ignore this error */
return;
}
fprintf(MSG_OUT, "ERROR: %s returns %s\n", where, s);
exit(code);
}
} | /* Die if we get a bad CURLMcode somewhere */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/evhiperfifo.c#L129-L153 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | check_multi_info | static void check_multi_info(GlobalInfo *g)
{
char *eff_url;
CURLMsg *msg;
int msgs_left;
ConnInfo *conn;
CURL *easy;
CURLcode res;
fprintf(MSG_OUT, "REMAINING: %d\n", g->still_running);
while ((msg = curl_multi_info_read(g->multi, &msgs_left))) {
if (msg->msg == CURLMSG_DONE) {
easy = msg->easy_handle;
res = msg->data.result;
curl_easy_getinfo(easy, CURLINFO_PRIVATE, &conn);
curl_easy_getinfo(easy, CURLINFO_EFFECTIVE_URL, &eff_url);
fprintf(MSG_OUT, "DONE: %s => (%d) %s\n", eff_url, res, conn->error);
curl_multi_remove_handle(g->multi, easy);
free(conn->url);
curl_easy_cleanup(easy);
free(conn);
}
}
} | /* Check for completed transfers, and remove their easy handles */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/evhiperfifo.c#L158-L181 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | event_cb | static void event_cb(EV_P_ struct ev_io *w, int revents)
{
DPRINT("%s w %p revents %i\n", __PRETTY_FUNCTION__, w, revents);
GlobalInfo *g = (GlobalInfo*) w->data;
CURLMcode rc;
int action = (revents&EV_READ?CURL_POLL_IN:0)|
(revents&EV_WRITE?CURL_POLL_OUT:0);
rc = curl_multi_socket_action(g->multi, w->fd, action, &g->still_running);
mcode_or_die("event_cb: curl_multi_socket_action", rc);
check_multi_info(g);
if ( g->still_running <= 0 )
{
fprintf(MSG_OUT, "last transfer done, kill timeout\n");
ev_timer_stop(g->loop, &g->timer_event);
}
} | /* Called by libevent when we get action on a multi socket */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/evhiperfifo.c#L186-L202 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | timer_cb | static void timer_cb(EV_P_ struct ev_timer *w, int revents)
{
DPRINT("%s w %p revents %i\n", __PRETTY_FUNCTION__, w, revents);
GlobalInfo *g = (GlobalInfo *)w->data;
CURLMcode rc;
rc = curl_multi_socket_action(g->multi, CURL_SOCKET_TIMEOUT, 0, &g->still_running);
mcode_or_die("timer_cb: curl_multi_socket_action", rc);
check_multi_info(g);
} | /* Called by libevent when our timeout expires */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/evhiperfifo.c#L205-L215 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | remsock | static void remsock(SockInfo *f, GlobalInfo *g)
{
printf("%s \n", __PRETTY_FUNCTION__);
if ( f )
{
if ( f->evset )
ev_io_stop(g->loop, &f->ev);
free(f);
}
} | /* Clean up the SockInfo structure */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/evhiperfifo.c#L218-L227 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | setsock | static void setsock(SockInfo*f, curl_socket_t s, CURL*e, int act, GlobalInfo*g)
{
printf("%s \n", __PRETTY_FUNCTION__);
int kind = (act&CURL_POLL_IN?EV_READ:0)|(act&CURL_POLL_OUT?EV_WRITE:0);
f->sockfd = s;
f->action = act;
f->easy = e;
if ( f->evset )
ev_io_stop(g->loop, &f->ev);
ev_io_init(&f->ev, event_cb, f->sockfd, kind);
f->ev.data = g;
f->evset=1;
ev_io_start(g->loop, &f->ev);
} | /* Assign information to a SockInfo structure */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/evhiperfifo.c#L232-L247 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | addsock | static void addsock(curl_socket_t s, CURL *easy, int action, GlobalInfo *g)
{
SockInfo *fdp = calloc(sizeof(SockInfo), 1);
fdp->global = g;
setsock(fdp, s, easy, action, g);
curl_multi_assign(g->multi, s, fdp);
} | /* Initialize a new SockInfo structure */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/evhiperfifo.c#L252-L259 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | sock_cb | static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp)
{
DPRINT("%s e %p s %i what %i cbp %p sockp %p\n",
__PRETTY_FUNCTION__, e, s, what, cbp, sockp);
GlobalInfo *g = (GlobalInfo*) cbp;
SockInfo *fdp = (SockInfo*) sockp;
const char *whatstr[]={ "none", "IN", "OUT", "INOUT", "REMOVE"};
fprintf(MSG_OUT,
"socket callback: s=%d e=%p what=%s ", s, e, whatstr[what]);
if ( what == CURL_POLL_REMOVE )
{
fprintf(MSG_OUT, "\n");
remsock(fdp, g);
} else
{
if ( !fdp )
{
fprintf(MSG_OUT, "Adding data: %s\n", whatstr[what]);
addsock(s, e, what, g);
} else
{
fprintf(MSG_OUT,
"Changing action from %s to %s\n",
whatstr[fdp->action], whatstr[what]);
setsock(fdp, s, e, what, g);
}
}
return 0;
} | /* CURLMOPT_SOCKETFUNCTION */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/evhiperfifo.c#L262-L292 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | write_cb | static size_t write_cb(void *ptr, size_t size, size_t nmemb, void *data)
{
size_t realsize = size * nmemb;
ConnInfo *conn = (ConnInfo*) data;
(void)ptr;
(void)conn;
return realsize;
} | /* CURLOPT_WRITEFUNCTION */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/evhiperfifo.c#L296-L303 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | prog_cb | static int prog_cb (void *p, double dltotal, double dlnow, double ult,
double uln)
{
ConnInfo *conn = (ConnInfo *)p;
(void)ult;
(void)uln;
fprintf(MSG_OUT, "Progress: %s (%g/%g)\n", conn->url, dlnow, dltotal);
return 0;
} | /* CURLOPT_PROGRESSFUNCTION */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/evhiperfifo.c#L307-L316 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | new_conn | static void new_conn(char *url, GlobalInfo *g )
{
ConnInfo *conn;
CURLMcode rc;
conn = calloc(1, sizeof(ConnInfo));
memset(conn, 0, sizeof(ConnInfo));
conn->error[0]='\0';
conn->easy = curl_easy_init();
if ( !conn->easy )
{
fprintf(MSG_OUT, "curl_easy_init() failed, exiting!\n");
exit(2);
}
conn->global = g;
conn->url = strdup(url);
curl_easy_setopt(conn->easy, CURLOPT_URL, conn->url);
curl_easy_setopt(conn->easy, CURLOPT_WRITEFUNCTION, write_cb);
curl_easy_setopt(conn->easy, CURLOPT_WRITEDATA, conn);
curl_easy_setopt(conn->easy, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(conn->easy, CURLOPT_ERRORBUFFER, conn->error);
curl_easy_setopt(conn->easy, CURLOPT_PRIVATE, conn);
curl_easy_setopt(conn->easy, CURLOPT_NOPROGRESS, 0L);
curl_easy_setopt(conn->easy, CURLOPT_PROGRESSFUNCTION, prog_cb);
curl_easy_setopt(conn->easy, CURLOPT_PROGRESSDATA, conn);
curl_easy_setopt(conn->easy, CURLOPT_LOW_SPEED_TIME, 3L);
curl_easy_setopt(conn->easy, CURLOPT_LOW_SPEED_LIMIT, 10L);
fprintf(MSG_OUT,
"Adding easy %p to multi %p (%s)\n", conn->easy, g->multi, url);
rc = curl_multi_add_handle(g->multi, conn->easy);
mcode_or_die("new_conn: curl_multi_add_handle", rc);
/* note that the add_handle() will set a time-out to trigger very soon so
that the necessary socket_action() call will be called by this app */
} | /* Create a new easy handle, and add it to the global curl_multi */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/evhiperfifo.c#L320-L356 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | fifo_cb | static void fifo_cb(EV_P_ struct ev_io *w, int revents)
{
char s[1024];
long int rv=0;
int n=0;
GlobalInfo *g = (GlobalInfo *)w->data;
do
{
s[0]='\0';
rv=fscanf(g->input, "%1023s%n", s, &n);
s[n]='\0';
if ( n && s[0] )
{
new_conn(s,g); /* if we read a URL, go get it! */
} else break;
} while ( rv != EOF );
} | /* This gets called whenever data is received from the fifo */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/evhiperfifo.c#L359-L376 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | init_fifo | static int init_fifo (GlobalInfo *g)
{
struct stat st;
static const char *fifo = "hiper.fifo";
curl_socket_t sockfd;
fprintf(MSG_OUT, "Creating named pipe \"%s\"\n", fifo);
if ( lstat (fifo, &st) == 0 )
{
if ( (st.st_mode & S_IFMT) == S_IFREG )
{
errno = EEXIST;
perror("lstat");
exit (1);
}
}
unlink(fifo);
if ( mkfifo (fifo, 0600) == -1 )
{
perror("mkfifo");
exit (1);
}
sockfd = open(fifo, O_RDWR | O_NONBLOCK, 0);
if ( sockfd == -1 )
{
perror("open");
exit (1);
}
g->input = fdopen(sockfd, "r");
fprintf(MSG_OUT, "Now, pipe some URL's into > %s\n", fifo);
ev_io_init(&g->fifo_event, fifo_cb, sockfd, EV_READ);
ev_io_start(g->loop, &g->fifo_event);
return(0);
} | /* Create a named pipe and tell libevent to monitor it */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/evhiperfifo.c#L379-L413 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | write_callback | static size_t write_callback(char *buffer,
size_t size,
size_t nitems,
void *userp)
{
char *newbuff;
size_t rembuff;
URL_FILE *url = (URL_FILE *)userp;
size *= nitems;
rembuff=url->buffer_len - url->buffer_pos; /* remaining space in buffer */
if(size > rembuff) {
/* not enough space in buffer */
newbuff=realloc(url->buffer,url->buffer_len + (size - rembuff));
if(newbuff==NULL) {
fprintf(stderr,"callback buffer grow failed\n");
size=rembuff;
}
else {
/* realloc suceeded increase buffer size*/
url->buffer_len+=size - rembuff;
url->buffer=newbuff;
}
}
memcpy(&url->buffer[url->buffer_pos], buffer, size);
url->buffer_pos += size;
return size;
} | /* curl calls this routine to get more data */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/fopen.c#L90-L121 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | fill_buffer | static int fill_buffer(URL_FILE *file, size_t want)
{
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
struct timeval timeout;
int rc;
/* only attempt to fill buffer if transactions still running and buffer
* doesnt exceed required size already
*/
if((!file->still_running) || (file->buffer_pos > want))
return 0;
/* attempt to fill buffer */
do {
int maxfd = -1;
long curl_timeo = -1;
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
/* set a suitable timeout to fail on */
timeout.tv_sec = 60; /* 1 minute */
timeout.tv_usec = 0;
curl_multi_timeout(multi_handle, &curl_timeo);
if(curl_timeo >= 0) {
timeout.tv_sec = curl_timeo / 1000;
if(timeout.tv_sec > 1)
timeout.tv_sec = 1;
else
timeout.tv_usec = (curl_timeo % 1000) * 1000;
}
/* get file descriptors from the transfers */
curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
/* In a real-world program you OF COURSE check the return code of the
function calls. On success, the value of maxfd is guaranteed to be
greater or equal than -1. We call select(maxfd + 1, ...), specially
in case of (maxfd == -1), we call select(0, ...), which is basically
equal to sleep. */
rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
switch(rc) {
case -1:
/* select error */
break;
case 0:
default:
/* timeout or readable/writable sockets */
curl_multi_perform(multi_handle, &file->still_running);
break;
}
} while(file->still_running && (file->buffer_pos < want));
return 1;
} | /* use to attempt to fill the read buffer up to requested number of bytes */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/fopen.c#L124-L184 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | use_buffer | static int use_buffer(URL_FILE *file,int want)
{
/* sort out buffer */
if((file->buffer_pos - want) <=0) {
/* ditch buffer - write will recreate */
if(file->buffer)
free(file->buffer);
file->buffer=NULL;
file->buffer_pos=0;
file->buffer_len=0;
}
else {
/* move rest down make it available for later */
memmove(file->buffer,
&file->buffer[want],
(file->buffer_pos - want));
file->buffer_pos -= want;
}
return 0;
} | /* use to remove want bytes from the front of a files buffer */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/fopen.c#L187-L208 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | main | int main(int argc, char *argv[])
{
URL_FILE *handle;
FILE *outf;
int nread;
char buffer[256];
const char *url;
if(argc < 2)
url="http://192.168.7.3/testfile";/* default to testurl */
else
url=argv[1];/* use passed url */
/* copy from url line by line with fgets */
outf=fopen("fgets.test","w+");
if(!outf) {
perror("couldn't open fgets output file\n");
return 1;
}
handle = url_fopen(url, "r");
if(!handle) {
printf("couldn't url_fopen() %s\n", url);
fclose(outf);
return 2;
}
while(!url_feof(handle)) {
url_fgets(buffer,sizeof(buffer),handle);
fwrite(buffer,1,strlen(buffer),outf);
}
url_fclose(handle);
fclose(outf);
/* Copy from url with fread */
outf=fopen("fread.test","w+");
if(!outf) {
perror("couldn't open fread output file\n");
return 1;
}
handle = url_fopen("testfile", "r");
if(!handle) {
printf("couldn't url_fopen() testfile\n");
fclose(outf);
return 2;
}
do {
nread = url_fread(buffer, 1,sizeof(buffer), handle);
fwrite(buffer,1,nread,outf);
} while(nread);
url_fclose(handle);
fclose(outf);
/* Test rewind */
outf=fopen("rewind.test","w+");
if(!outf) {
perror("couldn't open fread output file\n");
return 1;
}
handle = url_fopen("testfile", "r");
if(!handle) {
printf("couldn't url_fopen() testfile\n");
fclose(outf);
return 2;
}
nread = url_fread(buffer, 1,sizeof(buffer), handle);
fwrite(buffer,1,nread,outf);
url_rewind(handle);
buffer[0]='\n';
fwrite(buffer,1,1,outf);
nread = url_fread(buffer, 1,sizeof(buffer), handle);
fwrite(buffer,1,nread,outf);
url_fclose(handle);
fclose(outf);
return 0;/* all done */
} | /* Small main program to retrive from a url using fgets and fread saving the
* output to two test files (note the fgets method will corrupt binary files if
* they contain 0 chars */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/fopen.c#L434-L527 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | throw_away | static size_t throw_away(void *ptr, size_t size, size_t nmemb, void *data)
{
(void)ptr;
(void)data;
/* we are not interested in the headers itself,
so we only return the size we would have saved ... */
return (size_t)(size * nmemb);
} | /*
* This is an example showing how to check a single file's size and mtime
* from an FTP server.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/ftpgetinfo.c#L32-L39 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | write_response | static size_t
write_response(void *ptr, size_t size, size_t nmemb, void *data)
{
FILE *writehere = (FILE *)data;
return fwrite(ptr, size, nmemb, writehere);
} | /*
* Similar to ftpget.c but this also stores the received response-lines
* in a separate file using our own callback!
*
* This functionality was introduced in libcurl 7.9.3.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/ftpgetresp.c#L33-L38 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | read_callback | static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream)
{
curl_off_t nread;
/* in real-world cases, this would probably get this data differently
as this fread() stuff is exactly what the library already would do
by default internally */
size_t retcode = fread(ptr, size, nmemb, stream);
nread = (curl_off_t)retcode;
fprintf(stderr, "*** We read %" CURL_FORMAT_CURL_OFF_T
" bytes from file\n", nread);
return retcode;
} | /* NOTE: if you want this example to work on Windows with libcurl as a
DLL, you MUST also provide a read callback with CURLOPT_READFUNCTION.
Failing to do so will give you a crash since a DLL may not use the
variable's memory when passed in to it from an app like this. */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/ftpupload.c#L52-L65 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | getcontentlengthfunc | size_t getcontentlengthfunc(void *ptr, size_t size, size_t nmemb, void *stream)
{
int r;
long len = 0;
/* _snscanf() is Win32 specific */
r = _snscanf(ptr, size * nmemb, "Content-Length: %ld\n", &len);
if (r) /* Microsoft: we don't read the specs */
*((long *) stream) = len;
return size * nmemb;
} | /* parse headers for Content-Length */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/ftpuploadresume.c#L48-L60 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | discardfunc | size_t discardfunc(void *ptr, size_t size, size_t nmemb, void *stream)
{
return size * nmemb;
} | /* discard downloaded data */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/ftpuploadresume.c#L63-L66 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | readfunc | size_t readfunc(void *ptr, size_t size, size_t nmemb, void *stream)
{
FILE *f = stream;
size_t n;
if (ferror(f))
return CURL_READFUNC_ABORT;
n = fread(ptr, size, nmemb, f) * size;
return n;
} | /* read data to upload */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/ftpuploadresume.c#L69-L80 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | mcode_or_die | static void mcode_or_die(const char *where, CURLMcode code) {
if ( CURLM_OK != code ) {
const char *s;
switch (code) {
case CURLM_CALL_MULTI_PERFORM: s="CURLM_CALL_MULTI_PERFORM"; break;
case CURLM_BAD_HANDLE: s="CURLM_BAD_HANDLE"; break;
case CURLM_BAD_EASY_HANDLE: s="CURLM_BAD_EASY_HANDLE"; break;
case CURLM_OUT_OF_MEMORY: s="CURLM_OUT_OF_MEMORY"; break;
case CURLM_INTERNAL_ERROR: s="CURLM_INTERNAL_ERROR"; break;
case CURLM_BAD_SOCKET: s="CURLM_BAD_SOCKET"; break;
case CURLM_UNKNOWN_OPTION: s="CURLM_UNKNOWN_OPTION"; break;
case CURLM_LAST: s="CURLM_LAST"; break;
default: s="CURLM_unknown";
}
MSG_OUT("ERROR: %s returns %s\n", where, s);
exit(code);
}
} | /* Die if we get a bad CURLMcode somewhere */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/ghiper.c#L103-L120 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | check_multi_info | static void check_multi_info(GlobalInfo *g)
{
char *eff_url;
CURLMsg *msg;
int msgs_left;
ConnInfo *conn;
CURL *easy;
CURLcode res;
MSG_OUT("REMAINING: %d\n", g->still_running);
while ((msg = curl_multi_info_read(g->multi, &msgs_left))) {
if (msg->msg == CURLMSG_DONE) {
easy = msg->easy_handle;
res = msg->data.result;
curl_easy_getinfo(easy, CURLINFO_PRIVATE, &conn);
curl_easy_getinfo(easy, CURLINFO_EFFECTIVE_URL, &eff_url);
MSG_OUT("DONE: %s => (%d) %s\n", eff_url, res, conn->error);
curl_multi_remove_handle(g->multi, easy);
free(conn->url);
curl_easy_cleanup(easy);
free(conn);
}
}
} | /* Check for completed transfers, and remove their easy handles */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/ghiper.c#L125-L148 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | timer_cb | static gboolean timer_cb(gpointer data)
{
GlobalInfo *g = (GlobalInfo *)data;
CURLMcode rc;
rc = curl_multi_socket_action(g->multi,
CURL_SOCKET_TIMEOUT, 0, &g->still_running);
mcode_or_die("timer_cb: curl_multi_socket_action", rc);
check_multi_info(g);
return FALSE;
} | /* Called by glib when our timeout expires */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/ghiper.c#L153-L163 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | update_timeout_cb | static int update_timeout_cb(CURLM *multi, long timeout_ms, void *userp)
{
struct timeval timeout;
GlobalInfo *g=(GlobalInfo *)userp;
timeout.tv_sec = timeout_ms/1000;
timeout.tv_usec = (timeout_ms%1000)*1000;
MSG_OUT("*** update_timeout_cb %ld => %ld:%ld ***\n",
timeout_ms, timeout.tv_sec, timeout.tv_usec);
g->timer_event = g_timeout_add(timeout_ms, timer_cb, g);
return 0;
} | /* Update the event timer after curl_multi library calls */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/ghiper.c#L168-L180 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | event_cb | static gboolean event_cb(GIOChannel *ch, GIOCondition condition, gpointer data)
{
GlobalInfo *g = (GlobalInfo*) data;
CURLMcode rc;
int fd=g_io_channel_unix_get_fd(ch);
int action =
(condition & G_IO_IN ? CURL_CSELECT_IN : 0) |
(condition & G_IO_OUT ? CURL_CSELECT_OUT : 0);
rc = curl_multi_socket_action(g->multi, fd, action, &g->still_running);
mcode_or_die("event_cb: curl_multi_socket_action", rc);
check_multi_info(g);
if(g->still_running) {
return TRUE;
} else {
MSG_OUT("last transfer done, kill timeout\n");
if (g->timer_event) { g_source_remove(g->timer_event); }
return FALSE;
}
} | /* Called by glib when we get action on a multi socket */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/ghiper.c#L186-L207 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | remsock | static void remsock(SockInfo *f)
{
if (!f) { return; }
if (f->ev) { g_source_remove(f->ev); }
g_free(f);
} | /* Clean up the SockInfo structure */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/ghiper.c#L212-L217 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | setsock | static void setsock(SockInfo*f, curl_socket_t s, CURL*e, int act, GlobalInfo*g)
{
GIOCondition kind =
(act&CURL_POLL_IN?G_IO_IN:0)|(act&CURL_POLL_OUT?G_IO_OUT:0);
f->sockfd = s;
f->action = act;
f->easy = e;
if (f->ev) { g_source_remove(f->ev); }
f->ev=g_io_add_watch(f->ch, kind, event_cb,g);
} | /* Assign information to a SockInfo structure */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/ghiper.c#L222-L233 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | addsock | static void addsock(curl_socket_t s, CURL *easy, int action, GlobalInfo *g)
{
SockInfo *fdp = g_malloc0(sizeof(SockInfo));
fdp->global = g;
fdp->ch=g_io_channel_unix_new(s);
setsock(fdp, s, easy, action, g);
curl_multi_assign(g->multi, s, fdp);
} | /* Initialize a new SockInfo structure */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/ghiper.c#L238-L246 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | sock_cb | static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp)
{
GlobalInfo *g = (GlobalInfo*) cbp;
SockInfo *fdp = (SockInfo*) sockp;
static const char *whatstr[]={ "none", "IN", "OUT", "INOUT", "REMOVE" };
MSG_OUT("socket callback: s=%d e=%p what=%s ", s, e, whatstr[what]);
if (what == CURL_POLL_REMOVE) {
MSG_OUT("\n");
remsock(fdp);
} else {
if (!fdp) {
MSG_OUT("Adding data: %s%s\n",
what&CURL_POLL_IN?"READ":"",
what&CURL_POLL_OUT?"WRITE":"" );
addsock(s, e, what, g);
}
else {
MSG_OUT(
"Changing action from %d to %d\n", fdp->action, what);
setsock(fdp, s, e, what, g);
}
}
return 0;
} | /* CURLMOPT_SOCKETFUNCTION */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/ghiper.c#L251-L275 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | write_cb | static size_t write_cb(void *ptr, size_t size, size_t nmemb, void *data)
{
size_t realsize = size * nmemb;
ConnInfo *conn = (ConnInfo*) data;
(void)ptr;
(void)conn;
return realsize;
} | /* CURLOPT_WRITEFUNCTION */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/ghiper.c#L280-L287 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | prog_cb | static int prog_cb (void *p, double dltotal, double dlnow, double ult, double uln)
{
ConnInfo *conn = (ConnInfo *)p;
MSG_OUT("Progress: %s (%g/%g)\n", conn->url, dlnow, dltotal);
return 0;
} | /* CURLOPT_PROGRESSFUNCTION */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/ghiper.c#L292-L297 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | new_conn | static void new_conn(char *url, GlobalInfo *g )
{
ConnInfo *conn;
CURLMcode rc;
conn = g_malloc0(sizeof(ConnInfo));
conn->error[0]='\0';
conn->easy = curl_easy_init();
if (!conn->easy) {
MSG_OUT("curl_easy_init() failed, exiting!\n");
exit(2);
}
conn->global = g;
conn->url = g_strdup(url);
curl_easy_setopt(conn->easy, CURLOPT_URL, conn->url);
curl_easy_setopt(conn->easy, CURLOPT_WRITEFUNCTION, write_cb);
curl_easy_setopt(conn->easy, CURLOPT_WRITEDATA, &conn);
curl_easy_setopt(conn->easy, CURLOPT_VERBOSE, (long)SHOW_VERBOSE);
curl_easy_setopt(conn->easy, CURLOPT_ERRORBUFFER, conn->error);
curl_easy_setopt(conn->easy, CURLOPT_PRIVATE, conn);
curl_easy_setopt(conn->easy, CURLOPT_NOPROGRESS, SHOW_PROGRESS?0L:1L);
curl_easy_setopt(conn->easy, CURLOPT_PROGRESSFUNCTION, prog_cb);
curl_easy_setopt(conn->easy, CURLOPT_PROGRESSDATA, conn);
curl_easy_setopt(conn->easy, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(conn->easy, CURLOPT_CONNECTTIMEOUT, 30L);
curl_easy_setopt(conn->easy, CURLOPT_LOW_SPEED_LIMIT, 1L);
curl_easy_setopt(conn->easy, CURLOPT_LOW_SPEED_TIME, 30L);
MSG_OUT("Adding easy %p to multi %p (%s)\n", conn->easy, g->multi, url);
rc =curl_multi_add_handle(g->multi, conn->easy);
mcode_or_die("new_conn: curl_multi_add_handle", rc);
/* note that the add_handle() will set a time-out to trigger very soon so
that the necessary socket_action() call will be called by this app */
} | /* Create a new easy handle, and add it to the global curl_multi */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/ghiper.c#L302-L338 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | fifo_cb | static gboolean fifo_cb (GIOChannel *ch, GIOCondition condition, gpointer data)
{
#define BUF_SIZE 1024
gsize len, tp;
gchar *buf, *tmp, *all=NULL;
GIOStatus rv;
do {
GError *err=NULL;
rv = g_io_channel_read_line (ch,&buf,&len,&tp,&err);
if ( buf ) {
if (tp) { buf[tp]='\0'; }
new_conn(buf,(GlobalInfo*)data);
g_free(buf);
} else {
buf = g_malloc(BUF_SIZE+1);
while (TRUE) {
buf[BUF_SIZE]='\0';
g_io_channel_read_chars(ch,buf,BUF_SIZE,&len,&err);
if (len) {
buf[len]='\0';
if (all) {
tmp=all;
all=g_strdup_printf("%s%s", tmp, buf);
g_free(tmp);
} else {
all = g_strdup(buf);
}
} else {
break;
}
}
if (all) {
new_conn(all,(GlobalInfo*)data);
g_free(all);
}
g_free(buf);
}
if ( err ) {
g_error("fifo_cb: %s", err->message);
g_free(err);
break;
}
} while ( (len) && (rv == G_IO_STATUS_NORMAL) );
return TRUE;
} | /* This gets called by glib whenever data is received from the fifo */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/ghiper.c#L342-L387 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | multi_timer_cb | static int multi_timer_cb(CURLM *multi, long timeout_ms, GlobalInfo *g)
{
struct timeval timeout;
(void)multi; /* unused */
timeout.tv_sec = timeout_ms/1000;
timeout.tv_usec = (timeout_ms%1000)*1000;
fprintf(MSG_OUT, "multi_timer_cb: Setting timeout to %ld ms\n", timeout_ms);
evtimer_add(&g->timer_event, &timeout);
return 0;
} | /* Update the event timer after curl_multi library calls */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/hiperfifo.c#L106-L116 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | mcode_or_die | static void mcode_or_die(const char *where, CURLMcode code)
{
if ( CURLM_OK != code ) {
const char *s;
switch (code) {
case CURLM_CALL_MULTI_PERFORM: s="CURLM_CALL_MULTI_PERFORM"; break;
case CURLM_BAD_HANDLE: s="CURLM_BAD_HANDLE"; break;
case CURLM_BAD_EASY_HANDLE: s="CURLM_BAD_EASY_HANDLE"; break;
case CURLM_OUT_OF_MEMORY: s="CURLM_OUT_OF_MEMORY"; break;
case CURLM_INTERNAL_ERROR: s="CURLM_INTERNAL_ERROR"; break;
case CURLM_UNKNOWN_OPTION: s="CURLM_UNKNOWN_OPTION"; break;
case CURLM_LAST: s="CURLM_LAST"; break;
default: s="CURLM_unknown";
break;
case CURLM_BAD_SOCKET: s="CURLM_BAD_SOCKET";
fprintf(MSG_OUT, "ERROR: %s returns %s\n", where, s);
/* ignore this error */
return;
}
fprintf(MSG_OUT, "ERROR: %s returns %s\n", where, s);
exit(code);
}
} | /* Die if we get a bad CURLMcode somewhere */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/hiperfifo.c#L119-L141 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | check_multi_info | static void check_multi_info(GlobalInfo *g)
{
char *eff_url;
CURLMsg *msg;
int msgs_left;
ConnInfo *conn;
CURL *easy;
CURLcode res;
fprintf(MSG_OUT, "REMAINING: %d\n", g->still_running);
while ((msg = curl_multi_info_read(g->multi, &msgs_left))) {
if (msg->msg == CURLMSG_DONE) {
easy = msg->easy_handle;
res = msg->data.result;
curl_easy_getinfo(easy, CURLINFO_PRIVATE, &conn);
curl_easy_getinfo(easy, CURLINFO_EFFECTIVE_URL, &eff_url);
fprintf(MSG_OUT, "DONE: %s => (%d) %s\n", eff_url, res, conn->error);
curl_multi_remove_handle(g->multi, easy);
free(conn->url);
curl_easy_cleanup(easy);
free(conn);
}
}
} | /* Check for completed transfers, and remove their easy handles */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/hiperfifo.c#L146-L169 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | event_cb | static void event_cb(int fd, short kind, void *userp)
{
GlobalInfo *g = (GlobalInfo*) userp;
CURLMcode rc;
int action =
(kind & EV_READ ? CURL_CSELECT_IN : 0) |
(kind & EV_WRITE ? CURL_CSELECT_OUT : 0);
rc = curl_multi_socket_action(g->multi, fd, action, &g->still_running);
mcode_or_die("event_cb: curl_multi_socket_action", rc);
check_multi_info(g);
if ( g->still_running <= 0 ) {
fprintf(MSG_OUT, "last transfer done, kill timeout\n");
if (evtimer_pending(&g->timer_event, NULL)) {
evtimer_del(&g->timer_event);
}
}
} | /* Called by libevent when we get action on a multi socket */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/hiperfifo.c#L174-L193 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | timer_cb | static void timer_cb(int fd, short kind, void *userp)
{
GlobalInfo *g = (GlobalInfo *)userp;
CURLMcode rc;
(void)fd;
(void)kind;
rc = curl_multi_socket_action(g->multi,
CURL_SOCKET_TIMEOUT, 0, &g->still_running);
mcode_or_die("timer_cb: curl_multi_socket_action", rc);
check_multi_info(g);
} | /* Called by libevent when our timeout expires */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/hiperfifo.c#L198-L209 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | remsock | static void remsock(SockInfo *f)
{
if (f) {
if (f->evset)
event_del(&f->ev);
free(f);
}
} | /* Clean up the SockInfo structure */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/hiperfifo.c#L214-L221 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | setsock | static void setsock(SockInfo*f, curl_socket_t s, CURL*e, int act, GlobalInfo*g)
{
int kind =
(act&CURL_POLL_IN?EV_READ:0)|(act&CURL_POLL_OUT?EV_WRITE:0)|EV_PERSIST;
f->sockfd = s;
f->action = act;
f->easy = e;
if (f->evset)
event_del(&f->ev);
event_set(&f->ev, f->sockfd, kind, event_cb, g);
f->evset=1;
event_add(&f->ev, NULL);
} | /* Assign information to a SockInfo structure */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/hiperfifo.c#L226-L239 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | addsock | static void addsock(curl_socket_t s, CURL *easy, int action, GlobalInfo *g) {
SockInfo *fdp = calloc(sizeof(SockInfo), 1);
fdp->global = g;
setsock(fdp, s, easy, action, g);
curl_multi_assign(g->multi, s, fdp);
} | /* Initialize a new SockInfo structure */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/hiperfifo.c#L244-L250 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | sock_cb | static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp)
{
GlobalInfo *g = (GlobalInfo*) cbp;
SockInfo *fdp = (SockInfo*) sockp;
const char *whatstr[]={ "none", "IN", "OUT", "INOUT", "REMOVE" };
fprintf(MSG_OUT,
"socket callback: s=%d e=%p what=%s ", s, e, whatstr[what]);
if (what == CURL_POLL_REMOVE) {
fprintf(MSG_OUT, "\n");
remsock(fdp);
}
else {
if (!fdp) {
fprintf(MSG_OUT, "Adding data: %s\n", whatstr[what]);
addsock(s, e, what, g);
}
else {
fprintf(MSG_OUT,
"Changing action from %s to %s\n",
whatstr[fdp->action], whatstr[what]);
setsock(fdp, s, e, what, g);
}
}
return 0;
} | /* CURLMOPT_SOCKETFUNCTION */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/hiperfifo.c#L253-L278 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | write_cb | static size_t write_cb(void *ptr, size_t size, size_t nmemb, void *data)
{
size_t realsize = size * nmemb;
ConnInfo *conn = (ConnInfo*) data;
(void)ptr;
(void)conn;
return realsize;
} | /* CURLOPT_WRITEFUNCTION */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/hiperfifo.c#L283-L290 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | prog_cb | static int prog_cb (void *p, double dltotal, double dlnow, double ult,
double uln)
{
ConnInfo *conn = (ConnInfo *)p;
(void)ult;
(void)uln;
fprintf(MSG_OUT, "Progress: %s (%g/%g)\n", conn->url, dlnow, dltotal);
return 0;
} | /* CURLOPT_PROGRESSFUNCTION */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/hiperfifo.c#L294-L303 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | new_conn | static void new_conn(char *url, GlobalInfo *g )
{
ConnInfo *conn;
CURLMcode rc;
conn = calloc(1, sizeof(ConnInfo));
memset(conn, 0, sizeof(ConnInfo));
conn->error[0]='\0';
conn->easy = curl_easy_init();
if (!conn->easy) {
fprintf(MSG_OUT, "curl_easy_init() failed, exiting!\n");
exit(2);
}
conn->global = g;
conn->url = strdup(url);
curl_easy_setopt(conn->easy, CURLOPT_URL, conn->url);
curl_easy_setopt(conn->easy, CURLOPT_WRITEFUNCTION, write_cb);
curl_easy_setopt(conn->easy, CURLOPT_WRITEDATA, &conn);
curl_easy_setopt(conn->easy, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(conn->easy, CURLOPT_ERRORBUFFER, conn->error);
curl_easy_setopt(conn->easy, CURLOPT_PRIVATE, conn);
curl_easy_setopt(conn->easy, CURLOPT_NOPROGRESS, 0L);
curl_easy_setopt(conn->easy, CURLOPT_PROGRESSFUNCTION, prog_cb);
curl_easy_setopt(conn->easy, CURLOPT_PROGRESSDATA, conn);
fprintf(MSG_OUT,
"Adding easy %p to multi %p (%s)\n", conn->easy, g->multi, url);
rc = curl_multi_add_handle(g->multi, conn->easy);
mcode_or_die("new_conn: curl_multi_add_handle", rc);
/* note that the add_handle() will set a time-out to trigger very soon so
that the necessary socket_action() call will be called by this app */
} | /* Create a new easy handle, and add it to the global curl_multi */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/hiperfifo.c#L307-L339 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | fifo_cb | static void fifo_cb(int fd, short event, void *arg)
{
char s[1024];
long int rv=0;
int n=0;
GlobalInfo *g = (GlobalInfo *)arg;
(void)fd; /* unused */
(void)event; /* unused */
do {
s[0]='\0';
rv=fscanf(g->input, "%1023s%n", s, &n);
s[n]='\0';
if ( n && s[0] ) {
new_conn(s,arg); /* if we read a URL, go get it! */
} else break;
} while ( rv != EOF);
} | /* This gets called whenever data is received from the fifo */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/hiperfifo.c#L342-L359 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | init_fifo | static int init_fifo (GlobalInfo *g)
{
struct stat st;
static const char *fifo = "hiper.fifo";
curl_socket_t sockfd;
fprintf(MSG_OUT, "Creating named pipe \"%s\"\n", fifo);
if (lstat (fifo, &st) == 0) {
if ((st.st_mode & S_IFMT) == S_IFREG) {
errno = EEXIST;
perror("lstat");
exit (1);
}
}
unlink(fifo);
if (mkfifo (fifo, 0600) == -1) {
perror("mkfifo");
exit (1);
}
sockfd = open(fifo, O_RDWR | O_NONBLOCK, 0);
if (sockfd == -1) {
perror("open");
exit (1);
}
g->input = fdopen(sockfd, "r");
fprintf(MSG_OUT, "Now, pipe some URL's into > %s\n", fifo);
event_set(&g->fifo_event, sockfd, EV_READ | EV_PERSIST, fifo_cb, g);
event_add(&g->fifo_event, NULL);
return (0);
} | /* Create a named pipe and tell libevent to monitor it */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/hiperfifo.c#L362-L392 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | write_cb | uint write_cb(char *in, uint size, uint nmemb, TidyBuffer *out)
{
uint r;
r = size * nmemb;
tidyBufAppend( out, in, r );
return(r);
} | /* curl write callback, to fill tidy's input buffer... */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/htmltidy.c#L37-L43 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | dumpNode | void dumpNode(TidyDoc doc, TidyNode tnod, int indent )
{
TidyNode child;
for ( child = tidyGetChild(tnod); child; child = tidyGetNext(child) )
{
ctmbstr name = tidyNodeGetName( child );
if ( name )
{
/* if it has a name, then it's an HTML tag ... */
TidyAttr attr;
printf( "%*.*s%s ", indent, indent, "<", name);
/* walk the attribute list */
for ( attr=tidyAttrFirst(child); attr; attr=tidyAttrNext(attr) ) {
printf(tidyAttrName(attr));
tidyAttrValue(attr)?printf("=\"%s\" ",
tidyAttrValue(attr)):printf(" ");
}
printf( ">\n");
}
else {
/* if it doesn't have a name, then it's probably text, cdata, etc... */
TidyBuffer buf;
tidyBufInit(&buf);
tidyNodeGetText(doc, child, &buf);
printf("%*.*s\n", indent, indent, buf.bp?(char *)buf.bp:"");
tidyBufFree(&buf);
}
dumpNode( doc, child, indent + 4 ); /* recursive */
}
} | /* Traverse the document tree */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/htmltidy.c#L46-L75 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | read_callback | static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream)
{
size_t retcode;
curl_off_t nread;
/* in real-world cases, this would probably get this data differently
as this fread() stuff is exactly what the library already would do
by default internally */
retcode = fread(ptr, size, nmemb, stream);
nread = (curl_off_t)retcode;
fprintf(stderr, "*** We read %" CURL_FORMAT_CURL_OFF_T
" bytes from file\n", nread);
return retcode;
} | /*
* This example shows a HTTP PUT operation. PUTs a file given as a command
* line argument to the URL also given on the command line.
*
* This example also uses its own read callback.
*
* Here's an article on how to setup a PUT handler for Apache:
* http://www.apacheweek.com/features/put
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/httpput.c#L39-L55 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | main | int main(void)
{
CURL *http_handle;
CURLM *multi_handle;
int still_running; /* keep number of running handles */
http_handle = curl_easy_init();
/* set the options (I left out a few, you'll get the point anyway) */
curl_easy_setopt(http_handle, CURLOPT_URL, "http://www.example.com/");
curl_easy_setopt(http_handle, CURLOPT_DEBUGFUNCTION, my_trace);
curl_easy_setopt(http_handle, CURLOPT_VERBOSE, 1L);
/* init a multi stack */
multi_handle = curl_multi_init();
/* add the individual transfers */
curl_multi_add_handle(multi_handle, http_handle);
/* we start some action by calling perform right away */
curl_multi_perform(multi_handle, &still_running);
do {
struct timeval timeout;
int rc; /* select() return code */
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
int maxfd = -1;
long curl_timeo = -1;
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
/* set a suitable timeout to play around with */
timeout.tv_sec = 1;
timeout.tv_usec = 0;
curl_multi_timeout(multi_handle, &curl_timeo);
if(curl_timeo >= 0) {
timeout.tv_sec = curl_timeo / 1000;
if(timeout.tv_sec > 1)
timeout.tv_sec = 1;
else
timeout.tv_usec = (curl_timeo % 1000) * 1000;
}
/* get file descriptors from the transfers */
curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
/* In a real-world program you OF COURSE check the return code of the
function calls. On success, the value of maxfd is guaranteed to be
greater or equal than -1. We call select(maxfd + 1, ...), specially in
case of (maxfd == -1), we call select(0, ...), which is basically equal
to sleep. */
rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
switch(rc) {
case -1:
/* select error */
still_running = 0;
printf("select() returns error, this is badness\n");
break;
case 0:
default:
/* timeout or readable/writable sockets */
curl_multi_perform(multi_handle, &still_running);
break;
}
} while(still_running);
curl_multi_cleanup(multi_handle);
curl_easy_cleanup(http_handle);
return 0;
} | /*
* Simply download a HTTP file.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/multi-debugcallback.c#L123-L205 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | main | int main(void)
{
CURL *http_handle;
CURL *http_handle2;
CURLM *multi_handle;
int still_running; /* keep number of running handles */
http_handle = curl_easy_init();
http_handle2 = curl_easy_init();
/* set options */
curl_easy_setopt(http_handle, CURLOPT_URL, "http://www.example.com/");
/* set options */
curl_easy_setopt(http_handle2, CURLOPT_URL, "http://localhost/");
/* init a multi stack */
multi_handle = curl_multi_init();
/* add the individual transfers */
curl_multi_add_handle(multi_handle, http_handle);
curl_multi_add_handle(multi_handle, http_handle2);
/* we start some action by calling perform right away */
curl_multi_perform(multi_handle, &still_running);
do {
struct timeval timeout;
int rc; /* select() return code */
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
int maxfd = -1;
long curl_timeo = -1;
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
/* set a suitable timeout to play around with */
timeout.tv_sec = 1;
timeout.tv_usec = 0;
curl_multi_timeout(multi_handle, &curl_timeo);
if(curl_timeo >= 0) {
timeout.tv_sec = curl_timeo / 1000;
if(timeout.tv_sec > 1)
timeout.tv_sec = 1;
else
timeout.tv_usec = (curl_timeo % 1000) * 1000;
}
/* get file descriptors from the transfers */
curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
/* In a real-world program you OF COURSE check the return code of the
function calls. On success, the value of maxfd is guaranteed to be
greater or equal than -1. We call select(maxfd + 1, ...), specially in
case of (maxfd == -1), we call select(0, ...), which is basically equal
to sleep. */
rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
switch(rc) {
case -1:
/* select error */
break;
case 0:
default:
/* timeout or readable/writable sockets */
curl_multi_perform(multi_handle, &still_running);
break;
}
} while(still_running);
curl_multi_cleanup(multi_handle);
curl_easy_cleanup(http_handle);
curl_easy_cleanup(http_handle2);
return 0;
} | /*
* Simply download two HTTP files!
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/multi-double.c#L35-L119 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | main | int main(void)
{
CURL *http_handle;
CURLM *multi_handle;
int still_running; /* keep number of running handles */
http_handle = curl_easy_init();
/* set the options (I left out a few, you'll get the point anyway) */
curl_easy_setopt(http_handle, CURLOPT_URL, "http://www.example.com/");
/* init a multi stack */
multi_handle = curl_multi_init();
/* add the individual transfers */
curl_multi_add_handle(multi_handle, http_handle);
/* we start some action by calling perform right away */
curl_multi_perform(multi_handle, &still_running);
do {
struct timeval timeout;
int rc; /* select() return code */
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
int maxfd = -1;
long curl_timeo = -1;
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
/* set a suitable timeout to play around with */
timeout.tv_sec = 1;
timeout.tv_usec = 0;
curl_multi_timeout(multi_handle, &curl_timeo);
if(curl_timeo >= 0) {
timeout.tv_sec = curl_timeo / 1000;
if(timeout.tv_sec > 1)
timeout.tv_sec = 1;
else
timeout.tv_usec = (curl_timeo % 1000) * 1000;
}
/* get file descriptors from the transfers */
curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
/* In a real-world program you OF COURSE check the return code of the
function calls. On success, the value of maxfd is guaranteed to be
greater or equal than -1. We call select(maxfd + 1, ...), specially in
case of (maxfd == -1), we call select(0, ...), which is basically equal
to sleep. */
rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
switch(rc) {
case -1:
/* select error */
still_running = 0;
printf("select() returns error, this is badness\n");
break;
case 0:
default:
/* timeout or readable/writable sockets */
curl_multi_perform(multi_handle, &still_running);
break;
}
} while(still_running);
curl_multi_cleanup(multi_handle);
curl_easy_cleanup(http_handle);
return 0;
} | /*
* Simply download a HTTP file.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/multi-single.c#L37-L116 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | main | int main(int argc, char **argv)
{
pthread_t tid[NUMT];
int i;
int error;
/* Must initialize libcurl before any threads are started */
curl_global_init(CURL_GLOBAL_ALL);
for(i=0; i< NUMT; i++) {
error = pthread_create(&tid[i],
NULL, /* default attributes please */
pull_one_url,
(void *)urls[i]);
if(0 != error)
fprintf(stderr, "Couldn't run thread number %d, errno %d\n", i, error);
else
fprintf(stderr, "Thread %d, gets %s\n", i, urls[i]);
}
/* now wait for all threads to terminate */
for(i=0; i< NUMT; i++) {
error = pthread_join(tid[i], NULL);
fprintf(stderr, "Thread %d terminated\n", i);
}
return 0;
} | /*
int pthread_create(pthread_t *new_thread_ID,
const pthread_attr_t *attr,
void * (*start_func)(void *), void *arg);
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/multithread.c#L66-L93 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | rtsp_options | static void rtsp_options(CURL *curl, const char *uri)
{
CURLcode res = CURLE_OK;
printf("\nRTSP: OPTIONS %s\n", uri);
my_curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI, uri);
my_curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_OPTIONS);
my_curl_easy_perform(curl);
} | /* send RTSP OPTIONS request */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/rtsp.c#L71-L78 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | rtsp_describe | static void rtsp_describe(CURL *curl, const char *uri,
const char *sdp_filename)
{
CURLcode res = CURLE_OK;
FILE *sdp_fp = fopen(sdp_filename, "wt");
printf("\nRTSP: DESCRIBE %s\n", uri);
if (sdp_fp == NULL) {
fprintf(stderr, "Could not open '%s' for writing\n", sdp_filename);
sdp_fp = stdout;
}
else {
printf("Writing SDP to '%s'\n", sdp_filename);
}
my_curl_easy_setopt(curl, CURLOPT_WRITEDATA, sdp_fp);
my_curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_DESCRIBE);
my_curl_easy_perform(curl);
my_curl_easy_setopt(curl, CURLOPT_WRITEDATA, stdout);
if (sdp_fp != stdout) {
fclose(sdp_fp);
}
} | /* send RTSP DESCRIBE request and write sdp response to a file */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/rtsp.c#L82-L102 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | rtsp_setup | static void rtsp_setup(CURL *curl, const char *uri, const char *transport)
{
CURLcode res = CURLE_OK;
printf("\nRTSP: SETUP %s\n", uri);
printf(" TRANSPORT %s\n", transport);
my_curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI, uri);
my_curl_easy_setopt(curl, CURLOPT_RTSP_TRANSPORT, transport);
my_curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_SETUP);
my_curl_easy_perform(curl);
} | /* send RTSP SETUP request */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/rtsp.c#L105-L114 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | rtsp_play | static void rtsp_play(CURL *curl, const char *uri, const char *range)
{
CURLcode res = CURLE_OK;
printf("\nRTSP: PLAY %s\n", uri);
my_curl_easy_setopt(curl, CURLOPT_RTSP_STREAM_URI, uri);
my_curl_easy_setopt(curl, CURLOPT_RANGE, range);
my_curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_PLAY);
my_curl_easy_perform(curl);
} | /* send RTSP PLAY request */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/rtsp.c#L118-L126 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | rtsp_teardown | static void rtsp_teardown(CURL *curl, const char *uri)
{
CURLcode res = CURLE_OK;
printf("\nRTSP: TEARDOWN %s\n", uri);
my_curl_easy_setopt(curl, CURLOPT_RTSP_REQUEST, (long)CURL_RTSPREQ_TEARDOWN);
my_curl_easy_perform(curl);
} | /* send RTSP TEARDOWN request */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/rtsp.c#L130-L136 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | get_sdp_filename | static void get_sdp_filename(const char *url, char *sdp_filename)
{
const char *s = strrchr(url, '/');
strcpy(sdp_filename, "video.sdp");
if (s != NULL) {
s++;
if (s[0] != '\0') {
sprintf(sdp_filename, "%s.sdp", s);
}
}
} | /* convert url into an sdp filename */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/rtsp.c#L140-L150 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | get_media_control_attribute | static void get_media_control_attribute(const char *sdp_filename,
char *control)
{
int max_len = 256;
char *s = malloc(max_len);
FILE *sdp_fp = fopen(sdp_filename, "rt");
control[0] = '\0';
if (sdp_fp != NULL) {
while (fgets(s, max_len - 2, sdp_fp) != NULL) {
sscanf(s, " a = control: %s", control);
}
fclose(sdp_fp);
}
free(s);
} | /* scan sdp file for media control attribute */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/rtsp.c#L154-L168 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | main | int main(int argc, char * const argv[])
{
#if 1
const char *transport = "RTP/AVP;unicast;client_port=1234-1235"; /* UDP */
#else
const char *transport = "RTP/AVP/TCP;unicast;client_port=1234-1235"; /* TCP */
#endif
const char *range = "0.000-";
int rc = EXIT_SUCCESS;
char *base_name = NULL;
printf("\nRTSP request %s\n", VERSION_STR);
printf(" Project web site: http://code.google.com/p/rtsprequest/\n");
printf(" Requires cURL V7.20 or greater\n\n");
/* check command line */
if ((argc != 2) && (argc != 3)) {
base_name = strrchr(argv[0], '/');
if (base_name == NULL) {
base_name = strrchr(argv[0], '\\');
}
if (base_name == NULL) {
base_name = argv[0];
} else {
base_name++;
}
printf("Usage: %s url [transport]\n", base_name);
printf(" url of video server\n");
printf(" transport (optional) specifier for media stream protocol\n");
printf(" default transport: %s\n", transport);
printf("Example: %s rtsp://192.168.0.2/media/video1\n\n", base_name);
rc = EXIT_FAILURE;
} else {
const char *url = argv[1];
char *uri = malloc(strlen(url) + 32);
char *sdp_filename = malloc(strlen(url) + 32);
char *control = malloc(strlen(url) + 32);
CURLcode res;
get_sdp_filename(url, sdp_filename);
if (argc == 3) {
transport = argv[2];
}
/* initialize curl */
res = curl_global_init(CURL_GLOBAL_ALL);
if (res == CURLE_OK) {
curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
CURL *curl;
fprintf(stderr, " cURL V%s loaded\n", data->version);
/* initialize this curl session */
curl = curl_easy_init();
if (curl != NULL) {
my_curl_easy_setopt(curl, CURLOPT_VERBOSE, 0L);
my_curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L);
my_curl_easy_setopt(curl, CURLOPT_WRITEHEADER, stdout);
my_curl_easy_setopt(curl, CURLOPT_URL, url);
/* request server options */
sprintf(uri, "%s", url);
rtsp_options(curl, uri);
/* request session description and write response to sdp file */
rtsp_describe(curl, uri, sdp_filename);
/* get media control attribute from sdp file */
get_media_control_attribute(sdp_filename, control);
/* setup media stream */
sprintf(uri, "%s/%s", url, control);
rtsp_setup(curl, uri, transport);
/* start playing media stream */
sprintf(uri, "%s/", url);
rtsp_play(curl, uri, range);
printf("Playing video, press any key to stop ...");
_getch();
printf("\n");
/* teardown session */
rtsp_teardown(curl, uri);
/* cleanup */
curl_easy_cleanup(curl);
curl = NULL;
} else {
fprintf(stderr, "curl_easy_init() failed\n");
}
curl_global_cleanup();
} else {
fprintf(stderr, "curl_global_init(%s) failed: %d\n",
"CURL_GLOBAL_ALL", res);
}
free(control);
free(sdp_filename);
free(uri);
}
return rc;
} | /* main app */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/rtsp.c#L172-L271 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | wait_on_socket | static int wait_on_socket(curl_socket_t sockfd, int for_recv, long timeout_ms)
{
struct timeval tv;
fd_set infd, outfd, errfd;
int res;
tv.tv_sec = timeout_ms / 1000;
tv.tv_usec= (timeout_ms % 1000) * 1000;
FD_ZERO(&infd);
FD_ZERO(&outfd);
FD_ZERO(&errfd);
FD_SET(sockfd, &errfd); /* always check for error */
if(for_recv)
{
FD_SET(sockfd, &infd);
}
else
{
FD_SET(sockfd, &outfd);
}
/* select() returns the number of signalled sockets or -1 */
res = select(sockfd + 1, &infd, &outfd, &errfd, &tv);
return res;
} | /* Auxiliary function that waits on the socket. */ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/sendrecv.c#L29-L56 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | main | int main(void)
{
int i;
CURL *curl;
CURLcode res;
FILE *headerfile;
const char *pPassphrase = NULL;
static const char *pCertFile = "testcert.pem";
static const char *pCACertFile="cacert.pem";
const char *pKeyName;
const char *pKeyType;
const char *pEngine;
#ifdef USE_ENGINE
pKeyName = "rsa_test";
pKeyType = "ENG";
pEngine = "chil"; /* for nChiper HSM... */
#else
pKeyName = "testkey.pem";
pKeyType = "PEM";
pEngine = NULL;
#endif
headerfile = fopen("dumpit", "w");
curl_global_init(CURL_GLOBAL_DEFAULT);
curl = curl_easy_init();
if(curl) {
/* what call to write: */
curl_easy_setopt(curl, CURLOPT_URL, "HTTPS://your.favourite.ssl.site");
curl_easy_setopt(curl, CURLOPT_WRITEHEADER, headerfile);
for(i = 0; i < 1; i++) /* single-iteration loop, just to break out from */
{
if (pEngine) /* use crypto engine */
{
if (curl_easy_setopt(curl, CURLOPT_SSLENGINE,pEngine) != CURLE_OK)
{ /* load the crypto engine */
fprintf(stderr,"can't set crypto engine\n");
break;
}
if (curl_easy_setopt(curl, CURLOPT_SSLENGINE_DEFAULT,1L) != CURLE_OK)
{ /* set the crypto engine as default */
/* only needed for the first time you load
a engine in a curl object... */
fprintf(stderr,"can't set crypto engine as default\n");
break;
}
}
/* cert is stored PEM coded in file... */
/* since PEM is default, we needn't set it for PEM */
curl_easy_setopt(curl,CURLOPT_SSLCERTTYPE,"PEM");
/* set the cert for client authentication */
curl_easy_setopt(curl,CURLOPT_SSLCERT,pCertFile);
/* sorry, for engine we must set the passphrase
(if the key has one...) */
if (pPassphrase)
curl_easy_setopt(curl,CURLOPT_KEYPASSWD,pPassphrase);
/* if we use a key stored in a crypto engine,
we must set the key type to "ENG" */
curl_easy_setopt(curl,CURLOPT_SSLKEYTYPE,pKeyType);
/* set the private key (file or ID in engine) */
curl_easy_setopt(curl,CURLOPT_SSLKEY,pKeyName);
/* set the file with the certs vaildating the server */
curl_easy_setopt(curl,CURLOPT_CAINFO,pCACertFile);
/* disconnect if we can't validate server's cert */
curl_easy_setopt(curl,CURLOPT_SSL_VERIFYPEER,1L);
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
/* Check for errors */
if(res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));
/* we are done... */
}
/* always cleanup */
curl_easy_cleanup(curl);
}
curl_global_cleanup();
return 0;
} | /* some requirements for this to work:
1. set pCertFile to the file with the client certificate
2. if the key is passphrase protected, set pPassphrase to the
passphrase you use
3. if you are using a crypto engine:
3.1. set a #define USE_ENGINE
3.2. set pEngine to the name of the crypto engine you use
3.3. set pKeyName to the key identifier you want to use
4. if you don't use a crypto engine:
4.1. set pKeyName to the file name of your client key
4.2. if the format of the key file is DER, set pKeyType to "DER"
!! verify of the server certificate is not implemented here !!
**** This example only works with libcurl 7.9.3 and later! ****
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/docs/examples/simplessl.c#L44-L138 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | Curl_resolver_global_init | int Curl_resolver_global_init(void)
{
#ifdef CARES_HAVE_ARES_LIBRARY_INIT
if(ares_library_init(ARES_LIB_INIT_ALL)) {
return CURLE_FAILED_INIT;
}
#endif
return CURLE_OK;
} | /*
* Curl_resolver_global_init() - the generic low-level asynchronous name
* resolve API. Called from curl_global_init() to initialize global resolver
* environment. Initializes ares library.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/lib/asyn-ares.c#L103-L111 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | Curl_resolver_global_cleanup | void Curl_resolver_global_cleanup(void)
{
#ifdef CARES_HAVE_ARES_LIBRARY_CLEANUP
ares_library_cleanup();
#endif
} | /*
* Curl_resolver_global_cleanup()
*
* Called from curl_global_cleanup() to destroy global resolver environment.
* Deinitializes ares library.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/lib/asyn-ares.c#L119-L124 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | Curl_resolver_init | CURLcode Curl_resolver_init(void **resolver)
{
int status = ares_init((ares_channel*)resolver);
if(status != ARES_SUCCESS) {
if(status == ARES_ENOMEM)
return CURLE_OUT_OF_MEMORY;
else
return CURLE_FAILED_INIT;
}
return CURLE_OK;
/* make sure that all other returns from this function should destroy the
ares channel before returning error! */
} | /*
* Curl_resolver_init()
*
* Called from curl_easy_init() -> Curl_open() to initialize resolver
* URL-state specific environment ('resolver' member of the UrlState
* structure). Fills the passed pointer by the initialized ares_channel.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/lib/asyn-ares.c#L133-L145 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | Curl_resolver_cleanup | void Curl_resolver_cleanup(void *resolver)
{
ares_destroy((ares_channel)resolver);
} | /*
* Curl_resolver_cleanup()
*
* Called from curl_easy_cleanup() -> Curl_close() to cleanup resolver
* URL-state specific environment ('resolver' member of the UrlState
* structure). Destroys the ares channel.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/lib/asyn-ares.c#L154-L157 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | Curl_resolver_duphandle | int Curl_resolver_duphandle(void **to, void *from)
{
/* Clone the ares channel for the new handle */
if(ARES_SUCCESS != ares_dup((ares_channel*)to,(ares_channel)from))
return CURLE_FAILED_INIT;
return CURLE_OK;
} | /*
* Curl_resolver_duphandle()
*
* Called from curl_easy_duphandle() to duplicate resolver URL-state specific
* environment ('resolver' member of the UrlState structure). Duplicates the
* 'from' ares channel and passes the resulting channel to the 'to' pointer.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/lib/asyn-ares.c#L166-L172 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
BigWorld-Engine-14.4.1 | github_2023 | v2v3v4 | c | Curl_resolver_cancel | void Curl_resolver_cancel(struct connectdata *conn)
{
if(conn && conn->data && conn->data->state.resolver)
ares_cancel((ares_channel)conn->data->state.resolver);
destroy_async_data(&conn->async);
} | /*
* Cancel all possibly still on-going resolves for this connection.
*/ | https://github.com/v2v3v4/BigWorld-Engine-14.4.1/blob/4389085c8ce35cff887a4cc18fc47d1133d89ffb/programming/bigworld/third_party/curl/lib/asyn-ares.c#L179-L184 | 4389085c8ce35cff887a4cc18fc47d1133d89ffb |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.