这篇教程C++ xmpp_debug函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中xmpp_debug函数的典型用法代码示例。如果您正苦于以下问题:C++ xmpp_debug函数的具体用法?C++ xmpp_debug怎么用?C++ xmpp_debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了xmpp_debug函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: _handle_stream_startstatic void _handle_stream_start(char *name, char **attrs, void * const userdata){ xmpp_conn_t *conn = (xmpp_conn_t *)userdata; char *id; xmpp_debug(conn->ctx, "xmpp", "debug: _handle_stream_start"); if (strcmp(name, "stream:stream") != 0) { printf("name = %s/n", name); xmpp_error(conn->ctx, "conn", "Server did not open valid stream."); conn_disconnect(conn); } else { _log_open_tag(conn, attrs); if (conn->stream_id) xmpp_free(conn->ctx, conn->stream_id); id = _get_stream_attribute(attrs, "id"); if (id) conn->stream_id = xmpp_strdup(conn->ctx, id); if (!conn->stream_id) { xmpp_error(conn->ctx, "conn", "Memory allocation failed."); conn_disconnect(conn); } } /* call stream open handler */ xmpp_debug(conn->ctx, "xmpp", "will call open_handler"); conn->open_handler(conn);}
开发者ID:tohava,项目名称:libstrophe,代码行数:29,
示例2: _handle_sasl_resultstatic int _handle_sasl_result(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata){ char *name; name = xmpp_stanza_get_name(stanza); /* the server should send a <success> or <failure> stanza */ if (strcmp(name, "failure") == 0) { xmpp_debug(conn->ctx, "xmpp", "SASL %s auth failed", (char *)userdata); /* fall back to next auth method */ _auth(conn); } else if (strcmp(name, "success") == 0) { /* SASL PLAIN auth successful, we need to restart the stream */ xmpp_debug(conn->ctx, "xmpp", "SASL %s auth successful", (char *)userdata); /* reset parser */ conn_prepare_reset(conn, _handle_open_sasl); /* send stream tag */ conn_open_stream(conn); } else { /* got unexpected reply */ xmpp_error(conn->ctx, "xmpp", "Got unexpected reply to SASL %s"/ "authentication.", (char *)userdata); xmpp_disconnect(conn); } return 0;}
开发者ID:mcanthony,项目名称:libstrophe,代码行数:34,
示例3: _handle_proceedtls_defaultstatic int _handle_proceedtls_default(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata){ char *name; name = xmpp_stanza_get_name(stanza); xmpp_debug(conn->ctx, "xmpp", "handle proceedtls called for %s", name); if (strcmp(name, "proceed") == 0) { xmpp_debug(conn->ctx, "xmpp", "proceeding with TLS"); conn->tls = tls_new(conn->ctx, conn->sock); if (!tls_start(conn->tls)) { xmpp_debug(conn->ctx, "xmpp", "Couldn't start TLS! error %d", tls_error(conn->tls)); tls_free(conn->tls); conn->tls = NULL; conn->tls_failed = 1; /* failed tls spoils the connection, so disconnect */ xmpp_disconnect(conn); } else { conn->secured = 1; conn_prepare_reset(conn, auth_handle_open); conn_open_stream(conn); } } return 0;}
开发者ID:mcanthony,项目名称:libstrophe,代码行数:35,
示例4: xmpp_connect_client/** Initiate a connection to the XMPP server. * This function returns immediately after starting the connection * process to the XMPP server, and notifications of connection state changes * will be sent to the callback function. The domain and port to connect to * are usually determined by an SRV lookup for the xmpp-client service at * the domain specified in the JID. If SRV lookup fails, altdomain and * altport will be used instead if specified. * * @param conn a Strophe connection object * @param altdomain a string with domain to use if SRV lookup fails. If this * is NULL, the domain from the JID will be used. * @param altport an integer port number to use if SRV lookup fails. If this * is 0, the default port will be assumed. * @param callback a xmpp_conn_handler callback function that will receive * notifications of connection status * @param userdata an opaque data pointer that will be passed to the callback * * @return XMPP_EOK (0) on success or a number less than 0 on failure * * @ingroup Connections */int xmpp_connect_client(xmpp_conn_t * const conn, const char * const altdomain, unsigned short altport, xmpp_conn_handler callback, void * const userdata){ resolver_srv_rr_t *srv_rr_list = NULL; resolver_srv_rr_t *rr; char *domain; const char *host = NULL; unsigned short port = 0; int found = XMPP_DOMAIN_NOT_FOUND; int rc; domain = xmpp_jid_domain(conn->ctx, conn->jid); if (!domain) return XMPP_EMEM; if (altdomain != NULL) { xmpp_debug(conn->ctx, "xmpp", "Connecting via altdomain."); host = altdomain; port = altport ? altport : _conn_default_port(conn, XMPP_CLIENT); found = XMPP_DOMAIN_ALTDOMAIN; /* SSL tunneled connection on 5223 port is legacy and doesn't * have an SRV record. */ } else if (!conn->tls_legacy_ssl) { found = resolver_srv_lookup(conn->ctx, "xmpp-client", "tcp", domain, &srv_rr_list); } if (XMPP_DOMAIN_NOT_FOUND == found) { xmpp_debug(conn->ctx, "xmpp", "SRV lookup failed, " "connecting via domain."); host = domain; port = altport ? altport : _conn_default_port(conn, XMPP_CLIENT); found = XMPP_DOMAIN_ALTDOMAIN; } rr = srv_rr_list; do { if (XMPP_DOMAIN_FOUND == found && rr != NULL) { host = rr->target; port = rr->port; rr = rr->next; } rc = _conn_connect(conn, domain, host, port, XMPP_CLIENT, callback, userdata); } while (rc != 0 && rr != NULL); xmpp_free(conn->ctx, domain); resolver_srv_free(conn->ctx, srv_rr_list); return rc;}
开发者ID:apophys,项目名称:libstrophe,代码行数:75,
示例5: xmpp_connect_client/** Initiate a connection to the XMPP server. * This function returns immediately after starting the connection * process to the XMPP server, and notifiations of connection state changes * will be sent to the callback function. The domain and port to connect to * are usually determined by an SRV lookup for the xmpp-client service at * the domain specified in the JID. If SRV lookup fails, altdomain and * altport will be used instead if specified. * * @param conn a Strophe connection object * @param altdomain a string with domain to use if SRV lookup fails. If this * is NULL, the domain from the JID will be used. * @param altport an integer port number to use if SRV lookup fails. If this * is 0, the default port (5222) will be assumed. * @param callback a xmpp_conn_handler callback function that will receive * notifications of connection status * @param userdata an opaque data pointer that will be passed to the callback * * @return 0 on success and -1 on an error * * @ingroup Connections */int xmpp_connect_client(xmpp_conn_t * const conn, const char * const altdomain, unsigned short altport, xmpp_conn_handler callback, void * const userdata){ char connectdomain[2048]; int connectport; const char * domain; conn->type = XMPP_CLIENT; conn->domain = xmpp_jid_domain(conn->ctx, conn->jid); if (!conn->domain) return -1; if (altdomain) { xmpp_debug(conn->ctx, "xmpp", "Connecting via altdomain."); strcpy(connectdomain, altdomain); connectport = altport ? altport : 5222; } else if (!sock_srv_lookup("xmpp-client", "tcp", conn->domain, connectdomain, 2048, &connectport)) { xmpp_debug(conn->ctx, "xmpp", "SRV lookup failed."); if (!altdomain) domain = conn->domain; else domain = altdomain; xmpp_debug(conn->ctx, "xmpp", "Using alternate domain %s, port %d", altdomain, altport); strcpy(connectdomain, domain); connectport = altport ? altport : 5222; } conn->sock = sock_connect(connectdomain, connectport); xmpp_debug(conn->ctx, "xmpp", "sock_connect to %s:%d returned %d", connectdomain, connectport, conn->sock); if (conn->sock == -1) return -1; /* setup handler */ conn->conn_handler = callback; conn->userdata = userdata; /* FIXME: it could happen that the connect returns immediately as * successful, though this is pretty unlikely. This would be a little * hard to fix, since we'd have to detect and fire off the callback * from within the event loop */ conn->state = XMPP_STATE_CONNECTING; conn->timeout_stamp = time_stamp(); xmpp_debug(conn->ctx, "xmpp", "attempting to connect to %s", connectdomain); if (conn->xev) conn_ev_add_connect_handler(conn->xev); return 0;}
开发者ID:tohava,项目名称:libstrophe,代码行数:75,
示例6: _handle_stream_stanzastatic void _handle_stream_stanza(xmpp_stanza_t *stanza, void * const userdata){ xmpp_conn_t *conn = (xmpp_conn_t *)userdata; char *buf; size_t len; xmpp_debug(conn->ctx, "xmpp", "debug: _handle_stream_stanza"); if (xmpp_stanza_to_text(stanza, &buf, &len) == 0) { xmpp_debug(conn->ctx, "xmpp", "RECV: %s", buf); xmpp_free(conn->ctx, buf); } handler_fire_stanza(conn, stanza);}
开发者ID:tohava,项目名称:libstrophe,代码行数:14,
示例7: xmpp_connect_component/** Initiate a component connection to server. * This function returns immediately after starting the connection * process to the XMPP server, and notifiations of connection state changes * will be sent to the internal callback function that will set up handler * for the component handshake as defined in XEP-0114. * The domain and port to connect to must be provided in this case as the JID * provided to the call serves as component identifier to the server and is * not subject to DNS resolution. * * @param conn a Strophe connection object * @param server a string with domain to use directly as the domain can't be * extracted from the component name/JID. If this is not set, the call * will fail. * @param port an integer port number to use to connect to server expecting * an external component. If this is 0, the port 5347 will be assumed. * @param callback a xmpp_conn_handler callback function that will receive * notifications of connection status * @param userdata an opaque data pointer that will be passed to the callback * * @return 0 on success and -1 on an error * * @ingroup Connections */int xmpp_connect_component(xmpp_conn_t * const conn, const char * const server, unsigned short port, xmpp_conn_handler callback, void * const userdata){ int connectport; if (conn->state != XMPP_STATE_DISCONNECTED) return -1; if (conn->domain != NULL) xmpp_free(conn->ctx, conn->domain); conn->type = XMPP_COMPONENT; conn->secured = 0; conn->tls_failed = 0; /* JID serves as an identificator here and will be used as "to" attribute of the stream */ conn->domain = xmpp_strdup(conn->ctx, conn->jid); /* The server domain, jid and password MUST be specified. */ if (!(server && conn->jid && conn->pass)) return -1; connectport = port ? port : _conn_default_port(conn); xmpp_debug(conn->ctx, "xmpp", "Connecting via %s", server); conn->sock = sock_connect(server, connectport); xmpp_debug(conn->ctx, "xmpp", "sock_connect to %s:%d returned %d", server, connectport, conn->sock); if (conn->sock == -1) return -1; /* XEP-0114 does not support TLS */ conn->tls_disabled = 1; /* setup handler */ conn->conn_handler = callback; conn->userdata = userdata; conn_prepare_reset(conn, auth_handle_component_open); /* FIXME: it could happen that the connect returns immediately as * successful, though this is pretty unlikely. This would be a little * hard to fix, since we'd have to detect and fire off the callback * from within the event loop */ conn->state = XMPP_STATE_CONNECTING; conn->timeout_stamp = time_stamp(); xmpp_debug(conn->ctx, "xmpp", "attempting to connect to %s", server); return 0;}
开发者ID:1Project,项目名称:SafeBoardMessenger,代码行数:72,
示例8: tls_startint tls_start(tls_t *tls){ int error; int ret; long x509_res; /* Since we're non-blocking, loop the connect call until it succeeds or fails */ while (1) { ret = SSL_connect(tls->ssl); error = ret <= 0 ? SSL_get_error(tls->ssl, ret) : 0; if (ret == -1 && tls_is_recoverable(error)) { /* wait for something to happen on the sock before looping back */ _tls_sock_wait(tls, error); continue; } /* success or fatal error */ break; } x509_res = SSL_get_verify_result(tls->ssl); xmpp_debug(tls->ctx, "tls", "Certificate verification %s", x509_res == X509_V_OK ? "passed" : "FAILED"); _tls_set_error(tls, error); return ret <= 0 ? 0 : 1;}
开发者ID:apophys,项目名称:libstrophe,代码行数:29,
示例9: _handle_registerstatic int _handle_register(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata){ char *type; /* delete missing handler */ xmpp_timed_handler_delete(conn, _handle_missing_register); /* server responded to legacy auth request */ type = xmpp_stanza_get_type(stanza); if (!type) { xmpp_error(conn->ctx, "xmpp", "Server sent us an unexpected response "/ "to register request."); xmpp_disconnect(conn); } else if (strcmp(type, "error") == 0) { /* legacy client auth failed, no more fallbacks */ xmpp_error(conn->ctx, "xmpp", "Register clientfailed."); xmpp_disconnect(conn); } else if (strcmp(type, "result") == 0) { /* auth succeeded */ xmpp_debug(conn->ctx, "xmpp", "Register succeeded."); _auth(conn); } else { xmpp_error(conn->ctx, "xmpp", "Server sent us a register" / "response with a bad type."); xmpp_disconnect(conn); } return 0;}
开发者ID:catap,项目名称:libstrophe,代码行数:32,
示例10: conn_tls_startint conn_tls_start(xmpp_conn_t * const conn){ int rc; if (conn->tls_disabled) { conn->tls = NULL; rc = -ENOSYS; } else { conn->tls = tls_new(conn->ctx, conn->sock); rc = conn->tls == NULL ? -ENOMEM : 0; } if (conn->tls != NULL) { if (tls_start(conn->tls)) { conn->secured = 1; conn_prepare_reset(conn, auth_handle_open); } else { rc = tls_error(conn->tls); conn->error = rc; tls_free(conn->tls); conn->tls = NULL; conn->tls_failed = 1; } } if (rc != 0) xmpp_debug(conn->ctx, "conn", "Couldn't start TLS! error %d", rc); return rc;}
开发者ID:1Project,项目名称:SafeBoardMessenger,代码行数:29,
示例11: xmpp_stop/** Stop the event loop. * This will stop the event loop after the current iteration and cause * xmpp_run to exit. * * @param ctx a Strophe context object * * @ingroup EventLoop */void xmpp_stop(xmpp_ctx_t *ctx){ xmpp_debug(ctx, "event", "Stopping event loop."); if (ctx->loop_status == XMPP_LOOP_RUNNING) ctx->loop_status = XMPP_LOOP_QUIT;}
开发者ID:pasis,项目名称:libmesode,代码行数:15,
示例12: _handle_sessionstatic int _handle_session(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata){ char *type; /* delete missing session handler */ xmpp_timed_handler_delete(conn, _handle_missing_session); /* server has replied to the session request */ type = xmpp_stanza_get_type(stanza); if (type && strcmp(type, "error") == 0) { xmpp_error(conn->ctx, "xmpp", "Session establishment failed."); xmpp_disconnect(conn); } else if (type && strcmp(type, "result") == 0) { xmpp_debug(conn->ctx, "xmpp", "Session establishment successful."); conn->authenticated = 1; /* call connection handler */ conn->conn_handler(conn, XMPP_CONN_CONNECT, 0, NULL, conn->userdata); } else { xmpp_error(conn->ctx, "xmpp", "Server sent malformed session reply."); xmpp_disconnect(conn); } return 0;}
开发者ID:mcanthony,项目名称:libstrophe,代码行数:28,
示例13: _handle_component_hs_response/* Check if the received stanza is <handshake/> and set auth to true * and fire connection handler. */int _handle_component_hs_response(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata){ char *name; xmpp_timed_handler_delete(conn, _handle_missing_handshake); name = xmpp_stanza_get_name(stanza); if (strcmp(name, "handshake") != 0) { char *msg; size_t msg_size; xmpp_stanza_to_text(stanza, &msg, &msg_size); if (msg) { xmpp_debug(conn->ctx, "auth", "Handshake failed: %s", msg); xmpp_free(conn->ctx, msg); } xmpp_disconnect(conn); return XMPP_EINT; } else { conn->authenticated = 1; conn->conn_handler(conn, XMPP_CONN_CONNECT, 0, NULL, conn->userdata); } /* We don't need this handler anymore, return 0 so it can be deleted * from the list of handlers. */ return 0;}
开发者ID:mcanthony,项目名称:libstrophe,代码行数:32,
示例14: _log_open_tagstatic void _log_open_tag(xmpp_conn_t *conn, char **attrs){ char buf[4096]; size_t pos; int len; int i; if (!attrs) return; pos = 0; len = xmpp_snprintf(buf, 4096, "<stream:stream"); if (len < 0) return; pos += len; for (i = 0; attrs[i]; i += 2) { len = xmpp_snprintf(&buf[pos], 4096 - pos, " %s='%s'", attrs[i], attrs[i+1]); if (len < 0) return; pos += len; } len = xmpp_snprintf(&buf[pos], 4096 - pos, ">"); if (len < 0) return; xmpp_debug(conn->ctx, "xmpp", "RECV: %s", buf);}
开发者ID:CAOJINGYOU,项目名称:libstrophe,代码行数:27,
示例15: _handle_legacystatic int _handle_legacy(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata){ char *type, *name; /* delete missing handler */ xmpp_timed_handler_delete(conn, _handle_missing_legacy); /* server responded to legacy auth request */ type = xmpp_stanza_get_type(stanza); name = xmpp_stanza_get_name(stanza); if (!type || strcmp(name, "iq") != 0) { xmpp_error(conn->ctx, "xmpp", "Server sent us an unexpected response "/ "to legacy authentication request."); xmpp_disconnect(conn); } else if (strcmp(type, "error") == 0) { /* legacy client auth failed, no more fallbacks */ xmpp_error(conn->ctx, "xmpp", "Legacy client authentication failed."); xmpp_disconnect(conn); } else if (strcmp(type, "result") == 0) { /* auth succeeded */ xmpp_debug(conn->ctx, "xmpp", "Legacy auth succeeded."); conn->authenticated = 1; conn->conn_handler(conn, XMPP_CONN_CONNECT, 0, NULL, conn->userdata); } else { xmpp_error(conn->ctx, "xmpp", "Server sent us a legacy authentication "/ "response with a bad type."); xmpp_disconnect(conn); } return 0;}
开发者ID:mcanthony,项目名称:libstrophe,代码行数:34,
示例16: _handle_digestmd5_rspauth/* handle the rspauth phase of digest auth */static int _handle_digestmd5_rspauth(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata){ xmpp_stanza_t *auth; char *name; name = xmpp_stanza_get_name(stanza); xmpp_debug(conn->ctx, "xmpp", "handle digest-md5 (rspauth) called for %s", name); if (strcmp(name, "challenge") == 0) { /* assume it's an rspauth response */ auth = xmpp_stanza_new(conn->ctx); if (!auth) { disconnect_mem_error(conn); return 0; } xmpp_stanza_set_name(auth, "response"); xmpp_stanza_set_ns(auth, XMPP_NS_SASL); xmpp_send(conn, auth); xmpp_stanza_release(auth); } else { return _handle_sasl_result(conn, stanza, "DIGEST-MD5"); } return 1;}
开发者ID:mcanthony,项目名称:libstrophe,代码行数:30,
示例17: conn_tls_startint conn_tls_start(xmpp_conn_t * const conn){ int rc; if (conn->tls_disabled) { conn->tls = NULL; rc = XMPP_EINVOP; } else { conn->tls = tls_new(conn); rc = conn->tls == NULL ? XMPP_EMEM : 0; } if (conn->tls != NULL) { if (tls_start(conn->tls)) { conn->secured = 1; } else { rc = XMPP_EINT; conn->error = tls_error(conn->tls); tls_free(conn->tls); conn->tls = NULL; conn->tls_failed = 1; } } if (rc != 0) { xmpp_debug(conn->ctx, "conn", "Couldn't start TLS! " "error %d tls_error %d", rc, conn->error); } return rc;}
开发者ID:apophys,项目名称:libstrophe,代码行数:29,
示例18: _conn_connectstatic int _conn_connect(xmpp_conn_t * const conn, const char * const domain, const char * const host, unsigned short port, xmpp_conn_type_t type, xmpp_conn_handler callback, void * const userdata){ xmpp_open_handler open_handler; if (conn->state != XMPP_STATE_DISCONNECTED) return XMPP_EINVOP; if (type != XMPP_CLIENT && type != XMPP_COMPONENT) return XMPP_EINVOP; if (host == NULL || port == 0) return XMPP_EINT; _conn_reset(conn); conn->type = type; conn->domain = xmpp_strdup(conn->ctx, domain); if (!conn->domain) return XMPP_EMEM; conn->sock = sock_connect(host, port); xmpp_debug(conn->ctx, "xmpp", "sock_connect() to %s:%u returned %d", host, port, conn->sock); if (conn->sock == -1) return XMPP_EINT; if (conn->ka_timeout || conn->ka_interval) sock_set_keepalive(conn->sock, conn->ka_timeout, conn->ka_interval); /* setup handler */ conn->conn_handler = callback; conn->userdata = userdata; open_handler = conn->is_raw ? auth_handle_open_stub : type == XMPP_CLIENT ? auth_handle_open : auth_handle_component_open; conn_prepare_reset(conn, open_handler); /* FIXME: it could happen that the connect returns immediately as * successful, though this is pretty unlikely. This would be a little * hard to fix, since we'd have to detect and fire off the callback * from within the event loop */ conn->state = XMPP_STATE_CONNECTING; conn->timeout_stamp = time_stamp(); xmpp_debug(conn->ctx, "xmpp", "Attempting to connect to %s", host); return 0;}
开发者ID:apophys,项目名称:libstrophe,代码行数:47,
示例19: _tls_set_errorstatic void _tls_set_error(tls_t *tls, int error){ if (error != 0 && !tls_is_recoverable(error)) { xmpp_debug(tls->ctx, "tls", "error=%d errno=%d", error, errno); _tls_log_error(tls->ctx); } tls->lasterror = error;}
开发者ID:apophys,项目名称:libstrophe,代码行数:8,
示例20: _disconnect_cleanup/* timed handler for cleanup if normal disconnect procedure takes too long */static int _disconnect_cleanup(xmpp_conn_t * const conn, void * const userdata){ xmpp_debug(conn->ctx, "xmpp", "disconnection forced by cleanup timeout"); conn_disconnect(conn); return 0;}
开发者ID:ITikhonov,项目名称:libcouplet,代码行数:9,
示例21: _handle_stream_endstatic void _handle_stream_end(char *name, void * const userdata){ xmpp_conn_t *conn = (xmpp_conn_t *)userdata; /* stream is over */ xmpp_debug(conn->ctx, "xmpp", "RECV: </stream:stream>"); conn_disconnect_clean(conn);}
开发者ID:CAOJINGYOU,项目名称:libstrophe,代码行数:9,
示例22: _handle_component_auth/* Will compute SHA1 and authenticate the component to the server */int _handle_component_auth(xmpp_conn_t * const conn){ uint8_t md_value[SHA1_DIGEST_SIZE]; SHA1_CTX mdctx; char *digest; size_t i; if (conn->stream_id == NULL) { xmpp_error(conn->ctx, "auth", "Received no stream id from the server."); return XMPP_EINT; } /* C++ xmpp_disconnect函数代码示例 C++ xmove_fd函数代码示例
|