1 /* GIO - GLib Input, Output and Streaming Library
3 * Copyright (C) 2008 Red Hat, Inc.
4 * Copyright (C) 2018 Igalia S.L.
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.
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.
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/>.
20 #ifndef __G_RESOLVER_H__
21 #define __G_RESOLVER_H__
23 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
24 #error "Only <gio/gio.h> can be included directly."
27 #include <gio/giotypes.h>
31 #define G_TYPE_RESOLVER (g_resolver_get_type ())
32 #define G_RESOLVER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_RESOLVER, GResolver))
33 #define G_RESOLVER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_RESOLVER, GResolverClass))
34 #define G_IS_RESOLVER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_RESOLVER))
35 #define G_IS_RESOLVER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_RESOLVER))
36 #define G_RESOLVER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_RESOLVER, GResolverClass))
38 typedef struct _GResolverPrivate GResolverPrivate;
39 typedef struct _GResolverClass GResolverClass;
42 GObject parent_instance;
44 GResolverPrivate *priv;
48 * GResolverNameLookupFlags:
49 * @G_RESOLVER_NAME_LOOKUP_FLAGS_DEFAULT: default behavior (same as g_resolver_lookup_by_name())
50 * @G_RESOLVER_NAME_LOOKUP_FLAGS_IPV4_ONLY: only resolve ipv4 addresses
51 * @G_RESOLVER_NAME_LOOKUP_FLAGS_IPV6_ONLY: only resolve ipv6 addresses
53 * Flags to modify lookup behavior.
58 G_RESOLVER_NAME_LOOKUP_FLAGS_DEFAULT = 0,
59 G_RESOLVER_NAME_LOOKUP_FLAGS_IPV4_ONLY = 1 << 0,
60 G_RESOLVER_NAME_LOOKUP_FLAGS_IPV6_ONLY = 1 << 1,
61 } GResolverNameLookupFlags;
63 struct _GResolverClass {
64 GObjectClass parent_class;
67 void ( *reload) (GResolver *resolver);
70 GList * ( *lookup_by_name) (GResolver *resolver,
71 const gchar *hostname,
72 GCancellable *cancellable,
74 void ( *lookup_by_name_async) (GResolver *resolver,
75 const gchar *hostname,
76 GCancellable *cancellable,
77 GAsyncReadyCallback callback,
79 GList * ( *lookup_by_name_finish) (GResolver *resolver,
83 gchar * ( *lookup_by_address) (GResolver *resolver,
84 GInetAddress *address,
85 GCancellable *cancellable,
87 void ( *lookup_by_address_async) (GResolver *resolver,
88 GInetAddress *address,
89 GCancellable *cancellable,
90 GAsyncReadyCallback callback,
92 gchar * ( *lookup_by_address_finish) (GResolver *resolver,
96 GList * ( *lookup_service) (GResolver *resolver,
98 GCancellable *cancellable,
100 void ( *lookup_service_async) (GResolver *resolver,
102 GCancellable *cancellable,
103 GAsyncReadyCallback callback,
105 GList * ( *lookup_service_finish) (GResolver *resolver,
106 GAsyncResult *result,
109 GList * ( *lookup_records) (GResolver *resolver,
111 GResolverRecordType record_type,
112 GCancellable *cancellable,
115 void ( *lookup_records_async) (GResolver *resolver,
117 GResolverRecordType record_type,
118 GCancellable *cancellable,
119 GAsyncReadyCallback callback,
122 GList * ( *lookup_records_finish) (GResolver *resolver,
123 GAsyncResult *result,
126 * GResolverClass::lookup_by_name_with_flags_async:
127 * @resolver: a #GResolver
128 * @hostname: the hostname to resolve
129 * @flags: extra #GResolverNameLookupFlags to modify the lookup
130 * @cancellable: (nullable): a #GCancellable
131 * @callback: (scope async): a #GAsyncReadyCallback to call when completed
132 * @user_data: (closure): data to pass to @callback
134 * Asynchronous version of GResolverClass::lookup_by_name_with_flags
136 * GResolverClass::lookup_by_name_with_flags_finish will be called to get
141 void ( *lookup_by_name_with_flags_async) (GResolver *resolver,
142 const gchar *hostname,
143 GResolverNameLookupFlags flags,
144 GCancellable *cancellable,
145 GAsyncReadyCallback callback,
148 * GResolverClass::lookup_by_name_with_flags_finish:
149 * @resolver: a #GResolver
150 * @result: a #GAsyncResult
151 * @error: (nullable): a pointer to a %NULL #GError
153 * Gets the result from GResolverClass::lookup_by_name_with_flags_async
155 * Returns: (element-type GInetAddress) (transfer full): List of #GInetAddress.
158 GList * ( *lookup_by_name_with_flags_finish) (GResolver *resolver,
159 GAsyncResult *result,
162 * GResolverClass::lookup_by_name_with_flags:
163 * @resolver: a #GResolver
164 * @hostname: the hostname to resolve
165 * @flags: extra #GResolverNameLookupFlags to modify the lookup
166 * @cancellable: (nullable): a #GCancellable
167 * @error: (nullable): a pointer to a %NULL #GError
169 * This is identical to GResolverClass::lookup_by_name except it takes
170 * @flags which modifies the behavior of the lookup. See #GResolverNameLookupFlags
173 * Returns: (element-type GInetAddress) (transfer full): List of #GInetAddress.
176 GList * ( *lookup_by_name_with_flags) (GResolver *resolver,
177 const gchar *hostname,
178 GResolverNameLookupFlags flags,
179 GCancellable *cancellable,
184 GLIB_AVAILABLE_IN_ALL
185 GType g_resolver_get_type (void) G_GNUC_CONST;
186 GLIB_AVAILABLE_IN_ALL
187 GResolver *g_resolver_get_default (void);
188 GLIB_AVAILABLE_IN_ALL
189 void g_resolver_set_default (GResolver *resolver);
190 GLIB_AVAILABLE_IN_ALL
191 GList *g_resolver_lookup_by_name (GResolver *resolver,
192 const gchar *hostname,
193 GCancellable *cancellable,
195 GLIB_AVAILABLE_IN_ALL
196 void g_resolver_lookup_by_name_async (GResolver *resolver,
197 const gchar *hostname,
198 GCancellable *cancellable,
199 GAsyncReadyCallback callback,
201 GLIB_AVAILABLE_IN_ALL
202 GList *g_resolver_lookup_by_name_finish (GResolver *resolver,
203 GAsyncResult *result,
205 GLIB_AVAILABLE_IN_2_60
206 void g_resolver_lookup_by_name_with_flags_async (GResolver *resolver,
207 const gchar *hostname,
208 GResolverNameLookupFlags flags,
209 GCancellable *cancellable,
210 GAsyncReadyCallback callback,
212 GLIB_AVAILABLE_IN_2_60
213 GList *g_resolver_lookup_by_name_with_flags_finish (GResolver *resolver,
214 GAsyncResult *result,
216 GLIB_AVAILABLE_IN_2_60
217 GList *g_resolver_lookup_by_name_with_flags (GResolver *resolver,
218 const gchar *hostname,
219 GResolverNameLookupFlags flags,
220 GCancellable *cancellable,
222 GLIB_AVAILABLE_IN_ALL
223 void g_resolver_free_addresses (GList *addresses);
224 GLIB_AVAILABLE_IN_ALL
225 gchar *g_resolver_lookup_by_address (GResolver *resolver,
226 GInetAddress *address,
227 GCancellable *cancellable,
229 GLIB_AVAILABLE_IN_ALL
230 void g_resolver_lookup_by_address_async (GResolver *resolver,
231 GInetAddress *address,
232 GCancellable *cancellable,
233 GAsyncReadyCallback callback,
235 GLIB_AVAILABLE_IN_ALL
236 gchar *g_resolver_lookup_by_address_finish (GResolver *resolver,
237 GAsyncResult *result,
239 GLIB_AVAILABLE_IN_ALL
240 GList *g_resolver_lookup_service (GResolver *resolver,
241 const gchar *service,
242 const gchar *protocol,
244 GCancellable *cancellable,
246 GLIB_AVAILABLE_IN_ALL
247 void g_resolver_lookup_service_async (GResolver *resolver,
248 const gchar *service,
249 const gchar *protocol,
251 GCancellable *cancellable,
252 GAsyncReadyCallback callback,
254 GLIB_AVAILABLE_IN_ALL
255 GList *g_resolver_lookup_service_finish (GResolver *resolver,
256 GAsyncResult *result,
258 GLIB_AVAILABLE_IN_2_34
259 GList *g_resolver_lookup_records (GResolver *resolver,
261 GResolverRecordType record_type,
262 GCancellable *cancellable,
264 GLIB_AVAILABLE_IN_2_34
265 void g_resolver_lookup_records_async (GResolver *resolver,
267 GResolverRecordType record_type,
268 GCancellable *cancellable,
269 GAsyncReadyCallback callback,
271 GLIB_AVAILABLE_IN_2_34
272 GList *g_resolver_lookup_records_finish (GResolver *resolver,
273 GAsyncResult *result,
275 GLIB_AVAILABLE_IN_ALL
276 void g_resolver_free_targets (GList *targets);
282 * Error domain for #GResolver. Errors in this domain will be from the
283 * #GResolverError enumeration. See #GError for more information on
286 #define G_RESOLVER_ERROR (g_resolver_error_quark ())
287 GLIB_AVAILABLE_IN_ALL
288 GQuark g_resolver_error_quark (void);
292 #endif /* __G_RESOLVER_H__ */