65 static int b64_write(
BIO *
h,
const char *buf,
int num);
66 static int b64_read(
BIO *
h,
char *buf,
int size);
67 static int b64_puts(
BIO *
h,
const char *str);
69 static long b64_ctrl(
BIO *
h,
int cmd,
long arg1,
void *arg2);
70 static int b64_new(
BIO *
h);
73 #define B64_BLOCK_SIZE 1024
74 #define B64_BLOCK_SIZE2 768
109 return(&methods_b64);
112 static int b64_new(
BIO *bi)
117 if (ctx == NULL)
return(0);
134 static int b64_free(
BIO *
a)
136 if (a == NULL)
return(0);
144 static int b64_read(
BIO *
b,
char *out,
int outl)
146 int ret=0,i,ii,j,
k,x,n,
num,ret_code=0;
150 if (out == NULL)
return(0);
153 if ((ctx == NULL) || (b->
next_bio == NULL))
return(0);
171 if (i > outl) i=outl;
228 q=p=(
unsigned char *)ctx->
tmp;
231 if (*(q++) !=
'\n')
continue;
245 (
unsigned char *)ctx->
buf,
247 if ((k <= 0) && (num == 0) && (ctx->
start))
251 if (p != (
unsigned char *)
254 i-=(p- (
unsigned char *)
256 for (x=0; x < i; x++)
271 if (p == (
unsigned char *)&(ctx->
tmp[0]))
283 for (ii=0; ii<n; ii++)
313 (
unsigned char *)ctx->
tmp,jj);
316 if (ctx->
tmp[jj-1] ==
'=')
319 if (ctx->
tmp[jj-2] ==
'=')
327 memmove(ctx->
tmp, &ctx->
tmp[jj], i-jj);
341 (
unsigned char *)ctx->
tmp,i);
357 memcpy(out,ctx->
buf,i);
370 return((ret == 0)?ret_code:ret);
373 static int b64_write(
BIO *b,
const char *in,
int inl)
414 if ((in == NULL) || (inl <= 0))
return(0);
445 memcpy(ctx->
tmp,in,n);
461 (
unsigned char *)in,n);
477 return((ret == 0)?i:ret);
491 static long b64_ctrl(
BIO *b,
int cmd,
long num,
void *
ptr)
533 i=b64_write(b,NULL,0);
542 (
unsigned char *)ctx->
buf,
543 (
unsigned char *)ctx->
tmp,
554 (
unsigned char *)ctx->
buf,
595 static int b64_puts(
BIO *b,
const char *str)
597 return b64_write(b,str,strlen(str));