libowfat/textcode/scan_quotedprintable.c
leitner a8f6a1c121 remove special case stralloc textcode functions
write generic stralloc and array textcode wrapper functions
change textcode API to use long instead of int
add cescape fmt and scan functions to textcode
add fmt_foldwhitespace to textcode
2003-09-19 19:08:13 +00:00

25 lines
551 B
C

#include "fmt.h"
#include "textcode.h"
#include "scan.h"
unsigned long scan_quotedprintable(const char *src,char *dest,unsigned long *destlen) {
register const unsigned char* s=(const unsigned char*) src;
unsigned long written=0,i;
for (i=0; s[i]; ++i) {
if (s[i]=='=') {
int j=scan_fromhex(s[i+1]);
if (j<0) break;
dest[written]=j<<4;
j=scan_fromhex(s[i+2]);
if (j<0) break;
dest[written]|=j;
i+=2;
} else {
dest[written]=s[i];
}
++written;
}
*destlen=written;
return i;
}