libowfat/test/b64decode.c

35 lines
668 B
C
Raw Normal View History

2002-09-06 18:00:07 +00:00
#include <string.h>
#include <unistd.h>
2002-09-06 18:00:07 +00:00
#include "buffer.h"
#include "textcode.h"
2004-01-06 23:35:06 +00:00
#include "havealloca.h"
2002-09-06 18:00:07 +00:00
void b64encode(const char* c) {
char* buf=alloca(strlen(c)*2+4);
unsigned long dlen;
2002-09-06 18:00:07 +00:00
scan_base64(c,buf,&dlen);
buffer_put(buffer_1,buf,dlen);
}
2004-11-25 21:52:35 +00:00
int main(int argc,char* argv[]) {
2002-09-06 18:00:07 +00:00
int i;
for (i=1; i<argc; ++i) {
b64encode(argv[i]);
2004-05-06 20:44:14 +00:00
buffer_flush(buffer_1);
2002-09-06 18:00:07 +00:00
}
if (argc<2) {
char src[1024];
2004-05-06 20:44:14 +00:00
int len;
while ((len=read(0,src,sizeof(src)-1))>0) {
src[len]=0;
b64encode(src);
}
if (isatty(1))
buffer_putnlflush(buffer_1);
else
buffer_flush(buffer_1);
2002-09-06 18:00:07 +00:00
if (len==-1) return(1);
}
return 0;
}