Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
678 B

#include "fmt.h"
#include "stralloc.h"
#include "textcode.h"
#include "haveinline.h"
int fmt_base64_sa(stralloc *sa,const char* src,unsigned int len) {
register const unsigned char* s=(const unsigned char*) src;
unsigned short bits=0,temp=0;
unsigned long i;
char dest;
for (i=0; i<len; ++i) {
temp<<=8; temp+=s[i]; bits+=8;
while (bits>6) {
if (!stralloc_catb(sa, &dest, 1)) return 0;
if (bits) {
if (!stralloc_catb(sa, &dest, 1)) return 0;
while (sa->len&3) {
if (!stralloc_catb(sa, "=", 1)) return 0;
return 1;