File: decode_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 (15 lines) | stat: -rw-r--r-- 339 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include "base64.h"

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