1 /* -*- mode: C; c-file-style: "gnu" -*- */
2 /* xdgmime.h: XDG Mime Spec mime resolver. Based on version 0.11 of the spec.
4 * More info can be found at http://www.freedesktop.org/standards/
6 * Copyright (C) 2003 Red Hat, Inc.
7 * Copyright (C) 2003 Jonathan Blandford <jrb@alum.mit.edu>
9 * SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0
13 #ifndef __XDG_MIME_H__
14 #define __XDG_MIME_H__
21 #endif /* __cplusplus */
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
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
33 typedef void (*XdgMimeCallback) (void *user_data);
34 typedef void (*XdgMimeDestroy) (void *user_data);
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)
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)
65 extern const char xdg_mime_type_unknown[];
66 extern const char xdg_mime_type_empty[];
67 extern 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
72 const char *xdg_mime_get_mime_type_for_data (const void *data,
75 const char *xdg_mime_get_mime_type_for_file (const char *file_name,
76 struct stat *statbuf);
77 const char *xdg_mime_get_mime_type_from_file_name (const char *file_name);
78 int xdg_mime_get_mime_types_from_file_name(const char *file_name,
79 const char *mime_types[],
81 int xdg_mime_is_valid_mime_type (const char *mime_type);
82 int xdg_mime_mime_type_equal (const char *mime_a,
84 int xdg_mime_media_type_equal (const char *mime_a,
86 int xdg_mime_mime_type_subclass (const char *mime_a,
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.
93 const char **xdg_mime_get_mime_parents (const char *mime);
94 char ** xdg_mime_list_mime_parents (const char *mime);
95 const char *xdg_mime_unalias_mime_type (const char *mime);
96 const char *xdg_mime_get_icon (const char *mime);
97 const char *xdg_mime_get_generic_icon (const char *mime);
98 int xdg_mime_get_max_buffer_extents (void);
99 void xdg_mime_shutdown (void);
100 void xdg_mime_dump (void);
101 int xdg_mime_register_reload_callback (XdgMimeCallback callback,
103 XdgMimeDestroy destroy);
104 void xdg_mime_remove_callback (int callback_id);
106 void xdg_mime_set_dirs (const char * const *dirs);
108 /* Private versions of functions that don't call xdg_mime_init () */
109 int _xdg_mime_mime_type_equal (const char *mime_a,
111 int _xdg_mime_mime_type_subclass (const char *mime,
114 const char *_xdg_mime_unalias_mime_type (const char *mime);
119 #endif /* __cplusplus */
120 #endif /* __XDG_MIME_H__ */