1 /* SPDX-License-Identifier: LGPL-2.1-or-later */ 2 #pragma once 3 4 #include "sd-resolve.h" 5 6 int resolve_getaddrinfo_with_destroy_callback( 7 sd_resolve *resolve, sd_resolve_query **q, 8 const char *node, const char *service, const struct addrinfo *hints, 9 sd_resolve_getaddrinfo_handler_t callback, 10 sd_resolve_destroy_t destroy_callback, void *userdata); 11 int resolve_getnameinfo_with_destroy_callback( 12 sd_resolve *resolve, sd_resolve_query **q, 13 const struct sockaddr *sa, socklen_t salen, int flags, uint64_t get, 14 sd_resolve_getnameinfo_handler_t callback, 15 sd_resolve_destroy_t destroy_callback, void *userdata); 16 17 #define resolve_getaddrinfo(resolve, ret_query, node, service, hints, callback, destroy_callback, userdata) \ 18 ({ \ 19 int (*_callback_)(sd_resolve_query*, int, const struct addrinfo*, typeof(userdata)) = callback; \ 20 void (*_destroy_)(typeof(userdata)) = destroy_callback; \ 21 resolve_getaddrinfo_with_destroy_callback( \ 22 resolve, ret_query, \ 23 node, service, hints, \ 24 (sd_resolve_getaddrinfo_handler_t) _callback_, \ 25 (sd_resolve_destroy_t) _destroy_, \ 26 userdata); \ 27 }) 28 29 #define resolve_getnameinfo(resolve, ret_query, sa, salen, flags, get, callback, destroy_callback, userdata) \ 30 ({ \ 31 int (*_callback_)(sd_resolve_query*, int, const char*, const char*, typeof(userdata)) = callback; \ 32 void (*_destroy_)(typeof(userdata)) = destroy_callback; \ 33 resolve_getaddrinfo_with_destroy_callback( \ 34 resolve, ret_query, \ 35 sa, salen, flags, get, \ 36 (sd_resolve_getnameinfo_handler_t) _callback_, \ 37 (sd_resolve_destroy_t) _destroy_, \ 38 userdata); \ 39 }) 40