[BACK]Return to uuencode.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

File: [local] / src / usr.bin / ssh / Attic / uuencode.c (download)

Revision 1.4, Thu May 4 22:38:00 2000 UTC (24 years, 1 month ago) by markus
Branch: MAIN
Changes since 1.3: +8 -92 lines

replace broken uuencode w/ libc b64_ntop

/*
 * Copyright (c) 2000 Markus Friedl.  All rights reserved.
 */
#include "includes.h"
#include "xmalloc.h"

#include <resolv.h>

int
uuencode(unsigned char *src, unsigned int srclength,
    char *target, size_t targsize)
{
	return b64_ntop(src, srclength, target, targsize);
}

int
uudecode(const char *src, unsigned char *target, size_t targsize)
{
	return b64_pton(src, target, targsize);
}

void
dump_base64(FILE *fp, unsigned char *data, int len)
{
	unsigned char *buf = xmalloc(2*len);
	int i, n;
	n = uuencode(data, len, buf, 2*len);
	for (i = 0; i < n; i++) {
		fprintf(fp, "%c", buf[i]);
		if (i % 70 == 69)
			fprintf(fp, "\n");
	}
	if (i % 70 != 69)
		fprintf(fp, "\n");
	xfree(buf);
}