/* glob must be valid UTF-8 */ void _xdg_glob_hash_append_glob (XdgGlobHash *glob_hash, const char *glob, const char *mime_type, int weight, int case_sensitive) { XdgGlobType type; assert (glob_hash != NULL); assert (glob != NULL); type = _xdg_glob_determine_type (glob); switch (type) { case XDG_GLOB_LITERAL: glob_hash->literal_list = _xdg_glob_list_append (glob_hash->literal_list, strdup (glob), strdup (mime_type), weight, case_sensitive); break; case XDG_GLOB_SIMPLE: glob_hash->simple_node = _xdg_glob_hash_insert_text (glob_hash->simple_node, glob + 1, mime_type, weight, case_sensitive); break; case XDG_GLOB_FULL: glob_hash->full_list = _xdg_glob_list_append (glob_hash->full_list, strdup (glob), strdup (mime_type), weight, case_sensitive); break; } }
static void test_individual_glob (const char *glob, XdgGlobType expected_type) { XdgGlobType test_type; test_type = _xdg_glob_determine_type (glob); if (test_type != expected_type) { printf ("Test Failed: %s is of type %s, but %s is expected\n", glob, ((test_type == XDG_GLOB_LITERAL)?"XDG_GLOB_LITERAL": ((test_type == XDG_GLOB_SIMPLE)?"XDG_GLOB_SIMPLE":"XDG_GLOB_FULL")), ((expected_type == XDG_GLOB_LITERAL)?"XDG_GLOB_LITERAL": ((expected_type == XDG_GLOB_SIMPLE)?"XDG_GLOB_SIMPLE":"XDG_GLOB_COMPLEX"))); } }