File: encode_line.c

package info (click to toggle)
bglibs 2.04%2Bdfsg-8
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 3,468 kB
  • sloc: ansic: 15,821; perl: 674; sh: 63; makefile: 29
file content (18 lines) | stat: -rw-r--r-- 379 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "base64.h"

int base64_encode_line(const unsigned char* bin, unsigned long len,
		       str* encoded)
{
  char tmp[4];
  while (len >= 3) {
    base64_encode_whole(bin, tmp);
    if (!str_catb(encoded, tmp, 4)) return 0;
    bin += 3;
    len -= 3;
  }
  if (len) {
    base64_encode_part(bin, len, tmp);
    if (!str_catb(encoded, tmp, 4)) return 0;
  }
  return 1;
}