forked from AuroraMiddleware/gtk
Resync with upstream
2004-12-09 Marco Pesenti Gritti <marco@gnome.org> * xdgmime.c: (xdg_mime_unalias_mime_type), (xdg_mime_mime_type_equal), (xdg_mime_mime_type_subclass), (xdg_mime_get_mime_parents): * xdgmime.h: * xdgmimealias.c: (_xdg_mime_alias_list_lookup): * xdgmimeglob.c: (_xdg_glob_hash_node_lookup_file_name): * xdgmimeint.c: (_xdg_ucs4_to_lower): * xdgmimeint.h: * xdgmimemagic.c: (_xdg_mime_magic_read_from_file): * xdgmimeparent.c: (_xdg_mime_parent_list_lookup): Resync with upstream
This commit is contained in:
parent
94ab8fe8c0
commit
08b5b675e1
@ -1,3 +1,18 @@
|
|||||||
|
2004-12-09 Marco Pesenti Gritti <marco@gnome.org>
|
||||||
|
|
||||||
|
* xdgmime.c: (xdg_mime_unalias_mime_type),
|
||||||
|
(xdg_mime_mime_type_equal), (xdg_mime_mime_type_subclass),
|
||||||
|
(xdg_mime_get_mime_parents):
|
||||||
|
* xdgmime.h:
|
||||||
|
* xdgmimealias.c: (_xdg_mime_alias_list_lookup):
|
||||||
|
* xdgmimeglob.c: (_xdg_glob_hash_node_lookup_file_name):
|
||||||
|
* xdgmimeint.c: (_xdg_ucs4_to_lower):
|
||||||
|
* xdgmimeint.h:
|
||||||
|
* xdgmimemagic.c: (_xdg_mime_magic_read_from_file):
|
||||||
|
* xdgmimeparent.c: (_xdg_mime_parent_list_lookup):
|
||||||
|
|
||||||
|
Resync with upstream
|
||||||
|
|
||||||
2004-12-09 Matthias Clasen <mclasen@redhat.com>
|
2004-12-09 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* xdgmimealias.c (_xdg_mime_alias_read_from_file):
|
* xdgmimealias.c (_xdg_mime_alias_read_from_file):
|
||||||
|
@ -25,7 +25,10 @@
|
|||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "xdgmime.h"
|
#include "xdgmime.h"
|
||||||
#include "xdgmimeint.h"
|
#include "xdgmimeint.h"
|
||||||
#include "xdgmimeglob.h"
|
#include "xdgmimeglob.h"
|
||||||
@ -529,11 +532,13 @@ xdg_mime_get_max_buffer_extents (void)
|
|||||||
return _xdg_mime_magic_get_buffer_extents (global_magic);
|
return _xdg_mime_magic_get_buffer_extents (global_magic);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
const char *
|
||||||
unalias_mime_type (const char *mime_type)
|
xdg_mime_unalias_mime_type (const char *mime_type)
|
||||||
{
|
{
|
||||||
const char *lookup;
|
const char *lookup;
|
||||||
|
|
||||||
|
xdg_mime_init ();
|
||||||
|
|
||||||
if ((lookup = _xdg_mime_alias_list_lookup (alias_list, mime_type)) != NULL)
|
if ((lookup = _xdg_mime_alias_list_lookup (alias_list, mime_type)) != NULL)
|
||||||
return lookup;
|
return lookup;
|
||||||
|
|
||||||
@ -548,8 +553,8 @@ xdg_mime_mime_type_equal (const char *mime_a,
|
|||||||
|
|
||||||
xdg_mime_init ();
|
xdg_mime_init ();
|
||||||
|
|
||||||
unalias_a = unalias_mime_type (mime_a);
|
unalias_a = xdg_mime_unalias_mime_type (mime_a);
|
||||||
unalias_b = unalias_mime_type (mime_b);
|
unalias_b = xdg_mime_unalias_mime_type (mime_b);
|
||||||
|
|
||||||
if (strcmp (unalias_a, unalias_b) == 0)
|
if (strcmp (unalias_a, unalias_b) == 0)
|
||||||
return 1;
|
return 1;
|
||||||
@ -599,8 +604,8 @@ xdg_mime_mime_type_subclass (const char *mime,
|
|||||||
|
|
||||||
xdg_mime_init ();
|
xdg_mime_init ();
|
||||||
|
|
||||||
umime = unalias_mime_type (mime);
|
umime = xdg_mime_unalias_mime_type (mime);
|
||||||
ubase = unalias_mime_type (base);
|
ubase = xdg_mime_unalias_mime_type (base);
|
||||||
|
|
||||||
if (strcmp (umime, ubase) == 0)
|
if (strcmp (umime, ubase) == 0)
|
||||||
return 1;
|
return 1;
|
||||||
@ -633,6 +638,18 @@ xdg_mime_mime_type_subclass (const char *mime,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char **
|
||||||
|
xdg_mime_get_mime_parents (const char *mime)
|
||||||
|
{
|
||||||
|
const char *umime;
|
||||||
|
|
||||||
|
xdg_mime_init ();
|
||||||
|
|
||||||
|
umime = xdg_mime_unalias_mime_type (mime);
|
||||||
|
|
||||||
|
return _xdg_mime_parent_list_lookup (parent_list, umime);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xdg_mime_dump (void)
|
xdg_mime_dump (void)
|
||||||
{
|
{
|
||||||
|
@ -51,37 +51,37 @@ typedef void (*XdgMimeDestroy) (void *user_data);
|
|||||||
#define xdg_mime_get_mime_type_from_file_name XDG_ENTRY(get_mime_type_from_file_name)
|
#define xdg_mime_get_mime_type_from_file_name XDG_ENTRY(get_mime_type_from_file_name)
|
||||||
#define xdg_mime_is_valid_mime_type XDG_ENTRY(is_valid_mime_type)
|
#define xdg_mime_is_valid_mime_type XDG_ENTRY(is_valid_mime_type)
|
||||||
#define xdg_mime_mime_type_equal XDG_ENTRY(mime_type_equal)
|
#define xdg_mime_mime_type_equal XDG_ENTRY(mime_type_equal)
|
||||||
#define xdg_mime_media_type_equal XDG_ENTRY(media_type_equal)
|
|
||||||
#define xdg_mime_mime_type_subclass XDG_ENTRY(mime_type_subclass)
|
#define xdg_mime_mime_type_subclass XDG_ENTRY(mime_type_subclass)
|
||||||
#define xdg_mime_get_max_buffer_extents XDG_ENTRY(get_max_buffer_extents)
|
#define xdg_mime_get_max_buffer_extents XDG_ENTRY(get_max_buffer_extents)
|
||||||
#define xdg_mime_shutdown XDG_ENTRY(shutdown)
|
#define xdg_mime_shutdown XDG_ENTRY(shutdown)
|
||||||
#define xdg_mime_register_reload_callback XDG_ENTRY(register_reload_callback)
|
#define xdg_mime_register_reload_callback XDG_ENTRY(register_reload_callback)
|
||||||
#define xdg_mime_remove_callback XDG_ENTRY(remove_callback)
|
#define xdg_mime_remove_callback XDG_ENTRY(remove_callback)
|
||||||
#define xdg_mime_type_unknown XDG_ENTRY(type_unknown)
|
#define xdg_mime_type_unknown XDG_ENTRY(type_unknown)
|
||||||
#define xdg_mime_dump XDG_ENTRY(dump)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern const char *xdg_mime_type_unknown;
|
extern const char *xdg_mime_type_unknown;
|
||||||
#define XDG_MIME_TYPE_UNKNOWN xdg_mime_type_unknown
|
#define XDG_MIME_TYPE_UNKNOWN xdg_mime_type_unknown
|
||||||
|
|
||||||
const char *xdg_mime_get_mime_type_for_data (const void *data,
|
const char *xdg_mime_get_mime_type_for_data (const void *data,
|
||||||
size_t len);
|
size_t len);
|
||||||
const char *xdg_mime_get_mime_type_for_file (const char *file_name);
|
const char *xdg_mime_get_mime_type_for_file (const char *file_name);
|
||||||
const char *xdg_mime_get_mime_type_from_file_name (const char *file_name);
|
const char *xdg_mime_get_mime_type_from_file_name (const char *file_name);
|
||||||
int xdg_mime_is_valid_mime_type (const char *mime_type);
|
int xdg_mime_is_valid_mime_type (const char *mime_type);
|
||||||
int xdg_mime_mime_type_equal (const char *mime_a,
|
int xdg_mime_mime_type_equal (const char *mime_a,
|
||||||
const char *mime_b);
|
const char *mime_b);
|
||||||
int xdg_mime_media_type_equal (const char *mime_a,
|
int xdg_mime_media_type_equal (const char *mime_a,
|
||||||
const char *mime_b);
|
const char *mime_b);
|
||||||
int xdg_mime_mime_type_subclass (const char *mime_a,
|
int xdg_mime_mime_type_subclass (const char *mime_a,
|
||||||
const char *mime_b);
|
const char *mime_b);
|
||||||
int xdg_mime_get_max_buffer_extents (void);
|
const char **xdg_mime_get_mime_parents (const char *mime);
|
||||||
void xdg_mime_shutdown (void);
|
const char *xdg_mime_unalias_mime_type (const char *mime);
|
||||||
void xdg_mime_dump (void);
|
int xdg_mime_get_max_buffer_extents (void);
|
||||||
int xdg_mime_register_reload_callback (XdgMimeCallback callback,
|
void xdg_mime_shutdown (void);
|
||||||
void *data,
|
void xdg_mime_dump (void);
|
||||||
XdgMimeDestroy destroy);
|
int xdg_mime_register_reload_callback (XdgMimeCallback callback,
|
||||||
void xdg_mime_remove_callback (int callback_id);
|
void *data,
|
||||||
|
XdgMimeDestroy destroy);
|
||||||
|
void xdg_mime_remove_callback (int callback_id);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,10 @@
|
|||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "xdgmimealias.h"
|
#include "xdgmimealias.h"
|
||||||
#include "xdgmimeint.h"
|
#include "xdgmimeint.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -103,11 +106,11 @@ _xdg_mime_alias_list_lookup (XdgAliasList *list,
|
|||||||
{
|
{
|
||||||
key.alias = (char *)alias;
|
key.alias = (char *)alias;
|
||||||
key.mime_type = 0;
|
key.mime_type = 0;
|
||||||
|
|
||||||
entry = bsearch (&key, list->aliases, list->n_aliases,
|
entry = bsearch (&key, list->aliases, list->n_aliases,
|
||||||
sizeof (XdgAlias), alias_entry_cmp);
|
sizeof (XdgAlias), alias_entry_cmp);
|
||||||
if (entry)
|
if (entry)
|
||||||
return entry->mime_type;
|
return entry->mime_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -25,7 +25,10 @@
|
|||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "xdgmimeglob.h"
|
#include "xdgmimeglob.h"
|
||||||
#include "xdgmimeint.h"
|
#include "xdgmimeint.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -260,13 +263,11 @@ _xdg_glob_hash_node_lookup_file_name (XdgGlobHashNode *glob_hash_node,
|
|||||||
|
|
||||||
character = _xdg_utf8_to_ucs4 (file_name);
|
character = _xdg_utf8_to_ucs4 (file_name);
|
||||||
if (ignore_case)
|
if (ignore_case)
|
||||||
character = _xdg_ucs4_to_upper(character);
|
character = _xdg_ucs4_to_lower(character);
|
||||||
|
|
||||||
for (node = glob_hash_node;
|
for (node = glob_hash_node; node && character >= node->character; node = node->next)
|
||||||
node && character >= (ignore_case?_xdg_ucs4_to_upper (node->character):node->character);
|
|
||||||
node = node->next)
|
|
||||||
{
|
{
|
||||||
if (character == (ignore_case?_xdg_ucs4_to_upper (node->character):node->character))
|
if (character == node->character)
|
||||||
{
|
{
|
||||||
file_name = _xdg_utf8_next_char (file_name);
|
file_name = _xdg_utf8_next_char (file_name);
|
||||||
if (*file_name == '\000')
|
if (*file_name == '\000')
|
||||||
|
@ -25,7 +25,10 @@
|
|||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "xdgmimeint.h"
|
#include "xdgmimeint.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -118,12 +121,12 @@ _xdg_utf8_to_ucs4(const char *source)
|
|||||||
/* hullo. this is great code. don't rewrite it */
|
/* hullo. this is great code. don't rewrite it */
|
||||||
|
|
||||||
xdg_unichar_t
|
xdg_unichar_t
|
||||||
_xdg_ucs4_to_upper (xdg_unichar_t source)
|
_xdg_ucs4_to_lower (xdg_unichar_t source)
|
||||||
{
|
{
|
||||||
/* FIXME: Do a real to_upper sometime */
|
/* FIXME: Do a real to_upper sometime */
|
||||||
/* CaseFolding-3.2.0.txt has a table of rules. */
|
/* CaseFolding-3.2.0.txt has a table of rules. */
|
||||||
if ((source & 0xFF) == source)
|
if ((source & 0xFF) == source)
|
||||||
return (xdg_unichar_t) toupper ((char) source);
|
return (xdg_unichar_t) tolower ((unsigned char) source);
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ typedef unsigned int xdg_uint32_t;
|
|||||||
#ifdef XDG_PREFIX
|
#ifdef XDG_PREFIX
|
||||||
#define _xdg_utf8_skip XDG_ENTRY(utf8_skip)
|
#define _xdg_utf8_skip XDG_ENTRY(utf8_skip)
|
||||||
#define _xdg_utf8_to_ucs4 XDG_ENTRY(utf8_to_ucs4)
|
#define _xdg_utf8_to_ucs4 XDG_ENTRY(utf8_to_ucs4)
|
||||||
#define _xdg_ucs4_to_upper XDG_ENTRY(ucs4_to_upper)
|
#define _xdg_ucs4_to_lower XDG_ENTRY(ucs4_to_lower)
|
||||||
#define _xdg_utf8_validate XDG_ENTRY(utf8_validate)
|
#define _xdg_utf8_validate XDG_ENTRY(utf8_validate)
|
||||||
#define _xdg_get_base_name XDG_ENTRY(get_ase_name)
|
#define _xdg_get_base_name XDG_ENTRY(get_ase_name)
|
||||||
#endif
|
#endif
|
||||||
@ -66,7 +66,7 @@ extern const char *const _xdg_utf8_skip;
|
|||||||
#define _xdg_utf8_char_size(p) (int) (_xdg_utf8_skip[*(unsigned char *)(p)])
|
#define _xdg_utf8_char_size(p) (int) (_xdg_utf8_skip[*(unsigned char *)(p)])
|
||||||
|
|
||||||
xdg_unichar_t _xdg_utf8_to_ucs4 (const char *source);
|
xdg_unichar_t _xdg_utf8_to_ucs4 (const char *source);
|
||||||
xdg_unichar_t _xdg_ucs4_to_upper (xdg_unichar_t source);
|
xdg_unichar_t _xdg_ucs4_to_lower (xdg_unichar_t source);
|
||||||
int _xdg_utf8_validate (const char *source);
|
int _xdg_utf8_validate (const char *source);
|
||||||
const char *_xdg_get_base_name (const char *file_name);
|
const char *_xdg_get_base_name (const char *file_name);
|
||||||
|
|
||||||
|
@ -25,7 +25,10 @@
|
|||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "xdgmimemagic.h"
|
#include "xdgmimemagic.h"
|
||||||
#include "xdgmimeint.h"
|
#include "xdgmimeint.h"
|
||||||
@ -768,9 +771,11 @@ _xdg_mime_magic_read_from_file (XdgMimeMagic *mime_magic,
|
|||||||
if (magic_file == NULL)
|
if (magic_file == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fread (header, 1, 12, magic_file);
|
if (fread (header, 1, 12, magic_file) == 12)
|
||||||
|
{
|
||||||
|
if (memcmp ("MIME-Magic\0\n", header, 12) == 0)
|
||||||
|
_xdg_mime_magic_read_magic_file (mime_magic, magic_file);
|
||||||
|
}
|
||||||
|
|
||||||
if (memcmp ("MIME-Magic\0\n", header, 12) == 0)
|
|
||||||
_xdg_mime_magic_read_magic_file (mime_magic, magic_file);
|
|
||||||
fclose (magic_file);
|
fclose (magic_file);
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,10 @@
|
|||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "xdgmimeparent.h"
|
#include "xdgmimeparent.h"
|
||||||
#include "xdgmimeint.h"
|
#include "xdgmimeint.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -108,11 +111,11 @@ _xdg_mime_parent_list_lookup (XdgParentList *list,
|
|||||||
{
|
{
|
||||||
key.mime = (char *)mime;
|
key.mime = (char *)mime;
|
||||||
key.parents = NULL;
|
key.parents = NULL;
|
||||||
|
|
||||||
entry = bsearch (&key, list->parents, list->n_mimes,
|
entry = bsearch (&key, list->parents, list->n_mimes,
|
||||||
sizeof (XdgMimeParents), &parent_entry_cmp);
|
sizeof (XdgMimeParents), &parent_entry_cmp);
|
||||||
if (entry)
|
if (entry)
|
||||||
return (const char **)entry->parents;
|
return (const char **)entry->parents;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user