GDBusInterfaceVTable: clarify memory handling for the method() virtual function
[platform/upstream/glib.git] / gio / xdgmime / xdgmime.h
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  *
9  * Licensed under the Academic Free License version 2.0
10  * Or under the following terms:
11  * 
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public
14  * License as published by the Free Software Foundation; either
15  * version 2 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
24  */
25
26
27 #ifndef __XDG_MIME_H__
28 #define __XDG_MIME_H__
29
30 #include <stdlib.h>
31 #include <sys/stat.h>
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif /* __cplusplus */
36
37 #ifdef XDG_PREFIX
38 #define XDG_ENTRY(func) _XDG_ENTRY2(XDG_PREFIX,func)
39 #define _XDG_ENTRY2(prefix,func) _XDG_ENTRY3(prefix,func)
40 #define _XDG_ENTRY3(prefix,func) prefix##_##func
41
42 #define XDG_RESERVED_ENTRY(func) _XDG_RESERVED_ENTRY2(XDG_PREFIX,func)
43 #define _XDG_RESERVED_ENTRY2(prefix,func) _XDG_RESERVED_ENTRY3(prefix,func)
44 #define _XDG_RESERVED_ENTRY3(prefix,func) _##prefix##_##func
45 #endif
46
47 typedef void (*XdgMimeCallback) (void *user_data);
48 typedef void (*XdgMimeDestroy)  (void *user_data);
49
50   
51 #ifdef XDG_PREFIX
52 #define xdg_mime_get_mime_type_for_data       XDG_ENTRY(get_mime_type_for_data)
53 #define xdg_mime_get_mime_type_for_file       XDG_ENTRY(get_mime_type_for_file)
54 #define xdg_mime_get_mime_type_from_file_name XDG_ENTRY(get_mime_type_from_file_name)
55 #define xdg_mime_get_mime_types_from_file_name XDG_ENTRY(get_mime_types_from_file_name)
56 #define xdg_mime_is_valid_mime_type           XDG_ENTRY(is_valid_mime_type)
57 #define xdg_mime_mime_type_equal              XDG_ENTRY(mime_type_equal)
58 #define xdg_mime_media_type_equal             XDG_ENTRY(media_type_equal)
59 #define xdg_mime_mime_type_subclass           XDG_ENTRY(mime_type_subclass)
60 #define xdg_mime_get_mime_parents             XDG_ENTRY(get_mime_parents)
61 #define xdg_mime_list_mime_parents            XDG_ENTRY(list_mime_parents)
62 #define xdg_mime_unalias_mime_type            XDG_ENTRY(unalias_mime_type)
63 #define xdg_mime_get_max_buffer_extents       XDG_ENTRY(get_max_buffer_extents)
64 #define xdg_mime_shutdown                     XDG_ENTRY(shutdown)
65 #define xdg_mime_dump                         XDG_ENTRY(dump)
66 #define xdg_mime_register_reload_callback     XDG_ENTRY(register_reload_callback)
67 #define xdg_mime_remove_callback              XDG_ENTRY(remove_callback)
68 #define xdg_mime_type_unknown                 XDG_ENTRY(type_unknown)
69 #define xdg_mime_get_icon                     XDG_ENTRY(get_icon)
70 #define xdg_mime_get_generic_icon             XDG_ENTRY(get_generic_icon)
71
72 #define _xdg_mime_mime_type_subclass          XDG_RESERVED_ENTRY(mime_type_subclass)
73 #define _xdg_mime_mime_type_equal             XDG_RESERVED_ENTRY(mime_type_equal)
74 #define _xdg_mime_unalias_mime_type           XDG_RESERVED_ENTRY(unalias_mime_type)
75 #endif
76
77 extern const char xdg_mime_type_unknown[];
78 #define XDG_MIME_TYPE_UNKNOWN xdg_mime_type_unknown
79
80 const char  *xdg_mime_get_mime_type_for_data       (const void *data,
81                                                     size_t      len,
82                                                     int        *result_prio);
83 #ifdef NOT_USED_IN_GIO
84 const char  *xdg_mime_get_mime_type_for_file       (const char *file_name,
85                                                     struct stat *statbuf);
86 const char  *xdg_mime_get_mime_type_from_file_name (const char *file_name);
87 #endif
88 int          xdg_mime_get_mime_types_from_file_name(const char *file_name,
89                                                     const char *mime_types[],
90                                                     int         n_mime_types);
91 #ifdef NOT_USED_IN_GIO
92 int          xdg_mime_is_valid_mime_type           (const char *mime_type);
93 #endif
94 int          xdg_mime_mime_type_equal              (const char *mime_a,
95                                                     const char *mime_b);
96 int          xdg_mime_media_type_equal             (const char *mime_a,
97                                                     const char *mime_b);
98 int          xdg_mime_mime_type_subclass           (const char *mime_a,
99                                                     const char *mime_b);
100   /* xdg_mime_get_mime_parents() is deprecated since it does
101    * not work correctly with caches. Use xdg_mime_list_parents() 
102    * instead, but notice that that function expects you to free
103    * the array it returns. 
104    */
105 #ifdef NOT_USED_IN_GIO
106 const char **xdg_mime_get_mime_parents             (const char *mime);
107 #endif
108 char **      xdg_mime_list_mime_parents            (const char *mime);
109 const char  *xdg_mime_unalias_mime_type            (const char *mime);
110 const char  *xdg_mime_get_icon                     (const char *mime);
111 const char  *xdg_mime_get_generic_icon             (const char *mime);
112 int          xdg_mime_get_max_buffer_extents       (void);
113 void         xdg_mime_shutdown                     (void);
114 #ifdef NOT_USED_IN_GIO
115 void         xdg_mime_dump                         (void);
116 #endif
117 int          xdg_mime_register_reload_callback     (XdgMimeCallback  callback,
118                                                     void            *data,
119                                                     XdgMimeDestroy   destroy);
120 #ifdef NOT_USED_IN_GIO
121 void         xdg_mime_remove_callback              (int              callback_id);
122 #endif
123
124    /* Private versions of functions that don't call xdg_mime_init () */
125 int          _xdg_mime_mime_type_equal             (const char *mime_a,
126                                                     const char *mime_b);
127 int          _xdg_mime_mime_type_subclass          (const char *mime,
128                                                     const char *base);
129 const char  *_xdg_mime_unalias_mime_type           (const char *mime);
130
131
132 #ifdef __cplusplus
133 }
134 #endif /* __cplusplus */
135 #endif /* __XDG_MIME_H__ */