aboutsummaryrefslogtreecommitdiff
path: root/lib/curl_sasl.c
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2012-05-31 23:11:54 +0100
committerSteve Holme <steve_holme@hotmail.com>2012-05-31 23:11:54 +0100
commit54d484e136d43b50934cc906804662e780adc3fa (patch)
tree2d895f748df6a9fcfe47c9a2b7f5597f3f87300f /lib/curl_sasl.c
parentcb3d0ce2cb5097d906c9e7b9d5bb1de2eb4bbb93 (diff)
sasl: Moved login authentication message creation from smtp.c
Moved the login message creation from smtp.c into the sasl module to allow for use by other modules such as pop3.
Diffstat (limited to 'lib/curl_sasl.c')
-rw-r--r--lib/curl_sasl.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/curl_sasl.c b/lib/curl_sasl.c
index e2e1e3e7a..50baea97a 100644
--- a/lib/curl_sasl.c
+++ b/lib/curl_sasl.c
@@ -77,3 +77,39 @@ CURLcode Curl_sasl_create_plain_message(struct SessionHandle *data,
return Curl_base64_encode(data, plainauth, 2 * ulen + plen + 2, outptr,
outlen);
}
+
+/*
+ * Curl_sasl_create_login_message()
+ *
+ * This is used to generate an already encoded login message containing the
+ * user name or password ready for sending to the recipient.
+ *
+ * Parameters:
+ *
+ * data [in] - The session handle.
+ * userp [in] - The user name.
+ * outptr [in/out] - The address where a pointer to newly allocated memory
+ * holding the result will be stored upon completion.
+ * outlen [out] - The length of the output message.
+ *
+ * Returns CURLE_OK on success.
+ */
+CURLcode Curl_sasl_create_login_message(struct SessionHandle *data,
+ const char* valuep, char **outptr,
+ size_t *outlen)
+{
+ size_t vlen = strlen(valuep);
+
+ if(!vlen) {
+ *outptr = strdup("=");
+ if(*outptr) {
+ *outlen = (size_t) 1;
+ return CURLE_OK;
+ }
+
+ *outlen = 0;
+ return CURLE_OUT_OF_MEMORY;
+ }
+
+ return Curl_base64_encode(data, valuep, vlen, outptr, outlen);
+}