]> git.proxmox.com Git - libxdgmime-perl.git/blame - src/xdgmime.h
Squashed 'xdgmime-source/' changes from 28b70c4..3e7ee2d
[libxdgmime-perl.git] / src / xdgmime.h
CommitLineData
cf31d981
SI
1/* -*- mode: C; c-file-style: "gnu" -*- */
2/* xdgmime.h: XDG Mime Spec mime resolver. Based on version 0.11 of the spec.
3 *
4 * More info can be found at http://www.freedesktop.org/standards/
5 *
6 * Copyright (C) 2003 Red Hat, Inc.
7 * Copyright (C) 2003 Jonathan Blandford <jrb@alum.mit.edu>
8 *
73d5a30a 9 * SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0
cf31d981
SI
10 */
11
12
13#ifndef __XDG_MIME_H__
14#define __XDG_MIME_H__
15
16#include <stdlib.h>
17#include <sys/stat.h>
18
19#ifdef __cplusplus
20extern "C" {
21#endif /* __cplusplus */
22
23#ifdef XDG_PREFIX
24#define XDG_ENTRY(func) _XDG_ENTRY2(XDG_PREFIX,func)
25#define _XDG_ENTRY2(prefix,func) _XDG_ENTRY3(prefix,func)
26#define _XDG_ENTRY3(prefix,func) prefix##_##func
27
28#define XDG_RESERVED_ENTRY(func) _XDG_RESERVED_ENTRY2(XDG_PREFIX,func)
29#define _XDG_RESERVED_ENTRY2(prefix,func) _XDG_RESERVED_ENTRY3(prefix,func)
30#define _XDG_RESERVED_ENTRY3(prefix,func) _##prefix##_##func
31#endif
32
33typedef void (*XdgMimeCallback) (void *user_data);
34typedef void (*XdgMimeDestroy) (void *user_data);
35
36
37#ifdef XDG_PREFIX
38#define xdg_mime_get_mime_type_for_data XDG_ENTRY(get_mime_type_for_data)
39#define xdg_mime_get_mime_type_for_file XDG_ENTRY(get_mime_type_for_file)
40#define xdg_mime_get_mime_type_from_file_name XDG_ENTRY(get_mime_type_from_file_name)
41#define xdg_mime_get_mime_types_from_file_name XDG_ENTRY(get_mime_types_from_file_name)
42#define xdg_mime_is_valid_mime_type XDG_ENTRY(is_valid_mime_type)
43#define xdg_mime_mime_type_equal XDG_ENTRY(mime_type_equal)
44#define xdg_mime_media_type_equal XDG_ENTRY(media_type_equal)
45#define xdg_mime_mime_type_subclass XDG_ENTRY(mime_type_subclass)
46#define xdg_mime_get_mime_parents XDG_ENTRY(get_mime_parents)
47#define xdg_mime_list_mime_parents XDG_ENTRY(list_mime_parents)
48#define xdg_mime_unalias_mime_type XDG_ENTRY(unalias_mime_type)
49#define xdg_mime_get_max_buffer_extents XDG_ENTRY(get_max_buffer_extents)
50#define xdg_mime_shutdown XDG_ENTRY(shutdown)
51#define xdg_mime_dump XDG_ENTRY(dump)
52#define xdg_mime_register_reload_callback XDG_ENTRY(register_reload_callback)
53#define xdg_mime_remove_callback XDG_ENTRY(remove_callback)
54#define xdg_mime_type_unknown XDG_ENTRY(type_unknown)
55#define xdg_mime_type_empty XDG_ENTRY(type_empty)
56#define xdg_mime_type_textplain XDG_ENTRY(type_textplain)
57#define xdg_mime_get_icon XDG_ENTRY(get_icon)
58#define xdg_mime_get_generic_icon XDG_ENTRY(get_generic_icon)
59
60#define _xdg_mime_mime_type_equal XDG_RESERVED_ENTRY(mime_type_equal)
61#define _xdg_mime_mime_type_subclass XDG_RESERVED_ENTRY(mime_type_subclass)
62#define _xdg_mime_unalias_mime_type XDG_RESERVED_ENTRY(unalias_mime_type)
63#endif
64
65extern const char xdg_mime_type_unknown[];
66extern const char xdg_mime_type_empty[];
67extern const char xdg_mime_type_textplain[];
68#define XDG_MIME_TYPE_UNKNOWN xdg_mime_type_unknown
69#define XDG_MIME_TYPE_EMPTY xdg_mime_type_empty
70#define XDG_MIME_TYPE_TEXTPLAIN xdg_mime_type_textplain
71
72const char *xdg_mime_get_mime_type_for_data (const void *data,
73 size_t len,
74 int *result_prio);
75const char *xdg_mime_get_mime_type_for_file (const char *file_name,
76 struct stat *statbuf);
77const char *xdg_mime_get_mime_type_from_file_name (const char *file_name);
78int xdg_mime_get_mime_types_from_file_name(const char *file_name,
79 const char *mime_types[],
80 int n_mime_types);
81int xdg_mime_is_valid_mime_type (const char *mime_type);
82int xdg_mime_mime_type_equal (const char *mime_a,
83 const char *mime_b);
84int xdg_mime_media_type_equal (const char *mime_a,
85 const char *mime_b);
86int xdg_mime_mime_type_subclass (const char *mime_a,
87 const char *mime_b);
88 /* xdg_mime_get_mime_parents() is deprecated since it does
89 * not work correctly with caches. Use xdg_mime_list_parents()
90 * instead, but notice that that function expects you to free
91 * the array it returns.
92 */
93const char **xdg_mime_get_mime_parents (const char *mime);
94char ** xdg_mime_list_mime_parents (const char *mime);
95const char *xdg_mime_unalias_mime_type (const char *mime);
96const char *xdg_mime_get_icon (const char *mime);
97const char *xdg_mime_get_generic_icon (const char *mime);
98int xdg_mime_get_max_buffer_extents (void);
99void xdg_mime_shutdown (void);
100void xdg_mime_dump (void);
101int xdg_mime_register_reload_callback (XdgMimeCallback callback,
102 void *data,
103 XdgMimeDestroy destroy);
104void xdg_mime_remove_callback (int callback_id);
105
73d5a30a
SI
106void xdg_mime_set_dirs (const char * const *dirs);
107
cf31d981
SI
108 /* Private versions of functions that don't call xdg_mime_init () */
109int _xdg_mime_mime_type_equal (const char *mime_a,
110 const char *mime_b);
111int _xdg_mime_mime_type_subclass (const char *mime,
112 const char *base);
113const char *_xdg_mime_unalias_mime_type (const char *mime);
114
115
116#ifdef __cplusplus
117}
118#endif /* __cplusplus */
119#endif /* __XDG_MIME_H__ */