[systemd-commits] 3 commits - TODO src/libsystemd src/systemd
Lennart Poettering
lennart at kemper.freedesktop.org
Fri Jan 17 10:59:55 PST 2014
TODO | 10 +
src/libsystemd/resolve-util.h | 2
src/libsystemd/sd-resolve.c | 278 +++++++++++++++++++++---------------------
src/libsystemd/test-resolve.c | 4
src/systemd/sd-resolve.h | 42 +++---
5 files changed, 173 insertions(+), 163 deletions(-)
New commits:
commit 6a8b5fa4635ed858788fb10099ec9b62b3359a0a
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Jan 17 19:59:50 2014 +0100
Update TODO
diff --git a/TODO b/TODO
index 926c26f..a567669 100644
--- a/TODO
+++ b/TODO
@@ -32,6 +32,15 @@ External:
Features:
+* sd-resolve:
+ - make sure event loop integration works similar to event loop integration in other libs
+ - maybe drop _free() call, introduce _unref() instead
+ - sd_resolve_freeanswer() is probably pointless, we don't define such a function for any other return values, but expect people to call free directly
+ - maybe simplify function calls that take a sd_resolve_query object, to not also require the matching sd_resolve?
+ - maybe drop the "n_proc" parameter to sd_resolve_new()?
+ - change all functions to return "int" and negative errno errors
+ - getnext and getnqueries should be renamed to get_next() and get_n_queries(), i.e. functions that are not modelled directly after the libc counterparts don't need to be a single word...
+
* New service property: maximum CPU and wallclock runtime for a service
* introduce bus call FreezeUnit(s, b), as well as "systemctl freeze
@@ -148,6 +157,7 @@ Features:
- make use of "drop" ioctl in pid 1 bus activation
- bus proxy: override unique id sender for messages from driver to match the well-known name
- bus driver: GetNameOwner() for "org.freedesktop.DBus" should return "org.freedesktop.DBus"
+ - update systemd.special(7) to mention that dbus.socket is only about the compatibility socket now
* sd-event
- allow multiple signal handlers per signal?
commit 5599e86621d85cc0ac1b5a368a951da23cfe1863
Author: Daniel Buch <boogiewasthere at gmail.com>
Date: Wed Jan 15 18:21:30 2014 +0100
sd-resolve: rename structs to fit coding-style e.g 'struct MixedCase'
lets get this right once, and if not for all, atleast for now :)
So comments and input about nameing is very welcome.
Cheers
diff --git a/src/libsystemd/sd-resolve.c b/src/libsystemd/sd-resolve.c
index 73a66c4..a368c1b 100644
--- a/src/libsystemd/sd-resolve.c
+++ b/src/libsystemd/sd-resolve.c
@@ -58,7 +58,7 @@ typedef enum {
RESPONSE_RES,
REQUEST_TERMINATE,
RESPONSE_DIED
-} query_type_t;
+} QueryType;
enum {
REQUEST_RECV_FD = 0,
@@ -87,7 +87,7 @@ struct sd_resolve_query {
sd_resolve *resolve;
int done;
unsigned id;
- query_type_t type;
+ QueryType type;
sd_resolve_query *done_next, *done_prev;
int ret;
int _errno;
@@ -97,31 +97,31 @@ struct sd_resolve_query {
void *userdata;
};
-typedef struct rheader {
- query_type_t type;
+typedef struct RHeader {
+ QueryType type;
unsigned id;
size_t length;
-} rheader_t;
+} RHeader;
-typedef struct addrinfo_request {
- struct rheader header;
+typedef struct AddrInfoRequest {
+ struct RHeader header;
int hints_is_null;
int ai_flags;
int ai_family;
int ai_socktype;
int ai_protocol;
size_t node_len, service_len;
-} addrinfo_request_t;
+} AddrInfoRequest;
-typedef struct addrinfo_response {
- struct rheader header;
+typedef struct AddrInfoResponse {
+ struct RHeader header;
int ret;
int _errno;
int _h_errno;
/* followed by addrinfo_serialization[] */
-} addrinfo_response_t;
+} AddrInfoResponse;
-typedef struct addrinfo_serialization {
+typedef struct AddrInfoSerialization {
int ai_flags;
int ai_family;
int ai_socktype;
@@ -129,49 +129,49 @@ typedef struct addrinfo_serialization {
size_t ai_addrlen;
size_t canonname_len;
/* Followed by ai_addr amd ai_canonname with variable lengths */
-} addrinfo_serialization_t;
+} AddrInfoSerialization;
-typedef struct nameinfo_request {
- struct rheader header;
+typedef struct NameInfoRequest {
+ struct RHeader header;
int flags;
socklen_t sockaddr_len;
int gethost, getserv;
-} nameinfo_request_t;
+} NameInfoRequest;
-typedef struct nameinfo_response {
- struct rheader header;
+typedef struct NameInfoResponse {
+ struct RHeader header;
size_t hostlen, servlen;
int ret;
int _errno;
int _h_errno;
-} nameinfo_response_t;
+} NameInfoResponse;
-typedef struct res_request {
- struct rheader header;
+typedef struct ResRequest {
+ struct RHeader header;
int class;
int type;
size_t dname_len;
-} res_request_t;
+} ResRequest;
-typedef struct res_response {
- struct rheader header;
+typedef struct ResResponse {
+ struct RHeader header;
int ret;
int _errno;
int _h_errno;
-} res_response_t;
-
-typedef union packet {
- rheader_t rheader;
- addrinfo_request_t addrinfo_request;
- addrinfo_response_t addrinfo_response;
- nameinfo_request_t nameinfo_request;
- nameinfo_response_t nameinfo_response;
- res_request_t res_request;
- res_response_t res_response;
-} packet_t;
+} ResResponse;
+
+typedef union Packet {
+ RHeader rheader;
+ AddrInfoRequest addrinfo_request;
+ AddrInfoResponse addrinfo_response;
+ NameInfoRequest nameinfo_request;
+ NameInfoResponse nameinfo_response;
+ ResRequest res_request;
+ ResResponse res_response;
+} Packet;
static int send_died(int out_fd) {
- rheader_t rh = {};
+ RHeader rh = {};
assert(out_fd > 0);
rh.type = RESPONSE_DIED;
@@ -182,7 +182,7 @@ static int send_died(int out_fd) {
}
static void *serialize_addrinfo(void *p, const struct addrinfo *ai, size_t *length, size_t maxlength) {
- addrinfo_serialization_t s;
+ AddrInfoSerialization s;
size_t cnl, l;
assert(p);
assert(ai);
@@ -190,7 +190,7 @@ static void *serialize_addrinfo(void *p, const struct addrinfo *ai, size_t *leng
assert(*length <= maxlength);
cnl = (ai->ai_canonname ? strlen(ai->ai_canonname)+1 : 0);
- l = sizeof(addrinfo_serialization_t) + ai->ai_addrlen + cnl;
+ l = sizeof(AddrInfoSerialization) + ai->ai_addrlen + cnl;
if (*length + l > maxlength)
return NULL;
@@ -202,24 +202,24 @@ static void *serialize_addrinfo(void *p, const struct addrinfo *ai, size_t *leng
s.ai_addrlen = ai->ai_addrlen;
s.canonname_len = cnl;
- memcpy((uint8_t*) p, &s, sizeof(addrinfo_serialization_t));
- memcpy((uint8_t*) p + sizeof(addrinfo_serialization_t), ai->ai_addr, ai->ai_addrlen);
+ memcpy((uint8_t*) p, &s, sizeof(AddrInfoSerialization));
+ memcpy((uint8_t*) p + sizeof(AddrInfoSerialization), ai->ai_addr, ai->ai_addrlen);
if (ai->ai_canonname)
- strcpy((char*) p + sizeof(addrinfo_serialization_t) + ai->ai_addrlen, ai->ai_canonname);
+ strcpy((char*) p + sizeof(AddrInfoSerialization) + ai->ai_addrlen, ai->ai_canonname);
*length += l;
return (uint8_t*) p + l;
}
static int send_addrinfo_reply(int out_fd, unsigned id, int ret, struct addrinfo *ai, int _errno, int _h_errno) {
- addrinfo_response_t data[BUFSIZE/sizeof(addrinfo_response_t) + 1] = {};
- addrinfo_response_t *resp = data;
+ AddrInfoResponse data[BUFSIZE/sizeof(AddrInfoResponse) + 1] = {};
+ AddrInfoResponse *resp = data;
assert(out_fd >= 0);
resp->header.type = RESPONSE_ADDRINFO;
resp->header.id = id;
- resp->header.length = sizeof(addrinfo_response_t);
+ resp->header.length = sizeof(AddrInfoResponse);
resp->ret = ret;
resp->_errno = _errno;
resp->_h_errno = _h_errno;
@@ -244,9 +244,9 @@ static int send_addrinfo_reply(int out_fd, unsigned id, int ret, struct addrinfo
}
static int send_nameinfo_reply(int out_fd, unsigned id, int ret, const char *host, const char *serv, int _errno, int _h_errno) {
- nameinfo_response_t data[BUFSIZE/sizeof(nameinfo_response_t) + 1] = {};
+ NameInfoResponse data[BUFSIZE/sizeof(NameInfoResponse) + 1] = {};
size_t hl, sl;
- nameinfo_response_t *resp = data;
+ NameInfoResponse *resp = data;
assert(out_fd >= 0);
@@ -255,7 +255,7 @@ static int send_nameinfo_reply(int out_fd, unsigned id, int ret, const char *hos
resp->header.type = RESPONSE_NAMEINFO;
resp->header.id = id;
- resp->header.length = sizeof(nameinfo_response_t) + hl + sl;
+ resp->header.length = sizeof(NameInfoResponse) + hl + sl;
resp->ret = ret;
resp->_errno = _errno;
resp->_h_errno = _h_errno;
@@ -265,23 +265,23 @@ static int send_nameinfo_reply(int out_fd, unsigned id, int ret, const char *hos
assert(sizeof(data) >= resp->header.length);
if (host)
- memcpy((uint8_t *)data + sizeof(nameinfo_response_t), host, hl);
+ memcpy((uint8_t *)data + sizeof(NameInfoResponse), host, hl);
if (serv)
- memcpy((uint8_t *)data + sizeof(nameinfo_response_t) + hl, serv, sl);
+ memcpy((uint8_t *)data + sizeof(NameInfoResponse) + hl, serv, sl);
return send(out_fd, resp, resp->header.length, MSG_NOSIGNAL);
}
static int send_res_reply(int out_fd, unsigned id, const unsigned char *answer, int ret, int _errno, int _h_errno) {
- res_response_t data[BUFSIZE/sizeof(res_response_t) + 1] = {};
- res_response_t *resp = data;
+ ResResponse data[BUFSIZE/sizeof(ResResponse) + 1] = {};
+ ResResponse *resp = data;
assert(out_fd >= 0);
resp->header.type = RESPONSE_RES;
resp->header.id = id;
- resp->header.length = sizeof(res_response_t) + (ret < 0 ? 0 : ret);
+ resp->header.length = sizeof(ResResponse) + (ret < 0 ? 0 : ret);
resp->ret = ret;
resp->_errno = _errno;
resp->_h_errno = _h_errno;
@@ -289,37 +289,37 @@ static int send_res_reply(int out_fd, unsigned id, const unsigned char *answer,
assert(sizeof(data) >= resp->header.length);
if (ret > 0)
- memcpy((uint8_t *)data + sizeof(res_response_t), answer, ret);
+ memcpy((uint8_t *)data + sizeof(ResResponse), answer, ret);
return send(out_fd, resp, resp->header.length, MSG_NOSIGNAL);
}
-static int handle_request(int out_fd, const packet_t *packet, size_t length) {
- const rheader_t *req;
+static int handle_request(int out_fd, const Packet *packet, size_t length) {
+ const RHeader *req;
assert(out_fd >= 0);
req = &packet->rheader;
assert(req);
- assert(length >= sizeof(rheader_t));
+ assert(length >= sizeof(RHeader));
assert(length == req->length);
switch (req->type) {
case REQUEST_ADDRINFO: {
struct addrinfo ai = {}, *result = NULL;
- const addrinfo_request_t *ai_req = &packet->addrinfo_request;
+ const AddrInfoRequest *ai_req = &packet->addrinfo_request;
const char *node, *service;
int ret;
- assert(length >= sizeof(addrinfo_request_t));
- assert(length == sizeof(addrinfo_request_t) + ai_req->node_len + ai_req->service_len);
+ assert(length >= sizeof(AddrInfoRequest));
+ assert(length == sizeof(AddrInfoRequest) + ai_req->node_len + ai_req->service_len);
ai.ai_flags = ai_req->ai_flags;
ai.ai_family = ai_req->ai_family;
ai.ai_socktype = ai_req->ai_socktype;
ai.ai_protocol = ai_req->ai_protocol;
- node = ai_req->node_len ? (const char*) ai_req + sizeof(addrinfo_request_t) : NULL;
- service = ai_req->service_len ? (const char*) ai_req + sizeof(addrinfo_request_t) + ai_req->node_len : NULL;
+ node = ai_req->node_len ? (const char*) ai_req + sizeof(AddrInfoRequest) : NULL;
+ service = ai_req->service_len ? (const char*) ai_req + sizeof(AddrInfoRequest) + ai_req->node_len : NULL;
ret = getaddrinfo(node, service,
ai_req->hints_is_null ? NULL : &ai,
@@ -331,14 +331,14 @@ static int handle_request(int out_fd, const packet_t *packet, size_t length) {
case REQUEST_NAMEINFO: {
int ret;
- const nameinfo_request_t *ni_req = &packet->nameinfo_request;
+ const NameInfoRequest *ni_req = &packet->nameinfo_request;
char hostbuf[NI_MAXHOST], servbuf[NI_MAXSERV];
struct sockaddr_storage sa;
- assert(length >= sizeof(nameinfo_request_t));
- assert(length == sizeof(nameinfo_request_t) + ni_req->sockaddr_len);
+ assert(length >= sizeof(NameInfoRequest));
+ assert(length == sizeof(NameInfoRequest) + ni_req->sockaddr_len);
- memcpy(&sa, (const uint8_t *) ni_req + sizeof(nameinfo_request_t), ni_req->sockaddr_len);
+ memcpy(&sa, (const uint8_t *) ni_req + sizeof(NameInfoRequest), ni_req->sockaddr_len);
ret = getnameinfo((struct sockaddr *)&sa, ni_req->sockaddr_len,
ni_req->gethost ? hostbuf : NULL, ni_req->gethost ? sizeof(hostbuf) : 0,
@@ -355,13 +355,13 @@ static int handle_request(int out_fd, const packet_t *packet, size_t length) {
case REQUEST_RES_SEARCH: {
int ret;
HEADER answer[BUFSIZE/sizeof(HEADER) + 1];
- const res_request_t *res_req = &packet->res_request;
+ const ResRequest *res_req = &packet->res_request;
const char *dname;
- assert(length >= sizeof(res_request_t));
- assert(length == sizeof(res_request_t) + res_req->dname_len);
+ assert(length >= sizeof(ResRequest));
+ assert(length == sizeof(ResRequest) + res_req->dname_len);
- dname = (const char *) req + sizeof(res_request_t);
+ dname = (const char *) req + sizeof(ResRequest);
if (req->type == REQUEST_RES_QUERY)
ret = res_query(dname, res_req->class, res_req->type, (unsigned char *) answer, BUFSIZE);
@@ -391,7 +391,7 @@ static void* thread_worker(void *p) {
pthread_sigmask(SIG_BLOCK, &fullset, NULL);
while (!resolve->dead) {
- packet_t buf[BUFSIZE/sizeof(packet_t) + 1];
+ Packet buf[BUFSIZE/sizeof(Packet) + 1];
ssize_t length;
length = recv(resolve->fds[REQUEST_RECV_FD], buf, sizeof(buf), 0);
@@ -478,7 +478,7 @@ void sd_resolve_free(sd_resolve *resolve) {
resolve->dead = 1;
if (resolve->fds[REQUEST_SEND_FD] >= 0) {
- rheader_t req = {};
+ RHeader req = {};
req.type = REQUEST_TERMINATE;
req.length = sizeof(req);
@@ -546,19 +546,19 @@ static void complete_query(sd_resolve *resolve, sd_resolve_query *q) {
}
static const void *unserialize_addrinfo(const void *p, struct addrinfo **ret_ai, size_t *length) {
- addrinfo_serialization_t s;
+ AddrInfoSerialization s;
size_t l;
struct addrinfo *ai;
assert(p);
assert(ret_ai);
assert(length);
- if (*length < sizeof(addrinfo_serialization_t))
+ if (*length < sizeof(AddrInfoSerialization))
return NULL;
memcpy(&s, p, sizeof(s));
- l = sizeof(addrinfo_serialization_t) + s.ai_addrlen + s.canonname_len;
+ l = sizeof(AddrInfoSerialization) + s.ai_addrlen + s.canonname_len;
if (*length < l)
return NULL;
@@ -583,10 +583,10 @@ static const void *unserialize_addrinfo(const void *p, struct addrinfo **ret_ai,
ai->ai_addrlen = s.ai_addrlen;
if (ai->ai_addr)
- memcpy(ai->ai_addr, (const uint8_t*) p + sizeof(addrinfo_serialization_t), s.ai_addrlen);
+ memcpy(ai->ai_addr, (const uint8_t*) p + sizeof(AddrInfoSerialization), s.ai_addrlen);
if (ai->ai_canonname)
- memcpy(ai->ai_canonname, (const uint8_t*) p + sizeof(addrinfo_serialization_t) + s.ai_addrlen, s.canonname_len);
+ memcpy(ai->ai_canonname, (const uint8_t*) p + sizeof(AddrInfoSerialization) + s.ai_addrlen, s.canonname_len);
*length -= l;
*ret_ai = ai;
@@ -601,15 +601,15 @@ fail:
return NULL;
}
-static int handle_response(sd_resolve *resolve, const packet_t *packet, size_t length) {
- const rheader_t *resp;
+static int handle_response(sd_resolve *resolve, const Packet *packet, size_t length) {
+ const RHeader *resp;
sd_resolve_query *q;
assert(resolve);
resp = &packet->rheader;
assert(resp);
- assert(length >= sizeof(rheader_t));
+ assert(length >= sizeof(RHeader));
assert(length == resp->length);
if (resp->type == RESPONSE_DIED) {
@@ -623,19 +623,19 @@ static int handle_response(sd_resolve *resolve, const packet_t *packet, size_t l
switch (resp->type) {
case RESPONSE_ADDRINFO: {
- const addrinfo_response_t *ai_resp = &packet->addrinfo_response;
+ const AddrInfoResponse *ai_resp = &packet->addrinfo_response;
const void *p;
size_t l;
struct addrinfo *prev = NULL;
- assert(length >= sizeof(addrinfo_response_t));
+ assert(length >= sizeof(AddrInfoResponse));
assert(q->type == REQUEST_ADDRINFO);
q->ret = ai_resp->ret;
q->_errno = ai_resp->_errno;
q->_h_errno = ai_resp->_h_errno;
- l = length - sizeof(addrinfo_response_t);
- p = (const uint8_t*) resp + sizeof(addrinfo_response_t);
+ l = length - sizeof(AddrInfoResponse);
+ p = (const uint8_t*) resp + sizeof(AddrInfoResponse);
while (l > 0 && p) {
struct addrinfo *ai = NULL;
@@ -659,9 +659,9 @@ static int handle_response(sd_resolve *resolve, const packet_t *packet, size_t l
}
case RESPONSE_NAMEINFO: {
- const nameinfo_response_t *ni_resp = &packet->nameinfo_response;
+ const NameInfoResponse *ni_resp = &packet->nameinfo_response;
- assert(length >= sizeof(nameinfo_response_t));
+ assert(length >= sizeof(NameInfoResponse));
assert(q->type == REQUEST_NAMEINFO);
q->ret = ni_resp->ret;
@@ -669,11 +669,11 @@ static int handle_response(sd_resolve *resolve, const packet_t *packet, size_t l
q->_h_errno = ni_resp->_h_errno;
if (ni_resp->hostlen)
- if (!(q->host = strndup((const char*) ni_resp + sizeof(nameinfo_response_t), ni_resp->hostlen-1)))
+ if (!(q->host = strndup((const char*) ni_resp + sizeof(NameInfoResponse), ni_resp->hostlen-1)))
q->ret = EAI_MEMORY;
if (ni_resp->servlen)
- if (!(q->serv = strndup((const char*) ni_resp + sizeof(nameinfo_response_t) + ni_resp->hostlen, ni_resp->servlen-1)))
+ if (!(q->serv = strndup((const char*) ni_resp + sizeof(NameInfoResponse) + ni_resp->hostlen, ni_resp->servlen-1)))
q->ret = EAI_MEMORY;
complete_query(resolve, q);
@@ -681,9 +681,9 @@ static int handle_response(sd_resolve *resolve, const packet_t *packet, size_t l
}
case RESPONSE_RES: {
- const res_response_t *res_resp = &packet->res_response;
+ const ResResponse *res_resp = &packet->res_response;
- assert(length >= sizeof(res_response_t));
+ assert(length >= sizeof(ResResponse));
assert(q->type == REQUEST_RES_QUERY || q->type == REQUEST_RES_SEARCH);
q->ret = res_resp->ret;
@@ -695,7 +695,7 @@ static int handle_response(sd_resolve *resolve, const packet_t *packet, size_t l
q->ret = -1;
q->_errno = ENOMEM;
} else
- memcpy(q->serv, (const char *)resp + sizeof(res_response_t), res_resp->ret);
+ memcpy(q->serv, (const char *)resp + sizeof(ResResponse), res_resp->ret);
}
complete_query(resolve, q);
@@ -714,7 +714,7 @@ int sd_resolve_wait(sd_resolve *resolve, int block) {
assert(resolve);
for (;;) {
- packet_t buf[BUFSIZE/sizeof(packet_t) + 1];
+ Packet buf[BUFSIZE/sizeof(Packet) + 1];
ssize_t l;
if (resolve->dead) {
@@ -788,8 +788,8 @@ static sd_resolve_query *alloc_query(sd_resolve *resolve) {
}
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;
+ AddrInfoRequest data[BUFSIZE/sizeof(AddrInfoRequest) + 1] = {};
+ AddrInfoRequest *req = data;
sd_resolve_query *q;
assert(resolve);
assert(node || service);
@@ -808,7 +808,7 @@ sd_resolve_query* sd_resolve_getaddrinfo(sd_resolve *resolve, const char *node,
req->header.id = q->id;
req->header.type = q->type = REQUEST_ADDRINFO;
- req->header.length = sizeof(addrinfo_request_t) + req->node_len + req->service_len;
+ req->header.length = sizeof(AddrInfoRequest) + req->node_len + req->service_len;
if (req->header.length > BUFSIZE) {
errno = ENOMEM;
@@ -823,10 +823,10 @@ sd_resolve_query* sd_resolve_getaddrinfo(sd_resolve *resolve, const char *node,
}
if (node)
- strcpy((char*) req + sizeof(addrinfo_request_t), node);
+ strcpy((char*) req + sizeof(AddrInfoRequest), node);
if (service)
- strcpy((char*) req + sizeof(addrinfo_request_t) + req->node_len, service);
+ strcpy((char*) req + sizeof(AddrInfoRequest) + req->node_len, service);
if (send(resolve->fds[REQUEST_SEND_FD], req, req->header.length, MSG_NOSIGNAL) < 0)
goto fail;
@@ -872,8 +872,8 @@ int sd_resolve_getaddrinfo_done(sd_resolve *resolve, sd_resolve_query* q, struct
}
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;
+ NameInfoRequest data[BUFSIZE/sizeof(NameInfoRequest) + 1] = {};
+ NameInfoRequest *req = data;
sd_resolve_query *q;
assert(resolve);
@@ -891,7 +891,7 @@ sd_resolve_query* sd_resolve_getnameinfo(sd_resolve *resolve, const struct socka
req->header.id = q->id;
req->header.type = q->type = REQUEST_NAMEINFO;
- req->header.length = sizeof(nameinfo_request_t) + salen;
+ req->header.length = sizeof(NameInfoRequest) + salen;
if (req->header.length > BUFSIZE) {
errno = ENOMEM;
@@ -903,7 +903,7 @@ sd_resolve_query* sd_resolve_getnameinfo(sd_resolve *resolve, const struct socka
req->gethost = gethost;
req->getserv = getserv;
- memcpy((uint8_t*) req + sizeof(nameinfo_request_t), sa, salen);
+ memcpy((uint8_t*) req + sizeof(NameInfoRequest), sa, salen);
if (send(resolve->fds[REQUEST_SEND_FD], req, req->header.length, MSG_NOSIGNAL) < 0)
goto fail;
@@ -957,9 +957,9 @@ int sd_resolve_getnameinfo_done(sd_resolve *resolve, sd_resolve_query* q, char *
return ret;
}
-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;
+static sd_resolve_query * resolve_res(sd_resolve *resolve, QueryType qtype, const char *dname, int class, int type) {
+ ResRequest data[BUFSIZE/sizeof(ResRequest) + 1];
+ ResRequest *req = data;
sd_resolve_query *q;
assert(resolve);
@@ -978,7 +978,7 @@ static sd_resolve_query * resolve_res(sd_resolve *resolve, query_type_t qtype, c
req->header.id = q->id;
req->header.type = q->type = qtype;
- req->header.length = sizeof(res_request_t) + req->dname_len;
+ req->header.length = sizeof(ResRequest) + req->dname_len;
if (req->header.length > BUFSIZE) {
errno = ENOMEM;
@@ -988,7 +988,7 @@ static sd_resolve_query * resolve_res(sd_resolve *resolve, query_type_t qtype, c
req->class = class;
req->type = type;
- strcpy((char*) req + sizeof(res_request_t), dname);
+ strcpy((char*) req + sizeof(ResRequest), dname);
if (send(resolve->fds[REQUEST_SEND_FD], req, req->header.length, MSG_NOSIGNAL) < 0)
goto fail;
commit 4f80925636ed98290c3091318257dbab9efa4d01
Author: Daniel Buch <boogiewasthere at gmail.com>
Date: Wed Jan 15 18:21:29 2014 +0100
sd-resolve: get rid of _t post-fixes for sd_ objects
We dont want _t prefixes, right?
diff --git a/src/libsystemd/resolve-util.h b/src/libsystemd/resolve-util.h
index 0761c96..4310f88 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 269f517..73a66c4 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 c7feb1e..7c1e7aa 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 2023f11..8df6152 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;
More information about the systemd-commits
mailing list