trimdomain(3)

trimdomain3

Trim the current domain name from a host name

Usage

#include <sys/types.h>

#include <libutil.h>

void

trimdomain(char *fullhost, size_t hostsize);

Library

System Utilities Library (libutil, -lutil)

Overview

The function trimdomain() removes the current domain name from the passed fullhost name by writing a NUL character over the first period of the passed name. The current domain name is determined by calling gethostname(3) and removing everything up to the first period. The name is determined the first time this function is called and is cached for future use.

The trimdomain() function will only trim the domain name if the passed fullhost ends with the current domain name and if the length of the resulting host name does not exceed hostsize.

If the passed fullhost is actually an X11 DISPLAY specification of the form host.domain:display[.screen], and the domain name is the same as the local domain name, trimdomain() will remove the embedded domain name, copying the screen and display numbers to the end of the base host name and resulting in host:display[.screen].

Return values

The trimdomain() function does not return a value.

Releases

75 releases since FreeBSD 3.2-RELEASE; the text changed 44 times.

  1. 3.2
  2. 3.3–3.4
  3. 3.5–3.5.1
  4. 4.0
  5. 4.1–4.2
  6. 4.3–4.4
  7. 4.5–4.11
  8. 5.0
  9. 5.1–5.2.1
  10. 5.3–6.3
  11. 6.4
  12. 7.0
  13. 7.1
  14. 7.2
  15. 7.3
  16. 7.4
  17. 8.0
  18. 8.1
  19. 8.2
  20. 8.3
  21. 8.4
  22. 9.0
  23. 9.1
  24. 9.2
  25. 9.3
  26. 10.0
  27. 10.1
  28. 10.2
  29. 10.3
  30. 10.4
  31. 11.0
  32. 11.1
  33. 11.2
  34. 11.3
  35. 11.4
  36. 12.0
  37. 12.1
  38. 12.2
  39. 12.3
  40. 12.4
  41. 13.0–13.2
  42. 13.3–14.4
  43. 14.5
  44. 15.0
  45. 15.1–16.0

History

The function trimdomain() first appeared in FreeBSD 3.2.

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.