Пример #1
0
Файл: flog.c Проект: bilken/Flog
static flog_module_t _module_from_string(const char *str)
{
    flog_module_t m;

    m = (flog_module_t)find_string_in_list(mstr_list,
            sizeof(mstr_list[0]), ARRAY_COUNT(mstr_list),
            str);
    if (!MODULE_IS_VALID(m) && m != FLOG_MOD_ALL) {
        return FLOG_MOD_INVALID;
    }
    return m;
}
Пример #2
0
Файл: flog.c Проект: bilken/Flog
static flog_severity_t _severity_from_string(const char *str)
{
    flog_severity_t s;

    s = (flog_severity_t)find_string_in_list(sstr_list,
            sizeof(sstr_list[0]), ARRAY_COUNT(sstr_list),
            str);
    if (!SEVERITY_IS_VALID(s)) {
        return FLOG_SVR_INVALID;
    }
    return s;
}
Пример #3
0
static void keyword_tree_reset1(GtkTreeModel *keyword_tree, GtkTreeIter *iter, GList **kw_list)
{
	gchar *found;
	gchar *name;
	if (!keyword_get_is_keyword(keyword_tree, iter)) return;

	name = keyword_get_name(keyword_tree, iter);
	found = find_string_in_list(*kw_list, name);

	if (found)
		{
		*kw_list = g_list_remove(*kw_list, found);
		g_free(found);
		}
	g_free(name);
}
Пример #4
0
GList *string_to_keywords_list(const gchar *text)
{
	GList *list = NULL;
	const gchar *ptr = text;

	while (*ptr != '\0')
		{
		const gchar *begin;
		gint l = 0;

		while (KEYWORDS_SEPARATOR(*ptr)) ptr++;
		begin = ptr;
		while (*ptr != '\0' && !KEYWORDS_SEPARATOR(*ptr))
			{
			ptr++;
			l++;
			}

		/* trim starting and ending whitespaces */
		while (l > 0 && g_ascii_isspace(*begin)) begin++, l--;
		while (l > 0 && g_ascii_isspace(begin[l-1])) l--;

		if (l > 0)
			{
			gchar *keyword = g_strndup(begin, l);

			/* only add if not already in the list */
			if (!find_string_in_list(list, keyword))
				list = g_list_append(list, keyword);
			else
				g_free(keyword);
			}
		}

	return list;
}
Пример #5
0
void keyword_tree_set(GtkTreeModel *keyword_tree, GtkTreeIter *iter_ptr, GList **kw_list)
{
	GtkTreeIter iter = *iter_ptr;
	while (TRUE)
		{
		GtkTreeIter parent;

		if (keyword_get_is_keyword(keyword_tree, &iter))
			{
			gchar *name = keyword_get_name(keyword_tree, &iter);
			if (!find_string_in_list(*kw_list, name))
				{
				*kw_list = g_list_append(*kw_list, name);
				}
			else
				{
				g_free(name);
				}
			}

		if (!gtk_tree_model_iter_parent(keyword_tree, &parent, &iter)) return;
		iter = parent;
		}
}