Back to index

libcitadel  8.12
xdgmime.h
Go to the documentation of this file.
00001 /* -*- mode: C; c-file-style: "gnu" -*- */
00002 /* xdgmime.h: XDG Mime Spec mime resolver.  Based on version 0.11 of the spec.
00003  *
00004  * More info can be found at http://www.freedesktop.org/standards/
00005  * 
00006  * Copyright (C) 2003  Red Hat, Inc.
00007  * Copyright (C) 2003  Jonathan Blandford <jrb@alum.mit.edu>
00008  *
00009  * Licensed under the Academic Free License version 2.0
00010  * Or under the following terms:
00011  * 
00012  * This library is free software; you can redistribute it and/or
00013  * modify it under the terms of the GNU Lesser General Public
00014  * License as published by the Free Software Foundation; either
00015  * version 2 of the License, or (at your option) any later version.
00016  *
00017  * This library is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020  * Lesser General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU Lesser General Public
00023  * License along with this library; if not, write to the
00024  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00025  * Boston, MA 02111-1307, USA.
00026  */
00027 
00028 
00029 #ifndef __XDG_MIME_H__
00030 #define __XDG_MIME_H__
00031 
00032 #include <stdlib.h>
00033 #include <sys/stat.h>
00034 
00035 #ifdef __cplusplus
00036 extern "C" {
00037 #endif /* __cplusplus */
00038 
00039 #ifdef XDG_PREFIX
00040 #define XDG_ENTRY(func) _XDG_ENTRY2(XDG_PREFIX,func)
00041 #define _XDG_ENTRY2(prefix,func) _XDG_ENTRY3(prefix,func)
00042 #define _XDG_ENTRY3(prefix,func) prefix##_##func
00043 
00044 #define XDG_RESERVED_ENTRY(func) _XDG_RESERVED_ENTRY2(XDG_PREFIX,func)
00045 #define _XDG_RESERVED_ENTRY2(prefix,func) _XDG_RESERVED_ENTRY3(prefix,func)
00046 #define _XDG_RESERVED_ENTRY3(prefix,func) _##prefix##_##func
00047 #endif
00048 
00049 typedef void (*XdgMimeCallback) (void *user_data);
00050 typedef void (*XdgMimeDestroy)  (void *user_data);
00051 
00052   
00053 #ifdef XDG_PREFIX
00054 #define xdg_mime_get_mime_type_for_data       XDG_ENTRY(mime_get_mime_type_for_data)
00055 #define xdg_mime_get_mime_type_for_file       XDG_ENTRY(mime_get_mime_type_for_file)
00056 #define xdg_mime_get_mime_type_from_file_name XDG_ENTRY(mime_get_mime_type_from_file_name)
00057 #define xdg_mime_is_valid_mime_type           XDG_ENTRY(mime_is_valid_mime_type)
00058 #define xdg_mime_mime_type_equal              XDG_ENTRY(mime_mime_type_equal)
00059 #define xdg_mime_media_type_equal             XDG_ENTRY(mime_media_type_equal)
00060 #define xdg_mime_mime_type_subclass           XDG_ENTRY(mime_mime_type_subclass)
00061 #define xdg_mime_get_mime_parents             XDG_ENTRY(mime_get_mime_parents)
00062 #define xdg_mime_list_mime_parents            XDG_ENTRY(mime_list_mime_parents)
00063 #define xdg_mime_unalias_mime_type            XDG_ENTRY(mime_unalias_mime_type)
00064 #define xdg_mime_get_max_buffer_extents       XDG_ENTRY(mime_get_max_buffer_extents)
00065 #define xdg_mime_shutdown                     XDG_ENTRY(mime_shutdown)
00066 #define xdg_mime_dump                         XDG_ENTRY(mime_dump)
00067 #define xdg_mime_register_reload_callback     XDG_ENTRY(mime_register_reload_callback)
00068 #define xdg_mime_remove_callback              XDG_ENTRY(mime_remove_callback)
00069 #define xdg_mime_type_unknown                 XDG_ENTRY(mime_type_unknown)
00070 
00071 #define _xdg_mime_mime_type_equal             XDG_RESERVED_ENTRY(mime_mime_type_equal)
00072 #define _xdg_mime_media_type_equal            XDG_RESERVED_ENTRY(mime_media_type_equal)
00073 #define _xdg_mime_mime_type_subclass          XDG_RESERVED_ENTRY(mime_mime_type_subclass)
00074 #endif
00075 
00076 extern const char xdg_mime_type_unknown[];
00077 #define XDG_MIME_TYPE_UNKNOWN xdg_mime_type_unknown
00078 
00079 const char  *xdg_mime_get_mime_type_for_data       (const void *data,
00080                                               size_t      len);
00081 const char  *xdg_mime_get_mime_type_for_file       (const char *file_name,
00082                                                     struct stat *statbuf);
00083 const char  *xdg_mime_get_mime_type_from_file_name (const char *file_name);
00084 int          xdg_mime_is_valid_mime_type           (const char *mime_type);
00085 int          xdg_mime_mime_type_equal              (const char *mime_a,
00086                                               const char *mime_b);
00087 int          xdg_mime_media_type_equal             (const char *mime_a,
00088                                               const char *mime_b);
00089 int          xdg_mime_mime_type_subclass           (const char *mime_a,
00090                                               const char *mime_b);
00091   /* xdg_mime_get_mime_parents() is deprecated since it does
00092    * not work correctly with caches. Use xdg_mime_list_parents() 
00093    * instead, but notice that that function expects you to free
00094    * the array it returns. 
00095    */
00096 const char **xdg_mime_get_mime_parents              (const char *mime);
00097 char **      xdg_mime_list_mime_parents             (const char *mime);
00098 const char  *xdg_mime_unalias_mime_type             (const char *mime);
00099 int          xdg_mime_get_max_buffer_extents       (void);
00100 void         xdg_mime_shutdown                     (void);
00101 void         xdg_mime_dump                         (void);
00102 int          xdg_mime_register_reload_callback     (XdgMimeCallback  callback,
00103                                               void            *data,
00104                                               XdgMimeDestroy   destroy);
00105 void         xdg_mime_remove_callback              (int              callback_id);
00106 
00107   /* Private versions of functions that don't call xdg_mime_init () */
00108 int          _xdg_mime_mime_type_equal             (const char *mime_a,
00109                                               const char *mime_b);
00110 int          _xdg_mime_media_type_equal            (const char *mime_a,
00111                                               const char *mime_b);
00112 int          _xdg_mime_mime_type_subclass          (const char *mime,
00113                                               const char *base);
00114 
00115 #ifdef __cplusplus
00116 }
00117 #endif /* __cplusplus */
00118 
00119 #endif /* __XDG_MIME_H__ */