blob: e15d0eace15ac4701e69a97f6268a53b12f9bb1d [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001.\"
2.\" Copyright 1998 by the Massachusetts Institute of Technology.
3.\"
4.\" Permission to use, copy, modify, and distribute this
5.\" software and its documentation for any purpose and without
6.\" fee is hereby granted, provided that the above copyright
7.\" notice appear in all copies and that both that copyright
8.\" notice and this permission notice appear in supporting
9.\" documentation, and that the name of M.I.T. not be used in
10.\" advertising or publicity pertaining to distribution of the
11.\" software without specific, written prior permission.
12.\" M.I.T. makes no representations about the suitability of
13.\" this software for any purpose. It is provided "as is"
14.\" without express or implied warranty.
15.\"
16.TH ARES_PARSE_TXT_REPLY 3 "27 October 2009"
17.SH NAME
18ares_parse_txt_reply \- Parse a reply to a DNS query of type TXT
19.SH SYNOPSIS
20.nf
21.B #include <ares.h>
22.PP
23.B int ares_parse_txt_reply(const unsigned char* \fIabuf\fP, int \fIalen\fP,
24.B struct ares_txt_reply **\fItxt_out\fP);
25.PP
26.B int ares_parse_txt_reply_ext(const unsigned char* \fIabuf\fP, int \fIalen\fP,
27.B struct ares_txt_ext **\fItxt_out\fP);
28.fi
29.SH DESCRIPTION
30The
31.BR "ares_parse_txt_reply" " (" "ares_parse_txt_reply_ext" ")"
32function parses the response to a query of type TXT into a
33linked list (one element per sub-string) of
34.IR "struct ares_txt_reply" " (" "struct ares_txt_ext" ")"
35The parameters
36.I abuf
37and
38.I alen
39give the contents of the response. The result is stored in allocated
40memory and a pointer to it stored into the variable pointed to by
41.IR txt_out .
42It is the caller's responsibility to free the resulting
43.IR txt_out
44structure when it is no longer needed using the function
45.B ares_free_data
46.PP
47The structure
48.I ares_txt_reply
49contains the following fields:
50.sp
51.in +4n
52.nf
53struct ares_txt_reply {
54 struct ares_txt_reply *next;
55 unsigned int length;
56 unsigned char *txt;
57};
58.fi
59.in
60.PP
61The structure
62.I ares_txt_ext
63contains the following fields:
64.sp
65.in +4n
66.nf
67struct ares_txt_ext {
68 struct ares_txt_ext *next;
69 unsigned int length;
70 unsigned char *txt;
71 unsigned char record_start;
72};
73.fi
74.in
75.PP
76The
77.I record_start
78field in
79.I struct ares_txt_ext
80is 1 if this structure is a start of a TXT record, and 0 if the structure is a
81continuation of a previous record. The linked list of the
82.I struct ares_txt_ext
83will have at least one item with
84.I record_start
85equal to 1, and may have some items with
86.I record_start
87equal to 0 between them.
88.PP
89These sequences of
90.I struct ares_txt_ext
91(starting from the item with
92.I record_start
93equal to 1, and ending right before the record start item) may be treated as
94either components of a single TXT record or as a multi-parted TXT record,
95depending on particular use case.
96.PP
97.SH RETURN VALUES
98.BR "ares_parse_txt_reply" " (" "ares_parse_txt_reply_ext" ")"
99can return any of the following values:
100.TP 15
101.B ARES_SUCCESS
102The response was successfully parsed.
103.TP 15
104.B ARES_EBADRESP
105The response was malformatted.
106.TP 15
107.B ARES_ENODATA
108The response did not contain an answer to the query.
109.TP 15
110.B ARES_ENOMEM
111Memory was exhausted.
112.SH AVAILABILITY
113This function was first introduced in c-ares version 1.7.0.
114.SH SEE ALSO
115.BR ares_query (3)
116.BR ares_free_data (3)
117.SH AUTHOR
118Written by Jakub Hrozek <jhrozek@redhat.com>, on behalf of Red Hat, Inc http://www.redhat.com
119.PP
120Amended by Fedor Indutny <fedor@indutny.com>, on behalf of PayPal, Inc https://www.paypal.com