Пример #1
0
static void
test_module_equals_hash (Test *test, gconstpointer unused)
{
	GckModule *other;
	GObject *obj;
	guint hash;

	hash = gck_module_hash (test->module);
	g_assert (hash != 0);

	g_assert (gck_module_equal (test->module, test->module));

	other = gck_module_new (gck_module_get_functions (test->module));
	obj = g_object_new (G_TYPE_OBJECT, NULL);

	g_assert (gck_module_equal (test->module, other));

	/* TODO: Could do with another test for inequality */
	g_assert (!gck_module_equal (test->module, obj));

	g_object_unref (other);
	g_object_unref (obj);
}
Пример #2
0
/**
 * gck_slot_equal:
 * @slot1: A pointer to the first GckSlot
 * @slot2: A pointer to the second GckSlot
 *
 * Checks equality of two slots. Two GckSlot objects can point to the same
 * underlying PKCS#11 slot.
 *
 * Return value: TRUE if slot1 and slot2 are equal. FALSE if either is not a GckSlot.
 **/
gboolean
gck_slot_equal (gconstpointer slot1, gconstpointer slot2)
{
	GckSlot *s1, *s2;

	if (slot1 == slot2)
		return TRUE;
	if (!GCK_IS_SLOT (slot1) || !GCK_IS_SLOT (slot2))
		return FALSE;

	s1 = GCK_SLOT (slot1);
	s2 = GCK_SLOT (slot2);

	return s1->pv->handle == s2->pv->handle &&
	       gck_module_equal (s1->pv->module, s2->pv->module);
}