authsasltobase64.c
上传用户:s81996212
上传日期:2007-01-04
资源大小:722k
文件大小:1k
源码类别:

WEB邮件程序

开发平台:

C/C++

  1. #include <stdlib.h>
  2. #include "rfc2045/rfc2045.h"
  3. static char *write_challenge_buf;
  4. static char *write_challenge_ptr;
  5. static void write_challenge(const char *p, size_t l)
  6. {
  7. while (l)
  8. {
  9. if (*p == 'r' || *p == 'n')
  10. {
  11. ++p;
  12. --l;
  13. continue;
  14. }
  15. *write_challenge_ptr++ = *p++;
  16. --l;
  17. }
  18. }
  19. char *authsasl_tobase64(const char *p, int l)
  20. {
  21. if (l < 0) l=strlen(p);
  22. write_challenge_buf=malloc((l+3)/3*4+1);
  23. if (!write_challenge_buf)
  24. return (0);
  25. write_challenge_ptr=write_challenge_buf;
  26. rfc2045_base64encode_start( &write_challenge );
  27. rfc2045_base64encode(p, l);
  28. rfc2045_base64encode_end();
  29. *write_challenge_ptr=0;
  30. return (write_challenge_buf);
  31. }