3 #include "rfc822/encode.h"
5 static int write_challenge(const char *p
, size_t l
, void *vp
)
11 if (*p
== '\r' || *p
== '\n')
26 char *authsasl_tobase64(const char *p
, int l
)
28 char *write_challenge_buf
;
29 char *write_challenge_ptr
;
31 struct libmail_encode_info encodeInfo
;
33 if (l
< 0) l
=strlen(p
);
35 write_challenge_buf
=malloc((l
+3)/3*4+1);
36 if (!write_challenge_buf
)
39 write_challenge_ptr
=write_challenge_buf
;
41 libmail_encode_start(&encodeInfo
, "base64", &write_challenge
,
42 &write_challenge_ptr
);
44 libmail_encode(&encodeInfo
, p
, l
);
45 libmail_encode_end(&encodeInfo
);
46 *write_challenge_ptr
=0;
47 return (write_challenge_buf
);