Ejemplo n.º 1
0
const char *
version_get_version_with_git ()
{
    const char *git_version;
    static char version[256];

    git_version = version_get_git ();

    snprintf (version, sizeof (version), "%s%s%s%s",
              version_get_version (),
              (git_version && git_version[0]) ? " (git: " : "",
              (git_version && git_version[0]) ? git_version : "",
              (git_version && git_version[0]) ? ")" : "");

    return version;
}
Ejemplo n.º 2
0
const char *
plugin_api_info_get_internal (void *data, const char *info_name,
                              const char *arguments)
{
    time_t inactivity;
    static char value[32], version_number[32] = { '\0' };
    static char weechat_dir_absolute_path[PATH_MAX] = { '\0' };
    int rgb, limit;
    char *pos, *color;

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

    if (!info_name)
        return NULL;

    if (string_strcasecmp (info_name, "version") == 0)
    {
        return version_get_version ();
    }
    else if (string_strcasecmp (info_name, "version_number") == 0)
    {
        if (!version_number[0])
        {
            snprintf (version_number, sizeof (version_number), "%d",
                      util_version_number (version_get_version ()));
        }
        return version_number;
    }
    else if (string_strcasecmp (info_name, "version_git") == 0)
    {
        return version_get_git ();
    }
    else if (string_strcasecmp (info_name, "date") == 0)
    {
        return version_get_compilation_date ();
    }
    else if (string_strcasecmp (info_name, "dir_separator") == 0)
    {
        return DIR_SEPARATOR;
    }
    else if (string_strcasecmp (info_name, "weechat_dir") == 0)
    {
        if (!weechat_dir_absolute_path[0])
        {
            if (!realpath (weechat_home, weechat_dir_absolute_path))
                return NULL;
        }
        return (weechat_dir_absolute_path[0]) ?
            weechat_dir_absolute_path : weechat_home;
    }
    else if (string_strcasecmp (info_name, "weechat_libdir") == 0)
    {
        return WEECHAT_LIBDIR;
    }
    else if (string_strcasecmp (info_name, "weechat_sharedir") == 0)
    {
        return WEECHAT_SHAREDIR;
    }
    else if (string_strcasecmp (info_name, "weechat_localedir") == 0)
    {
        return LOCALEDIR;
    }
    else if (string_strcasecmp (info_name, "weechat_site") == 0)
    {
        return WEECHAT_WEBSITE;
    }
    else if (string_strcasecmp (info_name, "weechat_site_download") == 0)
    {
        return WEECHAT_WEBSITE_DOWNLOAD;
    }
    else if (string_strcasecmp (info_name, "weechat_upgrading") == 0)
    {
        snprintf (value, sizeof (value), "%d", weechat_upgrading);
        return value;
    }
    else if (string_strcasecmp (info_name, "charset_terminal") == 0)
    {
        return weechat_local_charset;
    }
    else if (string_strcasecmp (info_name, "charset_internal") == 0)
    {
        return WEECHAT_INTERNAL_CHARSET;
    }
    else if (string_strcasecmp (info_name, "locale") == 0)
    {
        return setlocale (LC_MESSAGES, NULL);
    }
    else if (string_strcasecmp (info_name, "inactivity") == 0)
    {
        if (gui_key_last_activity_time == 0)
            inactivity = 0;
        else
            inactivity = time (NULL) - gui_key_last_activity_time;
        snprintf (value, sizeof (value), "%ld", (long int)inactivity);
        return value;
    }
    else if (string_strcasecmp (info_name, "filters_enabled") == 0)
    {
        snprintf (value, sizeof (value), "%d", gui_filters_enabled);
        return value;
    }
    else if (string_strcasecmp (info_name, "cursor_mode") == 0)
    {
        snprintf (value, sizeof (value), "%d", gui_cursor_mode);
        return value;
    }
    else if (string_strcasecmp (info_name, "term_width") == 0)
    {
        snprintf (value, sizeof (value), "%d", gui_window_get_width ());
        return value;
    }
    else if (string_strcasecmp (info_name, "term_height") == 0)
    {
        snprintf (value, sizeof (value), "%d", gui_window_get_height ());
        return value;
    }
    else if (string_strcasecmp (info_name, "color_ansi_regex") == 0)
    {
        return GUI_COLOR_REGEX_ANSI_DECODE;
    }
    else if (string_strcasecmp (info_name, "color_term2rgb") == 0)
    {
        if (arguments && arguments[0])
        {
            snprintf (value, sizeof (value),
                      "%d",
                      gui_color_convert_term_to_rgb (atoi (arguments)));
            return value;
        }
    }
    else if (string_strcasecmp (info_name, "color_rgb2term") == 0)
    {
        if (arguments && arguments[0])
        {
            limit = 256;
            pos = strchr (arguments, ',');
            if (pos)
            {
                color = string_strndup (arguments, pos - arguments);
                if (!color)
                    return NULL;
                rgb = atoi (color);
                limit = atoi (pos + 1);
                free (color);
            }
            else
                rgb = atoi (arguments);
            snprintf (value, sizeof (value),
                      "%d",
                      gui_color_convert_rgb_to_term (rgb, limit));
            return value;
        }
    }

    /* info not found */
    return NULL;
}