• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ silc_calloc函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: silc_idlist_get_channels

SilcChannelEntry *
silc_idlist_get_channels(SilcIDList id_list, SilcChannelID *channel_id,
			 SilcUInt32 *channels_count)
{
  SilcList list;
  SilcIDCacheEntry id_cache = NULL;
  SilcChannelEntry *channels = NULL;
  int i = 0;

  SILC_LOG_DEBUG(("Start"));

  if (!channel_id) {
    if (!silc_idcache_get_all(id_list->channels, &list))
      return NULL;

    channels = silc_calloc(silc_list_count(list), sizeof(*channels));

    i = 0;
    silc_list_start(list);
    while ((id_cache = silc_list_get(list)))
      channels[i++] = (SilcChannelEntry)id_cache->context;
  } else {
    if (!silc_idcache_find_by_id_one(id_list->channels, channel_id, &id_cache))
      return NULL;

    i = 1;
    channels = silc_calloc(1, sizeof(*channels));
    channels[0] = (SilcChannelEntry)id_cache->context;
  }

  if (channels_count)
    *channels_count = i;

  return channels;
}
开发者ID:FabrizioFabbe,项目名称:silc,代码行数:35,代码来源:idlist.c


示例2: silc_client_alloc

SilcClient silc_client_alloc(SilcClientOperations *ops,
			     SilcClientParams *params,
			     void *application,
			     const char *version_string)
{
  SilcClient new_client;

  new_client = silc_calloc(1, sizeof(*new_client));
  if (!new_client)
    return NULL;
  new_client->application = application;

  new_client->internal = silc_calloc(1, sizeof(*new_client->internal));
  if (!new_client->internal) {
    silc_free(new_client);
    return NULL;
  }
  new_client->internal->ops = ops;
  new_client->internal->params =
    silc_calloc(1, sizeof(*new_client->internal->params));
  if (!version_string)
    version_string = silc_version_string;
  new_client->internal->silc_client_version = strdup(version_string);

  if (params)
    memcpy(new_client->internal->params, params, sizeof(*params));

  new_client->internal->params->
    nickname_format[sizeof(new_client->internal->
			   params->nickname_format) - 1] = 0;

  silc_atomic_init32(&new_client->internal->conns, 0);

  return new_client;
}
开发者ID:TabTwo,项目名称:silc-client,代码行数:35,代码来源:client.c


示例3: silc_command_payload_encode_vap

SilcBuffer silc_command_payload_encode_vap(SilcCommand cmd,
					   SilcUInt16 ident,
					   SilcUInt32 argc, va_list ap)
{
  unsigned char **argv = NULL;
  SilcUInt32 *argv_lens = NULL, *argv_types = NULL;
  unsigned char *x;
  SilcUInt32 x_len;
  SilcUInt32 x_type;
  SilcBuffer buffer = NULL;
  int i, k = 0;

  if (argc) {
    argv = silc_calloc(argc, sizeof(unsigned char *));
    if (!argv)
      return NULL;
    argv_lens = silc_calloc(argc, sizeof(SilcUInt32));
    if (!argv_lens)
      return NULL;
    argv_types = silc_calloc(argc, sizeof(SilcUInt32));
    if (!argv_types)
      return NULL;

    for (i = 0, k = 0; i < argc; i++) {
      x_type = va_arg(ap, SilcUInt32);
      x = va_arg(ap, unsigned char *);
      x_len = va_arg(ap, SilcUInt32);

      if (!x_type || !x || !x_len)
	continue;

      argv[k] = silc_memdup(x, x_len);
      if (!argv[k])
	goto out;
      argv_lens[k] = x_len;
      argv_types[k] = x_type;
      k++;
    }
  }

  buffer = silc_command_payload_encode(cmd, k, argv, argv_lens,
				       argv_types, ident);

 out:
  for (i = 0; i < k; i++)
    silc_free(argv[i]);
  silc_free(argv);
  silc_free(argv_lens);
  silc_free(argv_types);

  return buffer;
}
开发者ID:FabrizioFabbe,项目名称:silc,代码行数:52,代码来源:silccommand.c


示例4: silc_thread_create

SilcThread silc_thread_create(SilcThreadStart start_func, void *context,
			      SilcBool waitable)
{
#ifdef SILC_THREADS
  int ret;
  SilcOs2Thread thread = silc_calloc(1, sizeof(*thread));
  if (!thread)
    return NULL;

  thread->start_func = start_func;
  thread->context = context;
  thread->waitable = waitable;

  /* Create the thread, and run it */
  thread->thread = _beginthread(silc_thread_os2_start, NULL, 65536, thread);
  if (thread->thread < 0) {
    SILC_LOG_ERROR(("Could not create new thread"));
    silc_free(thread);
    return NULL;
  }

  return (SilcThread)thread->thread;
#else
  /* Call thread callback immediately */
  (*start_func)(context);
  return NULL;
#endif
}
开发者ID:FabrizioFabbe,项目名称:runtime,代码行数:28,代码来源:silcos2thread.c


示例5: purple_whiteboard_get_session

PurpleWhiteboard *silcpurple_wb_init(SilcPurple sg, SilcClientEntry client_entry)
{
        SilcClientConnection conn;
	PurpleWhiteboard *wb;
	SilcPurpleWb wbs;

	conn = sg->conn;
	wb = purple_whiteboard_get_session(sg->account, client_entry->nickname);
	if (!wb)
		wb = purple_whiteboard_create(sg->account, client_entry->nickname, 0);
	if (!wb)
		return NULL;

	if (!wb->proto_data) {
		wbs = silc_calloc(1, sizeof(*wbs));
		if (!wbs)
			return NULL;
		wbs->type = 0;
		wbs->u.client = client_entry;
		wbs->width = SILCPURPLE_WB_WIDTH;
		wbs->height = SILCPURPLE_WB_HEIGHT;
		wbs->brush_size = SILCPURPLE_WB_BRUSH_SMALL;
		wbs->brush_color = SILCPURPLE_WB_COLOR_BLACK;
		wb->proto_data = wbs;

		/* Start the whiteboard */
		purple_whiteboard_start(wb);
		purple_whiteboard_clear(wb);
	}

	return wb;
}
开发者ID:bf4,项目名称:pidgin-mac,代码行数:32,代码来源:wb.c


示例6: silc_server_command_alloc

SilcServerCommand silc_server_command_alloc(SilcServerThread thread)
{
  SilcServerCommand cmd;

  silc_mutex_lock(thread->server->lock);

  /* Get command context from freelist or allocate new one. */
  cmd = silc_list_get(thread->server->command_pool);
  if (!cmd) {
    silc_mutex_unlock(thread->server->lock);

    cmd = silc_calloc(1, sizeof(*cmd));
    if (!cmd)
      return NULL;

    SILC_LOG_DEBUG(("Allocating command context %p", cmd));

    cmd->thread = thread;

    return cmd;
  }

  SILC_LOG_DEBUG(("Get command context %p", cmd));

  /* Delete from freelist */
  silc_list_del(thread->server->command_pool, cmd);

  cmd->thread = thread;

  silc_mutex_unlock(thread->server->lock);

  return cmd;
}
开发者ID:FabrizioFabbe,项目名称:silc,代码行数:33,代码来源:server_st_command.c


示例7: silc_client_add_to_channel

SilcBool silc_client_add_to_channel(SilcClient client,
				    SilcClientConnection conn,
				    SilcChannelEntry channel,
				    SilcClientEntry client_entry,
				    SilcUInt32 cumode)
{
  SilcChannelUser chu;

  if (silc_client_on_channel(channel, client_entry))
    return TRUE;

  SILC_LOG_DEBUG(("Add client %s to channel", client_entry->nickname));

  chu = silc_calloc(1, sizeof(*chu));
  if (!chu)
    return FALSE;

  chu->client = client_entry;
  chu->channel = channel;
  chu->mode = cumode;

  silc_client_ref_client(client, conn, client_entry);
  silc_client_ref_channel(client, conn, channel);

  silc_hash_table_add(channel->user_list, client_entry, chu);
  silc_hash_table_add(client_entry->channels, channel, chu);

  return TRUE;
}
开发者ID:TabTwo,项目名称:silc-client,代码行数:29,代码来源:client_channel.c


示例8: silc_thread_create

SilcThread silc_thread_create(SilcThreadStart start_func, void *context,
			      SilcBool waitable)
{
#ifdef SILC_THREADS
  SilcWin32Thread thread;
  unsigned id;

  SILC_LOG_DEBUG(("Creating new thread"));

  thread = silc_calloc(1, sizeof(*thread));
  thread->start_func = start_func;
  thread->context = context;
  thread->waitable = waitable;
  thread->thread =
    _beginthreadex(NULL, 0, (LPTHREAD_START_ROUTINE)silc_thread_win32_start,
		   (void *)thread, 0, &id);

  if (!thread->thread) {
    SILC_LOG_ERROR(("Could not create new thread"));
    silc_free(thread);
    return NULL;
  }

  return (SilcThread)thread;
#else
  /* Call thread callback immediately */
  (*start_func)(context);
  return NULL;
#endif
}
开发者ID:TabTwo,项目名称:silc-client,代码行数:30,代码来源:silcwin32thread.c


示例9: event_joined

static void event_joined(struct event *event)
{
	struct channel *channel = event_get_control(event, channel);
	struct channel_connection *chconn = channel_get_connection(channel);
	struct i_silc_channel_connection *silc_chconn;
	struct i_silc_gateway_connection *silc_gwconn;
	SilcJoinResolve *r;

	i_assert(chconn != NULL);

	if( !IS_SILC_CHCONN(chconn) )
		return;
	
	silc_chconn = (struct i_silc_channel_connection *)chconn;
	silc_gwconn = (struct i_silc_gateway_connection *)chconn->gwconn;

	r = silc_calloc(1, sizeof(*r));
	r->channel = silc_chconn->channel_entry;
	r->retry = 0;

	if( event_isset(event, "init") ) {
		silc_client_get_clients_by_channel(silc_gwconn->client,
				silc_gwconn->conn, silc_chconn->channel_entry,
				refresh_nicklist_resolved, r);
	}
}
开发者ID:irssi-import,项目名称:icecap_silc,代码行数:26,代码来源:silc-channel-connection.c


示例10: silc_hash_table_replace_internal

static inline SilcBool
silc_hash_table_replace_internal(SilcHashTable ht, void *key, void *context,
				 SilcHashFunction hash,
				 void *hash_user_context)
{
  SilcHashTableEntry *entry;
  SilcUInt32 i = SILC_HASH_TABLE_HASH(hash, hash_user_context);

  SILC_HT_DEBUG(("index %d key %p", i, key));

  entry = &ht->table[i];
  if (*entry) {
    /* The entry exists already. We have a collision, replace the old
       key and context. */
    if (ht->destructor)
      ht->destructor((*entry)->key, (*entry)->context,
		     ht->destructor_user_context);
  } else {
    /* New key */
    *entry = silc_calloc(1, sizeof(**entry));
    if (!(*entry))
      return FALSE;
    ht->entry_count++;
  }

  (*entry)->key = key;
  (*entry)->context = context;

  if (SILC_HASH_REHASH_INC)
    silc_hash_table_rehash(ht, 0);

  return TRUE;
}
开发者ID:TabTwo,项目名称:silc-client,代码行数:33,代码来源:silchashtable.c


示例11: silc_attribute_payload_alloc

SilcAttributePayload silc_attribute_payload_alloc(SilcAttribute attribute,
						  SilcAttributeFlags flags,
						  void *object,
						  SilcUInt32 object_size)
{
  SilcAttributePayload attr;
  SilcUInt32 tmp_len;

  attr = silc_calloc(1, sizeof(*attr));
  if (!attr)
    return NULL;

  attr->attribute = attribute;
  attr->flags = flags;
  attr->data =
    silc_attribute_payload_encode_int(attribute, flags, object,
				      object_size, &tmp_len);
  attr->data_len = (SilcUInt16)tmp_len;
  if (!attr->data) {
    silc_free(attr);
    return NULL;
  }

  return attr;
}
开发者ID:TabTwo,项目名称:silc-client,代码行数:25,代码来源:silcattrs.c


示例12: silc_connauth_alloc

SilcConnAuth silc_connauth_alloc(SilcSchedule schedule,
				 SilcSKE ske,
				 SilcUInt32 timeout_secs)
{
  SilcConnAuth connauth;

  if (!schedule || !ske)
    return NULL;

  connauth = silc_calloc(1, sizeof(*connauth));
  if (!connauth)
    return NULL;

  connauth->fsm = silc_fsm_alloc(connauth, silc_connauth_fsm_destructor,
				 NULL, schedule);
  if (!connauth->fsm) {
    silc_connauth_free(connauth);
    return NULL;
  }

  connauth->timeout_secs = timeout_secs;
  connauth->ske = ske;
  ske->refcnt++;

  return connauth;
}
开发者ID:TabTwo,项目名称:silc-toolkit,代码行数:26,代码来源:silcconnauth.c


示例13: silc_idlist_add_server

SilcServerEntry
silc_idlist_add_server(SilcIDList id_list,
		       char *server_name, int server_type,
		       SilcServerID *id, SilcServerEntry router,
		       void *connection)
{
  SilcServerEntry server;
  char *server_namec = NULL;

  SILC_LOG_DEBUG(("Adding new server entry"));

  /* Normalize name.  This is cached, original is in server context.  */
  if (server_name) {
    server_namec = silc_identifier_check(server_name, strlen(server_name),
					 SILC_STRING_UTF8, 256, NULL);
    if (!server_namec)
      return NULL;
  }

  server = silc_calloc(1, sizeof(*server));
  server->server_name = server_name;
  server->server_type = server_type;
  server->id = id;
  server->router = router;
  server->connection = connection;

  if (!silc_idcache_add(id_list->servers, server_namec,
			(void *)server->id, (void *)server)) {
    silc_free(server);
    silc_free(server_namec);
    return NULL;
  }

  return server;
}
开发者ID:FabrizioFabbe,项目名称:silc,代码行数:35,代码来源:idlist.c


示例14: silc_sftp_server_start

SilcSFTP silc_sftp_server_start(SilcStream stream,
				SilcSchedule schedule,
				SilcSFTPErrorCallback error_cb,
				void *context,
				SilcSFTPFilesystem fs)
{
  SilcSFTPServer server;

  if (!schedule)
    schedule = silc_schedule_get_global();

  server = silc_calloc(1, sizeof(*server));
  if (!server)
    return NULL;
  server->stream = stream;
  server->schedule = schedule;
  server->error = error_cb;
  server->context = context;
  server->fs = fs;

  /* We handle the stream now */
  silc_stream_set_notifier(stream, schedule, silc_sftp_server_io, server);

  SILC_LOG_DEBUG(("Starting SFTP server %p", server));

  return (SilcSFTP)server;
}
开发者ID:FabrizioFabbe,项目名称:silc,代码行数:27,代码来源:sftp_server.c


示例15: silcpurple_buddy_keyagr_request

void silcpurple_buddy_keyagr_request(SilcClient client,
				   SilcClientConnection conn,
				   SilcClientEntry client_entry,
				   const char *hostname, SilcUInt16 port)
{
	char tmp[128], tmp2[128];
	SilcPurpleKeyAgrAsk a;
	PurpleConnection *gc = client->application;

	g_snprintf(tmp, sizeof(tmp),
		   _("Key agreement request received from %s. Would you like to "
		     "perform the key agreement?"), client_entry->nickname);
	if (hostname)
		g_snprintf(tmp2, sizeof(tmp2),
			   _("The remote user is waiting key agreement on:\n"
			     "Remote host: %s\nRemote port: %d"), hostname, port);

	a = silc_calloc(1, sizeof(*a));
	if (!a)
		return;
	a->client = client;
	a->conn = conn;
	a->client_id = *client_entry->id;
	if (hostname)
		a->hostname = strdup(hostname);
	a->port = port;

	purple_request_action(client->application, _("Key Agreement Request"), tmp,
			    hostname ? tmp2 : NULL, 1, gc->account, client_entry->nickname,
				NULL, a, 2, _("Yes"), G_CALLBACK(silcpurple_buddy_keyagr_request_cb),
			    _("No"), G_CALLBACK(silcpurple_buddy_keyagr_request_cb));
}
开发者ID:dylex,项目名称:pidgin,代码行数:32,代码来源:buddy.c


示例16: main

int main(int argc, char **argv)
{
  Client client = silc_calloc(1, sizeof(*client));

  gclient = client;

  if (argc > 1) {
    if (!strcmp(argv[1], "-d"))
      silc_log_debug(TRUE);
    if (argc > 2 && !strcmp(argv[2], "-x"))
      silc_log_debug_hexdump(TRUE);
    silc_log_set_debug_string("*");
  }

  client->schedule = silc_schedule_init(0, NULL);
  if (!client->schedule)
    return -1;

  /* Connecto to server */
  silc_net_tcp_connect(NULL, "127.0.0.1", 5000, client->schedule,
		       connect_callback, client);

  silc_schedule(client->schedule);
  return 0;
}
开发者ID:TabTwo,项目名称:silc-toolkit,代码行数:25,代码来源:sftp_client.c


示例17: silc_hash_table_add_internal

static inline SilcBool
silc_hash_table_add_internal(SilcHashTable ht, void *key, void *context,
			     SilcHashFunction hash,
			     void *hash_user_context)
{
  SilcHashTableEntry *entry;
  SilcUInt32 i = SILC_HASH_TABLE_HASH(hash, hash_user_context);

  SILC_HT_DEBUG(("index %d key %p", i, key));

  entry = &ht->table[i];
  if (*entry) {
    /* The entry exists already. We have a collision, add it to the
       list to avoid collision. */
    SilcHashTableEntry e, tmp;

    e = *entry;
    tmp = e->next;
    while (tmp) {
      e = tmp;
      tmp = tmp->next;
    }

    SILC_HT_DEBUG(("Collision; adding new key to list"));

    e->next = silc_calloc(1, sizeof(*e->next));
    if (!e->next)
      return FALSE;
    e->next->key = key;
    e->next->context = context;
    ht->entry_count++;
  } else {
    /* New key */
    SILC_HT_DEBUG(("New key"));
    *entry = silc_calloc(1, sizeof(**entry));
    if (!(*entry))
      return FALSE;
    (*entry)->key = key;
    (*entry)->context = context;
    ht->entry_count++;
  }

  if (SILC_HASH_REHASH_INC)
    silc_hash_table_rehash(ht, 0);

  return TRUE;
}
开发者ID:TabTwo,项目名称:silc-client,代码行数:47,代码来源:silchashtable.c


示例18: silc_vcard_alloc

SilcVCard silc_vcard_alloc(void)
{
  SilcVCard vcard = silc_calloc(1, sizeof(*vcard));
  if (!vcard)
    return NULL;
  vcard->dynamic = TRUE;
  return vcard;
}
开发者ID:TabTwo,项目名称:silc-toolkit,代码行数:8,代码来源:silcvcard.c


示例19: silcpurple_wb_request

static void
silcpurple_wb_request(SilcClient client, const unsigned char *message,
		      SilcUInt32 message_len, SilcClientEntry sender,
		      SilcChannelEntry channel)
{
	char tmp[256];
	SilcPurpleWbRequest req;
	PurpleConnection *gc;
	SilcPurple sg;

	gc = client->application;
	sg = gc->proto_data;

	/* Open whiteboard automatically if requested */
	if (purple_account_get_bool(sg->account, "open-wb", FALSE)) {
		PurpleWhiteboard *wb;

		if (!channel)
			wb = silcpurple_wb_init(sg, sender);
		else
			wb = silcpurple_wb_init_ch(sg, channel);

		silcpurple_wb_parse(wb->proto_data, wb,
				    (unsigned char *)message,
				    message_len);
		return;
	}

	/* Close any previous unaccepted requests */
	purple_request_close_with_handle(sender);

	if (!channel) {
		g_snprintf(tmp, sizeof(tmp),
			   _("%s sent message to whiteboard. Would you like "
			     "to open the whiteboard?"), sender->nickname);
	} else {
		g_snprintf(tmp, sizeof(tmp),
			   _("%s sent message to whiteboard on %s channel. "
			     "Would you like to open the whiteboard?"),
			   sender->nickname, channel->channel_name);
	}

	req = silc_calloc(1, sizeof(*req));
	if (!req)
		return;
	req->message = silc_memdup(message, message_len);
	req->message_len = message_len;
	req->sender = sender;
	req->channel = channel;
	req->sg = sg;

	purple_request_action(gc, _("Whiteboard"), tmp, NULL, 1,
				sg->account, sender->nickname, NULL, req, 2,
			    _("Yes"), G_CALLBACK(silcpurple_wb_request_cb),
			    _("No"), G_CALLBACK(silcpurple_wb_request_cb));
}
开发者ID:bf4,项目名称:pidgin-mac,代码行数:56,代码来源:wb.c


示例20: silc_command_payload_parse

SilcCommandPayload silc_command_payload_parse(const unsigned char *payload,
					      SilcUInt32 payload_len)
{
  SilcBufferStruct buffer;
  SilcCommandPayload newp;
  unsigned char args_num;
  SilcUInt16 p_len;
  int ret;

  SILC_LOG_DEBUG(("Parsing command payload"));

  silc_buffer_set(&buffer, (unsigned char *)payload, payload_len);
  newp = silc_calloc(1, sizeof(*newp));
  if (!newp)
    return NULL;

  /* Parse the Command Payload */
  ret = silc_buffer_unformat(&buffer,
			     SILC_STR_UI_SHORT(&p_len),
			     SILC_STR_UI_CHAR(&newp->cmd),
			     SILC_STR_UI_CHAR(&args_num),
			     SILC_STR_UI_SHORT(&newp->ident),
			     SILC_STR_END);
  if (ret == -1) {
    SILC_LOG_ERROR(("Incorrect command payload in packet"));
    silc_free(newp);
    return NULL;
  }

  if (p_len != silc_buffer_len(&buffer)) {
    SILC_LOG_ERROR(("Incorrect command payload in packet"));
    silc_free(newp);
    return NULL;
  }

  if (newp->cmd == 0) {
    SILC_LOG_ERROR(("Incorrect command type in command payload"));
    silc_free(newp);
    return NULL;
  }

  silc_buffer_pull(&buffer, SILC_COMMAND_PAYLOAD_LEN);
  if (args_num) {
    newp->args = silc_argument_payload_parse(buffer.data,
					     silc_buffer_len(&buffer),
					     args_num);
    if (!newp->args) {
      silc_free(newp);
      return NULL;
    }
  }
  silc_buffer_push(&buffer, SILC_COMMAND_PAYLOAD_LEN);

  return newp;
}
开发者ID:FabrizioFabbe,项目名称:silc,代码行数:55,代码来源:silccommand.c



注:本文中的silc_calloc函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ silc_free函数代码示例发布时间:2022-05-30
下一篇:
C++ sil_wrw_mem函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap