void relay_weechat_alloc_with_infolist (struct t_relay_client *client, struct t_infolist *infolist) { struct t_relay_weechat_data *weechat_data; int index, value; char name[64]; const char *key; client->protocol_data = malloc (sizeof (*weechat_data)); if (client->protocol_data) { /* general stuff */ RELAY_WEECHAT_DATA(client, password_ok) = weechat_infolist_integer (infolist, "password_ok"); RELAY_WEECHAT_DATA(client, compression) = weechat_infolist_integer (infolist, "compression"); /* sync of buffers */ RELAY_WEECHAT_DATA(client, buffers_sync) = weechat_hashtable_new (32, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_INTEGER, NULL, NULL); index = 0; while (1) { snprintf (name, sizeof (name), "buffers_sync_name_%05d", index); key = weechat_infolist_string (infolist, name); if (!key) break; snprintf (name, sizeof (name), "buffers_sync_value_%05d", index); value = weechat_infolist_integer (infolist, name); weechat_hashtable_set (RELAY_WEECHAT_DATA(client, buffers_sync), key, &value); index++; } RELAY_WEECHAT_DATA(client, hook_signal_buffer) = NULL; RELAY_WEECHAT_DATA(client, hook_hsignal_nicklist) = NULL; RELAY_WEECHAT_DATA(client, hook_signal_upgrade) = NULL; RELAY_WEECHAT_DATA(client, buffers_nicklist) = weechat_hashtable_new (32, WEECHAT_HASHTABLE_POINTER, WEECHAT_HASHTABLE_POINTER, NULL, NULL); weechat_hashtable_set_pointer (RELAY_WEECHAT_DATA(client, buffers_nicklist), "callback_free_value", &relay_weechat_free_buffers_nicklist); RELAY_WEECHAT_DATA(client, hook_timer_nicklist) = NULL; relay_weechat_hook_signals (client); } }
void relay_weechat_alloc (struct t_relay_client *client) { struct t_relay_weechat_data *weechat_data; char *password; password = weechat_string_eval_expression (weechat_config_string (relay_config_network_password), NULL, NULL, NULL); client->protocol_data = malloc (sizeof (*weechat_data)); if (client->protocol_data) { RELAY_WEECHAT_DATA(client, password_ok) = (password && password[0]) ? 0 : 1; RELAY_WEECHAT_DATA(client, compression) = RELAY_WEECHAT_COMPRESSION_ZLIB; RELAY_WEECHAT_DATA(client, buffers_sync) = weechat_hashtable_new (32, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_INTEGER, NULL, NULL); RELAY_WEECHAT_DATA(client, hook_signal_buffer) = NULL; RELAY_WEECHAT_DATA(client, hook_hsignal_nicklist) = NULL; RELAY_WEECHAT_DATA(client, hook_signal_upgrade) = NULL; RELAY_WEECHAT_DATA(client, buffers_nicklist) = weechat_hashtable_new (32, WEECHAT_HASHTABLE_POINTER, WEECHAT_HASHTABLE_POINTER, NULL, NULL); weechat_hashtable_set_pointer (RELAY_WEECHAT_DATA(client, buffers_nicklist), "callback_free_value", &relay_weechat_free_buffers_nicklist); RELAY_WEECHAT_DATA(client, hook_timer_nicklist) = NULL; relay_weechat_hook_signals (client); } if (password) free (password); }
void relay_weechat_alloc_with_infolist (struct t_relay_client *client, struct t_infolist *infolist) { struct t_relay_weechat_data *weechat_data; int index, rc, value_int; char name[64]; const char *key, *value; client->protocol_data = malloc (sizeof (*weechat_data)); if (client->protocol_data) { /* general stuff */ RELAY_WEECHAT_DATA(client, password_ok) = weechat_infolist_integer (infolist, "password_ok"); RELAY_WEECHAT_DATA(client, compression) = weechat_infolist_integer (infolist, "compression"); /* sync of buffers */ RELAY_WEECHAT_DATA(client, buffers_sync) = weechat_hashtable_new (16, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING, NULL, NULL); index = 0; while (1) { snprintf (name, sizeof (name), "buffers_sync_name_%05d", index); key = weechat_infolist_string (infolist, name); if (!key) break; snprintf (name, sizeof (name), "buffers_sync_value_%05d", index); value = weechat_infolist_string (infolist, name); rc = sscanf (value, "%d", &value_int); if ((rc == EOF) || (rc == 0)) value_int = 0; weechat_hashtable_set (RELAY_WEECHAT_DATA(client, buffers_sync), key, &value_int); index++; } RELAY_WEECHAT_DATA(client, hook_signal_buffer) = NULL; RELAY_WEECHAT_DATA(client, hook_signal_nicklist) = NULL; RELAY_WEECHAT_DATA(client, buffers_nicklist) = weechat_hashtable_new (16, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING, NULL, NULL); index = 0; while (1) { snprintf (name, sizeof (name), "buffers_nicklist_name_%05d", index); key = weechat_infolist_string (infolist, name); if (!key) break; snprintf (name, sizeof (name), "buffers_nicklist_value_%05d", index); value = weechat_infolist_string (infolist, name); weechat_hashtable_set (RELAY_WEECHAT_DATA(client, buffers_sync), key, value); index++; } RELAY_WEECHAT_DATA(client, hook_timer_nicklist) = NULL; if (weechat_hashtable_get_integer (RELAY_WEECHAT_DATA(client, buffers_sync), "items_count") > 0) relay_weechat_hook_signals (client); if (weechat_hashtable_get_integer (RELAY_WEECHAT_DATA(client, buffers_sync), "items_count") > 0) relay_weechat_hook_timer_nicklist (client); } }