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

#include <stdint.h>
#include <string.h>
#include <skalibs/uint32.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]) ;
    memcpy(s+len, "00000000", 8-i) ;
    memcpy(s+len+8-i, fmt, i) ;
    len += 8 ;
  }
  return len ;
}