Exemplo n.º 1
0
static int
search_gui_cmp(GtkTreeModel *model, GtkTreeIter *iter1, GtkTreeIter *iter2,
	void *user_data)
{
	const struct result_data *a, *b;
	enum c_sr_columns column;
	int ret = 0;
	
	column = GPOINTER_TO_UINT(user_data);
	a = get_result_data(model, iter1);
	b = get_result_data(model, iter2);
	switch (column) {
	case c_sr_filename: ret = search_gui_cmp_filename(a, b); break;
	case c_sr_ext:		ret = search_gui_cmp_ext(a, b); break;
	case c_sr_mime:		ret = search_gui_cmp_mime(a, b); break;
	case c_sr_vendor:	ret = search_gui_cmp_vendor(a, b); break;
	case c_sr_info:		ret = search_gui_cmp_info(a, b); break;
	case c_sr_size:		ret = search_gui_cmp_size(a, b); break;
	case c_sr_count:	ret = search_gui_cmp_count(a, b); break;
	case c_sr_loc:		ret = search_gui_cmp_country(a, b); break;
	case c_sr_charset:	ret = search_gui_cmp_charset(a, b); break;
	case c_sr_route:	ret = search_gui_cmp_route(a, b); break;
	case c_sr_protocol:	ret = search_gui_cmp_protocol(a, b); break;
	case c_sr_hops:		ret = search_gui_cmp_hops(a, b); break;
	case c_sr_ttl:		ret = search_gui_cmp_ttl(a, b); break;
	case c_sr_spam:		ret = search_gui_cmp_spam(a, b); break;
	case c_sr_owned:	ret = search_gui_cmp_owned(a, b); break;
	case c_sr_hostile:	ret = search_gui_cmp_hostile(a, b); break;
	case c_sr_sha1:		ret = search_gui_cmp_sha1(a, b); break;
	case c_sr_ctime:	ret = search_gui_cmp_ctime(a, b); break;
	case c_sr_num: 		g_assert_not_reached(); break;
	}
	/* Use address to stabilize sorting */
	return ret ? ret : CMP(pointer_to_ulong(a), pointer_to_ulong(b));
}
Exemplo n.º 2
0
static inline void
set_parent(rbnode_t *node, rbnode_t *parent)
{
	node->parent = ulong_to_pointer(
		pointer_to_ulong(parent) |
		(pointer_to_ulong(node->parent) & RB_COLOR_MASK)
	);
}
Exemplo n.º 3
0
static inline
void set_color(rbnode_t *node, enum rbcolor color)
{
	g_assert(RB_BLACK == color || RB_RED == color);

	node->parent = ulong_to_pointer(
		(pointer_to_ulong(node->parent) & ~RB_COLOR_MASK) | color);
}
Exemplo n.º 4
0
/**
 * Locate a symbol at the given addres.
 *
 * @param bc		the BFD context retrieved by bfd_util_get_context()
 * @param addr		the address of the symbol
 * @param loc		where location information is returned
 *
 * @return TRUE if the symbol address was located.
 */
bool
bfd_util_locate(bfd_ctx_t *bc, const void *addr, struct symbol_loc *loc)
{
	struct symbol_ctx sc;
	const void *lookaddr;
	const char *name;

	g_assert(loc != NULL);

	if G_UNLIKELY(NULL == bc)
		return FALSE;

	bfd_ctx_check(bc);

	mutex_lock_fast(&bc->lock);

	ZERO(&sc);
	lookaddr = const_ptr_add_offset(addr, bc->offset);
	sc.addr = pointer_to_ulong(lookaddr);
	sc.symbols = bc->symbols;

	bfd_map_over_sections(bc->handle, bfd_util_lookup_section, &sc);

	if (sc.location.function != NULL) {
		*loc = sc.location;		/* Struct copy */
		mutex_unlock_fast(&bc->lock);
		return TRUE;
	}

	/*
	 * For some reason the BFD library successfully loads symbols but is not
	 * able to locate them through bfd_map_over_sections().
	 *
	 * Load the symbol table ourselves and perform the lookup then.  We will
	 * only be able to fill the routine name, and not the source code
	 * information but that is better than nothing.
	 */

	if (NULL == bc->text_symbols) {
		bc->text_symbols = symbols_make(bc->count, FALSE);
		bfd_util_load_text(bc, bc->text_symbols);
		symbols_sort(bc->text_symbols);
	}

	name = symbols_name_only(bc->text_symbols, lookaddr, FALSE);
	if (name != NULL) {
		ZERO(loc);
		loc->function = name;
		mutex_unlock_fast(&bc->lock);
		return TRUE;
	}

	mutex_unlock_fast(&bc->lock);
	return FALSE;
}
Exemplo n.º 5
0
static inline rbnode_t *
get_parent(const rbnode_t *node)
{
	return ulong_to_pointer(pointer_to_ulong(node->parent) & ~RB_COLOR_MASK);
}
Exemplo n.º 6
0
static inline
void invalidate(rbnode_t *node)
{
	node->parent = ulong_to_pointer(
		(pointer_to_ulong(node->parent) & ~RB_COLOR_MASK));
}
Exemplo n.º 7
0
static inline enum rbcolor
get_color(const rbnode_t *node)
{
	return pointer_to_ulong(node->parent) & RB_COLOR_MASK;
}