ares_parse_txt_reply.3 (2619B)
1 .\" 2 .\" Copyright 1998 by the Massachusetts Institute of Technology. 3 .\" SPDX-License-Identifier: MIT 4 .\" 5 .TH ARES_PARSE_TXT_REPLY 3 "27 October 2009" 6 .SH NAME 7 ares_parse_txt_reply \- Parse a reply to a DNS query of type TXT 8 .SH SYNOPSIS 9 .nf 10 #include <ares.h> 11 12 int ares_parse_txt_reply(const unsigned char* \fIabuf\fP, int \fIalen\fP, 13 struct ares_txt_reply **\fItxt_out\fP); 14 15 int ares_parse_txt_reply_ext(const unsigned char* \fIabuf\fP, int \fIalen\fP, 16 struct ares_txt_ext **\fItxt_out\fP); 17 .fi 18 .SH DESCRIPTION 19 The \fIares_parse_txt_reply(3)\fP and \fIares_parse_txt_reply_ext(3)\fP 20 functions parse the response to a query of type TXT into a linked list (one 21 element per sub-string) of 22 .IR "struct ares_txt_reply" " (" "struct ares_txt_ext" ")" 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 txt_out . 30 It is the caller's responsibility to free the resulting 31 .IR txt_out 32 structure when it is no longer needed using the function 33 \fBares_free_data(3)\fP. 34 35 The structure 36 .I ares_txt_reply 37 contains the following fields: 38 .nf 39 struct ares_txt_reply { 40 struct ares_txt_reply *next; 41 unsigned int length; 42 unsigned char *txt; 43 }; 44 .fi 45 46 The structure 47 .I ares_txt_ext 48 contains the following fields: 49 .nf 50 struct ares_txt_ext { 51 struct ares_txt_ext *next; 52 unsigned int length; 53 unsigned char *txt; 54 unsigned char record_start; 55 }; 56 .fi 57 The 58 .I record_start 59 field in 60 .I struct ares_txt_ext 61 is 1 if this structure is a start of a TXT record, and 0 if the structure is a 62 continuation of a previous record. The linked list of the 63 .I struct ares_txt_ext 64 will have at least one item with 65 .I record_start 66 equal to 1, and may have some items with 67 .I record_start 68 equal to 0 between them. 69 70 These sequences of 71 .I struct ares_txt_ext 72 (starting from the item with 73 .I record_start 74 equal to 1, and ending right before the record start item) may be treated as 75 either components of a single TXT record or as a multi-parted TXT record, 76 depending on particular use case. 77 .SH RETURN VALUES 78 .BR "ares_parse_txt_reply" " (" "ares_parse_txt_reply_ext" ")" 79 can return any of the following values: 80 .TP 15 81 .B ARES_SUCCESS 82 The response was successfully parsed. 83 .TP 15 84 .B ARES_EBADRESP 85 The response was malformatted. 86 .TP 15 87 .B ARES_ENODATA 88 The response did not contain an answer to the query. 89 .TP 15 90 .B ARES_ENOMEM 91 Memory was exhausted. 92 .SH AVAILABILITY 93 This function was first introduced in c-ares version 1.7.0. 94 .SH SEE ALSO 95 .BR ares_query (3) 96 .BR ares_free_data (3)