您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ xmpp_free函数代码示例

51自学网 2021-06-03 11:49:37
  C++
这篇教程C++ xmpp_free函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中xmpp_free函数的典型用法代码示例。如果您正苦于以下问题:C++ xmpp_free函数的具体用法?C++ xmpp_free怎么用?C++ xmpp_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了xmpp_free函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: xmpp_stanza_release

/** Release a stanza object and all of its children. *  This function releases a stanza object and potentially all of its *  children, which may cause the object(s) to be freed. * *  @param stanza a Strophe stanza object * *  @return TRUE if the object was freed and FALSE otherwise * *  @ingroup Stanza */int xmpp_stanza_release(xmpp_stanza_t * const stanza){    int released = 0;    xmpp_stanza_t *child, *tchild;    /* release stanza */    if (stanza->ref > 1)        stanza->ref--;    else {        /* release all children */        child = stanza->children;        while (child) {            tchild = child;            child = child->next;            xmpp_stanza_release(tchild);        }        if (stanza->attributes) hash_release(stanza->attributes);        if (stanza->data) xmpp_free(stanza->ctx, stanza->data);        xmpp_free(stanza->ctx, stanza);        released = 1;    }    return released;}
开发者ID:apophys,项目名称:libstrophe,代码行数:35,


示例2: xmpp_handler_delete

/** Delete a stanza handler. * *  @param conn a Strophe connection object *  @param handler a function pointer to a stanza handler * *  @ingroup Handlers */void xmpp_handler_delete(xmpp_conn_t * const conn,			 xmpp_handler handler){    xmpp_handlist_t *prev, *item;    if (!conn->handlers) return;    prev = NULL;    item = conn->handlers;    while (item) {	if (item->handler == (void *)handler)	    break;		prev = item;	item = item->next;    }    if (item) {	if (prev)	    prev->next = item->next;	else	    conn->handlers = item->next;	if (item->ns) xmpp_free(conn->ctx, item->ns);	if (item->name) xmpp_free(conn->ctx, item->name);	if (item->type) xmpp_free(conn->ctx, item->type);	xmpp_free(conn->ctx, item);    }}
开发者ID:1Project,项目名称:SafeBoardMessenger,代码行数:36,


示例3: hash_drop

/** delete a key from a hash table */int hash_drop(hash_t *table, const char *key){   xmpp_ctx_t *ctx = table->ctx;   hashentry_t *entry, *prev;   int table_index = _hash_key(table, key);   /* look up the hash entry */   entry = table->entries[table_index];   prev = NULL;   while (entry != NULL) {	/* traverse the linked list looking for the key */	if (!strcmp(key, entry->key)) {	  /* match, remove the entry */	  xmpp_free(ctx, entry->key);	  if (table->free) table->free(ctx, entry->value);	  if (prev == NULL) {	    table->entries[table_index] = entry->next;	  } else {	    prev->next = entry->next;	  }	  xmpp_free(ctx, entry);	  table->num_keys--;	  return 0;	}	prev = entry;	entry = entry->next;   }   /* no match */   return -1;}
开发者ID:pasis,项目名称:libmesode,代码行数:31,


示例4: xmpp_id_handler_delete

/** Delete an id based stanza handler. * *  @param conn a Strophe connection object *  @param handler a function pointer to a stanza handler *  @param id a string containing the id the handler is for * *  @ingroup Handlers */void xmpp_id_handler_delete(xmpp_conn_t * const conn,			    xmpp_handler handler,			    const char * const id){    xmpp_handlist_t *item, *prev;    prev = NULL;    item = (xmpp_handlist_t *)hash_get(conn->id_handlers, id);    if (!item) return;    while (item) {	if (item->handler == (void *)handler)	    break;	prev = item;	item = item->next;    }    if (item) {	if (prev)	    prev->next = item->next;	else {	    hash_drop(conn->id_handlers, id);	    hash_add(conn->id_handlers, id, item->next);	}	xmpp_free(conn->ctx, item->id);	xmpp_free(conn->ctx, item);    }}
开发者ID:1Project,项目名称:SafeBoardMessenger,代码行数:37,


示例5: zkmuc_group_msg_handler

static int zkmuc_group_msg_handler(xmpp_ua_t *ua, xmpp_stanza_t *stanza, void *userdata){	char *type = xmpp_stanza_get_type(stanza);	if (type && !strcmp(type, "groupchat"))	{		zkmuc_ctx_t *ctx = (zkmuc_ctx_t *)userdata;	//	char *from = xmpp_stanza_get_attribute(stanza, "from");		xmpp_stanza_t *stanza_body = xmpp_stanza_get_child_by_name(stanza, "zonekey");		if (!stanza_body)		{			return 0;		}		xmpp_stanza_t *stanza_jid = xmpp_stanza_get_child_by_name(stanza_body, "jid");		char *jid_value = xmpp_stanza_get_text(stanza_jid);		char *text = xmpp_stanza_get_text(stanza_body);		if (text && ctx->room_cbs.on_broadcast_message)		{			ctx->room_cbs.on_broadcast_message(ctx, /*from*/jid_value, text, ctx->room_data);		}		xmpp_free(_xmpp_ctx, jid_value);		xmpp_free(_xmpp_ctx, text);		return 1;	}		return 0;}
开发者ID:FihlaTV,项目名称:conference,代码行数:26,


示例6: 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,


示例7: _start_element

static 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,


示例8: _handle_carbons

static gboolean_handle_carbons(xmpp_stanza_t *const stanza){    xmpp_stanza_t *carbons = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CARBONS);    if (!carbons) {        return FALSE;    }    char *name = xmpp_stanza_get_name(carbons);    if ((g_strcmp0(name, "received") == 0) || (g_strcmp0(name, "sent")) == 0) {        xmpp_stanza_t *forwarded = xmpp_stanza_get_child_by_ns(carbons, STANZA_NS_FORWARD);        xmpp_stanza_t *message = xmpp_stanza_get_child_by_name(forwarded, STANZA_NAME_MESSAGE);        xmpp_ctx_t *ctx = connection_get_ctx();        gchar *to = xmpp_stanza_get_attribute(message, STANZA_ATTR_TO);        gchar *from = xmpp_stanza_get_attribute(message, STANZA_ATTR_FROM);        // happens when receive a carbon of a self sent message        if (!to) to = from;        Jid *jid_from = jid_create(from);        Jid *jid_to = jid_create(to);        Jid *my_jid = jid_create(jabber_get_fulljid());        // check for and deal with message        xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(message, STANZA_NAME_BODY);        if (body) {            char *message_txt = xmpp_stanza_get_text(body);            if (message_txt) {                // check for pgp encrypted message                char *enc_message = NULL;                xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(message, STANZA_NS_ENCRYPTED);                if (x) {                    enc_message = xmpp_stanza_get_text(x);                }                // if we are the recipient, treat as standard incoming message                if(g_strcmp0(my_jid->barejid, jid_to->barejid) == 0){                    sv_ev_incoming_carbon(jid_from->barejid, jid_from->resourcepart, message_txt, enc_message);                // else treat as a sent message                } else {                    sv_ev_outgoing_carbon(jid_to->barejid, message_txt, enc_message);                }                xmpp_free(ctx, message_txt);                xmpp_free(ctx, enc_message);            }        }        jid_destroy(jid_from);        jid_destroy(jid_to);        jid_destroy(my_jid);        return TRUE;    }    return FALSE;}
开发者ID:0xPoly,项目名称:profanity,代码行数:59,


示例9: xmpp_user_release

void xmpp_user_release(xmpp_user_t * const user){	xmpp_ctx_t *ctx = user->conn->ctx;	if (user->name) xmpp_free(ctx, user->name);	if (user->jid) xmpp_free(ctx, user->jid);	xmpp_free(ctx, user);}
开发者ID:hnakagawa,项目名称:libantis,代码行数:8,


示例10: XMPP_IBB_Data_Process

int XMPP_IBB_Data_Process(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata){    char* intext;    unsigned char *result;    xmpp_ctx_t *ctx = (xmpp_ctx_t*)userdata;    char *szSid, szSeq;	//    xmpp_ibb_session_t* ibb_ssn;        szSid = /	xmpp_stanza_get_attribute(xmpp_stanza_get_child_by_name(stanza, "data"), "sid");     szSeq = / 	xmpp_stanza_get_attribute(xmpp_stanza_get_child_by_name(stanza, "data"), "seq");     intext = xmpp_stanza_get_text(xmpp_stanza_get_child_by_name(stanza, "data"));    printf("[Sid=%s][Seq=%s][Raw Data=%s]/n", szSid, szSeq, intext);    result = base64_decode(ctx, intext, strlen(intext));    printf("Decode result=%s/n", result);    gRecv = malloc(strlen(result)+1);    strcpy(gRecv, result);        if(gStanza == NULL)        gStanza = xmpp_stanza_copy(stanza);#if 0  //data queue function has not been verified.  	                ibb_ssn = XMPP_Get_IBB_Session_Handle(szSid);    if( ibb_ssn == NULL)		    {        printf("Opened Session ID not found/n"); 	goto error;    }    xmpp_ibb_data_t* ibb_data_new = malloc(sizeof(xmpp_ibb_data_t));    ibb_data_new->seq_num = malloc(strlen(szSeq)+1);    ibb_data_new->recv_data =  malloc(strlen(result)+1);        strcpy(ibb_data_new->seq_num, szSeq);       strcpy(ibb_data_new->recv_data, result);       XMPP_IBB_Add_Session_Data_Queue(ibb_ssn, ibb_data_new);#endiferror:    xmpp_free(ctx, szSid);    xmpp_free(ctx, szSeq);    xmpp_free(ctx, intext);    xmpp_free(ctx, result);    return 1;}
开发者ID:RyanHong-2015,项目名称:libstrophe-xep,代码行数:56,


示例11: _handle_digestmd5_challenge

/* handle the challenge phase of digest auth */static int _handle_digestmd5_challenge(xmpp_conn_t * const conn,			      xmpp_stanza_t * const stanza,			      void * const userdata){    char *text;    char *response;    xmpp_stanza_t *auth, *authdata;    char *name;    name = xmpp_stanza_get_name(stanza);    xmpp_debug(conn->ctx, "xmpp",/	"handle digest-md5 (challenge) called for %s", name);    if (strcmp(name, "challenge") == 0) {	text = xmpp_stanza_get_text(stanza);	response = sasl_digest_md5(conn->ctx, text, conn->jid, conn->pass);	if (!response) {	    disconnect_mem_error(conn);	    return 0;	}	xmpp_free(conn->ctx, text);	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);	authdata = xmpp_stanza_new(conn->ctx);	if (!authdata) {	    disconnect_mem_error(conn);	    return 0;	}	xmpp_stanza_set_text(authdata, response);	xmpp_free(conn->ctx, response);	xmpp_stanza_add_child(auth, authdata);	xmpp_stanza_release(authdata);	handler_add(conn, _handle_digestmd5_rspauth,		    XMPP_NS_SASL, NULL, NULL, NULL);	xmpp_send(conn, auth);	xmpp_stanza_release(auth);    } else {	return _handle_sasl_result(conn, stanza, "DIGEST-MD5");    }    /* remove ourselves */    return 0;}
开发者ID:mcanthony,项目名称:libstrophe,代码行数:56,


示例12: _conn_attributes_destroy

static void _conn_attributes_destroy(xmpp_conn_t *conn, char **attributes,                                     size_t attributes_len){    size_t i;    if (attributes) {        for (i = 0; i < attributes_len; ++i)            xmpp_free(conn->ctx, attributes[i]);        xmpp_free(conn->ctx, attributes);    }}
开发者ID:apophys,项目名称:libstrophe,代码行数:11,


示例13: _muc_user_handler

static int_muc_user_handler(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, void *const userdata){    xmpp_ctx_t *ctx = connection_get_ctx();    xmpp_stanza_t *xns_muc_user = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_MUC_USER);    char *room = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);    if (!room) {        log_warning("Message received with no from attribute, ignoring");        return 1;    }    // XEP-0045    xmpp_stanza_t *invite = xmpp_stanza_get_child_by_name(xns_muc_user, STANZA_NAME_INVITE);    if (!invite) {        return 1;    }    char *invitor_jid = xmpp_stanza_get_attribute(invite, STANZA_ATTR_FROM);    if (!invitor_jid) {        log_warning("Chat room invite received with no from attribute");        return 1;    }    Jid *jidp = jid_create(invitor_jid);    if (!jidp) {        return 1;    }    char *invitor = jidp->barejid;    char *reason = NULL;    xmpp_stanza_t *reason_st = xmpp_stanza_get_child_by_name(invite, STANZA_NAME_REASON);    if (reason_st) {        reason = xmpp_stanza_get_text(reason_st);    }    char *password = NULL;    xmpp_stanza_t *password_st = xmpp_stanza_get_child_by_name(xns_muc_user, STANZA_NAME_PASSWORD);    if (password_st) {        password = xmpp_stanza_get_text(password_st);    }    sv_ev_room_invite(INVITE_MEDIATED, invitor, room, reason, password);    jid_destroy(jidp);    if (reason) {        xmpp_free(ctx, reason);    }    if (password) {        xmpp_free(ctx, password);    }    return 1;}
开发者ID:KThand1,项目名称:profanity,代码行数:53,


示例14: main

int main(int argc, char **argv){    xmpp_ctx_t *ctx;    xmpp_mem_t mymem;    xmpp_log_t mylog;    char my_str[5] = "asdf";    void *testptr1, *testptr2;    ctx = xmpp_ctx_new(NULL, NULL);    if (ctx == NULL) return 1;    /* destroy context */    xmpp_ctx_free(ctx);    /* setup our memory handler */    mymem.alloc = my_alloc;    mymem.free = my_free;    mymem.realloc = my_realloc;    /* setup our logger */    mylog.handler = my_logger;    mylog.userdata = my_str;    ctx = xmpp_ctx_new(&mymem, &mylog);    xmpp_debug(ctx, "test", "hello");    testptr1 = xmpp_alloc(ctx, 1024);    if (testptr1 == NULL) {	xmpp_ctx_free(ctx);	return 1;    }    testptr2 = xmpp_realloc(ctx, testptr1, 2048);    if (testptr2 == NULL) {	xmpp_free(ctx, testptr1);	xmpp_ctx_free(ctx);	return 1;    }    xmpp_free(ctx, testptr2);    xmpp_ctx_free(ctx);    /* check for test failure */    if (!(log_called && mem_alloc_called && mem_realloc_called && 	  mem_free_called))	return 1;    if (mem_alloc_called != mem_free_called)        return 1;        return 0;}
开发者ID:boothj5,项目名称:libmesode,代码行数:52,


示例15: _free_cbattrs

static void _free_cbattrs(parser_t *parser, char **attrs){    int i;    if (!attrs)        return;    for (i = 0; attrs[i]; i += 2) {        if (attrs[i]) xmpp_free(parser->ctx, attrs[i]);        if (attrs[i+1]) xmpp_free(parser->ctx, attrs[i+1]);    }    xmpp_free(parser->ctx, attrs);}
开发者ID:1Project,项目名称:SafeBoardMessenger,代码行数:14,


示例16: main

int main(int argc, char *argv[]){    xmpp_ctx_t *ctx;    unsigned char *udec;    char *dec;    char *enc;    size_t len;    int i;    printf("BASE64 tests./n");    ctx = xmpp_ctx_new(NULL, NULL);    if (ctx == NULL) {        fprintf(stderr, "failed to create context/n");        return 1;    }    for (i = 0; i < ARRAY_SIZE(tests); ++i) {        printf("Test #%d: ", (int)i + 1);        enc = xmpp_base64_encode(ctx, (unsigned char *)tests[i].raw,                                 strlen(tests[i].raw));        assert(enc != NULL);        COMPARE(tests[i].base64, enc);        xmpp_free(ctx, enc);        dec = xmpp_base64_decode_str(ctx, tests[i].base64,                                     strlen(tests[i].base64));        assert(dec != NULL);        COMPARE_BUF(tests[i].raw, strlen(tests[i].raw), dec, strlen(dec));        xmpp_free(ctx, dec);        printf("ok/n");    }    printf("Test with binary data: ");    enc = xmpp_base64_encode(ctx, bin_data, sizeof(bin_data));    assert(enc != NULL);    xmpp_base64_decode_bin(ctx, enc, strlen(enc), &udec, &len);    assert(udec != NULL);    assert(len != 0);    assert(len == sizeof(bin_data));    COMPARE_BUF(bin_data, sizeof(bin_data), udec, len);    xmpp_free(ctx, udec);    xmpp_free(ctx, enc);    printf("ok/n");    xmpp_ctx_free(ctx);    return 0;}
开发者ID:Aversiste,项目名称:libstrophe,代码行数:49,


示例17: xmpp_send_raw

/** Send raw bytes to the XMPP server. *  This function is a convenience function to send raw bytes to the  *  XMPP server.  It is usedly primarly by xmpp_send_raw_string.  This  *  function should be used with care as it does not validate the bytes and *  invalid data may result in stream termination by the XMPP server. * *  @param conn a Strophe connection object *  @param data a buffer of raw bytes *  @param len the length of the data in the buffer */void xmpp_send_raw(xmpp_conn_t * const conn,		   const char * const data, const size_t len){    xmpp_send_queue_t *item;    if (conn->state != XMPP_STATE_CONNECTED) return;    /* create send queue item for queue */    item = xmpp_alloc(conn->ctx, sizeof(xmpp_send_queue_t));    if (!item) return;    item->data = xmpp_alloc(conn->ctx, len);    if (!item->data) {	xmpp_free(conn->ctx, item);	return;    }    memcpy(item->data, data, len);    item->len = len;    item->next = NULL;    item->written = 0;    /* add item to the send queue */    if (!conn->send_queue_tail) {	/* first item, set head and tail */	conn->send_queue_head = item;	conn->send_queue_tail = item;    } else {	/* add to the tail */	conn->send_queue_tail->next = item;	conn->send_queue_tail = item;    }    conn->send_queue_len++;}
开发者ID:CAOJINGYOU,项目名称:libstrophe,代码行数:43,


示例18: hash_add

/** add a key, value pair to a hash table. *  each key can appear only once; the value of any *  identical key will be replaced */int hash_add(hash_t *table, const char * const key, void *data){   xmpp_ctx_t *ctx = table->ctx;   hashentry_t *entry = NULL;   int table_index = _hash_key(table, key);   /* drop existing entry, if any */   hash_drop(table, key);   /* allocate and fill a new entry */   entry = xmpp_alloc(ctx, sizeof(hashentry_t));   if (!entry) return -1;   entry->key = xmpp_strdup(ctx, key);   if (!entry->key) {       xmpp_free(ctx, entry);       return -1;   }   entry->value = data;   /* insert ourselves in the linked list */   /* TODO: this leaks duplicate keys */   entry->next = table->entries[table_index];   table->entries[table_index] = entry;   table->num_keys++;   return 0;}
开发者ID:pasis,项目名称:libmesode,代码行数:30,


示例19: connection_free_uuid

voidconnection_free_uuid(char *uuid){    if (uuid) {        xmpp_free(conn.xmpp_ctx, uuid);    }}
开发者ID:klement,项目名称:profanity,代码行数:7,


示例20: xmpp_stanza_set_attribute

/** Set an attribute for a stanza object. *   *  @param stanza a Strophe stanza object *  @param key a string with the attribute name *  @param value a string with the attribute value * *  @return XMPP_EOK (0) on success or a number less than 0 on failure * *  @ingroup Stanza */int xmpp_stanza_set_attribute(xmpp_stanza_t * const stanza,                              const char * const key,                              const char * const value){    char *val;    int rc;    if (stanza->type != XMPP_STANZA_TAG) return XMPP_EINVOP;    if (!stanza->attributes) {        stanza->attributes = hash_new(stanza->ctx, 8, xmpp_free);        if (!stanza->attributes) return XMPP_EMEM;    }    val = xmpp_strdup(stanza->ctx, value);    if (!val) {        hash_release(stanza->attributes);        return XMPP_EMEM;    }    rc = hash_add(stanza->attributes, key, val);    if (rc < 0) {        xmpp_free(stanza->ctx, val);        return XMPP_EMEM;    }    return XMPP_EOK;}
开发者ID:apophys,项目名称:libstrophe,代码行数:38,


示例21: _log_open_tag

static void _log_open_tag(xmpp_conn_t *conn, char **attrs){    char buf[4096];    size_t pos;    int len;    int i;    char *attr;    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) {        attr = parser_attr_name(conn->ctx, attrs[i]);        len = xmpp_snprintf(&buf[pos], 4096 - pos, " %s='%s'",                            attr, attrs[i+1]);        xmpp_free(conn->ctx, attr);        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:1Project,项目名称:SafeBoardMessenger,代码行数:29,


示例22: xmpp_rand_new

/** Create and initialize a Strophe context object. *  If mem is NULL, a default allocation setup will be used which *  wraps malloc(), free(), and realloc() from the standard library. *  If log is NULL, a default logger will be used which does no *  logging.  Basic filtered logging to stderr can be done with the *  xmpp_get_default_logger() convenience function. * *  @param mem a pointer to an xmpp_mem_t structure or NULL *  @param log a pointer to an xmpp_log_t structure or NULL * *  @return the allocated Strophe context object or NULL on an error * *  @ingroup Context */xmpp_ctx_t *xmpp_ctx_new(const xmpp_mem_t * const mem, 			 const xmpp_log_t * const log){    xmpp_ctx_t *ctx = NULL;    if (mem == NULL)	ctx = xmpp_default_mem.alloc(sizeof(xmpp_ctx_t), NULL);    else	ctx = mem->alloc(sizeof(xmpp_ctx_t), mem->userdata);    if (ctx != NULL) {	if (mem != NULL) 	    ctx->mem = mem;	else 	    ctx->mem = &xmpp_default_mem;	if (log == NULL)	    ctx->log = &xmpp_default_log;	else	    ctx->log = log;	ctx->connlist = NULL;	ctx->loop_status = XMPP_LOOP_NOTSTARTED;	ctx->rand = xmpp_rand_new(ctx);	if (ctx->rand == NULL) {	    xmpp_free(ctx, ctx);	    ctx = NULL;	}    }    return ctx;}
开发者ID:1Project,项目名称:SafeBoardMessenger,代码行数:46,


示例23: test_jid_new

int test_jid_new(xmpp_ctx_t *ctx){    char *jid;    jid = xmpp_jid_new(ctx, "node", "domain", "resource");    printf("new jid: '%s'/n", jid);    if (strcmp(jid, "[email
C++ xmpp_send函数代码示例
C++ xmpp_error函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。