xdgmime.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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, write to the
  24. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  25. * Boston, MA 02111-1307, USA.
  26. */
  27. #ifndef __XDG_MIME_H__
  28. #define __XDG_MIME_H__
  29. #include <stdlib.h>
  30. #include <sys/stat.h>
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif /* __cplusplus */
  34. #ifdef XDG_PREFIX
  35. #define XDG_ENTRY(func) _XDG_ENTRY2(XDG_PREFIX,func)
  36. #define _XDG_ENTRY2(prefix,func) _XDG_ENTRY3(prefix,func)
  37. #define _XDG_ENTRY3(prefix,func) prefix##_##func
  38. #define XDG_RESERVED_ENTRY(func) _XDG_RESERVED_ENTRY2(XDG_PREFIX,func)
  39. #define _XDG_RESERVED_ENTRY2(prefix,func) _XDG_RESERVED_ENTRY3(prefix,func)
  40. #define _XDG_RESERVED_ENTRY3(prefix,func) _##prefix##_##func
  41. #endif
  42. typedef void (*XdgMimeCallback) (void *user_data);
  43. typedef void (*XdgMimeDestroy) (void *user_data);
  44. #ifdef XDG_PREFIX
  45. #define xdg_mime_get_mime_type_for_data XDG_ENTRY(get_mime_type_for_data)
  46. #define xdg_mime_get_mime_type_for_file XDG_ENTRY(get_mime_type_for_file)
  47. #define xdg_mime_get_mime_type_from_file_name XDG_ENTRY(get_mime_type_from_file_name)
  48. #define xdg_mime_get_mime_types_from_file_name XDG_ENTRY(get_mime_types_from_file_name)
  49. #define xdg_mime_is_valid_mime_type XDG_ENTRY(is_valid_mime_type)
  50. #define xdg_mime_mime_type_equal XDG_ENTRY(mime_type_equal)
  51. #define xdg_mime_media_type_equal XDG_ENTRY(media_type_equal)
  52. #define xdg_mime_mime_type_subclass XDG_ENTRY(mime_type_subclass)
  53. #define xdg_mime_get_mime_parents XDG_ENTRY(get_mime_parents)
  54. #define xdg_mime_list_mime_parents XDG_ENTRY(list_mime_parents)
  55. #define xdg_mime_unalias_mime_type XDG_ENTRY(unalias_mime_type)
  56. #define xdg_mime_get_max_buffer_extents XDG_ENTRY(get_max_buffer_extents)
  57. #define xdg_mime_shutdown XDG_ENTRY(shutdown)
  58. #define xdg_mime_dump XDG_ENTRY(dump)
  59. #define xdg_mime_register_reload_callback XDG_ENTRY(register_reload_callback)
  60. #define xdg_mime_remove_callback XDG_ENTRY(remove_callback)
  61. #define xdg_mime_type_unknown XDG_ENTRY(type_unknown)
  62. #define xdg_mime_type_empty XDG_ENTRY(type_empty)
  63. #define xdg_mime_type_textplain XDG_ENTRY(type_textplain)
  64. #define xdg_mime_get_icon XDG_ENTRY(get_icon)
  65. #define xdg_mime_get_generic_icon XDG_ENTRY(get_generic_icon)
  66. #define _xdg_mime_mime_type_equal XDG_RESERVED_ENTRY(mime_type_equal)
  67. #define _xdg_mime_mime_type_subclass XDG_RESERVED_ENTRY(mime_type_subclass)
  68. #define _xdg_mime_unalias_mime_type XDG_RESERVED_ENTRY(unalias_mime_type)
  69. #endif
  70. extern const char xdg_mime_type_unknown[];
  71. extern const char xdg_mime_type_empty[];
  72. extern const char xdg_mime_type_textplain[];
  73. #define XDG_MIME_TYPE_UNKNOWN xdg_mime_type_unknown
  74. #define XDG_MIME_TYPE_EMPTY xdg_mime_type_empty
  75. #define XDG_MIME_TYPE_TEXTPLAIN xdg_mime_type_textplain
  76. const char *xdg_mime_get_mime_type_for_data (const void *data,
  77. size_t len,
  78. int *result_prio);
  79. const char *xdg_mime_get_mime_type_for_file (const char *file_name,
  80. struct stat *statbuf);
  81. const char *xdg_mime_get_mime_type_from_file_name (const char *file_name);
  82. int xdg_mime_get_mime_types_from_file_name(const char *file_name,
  83. const char *mime_types[],
  84. int n_mime_types);
  85. int xdg_mime_is_valid_mime_type (const char *mime_type);
  86. int xdg_mime_mime_type_equal (const char *mime_a,
  87. const char *mime_b);
  88. int xdg_mime_media_type_equal (const char *mime_a,
  89. const char *mime_b);
  90. int xdg_mime_mime_type_subclass (const char *mime_a,
  91. const char *mime_b);
  92. /* xdg_mime_get_mime_parents() is deprecated since it does
  93. * not work correctly with caches. Use xdg_mime_list_parents()
  94. * instead, but notice that that function expects you to free
  95. * the array it returns.
  96. */
  97. const char **xdg_mime_get_mime_parents (const char *mime);
  98. char ** xdg_mime_list_mime_parents (const char *mime);
  99. const char *xdg_mime_unalias_mime_type (const char *mime);
  100. const char *xdg_mime_get_icon (const char *mime);
  101. const char *xdg_mime_get_generic_icon (const char *mime);
  102. int xdg_mime_get_max_buffer_extents (void);
  103. void xdg_mime_shutdown (void);
  104. void xdg_mime_dump (void);
  105. int xdg_mime_register_reload_callback (XdgMimeCallback callback,
  106. void *data,
  107. XdgMimeDestroy destroy);
  108. void xdg_mime_remove_callback (int callback_id);
  109. /* Private versions of functions that don't call xdg_mime_init () */
  110. int _xdg_mime_mime_type_equal (const char *mime_a,
  111. const char *mime_b);
  112. int _xdg_mime_mime_type_subclass (const char *mime,
  113. const char *base);
  114. const char *_xdg_mime_unalias_mime_type (const char *mime);
  115. #ifdef __cplusplus
  116. }
  117. #endif /* __cplusplus */
  118. #endif /* __XDG_MIME_H__ */