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

#include <sys/types.h>
#include <stdint.h>
#include <skalibs/uint32.h>
#include <skalibs/bytestr.h>
#include <skalibs/biguint.h>

size_t bu_fmt (char *s, uint32_t const *x, unsigned int n)
{
  size_t len = 0 ;
  while (n--)
  {
    char fmt[8] ;
    size_t i = uint32_xfmt(fmt, x[n]) ;
    byte_copy(s+len, 8-i, "00000000") ;
    byte_copy(s+len+8-i, i, fmt) ;
    len += 8 ;
  }
  return len ;
}