1 #ifndef __GSK_NAME_RESOLVER_H_ 2 #define __GSK_NAME_RESOLVER_H_ 3 4 #include "gsksocketaddress.h" 5 6 G_BEGIN_DECLS 7 8 /* --- typedefs --- */ 9 typedef struct _GskNameResolver GskNameResolver; 10 typedef struct _GskNameResolverIface GskNameResolverIface; 11 typedef struct _GskNameResolverTask GskNameResolverTask; 12 13 /* --- type macros --- */ 14 GType gsk_name_resolver_get_type(void) G_GNUC_CONST; 15 #define GSK_TYPE_NAME_RESOLVER (gsk_name_resolver_get_type ()) 16 #define GSK_NAME_RESOLVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSK_TYPE_NAME_RESOLVER, GskNameResolver)) 17 #define GSK_NAME_RESOLVER_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GSK_TYPE_NAME_RESOLVER, GskNameResolverIface)) 18 #define GSK_IS_NAME_RESOLVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSK_TYPE_NAME_RESOLVER)) 19 20 typedef void (*GskNameResolverSuccessFunc) (GskSocketAddress *address, 21 gpointer func_data); 22 typedef void (*GskNameResolverFailureFunc) (GError *error, 23 gpointer func_data); 24 25 typedef enum 26 { 27 GSK_NAME_RESOLVER_FAMILY_NONE, 28 GSK_NAME_RESOLVER_FAMILY_IPV4 29 } GskNameResolverFamily; 30 31 /* --- structures --- */ 32 struct _GskNameResolverIface 33 { 34 GObjectClass object_class; 35 gpointer (*start_resolve) (GskNameResolver *resolver, 36 GskNameResolverFamily family, 37 const char *name, 38 GskNameResolverSuccessFunc success, 39 GskNameResolverFailureFunc failure, 40 gpointer func_data, 41 GDestroyNotify destroy); 42 gboolean (*cancel_resolve) (GskNameResolver *resolver, 43 gpointer handle); 44 }; 45 46 47 /* --- prototypes --- */ 48 49 /* handling families of names */ 50 GskNameResolverFamily gsk_name_resolver_family_get_by_name (const char *name); 51 const char *gsk_name_resolver_family_get_name(GskNameResolverFamily family); 52 53 /* easy, non-cancellable API */ 54 void gsk_name_resolver_lookup (GskNameResolverFamily family, 55 const char *name, 56 GskNameResolverSuccessFunc success, 57 GskNameResolverFailureFunc failure, 58 gpointer func_data, 59 GDestroyNotify destroy); 60 61 /* starting/cancelling name resolution */ 62 GskNameResolverTask * 63 gsk_name_resolver_task_new (GskNameResolverFamily family, 64 const char *name, 65 GskNameResolverSuccessFunc success, 66 GskNameResolverFailureFunc failure, 67 gpointer func_data, 68 GDestroyNotify destroy); 69 void gsk_name_resolver_task_cancel (GskNameResolverTask *task); 70 void gsk_name_resolver_task_ref (GskNameResolverTask *task); 71 void gsk_name_resolver_task_unref (GskNameResolverTask *task); 72 73 #ifndef GSK_DISABLE_DEPRECATED 74 #define gsk_name_resolve gsk_name_resolver_task_new 75 #endif 76 77 #define gsk_name_resolver_lookup(family, name, success, failure, func_data, destroy) \ 78 gsk_name_resolver_task_unref(gsk_name_resolver_task_new(family, name, success, failure, func_data, destroy)) 79 80 /* tweaking the default name resolver */ 81 void gsk_name_resolver_set_dns_cache_size (guint64 max_bytes, 82 guint max_records); 83 void gsk_name_resolver_set_dns_roundrobin (gboolean do_roundrobin); 84 85 86 /*< protected: for use by implementors of new families only >*/ 87 GskNameResolverFamily gsk_name_resolver_family_unique (const char *name); 88 void gsk_name_resolver_add_family_name (GskNameResolverFamily family, 89 const char *name); 90 91 typedef GskNameResolver *(*GskNameResolverFamilyHandler) (gpointer data); 92 void gsk_name_resolver_add_family_resolver (GskNameResolverFamily family, 93 GskNameResolver *resolver); 94 void gsk_name_resolver_add_family_handler (GskNameResolverFamily family, 95 GskNameResolverFamilyHandler handler, 96 gpointer data, 97 GDestroyNotify destroy); 98 99 G_END_DECLS 100 101 #endif 102