Example #1
0
int
irc_redirect_add_to_infolist (struct t_infolist *infolist,
                              struct t_irc_redirect *redirect)
{
    struct t_infolist_item *ptr_item;

    if (!infolist || !redirect)
        return 0;

    ptr_item = weechat_infolist_new_item (infolist);
    if (!ptr_item)
        return 0;

    if (!weechat_infolist_new_var_pointer (ptr_item, "server", redirect->server))
        return 0;
    if (!weechat_infolist_new_var_string (ptr_item, "server_name", redirect->server->name))
        return 0;
    if (!weechat_infolist_new_var_string (ptr_item, "pattern", redirect->pattern))
        return 0;
    if (!weechat_infolist_new_var_string (ptr_item, "signal", redirect->signal))
        return 0;
    if (!weechat_infolist_new_var_integer (ptr_item, "count", redirect->count))
        return 0;
    if (!weechat_infolist_new_var_integer (ptr_item, "current_count", redirect->current_count))
        return 0;
    if (!weechat_infolist_new_var_string (ptr_item, "string", redirect->string))
        return 0;
    if (!weechat_infolist_new_var_integer (ptr_item, "timeout", redirect->timeout))
        return 0;
    if (!weechat_infolist_new_var_string (ptr_item, "command", redirect->command))
        return 0;
    if (!weechat_infolist_new_var_integer (ptr_item, "assigned_to_command", redirect->assigned_to_command))
        return 0;
    if (!weechat_infolist_new_var_time (ptr_item, "start_time", redirect->start_time))
        return 0;
    if (!weechat_infolist_new_var_string (ptr_item, "cmd_start", weechat_hashtable_get_string (redirect->cmd_start, "keys_values")))
        return 0;
    if (!weechat_infolist_new_var_string (ptr_item, "cmd_stop", weechat_hashtable_get_string (redirect->cmd_stop, "keys_values")))
        return 0;
    if (!weechat_infolist_new_var_string (ptr_item, "cmd_extra", weechat_hashtable_get_string (redirect->cmd_extra, "keys_values")))
        return 0;
    if (!weechat_infolist_new_var_integer (ptr_item, "cmd_start_received", redirect->cmd_start_received))
        return 0;
    if (!weechat_infolist_new_var_integer (ptr_item, "cmd_stop_received", redirect->cmd_stop_received))
        return 0;
    if (!weechat_infolist_new_var_string (ptr_item, "cmd_filter", weechat_hashtable_get_string (redirect->cmd_filter, "keys_values")))
        return 0;
    if (!weechat_infolist_new_var_string (ptr_item, "output", redirect->output))
        return 0;
    if (!weechat_infolist_new_var_integer (ptr_item, "output_size", redirect->output_size))
        return 0;

    return 1;
}
Example #2
0
void
relay_weechat_msg_add_hashtable (struct t_relay_weechat_msg *msg,
                                 struct t_hashtable *hashtable)
{
    char *types[2] = { "type_keys", "type_values" };
    const char *type;
    int i, count;

    for (i = 0; i < 2; i++)
    {
        type = weechat_hashtable_get_string (hashtable, types[i]);
        if (strcmp (type, WEECHAT_HASHTABLE_INTEGER) == 0)
            relay_weechat_msg_add_type (msg, RELAY_WEECHAT_MSG_OBJ_INT);
        else if (strcmp (type, WEECHAT_HASHTABLE_STRING) == 0)
            relay_weechat_msg_add_type (msg, RELAY_WEECHAT_MSG_OBJ_STRING);
        else if (strcmp (type, WEECHAT_HASHTABLE_POINTER) == 0)
            relay_weechat_msg_add_type (msg, RELAY_WEECHAT_MSG_OBJ_POINTER);
        else if (strcmp (type, WEECHAT_HASHTABLE_BUFFER) == 0)
            relay_weechat_msg_add_type (msg, RELAY_WEECHAT_MSG_OBJ_POINTER);
        else if (strcmp (type, WEECHAT_HASHTABLE_TIME) == 0)
            relay_weechat_msg_add_type (msg, RELAY_WEECHAT_MSG_OBJ_TIME);
    }

    /* number of items */
    count = weechat_hashtable_get_integer (hashtable, "items_count");
    relay_weechat_msg_add_int (msg, count);

    /* add all items */
    weechat_hashtable_map (hashtable,
                           &relay_weechat_msg_hashtable_map_cb, msg);
}
Example #3
0
void
relay_weechat_msg_hashtable_map_cb (void *data, struct t_hashtable *hashtable,
                                    const void *key, const void *value)
{
    struct t_relay_weechat_msg *msg;
    char *types[2] = { "type_keys", "type_values" };
    const void *pointers[2];
    const char *type;
    int i;

    msg = (struct t_relay_weechat_msg *)data;
    pointers[0] = key;
    pointers[1] = value;

    for (i = 0; i < 2; i++)
    {
        type = weechat_hashtable_get_string (hashtable, types[i]);
        if (strcmp (type, WEECHAT_HASHTABLE_INTEGER) == 0)
            relay_weechat_msg_add_int (msg, *((int *)pointers[i]));
        else if (strcmp (type, WEECHAT_HASHTABLE_STRING) == 0)
            relay_weechat_msg_add_string (msg, (const char *)pointers[i]);
        else if (strcmp (type, WEECHAT_HASHTABLE_POINTER) == 0)
            relay_weechat_msg_add_pointer (msg, (void *)pointers[i]);
        else if (strcmp (type, WEECHAT_HASHTABLE_BUFFER) == 0)
            relay_weechat_msg_add_pointer (msg, (void *)pointers[i]);
        else if (strcmp (type, WEECHAT_HASHTABLE_TIME) == 0)
            relay_weechat_msg_add_time (msg, *((time_t *)pointers[i]));
    }
}
Example #4
0
int
weechat_ruby_hash_foreach_cb (VALUE key, VALUE value, void *arg)
{
    struct t_hashtable *hashtable;
    const char *type_values;

    hashtable = (struct t_hashtable *)arg;
    if ((TYPE(key) == T_STRING) && (TYPE(value) == T_STRING))
    {
        type_values = weechat_hashtable_get_string (hashtable, "type_values");
        if (strcmp (type_values, WEECHAT_HASHTABLE_STRING) == 0)
        {
            weechat_hashtable_set (hashtable, StringValuePtr(key),
                                   StringValuePtr(value));
        }
        else if (strcmp (type_values, WEECHAT_HASHTABLE_POINTER) == 0)
        {
            weechat_hashtable_set (hashtable, StringValuePtr(key),
                                   plugin_script_str2ptr (weechat_ruby_plugin,
                                                          NULL, NULL,
                                                          StringValuePtr(value)));
        }
    }
    return 0;
}
Example #5
0
int
trigger_callback_hsignal_cb (void *data, const char *signal,
                             struct t_hashtable *hashtable)
{
    const char *type_values;

    TRIGGER_CALLBACK_CB_INIT(WEECHAT_RC_OK);

    /* duplicate hashtable */
    if (hashtable
        && (strcmp (weechat_hashtable_get_string (hashtable, "type_keys"), "string") == 0))
    {
        type_values = weechat_hashtable_get_string (hashtable, "type_values");
        if (strcmp (type_values, "pointer") == 0)
        {
            pointers = weechat_hashtable_dup (hashtable);
            if (!pointers)
                goto end;
        }
        else if (strcmp (type_values, "string") == 0)
        {
            extra_vars = weechat_hashtable_dup (hashtable);
            if (!extra_vars)
                goto end;
        }
    }

    /* create hashtable (if not already created) */
    if (!extra_vars)
    {
        TRIGGER_CALLBACK_CB_NEW_EXTRA_VARS;
    }

    /* add data in hashtable used for conditions/replace/command */
    weechat_hashtable_set (extra_vars, "tg_signal", signal);

    /* execute the trigger (conditions, regex, command) */
    trigger_callback_execute (trigger, NULL, pointers, extra_vars);

end:
    TRIGGER_CALLBACK_CB_END(trigger_rc);
}
Example #6
0
void
relay_weechat_print_log (struct t_relay_client *client)
{
    if (client->protocol_data)
    {
        weechat_log_printf ("    password_ok. . . . . . : %d",   RELAY_WEECHAT_DATA(client, password_ok));
        weechat_log_printf ("    compression. . . . . . : %d",   RELAY_WEECHAT_DATA(client, compression));
        weechat_log_printf ("    buffers_sync . . . . . : 0x%lx (hashtable: '%s')",
                            RELAY_WEECHAT_DATA(client, buffers_sync),
                            weechat_hashtable_get_string (RELAY_WEECHAT_DATA(client, buffers_sync),
                                                          "keys_values"));
        weechat_log_printf ("    hook_signal_buffer . . : 0x%lx", RELAY_WEECHAT_DATA(client, hook_signal_buffer));
        weechat_log_printf ("    hook_signal_nicklist . : 0x%lx", RELAY_WEECHAT_DATA(client, hook_signal_nicklist));
        weechat_log_printf ("    buffers_nicklist . . . : 0x%lx (hashtable: '%s')",
                            RELAY_WEECHAT_DATA(client, buffers_nicklist),
                            weechat_hashtable_get_string (RELAY_WEECHAT_DATA(client, buffers_nicklist),
                                                          "keys_values"));
        weechat_log_printf ("    hook_timer_nicklist. . : 0x%lx", RELAY_WEECHAT_DATA(client, hook_timer_nicklist));
    }
}
Example #7
0
void
irc_redirect_print_log (struct t_irc_server *server)
{
    struct t_irc_redirect *ptr_redirect;

    for (ptr_redirect = server->redirects; ptr_redirect;
         ptr_redirect = ptr_redirect->next_redirect)
    {
        weechat_log_printf ("");
        weechat_log_printf ("  => redirect (addr:0x%lx):", ptr_redirect);
        weechat_log_printf ("       server. . . . . . . : 0x%lx ('%s')",
                            ptr_redirect->server, ptr_redirect->server->name);
        weechat_log_printf ("       pattern . . . . . . : '%s'",  ptr_redirect->pattern);
        weechat_log_printf ("       signal. . . . . . . : '%s'",  ptr_redirect->signal);
        weechat_log_printf ("       count . . . . . . . : %d",    ptr_redirect->count);
        weechat_log_printf ("       current_count . . . : %d",    ptr_redirect->current_count);
        weechat_log_printf ("       string. . . . . . . : '%s'",  ptr_redirect->string);
        weechat_log_printf ("       timeout . . . . . . : %d",    ptr_redirect->timeout);
        weechat_log_printf ("       command . . . . . . : '%s'",  ptr_redirect->command);
        weechat_log_printf ("       assigned_to_command : %d",    ptr_redirect->assigned_to_command);
        weechat_log_printf ("       start_time. . . . . : %ld",   ptr_redirect->start_time);
        weechat_log_printf ("       cmd_start . . . . . : 0x%lx (hashtable: '%s')",
                            ptr_redirect->cmd_start,
                            weechat_hashtable_get_string (ptr_redirect->cmd_start, "keys_values"));
        weechat_log_printf ("       cmd_stop. . . . . . : 0x%lx (hashtable: '%s')",
                            ptr_redirect->cmd_stop,
                            weechat_hashtable_get_string (ptr_redirect->cmd_stop, "keys_values"));
        weechat_log_printf ("       cmd_extra . . . . . : 0x%lx (hashtable: '%s')",
                            ptr_redirect->cmd_extra,
                            weechat_hashtable_get_string (ptr_redirect->cmd_extra, "keys_values"));
        weechat_log_printf ("       cmd_start_received. : %d",    ptr_redirect->cmd_start_received);
        weechat_log_printf ("       cmd_stop_received . : %d",    ptr_redirect->cmd_stop_received);
        weechat_log_printf ("       cmd_filter. . . . . : 0x%lx (hashtable: '%s')",
                            ptr_redirect->cmd_filter,
                            weechat_hashtable_get_string (ptr_redirect->cmd_filter, "keys_values"));
        weechat_log_printf ("       output. . . . . . . : '%s'",  ptr_redirect->output);
        weechat_log_printf ("       output_size . . . . : %d",    ptr_redirect->output_size);
        weechat_log_printf ("       prev_redirect . . . : 0x%lx", ptr_redirect->prev_redirect);
        weechat_log_printf ("       next_redirect . . . : 0x%lx", ptr_redirect->next_redirect);
    }
}