static PyObject *mime_type_equal (PyObject *self, PyObject *args) { const char *mime_a, *mime_b; if (!PyArg_ParseTuple(args, "ss", &mime_a, &mime_b)) return NULL; return PyBool_FromLong(xdg_mime_mime_type_equal(mime_a, mime_b)); }
/** * g_content_type_equals: * @type1: a content type string * @type2: a content type string * * Compares two content types for equality. * * Returns: %TRUE if the two strings are identical or equivalent, * %FALSE otherwise. */ gboolean g_content_type_equals (const gchar *type1, const gchar *type2) { gboolean res; g_return_val_if_fail (type1 != NULL, FALSE); g_return_val_if_fail (type2 != NULL, FALSE); G_LOCK (gio_xdgmime); res = xdg_mime_mime_type_equal (type1, type2); G_UNLOCK (gio_xdgmime); return res; }
static void test_alias (const char *mime_a, const char *mime_b, int expected) { int actual; actual = xdg_mime_mime_type_equal (mime_a, mime_b); if (actual != expected) { printf ("Test Failed: %s is %s to %s\n", mime_a, actual ? "equal" : "not equal", mime_b); } }
static const char * cache_magic_lookup_data (XdgMimeCache *cache, const void *data, size_t len, int *prio, const char *mime_types[], int n_mime_types) { xdg_uint32_t list_offset; xdg_uint32_t n_entries; xdg_uint32_t offset; int j, n; *prio = 0; list_offset = GET_UINT32 (cache->buffer, 24); n_entries = GET_UINT32 (cache->buffer, list_offset); offset = GET_UINT32 (cache->buffer, list_offset + 8); for (j = 0; j < n_entries; j++) { const char *match; match = cache_magic_compare_to_data (cache, offset + 16 * j, data, len, prio); if (match) return match; else { xdg_uint32_t mimetype_offset; const char *non_match; mimetype_offset = GET_UINT32 (cache->buffer, offset + 16 * j + 4); non_match = cache->buffer + mimetype_offset; for (n = 0; n < n_mime_types; n++) { if (mime_types[n] && xdg_mime_mime_type_equal (mime_types[n], non_match)) mime_types[n] = NULL; } } } return NULL; }