ARES\_PARSE\_TXT\_REPLY(3) Library Functions Manual ARES\_PARSE\_TXT\_REPLY(3)

# [NAME](#NAME)

ares\_parse\_txt\_reply - Parse a reply to a DNS query of type TXT

# [SYNOPSIS](#SYNOPSIS)

```
#include <ares.h>
int ares_parse_txt_reply(const unsigned char* abuf, int alen,


                         struct ares_txt_reply **txt_out);
int ares_parse_txt_reply_ext(const unsigned char* abuf, int alen,


                             struct ares_txt_ext **txt_out);
```

# [DESCRIPTION](#DESCRIPTION)

The [*ares\_parse\_txt\_reply(3)*](/man/os/c-ares/ares_parse_txt_reply.3) and [*ares\_parse\_txt\_reply\_ext(3)*](/man/os/c-ares/ares_parse_txt_reply_ext.3) functions parse the response to a query of type TXT into a linked list (one element per sub-string) of *struct ares\_txt\_reply* (*struct ares\_txt\_ext*) The parameters *abuf* and *alen* give the contents of the response. The result is stored in allocated memory and a pointer to it stored into the variable pointed to by *txt\_out*. It is the caller's responsibility to free the resulting *txt\_out* structure when it is no longer needed using the function [**ares\_free\_data(3)**](/man/os/c-ares/ares_free_data.3).

The structure *ares\_txt\_reply* contains the following fields:

```
struct ares_txt_reply {


  struct ares_txt_reply  *next;


  unsigned int  length;


  unsigned char *txt;
};
```

The structure *ares\_txt\_ext* contains the following fields:

```
struct ares_txt_ext {


  struct ares_txt_ext  *next;


  unsigned int  length;


  unsigned char *txt;


  unsigned char record_start;
};
```

The *record\_start* field in *struct ares\_txt\_ext* is 1 if this structure is a start of a TXT record, and 0 if the structure is a continuation of a previous record. The linked list of the *struct ares\_txt\_ext* will have at least one item with *record\_start* equal to 1, and may have some items with *record\_start* equal to 0 between them.

These sequences of *struct ares\_txt\_ext* (starting from the item with *record\_start* equal to 1, and ending right before the record start item) may be treated as either components of a single TXT record or as a multi-parted TXT record, depending on particular use case.

# [RETURN VALUES](#RETURN_VALUES)

**ares\_parse\_txt\_reply** (**ares\_parse\_txt\_reply\_ext**) can return any of the following values:

[**ARES\_SUCCESS**](#ARES_SUCCESS)

The response was successfully parsed.

[**ARES\_EBADRESP**](#ARES_EBADRESP)

The response was malformatted.

[**ARES\_ENODATA**](#ARES_ENODATA)

The response did not contain an answer to the query.

[**ARES\_ENOMEM**](#ARES_ENOMEM)

Memory was exhausted.

# [AVAILABILITY](#AVAILABILITY)

This function was first introduced in c-ares version 1.7.0.

# [SEE ALSO](#SEE_ALSO)

[**ares\_query**(3)](/man/os/c-ares/ares_query.3) [**ares\_free\_data**(3)](/man/os/c-ares/ares_free_data.3)

27 October 2009

---

Document: ares_parse_txt_reply(3) from c-ares 1.34.9-r0 (Chainguard OS)
Source: https://github.com/c-ares/c-ares
