diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libsystemd/resolve-util.h | 2 | ||||
-rw-r--r-- | src/libsystemd/sd-resolve.c | 72 | ||||
-rw-r--r-- | src/libsystemd/test-resolve.c | 4 | ||||
-rw-r--r-- | src/systemd/sd-resolve.h | 42 |
4 files changed, 60 insertions, 60 deletions
diff --git a/src/libsystemd/resolve-util.h b/src/libsystemd/resolve-util.h index 0761c96d96..4310f88504 100644 --- a/src/libsystemd/resolve-util.h +++ b/src/libsystemd/resolve-util.h @@ -23,7 +23,7 @@ #include "util.h" -DEFINE_TRIVIAL_CLEANUP_FUNC(sd_resolve_t*, sd_resolve_free); +DEFINE_TRIVIAL_CLEANUP_FUNC(sd_resolve*, sd_resolve_free); DEFINE_TRIVIAL_CLEANUP_FUNC(unsigned char *, sd_resolve_freeanswer); DEFINE_TRIVIAL_CLEANUP_FUNC(struct addrinfo*, sd_resolve_freeaddrinfo); #define _cleanup_resolve_free_ _cleanup_(sd_resolve_freep) diff --git a/src/libsystemd/sd-resolve.c b/src/libsystemd/sd-resolve.c index 269f5170bd..73a66c4df1 100644 --- a/src/libsystemd/sd-resolve.c +++ b/src/libsystemd/sd-resolve.c @@ -75,20 +75,20 @@ struct sd_resolve { unsigned valid_workers; unsigned current_id, current_index; - sd_resolve_query_t* queries[MAX_QUERIES]; + sd_resolve_query* queries[MAX_QUERIES]; - sd_resolve_query_t *done_head, *done_tail; + sd_resolve_query *done_head, *done_tail; int n_queries; int dead; }; struct sd_resolve_query { - sd_resolve_t *resolve; + sd_resolve *resolve; int done; unsigned id; query_type_t type; - sd_resolve_query_t *done_next, *done_prev; + sd_resolve_query *done_next, *done_prev; int ret; int _errno; int _h_errno; @@ -383,7 +383,7 @@ static int handle_request(int out_fd, const packet_t *packet, size_t length) { } static void* thread_worker(void *p) { - sd_resolve_t *resolve = p; + sd_resolve *resolve = p; sigset_t fullset; /* No signals in this thread please */ @@ -414,8 +414,8 @@ static void* thread_worker(void *p) { return NULL; } -sd_resolve_t* sd_resolve_new(unsigned n_proc) { - sd_resolve_t *resolve = NULL; +sd_resolve* sd_resolve_new(unsigned n_proc) { + sd_resolve *resolve = NULL; int i, r; assert(n_proc >= 1); @@ -423,7 +423,7 @@ sd_resolve_t* sd_resolve_new(unsigned n_proc) { if (n_proc > MAX_WORKERS) n_proc = MAX_WORKERS; - resolve = malloc(sizeof(sd_resolve_t)); + resolve = malloc(sizeof(sd_resolve)); if (!resolve) { errno = ENOMEM; goto fail; @@ -468,7 +468,7 @@ fail: return NULL; } -void sd_resolve_free(sd_resolve_t *resolve) { +void sd_resolve_free(sd_resolve *resolve) { int i; int saved_errno = errno; unsigned p; @@ -511,14 +511,14 @@ void sd_resolve_free(sd_resolve_t *resolve) { errno = saved_errno; } -int sd_resolve_fd(sd_resolve_t *resolve) { +int sd_resolve_fd(sd_resolve *resolve) { assert(resolve); return resolve->fds[RESPONSE_RECV_FD]; } -static sd_resolve_query_t *lookup_query(sd_resolve_t *resolve, unsigned id) { - sd_resolve_query_t *q; +static sd_resolve_query *lookup_query(sd_resolve *resolve, unsigned id) { + sd_resolve_query *q; assert(resolve); q = resolve->queries[id % MAX_QUERIES]; @@ -529,7 +529,7 @@ static sd_resolve_query_t *lookup_query(sd_resolve_t *resolve, unsigned id) { return NULL; } -static void complete_query(sd_resolve_t *resolve, sd_resolve_query_t *q) { +static void complete_query(sd_resolve *resolve, sd_resolve_query *q) { assert(resolve); assert(q); assert(!q->done); @@ -601,9 +601,9 @@ fail: return NULL; } -static int handle_response(sd_resolve_t *resolve, const packet_t *packet, size_t length) { +static int handle_response(sd_resolve *resolve, const packet_t *packet, size_t length) { const rheader_t *resp; - sd_resolve_query_t *q; + sd_resolve_query *q; assert(resolve); @@ -709,7 +709,7 @@ static int handle_response(sd_resolve_t *resolve, const packet_t *packet, size_t return 0; } -int sd_resolve_wait(sd_resolve_t *resolve, int block) { +int sd_resolve_wait(sd_resolve *resolve, int block) { int handled = 0; assert(resolve); @@ -748,8 +748,8 @@ int sd_resolve_wait(sd_resolve_t *resolve, int block) { } } -static sd_resolve_query_t *alloc_query(sd_resolve_t *resolve) { - sd_resolve_query_t *q; +static sd_resolve_query *alloc_query(sd_resolve *resolve) { + sd_resolve_query *q; assert(resolve); if (resolve->n_queries >= MAX_QUERIES) { @@ -765,7 +765,7 @@ static sd_resolve_query_t *alloc_query(sd_resolve_t *resolve) { resolve->current_index -= MAX_QUERIES; } - q = resolve->queries[resolve->current_index] = malloc(sizeof(sd_resolve_query_t)); + q = resolve->queries[resolve->current_index] = malloc(sizeof(sd_resolve_query)); if (!q) { errno = ENOMEM; return NULL; @@ -787,10 +787,10 @@ static sd_resolve_query_t *alloc_query(sd_resolve_t *resolve) { return q; } -sd_resolve_query_t* sd_resolve_getaddrinfo(sd_resolve_t *resolve, const char *node, const char *service, const struct addrinfo *hints) { +sd_resolve_query* sd_resolve_getaddrinfo(sd_resolve *resolve, const char *node, const char *service, const struct addrinfo *hints) { addrinfo_request_t data[BUFSIZE/sizeof(addrinfo_request_t) + 1] = {}; addrinfo_request_t *req = data; - sd_resolve_query_t *q; + sd_resolve_query *q; assert(resolve); assert(node || service); @@ -840,7 +840,7 @@ fail: return NULL; } -int sd_resolve_getaddrinfo_done(sd_resolve_t *resolve, sd_resolve_query_t* q, struct addrinfo **ret_res) { +int sd_resolve_getaddrinfo_done(sd_resolve *resolve, sd_resolve_query* q, struct addrinfo **ret_res) { int ret; assert(resolve); assert(q); @@ -871,10 +871,10 @@ int sd_resolve_getaddrinfo_done(sd_resolve_t *resolve, sd_resolve_query_t* q, st return ret; } -sd_resolve_query_t* sd_resolve_getnameinfo(sd_resolve_t *resolve, const struct sockaddr *sa, socklen_t salen, int flags, int gethost, int getserv) { +sd_resolve_query* sd_resolve_getnameinfo(sd_resolve *resolve, const struct sockaddr *sa, socklen_t salen, int flags, int gethost, int getserv) { nameinfo_request_t data[BUFSIZE/sizeof(nameinfo_request_t) + 1] = {}; nameinfo_request_t *req = data; - sd_resolve_query_t *q; + sd_resolve_query *q; assert(resolve); assert(sa); @@ -917,7 +917,7 @@ fail: return NULL; } -int sd_resolve_getnameinfo_done(sd_resolve_t *resolve, sd_resolve_query_t* q, char *ret_host, size_t hostlen, char *ret_serv, size_t servlen) { +int sd_resolve_getnameinfo_done(sd_resolve *resolve, sd_resolve_query* q, char *ret_host, size_t hostlen, char *ret_serv, size_t servlen) { int ret; assert(resolve); assert(q); @@ -957,10 +957,10 @@ int sd_resolve_getnameinfo_done(sd_resolve_t *resolve, sd_resolve_query_t* q, ch return ret; } -static sd_resolve_query_t * resolve_res(sd_resolve_t *resolve, query_type_t qtype, const char *dname, int class, int type) { +static sd_resolve_query * resolve_res(sd_resolve *resolve, query_type_t qtype, const char *dname, int class, int type) { res_request_t data[BUFSIZE/sizeof(res_request_t) + 1]; res_request_t *req = data; - sd_resolve_query_t *q; + sd_resolve_query *q; assert(resolve); assert(dname); @@ -1002,15 +1002,15 @@ fail: return NULL; } -sd_resolve_query_t* sd_resolve_res_query(sd_resolve_t *resolve, const char *dname, int class, int type) { +sd_resolve_query* sd_resolve_res_query(sd_resolve *resolve, const char *dname, int class, int type) { return resolve_res(resolve, REQUEST_RES_QUERY, dname, class, type); } -sd_resolve_query_t* sd_resolve_res_search(sd_resolve_t *resolve, const char *dname, int class, int type) { +sd_resolve_query* sd_resolve_res_search(sd_resolve *resolve, const char *dname, int class, int type) { return resolve_res(resolve, REQUEST_RES_SEARCH, dname, class, type); } -int sd_resolve_res_done(sd_resolve_t *resolve, sd_resolve_query_t* q, unsigned char **answer) { +int sd_resolve_res_done(sd_resolve *resolve, sd_resolve_query* q, unsigned char **answer) { int ret; assert(resolve); assert(q); @@ -1043,17 +1043,17 @@ int sd_resolve_res_done(sd_resolve_t *resolve, sd_resolve_query_t* q, unsigned c return ret < 0 ? -errno : ret; } -sd_resolve_query_t* sd_resolve_getnext(sd_resolve_t *resolve) { +sd_resolve_query* sd_resolve_getnext(sd_resolve *resolve) { assert(resolve); return resolve->done_head; } -int sd_resolve_getnqueries(sd_resolve_t *resolve) { +int sd_resolve_getnqueries(sd_resolve *resolve) { assert(resolve); return resolve->n_queries; } -void sd_resolve_cancel(sd_resolve_t *resolve, sd_resolve_query_t* q) { +void sd_resolve_cancel(sd_resolve *resolve, sd_resolve_query* q) { int i; int saved_errno = errno; @@ -1116,7 +1116,7 @@ void sd_resolve_freeanswer(unsigned char *answer) { errno = saved_errno; } -int sd_resolve_isdone(sd_resolve_t *resolve, sd_resolve_query_t*q) { +int sd_resolve_isdone(sd_resolve *resolve, sd_resolve_query*q) { assert(resolve); assert(q); assert(q->resolve == resolve); @@ -1124,7 +1124,7 @@ int sd_resolve_isdone(sd_resolve_t *resolve, sd_resolve_query_t*q) { return q->done; } -void sd_resolve_setuserdata(sd_resolve_t *resolve, sd_resolve_query_t *q, void *userdata) { +void sd_resolve_setuserdata(sd_resolve *resolve, sd_resolve_query *q, void *userdata) { assert(q); assert(resolve); assert(q->resolve = resolve); @@ -1132,7 +1132,7 @@ void sd_resolve_setuserdata(sd_resolve_t *resolve, sd_resolve_query_t *q, void * q->userdata = userdata; } -void* sd_resolve_getuserdata(sd_resolve_t *resolve, sd_resolve_query_t *q) { +void* sd_resolve_getuserdata(sd_resolve *resolve, sd_resolve_query *q) { assert(q); assert(resolve); assert(q->resolve = resolve); diff --git a/src/libsystemd/test-resolve.c b/src/libsystemd/test-resolve.c index c7feb1ecdb..7c1e7aa32c 100644 --- a/src/libsystemd/test-resolve.c +++ b/src/libsystemd/test-resolve.c @@ -37,10 +37,10 @@ int main(int argc, char *argv[]) { int r = 1, ret; - _cleanup_resolve_free_ sd_resolve_t *resolve = NULL; + _cleanup_resolve_free_ sd_resolve *resolve = NULL; _cleanup_resolve_addrinfo_free_ struct addrinfo *ai = NULL; _cleanup_resolve_answer_free_ unsigned char *srv = NULL; - sd_resolve_query_t *q1, *q2, *q3; + sd_resolve_query *q1, *q2, *q3; struct addrinfo hints = {}; struct sockaddr_in sa = {}; char host[NI_MAXHOST] = "", serv[NI_MAXSERV] = ""; diff --git a/src/systemd/sd-resolve.h b/src/systemd/sd-resolve.h index 2023f11e72..8df6152c56 100644 --- a/src/systemd/sd-resolve.h +++ b/src/systemd/sd-resolve.h @@ -33,7 +33,7 @@ _SD_BEGIN_DECLARATIONS; * * \section moo Method of operation * - * To use sd-resolve allocate an sd_resolve_t object with + * To use sd-resolve allocate an sd_resolve object with * sd_resolve_new(). This will spawn a number of worker threads (or processes, depending on what is available) which * are subsequently used to process the queries the controlling * program issues via sd_resolve_getaddrinfo() and @@ -45,36 +45,36 @@ _SD_BEGIN_DECLARATIONS; */ /** An opaque sd-resolve session structure */ -typedef struct sd_resolve sd_resolve_t; +typedef struct sd_resolve sd_resolve; /** An opaque sd-resolve query structure */ -typedef struct sd_resolve_query sd_resolve_query_t; +typedef struct sd_resolve_query sd_resolve_query; /** Allocate a new sd-resolve session with n_proc worker processes/threads */ -sd_resolve_t* sd_resolve_new(unsigned n_proc); +sd_resolve* sd_resolve_new(unsigned n_proc); /** Free a sd-resolve session. This destroys all attached - * sd_resolve_query_t objects automatically */ -void sd_resolve_free(sd_resolve_t *resolve); + * sd_resolve_query objects automatically */ +void sd_resolve_free(sd_resolve *resolve); /** Return the UNIX file descriptor to select() for readability * on. Use this function to integrate sd-resolve with your custom main * loop. */ -int sd_resolve_fd(sd_resolve_t *resolve); +int sd_resolve_fd(sd_resolve *resolve); /** Process pending responses. After this function is called you can * get the next completed query object(s) using sd_resolve_getnext(). If * block is non-zero wait until at least one response has been * processed. If block is zero, process all pending responses and * return. */ -int sd_resolve_wait(sd_resolve_t *resolve, int block); +int sd_resolve_wait(sd_resolve *resolve, int block); /** Issue a name to address query on the specified session. The * arguments are compatible with the ones of libc's * getaddrinfo(3). The function returns a new query object. When the * query is completed you may retrieve the results using * sd_resolve_getaddrinfo_done().*/ -sd_resolve_query_t* sd_resolve_getaddrinfo(sd_resolve_t *resolve, const char *node, const char *service, const struct addrinfo *hints); +sd_resolve_query* sd_resolve_getaddrinfo(sd_resolve *resolve, const char *node, const char *service, const struct addrinfo *hints); /** Retrieve the results of a preceding sd_resolve_getaddrinfo() * call. Returns a addrinfo structure and a return value compatible @@ -83,7 +83,7 @@ sd_resolve_query_t* sd_resolve_getaddrinfo(sd_resolve_t *resolve, const char *no * returned addrinfo structure with sd_resolve_freeaddrinfo() and not * libc's freeaddrinfo(3)! If the query is not completed yet EAI_AGAIN * is returned.*/ -int sd_resolve_getaddrinfo_done(sd_resolve_t *resolve, sd_resolve_query_t* q, struct addrinfo **ret_res); +int sd_resolve_getaddrinfo_done(sd_resolve *resolve, sd_resolve_query* q, struct addrinfo **ret_res); /** Issue an address to name query on the specified session. The * arguments are compatible with the ones of libc's @@ -91,26 +91,26 @@ int sd_resolve_getaddrinfo_done(sd_resolve_t *resolve, sd_resolve_query_t* q, st * query is completed you may retrieve the results using * sd_resolve_getnameinfo_done(). Set gethost (resp. getserv) to non-zero * if you want to query the hostname (resp. the service name). */ -sd_resolve_query_t* sd_resolve_getnameinfo(sd_resolve_t *resolve, const struct sockaddr *sa, socklen_t salen, int flags, int gethost, int getserv); +sd_resolve_query* sd_resolve_getnameinfo(sd_resolve *resolve, const struct sockaddr *sa, socklen_t salen, int flags, int gethost, int getserv); /** Retrieve the results of a preceding sd_resolve_getnameinfo() * call. Returns the hostname and the service name in ret_host and * ret_serv. The query object q is destroyed by this call and may not * be used any further. If the query is not completed yet EAI_AGAIN is * returned. */ -int sd_resolve_getnameinfo_done(sd_resolve_t *resolve, sd_resolve_query_t* q, char *ret_host, size_t hostlen, char *ret_serv, size_t servlen); +int sd_resolve_getnameinfo_done(sd_resolve *resolve, sd_resolve_query* q, char *ret_host, size_t hostlen, char *ret_serv, size_t servlen); /** Issue a resolveer query on the specified session. The arguments are * compatible with the ones of libc's res_query(3). The function returns a new * query object. When the query is completed you may retrieve the results using * sd_resolve_res_done(). */ -sd_resolve_query_t* sd_resolve_res_query(sd_resolve_t *resolve, const char *dname, int class, int type); +sd_resolve_query* sd_resolve_res_query(sd_resolve *resolve, const char *dname, int class, int type); /** Issue an resolveer query on the specified session. The arguments are * compatible with the ones of libc's res_search(3). The function returns a new * query object. When the query is completed you may retrieve the results using * sd_resolve_res_done(). */ -sd_resolve_query_t* sd_resolve_res_search(sd_resolve_t *resolve, const char *dname, int class, int type); +sd_resolve_query* sd_resolve_res_search(sd_resolve *resolve, const char *dname, int class, int type); /** Retrieve the results of a preceding sd_resolve_res_query() or * resolve_res_search call. The query object q is destroyed by this @@ -119,20 +119,20 @@ sd_resolve_query_t* sd_resolve_res_search(sd_resolve_t *resolve, const char *dna * -EAGAIN is returned, on failure -errno is returned, otherwise the * length of answer is returned. Make sure to free the answer is a * call to sd_resolve_freeanswer(). */ -int sd_resolve_res_done(sd_resolve_t *resolve, sd_resolve_query_t* q, unsigned char **answer); +int sd_resolve_res_done(sd_resolve *resolve, sd_resolve_query* q, unsigned char **answer); /** Return the next completed query object. If no query has been * completed yet, return NULL. Please note that you need to run * sd_resolve_wait() before this function will return sensible data. */ -sd_resolve_query_t* sd_resolve_getnext(sd_resolve_t *resolve); +sd_resolve_query* sd_resolve_getnext(sd_resolve *resolve); /** Return the number of query objects (completed or not) attached to * this session */ -int sd_resolve_getnqueries(sd_resolve_t *resolve); +int sd_resolve_getnqueries(sd_resolve *resolve); /** Cancel a currently running query. q is is destroyed by this call * and may not be used any futher. */ -void sd_resolve_cancel(sd_resolve_t *resolve, sd_resolve_query_t* q); +void sd_resolve_cancel(sd_resolve *resolve, sd_resolve_query* q); /** Free the addrinfo structure as returned by * sd_resolve_getaddrinfo_done(). Make sure to use this functions instead @@ -143,15 +143,15 @@ void sd_resolve_freeaddrinfo(struct addrinfo *ai); void sd_resolve_freeanswer(unsigned char *answer); /** Returns non-zero when the query operation specified by q has been completed */ -int sd_resolve_isdone(sd_resolve_t *resolve, sd_resolve_query_t*q); +int sd_resolve_isdone(sd_resolve *resolve, sd_resolve_query*q); /** Assign some opaque userdata with a query object */ -void sd_resolve_setuserdata(sd_resolve_t *resolve, sd_resolve_query_t *q, void *userdata); +void sd_resolve_setuserdata(sd_resolve *resolve, sd_resolve_query *q, void *userdata); /** Return userdata assigned to a query object. Use * sd_resolve_setuserdata() to set this data. If no data has been set * prior to this call it returns NULL. */ -void* sd_resolve_getuserdata(sd_resolve_t *resolve, sd_resolve_query_t *q); +void* sd_resolve_getuserdata(sd_resolve *resolve, sd_resolve_query *q); _SD_END_DECLARATIONS; |