Example #1
0
void
alias_run_command (struct t_gui_buffer **buffer, const char *command)
{
    char *string;
    struct t_gui_buffer *old_current_buffer, *new_current_buffer;

    /* save current buffer pointer */
    old_current_buffer = dogechat_current_buffer();

    /* execute command */
    string = dogechat_buffer_string_replace_local_var (*buffer, command);
    dogechat_command (*buffer,
                     (string) ? string : command);
    if (string)
        free (string);

    /* get new current buffer */
    new_current_buffer = dogechat_current_buffer();

    /*
     * if current buffer was changed by command, then we'll use this one for
     * next commands in alias
     */
    if (old_current_buffer != new_current_buffer)
        *buffer = new_current_buffer;
}
Example #2
0
void
script_action_list_input (int send_to_buffer)
{
    int i, length;
    char hdata_name[128], *buf, str_pos[16];
    struct t_hdata *hdata;
    void *ptr_script;

    buf = malloc (16384);
    if (!buf)
        return;

    buf[0] = '\0';
    length = 0;

    for (i = 0; i < SCRIPT_NUM_LANGUAGES; i++)
    {
        snprintf (hdata_name, sizeof (hdata_name),
                  "%s_script", script_language[i]);
        hdata = dogechat_hdata_get (hdata_name);
        ptr_script = dogechat_hdata_get_list (hdata, "scripts");
        while (ptr_script)
        {
            if (buf[0])
                strcat (buf, ", ");
            strcat (buf, dogechat_hdata_string (hdata, ptr_script, "name"));
            strcat (buf, ".");
            strcat (buf, script_extension[i]);
            strcat (buf, " ");
            strcat (buf, dogechat_hdata_string (hdata, ptr_script, "version"));
            length = strlen (buf);
            if (length > 16384 - 64)
            {
                strcat (buf, "...");
                length += 3;
                break;
            }
            ptr_script = dogechat_hdata_move (hdata, ptr_script, 1);
        }
    }

    if (buf[0])
    {
        if (send_to_buffer)
            dogechat_command (dogechat_current_buffer (), buf);
        else
        {
            dogechat_buffer_set (dogechat_current_buffer (), "input", buf);
            snprintf (str_pos, sizeof (str_pos), "%d", length);
            dogechat_buffer_set (dogechat_current_buffer (), "input_pos", str_pos);
        }
    }
}
Example #3
0
void
fifo_exec (const char *text)
{
    char *text2, *pos_msg;
    struct t_gui_buffer *ptr_buffer;

    text2 = strdup (text);
    if (!text2)
        return;

    pos_msg = NULL;
    ptr_buffer = NULL;

    /*
     * look for plugin + buffer name at beginning of text
     * text may be: "plugin.buffer *text" or "*text"
     */
    if (text2[0] == '*')
    {
        pos_msg = text2 + 1;
        ptr_buffer = dogechat_current_buffer ();
    }
    else
    {
        pos_msg = strstr (text2, " *");
        if (!pos_msg)
        {
            dogechat_printf (NULL,
                            _("%s%s: invalid text received in pipe"),
                            dogechat_prefix ("error"), FIFO_PLUGIN_NAME);
            free (text2);
            return;
        }
        pos_msg[0] = '\0';
        pos_msg += 2;
        ptr_buffer = dogechat_buffer_search ("==", text2);
        if (!ptr_buffer)
        {
            dogechat_printf (NULL,
                            _("%s%s: buffer \"%s\" not found"),
                            dogechat_prefix ("error"), FIFO_PLUGIN_NAME,
                            text2);
            free (text2);
            return;
        }
    }

    dogechat_command (ptr_buffer, pos_msg);

    free (text2);
}