summaryrefslogtreecommitdiff
path: root/src/libs6dns/s6dns_fmt_mx.c
blob: aba538ba3f6184400e840969fef357d2074b1d33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* ISC license. */

#include <skalibs/uint16.h>
#include <skalibs/bytestr.h>
#include <s6-dns/s6dns-message.h>
#include <s6-dns/s6dns-fmt.h>

unsigned int s6dns_fmt_mx (char *s, unsigned int max, s6dns_message_rr_mx_t const *mx)
{
  char fmt[UINT16_FMT] ;
  unsigned int len = uint16_fmt(fmt, mx->preference) ;
  unsigned int r ;
  if (len >= max) return 0 ;
  fmt[len++] = ' ' ;
  r = s6dns_domain_tostring(s + len, max - len, &mx->exchange) ;
  if (!r) return 0 ;
  byte_copy(s, len, fmt) ;
  return len + r ;
}