You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
668 B
C

22 years ago
#include <string.h>
#include <unistd.h>
22 years ago
#include "buffer.h"
#include "textcode.h"
21 years ago
#include "havealloca.h"
22 years ago
void b64encode(const char* c) {
char* buf=alloca(strlen(c)*2+4);
unsigned long dlen;
22 years ago
scan_base64(c,buf,&dlen);
buffer_put(buffer_1,buf,dlen);
}
int main(int argc,char* argv[]) {
22 years ago
int i;
for (i=1; i<argc; ++i) {
b64encode(argv[i]);
buffer_flush(buffer_1);
22 years ago
}
if (argc<2) {
char src[1024];
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);
22 years ago
if (len==-1) return(1);
}
return 0;
}