mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-14 19:55:12 +01:00
Merge branch 'xdgmime_update' into 'main'
Updating xdgmime See merge request GNOME/glib!2029
This commit is contained in:
commit
60173d0a38
@ -13,4 +13,5 @@ xdgmime_lib = static_library('xdgmime',
|
||||
sources : xdgmime_sources,
|
||||
include_directories : [configinc],
|
||||
pic : true,
|
||||
c_args : [ '-DXDG_PREFIX=_gio_xdg' ] + glib_hidden_visibility_args)
|
||||
c_args : [ '-DHAVE_CONFIG_H',
|
||||
'-DXDG_PREFIX=_gio_xdg' ] + glib_hidden_visibility_args)
|
||||
|
@ -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"
|
||||
@ -134,7 +138,8 @@ xdg_dir_time_list_free (XdgDirTimeList *list)
|
||||
}
|
||||
|
||||
static int
|
||||
xdg_mime_init_from_directory (const char *directory)
|
||||
xdg_mime_init_from_directory (const char *directory,
|
||||
void *user_data)
|
||||
{
|
||||
char *file_name;
|
||||
struct stat st;
|
||||
@ -400,10 +405,11 @@ xdg_check_file (const char *file_path,
|
||||
|
||||
static int
|
||||
xdg_check_dir (const char *directory,
|
||||
int *invalid_dir_list)
|
||||
void *user_data)
|
||||
{
|
||||
int invalid, exists;
|
||||
char *file_name;
|
||||
int* invalid_dir_list = user_data;
|
||||
|
||||
assert (directory != NULL);
|
||||
|
||||
@ -458,8 +464,7 @@ xdg_check_dirs (void)
|
||||
for (list = dir_time_list; list; list = list->next)
|
||||
list->checked = XDG_CHECKED_UNCHECKED;
|
||||
|
||||
xdg_run_command_on_dirs ((XdgDirectoryFunc) xdg_check_dir,
|
||||
&invalid_dir_list);
|
||||
xdg_run_command_on_dirs (xdg_check_dir, &invalid_dir_list);
|
||||
|
||||
if (invalid_dir_list)
|
||||
return TRUE;
|
||||
@ -515,8 +520,7 @@ xdg_mime_init (void)
|
||||
icon_list = _xdg_mime_icon_list_new ();
|
||||
generic_icon_list = _xdg_mime_icon_list_new ();
|
||||
|
||||
xdg_run_command_on_dirs ((XdgDirectoryFunc) xdg_mime_init_from_directory,
|
||||
NULL);
|
||||
xdg_run_command_on_dirs (xdg_mime_init_from_directory, NULL);
|
||||
|
||||
need_reread = FALSE;
|
||||
}
|
||||
@ -621,13 +625,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 *
|
||||
|
@ -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.
|
||||
*/
|
||||
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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__
|
||||
|
@ -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;
|
||||
@ -176,7 +180,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 +203,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 +222,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 +252,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 +272,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 +294,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;
|
||||
@ -428,12 +408,14 @@ 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++)
|
||||
@ -454,16 +436,19 @@ cache_glob_lookup_fnmatch (const char *file_name,
|
||||
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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -492,7 +477,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];
|
||||
|
||||
@ -578,17 +564,17 @@ cache_glob_lookup_suffix (const char *file_name,
|
||||
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)
|
||||
@ -680,14 +666,16 @@ cache_glob_lookup_file_name (const char *file_name,
|
||||
if (n < 2)
|
||||
n += cache_glob_lookup_suffix (file_name, len, TRUE, mimes + n, n_mimes - n);
|
||||
|
||||
free (lower_case);
|
||||
|
||||
/* Last, try fnmatch */
|
||||
if (n == 0)
|
||||
n = cache_glob_lookup_fnmatch (lower_case, mimes, n_mimes, FALSE);
|
||||
if (n < 2)
|
||||
n += cache_glob_lookup_fnmatch (file_name, mimes + n, n_mimes - n);
|
||||
n += cache_glob_lookup_fnmatch (file_name, mimes + n, n_mimes - n, TRUE);
|
||||
|
||||
n = filter_out_dupes (mimes, n);
|
||||
|
||||
free (lower_case);
|
||||
|
||||
qsort (mimes, n, sizeof (MimeWeight), compare_mime_weight);
|
||||
|
||||
if (n_mime_types < n)
|
||||
@ -743,8 +731,7 @@ cache_get_mime_type_for_data (const void *data,
|
||||
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 +741,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;
|
||||
@ -844,7 +844,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);
|
||||
@ -905,7 +905,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);
|
||||
@ -995,7 +996,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;
|
||||
|
||||
@ -1120,6 +1122,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,15 +1137,15 @@ 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];
|
||||
|
@ -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__
|
||||
|
@ -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"
|
||||
@ -86,7 +90,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)
|
||||
{
|
||||
|
@ -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__
|
||||
|
@ -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"
|
||||
@ -178,3 +182,4 @@ _xdg_mime_icon_list_dump (XdgIconList *list)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -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__
|
||||
|
@ -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)
|
||||
|
@ -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__
|
||||
|
@ -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;
|
||||
|
@ -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__
|
||||
|
@ -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"
|
||||
@ -215,3 +219,4 @@ _xdg_mime_parent_list_dump (XdgParentList *list)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -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__
|
||||
|
Loading…
x
Reference in New Issue
Block a user