mirror of
https://git.proxmox.com/git/libxdgmime-perl
synced 2025-08-15 14:36:24 +00:00
Merge commit '73d5a30a1d93eb79761f2472c685afb8e42a8646' from upstream
git-subtree-dir: xdgmime-source git-subtree-origin: https://gitlab.freedesktop.org/xdg/xdgmime.git
This commit is contained in:
commit
748e495f5f
@ -15,7 +15,7 @@ variables:
|
|||||||
gettext-devel
|
gettext-devel
|
||||||
meson
|
meson
|
||||||
|
|
||||||
build:meson:
|
build:autotools:
|
||||||
before_script:
|
before_script:
|
||||||
- dnf update -y --nogpgcheck
|
- dnf update -y --nogpgcheck
|
||||||
- dnf install -y --nogpgcheck $DEPENDENCIES
|
- dnf install -y --nogpgcheck $DEPENDENCIES
|
||||||
@ -25,5 +25,19 @@ build:meson:
|
|||||||
# Compile shared-mime-info
|
# Compile shared-mime-info
|
||||||
- git clone https://gitlab.freedesktop.org/xdg/shared-mime-info.git
|
- git clone https://gitlab.freedesktop.org/xdg/shared-mime-info.git
|
||||||
- cd shared-mime-info
|
- cd shared-mime-info
|
||||||
- meson _build
|
- meson _build -Dxdgmime-path=$PWD/../
|
||||||
|
- ninja -C _build test
|
||||||
|
|
||||||
|
build:meson:
|
||||||
|
before_script:
|
||||||
|
- dnf update -y --nogpgcheck
|
||||||
|
- dnf install -y --nogpgcheck $DEPENDENCIES
|
||||||
|
script:
|
||||||
|
- meson _build
|
||||||
|
- ninja -C _build
|
||||||
|
|
||||||
|
# Compile shared-mime-info
|
||||||
|
- git clone https://gitlab.freedesktop.org/xdg/shared-mime-info.git
|
||||||
|
- cd shared-mime-info
|
||||||
|
- meson _build -Dxdgmime-path=$PWD/../_build/
|
||||||
- ninja -C _build test
|
- ninja -C _build test
|
||||||
|
17
xdgmime-source/meson.build
Normal file
17
xdgmime-source/meson.build
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
project('xdgmime', 'c',
|
||||||
|
version: '0.0',
|
||||||
|
default_options: ['c_std=c99', 'warning_level=1', 'debug=true'],
|
||||||
|
meson_version: '>=0.48.0',
|
||||||
|
)
|
||||||
|
|
||||||
|
add_project_arguments(
|
||||||
|
'-D_POSIX_C_SOURCE=200809L',
|
||||||
|
'-DXDG_PREFIX=xdg_test',
|
||||||
|
'-DHAVE_MMAP',
|
||||||
|
'-Wmissing-prototypes',
|
||||||
|
'-Wno-sign-compare',
|
||||||
|
language: 'c',
|
||||||
|
native: true,
|
||||||
|
)
|
||||||
|
|
||||||
|
subdir('src')
|
@ -1,14 +1,22 @@
|
|||||||
|
.POSIX:
|
||||||
|
.PHONY: all clean
|
||||||
|
|
||||||
CFLAGS=-Wall -Wmissing-prototypes -Wno-sign-compare -g -DXDG_PREFIX=xdg_test -DHAVE_MMAP
|
C_STD = -std=c99 -D_POSIX_C_SOURCE=200809L
|
||||||
|
ALL_CFLAGS = $(C_STD) -c -g -DXDG_PREFIX=xdg_test -DHAVE_MMAP -Wall -Wmissing-prototypes -Wno-sign-compare $(CFLAGS)
|
||||||
|
|
||||||
|
.c.o:
|
||||||
|
$(CC) $(ALL_CFLAGS) -o $@ $<
|
||||||
|
|
||||||
all: test-mime test-mime-data print-mime-data
|
all: test-mime test-mime-data print-mime-data
|
||||||
|
|
||||||
test-mime: xdgmime.o xdgmimeglob.o xdgmimeint.o xdgmimemagic.o xdgmimealias.o xdgmimeparent.o xdgmimecache.o xdgmimeicon.o
|
test-mime: test-mime.o xdgmime.o xdgmimeglob.o xdgmimeint.o xdgmimemagic.o xdgmimealias.o xdgmimeparent.o xdgmimecache.o xdgmimeicon.o
|
||||||
|
$(CC) $(LDFLAGS) -o $@ $?
|
||||||
|
|
||||||
test-mime-data: xdgmime.o xdgmimeglob.o xdgmimeint.o xdgmimemagic.o xdgmimealias.o xdgmimeparent.o xdgmimecache.o xdgmimeicon.o
|
test-mime-data: test-mime-data.o xdgmime.o xdgmimeglob.o xdgmimeint.o xdgmimemagic.o xdgmimealias.o xdgmimeparent.o xdgmimecache.o xdgmimeicon.o
|
||||||
|
$(CC) $(LDFLAGS) -o $@ $?
|
||||||
|
|
||||||
print-mime-data: xdgmime.o xdgmimeglob.o xdgmimeint.o xdgmimemagic.o xdgmimealias.o xdgmimeparent.o xdgmimecache.o xdgmimeicon.o
|
print-mime-data: print-mime-data.o xdgmime.o xdgmimeglob.o xdgmimeint.o xdgmimemagic.o xdgmimealias.o xdgmimeparent.o xdgmimecache.o xdgmimeicon.o
|
||||||
|
$(CC) $(LDFLAGS) -o $@ $?
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *~ *.o test-mime test-mime-data print-mime-data
|
rm -f *~ *.o test-mime test-mime-data print-mime-data
|
||||||
|
|
||||||
|
35
xdgmime-source/src/meson.build
Normal file
35
xdgmime-source/src/meson.build
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
libcommon = static_library('common',
|
||||||
|
'xdgmime.c',
|
||||||
|
'xdgmimeglob.c',
|
||||||
|
'xdgmimeint.c',
|
||||||
|
'xdgmimemagic.c',
|
||||||
|
'xdgmimealias.c',
|
||||||
|
'xdgmimeparent.c',
|
||||||
|
'xdgmimecache.c',
|
||||||
|
'xdgmimeicon.c',
|
||||||
|
native: true,
|
||||||
|
)
|
||||||
|
|
||||||
|
test_mime = executable('test-mime',
|
||||||
|
'test-mime.c',
|
||||||
|
link_with: libcommon,
|
||||||
|
native: true,
|
||||||
|
install: false,
|
||||||
|
)
|
||||||
|
meson.override_find_program('test-mime', test_mime)
|
||||||
|
|
||||||
|
test_mime_data = executable('test-mime-data',
|
||||||
|
'test-mime-data.c',
|
||||||
|
link_with: libcommon,
|
||||||
|
native: true,
|
||||||
|
install: false,
|
||||||
|
)
|
||||||
|
meson.override_find_program('test-mime-data', test_mime_data)
|
||||||
|
|
||||||
|
print_mime_data = executable('print-mime-data',
|
||||||
|
'print-mime-data.c',
|
||||||
|
link_with: libcommon,
|
||||||
|
native: true,
|
||||||
|
install: false,
|
||||||
|
)
|
||||||
|
meson.override_find_program('print-mime-data', print_mime_data)
|
@ -6,23 +6,7 @@
|
|||||||
* Copyright (C) 2005 Matthias Clasen <mclasen@redhat.com>
|
* Copyright (C) 2005 Matthias Clasen <mclasen@redhat.com>
|
||||||
* Copyright (C) 2012 Bastien Nocera <hadess@hadess.net>
|
* Copyright (C) 2012 Bastien Nocera <hadess@hadess.net>
|
||||||
*
|
*
|
||||||
* Licensed under the Academic Free License version 2.0
|
* SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0
|
||||||
* Or under the following terms:
|
|
||||||
*
|
|
||||||
* 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 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
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* 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, write to the
|
|
||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
* Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -5,28 +5,13 @@
|
|||||||
* Copyright (C) 2005 Red Hat, Inc.
|
* Copyright (C) 2005 Red Hat, Inc.
|
||||||
* Copyright (C) 2005 Matthias Clasen <mclasen@redhat.com>
|
* Copyright (C) 2005 Matthias Clasen <mclasen@redhat.com>
|
||||||
*
|
*
|
||||||
* Licensed under the Academic Free License version 2.0
|
* SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0
|
||||||
* Or under the following terms:
|
|
||||||
*
|
|
||||||
* 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 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
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* 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, write to the
|
|
||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
* Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <strings.h>
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
|
|
||||||
#include "xdgmime.h"
|
#include "xdgmime.h"
|
||||||
@ -63,8 +48,8 @@ check_mime_type (const char *mt,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (verbose > 0)
|
if (verbose > 0)
|
||||||
printf ("%s, '%s' test: expected %s, got %s\n",
|
fprintf (stderr, "%s, '%s' test: expected %s, got %s\n",
|
||||||
filename, test, mt_expected, mt);
|
filename, test, mt_expected, mt);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -114,7 +99,7 @@ test_by_data (const char *dir,
|
|||||||
|
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
{
|
{
|
||||||
printf ("Could not open %s\n", path);
|
fprintf (stderr, "Could not open %s\n", path);
|
||||||
error++;
|
error++;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -125,7 +110,7 @@ test_by_data (const char *dir,
|
|||||||
|
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
{
|
{
|
||||||
printf ("Failed to allocate memory for file %s\n", filename);
|
fprintf (stderr, "Failed to allocate memory for file %s\n", filename);
|
||||||
error++;
|
error++;
|
||||||
|
|
||||||
fclose (file);
|
fclose (file);
|
||||||
@ -136,7 +121,7 @@ test_by_data (const char *dir,
|
|||||||
|
|
||||||
if (ferror (file))
|
if (ferror (file))
|
||||||
{
|
{
|
||||||
printf ("Error reading file %s\n", path);
|
fprintf (stderr, "Error reading file %s\n", path);
|
||||||
error++;
|
error++;
|
||||||
|
|
||||||
free (data);
|
free (data);
|
||||||
@ -200,7 +185,7 @@ read_from_file (const char *filename)
|
|||||||
|
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
{
|
{
|
||||||
printf ("Could not open %s\n", filename);
|
fprintf (stderr, "Could not open %s\n", filename);
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,7 +202,7 @@ read_from_file (const char *filename)
|
|||||||
space = strchr (rest, ' ');
|
space = strchr (rest, ' ');
|
||||||
if (!space)
|
if (!space)
|
||||||
{
|
{
|
||||||
printf ("Malformed line in %s:%d\n\t%s\n", filename, lineno, line);
|
fprintf (stderr, "Malformed line in %s:%d\n\t%s\n", filename, lineno, line);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,22 +297,15 @@ main (int argc, char *argv[])
|
|||||||
read_from_file (argv[i]);
|
read_from_file (argv[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error > 0 || failed > 0)
|
printf ("%d errors, %d comparisons, %d failed",
|
||||||
{
|
error, total, failed);
|
||||||
printf ("%d errors, %d comparisons, %d failed",
|
if (xfailed > 0)
|
||||||
error, total, failed);
|
printf (" (%d expected)", xfailed);
|
||||||
if (xfailed > 0)
|
if (xmatch > 0)
|
||||||
printf (" (%d expected)", xfailed);
|
printf (", %d unexpected successes", xmatch);
|
||||||
if (xmatch > 0)
|
printf ("\n");
|
||||||
printf (", %d unexpected successes", xmatch);
|
|
||||||
printf ("\n");
|
|
||||||
|
|
||||||
if (xmatch > 0)
|
|
||||||
return 1;
|
|
||||||
if (xfailed == failed)
|
|
||||||
return 0;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (error > 0 || xmatch > 0 || failed != xfailed)
|
||||||
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2,27 +2,12 @@
|
|||||||
* Copyright (C) 2003,2004 Red Hat, Inc.
|
* Copyright (C) 2003,2004 Red Hat, Inc.
|
||||||
* Copyright (C) 2003,2004 Jonathan Blandford <jrb@alum.mit.edu>
|
* Copyright (C) 2003,2004 Jonathan Blandford <jrb@alum.mit.edu>
|
||||||
*
|
*
|
||||||
* Licensed under the Academic Free License version 2.0
|
* SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0
|
||||||
* Or under the following terms:
|
|
||||||
*
|
|
||||||
* 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 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
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* 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, write to the
|
|
||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
* Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
*/
|
||||||
#include "xdgmime.h"
|
#include "xdgmime.h"
|
||||||
#include "xdgmimeglob.h"
|
#include "xdgmimeglob.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <strings.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,23 +6,7 @@
|
|||||||
* Copyright (C) 2003,2004 Red Hat, Inc.
|
* Copyright (C) 2003,2004 Red Hat, Inc.
|
||||||
* Copyright (C) 2003,2004 Jonathan Blandford <jrb@alum.mit.edu>
|
* Copyright (C) 2003,2004 Jonathan Blandford <jrb@alum.mit.edu>
|
||||||
*
|
*
|
||||||
* Licensed under the Academic Free License version 2.0
|
* SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0
|
||||||
* Or under the following terms:
|
|
||||||
*
|
|
||||||
* 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 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
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* 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, write to the
|
|
||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
* Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
@ -45,6 +29,10 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
#ifndef S_ISREG
|
||||||
|
#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct XdgDirTimeList XdgDirTimeList;
|
typedef struct XdgDirTimeList XdgDirTimeList;
|
||||||
typedef struct XdgCallbackList XdgCallbackList;
|
typedef struct XdgCallbackList XdgCallbackList;
|
||||||
|
|
||||||
@ -60,6 +48,8 @@ static XdgCallbackList *callback_list = NULL;
|
|||||||
static XdgIconList *icon_list = NULL;
|
static XdgIconList *icon_list = NULL;
|
||||||
static XdgIconList *generic_icon_list = NULL;
|
static XdgIconList *generic_icon_list = NULL;
|
||||||
|
|
||||||
|
static char **xdg_dirs = NULL; /* NULL terminated */
|
||||||
|
|
||||||
XdgMimeCache **_caches = NULL;
|
XdgMimeCache **_caches = NULL;
|
||||||
static int n_caches = 0;
|
static int n_caches = 0;
|
||||||
|
|
||||||
@ -144,8 +134,8 @@ xdg_mime_init_from_directory (const char *directory,
|
|||||||
|
|
||||||
assert (directory != NULL);
|
assert (directory != NULL);
|
||||||
|
|
||||||
file_name = malloc (strlen (directory) + strlen ("/mime/mime.cache") + 1);
|
file_name = malloc (strlen (directory) + strlen ("/mime.cache") + 1);
|
||||||
strcpy (file_name, directory); strcat (file_name, "/mime/mime.cache");
|
strcpy (file_name, directory); strcat (file_name, "/mime.cache");
|
||||||
if (stat (file_name, &st) == 0)
|
if (stat (file_name, &st) == 0)
|
||||||
{
|
{
|
||||||
XdgMimeCache *cache = _xdg_mime_cache_new_from_file (file_name);
|
XdgMimeCache *cache = _xdg_mime_cache_new_from_file (file_name);
|
||||||
@ -164,8 +154,8 @@ xdg_mime_init_from_directory (const char *directory,
|
|||||||
}
|
}
|
||||||
free (file_name);
|
free (file_name);
|
||||||
|
|
||||||
file_name = malloc (strlen (directory) + strlen ("/mime/globs2") + 1);
|
file_name = malloc (strlen (directory) + strlen ("/globs2") + 1);
|
||||||
strcpy (file_name, directory); strcat (file_name, "/mime/globs2");
|
strcpy (file_name, directory); strcat (file_name, "/globs2");
|
||||||
if (stat (file_name, &st) == 0)
|
if (stat (file_name, &st) == 0)
|
||||||
{
|
{
|
||||||
_xdg_mime_glob_read_from_file (global_hash, file_name, TRUE);
|
_xdg_mime_glob_read_from_file (global_hash, file_name, TRUE);
|
||||||
@ -174,8 +164,8 @@ xdg_mime_init_from_directory (const char *directory,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
free (file_name);
|
free (file_name);
|
||||||
file_name = malloc (strlen (directory) + strlen ("/mime/globs") + 1);
|
file_name = malloc (strlen (directory) + strlen ("/globs") + 1);
|
||||||
strcpy (file_name, directory); strcat (file_name, "/mime/globs");
|
strcpy (file_name, directory); strcat (file_name, "/globs");
|
||||||
if (stat (file_name, &st) == 0)
|
if (stat (file_name, &st) == 0)
|
||||||
{
|
{
|
||||||
_xdg_mime_glob_read_from_file (global_hash, file_name, FALSE);
|
_xdg_mime_glob_read_from_file (global_hash, file_name, FALSE);
|
||||||
@ -187,8 +177,8 @@ xdg_mime_init_from_directory (const char *directory,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
file_name = malloc (strlen (directory) + strlen ("/mime/magic") + 1);
|
file_name = malloc (strlen (directory) + strlen ("/magic") + 1);
|
||||||
strcpy (file_name, directory); strcat (file_name, "/mime/magic");
|
strcpy (file_name, directory); strcat (file_name, "/magic");
|
||||||
if (stat (file_name, &st) == 0)
|
if (stat (file_name, &st) == 0)
|
||||||
{
|
{
|
||||||
_xdg_mime_magic_read_from_file (global_magic, file_name);
|
_xdg_mime_magic_read_from_file (global_magic, file_name);
|
||||||
@ -199,69 +189,81 @@ xdg_mime_init_from_directory (const char *directory,
|
|||||||
free (file_name);
|
free (file_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
file_name = malloc (strlen (directory) + strlen ("/mime/aliases") + 1);
|
file_name = malloc (strlen (directory) + strlen ("/aliases") + 1);
|
||||||
strcpy (file_name, directory); strcat (file_name, "/mime/aliases");
|
strcpy (file_name, directory); strcat (file_name, "/aliases");
|
||||||
_xdg_mime_alias_read_from_file (alias_list, file_name);
|
_xdg_mime_alias_read_from_file (alias_list, file_name);
|
||||||
free (file_name);
|
free (file_name);
|
||||||
|
|
||||||
file_name = malloc (strlen (directory) + strlen ("/mime/subclasses") + 1);
|
file_name = malloc (strlen (directory) + strlen ("/subclasses") + 1);
|
||||||
strcpy (file_name, directory); strcat (file_name, "/mime/subclasses");
|
strcpy (file_name, directory); strcat (file_name, "/subclasses");
|
||||||
_xdg_mime_parent_read_from_file (parent_list, file_name);
|
_xdg_mime_parent_read_from_file (parent_list, file_name);
|
||||||
free (file_name);
|
free (file_name);
|
||||||
|
|
||||||
file_name = malloc (strlen (directory) + strlen ("/mime/icons") + 1);
|
file_name = malloc (strlen (directory) + strlen ("/icons") + 1);
|
||||||
strcpy (file_name, directory); strcat (file_name, "/mime/icons");
|
strcpy (file_name, directory); strcat (file_name, "/icons");
|
||||||
_xdg_mime_icon_read_from_file (icon_list, file_name);
|
_xdg_mime_icon_read_from_file (icon_list, file_name);
|
||||||
free (file_name);
|
free (file_name);
|
||||||
|
|
||||||
file_name = malloc (strlen (directory) + strlen ("/mime/generic-icons") + 1);
|
file_name = malloc (strlen (directory) + strlen ("/generic-icons") + 1);
|
||||||
strcpy (file_name, directory); strcat (file_name, "/mime/generic-icons");
|
strcpy (file_name, directory); strcat (file_name, "/generic-icons");
|
||||||
_xdg_mime_icon_read_from_file (generic_icon_list, file_name);
|
_xdg_mime_icon_read_from_file (generic_icon_list, file_name);
|
||||||
free (file_name);
|
free (file_name);
|
||||||
|
|
||||||
return FALSE; /* Keep processing */
|
return FALSE; /* Keep processing */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Runs a command on all the directories in the search path */
|
/* Set @xdg_dirs from the environment. It must not have been set already. */
|
||||||
static void
|
static void
|
||||||
xdg_run_command_on_dirs (XdgDirectoryFunc func,
|
xdg_init_dirs (void)
|
||||||
void *user_data)
|
|
||||||
{
|
{
|
||||||
const char *xdg_data_home;
|
const char *xdg_data_home, *home, *xdg_data_dirs;
|
||||||
const char *xdg_data_dirs;
|
|
||||||
const char *ptr;
|
const char *ptr;
|
||||||
|
size_t n_dirs = 0;
|
||||||
|
size_t i, current_dir;
|
||||||
|
|
||||||
|
assert (xdg_dirs == NULL);
|
||||||
|
|
||||||
xdg_data_home = getenv ("XDG_DATA_HOME");
|
xdg_data_home = getenv ("XDG_DATA_HOME");
|
||||||
if (xdg_data_home)
|
home = getenv ("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");
|
xdg_data_dirs = getenv ("XDG_DATA_DIRS");
|
||||||
|
|
||||||
if (xdg_data_dirs == NULL)
|
if (xdg_data_dirs == NULL)
|
||||||
xdg_data_dirs = "/usr/local/share/:/usr/share/";
|
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;
|
ptr = xdg_data_dirs;
|
||||||
|
|
||||||
while (*ptr != '\000')
|
while (*ptr != '\000')
|
||||||
@ -269,33 +271,82 @@ xdg_run_command_on_dirs (XdgDirectoryFunc func,
|
|||||||
const char *end_ptr;
|
const char *end_ptr;
|
||||||
char *dir;
|
char *dir;
|
||||||
int len;
|
int len;
|
||||||
int stop_processing;
|
|
||||||
|
|
||||||
end_ptr = ptr;
|
end_ptr = ptr;
|
||||||
while (*end_ptr != ':' && *end_ptr != '\000')
|
while (*end_ptr != ':' && *end_ptr != '\000')
|
||||||
end_ptr ++;
|
end_ptr ++;
|
||||||
|
|
||||||
if (end_ptr == ptr)
|
if (end_ptr == ptr)
|
||||||
{
|
{
|
||||||
ptr++;
|
ptr++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*end_ptr == ':')
|
if (*end_ptr == ':')
|
||||||
len = end_ptr - ptr;
|
len = end_ptr - ptr;
|
||||||
else
|
else
|
||||||
len = end_ptr - ptr + 1;
|
len = end_ptr - ptr + 1;
|
||||||
dir = malloc (len + 1);
|
dir = malloc (len + strlen ("/mime/") + 1);
|
||||||
strncpy (dir, ptr, len);
|
strncpy (dir, ptr, len);
|
||||||
dir[len] = '\0';
|
dir[len] = '\0';
|
||||||
stop_processing = (func) (dir, user_data);
|
strcat (dir, "/mime/");
|
||||||
free (dir);
|
|
||||||
|
|
||||||
if (stop_processing)
|
xdg_dirs[current_dir++] = dir;
|
||||||
return;
|
|
||||||
|
|
||||||
ptr = end_ptr;
|
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]);
|
||||||
|
free (xdg_dirs);
|
||||||
|
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
|
/* Checks file_path to make sure it has the same mtime as last time it was
|
||||||
@ -350,8 +401,8 @@ xdg_check_dir (const char *directory,
|
|||||||
assert (directory != NULL);
|
assert (directory != NULL);
|
||||||
|
|
||||||
/* Check the mime.cache file */
|
/* Check the mime.cache file */
|
||||||
file_name = malloc (strlen (directory) + strlen ("/mime/mime.cache") + 1);
|
file_name = malloc (strlen (directory) + strlen ("/mime.cache") + 1);
|
||||||
strcpy (file_name, directory); strcat (file_name, "/mime/mime.cache");
|
strcpy (file_name, directory); strcat (file_name, "/mime.cache");
|
||||||
invalid = xdg_check_file (file_name, &exists);
|
invalid = xdg_check_file (file_name, &exists);
|
||||||
free (file_name);
|
free (file_name);
|
||||||
if (invalid)
|
if (invalid)
|
||||||
@ -365,8 +416,8 @@ xdg_check_dir (const char *directory,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check the globs file */
|
/* Check the globs file */
|
||||||
file_name = malloc (strlen (directory) + strlen ("/mime/globs") + 1);
|
file_name = malloc (strlen (directory) + strlen ("/globs") + 1);
|
||||||
strcpy (file_name, directory); strcat (file_name, "/mime/globs");
|
strcpy (file_name, directory); strcat (file_name, "/globs");
|
||||||
invalid = xdg_check_file (file_name, NULL);
|
invalid = xdg_check_file (file_name, NULL);
|
||||||
free (file_name);
|
free (file_name);
|
||||||
if (invalid)
|
if (invalid)
|
||||||
@ -376,8 +427,8 @@ xdg_check_dir (const char *directory,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check the magic file */
|
/* Check the magic file */
|
||||||
file_name = malloc (strlen (directory) + strlen ("/mime/magic") + 1);
|
file_name = malloc (strlen (directory) + strlen ("/magic") + 1);
|
||||||
strcpy (file_name, directory); strcat (file_name, "/mime/magic");
|
strcpy (file_name, directory); strcat (file_name, "/magic");
|
||||||
invalid = xdg_check_file (file_name, NULL);
|
invalid = xdg_check_file (file_name, NULL);
|
||||||
free (file_name);
|
free (file_name);
|
||||||
if (invalid)
|
if (invalid)
|
||||||
@ -824,6 +875,8 @@ xdg_mime_list_mime_parents (const char *mime)
|
|||||||
char **result;
|
char **result;
|
||||||
int i, n;
|
int i, n;
|
||||||
|
|
||||||
|
xdg_mime_init ();
|
||||||
|
|
||||||
if (_caches)
|
if (_caches)
|
||||||
return _xdg_mime_cache_list_mime_parents (mime);
|
return _xdg_mime_cache_list_mime_parents (mime);
|
||||||
|
|
||||||
|
@ -6,23 +6,7 @@
|
|||||||
* Copyright (C) 2003 Red Hat, Inc.
|
* Copyright (C) 2003 Red Hat, Inc.
|
||||||
* Copyright (C) 2003 Jonathan Blandford <jrb@alum.mit.edu>
|
* Copyright (C) 2003 Jonathan Blandford <jrb@alum.mit.edu>
|
||||||
*
|
*
|
||||||
* Licensed under the Academic Free License version 2.0
|
* SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0
|
||||||
* Or under the following terms:
|
|
||||||
*
|
|
||||||
* 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 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
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* 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, write to the
|
|
||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
* Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@ -119,6 +103,8 @@ int xdg_mime_register_reload_callback (XdgMimeCallback callback,
|
|||||||
XdgMimeDestroy destroy);
|
XdgMimeDestroy destroy);
|
||||||
void xdg_mime_remove_callback (int callback_id);
|
void xdg_mime_remove_callback (int callback_id);
|
||||||
|
|
||||||
|
void xdg_mime_set_dirs (const char * const *dirs);
|
||||||
|
|
||||||
/* Private versions of functions that don't call xdg_mime_init () */
|
/* Private versions of functions that don't call xdg_mime_init () */
|
||||||
int _xdg_mime_mime_type_equal (const char *mime_a,
|
int _xdg_mime_mime_type_equal (const char *mime_a,
|
||||||
const char *mime_b);
|
const char *mime_b);
|
||||||
|
@ -6,23 +6,7 @@
|
|||||||
* Copyright (C) 2004 Red Hat, Inc.
|
* Copyright (C) 2004 Red Hat, Inc.
|
||||||
* Copyright (C) 2004 Matthias Clasen <mclasen@redhat.com>
|
* Copyright (C) 2004 Matthias Clasen <mclasen@redhat.com>
|
||||||
*
|
*
|
||||||
* Licensed under the Academic Free License version 2.0
|
* SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0
|
||||||
* Or under the following terms:
|
|
||||||
*
|
|
||||||
* 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 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
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* 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, write to the
|
|
||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
* Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -6,23 +6,7 @@
|
|||||||
* Copyright (C) 2004 Red Hat, Inc.
|
* Copyright (C) 2004 Red Hat, Inc.
|
||||||
* Copyright (C) 200 Matthias Clasen <mclasen@redhat.com>
|
* Copyright (C) 200 Matthias Clasen <mclasen@redhat.com>
|
||||||
*
|
*
|
||||||
* Licensed under the Academic Free License version 2.0
|
* SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0
|
||||||
* Or under the following terms:
|
|
||||||
*
|
|
||||||
* 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 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
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* 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, write to the
|
|
||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
* Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __XDG_MIME_ALIAS_H__
|
#ifndef __XDG_MIME_ALIAS_H__
|
||||||
|
@ -5,23 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (C) 2005 Matthias Clasen <mclasen@redhat.com>
|
* Copyright (C) 2005 Matthias Clasen <mclasen@redhat.com>
|
||||||
*
|
*
|
||||||
* Licensed under the Academic Free License version 2.0
|
* SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0
|
||||||
* Or under the following terms:
|
|
||||||
*
|
|
||||||
* 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 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
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* 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, write to the
|
|
||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
* Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
@ -72,6 +56,10 @@
|
|||||||
#define MAP_FAILED ((void *) -1)
|
#define MAP_FAILED ((void *) -1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef S_ISREG
|
||||||
|
#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define MAJOR_VERSION 1
|
#define MAJOR_VERSION 1
|
||||||
#define MINOR_VERSION_MIN 1
|
#define MINOR_VERSION_MIN 1
|
||||||
#define MINOR_VERSION_MAX 2
|
#define MINOR_VERSION_MAX 2
|
||||||
@ -157,6 +145,12 @@ _xdg_mime_cache_new_from_file (const char *file_name)
|
|||||||
if (fd != -1)
|
if (fd != -1)
|
||||||
close (fd);
|
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 */
|
#endif /* HAVE_MMAP */
|
||||||
|
|
||||||
return cache;
|
return cache;
|
||||||
@ -302,10 +296,16 @@ cache_alias_lookup (const char *alias)
|
|||||||
for (i = 0; _caches[i]; i++)
|
for (i = 0; _caches[i]; i++)
|
||||||
{
|
{
|
||||||
XdgMimeCache *cache = _caches[i];
|
XdgMimeCache *cache = _caches[i];
|
||||||
xdg_uint32_t list_offset = GET_UINT32 (cache->buffer, 4);
|
xdg_uint32_t list_offset;
|
||||||
xdg_uint32_t n_entries = GET_UINT32 (cache->buffer, list_offset);
|
xdg_uint32_t n_entries;
|
||||||
xdg_uint32_t 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;
|
min = 0;
|
||||||
max = n_entries - 1;
|
max = n_entries - 1;
|
||||||
while (max >= min)
|
while (max >= min)
|
||||||
@ -348,10 +348,16 @@ cache_glob_lookup_literal (const char *file_name,
|
|||||||
for (i = 0; _caches[i]; i++)
|
for (i = 0; _caches[i]; i++)
|
||||||
{
|
{
|
||||||
XdgMimeCache *cache = _caches[i];
|
XdgMimeCache *cache = _caches[i];
|
||||||
xdg_uint32_t list_offset = GET_UINT32 (cache->buffer, 12);
|
xdg_uint32_t list_offset;
|
||||||
xdg_uint32_t n_entries = GET_UINT32 (cache->buffer, list_offset);
|
xdg_uint32_t n_entries;
|
||||||
xdg_uint32_t 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;
|
min = 0;
|
||||||
max = n_entries - 1;
|
max = n_entries - 1;
|
||||||
while (max >= min)
|
while (max >= min)
|
||||||
@ -404,8 +410,14 @@ cache_glob_lookup_fnmatch (const char *file_name,
|
|||||||
{
|
{
|
||||||
XdgMimeCache *cache = _caches[i];
|
XdgMimeCache *cache = _caches[i];
|
||||||
|
|
||||||
xdg_uint32_t list_offset = GET_UINT32 (cache->buffer, 20);
|
xdg_uint32_t list_offset;
|
||||||
xdg_uint32_t n_entries = GET_UINT32 (cache->buffer, 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);
|
||||||
|
|
||||||
for (j = 0; j < n_entries && n < n_mime_types; j++)
|
for (j = 0; j < n_entries && n < n_mime_types; j++)
|
||||||
{
|
{
|
||||||
@ -528,9 +540,16 @@ cache_glob_lookup_suffix (const char *file_name,
|
|||||||
{
|
{
|
||||||
XdgMimeCache *cache = _caches[i];
|
XdgMimeCache *cache = _caches[i];
|
||||||
|
|
||||||
xdg_uint32_t list_offset = GET_UINT32 (cache->buffer, 16);
|
xdg_uint32_t list_offset;
|
||||||
xdg_uint32_t n_entries = GET_UINT32 (cache->buffer, list_offset);
|
xdg_uint32_t n_entries;
|
||||||
xdg_uint32_t offset = GET_UINT32 (cache->buffer, list_offset + 4);
|
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);
|
||||||
|
|
||||||
n = cache_glob_node_lookup_suffix (cache,
|
n = cache_glob_node_lookup_suffix (cache,
|
||||||
n_entries, offset,
|
n_entries, offset,
|
||||||
@ -637,6 +656,9 @@ _xdg_mime_cache_get_max_buffer_extents (void)
|
|||||||
{
|
{
|
||||||
XdgMimeCache *cache = _caches[i];
|
XdgMimeCache *cache = _caches[i];
|
||||||
|
|
||||||
|
if (cache->buffer == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
offset = GET_UINT32 (cache->buffer, 24);
|
offset = GET_UINT32 (cache->buffer, 24);
|
||||||
max_extent = MAX (max_extent, GET_UINT32 (cache->buffer, offset + 4));
|
max_extent = MAX (max_extent, GET_UINT32 (cache->buffer, offset + 4));
|
||||||
}
|
}
|
||||||
@ -663,6 +685,9 @@ cache_get_mime_type_for_data (const void *data,
|
|||||||
int prio;
|
int prio;
|
||||||
const char *match;
|
const char *match;
|
||||||
|
|
||||||
|
if (cache->buffer == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
match = cache_magic_lookup_data (cache, data, len, &prio);
|
match = cache_magic_lookup_data (cache, data, len, &prio);
|
||||||
if (prio > priority)
|
if (prio > priority)
|
||||||
{
|
{
|
||||||
@ -864,11 +889,16 @@ _xdg_mime_cache_mime_type_subclass (const char *mime,
|
|||||||
for (i = 0; _caches[i]; i++)
|
for (i = 0; _caches[i]; i++)
|
||||||
{
|
{
|
||||||
XdgMimeCache *cache = _caches[i];
|
XdgMimeCache *cache = _caches[i];
|
||||||
|
xdg_uint32_t list_offset;
|
||||||
xdg_uint32_t list_offset = GET_UINT32 (cache->buffer, 8);
|
xdg_uint32_t n_entries;
|
||||||
xdg_uint32_t n_entries = GET_UINT32 (cache->buffer, list_offset);
|
|
||||||
xdg_uint32_t offset, n_parents, parent_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;
|
min = 0;
|
||||||
max = n_entries - 1;
|
max = n_entries - 1;
|
||||||
while (max >= min)
|
while (max >= min)
|
||||||
@ -889,7 +919,9 @@ _xdg_mime_cache_mime_type_subclass (const char *mime,
|
|||||||
for (j = 0; j < n_parents; j++)
|
for (j = 0; j < n_parents; j++)
|
||||||
{
|
{
|
||||||
parent_offset = GET_UINT32 (cache->buffer, offset + 4 + 4 * j);
|
parent_offset = GET_UINT32 (cache->buffer, offset + 4 + 4 * j);
|
||||||
if (_xdg_mime_cache_mime_type_subclass (cache->buffer + parent_offset, ubase))
|
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))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -928,9 +960,14 @@ _xdg_mime_cache_list_mime_parents (const char *mime)
|
|||||||
for (i = 0; _caches[i]; i++)
|
for (i = 0; _caches[i]; i++)
|
||||||
{
|
{
|
||||||
XdgMimeCache *cache = _caches[i];
|
XdgMimeCache *cache = _caches[i];
|
||||||
|
xdg_uint32_t list_offset;
|
||||||
xdg_uint32_t list_offset = GET_UINT32 (cache->buffer, 8);
|
xdg_uint32_t n_entries;
|
||||||
xdg_uint32_t n_entries = GET_UINT32 (cache->buffer, list_offset);
|
|
||||||
|
if (cache->buffer == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
list_offset = GET_UINT32 (cache->buffer, 8);
|
||||||
|
n_entries = GET_UINT32 (cache->buffer, list_offset);
|
||||||
|
|
||||||
for (j = 0; j < n_entries; j++)
|
for (j = 0; j < n_entries; j++)
|
||||||
{
|
{
|
||||||
@ -980,10 +1017,16 @@ cache_lookup_icon (const char *mime, int header)
|
|||||||
for (i = 0; _caches[i]; i++)
|
for (i = 0; _caches[i]; i++)
|
||||||
{
|
{
|
||||||
XdgMimeCache *cache = _caches[i];
|
XdgMimeCache *cache = _caches[i];
|
||||||
xdg_uint32_t list_offset = GET_UINT32 (cache->buffer, header);
|
xdg_uint32_t list_offset;
|
||||||
xdg_uint32_t n_entries = GET_UINT32 (cache->buffer, list_offset);
|
xdg_uint32_t n_entries;
|
||||||
xdg_uint32_t 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;
|
min = 0;
|
||||||
max = n_entries - 1;
|
max = n_entries - 1;
|
||||||
while (max >= min)
|
while (max >= min)
|
||||||
@ -1060,6 +1103,10 @@ _xdg_mime_cache_glob_dump (void)
|
|||||||
xdg_uint32_t list_offset;
|
xdg_uint32_t list_offset;
|
||||||
xdg_uint32_t n_entries;
|
xdg_uint32_t n_entries;
|
||||||
xdg_uint32_t offset;
|
xdg_uint32_t offset;
|
||||||
|
|
||||||
|
if (cache->buffer == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
list_offset = GET_UINT32 (cache->buffer, 16);
|
list_offset = GET_UINT32 (cache->buffer, 16);
|
||||||
n_entries = GET_UINT32 (cache->buffer, list_offset);
|
n_entries = GET_UINT32 (cache->buffer, list_offset);
|
||||||
offset = GET_UINT32 (cache->buffer, list_offset + 4);
|
offset = GET_UINT32 (cache->buffer, list_offset + 4);
|
||||||
|
@ -5,23 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (C) 2005 Matthias Clasen <mclasen@redhat.com>
|
* Copyright (C) 2005 Matthias Clasen <mclasen@redhat.com>
|
||||||
*
|
*
|
||||||
* Licensed under the Academic Free License version 2.0
|
* SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0
|
||||||
* Or under the following terms:
|
|
||||||
*
|
|
||||||
* 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 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
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* 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, write to the
|
|
||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
* Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __XDG_MIME_CACHE_H__
|
#ifndef __XDG_MIME_CACHE_H__
|
||||||
|
@ -6,23 +6,7 @@
|
|||||||
* Copyright (C) 2003 Red Hat, Inc.
|
* Copyright (C) 2003 Red Hat, Inc.
|
||||||
* Copyright (C) 2003 Jonathan Blandford <jrb@alum.mit.edu>
|
* Copyright (C) 2003 Jonathan Blandford <jrb@alum.mit.edu>
|
||||||
*
|
*
|
||||||
* Licensed under the Academic Free License version 2.0
|
* SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0
|
||||||
* Or under the following terms:
|
|
||||||
*
|
|
||||||
* 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 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
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* 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, write to the
|
|
||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
* Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -6,23 +6,7 @@
|
|||||||
* Copyright (C) 2003 Red Hat, Inc.
|
* Copyright (C) 2003 Red Hat, Inc.
|
||||||
* Copyright (C) 2003 Jonathan Blandford <jrb@alum.mit.edu>
|
* Copyright (C) 2003 Jonathan Blandford <jrb@alum.mit.edu>
|
||||||
*
|
*
|
||||||
* Licensed under the Academic Free License version 2.0
|
* SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0
|
||||||
* Or under the following terms:
|
|
||||||
*
|
|
||||||
* 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 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
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* 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, write to the
|
|
||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
* Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __XDG_MIME_GLOB_H__
|
#ifndef __XDG_MIME_GLOB_H__
|
||||||
|
@ -5,23 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (C) 2008 Red Hat, Inc.
|
* Copyright (C) 2008 Red Hat, Inc.
|
||||||
*
|
*
|
||||||
* Licensed under the Academic Free License version 2.0
|
* SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0
|
||||||
* Or under the following terms:
|
|
||||||
*
|
|
||||||
* 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 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
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* 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, write to the
|
|
||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
* Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -5,23 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (C) 2008 Red Hat, Inc.
|
* Copyright (C) 2008 Red Hat, Inc.
|
||||||
*
|
*
|
||||||
* Licensed under the Academic Free License version 2.0
|
* SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0
|
||||||
* Or under the following terms:
|
|
||||||
*
|
|
||||||
* 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 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
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* 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, write to the
|
|
||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
* Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __XDG_MIME_ICON_H__
|
#ifndef __XDG_MIME_ICON_H__
|
||||||
|
@ -6,23 +6,7 @@
|
|||||||
* Copyright (C) 2003 Red Hat, Inc.
|
* Copyright (C) 2003 Red Hat, Inc.
|
||||||
* Copyright (C) 2003 Jonathan Blandford <jrb@alum.mit.edu>
|
* Copyright (C) 2003 Jonathan Blandford <jrb@alum.mit.edu>
|
||||||
*
|
*
|
||||||
* Licensed under the Academic Free License version 2.0
|
* SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0
|
||||||
* Or under the following terms:
|
|
||||||
*
|
|
||||||
* 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 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
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* 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, write to the
|
|
||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
* Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -6,23 +6,7 @@
|
|||||||
* Copyright (C) 2003 Red Hat, Inc.
|
* Copyright (C) 2003 Red Hat, Inc.
|
||||||
* Copyright (C) 2003 Jonathan Blandford <jrb@alum.mit.edu>
|
* Copyright (C) 2003 Jonathan Blandford <jrb@alum.mit.edu>
|
||||||
*
|
*
|
||||||
* Licensed under the Academic Free License version 2.0
|
* SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0
|
||||||
* Or under the following terms:
|
|
||||||
*
|
|
||||||
* 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 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
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* 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, write to the
|
|
||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
* Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __XDG_MIME_INT_H__
|
#ifndef __XDG_MIME_INT_H__
|
||||||
|
@ -6,23 +6,7 @@
|
|||||||
* Copyright (C) 2003 Red Hat, Inc.
|
* Copyright (C) 2003 Red Hat, Inc.
|
||||||
* Copyright (C) 2003 Jonathan Blandford <jrb@alum.mit.edu>
|
* Copyright (C) 2003 Jonathan Blandford <jrb@alum.mit.edu>
|
||||||
*
|
*
|
||||||
* Licensed under the Academic Free License version 2.0
|
* SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0
|
||||||
* Or under the following terms:
|
|
||||||
*
|
|
||||||
* 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 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
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* 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, write to the
|
|
||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
* Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
@ -103,6 +87,8 @@ _xdg_mime_magic_matchlet_new (void)
|
|||||||
XdgMimeMagicMatchlet *matchlet;
|
XdgMimeMagicMatchlet *matchlet;
|
||||||
|
|
||||||
matchlet = malloc (sizeof (XdgMimeMagicMatchlet));
|
matchlet = malloc (sizeof (XdgMimeMagicMatchlet));
|
||||||
|
if (matchlet == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
matchlet->indent = 0;
|
matchlet->indent = 0;
|
||||||
matchlet->offset = 0;
|
matchlet->offset = 0;
|
||||||
@ -355,6 +341,11 @@ _xdg_mime_magic_parse_magic_line (FILE *magic_file,
|
|||||||
return XDG_MIME_MAGIC_ERROR;
|
return XDG_MIME_MAGIC_ERROR;
|
||||||
|
|
||||||
matchlet = _xdg_mime_magic_matchlet_new ();
|
matchlet = _xdg_mime_magic_matchlet_new ();
|
||||||
|
|
||||||
|
/* OOM */
|
||||||
|
if (matchlet == NULL)
|
||||||
|
return XDG_MIME_MAGIC_ERROR;
|
||||||
|
|
||||||
matchlet->indent = indent;
|
matchlet->indent = indent;
|
||||||
matchlet->offset = _xdg_mime_magic_read_a_number (magic_file, &end_of_file);
|
matchlet->offset = _xdg_mime_magic_read_a_number (magic_file, &end_of_file);
|
||||||
if (end_of_file)
|
if (end_of_file)
|
||||||
@ -479,7 +470,9 @@ _xdg_mime_magic_parse_magic_line (FILE *magic_file,
|
|||||||
/* We clean up the matchlet, byte swapping if needed */
|
/* We clean up the matchlet, byte swapping if needed */
|
||||||
if (matchlet->word_size > 1)
|
if (matchlet->word_size > 1)
|
||||||
{
|
{
|
||||||
|
#if LITTLE_ENDIAN
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
#endif
|
||||||
if (matchlet->value_length % matchlet->word_size != 0)
|
if (matchlet->value_length % matchlet->word_size != 0)
|
||||||
{
|
{
|
||||||
_xdg_mime_magic_matchlet_free (matchlet);
|
_xdg_mime_magic_matchlet_free (matchlet);
|
||||||
@ -767,6 +760,11 @@ _xdg_mime_magic_read_magic_file (XdgMimeMagic *mime_magic,
|
|||||||
{
|
{
|
||||||
case XDG_MIME_MAGIC_SECTION:
|
case XDG_MIME_MAGIC_SECTION:
|
||||||
match = _xdg_mime_magic_match_new ();
|
match = _xdg_mime_magic_match_new ();
|
||||||
|
|
||||||
|
/* OOM */
|
||||||
|
if (match == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
state = _xdg_mime_magic_parse_header (magic_file, match);
|
state = _xdg_mime_magic_parse_header (magic_file, match);
|
||||||
if (state == XDG_MIME_MAGIC_EOF || state == XDG_MIME_MAGIC_ERROR)
|
if (state == XDG_MIME_MAGIC_EOF || state == XDG_MIME_MAGIC_ERROR)
|
||||||
_xdg_mime_magic_match_free (match);
|
_xdg_mime_magic_match_free (match);
|
||||||
@ -784,6 +782,11 @@ _xdg_mime_magic_read_magic_file (XdgMimeMagic *mime_magic,
|
|||||||
break;
|
break;
|
||||||
case XDG_MIME_MAGIC_ERROR:
|
case XDG_MIME_MAGIC_ERROR:
|
||||||
state = _xdg_mime_magic_parse_error (magic_file);
|
state = _xdg_mime_magic_parse_error (magic_file);
|
||||||
|
|
||||||
|
/* After a parse error we can only be at EOF or reset to starting a
|
||||||
|
* new section. */
|
||||||
|
assert (state == XDG_MIME_MAGIC_EOF || state == XDG_MIME_MAGIC_SECTION);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case XDG_MIME_MAGIC_EOF:
|
case XDG_MIME_MAGIC_EOF:
|
||||||
default:
|
default:
|
||||||
|
@ -6,23 +6,7 @@
|
|||||||
* Copyright (C) 2003 Red Hat, Inc.
|
* Copyright (C) 2003 Red Hat, Inc.
|
||||||
* Copyright (C) 2003 Jonathan Blandford <jrb@alum.mit.edu>
|
* Copyright (C) 2003 Jonathan Blandford <jrb@alum.mit.edu>
|
||||||
*
|
*
|
||||||
* Licensed under the Academic Free License version 2.0
|
* SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0
|
||||||
* Or under the following terms:
|
|
||||||
*
|
|
||||||
* 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 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
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* 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, write to the
|
|
||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
* Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __XDG_MIME_MAGIC_H__
|
#ifndef __XDG_MIME_MAGIC_H__
|
||||||
|
@ -6,23 +6,7 @@
|
|||||||
* Copyright (C) 2004 Red Hat, Inc.
|
* Copyright (C) 2004 Red Hat, Inc.
|
||||||
* Copyright (C) 2004 Matthias Clasen <mclasen@redhat.com>
|
* Copyright (C) 2004 Matthias Clasen <mclasen@redhat.com>
|
||||||
*
|
*
|
||||||
* Licensed under the Academic Free License version 2.0
|
* SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0
|
||||||
* Or under the following terms:
|
|
||||||
*
|
|
||||||
* 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 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
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* 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, write to the
|
|
||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
* Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
@ -111,6 +95,7 @@ _xdg_mime_parent_list_lookup (XdgParentList *list,
|
|||||||
{
|
{
|
||||||
key.mime = (char *)mime;
|
key.mime = (char *)mime;
|
||||||
key.parents = NULL;
|
key.parents = NULL;
|
||||||
|
key.n_parents = 0;
|
||||||
|
|
||||||
entry = bsearch (&key, list->parents, list->n_mimes,
|
entry = bsearch (&key, list->parents, list->n_mimes,
|
||||||
sizeof (XdgMimeParents), &parent_entry_cmp);
|
sizeof (XdgMimeParents), &parent_entry_cmp);
|
||||||
|
@ -6,23 +6,7 @@
|
|||||||
* Copyright (C) 2004 Red Hat, Inc.
|
* Copyright (C) 2004 Red Hat, Inc.
|
||||||
* Copyright (C) 200 Matthias Clasen <mclasen@redhat.com>
|
* Copyright (C) 200 Matthias Clasen <mclasen@redhat.com>
|
||||||
*
|
*
|
||||||
* Licensed under the Academic Free License version 2.0
|
* SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0
|
||||||
* Or under the following terms:
|
|
||||||
*
|
|
||||||
* 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 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
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* 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, write to the
|
|
||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
* Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __XDG_MIME_PARENT_H__
|
#ifndef __XDG_MIME_PARENT_H__
|
||||||
|
Loading…
Reference in New Issue
Block a user