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>
|
||||
|
||||
* xdgmimealias.c (_xdg_mime_alias_read_from_file):
|
||||
|
@ -25,7 +25,10 @@
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "xdgmime.h"
|
||||
#include "xdgmimeint.h"
|
||||
#include "xdgmimeglob.h"
|
||||
@ -529,11 +532,13 @@ xdg_mime_get_max_buffer_extents (void)
|
||||
return _xdg_mime_magic_get_buffer_extents (global_magic);
|
||||
}
|
||||
|
||||
static const char *
|
||||
unalias_mime_type (const char *mime_type)
|
||||
const char *
|
||||
xdg_mime_unalias_mime_type (const char *mime_type)
|
||||
{
|
||||
const char *lookup;
|
||||
|
||||
xdg_mime_init ();
|
||||
|
||||
if ((lookup = _xdg_mime_alias_list_lookup (alias_list, mime_type)) != NULL)
|
||||
return lookup;
|
||||
|
||||
@ -548,8 +553,8 @@ xdg_mime_mime_type_equal (const char *mime_a,
|
||||
|
||||
xdg_mime_init ();
|
||||
|
||||
unalias_a = unalias_mime_type (mime_a);
|
||||
unalias_b = unalias_mime_type (mime_b);
|
||||
unalias_a = xdg_mime_unalias_mime_type (mime_a);
|
||||
unalias_b = xdg_mime_unalias_mime_type (mime_b);
|
||||
|
||||
if (strcmp (unalias_a, unalias_b) == 0)
|
||||
return 1;
|
||||
@ -599,8 +604,8 @@ xdg_mime_mime_type_subclass (const char *mime,
|
||||
|
||||
xdg_mime_init ();
|
||||
|
||||
umime = unalias_mime_type (mime);
|
||||
ubase = unalias_mime_type (base);
|
||||
umime = xdg_mime_unalias_mime_type (mime);
|
||||
ubase = xdg_mime_unalias_mime_type (base);
|
||||
|
||||
if (strcmp (umime, ubase) == 0)
|
||||
return 1;
|
||||
@ -633,6 +638,18 @@ xdg_mime_mime_type_subclass (const char *mime,
|
||||
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
|
||||
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_is_valid_mime_type XDG_ENTRY(is_valid_mime_type)
|
||||
#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_get_max_buffer_extents XDG_ENTRY(get_max_buffer_extents)
|
||||
#define xdg_mime_shutdown XDG_ENTRY(shutdown)
|
||||
#define xdg_mime_register_reload_callback XDG_ENTRY(register_reload_callback)
|
||||
#define xdg_mime_remove_callback XDG_ENTRY(remove_callback)
|
||||
#define xdg_mime_type_unknown XDG_ENTRY(type_unknown)
|
||||
#define xdg_mime_dump XDG_ENTRY(dump)
|
||||
#endif
|
||||
|
||||
extern const char *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,
|
||||
size_t len);
|
||||
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);
|
||||
int xdg_mime_is_valid_mime_type (const char *mime_type);
|
||||
int xdg_mime_mime_type_equal (const char *mime_a,
|
||||
const char *mime_b);
|
||||
int xdg_mime_media_type_equal (const char *mime_a,
|
||||
const char *mime_b);
|
||||
int xdg_mime_mime_type_subclass (const char *mime_a,
|
||||
const char *mime_b);
|
||||
int xdg_mime_get_max_buffer_extents (void);
|
||||
void xdg_mime_shutdown (void);
|
||||
void xdg_mime_dump (void);
|
||||
int xdg_mime_register_reload_callback (XdgMimeCallback callback,
|
||||
void *data,
|
||||
XdgMimeDestroy destroy);
|
||||
void xdg_mime_remove_callback (int callback_id);
|
||||
const char *xdg_mime_get_mime_type_for_data (const void *data,
|
||||
size_t len);
|
||||
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);
|
||||
int xdg_mime_is_valid_mime_type (const char *mime_type);
|
||||
int xdg_mime_mime_type_equal (const char *mime_a,
|
||||
const char *mime_b);
|
||||
int xdg_mime_media_type_equal (const char *mime_a,
|
||||
const char *mime_b);
|
||||
int xdg_mime_mime_type_subclass (const char *mime_a,
|
||||
const char *mime_b);
|
||||
const char **xdg_mime_get_mime_parents (const char *mime);
|
||||
const char *xdg_mime_unalias_mime_type (const char *mime);
|
||||
int xdg_mime_get_max_buffer_extents (void);
|
||||
void xdg_mime_shutdown (void);
|
||||
void xdg_mime_dump (void);
|
||||
int xdg_mime_register_reload_callback (XdgMimeCallback callback,
|
||||
void *data,
|
||||
XdgMimeDestroy destroy);
|
||||
void xdg_mime_remove_callback (int callback_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -25,7 +25,10 @@
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "xdgmimealias.h"
|
||||
#include "xdgmimeint.h"
|
||||
#include <stdlib.h>
|
||||
@ -103,11 +106,11 @@ _xdg_mime_alias_list_lookup (XdgAliasList *list,
|
||||
{
|
||||
key.alias = (char *)alias;
|
||||
key.mime_type = 0;
|
||||
|
||||
|
||||
entry = bsearch (&key, list->aliases, list->n_aliases,
|
||||
sizeof (XdgAlias), alias_entry_cmp);
|
||||
if (entry)
|
||||
return entry->mime_type;
|
||||
return entry->mime_type;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
@ -25,7 +25,10 @@
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "xdgmimeglob.h"
|
||||
#include "xdgmimeint.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);
|
||||
if (ignore_case)
|
||||
character = _xdg_ucs4_to_upper(character);
|
||||
character = _xdg_ucs4_to_lower(character);
|
||||
|
||||
for (node = glob_hash_node;
|
||||
node && character >= (ignore_case?_xdg_ucs4_to_upper (node->character):node->character);
|
||||
node = node->next)
|
||||
for (node = glob_hash_node; 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);
|
||||
if (*file_name == '\000')
|
||||
|
@ -25,7 +25,10 @@
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "xdgmimeint.h"
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
@ -118,12 +121,12 @@ _xdg_utf8_to_ucs4(const char *source)
|
||||
/* hullo. this is great code. don't rewrite it */
|
||||
|
||||
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 */
|
||||
/* CaseFolding-3.2.0.txt has a table of rules. */
|
||||
if ((source & 0xFF) == source)
|
||||
return (xdg_unichar_t) toupper ((char) source);
|
||||
return (xdg_unichar_t) tolower ((unsigned char) source);
|
||||
return source;
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ typedef unsigned int xdg_uint32_t;
|
||||
#ifdef XDG_PREFIX
|
||||
#define _xdg_utf8_skip XDG_ENTRY(utf8_skip)
|
||||
#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_get_base_name XDG_ENTRY(get_ase_name)
|
||||
#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)])
|
||||
|
||||
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);
|
||||
const char *_xdg_get_base_name (const char *file_name);
|
||||
|
||||
|
@ -25,7 +25,10 @@
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include "xdgmimemagic.h"
|
||||
#include "xdgmimeint.h"
|
||||
@ -768,9 +771,11 @@ _xdg_mime_magic_read_from_file (XdgMimeMagic *mime_magic,
|
||||
if (magic_file == NULL)
|
||||
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);
|
||||
}
|
||||
|
@ -25,7 +25,10 @@
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "xdgmimeparent.h"
|
||||
#include "xdgmimeint.h"
|
||||
#include <stdlib.h>
|
||||
@ -108,11 +111,11 @@ _xdg_mime_parent_list_lookup (XdgParentList *list,
|
||||
{
|
||||
key.mime = (char *)mime;
|
||||
key.parents = NULL;
|
||||
|
||||
|
||||
entry = bsearch (&key, list->parents, list->n_mimes,
|
||||
sizeof (XdgMimeParents), &parent_entry_cmp);
|
||||
if (entry)
|
||||
return (const char **)entry->parents;
|
||||
return (const char **)entry->parents;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user