ares_parse_a_reply.3 (1638B)
1 .\" 2 .\" Copyright 1998 by the Massachusetts Institute of Technology. 3 .\" SPDX-License-Identifier: MIT 4 .\" 5 .TH ARES_PARSE_A_REPLY 3 "25 July 1998" 6 .SH NAME 7 ares_parse_a_reply \- Parse a reply to a DNS query of type A 8 .SH SYNOPSIS 9 .nf 10 #include <ares.h> 11 12 int ares_parse_a_reply(const unsigned char *\fIabuf\fP, int \fIalen\fP, 13 struct hostent **\fIhost\fP, 14 struct ares_addrttl *\fIaddrttls\fP, int *\fInaddrttls\fP); 15 .fi 16 .SH DESCRIPTION 17 The 18 .B ares_parse_a_reply 19 function parses the response to a query of type A into a 20 .BR "struct hostent" 21 and/or an array of 22 .BR "struct ares_addrttls" . 23 The parameters 24 .I abuf 25 and 26 .I alen 27 give the contents of the response. The result is stored in allocated 28 memory and a pointer to it stored into the variable pointed to by 29 .IR host , 30 if host is nonnull. 31 It is the caller's responsibility to free the resulting host structure 32 using 33 .BR ares_free_hostent (3) 34 when it is no longer needed. 35 .PP 36 If 37 .IR addrttls 38 and 39 .IR naddrttls 40 are both nonnull, 41 then up to *naddrttls 42 .BR "struct ares_addrttl" 43 records are stored in the array pointed to by addrttls, 44 and then *naddrttls is set to the number of records so stored. 45 Note that the memory for these records is supplied by the caller. 46 .SH RETURN VALUES 47 .B ares_parse_a_reply 48 can return any of the following values: 49 .TP 15 50 .B ARES_SUCCESS 51 The response was successfully parsed. 52 .TP 15 53 .B ARES_EBADRESP 54 The response was malformatted. 55 .TP 15 56 .B ARES_ENODATA 57 The response did not contain an answer to the query. 58 .TP 15 59 .B ARES_ENOMEM 60 Memory was exhausted. 61 .SH SEE ALSO 62 .BR ares_gethostbyname (3), 63 .BR ares_free_hostent (3)