Skip to content

Commit

Permalink
Improve request names API.
Browse files Browse the repository at this point in the history
  • Loading branch information
vstakhov committed Apr 8, 2014
1 parent a8b1f29 commit b176222
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
9 changes: 8 additions & 1 deletion include/rdns.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ typedef void (*rdns_log_function) (
va_list args //!< set of arguments
);

struct rdns_request_name {
char *name;
enum rdns_request_type type;
unsigned int len;
};

/*
* RDNS API
*/
Expand Down Expand Up @@ -322,7 +328,8 @@ bool rdns_request_has_type (struct rdns_request *req, enum rdns_request_type typ
* @param req request object
* @return requested name as it was passed to `rdns_make_request`
*/
const char* rdns_request_get_name (struct rdns_request *req);
const struct rdns_request_name* rdns_request_get_name (struct rdns_request *req,
unsigned int *count);

/**
* Return PTR string for a request (ipv4 or ipv6) addresses
Expand Down
6 changes: 1 addition & 5 deletions src/dns_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,7 @@ struct rdns_request {
unsigned int retransmits;

int id;
struct _rdns_request_name {
char *name;
enum rdns_request_type type;
unsigned int len;
} *requested_names;
struct rdns_request_name *requested_names;
unsigned int qcount;

enum {
Expand Down
2 changes: 1 addition & 1 deletion src/resolver.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ rdns_make_request_full (
req->arg = cbdata;
req->reply = NULL;
req->qcount = queries;
req->requested_names = malloc (queries * sizeof (struct _rdns_request_name));
req->requested_names = malloc (queries * sizeof (struct rdns_request_name));
if (req->requested_names == NULL) {
free (req);
return NULL;
Expand Down
10 changes: 7 additions & 3 deletions src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,10 +459,14 @@ rdns_request_has_type (struct rdns_request *req, enum rdns_request_type type)
return false;
}

const char*
rdns_request_get_name (struct rdns_request *req)
const struct rdns_request_name *
rdns_request_get_name (struct rdns_request *req, unsigned int *count)
{
return req->requested_names[0].name;

if (count != NULL) {
*count = req->qcount;
}
return req->requested_names;
}

char *
Expand Down

0 comments on commit b176222

Please sign in to comment.