1
0
mirror of https://github.com/winscp/winscp.git synced 2026-10-24 02:28:55 +03:00
Files
winscp/source/putty/utils/base64_decode.c
Martin Prikryl f670f4ebb1 Resetting differences to official PuTTY that are no longer needed
Most, if not all, were for compatibility with the classic C++Builder compiler (declarations in the middle of code + inline structure initializers)

Source commit: a9f38c3a07777e538c3c6e0fbdd38e9d68327dfa
2025-12-06 01:29:35 +01:00

38 lines
879 B
C

#include "misc.h"
void base64_decode_bs(BinarySink *bs, ptrlen input)
{
BinarySource src[1];
BinarySource_BARE_INIT_PL(src, input);
while (get_avail(src)) {
char b64atom[4];
unsigned char binatom[3];
for (size_t i = 0; i < 4 ;) {
char c = get_byte(src);
if (get_err(src))
c = '=';
if (c == '\n' || c == '\r')
continue;
b64atom[i++] = c;
}
put_data(bs, binatom, base64_decode_atom(b64atom, binatom));
}
}
void base64_decode_fp(FILE *fp, ptrlen input)
{
stdio_sink ss;
stdio_sink_init(&ss, fp);
base64_decode_bs(BinarySink_UPCAST(&ss), input);
}
strbuf *base64_decode_sb(ptrlen input)
{
strbuf *sb = strbuf_new_nm();
base64_decode_bs(BinarySink_UPCAST(sb), input);
return sb;
}