gresolver.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. /* GIO - GLib Input, Output and Streaming Library
  2. *
  3. * Copyright (C) 2008 Red Hat, Inc.
  4. * Copyright (C) 2018 Igalia S.L.
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General
  17. * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef __G_RESOLVER_H__
  20. #define __G_RESOLVER_H__
  21. #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
  22. #error "Only <gio/gio.h> can be included directly."
  23. #endif
  24. #include <gio/giotypes.h>
  25. G_BEGIN_DECLS
  26. #define G_TYPE_RESOLVER (g_resolver_get_type ())
  27. #define G_RESOLVER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_RESOLVER, GResolver))
  28. #define G_RESOLVER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_RESOLVER, GResolverClass))
  29. #define G_IS_RESOLVER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_RESOLVER))
  30. #define G_IS_RESOLVER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_RESOLVER))
  31. #define G_RESOLVER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_RESOLVER, GResolverClass))
  32. typedef struct _GResolverPrivate GResolverPrivate;
  33. typedef struct _GResolverClass GResolverClass;
  34. struct _GResolver {
  35. GObject parent_instance;
  36. GResolverPrivate *priv;
  37. };
  38. /**
  39. * GResolverNameLookupFlags:
  40. * @G_RESOLVER_NAME_LOOKUP_FLAGS_DEFAULT: default behavior (same as g_resolver_lookup_by_name())
  41. * @G_RESOLVER_NAME_LOOKUP_FLAGS_IPV4_ONLY: only resolve ipv4 addresses
  42. * @G_RESOLVER_NAME_LOOKUP_FLAGS_IPV6_ONLY: only resolve ipv6 addresses
  43. *
  44. * Flags to modify lookup behavior.
  45. *
  46. * Since: 2.60
  47. */
  48. typedef enum {
  49. G_RESOLVER_NAME_LOOKUP_FLAGS_DEFAULT = 0,
  50. G_RESOLVER_NAME_LOOKUP_FLAGS_IPV4_ONLY = 1 << 0,
  51. G_RESOLVER_NAME_LOOKUP_FLAGS_IPV6_ONLY = 1 << 1,
  52. } GResolverNameLookupFlags;
  53. struct _GResolverClass {
  54. GObjectClass parent_class;
  55. /* Signals */
  56. void ( *reload) (GResolver *resolver);
  57. /* Virtual methods */
  58. GList * ( *lookup_by_name) (GResolver *resolver,
  59. const gchar *hostname,
  60. GCancellable *cancellable,
  61. GError **error);
  62. void ( *lookup_by_name_async) (GResolver *resolver,
  63. const gchar *hostname,
  64. GCancellable *cancellable,
  65. GAsyncReadyCallback callback,
  66. gpointer user_data);
  67. GList * ( *lookup_by_name_finish) (GResolver *resolver,
  68. GAsyncResult *result,
  69. GError **error);
  70. gchar * ( *lookup_by_address) (GResolver *resolver,
  71. GInetAddress *address,
  72. GCancellable *cancellable,
  73. GError **error);
  74. void ( *lookup_by_address_async) (GResolver *resolver,
  75. GInetAddress *address,
  76. GCancellable *cancellable,
  77. GAsyncReadyCallback callback,
  78. gpointer user_data);
  79. gchar * ( *lookup_by_address_finish) (GResolver *resolver,
  80. GAsyncResult *result,
  81. GError **error);
  82. GList * ( *lookup_service) (GResolver *resolver,
  83. const gchar *rrname,
  84. GCancellable *cancellable,
  85. GError **error);
  86. void ( *lookup_service_async) (GResolver *resolver,
  87. const gchar *rrname,
  88. GCancellable *cancellable,
  89. GAsyncReadyCallback callback,
  90. gpointer user_data);
  91. GList * ( *lookup_service_finish) (GResolver *resolver,
  92. GAsyncResult *result,
  93. GError **error);
  94. GList * ( *lookup_records) (GResolver *resolver,
  95. const gchar *rrname,
  96. GResolverRecordType record_type,
  97. GCancellable *cancellable,
  98. GError **error);
  99. void ( *lookup_records_async) (GResolver *resolver,
  100. const gchar *rrname,
  101. GResolverRecordType record_type,
  102. GCancellable *cancellable,
  103. GAsyncReadyCallback callback,
  104. gpointer user_data);
  105. GList * ( *lookup_records_finish) (GResolver *resolver,
  106. GAsyncResult *result,
  107. GError **error);
  108. /**
  109. * GResolverClass::lookup_by_name_with_flags_async:
  110. * @resolver: a #GResolver
  111. * @hostname: the hostname to resolve
  112. * @flags: extra #GResolverNameLookupFlags to modify the lookup
  113. * @cancellable: (nullable): a #GCancellable
  114. * @callback: (scope async): a #GAsyncReadyCallback to call when completed
  115. * @user_data: (closure): data to pass to @callback
  116. *
  117. * Asynchronous version of GResolverClass::lookup_by_name_with_flags
  118. *
  119. * GResolverClass::lookup_by_name_with_flags_finish will be called to get
  120. * the result.
  121. *
  122. * Since: 2.60
  123. */
  124. void ( *lookup_by_name_with_flags_async) (GResolver *resolver,
  125. const gchar *hostname,
  126. GResolverNameLookupFlags flags,
  127. GCancellable *cancellable,
  128. GAsyncReadyCallback callback,
  129. gpointer user_data);
  130. /**
  131. * GResolverClass::lookup_by_name_with_flags_finish:
  132. * @resolver: a #GResolver
  133. * @result: a #GAsyncResult
  134. * @error: (nullable): a pointer to a %NULL #GError
  135. *
  136. * Gets the result from GResolverClass::lookup_by_name_with_flags_async
  137. *
  138. * Returns: (element-type GInetAddress) (transfer full): List of #GInetAddress.
  139. * Since: 2.60
  140. */
  141. GList * ( *lookup_by_name_with_flags_finish) (GResolver *resolver,
  142. GAsyncResult *result,
  143. GError **error);
  144. /**
  145. * GResolverClass::lookup_by_name_with_flags:
  146. * @resolver: a #GResolver
  147. * @hostname: the hostname to resolve
  148. * @flags: extra #GResolverNameLookupFlags to modify the lookup
  149. * @cancellable: (nullable): a #GCancellable
  150. * @error: (nullable): a pointer to a %NULL #GError
  151. *
  152. * This is identical to GResolverClass::lookup_by_name except it takes
  153. * @flags which modifies the behavior of the lookup. See #GResolverNameLookupFlags
  154. * for more details.
  155. *
  156. * Returns: (element-type GInetAddress) (transfer full): List of #GInetAddress.
  157. * Since: 2.60
  158. */
  159. GList * ( *lookup_by_name_with_flags) (GResolver *resolver,
  160. const gchar *hostname,
  161. GResolverNameLookupFlags flags,
  162. GCancellable *cancellable,
  163. GError **error);
  164. };
  165. GLIB_AVAILABLE_IN_ALL
  166. GType g_resolver_get_type (void) G_GNUC_CONST;
  167. GLIB_AVAILABLE_IN_ALL
  168. GResolver *g_resolver_get_default (void);
  169. GLIB_AVAILABLE_IN_ALL
  170. void g_resolver_set_default (GResolver *resolver);
  171. GLIB_AVAILABLE_IN_ALL
  172. GList *g_resolver_lookup_by_name (GResolver *resolver,
  173. const gchar *hostname,
  174. GCancellable *cancellable,
  175. GError **error);
  176. GLIB_AVAILABLE_IN_ALL
  177. void g_resolver_lookup_by_name_async (GResolver *resolver,
  178. const gchar *hostname,
  179. GCancellable *cancellable,
  180. GAsyncReadyCallback callback,
  181. gpointer user_data);
  182. GLIB_AVAILABLE_IN_ALL
  183. GList *g_resolver_lookup_by_name_finish (GResolver *resolver,
  184. GAsyncResult *result,
  185. GError **error);
  186. GLIB_AVAILABLE_IN_2_60
  187. void g_resolver_lookup_by_name_with_flags_async (GResolver *resolver,
  188. const gchar *hostname,
  189. GResolverNameLookupFlags flags,
  190. GCancellable *cancellable,
  191. GAsyncReadyCallback callback,
  192. gpointer user_data);
  193. GLIB_AVAILABLE_IN_2_60
  194. GList *g_resolver_lookup_by_name_with_flags_finish (GResolver *resolver,
  195. GAsyncResult *result,
  196. GError **error);
  197. GLIB_AVAILABLE_IN_2_60
  198. GList *g_resolver_lookup_by_name_with_flags (GResolver *resolver,
  199. const gchar *hostname,
  200. GResolverNameLookupFlags flags,
  201. GCancellable *cancellable,
  202. GError **error);
  203. GLIB_AVAILABLE_IN_ALL
  204. void g_resolver_free_addresses (GList *addresses);
  205. GLIB_AVAILABLE_IN_ALL
  206. gchar *g_resolver_lookup_by_address (GResolver *resolver,
  207. GInetAddress *address,
  208. GCancellable *cancellable,
  209. GError **error);
  210. GLIB_AVAILABLE_IN_ALL
  211. void g_resolver_lookup_by_address_async (GResolver *resolver,
  212. GInetAddress *address,
  213. GCancellable *cancellable,
  214. GAsyncReadyCallback callback,
  215. gpointer user_data);
  216. GLIB_AVAILABLE_IN_ALL
  217. gchar *g_resolver_lookup_by_address_finish (GResolver *resolver,
  218. GAsyncResult *result,
  219. GError **error);
  220. GLIB_AVAILABLE_IN_ALL
  221. GList *g_resolver_lookup_service (GResolver *resolver,
  222. const gchar *service,
  223. const gchar *protocol,
  224. const gchar *domain,
  225. GCancellable *cancellable,
  226. GError **error);
  227. GLIB_AVAILABLE_IN_ALL
  228. void g_resolver_lookup_service_async (GResolver *resolver,
  229. const gchar *service,
  230. const gchar *protocol,
  231. const gchar *domain,
  232. GCancellable *cancellable,
  233. GAsyncReadyCallback callback,
  234. gpointer user_data);
  235. GLIB_AVAILABLE_IN_ALL
  236. GList *g_resolver_lookup_service_finish (GResolver *resolver,
  237. GAsyncResult *result,
  238. GError **error);
  239. GLIB_AVAILABLE_IN_2_34
  240. GList *g_resolver_lookup_records (GResolver *resolver,
  241. const gchar *rrname,
  242. GResolverRecordType record_type,
  243. GCancellable *cancellable,
  244. GError **error);
  245. GLIB_AVAILABLE_IN_2_34
  246. void g_resolver_lookup_records_async (GResolver *resolver,
  247. const gchar *rrname,
  248. GResolverRecordType record_type,
  249. GCancellable *cancellable,
  250. GAsyncReadyCallback callback,
  251. gpointer user_data);
  252. GLIB_AVAILABLE_IN_2_34
  253. GList *g_resolver_lookup_records_finish (GResolver *resolver,
  254. GAsyncResult *result,
  255. GError **error);
  256. GLIB_AVAILABLE_IN_ALL
  257. void g_resolver_free_targets (GList *targets);
  258. /**
  259. * G_RESOLVER_ERROR:
  260. *
  261. * Error domain for #GResolver. Errors in this domain will be from the
  262. * #GResolverError enumeration. See #GError for more information on
  263. * error domains.
  264. */
  265. #define G_RESOLVER_ERROR (g_resolver_error_quark ())
  266. GLIB_AVAILABLE_IN_ALL
  267. GQuark g_resolver_error_quark (void);
  268. G_END_DECLS
  269. #endif /* __G_RESOLVER_H__ */