mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
Update gio/xdgmime with commit 722325f of xdgmime project
This commit is contained in:
parent
1176835ce3
commit
3d2ac608de
@ -12,7 +12,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ -20,10 +20,14 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "xdgmime.h"
|
||||
#include "xdgmimeint.h"
|
||||
@ -56,8 +60,6 @@ static XdgCallbackList *callback_list = NULL;
|
||||
static XdgIconList *icon_list = NULL;
|
||||
static XdgIconList *generic_icon_list = NULL;
|
||||
|
||||
static char **xdg_dirs = NULL; /* NULL terminated */
|
||||
|
||||
XdgMimeCache **_caches = NULL;
|
||||
static int n_caches = 0;
|
||||
|
||||
@ -141,8 +143,8 @@ xdg_mime_init_from_directory (const char *directory)
|
||||
|
||||
assert (directory != NULL);
|
||||
|
||||
file_name = malloc (strlen (directory) + strlen ("/mime.cache") + 1);
|
||||
strcpy (file_name, directory); strcat (file_name, "/mime.cache");
|
||||
file_name = malloc (strlen (directory) + strlen ("/mime/mime.cache") + 1);
|
||||
strcpy (file_name, directory); strcat (file_name, "/mime/mime.cache");
|
||||
if (stat (file_name, &st) == 0)
|
||||
{
|
||||
XdgMimeCache *cache = _xdg_mime_cache_new_from_file (file_name);
|
||||
@ -161,8 +163,8 @@ xdg_mime_init_from_directory (const char *directory)
|
||||
}
|
||||
free (file_name);
|
||||
|
||||
file_name = malloc (strlen (directory) + strlen ("/globs2") + 1);
|
||||
strcpy (file_name, directory); strcat (file_name, "/globs2");
|
||||
file_name = malloc (strlen (directory) + strlen ("/mime/globs2") + 1);
|
||||
strcpy (file_name, directory); strcat (file_name, "/mime/globs2");
|
||||
if (stat (file_name, &st) == 0)
|
||||
{
|
||||
_xdg_mime_glob_read_from_file (global_hash, file_name, TRUE);
|
||||
@ -171,8 +173,8 @@ xdg_mime_init_from_directory (const char *directory)
|
||||
else
|
||||
{
|
||||
free (file_name);
|
||||
file_name = malloc (strlen (directory) + strlen ("/globs") + 1);
|
||||
strcpy (file_name, directory); strcat (file_name, "/globs");
|
||||
file_name = malloc (strlen (directory) + strlen ("/mime/globs") + 1);
|
||||
strcpy (file_name, directory); strcat (file_name, "/mime/globs");
|
||||
if (stat (file_name, &st) == 0)
|
||||
{
|
||||
_xdg_mime_glob_read_from_file (global_hash, file_name, FALSE);
|
||||
@ -184,8 +186,8 @@ xdg_mime_init_from_directory (const char *directory)
|
||||
}
|
||||
}
|
||||
|
||||
file_name = malloc (strlen (directory) + strlen ("/magic") + 1);
|
||||
strcpy (file_name, directory); strcat (file_name, "/magic");
|
||||
file_name = malloc (strlen (directory) + strlen ("/mime/magic") + 1);
|
||||
strcpy (file_name, directory); strcat (file_name, "/mime/magic");
|
||||
if (stat (file_name, &st) == 0)
|
||||
{
|
||||
_xdg_mime_magic_read_from_file (global_magic, file_name);
|
||||
@ -196,81 +198,69 @@ xdg_mime_init_from_directory (const char *directory)
|
||||
free (file_name);
|
||||
}
|
||||
|
||||
file_name = malloc (strlen (directory) + strlen ("/aliases") + 1);
|
||||
strcpy (file_name, directory); strcat (file_name, "/aliases");
|
||||
file_name = malloc (strlen (directory) + strlen ("/mime/aliases") + 1);
|
||||
strcpy (file_name, directory); strcat (file_name, "/mime/aliases");
|
||||
_xdg_mime_alias_read_from_file (alias_list, file_name);
|
||||
free (file_name);
|
||||
|
||||
file_name = malloc (strlen (directory) + strlen ("/subclasses") + 1);
|
||||
strcpy (file_name, directory); strcat (file_name, "/subclasses");
|
||||
file_name = malloc (strlen (directory) + strlen ("/mime/subclasses") + 1);
|
||||
strcpy (file_name, directory); strcat (file_name, "/mime/subclasses");
|
||||
_xdg_mime_parent_read_from_file (parent_list, file_name);
|
||||
free (file_name);
|
||||
|
||||
file_name = malloc (strlen (directory) + strlen ("/icons") + 1);
|
||||
strcpy (file_name, directory); strcat (file_name, "/icons");
|
||||
file_name = malloc (strlen (directory) + strlen ("/mime/icons") + 1);
|
||||
strcpy (file_name, directory); strcat (file_name, "/mime/icons");
|
||||
_xdg_mime_icon_read_from_file (icon_list, file_name);
|
||||
free (file_name);
|
||||
|
||||
file_name = malloc (strlen (directory) + strlen ("/generic-icons") + 1);
|
||||
strcpy (file_name, directory); strcat (file_name, "/generic-icons");
|
||||
file_name = malloc (strlen (directory) + strlen ("/mime/generic-icons") + 1);
|
||||
strcpy (file_name, directory); strcat (file_name, "/mime/generic-icons");
|
||||
_xdg_mime_icon_read_from_file (generic_icon_list, file_name);
|
||||
free (file_name);
|
||||
|
||||
return FALSE; /* Keep processing */
|
||||
}
|
||||
|
||||
/* Set @xdg_dirs from the environment. It must not have been set already. */
|
||||
/* Runs a command on all the directories in the search path */
|
||||
static void
|
||||
xdg_init_dirs (void)
|
||||
xdg_run_command_on_dirs (XdgDirectoryFunc func,
|
||||
void *user_data)
|
||||
{
|
||||
const char *xdg_data_home, *home, *xdg_data_dirs;
|
||||
const char *xdg_data_home;
|
||||
const char *xdg_data_dirs;
|
||||
const char *ptr;
|
||||
size_t n_dirs = 0;
|
||||
size_t i, current_dir;
|
||||
|
||||
assert (xdg_dirs == NULL);
|
||||
|
||||
xdg_data_home = getenv ("XDG_DATA_HOME");
|
||||
home = getenv ("HOME");
|
||||
xdg_data_dirs = getenv ("XDG_DATA_DIRS");
|
||||
if (xdg_data_home)
|
||||
{
|
||||
if ((func) (xdg_data_home, user_data))
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *home;
|
||||
|
||||
home = getenv ("HOME");
|
||||
if (home != NULL)
|
||||
{
|
||||
char *guessed_xdg_home;
|
||||
int stop_processing;
|
||||
|
||||
guessed_xdg_home = malloc (strlen (home) + strlen ("/.local/share/") + 1);
|
||||
strcpy (guessed_xdg_home, home);
|
||||
strcat (guessed_xdg_home, "/.local/share/");
|
||||
stop_processing = (func) (guessed_xdg_home, user_data);
|
||||
free (guessed_xdg_home);
|
||||
|
||||
if (stop_processing)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
xdg_data_dirs = getenv ("XDG_DATA_DIRS");
|
||||
if (xdg_data_dirs == NULL)
|
||||
xdg_data_dirs = "/usr/local/share/:/usr/share/";
|
||||
|
||||
/* Work out how many dirs we’re dealing with. */
|
||||
if (xdg_data_home != NULL || home != NULL)
|
||||
n_dirs++;
|
||||
n_dirs++; /* initial entry in @xdg_data_dirs */
|
||||
for (i = 0; xdg_data_dirs[i] != '\0'; i++)
|
||||
if (xdg_data_dirs[i] == ':')
|
||||
n_dirs++;
|
||||
|
||||
xdg_dirs = calloc (n_dirs + 1 /* NULL terminator */, sizeof (char *));
|
||||
current_dir = 0;
|
||||
|
||||
/* $XDG_DATA_HOME */
|
||||
if (xdg_data_home != NULL)
|
||||
{
|
||||
char *mime_subdir;
|
||||
|
||||
mime_subdir = malloc (strlen (xdg_data_home) + strlen ("/mime/") + 1);
|
||||
strcpy (mime_subdir, xdg_data_home);
|
||||
strcat (mime_subdir, "/mime/");
|
||||
|
||||
xdg_dirs[current_dir++] = mime_subdir;
|
||||
}
|
||||
else if (home != NULL)
|
||||
{
|
||||
char *guessed_xdg_home;
|
||||
|
||||
guessed_xdg_home = malloc (strlen (home) + strlen ("/.local/share/mime/") + 1);
|
||||
strcpy (guessed_xdg_home, home);
|
||||
strcat (guessed_xdg_home, "/.local/share/mime/");
|
||||
|
||||
xdg_dirs[current_dir++] = guessed_xdg_home;
|
||||
}
|
||||
|
||||
/* $XDG_DATA_DIRS */
|
||||
ptr = xdg_data_dirs;
|
||||
|
||||
while (*ptr != '\000')
|
||||
@ -278,83 +268,33 @@ xdg_init_dirs (void)
|
||||
const char *end_ptr;
|
||||
char *dir;
|
||||
int len;
|
||||
int stop_processing;
|
||||
|
||||
end_ptr = ptr;
|
||||
while (*end_ptr != ':' && *end_ptr != '\000')
|
||||
end_ptr ++;
|
||||
end_ptr ++;
|
||||
|
||||
if (end_ptr == ptr)
|
||||
{
|
||||
ptr++;
|
||||
continue;
|
||||
}
|
||||
{
|
||||
ptr++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (*end_ptr == ':')
|
||||
len = end_ptr - ptr;
|
||||
len = end_ptr - ptr;
|
||||
else
|
||||
len = end_ptr - ptr + 1;
|
||||
dir = malloc (len + strlen ("/mime/") + 1);
|
||||
len = end_ptr - ptr + 1;
|
||||
dir = malloc (len + 1);
|
||||
strncpy (dir, ptr, len);
|
||||
dir[len] = '\0';
|
||||
strcat (dir, "/mime/");
|
||||
stop_processing = (func) (dir, user_data);
|
||||
free (dir);
|
||||
|
||||
xdg_dirs[current_dir++] = dir;
|
||||
if (stop_processing)
|
||||
return;
|
||||
|
||||
ptr = end_ptr;
|
||||
}
|
||||
|
||||
/* NULL terminator */
|
||||
xdg_dirs[current_dir] = NULL;
|
||||
|
||||
need_reread = TRUE;
|
||||
}
|
||||
|
||||
/* Runs a command on all the directories in the search path (@xdg_dirs). */
|
||||
static void
|
||||
xdg_run_command_on_dirs (XdgDirectoryFunc func,
|
||||
void *user_data)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (xdg_dirs == NULL)
|
||||
xdg_init_dirs ();
|
||||
|
||||
for (i = 0; xdg_dirs[i] != NULL; i++)
|
||||
{
|
||||
if ((func) (xdg_dirs[i], user_data))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Allows the calling code to override the directories used by xdgmime, without
|
||||
* having to change environment variables in a running process (which is not
|
||||
* thread safe). This is intended to be used by tests. The changes will be
|
||||
* picked up by xdg_mime_init() next time public API is called.
|
||||
*
|
||||
* This will set @xdg_dirs. Directories in @dirs must be complete, including
|
||||
* the conventional `/mime` subdirectory. This is to allow tests to override
|
||||
* them without the need to create a subdirectory. */
|
||||
void
|
||||
xdg_mime_set_dirs (const char * const *dirs)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; xdg_dirs != NULL && xdg_dirs[i] != NULL; i++)
|
||||
free (xdg_dirs[i]);
|
||||
if (xdg_dirs != NULL)
|
||||
free (xdg_dirs[i]);
|
||||
xdg_dirs = NULL;
|
||||
|
||||
if (dirs != NULL)
|
||||
{
|
||||
for (i = 0; dirs[i] != NULL; i++);
|
||||
xdg_dirs = calloc (i + 1 /* NULL terminator */, sizeof (char*));
|
||||
for (i = 0; dirs[i] != NULL; i++)
|
||||
xdg_dirs[i] = strdup (dirs[i]);
|
||||
xdg_dirs[i] = NULL;
|
||||
}
|
||||
|
||||
need_reread = TRUE;
|
||||
}
|
||||
|
||||
/* Checks file_path to make sure it has the same mtime as last time it was
|
||||
@ -408,8 +348,8 @@ xdg_check_dir (const char *directory,
|
||||
assert (directory != NULL);
|
||||
|
||||
/* Check the mime.cache file */
|
||||
file_name = malloc (strlen (directory) + strlen ("/mime.cache") + 1);
|
||||
strcpy (file_name, directory); strcat (file_name, "/mime.cache");
|
||||
file_name = malloc (strlen (directory) + strlen ("/mime/mime.cache") + 1);
|
||||
strcpy (file_name, directory); strcat (file_name, "/mime/mime.cache");
|
||||
invalid = xdg_check_file (file_name, &exists);
|
||||
free (file_name);
|
||||
if (invalid)
|
||||
@ -423,8 +363,8 @@ xdg_check_dir (const char *directory,
|
||||
}
|
||||
|
||||
/* Check the globs file */
|
||||
file_name = malloc (strlen (directory) + strlen ("/globs") + 1);
|
||||
strcpy (file_name, directory); strcat (file_name, "/globs");
|
||||
file_name = malloc (strlen (directory) + strlen ("/mime/globs") + 1);
|
||||
strcpy (file_name, directory); strcat (file_name, "/mime/globs");
|
||||
invalid = xdg_check_file (file_name, NULL);
|
||||
free (file_name);
|
||||
if (invalid)
|
||||
@ -434,8 +374,8 @@ xdg_check_dir (const char *directory,
|
||||
}
|
||||
|
||||
/* Check the magic file */
|
||||
file_name = malloc (strlen (directory) + strlen ("/magic") + 1);
|
||||
strcpy (file_name, directory); strcat (file_name, "/magic");
|
||||
file_name = malloc (strlen (directory) + strlen ("/mime/magic") + 1);
|
||||
strcpy (file_name, directory); strcat (file_name, "/mime/magic");
|
||||
invalid = xdg_check_file (file_name, NULL);
|
||||
free (file_name);
|
||||
if (invalid)
|
||||
@ -549,8 +489,6 @@ xdg_mime_get_mime_type_for_data (const void *data,
|
||||
return _xdg_binary_or_text_fallback(data, len);
|
||||
}
|
||||
|
||||
#ifdef NOT_USED_IN_GIO
|
||||
|
||||
const char *
|
||||
xdg_mime_get_mime_type_for_file (const char *file_name,
|
||||
struct stat *statbuf)
|
||||
@ -621,13 +559,13 @@ xdg_mime_get_mime_type_for_file (const char *file_name,
|
||||
mime_type = _xdg_mime_magic_lookup_data (global_magic, data, bytes_read, NULL,
|
||||
mime_types, n);
|
||||
|
||||
if (!mime_type)
|
||||
mime_type = _xdg_binary_or_text_fallback (data, bytes_read);
|
||||
|
||||
free (data);
|
||||
fclose (file);
|
||||
|
||||
if (mime_type)
|
||||
return mime_type;
|
||||
|
||||
return _xdg_binary_or_text_fallback(data, bytes_read);
|
||||
return mime_type;
|
||||
}
|
||||
|
||||
const char *
|
||||
@ -646,8 +584,6 @@ xdg_mime_get_mime_type_from_file_name (const char *file_name)
|
||||
return XDG_MIME_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int
|
||||
xdg_mime_get_mime_types_from_file_name (const char *file_name,
|
||||
const char *mime_types[],
|
||||
@ -661,8 +597,6 @@ xdg_mime_get_mime_types_from_file_name (const char *file_name,
|
||||
return _xdg_glob_hash_lookup_file_name (global_hash, file_name, mime_types, n_mime_types);
|
||||
}
|
||||
|
||||
#ifdef NOT_USED_IN_GIO
|
||||
|
||||
int
|
||||
xdg_mime_is_valid_mime_type (const char *mime_type)
|
||||
{
|
||||
@ -671,8 +605,6 @@ xdg_mime_is_valid_mime_type (const char *mime_type)
|
||||
return _xdg_utf8_validate (mime_type);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void
|
||||
xdg_mime_shutdown (void)
|
||||
{
|
||||
@ -888,19 +820,14 @@ xdg_mime_mime_type_subclass (const char *mime,
|
||||
char **
|
||||
xdg_mime_list_mime_parents (const char *mime)
|
||||
{
|
||||
const char *umime;
|
||||
const char **parents;
|
||||
char **result;
|
||||
int i, n;
|
||||
|
||||
xdg_mime_init ();
|
||||
|
||||
if (_caches)
|
||||
return _xdg_mime_cache_list_mime_parents (mime);
|
||||
|
||||
umime = _xdg_mime_unalias_mime_type (mime);
|
||||
|
||||
parents = _xdg_mime_parent_list_lookup (parent_list, umime);
|
||||
parents = xdg_mime_get_mime_parents (mime);
|
||||
|
||||
if (!parents)
|
||||
return NULL;
|
||||
@ -914,8 +841,6 @@ xdg_mime_list_mime_parents (const char *mime)
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef NOT_USED_IN_GIO
|
||||
|
||||
const char **
|
||||
xdg_mime_get_mime_parents (const char *mime)
|
||||
{
|
||||
@ -945,7 +870,6 @@ xdg_mime_dump (void)
|
||||
_xdg_mime_cache_glob_dump ();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Registers a function to be called every time the mime database reloads its files
|
||||
*/
|
||||
@ -973,8 +897,6 @@ xdg_mime_register_reload_callback (XdgMimeCallback callback,
|
||||
return callback_id - 1;
|
||||
}
|
||||
|
||||
#ifdef NOT_USED_IN_GIO
|
||||
|
||||
void
|
||||
xdg_mime_remove_callback (int callback_id)
|
||||
{
|
||||
@ -1000,8 +922,6 @@ xdg_mime_remove_callback (int callback_id)
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
const char *
|
||||
xdg_mime_get_icon (const char *mime)
|
||||
{
|
||||
|
@ -12,7 +12,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ -20,7 +20,9 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
|
||||
@ -71,9 +73,9 @@ typedef void (*XdgMimeDestroy) (void *user_data);
|
||||
#define xdg_mime_get_icon XDG_ENTRY(get_icon)
|
||||
#define xdg_mime_get_generic_icon XDG_ENTRY(get_generic_icon)
|
||||
|
||||
#define _xdg_mime_mime_type_subclass XDG_RESERVED_ENTRY(mime_type_subclass)
|
||||
#define _xdg_mime_mime_type_equal XDG_RESERVED_ENTRY(mime_type_equal)
|
||||
#define _xdg_mime_unalias_mime_type XDG_RESERVED_ENTRY(unalias_mime_type)
|
||||
#define _xdg_mime_mime_type_subclass XDG_RESERVED_ENTRY(mime_type_subclass)
|
||||
#define _xdg_mime_unalias_mime_type XDG_RESERVED_ENTRY(unalias_mime_type)
|
||||
#endif
|
||||
|
||||
extern const char xdg_mime_type_unknown[];
|
||||
@ -86,17 +88,13 @@ extern const char xdg_mime_type_textplain[];
|
||||
const char *xdg_mime_get_mime_type_for_data (const void *data,
|
||||
size_t len,
|
||||
int *result_prio);
|
||||
#ifdef NOT_USED_IN_GIO
|
||||
const char *xdg_mime_get_mime_type_for_file (const char *file_name,
|
||||
struct stat *statbuf);
|
||||
const char *xdg_mime_get_mime_type_from_file_name (const char *file_name);
|
||||
#endif
|
||||
int xdg_mime_get_mime_types_from_file_name(const char *file_name,
|
||||
const char *mime_types[],
|
||||
int n_mime_types);
|
||||
#ifdef NOT_USED_IN_GIO
|
||||
int xdg_mime_is_valid_mime_type (const char *mime_type);
|
||||
#endif
|
||||
int xdg_mime_mime_type_equal (const char *mime_a,
|
||||
const char *mime_b);
|
||||
int xdg_mime_media_type_equal (const char *mime_a,
|
||||
@ -108,26 +106,18 @@ int xdg_mime_mime_type_subclass (const char *mime_a,
|
||||
* instead, but notice that that function expects you to free
|
||||
* the array it returns.
|
||||
*/
|
||||
#ifdef NOT_USED_IN_GIO
|
||||
const char **xdg_mime_get_mime_parents (const char *mime);
|
||||
#endif
|
||||
char ** xdg_mime_list_mime_parents (const char *mime);
|
||||
const char *xdg_mime_unalias_mime_type (const char *mime);
|
||||
const char *xdg_mime_get_icon (const char *mime);
|
||||
const char *xdg_mime_get_generic_icon (const char *mime);
|
||||
int xdg_mime_get_max_buffer_extents (void);
|
||||
void xdg_mime_shutdown (void);
|
||||
#ifdef NOT_USED_IN_GIO
|
||||
void xdg_mime_dump (void);
|
||||
#endif
|
||||
int xdg_mime_register_reload_callback (XdgMimeCallback callback,
|
||||
void *data,
|
||||
XdgMimeDestroy destroy);
|
||||
#ifdef NOT_USED_IN_GIO
|
||||
void xdg_mime_remove_callback (int callback_id);
|
||||
#endif
|
||||
|
||||
void xdg_mime_set_dirs (const char * const *dirs);
|
||||
|
||||
/* Private versions of functions that don't call xdg_mime_init () */
|
||||
int _xdg_mime_mime_type_equal (const char *mime_a,
|
||||
|
@ -12,7 +12,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ -20,10 +20,14 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "xdgmimealias.h"
|
||||
#include "xdgmimeint.h"
|
||||
@ -161,8 +165,6 @@ _xdg_mime_alias_read_from_file (XdgAliasList *list,
|
||||
}
|
||||
|
||||
|
||||
#ifdef NOT_USED_IN_GIO
|
||||
|
||||
void
|
||||
_xdg_mime_alias_list_dump (XdgAliasList *list)
|
||||
{
|
||||
@ -179,4 +181,4 @@ _xdg_mime_alias_list_dump (XdgAliasList *list)
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ -20,7 +20,9 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __XDG_MIME_ALIAS_H__
|
||||
@ -44,7 +46,6 @@ XdgAliasList *_xdg_mime_alias_list_new (void);
|
||||
void _xdg_mime_alias_list_free (XdgAliasList *list);
|
||||
const char *_xdg_mime_alias_list_lookup (XdgAliasList *list,
|
||||
const char *alias);
|
||||
#ifdef NOT_USED_IN_GIO
|
||||
void _xdg_mime_alias_list_dump (XdgAliasList *list);
|
||||
#endif
|
||||
|
||||
#endif /* __XDG_MIME_ALIAS_H__ */
|
||||
|
@ -11,7 +11,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ -19,10 +19,14 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -39,7 +43,7 @@
|
||||
#ifdef HAVE_MMAP
|
||||
#include <sys/mman.h>
|
||||
#else
|
||||
#warning Building xdgmime without MMAP support. Binary "mime.info" cache files will not be used.
|
||||
#warning Building xdgmime without MMAP support. Binary "mime.cache" files will not be used.
|
||||
#endif
|
||||
|
||||
#include <sys/stat.h>
|
||||
@ -117,9 +121,9 @@ _xdg_mime_cache_new_from_file (const char *file_name)
|
||||
int minor;
|
||||
|
||||
/* Open the file and map it into memory */
|
||||
do
|
||||
do {
|
||||
fd = open (file_name, O_RDONLY|_O_BINARY, 0);
|
||||
while (fd == -1 && errno == EINTR);
|
||||
} while (fd == -1 && errno == EINTR);
|
||||
|
||||
if (fd < 0)
|
||||
return NULL;
|
||||
@ -153,12 +157,6 @@ _xdg_mime_cache_new_from_file (const char *file_name)
|
||||
if (fd != -1)
|
||||
close (fd);
|
||||
|
||||
#else /* HAVE_MMAP */
|
||||
cache = (XdgMimeCache *) malloc (sizeof (XdgMimeCache));
|
||||
cache->minor = 0;
|
||||
cache->ref_count = 1;
|
||||
cache->buffer = NULL;
|
||||
cache->size = 0;
|
||||
#endif /* HAVE_MMAP */
|
||||
|
||||
return cache;
|
||||
@ -176,7 +174,7 @@ cache_magic_matchlet_compare_to_data (XdgMimeCache *cache,
|
||||
xdg_uint32_t data_offset = GET_UINT32 (cache->buffer, offset + 16);
|
||||
xdg_uint32_t mask_offset = GET_UINT32 (cache->buffer, offset + 20);
|
||||
|
||||
int i, j;
|
||||
xdg_uint32_t i, j;
|
||||
|
||||
for (i = range_start; i < range_start + range_length; i++)
|
||||
{
|
||||
@ -199,16 +197,9 @@ cache_magic_matchlet_compare_to_data (XdgMimeCache *cache,
|
||||
}
|
||||
else
|
||||
{
|
||||
for (j = 0; j < data_length; j++)
|
||||
{
|
||||
if (((unsigned char *)cache->buffer)[data_offset + j] != ((unsigned char *) data)[j + i])
|
||||
{
|
||||
valid_matchlet = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
valid_matchlet = memcmp(cache->buffer + data_offset, (unsigned char *)data + i, data_length) == 0;
|
||||
}
|
||||
|
||||
|
||||
if (valid_matchlet)
|
||||
return TRUE;
|
||||
}
|
||||
@ -225,7 +216,7 @@ cache_magic_matchlet_compare (XdgMimeCache *cache,
|
||||
xdg_uint32_t n_children = GET_UINT32 (cache->buffer, offset + 24);
|
||||
xdg_uint32_t child_offset = GET_UINT32 (cache->buffer, offset + 28);
|
||||
|
||||
int i;
|
||||
xdg_uint32_t i;
|
||||
|
||||
if (cache_magic_matchlet_compare_to_data (cache, offset, data, len))
|
||||
{
|
||||
@ -255,7 +246,7 @@ cache_magic_compare_to_data (XdgMimeCache *cache,
|
||||
xdg_uint32_t n_matchlets = GET_UINT32 (cache->buffer, offset + 8);
|
||||
xdg_uint32_t matchlet_offset = GET_UINT32 (cache->buffer, offset + 12);
|
||||
|
||||
int i;
|
||||
xdg_uint32_t i;
|
||||
|
||||
for (i = 0; i < n_matchlets; i++)
|
||||
{
|
||||
@ -275,15 +266,13 @@ 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)
|
||||
int *prio)
|
||||
{
|
||||
xdg_uint32_t list_offset;
|
||||
xdg_uint32_t n_entries;
|
||||
xdg_uint32_t offset;
|
||||
|
||||
int j, n;
|
||||
xdg_uint32_t j;
|
||||
|
||||
*prio = 0;
|
||||
|
||||
@ -299,21 +288,6 @@ cache_magic_lookup_data (XdgMimeCache *cache,
|
||||
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;
|
||||
@ -328,16 +302,10 @@ cache_alias_lookup (const char *alias)
|
||||
for (i = 0; _caches[i]; i++)
|
||||
{
|
||||
XdgMimeCache *cache = _caches[i];
|
||||
xdg_uint32_t list_offset;
|
||||
xdg_uint32_t n_entries;
|
||||
xdg_uint32_t list_offset = GET_UINT32 (cache->buffer, 4);
|
||||
xdg_uint32_t n_entries = GET_UINT32 (cache->buffer, list_offset);
|
||||
xdg_uint32_t offset;
|
||||
|
||||
if (cache->buffer == NULL)
|
||||
continue;
|
||||
|
||||
list_offset = GET_UINT32 (cache->buffer, 4);
|
||||
n_entries = GET_UINT32 (cache->buffer, list_offset);
|
||||
|
||||
min = 0;
|
||||
max = n_entries - 1;
|
||||
while (max >= min)
|
||||
@ -380,16 +348,10 @@ cache_glob_lookup_literal (const char *file_name,
|
||||
for (i = 0; _caches[i]; i++)
|
||||
{
|
||||
XdgMimeCache *cache = _caches[i];
|
||||
xdg_uint32_t list_offset;
|
||||
xdg_uint32_t n_entries;
|
||||
xdg_uint32_t list_offset = GET_UINT32 (cache->buffer, 12);
|
||||
xdg_uint32_t n_entries = GET_UINT32 (cache->buffer, list_offset);
|
||||
xdg_uint32_t offset;
|
||||
|
||||
if (cache->buffer == NULL)
|
||||
continue;
|
||||
|
||||
list_offset = GET_UINT32 (cache->buffer, 12);
|
||||
n_entries = GET_UINT32 (cache->buffer, list_offset);
|
||||
|
||||
min = 0;
|
||||
max = n_entries - 1;
|
||||
while (max >= min)
|
||||
@ -428,50 +390,49 @@ cache_glob_lookup_literal (const char *file_name,
|
||||
static int
|
||||
cache_glob_lookup_fnmatch (const char *file_name,
|
||||
MimeWeight mime_types[],
|
||||
int n_mime_types)
|
||||
int n_mime_types,
|
||||
int case_sensitive_check)
|
||||
{
|
||||
const char *mime_type;
|
||||
const char *ptr;
|
||||
|
||||
int i, j, n;
|
||||
int i, n;
|
||||
xdg_uint32_t j;
|
||||
|
||||
n = 0;
|
||||
for (i = 0; _caches[i]; i++)
|
||||
{
|
||||
XdgMimeCache *cache = _caches[i];
|
||||
|
||||
xdg_uint32_t list_offset;
|
||||
xdg_uint32_t n_entries;
|
||||
|
||||
if (cache->buffer == NULL)
|
||||
continue;
|
||||
|
||||
list_offset = GET_UINT32 (cache->buffer, 20);
|
||||
n_entries = GET_UINT32 (cache->buffer, list_offset);
|
||||
xdg_uint32_t list_offset = GET_UINT32 (cache->buffer, 20);
|
||||
xdg_uint32_t n_entries = GET_UINT32 (cache->buffer, list_offset);
|
||||
|
||||
for (j = 0; j < n_entries && n < n_mime_types; j++)
|
||||
{
|
||||
xdg_uint32_t offset = GET_UINT32 (cache->buffer, list_offset + 4 + 12 * j);
|
||||
xdg_uint32_t mimetype_offset = GET_UINT32 (cache->buffer, list_offset + 4 + 12 * j + 4);
|
||||
int weight = GET_UINT32 (cache->buffer, list_offset + 4 + 12 * j + 8);
|
||||
int case_sensitive = weight & 0x100;
|
||||
weight = weight & 0xff;
|
||||
ptr = cache->buffer + offset;
|
||||
mime_type = cache->buffer + mimetype_offset;
|
||||
|
||||
/* FIXME: Not UTF-8 safe */
|
||||
if (fnmatch (ptr, file_name, 0) == 0)
|
||||
if (case_sensitive_check || !case_sensitive)
|
||||
{
|
||||
mime_types[n].mime = mime_type;
|
||||
mime_types[n].weight = weight;
|
||||
n++;
|
||||
/* FIXME: Not UTF-8 safe */
|
||||
if (fnmatch (ptr, file_name, 0) == 0)
|
||||
{
|
||||
mime_types[n].mime = mime_type;
|
||||
mime_types[n].weight = weight;
|
||||
n++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (n == n_mime_types)
|
||||
break;
|
||||
if (n > 0)
|
||||
return n;
|
||||
}
|
||||
|
||||
return n;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
@ -492,7 +453,8 @@ cache_glob_node_lookup_suffix (XdgMimeCache *cache,
|
||||
int weight;
|
||||
int case_sensitive;
|
||||
|
||||
int min, max, mid, n, i;
|
||||
xdg_uint32_t i;
|
||||
int min, max, mid, n;
|
||||
|
||||
character = file_name[len - 1];
|
||||
|
||||
@ -562,33 +524,25 @@ cache_glob_lookup_suffix (const char *file_name,
|
||||
{
|
||||
int i, n;
|
||||
|
||||
n = 0;
|
||||
for (i = 0; _caches[i]; i++)
|
||||
{
|
||||
XdgMimeCache *cache = _caches[i];
|
||||
|
||||
xdg_uint32_t list_offset;
|
||||
xdg_uint32_t n_entries;
|
||||
xdg_uint32_t offset;
|
||||
xdg_uint32_t list_offset = GET_UINT32 (cache->buffer, 16);
|
||||
xdg_uint32_t n_entries = GET_UINT32 (cache->buffer, list_offset);
|
||||
xdg_uint32_t offset = GET_UINT32 (cache->buffer, list_offset + 4);
|
||||
|
||||
if (cache->buffer == NULL)
|
||||
continue;
|
||||
|
||||
list_offset = GET_UINT32 (cache->buffer, 16);
|
||||
n_entries = GET_UINT32 (cache->buffer, list_offset);
|
||||
offset = GET_UINT32 (cache->buffer, list_offset + 4);
|
||||
|
||||
n += cache_glob_node_lookup_suffix (cache,
|
||||
n_entries, offset,
|
||||
file_name, len,
|
||||
ignore_case,
|
||||
mime_types + n,
|
||||
n_mime_types - n);
|
||||
if (n == n_mime_types)
|
||||
break;
|
||||
n = cache_glob_node_lookup_suffix (cache,
|
||||
n_entries, offset,
|
||||
file_name, len,
|
||||
ignore_case,
|
||||
mime_types,
|
||||
n_mime_types);
|
||||
if (n > 0)
|
||||
return n;
|
||||
}
|
||||
|
||||
return n;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int compare_mime_weight (const void *a, const void *b)
|
||||
@ -616,35 +570,7 @@ ascii_tolower (const char *str)
|
||||
}
|
||||
|
||||
static int
|
||||
filter_out_dupes (MimeWeight mimes[], int n_mimes)
|
||||
{
|
||||
int last;
|
||||
int i, j;
|
||||
|
||||
last = n_mimes;
|
||||
|
||||
for (i = 0; i < last; i++)
|
||||
{
|
||||
j = i + 1;
|
||||
while (j < last)
|
||||
{
|
||||
if (strcmp (mimes[i].mime, mimes[j].mime) == 0)
|
||||
{
|
||||
mimes[i].weight = MAX (mimes[i].weight, mimes[j].weight);
|
||||
last--;
|
||||
mimes[j].mime = mimes[last].mime;
|
||||
mimes[j].weight = mimes[last].weight;
|
||||
}
|
||||
else
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
static int
|
||||
cache_glob_lookup_file_name (const char *file_name,
|
||||
cache_glob_lookup_file_name (const char *file_name,
|
||||
const char *mime_types[],
|
||||
int n_mime_types)
|
||||
{
|
||||
@ -677,16 +603,16 @@ cache_glob_lookup_file_name (const char *file_name,
|
||||
|
||||
len = strlen (file_name);
|
||||
n = cache_glob_lookup_suffix (lower_case, len, FALSE, mimes, n_mimes);
|
||||
if (n < 2)
|
||||
n += cache_glob_lookup_suffix (file_name, len, TRUE, mimes + n, n_mimes - n);
|
||||
|
||||
free (lower_case);
|
||||
if (n == 0)
|
||||
n = cache_glob_lookup_suffix (file_name, len, TRUE, mimes, n_mimes);
|
||||
|
||||
/* Last, try fnmatch */
|
||||
if (n < 2)
|
||||
n += cache_glob_lookup_fnmatch (file_name, mimes + n, n_mimes - n);
|
||||
if (n == 0)
|
||||
n = cache_glob_lookup_fnmatch (lower_case, mimes, n_mimes, FALSE);
|
||||
if (n == 0)
|
||||
n = cache_glob_lookup_fnmatch (file_name, mimes, n_mimes, TRUE);
|
||||
|
||||
n = filter_out_dupes (mimes, n);
|
||||
free (lower_case);
|
||||
|
||||
qsort (mimes, n, sizeof (MimeWeight), compare_mime_weight);
|
||||
|
||||
@ -711,9 +637,6 @@ _xdg_mime_cache_get_max_buffer_extents (void)
|
||||
{
|
||||
XdgMimeCache *cache = _caches[i];
|
||||
|
||||
if (cache->buffer == NULL)
|
||||
continue;
|
||||
|
||||
offset = GET_UINT32 (cache->buffer, 24);
|
||||
max_extent = MAX (max_extent, GET_UINT32 (cache->buffer, offset + 4));
|
||||
}
|
||||
@ -740,11 +663,7 @@ cache_get_mime_type_for_data (const void *data,
|
||||
int prio;
|
||||
const char *match;
|
||||
|
||||
if (cache->buffer == NULL)
|
||||
continue;
|
||||
|
||||
match = cache_magic_lookup_data (cache, data, len, &prio,
|
||||
mime_types, n_mime_types);
|
||||
match = cache_magic_lookup_data (cache, data, len, &prio);
|
||||
if (prio > priority)
|
||||
{
|
||||
priority = prio;
|
||||
@ -754,14 +673,27 @@ cache_get_mime_type_for_data (const void *data,
|
||||
|
||||
if (result_prio)
|
||||
*result_prio = priority;
|
||||
|
||||
if (priority > 0)
|
||||
return mime_type;
|
||||
|
||||
if (priority > 0)
|
||||
{
|
||||
/* Pick glob-result R where mime_type inherits from R */
|
||||
for (n = 0; n < n_mime_types; n++)
|
||||
{
|
||||
if (mime_types[n] && _xdg_mime_cache_mime_type_subclass(mime_types[n], mime_type))
|
||||
return mime_types[n];
|
||||
}
|
||||
if (n == 0)
|
||||
{
|
||||
/* No globs: return magic match */
|
||||
return mime_type;
|
||||
}
|
||||
}
|
||||
|
||||
/* Pick first glob result, as fallback */
|
||||
for (n = 0; n < n_mime_types; n++)
|
||||
{
|
||||
if (mime_types[n])
|
||||
return mime_types[n];
|
||||
return mime_types[n];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@ -775,8 +707,6 @@ _xdg_mime_cache_get_mime_type_for_data (const void *data,
|
||||
return cache_get_mime_type_for_data (data, len, result_prio, NULL, 0);
|
||||
}
|
||||
|
||||
#ifdef NOT_USED_IN_GIO
|
||||
|
||||
const char *
|
||||
_xdg_mime_cache_get_mime_type_for_file (const char *file_name,
|
||||
struct stat *statbuf)
|
||||
@ -844,7 +774,7 @@ _xdg_mime_cache_get_mime_type_for_file (const char *file_name,
|
||||
mime_types, n);
|
||||
|
||||
if (!mime_type)
|
||||
mime_type = _xdg_binary_or_text_fallback(data, bytes_read);
|
||||
mime_type = _xdg_binary_or_text_fallback (data, bytes_read);
|
||||
|
||||
free (data);
|
||||
fclose (file);
|
||||
@ -863,8 +793,6 @@ _xdg_mime_cache_get_mime_type_from_file_name (const char *file_name)
|
||||
return XDG_MIME_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int
|
||||
_xdg_mime_cache_get_mime_types_from_file_name (const char *file_name,
|
||||
const char *mime_types[],
|
||||
@ -905,7 +833,8 @@ _xdg_mime_cache_mime_type_subclass (const char *mime,
|
||||
{
|
||||
const char *umime, *ubase;
|
||||
|
||||
int i, j, min, max, med, cmp;
|
||||
xdg_uint32_t j;
|
||||
int i, min, max, med, cmp;
|
||||
|
||||
umime = _xdg_mime_cache_unalias_mime_type (mime);
|
||||
ubase = _xdg_mime_cache_unalias_mime_type (base);
|
||||
@ -935,16 +864,11 @@ _xdg_mime_cache_mime_type_subclass (const char *mime,
|
||||
for (i = 0; _caches[i]; i++)
|
||||
{
|
||||
XdgMimeCache *cache = _caches[i];
|
||||
xdg_uint32_t list_offset;
|
||||
xdg_uint32_t n_entries;
|
||||
|
||||
xdg_uint32_t list_offset = GET_UINT32 (cache->buffer, 8);
|
||||
xdg_uint32_t n_entries = GET_UINT32 (cache->buffer, list_offset);
|
||||
xdg_uint32_t offset, n_parents, parent_offset;
|
||||
|
||||
if (cache->buffer == NULL)
|
||||
continue;
|
||||
|
||||
list_offset = GET_UINT32 (cache->buffer, 8);
|
||||
n_entries = GET_UINT32 (cache->buffer, list_offset);
|
||||
|
||||
min = 0;
|
||||
max = n_entries - 1;
|
||||
while (max >= min)
|
||||
@ -965,9 +889,7 @@ _xdg_mime_cache_mime_type_subclass (const char *mime,
|
||||
for (j = 0; j < n_parents; j++)
|
||||
{
|
||||
parent_offset = GET_UINT32 (cache->buffer, offset + 4 + 4 * j);
|
||||
if (strcmp (cache->buffer + parent_offset, mime) != 0 &&
|
||||
strcmp (cache->buffer + parent_offset, umime) != 0 &&
|
||||
_xdg_mime_cache_mime_type_subclass (cache->buffer + parent_offset, ubase))
|
||||
if (_xdg_mime_cache_mime_type_subclass (cache->buffer + parent_offset, ubase))
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -995,7 +917,8 @@ _xdg_mime_cache_unalias_mime_type (const char *mime)
|
||||
char **
|
||||
_xdg_mime_cache_list_mime_parents (const char *mime)
|
||||
{
|
||||
int i, j, k, l, p;
|
||||
int i, l, p;
|
||||
xdg_uint32_t j, k;
|
||||
char *all_parents[128]; /* we'll stop at 128 */
|
||||
char **result;
|
||||
|
||||
@ -1005,14 +928,9 @@ _xdg_mime_cache_list_mime_parents (const char *mime)
|
||||
for (i = 0; _caches[i]; i++)
|
||||
{
|
||||
XdgMimeCache *cache = _caches[i];
|
||||
xdg_uint32_t list_offset;
|
||||
xdg_uint32_t n_entries;
|
||||
|
||||
if (cache->buffer == NULL)
|
||||
continue;
|
||||
|
||||
list_offset = GET_UINT32 (cache->buffer, 8);
|
||||
n_entries = GET_UINT32 (cache->buffer, list_offset);
|
||||
|
||||
xdg_uint32_t list_offset = GET_UINT32 (cache->buffer, 8);
|
||||
xdg_uint32_t n_entries = GET_UINT32 (cache->buffer, list_offset);
|
||||
|
||||
for (j = 0; j < n_entries; j++)
|
||||
{
|
||||
@ -1062,16 +980,10 @@ cache_lookup_icon (const char *mime, int header)
|
||||
for (i = 0; _caches[i]; i++)
|
||||
{
|
||||
XdgMimeCache *cache = _caches[i];
|
||||
xdg_uint32_t list_offset;
|
||||
xdg_uint32_t n_entries;
|
||||
xdg_uint32_t list_offset = GET_UINT32 (cache->buffer, header);
|
||||
xdg_uint32_t n_entries = GET_UINT32 (cache->buffer, list_offset);
|
||||
xdg_uint32_t offset;
|
||||
|
||||
if (cache->buffer == NULL)
|
||||
continue;
|
||||
|
||||
list_offset = GET_UINT32 (cache->buffer, header);
|
||||
n_entries = GET_UINT32 (cache->buffer, list_offset);
|
||||
|
||||
min = 0;
|
||||
max = n_entries - 1;
|
||||
while (max >= min)
|
||||
@ -1109,8 +1021,6 @@ _xdg_mime_cache_get_icon (const char *mime)
|
||||
return cache_lookup_icon (mime, 32);
|
||||
}
|
||||
|
||||
#ifdef NOT_USED_IN_GIO
|
||||
|
||||
static void
|
||||
dump_glob_node (XdgMimeCache *cache,
|
||||
xdg_uint32_t offset,
|
||||
@ -1120,6 +1030,7 @@ dump_glob_node (XdgMimeCache *cache,
|
||||
xdg_uint32_t mime_offset;
|
||||
xdg_uint32_t n_children;
|
||||
xdg_uint32_t child_offset;
|
||||
xdg_uint32_t k;
|
||||
int i;
|
||||
|
||||
character = GET_UINT32 (cache->buffer, offset);
|
||||
@ -1134,25 +1045,21 @@ dump_glob_node (XdgMimeCache *cache,
|
||||
printf ("\n");
|
||||
if (child_offset)
|
||||
{
|
||||
for (i = 0; i < n_children; i++)
|
||||
dump_glob_node (cache, child_offset + 20 * i, depth + 1);
|
||||
for (k = 0; k < n_children; k++)
|
||||
dump_glob_node (cache, child_offset + 20 * k, depth + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_xdg_mime_cache_glob_dump (void)
|
||||
{
|
||||
int i, j;
|
||||
xdg_uint32_t i, j;
|
||||
for (i = 0; _caches[i]; i++)
|
||||
{
|
||||
XdgMimeCache *cache = _caches[i];
|
||||
xdg_uint32_t list_offset;
|
||||
xdg_uint32_t n_entries;
|
||||
xdg_uint32_t offset;
|
||||
|
||||
if (cache->buffer == NULL)
|
||||
continue;
|
||||
|
||||
list_offset = GET_UINT32 (cache->buffer, 16);
|
||||
n_entries = GET_UINT32 (cache->buffer, list_offset);
|
||||
offset = GET_UINT32 (cache->buffer, list_offset + 4);
|
||||
@ -1161,4 +1068,4 @@ _xdg_mime_cache_glob_dump (void)
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ -19,7 +19,9 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __XDG_MIME_CACHE_H__
|
||||
@ -56,16 +58,12 @@ void _xdg_mime_cache_unref (XdgMimeCache *cache);
|
||||
const char *_xdg_mime_cache_get_mime_type_for_data (const void *data,
|
||||
size_t len,
|
||||
int *result_prio);
|
||||
#ifdef NOT_USED_IN_GIO
|
||||
const char *_xdg_mime_cache_get_mime_type_for_file (const char *file_name,
|
||||
struct stat *statbuf);
|
||||
#endif
|
||||
int _xdg_mime_cache_get_mime_types_from_file_name (const char *file_name,
|
||||
const char *mime_types[],
|
||||
int n_mime_types);
|
||||
#ifdef NOT_USED_IN_GIO
|
||||
const char *_xdg_mime_cache_get_mime_type_from_file_name (const char *file_name);
|
||||
#endif
|
||||
int _xdg_mime_cache_is_valid_mime_type (const char *mime_type);
|
||||
int _xdg_mime_cache_mime_type_equal (const char *mime_a,
|
||||
const char *mime_b);
|
||||
@ -78,8 +76,6 @@ const char *_xdg_mime_cache_unalias_mime_type (const char *mime);
|
||||
int _xdg_mime_cache_get_max_buffer_extents (void);
|
||||
const char *_xdg_mime_cache_get_icon (const char *mime);
|
||||
const char *_xdg_mime_cache_get_generic_icon (const char *mime);
|
||||
#ifdef NOT_USED_IN_GIO
|
||||
void _xdg_mime_cache_glob_dump (void);
|
||||
#endif
|
||||
|
||||
#endif /* __XDG_MIME_CACHE_H__ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ -20,10 +20,14 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "xdgmimeglob.h"
|
||||
#include "xdgmimeint.h"
|
||||
@ -33,10 +37,6 @@
|
||||
#include <string.h>
|
||||
#include <fnmatch.h>
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE (0)
|
||||
#endif
|
||||
@ -86,7 +86,7 @@ _xdg_glob_list_new (void)
|
||||
return new_element;
|
||||
}
|
||||
|
||||
/* Frees glob_list and all of it's children */
|
||||
/* Frees glob_list and all of its children */
|
||||
static void
|
||||
_xdg_glob_list_free (XdgGlobList *glob_list)
|
||||
{
|
||||
@ -158,8 +158,6 @@ _xdg_glob_hash_node_new (void)
|
||||
return glob_hash_node;
|
||||
}
|
||||
|
||||
#ifdef NOT_USED_IN_GIO
|
||||
|
||||
static void
|
||||
_xdg_glob_hash_node_dump (XdgGlobHashNode *glob_hash_node,
|
||||
int depth)
|
||||
@ -179,8 +177,6 @@ _xdg_glob_hash_node_dump (XdgGlobHashNode *glob_hash_node,
|
||||
_xdg_glob_hash_node_dump (glob_hash_node->next, depth);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static XdgGlobHashNode *
|
||||
_xdg_glob_hash_insert_ucs4 (XdgGlobHashNode *glob_hash_node,
|
||||
xdg_unichar_t *text,
|
||||
@ -404,34 +400,6 @@ ascii_tolower (const char *str)
|
||||
return lower;
|
||||
}
|
||||
|
||||
static int
|
||||
filter_out_dupes (MimeWeight mimes[], int n_mimes)
|
||||
{
|
||||
int last;
|
||||
int i, j;
|
||||
|
||||
last = n_mimes;
|
||||
|
||||
for (i = 0; i < last; i++)
|
||||
{
|
||||
j = i + 1;
|
||||
while (j < last)
|
||||
{
|
||||
if (strcmp (mimes[i].mime, mimes[j].mime) == 0)
|
||||
{
|
||||
mimes[i].weight = MAX (mimes[i].weight, mimes[j].weight);
|
||||
last--;
|
||||
mimes[j].mime = mimes[last].mime;
|
||||
mimes[j].weight = mimes[last].weight;
|
||||
}
|
||||
else
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
int
|
||||
_xdg_glob_hash_lookup_file_name (XdgGlobHash *glob_hash,
|
||||
const char *file_name,
|
||||
@ -478,11 +446,11 @@ _xdg_glob_hash_lookup_file_name (XdgGlobHash *glob_hash,
|
||||
len = strlen (file_name);
|
||||
n = _xdg_glob_hash_node_lookup_file_name (glob_hash->simple_node, lower_case, len, FALSE,
|
||||
mimes, n_mimes);
|
||||
if (n < 2)
|
||||
n += _xdg_glob_hash_node_lookup_file_name (glob_hash->simple_node, file_name, len, TRUE,
|
||||
mimes + n, n_mimes - n);
|
||||
if (n == 0)
|
||||
n = _xdg_glob_hash_node_lookup_file_name (glob_hash->simple_node, file_name, len, TRUE,
|
||||
mimes, n_mimes);
|
||||
|
||||
if (n < 2)
|
||||
if (n == 0)
|
||||
{
|
||||
for (list = glob_hash->full_list; list && n < n_mime_types; list = list->next)
|
||||
{
|
||||
@ -496,8 +464,6 @@ _xdg_glob_hash_lookup_file_name (XdgGlobHash *glob_hash,
|
||||
}
|
||||
free (lower_case);
|
||||
|
||||
n = filter_out_dupes (mimes, n);
|
||||
|
||||
qsort (mimes, n, sizeof (MimeWeight), compare_mime_weight);
|
||||
|
||||
if (n_mime_types < n)
|
||||
@ -603,8 +569,6 @@ _xdg_glob_hash_append_glob (XdgGlobHash *glob_hash,
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NOT_USED_IN_GIO
|
||||
|
||||
void
|
||||
_xdg_glob_hash_dump (XdgGlobHash *glob_hash)
|
||||
{
|
||||
@ -641,7 +605,6 @@ _xdg_glob_hash_dump (XdgGlobHash *glob_hash)
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void
|
||||
_xdg_mime_glob_read_from_file (XdgGlobHash *glob_hash,
|
||||
|
@ -12,7 +12,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ -20,7 +20,9 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __XDG_MIME_GLOB_H__
|
||||
@ -63,8 +65,6 @@ void _xdg_glob_hash_append_glob (XdgGlobHash *glob_hash,
|
||||
int weight,
|
||||
int case_sensitive);
|
||||
XdgGlobType _xdg_glob_determine_type (const char *glob);
|
||||
#ifdef NOT_USED_IN_GIO
|
||||
void _xdg_glob_hash_dump (XdgGlobHash *glob_hash);
|
||||
#endif
|
||||
|
||||
#endif /* __XDG_MIME_GLOB_H__ */
|
||||
|
@ -11,7 +11,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ -19,10 +19,14 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "xdgmimeicon.h"
|
||||
#include "xdgmimeint.h"
|
||||
@ -159,7 +163,6 @@ _xdg_mime_icon_read_from_file (XdgIconList *list,
|
||||
sizeof (XdgIcon), icon_entry_cmp);
|
||||
}
|
||||
|
||||
#ifdef NOT_USED_IN_GIO
|
||||
|
||||
void
|
||||
_xdg_mime_icon_list_dump (XdgIconList *list)
|
||||
@ -177,4 +180,4 @@ _xdg_mime_icon_list_dump (XdgIconList *list)
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ -19,7 +19,9 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __XDG_MIME_ICON_H__
|
||||
@ -43,8 +45,6 @@ XdgIconList *_xdg_mime_icon_list_new (void);
|
||||
void _xdg_mime_icon_list_free (XdgIconList *list);
|
||||
const char *_xdg_mime_icon_list_lookup (XdgIconList *list,
|
||||
const char *mime);
|
||||
#ifdef NOT_USED_IN_GIO
|
||||
void _xdg_mime_icon_list_dump (XdgIconList *list);
|
||||
#endif
|
||||
|
||||
#endif /* __XDG_MIME_ICON_H__ */
|
||||
|
@ -12,7 +12,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ -20,10 +20,14 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "xdgmimeint.h"
|
||||
#include <ctype.h>
|
||||
@ -189,7 +193,7 @@ const char *
|
||||
_xdg_binary_or_text_fallback(const void *data, size_t len)
|
||||
{
|
||||
unsigned char *chardata;
|
||||
int i;
|
||||
size_t i;
|
||||
|
||||
chardata = (unsigned char *) data;
|
||||
for (i = 0; i < 128 && i < len; ++i)
|
||||
|
@ -12,7 +12,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ -20,7 +20,9 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __XDG_MIME_INT_H__
|
||||
|
@ -12,7 +12,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ -20,10 +20,14 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include "xdgmimemagic.h"
|
||||
@ -316,7 +320,7 @@ _xdg_mime_magic_parse_magic_line (FILE *magic_file,
|
||||
int c;
|
||||
int end_of_file;
|
||||
int indent = 0;
|
||||
int bytes_read;
|
||||
size_t bytes_read;
|
||||
|
||||
assert (magic_file != NULL);
|
||||
|
||||
@ -403,7 +407,7 @@ _xdg_mime_magic_parse_magic_line (FILE *magic_file,
|
||||
return XDG_MIME_MAGIC_ERROR;
|
||||
}
|
||||
bytes_read = fread (matchlet->value, 1, matchlet->value_length, magic_file);
|
||||
if (bytes_read != matchlet->value_length)
|
||||
if (bytes_read != (size_t) matchlet->value_length)
|
||||
{
|
||||
_xdg_mime_magic_matchlet_free (matchlet);
|
||||
if (feof (magic_file))
|
||||
@ -423,7 +427,7 @@ _xdg_mime_magic_parse_magic_line (FILE *magic_file,
|
||||
return XDG_MIME_MAGIC_ERROR;
|
||||
}
|
||||
bytes_read = fread (matchlet->mask, 1, matchlet->value_length, magic_file);
|
||||
if (bytes_read != matchlet->value_length)
|
||||
if (bytes_read != (size_t) matchlet->value_length)
|
||||
{
|
||||
_xdg_mime_magic_matchlet_free (matchlet);
|
||||
if (feof (magic_file))
|
||||
@ -461,7 +465,7 @@ _xdg_mime_magic_parse_magic_line (FILE *magic_file,
|
||||
_xdg_mime_magic_matchlet_free (matchlet);
|
||||
return XDG_MIME_MAGIC_EOF;
|
||||
}
|
||||
if (matchlet->range_length == -1)
|
||||
if (matchlet->range_length == (unsigned int) -1)
|
||||
{
|
||||
_xdg_mime_magic_matchlet_free (matchlet);
|
||||
return XDG_MIME_MAGIC_ERROR;
|
||||
@ -475,9 +479,7 @@ _xdg_mime_magic_parse_magic_line (FILE *magic_file,
|
||||
/* We clean up the matchlet, byte swapping if needed */
|
||||
if (matchlet->word_size > 1)
|
||||
{
|
||||
#if LITTLE_ENDIAN
|
||||
int i;
|
||||
#endif
|
||||
unsigned int i;
|
||||
if (matchlet->value_length % matchlet->word_size != 0)
|
||||
{
|
||||
_xdg_mime_magic_matchlet_free (matchlet);
|
||||
@ -522,7 +524,7 @@ _xdg_mime_magic_matchlet_compare_to_data (XdgMimeMagicMatchlet *matchlet,
|
||||
const void *data,
|
||||
size_t len)
|
||||
{
|
||||
int i, j;
|
||||
unsigned int i, j;
|
||||
for (i = matchlet->offset; i < matchlet->offset + matchlet->range_length; i++)
|
||||
{
|
||||
int valid_matchlet = TRUE;
|
||||
|
@ -12,7 +12,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ -20,7 +20,9 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __XDG_MIME_MAGIC_H__
|
||||
|
@ -12,7 +12,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ -20,10 +20,14 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "xdgmimeparent.h"
|
||||
#include "xdgmimeint.h"
|
||||
@ -107,7 +111,6 @@ _xdg_mime_parent_list_lookup (XdgParentList *list,
|
||||
{
|
||||
key.mime = (char *)mime;
|
||||
key.parents = NULL;
|
||||
key.n_parents = 0;
|
||||
|
||||
entry = bsearch (&key, list->parents, list->n_mimes,
|
||||
sizeof (XdgMimeParents), &parent_entry_cmp);
|
||||
@ -196,7 +199,6 @@ _xdg_mime_parent_read_from_file (XdgParentList *list,
|
||||
sizeof (XdgMimeParents), &parent_entry_cmp);
|
||||
}
|
||||
|
||||
#ifdef NOT_USED_IN_GIO
|
||||
|
||||
void
|
||||
_xdg_mime_parent_list_dump (XdgParentList *list)
|
||||
@ -214,4 +216,4 @@ _xdg_mime_parent_list_dump (XdgParentList *list)
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@ -20,7 +20,9 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __XDG_MIME_PARENT_H__
|
||||
@ -44,8 +46,6 @@ XdgParentList *_xdg_mime_parent_list_new (void);
|
||||
void _xdg_mime_parent_list_free (XdgParentList *list);
|
||||
const char **_xdg_mime_parent_list_lookup (XdgParentList *list,
|
||||
const char *mime);
|
||||
#ifdef NOT_USED_IN_GIO
|
||||
void _xdg_mime_parent_list_dump (XdgParentList *list);
|
||||
#endif
|
||||
|
||||
#endif /* __XDG_MIME_PARENT_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user