NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
DOXYGEN
sasl_plain.c
Go to the documentation of this file.
1 
29 #include "config.h"
30 #include <stdio.h>
31 #include "mutt/lib.h"
32 #include "sasl_plain.h"
33 
55 size_t mutt_sasl_plain_msg(char *buf, size_t buflen, const char *cmd,
56  const char *authz, const char *user, const char *pass)
57 {
58  char tmp[768];
59  size_t len = 0;
60  size_t tmplen;
61 
62  if (!user || (*user == '\0') || !pass || (*pass == '\0'))
63  return 0;
64 
65  tmplen = snprintf(tmp, sizeof(tmp), "%s%c%s%c%s", NONULL(authz), '\0', user, '\0', pass);
66 
67  if (cmd && *cmd)
68  {
69  len = snprintf(buf, buflen, "%s ", cmd);
70  }
71  len += mutt_b64_encode(tmp, tmplen, buf + len, buflen - len);
72  return len;
73 }
#define NONULL(x)
Definition: string2.h:37
SASL plain authentication support.
size_t mutt_sasl_plain_msg(char *buf, size_t buflen, const char *cmd, const char *authz, const char *user, const char *pass)
Construct a base64 encoded SASL PLAIN message.
Definition: sasl_plain.c:55
size_t mutt_b64_encode(const char *in, size_t inlen, char *out, size_t outlen)
Convert raw bytes to null-terminated base64 string.
Definition: base64.c:88
Convenience wrapper for the library headers.