这篇教程C++ xmpp_error函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中xmpp_error函数的典型用法代码示例。如果您正苦于以下问题:C++ xmpp_error函数的具体用法?C++ xmpp_error怎么用?C++ xmpp_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了xmpp_error函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: _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,
示例2: _handle_stream_startstatic void _handle_stream_start(char *name, char **attrs, void * const userdata){ xmpp_conn_t *conn = (xmpp_conn_t *)userdata; char *id; 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 */ conn->open_handler(conn);}
开发者ID:CAOJINGYOU,项目名称:libstrophe,代码行数:28,
示例3: _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,
示例4: _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,
示例5: _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,
示例6: _conn_attributes_newstatic void _conn_attributes_new(xmpp_conn_t *conn, char **attrs, char ***attributes, size_t *attributes_len){ char **array = NULL; size_t nr = 0; size_t i; if (attrs) { for (; attrs[nr]; ++nr); array = xmpp_alloc(conn->ctx, sizeof(*array) * nr); for (i = 0; array && i < nr; ++i) { array[i] = (i & 1) == 0 ? parser_attr_name(conn->ctx, attrs[i]) : xmpp_strdup(conn->ctx, attrs[i]); if (array[i] == NULL) break; } if (!array || i < nr) { xmpp_error(conn->ctx, "xmpp", "Memory allocation error."); _conn_attributes_destroy(conn, array, i); array = NULL; nr = 0; } } *attributes = array; *attributes_len = nr;}
开发者ID:apophys,项目名称:libstrophe,代码行数:25,
示例7: _handle_missing_sessionstatic int _handle_missing_session(xmpp_conn_t * const conn, void * const userdata){ xmpp_error(conn->ctx, "xmpp", "Server did not reply to session request."); xmpp_disconnect(conn); return 0;}
开发者ID:mcanthony,项目名称:libstrophe,代码行数:7,
示例8: strlen/* split key, value pairs into a hash */static hash_t *_parse_digest_challenge(xmpp_ctx_t *ctx, const char *msg){ hash_t *result; unsigned char *text; char *key, *value; unsigned char *s, *t; text = (unsigned char *)xmpp_base64_decode_str(ctx, msg, strlen(msg)); if (text == NULL) { xmpp_error(ctx, "SASL", "couldn't Base64 decode challenge!"); return NULL; } result = hash_new(ctx, 10, xmpp_free); if (result != NULL) { s = text; while (*s != '/0') { /* skip any leading commas and spaces */ while ((*s == ',') || (*s == ' ')) s++; /* accumulate a key ending at '=' */ t = s; while ((*t != '=') && (*t != '/0')) t++; if (*t == '/0') break; /* bad string */ key = _make_string(ctx, (char *)s, (t-s)); if (key == NULL) break; /* advance our start pointer past the key */ s = t + 1; t = s; /* if we see quotes, grab the string in between */ if ((*s == '/'') || (*s == '"')) { t++; while ((*t != *s) && (*t != '/0')) t++; value = _make_string(ctx, (char *)s+1, (t-s-1)); if (*t == *s) { s = t + 1; } else { s = t; } /* otherwise, accumulate a value ending in ',' or '/0' */ } else { while ((*t != ',') && (*t != '/0')) t++; value = _make_string(ctx, (char *)s, (t-s)); s = t; } if (value == NULL) { xmpp_free(ctx, key); break; } /* TODO: check for collisions per spec */ hash_add(result, key, value); /* hash table now owns the value, free the key */ xmpp_free(ctx, key); } } xmpp_free(ctx, text); return result;}
开发者ID:boothj5,项目名称:libmesode,代码行数:60,
示例9: _start_elementstatic void _start_element(void *userdata, const XML_Char *nsname, const XML_Char **attrs){ parser_t *parser = (parser_t *)userdata; xmpp_stanza_t *child; char *ns, *name; ns = _xml_namespace(parser->ctx, nsname); name = _xml_name(parser->ctx, nsname); if (parser->depth == 0) { /* notify the owner */ if (parser->startcb) parser->startcb((char *)name, (char **)attrs, parser->userdata); } else { /* build stanzas at depth 1 */ if (!parser->stanza && parser->depth != 1) { /* something terrible happened */ /* FIXME: shutdown disconnect */ xmpp_error(parser->ctx, "parser", "oops, where did our stanza go?"); } else if (!parser->stanza) { /* starting a new toplevel stanza */ parser->stanza = xmpp_stanza_new(parser->ctx); if (!parser->stanza) { /* FIXME: can't allocate, disconnect */ } xmpp_stanza_set_name(parser->stanza, name); _set_attributes(parser->stanza, attrs); if (ns) xmpp_stanza_set_ns(parser->stanza, ns); } else { /* starting a child of parser->stanza */ child = xmpp_stanza_new(parser->ctx); if (!child) { /* FIXME: can't allocate, disconnect */ } xmpp_stanza_set_name(child, name); _set_attributes(child, attrs); if (ns) xmpp_stanza_set_ns(child, ns); /* add child to parent */ xmpp_stanza_add_child(parser->stanza, child); /* the child is owned by the toplevel stanza now */ xmpp_stanza_release(child); /* make child the current stanza */ parser->stanza = child; } } if (ns) xmpp_free(parser->ctx, ns); if (name) xmpp_free(parser->ctx, name); parser->depth++;}
开发者ID:EmuxEvans,项目名称:libstrophe,代码行数:59,
示例10: _handle_missing_features_saslstatic int _handle_missing_features_sasl(xmpp_conn_t * const conn, void * const userdata){ xmpp_error(conn->ctx, "xmpp", "Did not receive stream features "/ "after SASL authentication."); xmpp_disconnect(conn); return 0;}
开发者ID:mcanthony,项目名称:libstrophe,代码行数:8,
示例11: _start_elementstatic void _start_element(void *userdata, const xmlChar *name, const xmlChar *prefix, const xmlChar *uri, int nnamespaces, const xmlChar **namespaces, int nattrs, int ndefaulted, const xmlChar **attrs){ parser_t *parser = (parser_t *)userdata; xmpp_stanza_t *child; char **cbattrs; if (parser->depth == 0) { /* notify the owner */ if (parser->startcb) cbattrs = _convert_attrs(parser, nattrs, attrs); parser->startcb((char *)name, cbattrs, parser->userdata); _free_cbattrs(parser, cbattrs); } else { /* build stanzas at depth 1 */ if (!parser->stanza && parser->depth != 1) { /* something terrible happened */ /* FIXME: we should probably trigger a disconnect */ xmpp_error(parser->ctx, "parser", "oops, where did our stanza go?"); } else if (!parser->stanza) { /* starting a new toplevel stanza */ parser->stanza = xmpp_stanza_new(parser->ctx); if (!parser->stanza) { /* FIXME: can't allocate, disconnect */ } xmpp_stanza_set_name(parser->stanza, (char *)name); _set_attributes(parser->stanza, nattrs, attrs); if (uri) xmpp_stanza_set_ns(parser->stanza, (char *)uri); } else { /* starting a child of conn->stanza */ child = xmpp_stanza_new(parser->ctx); if (!child) { /* FIXME: can't allocate, disconnect */ } xmpp_stanza_set_name(child, (char *)name); _set_attributes(child, nattrs, attrs); if (uri) xmpp_stanza_set_ns(child, (char *)uri); /* add child to parent */ xmpp_stanza_add_child(parser->stanza, child); /* the child is owned by the toplevel stanza now */ xmpp_stanza_release(child); /* make child the current stanza */ parser->stanza = child; } } parser->depth++;}
开发者ID:1Project,项目名称:SafeBoardMessenger,代码行数:57,
示例12: xmpp_conn_set_flags/** Set flags for the connection. * This function applies set flags and resets unset ones. Default connection * configuration is all flags unset. Flags can be applied only for a connection * in disconnected state. * All unsupported flags are ignored. If a flag is unset after successful set * operation then the flag is not supported by current version. * * Supported flags are: * * - XMPP_CONN_FLAG_DISABLE_TLS * - XMPP_CONN_FLAG_MANDATORY_TLS * - XMPP_CONN_FLAG_LEGACY_SSL * * @param conn a Strophe connection object * @param flags ORed connection flags * * @return 0 on success or -1 if flags can't be applied. */int xmpp_conn_set_flags(xmpp_conn_t * const conn, long flags){ if (conn->state != XMPP_STATE_DISCONNECTED) { xmpp_error(conn->ctx, "conn", "Flags can be set only " "for disconnected connection"); return -1; } if (flags & XMPP_CONN_FLAG_DISABLE_TLS && flags & (XMPP_CONN_FLAG_MANDATORY_TLS | XMPP_CONN_FLAG_LEGACY_SSL)) { xmpp_error(conn->ctx, "conn", "Flags 0x%04lx conflict", flags); return -1; } conn->tls_disabled = (flags & XMPP_CONN_FLAG_DISABLE_TLS) ? 1 : 0; conn->tls_mandatory = (flags & XMPP_CONN_FLAG_MANDATORY_TLS) ? 1 : 0; conn->tls_legacy_ssl = (flags & XMPP_CONN_FLAG_LEGACY_SSL) ? 1 : 0; return 0;}
开发者ID:1Project,项目名称:SafeBoardMessenger,代码行数:37,
示例13: xmpp_log/** Write a log message to the logger. * Write a log message to the logger for the context for the specified * level and area. This function takes a printf-style format string and a * variable argument list (in va_list) format. This function is not meant * to be called directly, but is used via xmpp_error, xmpp_warn, xmpp_info, * and xmpp_debug. * * @param ctx a Strophe context object * @param level the level at which to log * @param area the area to log for * @param fmt a printf-style format string for the message * @param ap variable argument list supplied for the format string */void xmpp_log(const xmpp_ctx_t * const ctx, const xmpp_log_level_t level, const char * const area, const char * const fmt, va_list ap){ int oldret, ret; char smbuf[1024]; char *buf; va_list copy; va_copy(copy, ap); ret = xmpp_vsnprintf(smbuf, sizeof(smbuf), fmt, ap); if (ret >= (int)sizeof(smbuf)) { buf = (char *)xmpp_alloc(ctx, ret + 1); if (!buf) { buf = NULL; xmpp_error(ctx, "log", "Failed allocating memory for log message."); va_end(copy); return; } oldret = ret; ret = xmpp_vsnprintf(buf, ret + 1, fmt, copy); if (ret > oldret) { xmpp_error(ctx, "log", "Unexpected error"); xmpp_free(ctx, buf); va_end(copy); return; } } else { buf = smbuf; } va_end(copy); if (ctx->log->handler) ctx->log->handler(ctx->log->userdata, level, area, buf); if (buf != smbuf) xmpp_free(ctx, buf);}
开发者ID:1Project,项目名称:SafeBoardMessenger,代码行数:53,
示例14: xmpp_conn_set_keepalive/** Set TCP keepalive parameters * Turn on TCP keepalive and set timeout and interval. Zero timeout * disables TCP keepalives. The parameters are applied immediately for * a non disconnected object. Also, they are applied when the connection * object connects successfully. * * @param conn a Strophe connection object * @param timeout TCP keepalive timeout in seconds * @param interval TCP keepalive interval in seconds * * @ingroup Connections */void xmpp_conn_set_keepalive(xmpp_conn_t * const conn, int timeout, int interval){ int ret = 0; conn->ka_timeout = timeout; conn->ka_interval = interval; if (conn->state != XMPP_STATE_DISCONNECTED) ret = sock_set_keepalive(conn->sock, timeout, interval); if (ret < 0) { xmpp_error(conn->ctx, "xmpp", "Setting TCP keepalive (%d,%d) error: %d", timeout, interval, sock_error()); }}
开发者ID:apophys,项目名称:libstrophe,代码行数:27,
示例15: strlen/** Duplicate a string. * This function replaces the standard strdup library call with a version * that uses the Strophe context object's allocator. * * @param ctx a Strophe context object * @param s a string * * @return a new allocates string with the same data as s or NULL on error */char *xmpp_strdup(const xmpp_ctx_t * const ctx, const char * const s){ size_t len; char *copy; len = strlen(s); copy = xmpp_alloc(ctx, len + 1); if (!copy) { xmpp_error(ctx, "xmpp", "failed to allocate required memory"); return NULL; } memcpy(copy, s, len + 1); return copy;}
开发者ID:1Project,项目名称:SafeBoardMessenger,代码行数:25,
示例16: xmpp_alloc/** append 'key="value"' to a buffer, growing as necessary */static char *_add_key(xmpp_ctx_t *ctx, hash_t *table, const char *key, char *buf, int *len, int quote){ int olen,nlen; int keylen, valuelen; const char *value, *qvalue; char *c; /* allocate a zero-length string if necessary */ if (buf == NULL) { buf = xmpp_alloc(ctx, 1); buf[0] = '/0'; } if (buf == NULL) return NULL; /* get current string length */ olen = strlen(buf); value = hash_get(table, key); if (value == NULL) { xmpp_error(ctx, "SASL", "couldn't retrieve value for '%s'", key); value = ""; } if (quote) { qvalue = _make_quoted(ctx, value); } else { qvalue = value; } /* added length is key + '=' + value */ /* (+ ',' if we're not the first entry */ keylen = strlen(key); valuelen = strlen(qvalue); nlen = (olen ? 1 : 0) + keylen + 1 + valuelen + 1; buf = xmpp_realloc(ctx, buf, olen+nlen); if (buf != NULL) { c = buf + olen; if (olen) *c++ = ','; memcpy(c, key, keylen); c += keylen; *c++ = '='; memcpy(c, qvalue, valuelen); c += valuelen; *c++ = '/0'; } if (quote) xmpp_free(ctx, (char *)qvalue); return buf;}
开发者ID:boothj5,项目名称:libmesode,代码行数:48,
示例17: auth_handle_component_openvoid auth_handle_component_open(xmpp_conn_t * const conn){ int rc; /* reset all timed handlers */ handler_reset_timed(conn, 0); handler_add(conn, _handle_error, XMPP_NS_STREAMS, "error", NULL, NULL); handler_add(conn, _handle_component_hs_response, NULL, "handshake", NULL, NULL); handler_add_timed(conn, _handle_missing_handshake, HANDSHAKE_TIMEOUT, NULL); rc = _handle_component_auth(conn); if (rc != 0) { xmpp_error(conn->ctx, "auth", "Component authentication failed."); xmpp_disconnect(conn); }}
开发者ID:boothj5,项目名称:libmesode,代码行数:18,
示例18: _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_free函数代码示例 C++ xmpp_display_elems函数代码示例
|