---
name: "ares_parse_txt_reply"
section: "3"
platform: "linux"
package: "c-ares"
version: "1.34.9-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/ares_parse_txt_reply"
---

# ares\_parse\_txt\_reply(3)

Parse a reply to a DNS query of type TXT

## NAME

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

## 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

The *[ares\_parse\_txt\_reply(3)](/ares_parse_txt_reply/3.md)* and *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)](/ares_free_data/3.md)**.

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

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

- **ARES\_SUCCESS**

  The response was successfully parsed.

- **ARES\_EBADRESP**

  The response was malformatted.

- **ARES\_ENODATA**

  The response did not contain an answer to the query.

- **ARES\_ENOMEM**

  Memory was exhausted.

## AVAILABILITY

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

## SEE ALSO

[**ares\_query**(3)](/ares_query/3.md) [**ares\_free\_data**(3)](/ares_free_data/3.md)
