Esempio n. 1
0
int
plugin_config_set_internal (const char *option, const char *value)
{
    int rc;
    struct t_config_option *ptr_option;

    ptr_option = config_file_search_option (plugin_config_file,
                                            plugin_config_section_var,
                                            option);
    if (ptr_option)
    {
        rc = config_file_option_set (ptr_option, value, 0);
    }
    else
    {
        ptr_option = config_file_new_option (
            plugin_config_file, plugin_config_section_var,
            option, "string", NULL,
            NULL, 0, 0, "", value, 0,
            NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
        rc = (ptr_option) ? WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
    }

    return rc;
}
Esempio n. 2
0
int
plugin_config_create_option (const void *pointer, void *data,
                             struct t_config_file *config_file,
                             struct t_config_section *section,
                             const char *option_name, const char *value)
{
    struct t_config_option *ptr_option_desc, *ptr_option;

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

    ptr_option_desc = config_file_search_option (config_file,
                                                 plugin_config_section_desc,
                                                 option_name);

    ptr_option = config_file_new_option (
        config_file, section,
        option_name, "string",
        (ptr_option_desc) ? CONFIG_STRING(ptr_option_desc) : NULL,
        NULL, 0, 0, "", value, 0,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

    return (ptr_option) ?
        WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
}
Esempio n. 3
0
void
plugin_config_set_desc_internal (const char *option, const char *value)
{
    struct t_config_option *ptr_option;

    ptr_option = config_file_search_option (plugin_config_file,
                                            plugin_config_section_desc,
                                            option);
    if (ptr_option)
    {
        config_file_option_set (ptr_option, value, 1);
    }
    else
    {
        ptr_option = config_file_new_option (
            plugin_config_file, plugin_config_section_desc,
            option, "string", _("description of plugin option"),
            NULL, 0, 0, "", value, 0,
            NULL, NULL, NULL,
            &plugin_config_desc_changed_cb, NULL, NULL,
            NULL, NULL, NULL);
    }

    if (ptr_option)
        plugin_config_desc_changed_cb (NULL, NULL, ptr_option);
}
Esempio n. 4
0
int
plugin_config_create_desc (void *data, struct t_config_file *config_file,
                           struct t_config_section *section,
                           const char *option_name, const char *value)
{
    struct t_config_option *ptr_option_var, *ptr_option;

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

    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;
        }
        if (value)
            ptr_option_var->description = strdup (value);
    }

    ptr_option = config_file_new_option (
        config_file, section,
        option_name, "string", _("description of plugin option"),
        NULL, 0, 0, "", value, 0, NULL, NULL,
        &plugin_config_desc_changed_cb, NULL, NULL, NULL);

    return (ptr_option) ?
        DOGECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : DOGECHAT_CONFIG_OPTION_SET_ERROR;
}
Esempio n. 5
0
struct t_config_option *
proxy_create_option (const char *proxy_name, int index_option,
                     const char *value)
{
    struct t_config_option *ptr_option;
    int length;
    char *option_name;

    ptr_option = NULL;

    length = strlen (proxy_name) + 1 +
        strlen (proxy_option_string[index_option]) + 1;
    option_name = malloc (length);
    if (option_name)
    {
        snprintf (option_name, length, "%s.%s",
                  proxy_name, proxy_option_string[index_option]);

        switch (index_option)
        {
            case PROXY_OPTION_TYPE:
                ptr_option = config_file_new_option (
                    weechat_config_file, weechat_config_section_proxy,
                    option_name, "integer",
                    N_("proxy type (http (default), socks4, socks5)"),
                    "http|socks4|socks5", 0, 0, value, NULL, 0,
                    NULL, NULL, NULL, NULL, NULL, NULL);
                break;
            case PROXY_OPTION_IPV6:
                ptr_option = config_file_new_option (
                    weechat_config_file, weechat_config_section_proxy,
                    option_name, "boolean",
                    N_("connect to proxy using ipv6"),
                    NULL, 0, 0, value, NULL, 0,
                    NULL, NULL, NULL, NULL, NULL, NULL);
                break;
            case PROXY_OPTION_ADDRESS:
                ptr_option = config_file_new_option (
                    weechat_config_file, weechat_config_section_proxy,
                    option_name, "string",
                    N_("proxy server address (IP or hostname)"),
                    NULL, 0, 0, value, NULL, 0,
                    NULL, NULL, NULL, NULL, NULL, NULL);
                break;
            case PROXY_OPTION_PORT:
                ptr_option = config_file_new_option (
                    weechat_config_file, weechat_config_section_proxy,
                    option_name, "integer",
                    N_("port for connecting to proxy server"),
                    NULL, 0, 65535, value, NULL, 0,
                    NULL, NULL, NULL, NULL, NULL, NULL);
                break;
            case PROXY_OPTION_USERNAME:
                ptr_option = config_file_new_option (
                    weechat_config_file, weechat_config_section_proxy,
                    option_name, "string",
                    N_("username for proxy server "
                       "(note: content is evaluated, see /help eval)"),
                    NULL, 0, 0, value, NULL, 0,
                    NULL, NULL, NULL, NULL, NULL, NULL);
                break;
            case PROXY_OPTION_PASSWORD:
                ptr_option = config_file_new_option (
                    weechat_config_file, weechat_config_section_proxy,
                    option_name, "string",
                    N_("password for proxy server "
                       "(note: content is evaluated, see /help eval)"),
                    NULL, 0, 0, value, NULL, 0,
                    NULL, NULL, NULL, NULL, NULL, NULL);
                break;
            case PROXY_NUM_OPTIONS:
                break;
        }
        free (option_name);
    }

    return ptr_option;
}
Esempio n. 6
0
int
secure_init_options ()
{
    struct t_config_section *ptr_section;

    secure_config_file = config_file_new (NULL, SECURE_CONFIG_NAME,
                                          &secure_reload_cb, NULL);
    if (!secure_config_file)
        return 0;

    /* crypt */
    ptr_section = config_file_new_section (secure_config_file, "crypt",
                                           0, 0,
                                           NULL, NULL, NULL, NULL, NULL, NULL,
                                           NULL, NULL, NULL, NULL);
    if (!ptr_section)
    {
        config_file_free (secure_config_file);
        return 0;
    }

    secure_config_crypt_cipher = config_file_new_option (
        secure_config_file, ptr_section,
        "cipher", "integer",
        N_("cipher used to crypt data (the number after algorithm is the size "
           "of the key in bits)"),
        "aes128|aes192|aes256", 0, 0, "aes256", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL);
    secure_config_crypt_hash_algo = config_file_new_option (
        secure_config_file, ptr_section,
        "hash_algo", "integer",
        N_("hash algorithm used to check the decrypted data"),
        "sha224|sha256|sha384|sha512", 0, 0, "sha256", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL);
    secure_config_crypt_passphrase_file = config_file_new_option (
        secure_config_file, ptr_section,
        "passphrase_file", "string",
        N_("path to a file containing the passphrase to encrypt/decrypt secured "
           "data; this option is used only when reading file sec.conf; only "
           "first line of file is used; this file is used only if the "
           "environment variable \"WEECHAT_PASSPHRASE\" is not set (the "
           "environment variable has higher priority); security note: it is "
           "recommended to keep this file readable only by you and store it "
           "outside WeeChat home (for example in your home); example: "
           "\"~/.weechat-passphrase\""),
        NULL, 0, 0, "", NULL, 0,
        &secure_check_crypt_passphrase_file, NULL, NULL, NULL, NULL, NULL);
    secure_config_crypt_salt = config_file_new_option (
        secure_config_file, ptr_section,
        "salt", "boolean",
        N_("use salt when generating key used in encryption (recommended for "
           "maximum security); when enabled, the content of crypted data in "
           "file sec.conf will be different on each write of the file; if you "
           "put the file sec.conf in a version control system, then you "
           "can turn off this option to have always same content in file"),
        NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);

    /* data */
    ptr_section = config_file_new_section (secure_config_file, "data",
                                           0, 0,
                                           &secure_data_read_cb, NULL,
                                           &secure_data_write_cb, NULL,
                                           &secure_data_write_cb, NULL,
                                           NULL, NULL, NULL, NULL);
    if (!ptr_section)
    {
        config_file_free (secure_config_file);
        return 0;
    }

    return 1;
}