---
name: "hesiod"
section: "3"
platform: "linux"
package: "libhesiod-dev"
version: "3.2.1-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/hesiod"
---

# hesiod(3)

Hesiod name server interface library

## NAME

hesiod, hesiod\_init, hesiod\_resolve, hesiod\_free\_list, hesiod\_to\_bind, hesiod\_free\_string, hesiod\_end - Hesiod name server interface library

## SYNOPSIS

```
#include <hesiod.h>
```

**int hesiod\_init(void \*\**context*)** **char \*\*hesiod\_resolve(void \**context*, const char \**name*,** **const char \**type*)** **void hesiod\_free\_list(void \**context*, char \*\**list*);** **char \*hesiod\_to\_bind(void \**context*, const char \**name*,** **const char \**type*)** **void hesiod\_free\_string(void \**context*, char \**str*);** **char \*\*hesiod\_parse\_result(void \**context*,** **unsigned const char \**result*, int *rlen*)** **void hesiod\_end(void \**context*)**

**cc file.c -lhesiod**

## DESCRIPTION

This family of functions allows you to perform lookups of Hesiod information, which is stored as text records in the Domain Name Service.  To perform lookups, you must first initialize a *context*, an opaque object which stores information used internally by the library between calls. *hesiod\_init* initializes a context, storing a pointer to the context in the location pointed to by the *context* argument. *hesiod\_end* frees the resources used by a context.

*hesiod\_resolve* is the primary interface to the library.  If successful, it returns a list of one or more strings giving the records matching *name* and *type*. The last element of the list is followed by a NULL pointer.  It is the caller's responsibility to call *hesiod\_free\_list* to free the resources used by the returned list.

*hesiod\_to\_bind* converts *name* and *type* into the DNS name used by *hesiod\_resolve*. It is the caller's responsibility to free the returned string using *hesiod\_free\_string*.

*hesiod\_parse\_result* parses the result of a name server query into text records.  It is the caller's responsibility to call *hesiod\_free\_list* to free the resources used by the returned list.

## RETURN VALUES

If successful, *hesiod\_init* returns 0; otherwise it returns -1 and sets *errno* to indicate the error.  On failure, *hesiod\_resolve* and *hesiod\_to\_bind* return NULL and set the global variable *errno* to indicate the error.

## ENVIRONMENT

If the environment variable **HES\_DOMAIN** is set, it will override the domain in the Hesiod configuration file. If the environment variable **HESIOD\_CONFIG** is set, it specifies the location of the Hesiod configuration file.

## SEE ALSO

\`Hesiod - Project Athena Technical Plan -- Name Service', [named(8)](/named/8.md), [hesiod.conf(5)](/hesiod.conf/5.md)

## ERRORS

Hesiod calls may fail because of:

- ENOMEM

  Insufficient memory was available to carry out the requested operation.

- ENOEXEC

  *hesiod\_init* failed because the Hesiod configuration file was invalid.

- ECONNREFUSED

  *hesiod\_resolve* failed because no name server could be contacted to answer the query.

- EMSGSIZE

  *hesiod\_resolve* or *hesiod\_to\_bind* failed because the query or response was too big to fit into the packet buffers.

- ENOENT

  *hesiod\_resolve* failed because the name server had no text records matching *name* and *type*, or *hesiod\_to\_bind* failed because the *name* argument had a domain extension which could not be resolved with type \`\`rhs-extension'' in the local Hesiod domain.

- EINVAL

  *hesiod\_to\_bind* failed to convert the resulting domain name from UTF-8 to an internationalized domain name.

## AUTHOR

Steve Dyer, IBM/Project Athena\
 Greg Hudson, MIT Team Athena\
 Copyright 1987, 1988, 1995, 1996, 2000 by the Massachusetts Institute of Technology.

## BUGS

The strings corresponding to the *errno* values set by the Hesiod functions are not particularly indicative of what went wrong, especially for *ENOEXEC* and *ENOENT*.
