Beispiel #1
0
int
plugin_config_delete_desc (const void *pointer, void *data,
                           struct t_config_file *config_file,
                           struct t_config_section *section,
                           struct t_config_option *option)
{
    struct t_config_option *ptr_option_var;

    /* make C compiler happy */
    (void) pointer;
    (void) data;
    (void) section;

    ptr_option_var = config_file_search_option (config_file,
                                                plugin_config_section_var,
                                                option->name);
    if (ptr_option_var)
    {
        if (ptr_option_var->description)
        {
            free (ptr_option_var->description);
            ptr_option_var->description = NULL;
        }
    }

    config_file_option_free (option);

    return WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED;
}
Beispiel #2
0
void
proxy_free (struct t_proxy *proxy)
{
    int i;

    if (!proxy)
        return;

    /* remove proxy from proxies list */
    if (proxy->prev_proxy)
        (proxy->prev_proxy)->next_proxy = proxy->next_proxy;
    if (proxy->next_proxy)
        (proxy->next_proxy)->prev_proxy = proxy->prev_proxy;
    if (weechat_proxies == proxy)
        weechat_proxies = proxy->next_proxy;
    if (last_weechat_proxy == proxy)
        last_weechat_proxy = proxy->prev_proxy;

    /* free data */
    if (proxy->name)
        free (proxy->name);
    for (i = 0; i < PROXY_NUM_OPTIONS; i++)
    {
        config_file_option_free (proxy->options[i]);
    }

    free (proxy);
}
Beispiel #3
0
void
proxy_use_temp_proxies ()
{
    struct t_proxy *ptr_temp_proxy, *next_temp_proxy;
    int i, num_options_ok;

    for (ptr_temp_proxy = weechat_temp_proxies; ptr_temp_proxy;
         ptr_temp_proxy = ptr_temp_proxy->next_proxy)
    {
        num_options_ok = 0;
        for (i = 0; i < PROXY_NUM_OPTIONS; i++)
        {
            if (!ptr_temp_proxy->options[i])
            {
                ptr_temp_proxy->options[i] = proxy_create_option (ptr_temp_proxy->name,
                                                                  i,
                                                                  proxy_option_default[i]);
            }
            if (ptr_temp_proxy->options[i])
                num_options_ok++;
        }

        if (num_options_ok == PROXY_NUM_OPTIONS)
        {
            proxy_new_with_options (ptr_temp_proxy->name,
                                    ptr_temp_proxy->options[PROXY_OPTION_TYPE],
                                    ptr_temp_proxy->options[PROXY_OPTION_IPV6],
                                    ptr_temp_proxy->options[PROXY_OPTION_ADDRESS],
                                    ptr_temp_proxy->options[PROXY_OPTION_PORT],
                                    ptr_temp_proxy->options[PROXY_OPTION_USERNAME],
                                    ptr_temp_proxy->options[PROXY_OPTION_PASSWORD]);
        }
        else
        {
            for (i = 0; i < PROXY_NUM_OPTIONS; i++)
            {
                if (ptr_temp_proxy->options[i])
                {
                    config_file_option_free (ptr_temp_proxy->options[i]);
                    ptr_temp_proxy->options[i] = NULL;
                }
            }
        }
    }

    /* free all temp proxies */
    while (weechat_temp_proxies)
    {
        next_temp_proxy = weechat_temp_proxies->next_proxy;

        if (weechat_temp_proxies->name)
            free (weechat_temp_proxies->name);
        free (weechat_temp_proxies);

        weechat_temp_proxies = next_temp_proxy;
    }
    last_weechat_temp_proxy = NULL;
}
Beispiel #4
0
struct t_proxy *
proxy_new (const char *name, const char *type, const char *ipv6,
           const char *address, const char *port, const char *username,
           const char *password)
{
    struct t_config_option *option_type, *option_ipv6, *option_address;
    struct t_config_option *option_port, *option_username, *option_password;
    struct t_proxy *new_proxy;

    if (!name || !name[0])
        return NULL;

    /* it's not possible to create 2 proxies with same name */
    if (proxy_search (name))
        return NULL;

    /* look for type */
    if (proxy_search_type (type) < 0)
        return NULL;

    option_type = proxy_create_option (name, PROXY_OPTION_TYPE,
                                       type);
    option_ipv6 = proxy_create_option (name, PROXY_OPTION_IPV6,
                                       ipv6);
    option_address = proxy_create_option (name, PROXY_OPTION_ADDRESS,
                                          (address) ? address : "");
    option_port = proxy_create_option (name, PROXY_OPTION_PORT,
                                       port);
    option_username = proxy_create_option (name, PROXY_OPTION_USERNAME,
                                           (username) ? username : "");
    option_password = proxy_create_option (name, PROXY_OPTION_PASSWORD,
                                           (password) ? password : "");

    new_proxy = proxy_new_with_options (name, option_type, option_ipv6,
                                        option_address, option_port,
                                        option_username, option_password);
    if (!new_proxy)
    {
        if (option_type)
            config_file_option_free (option_type);
        if (option_ipv6)
            config_file_option_free (option_ipv6);
        if (option_address)
            config_file_option_free (option_address);
        if (option_port)
            config_file_option_free (option_port);
        if (option_username)
            config_file_option_free (option_username);
        if (option_password)
            config_file_option_free (option_password);
    }

    return new_proxy;
}