Refactor authenticators API to take an (opaque) smtp connection context
[exim.git] / src / src / auths / plaintext.c
index bdd05699de7e9f48d655df2c65916d1e1c95979d..7a0f788529456834efb4d6d821fceb76253cc927 100644 (file)
@@ -40,8 +40,8 @@ auth_plaintext_options_block auth_plaintext_option_defaults = {
 /* Dummy values */
 void auth_plaintext_init(auth_instance *ablock) {}
 int auth_plaintext_server(auth_instance *ablock, uschar *data) {return 0;}
-int auth_plaintext_client(auth_instance *ablock, smtp_inblock *inblock,
-  smtp_outblock *outblock, int timeout, uschar *buffer, int buffsize) {return 0;}
+int auth_plaintext_client(auth_instance *ablock, void * sx, int timeout,
+    uschar *buffer, int buffsize) {return 0;}
 
 #else   /*!MACRO_PREDEF*/
 
@@ -167,8 +167,7 @@ return auth_check_serv_cond(ablock);
 int
 auth_plaintext_client(
   auth_instance *ablock,                 /* authenticator block */
-  smtp_inblock *inblock,                 /* connection inblock */
-  smtp_outblock *outblock,               /* connection outblock */
+  void * sx,                            /* smtp connextion */
   int timeout,                           /* command timeout */
   uschar *buffer,                        /* buffer for reading response */
   int buffsize)                          /* size of buffer */
@@ -201,8 +200,8 @@ while ((s = string_nextinlist(&text, &sep, big_buffer, big_buffer_size)))
     uschar *ssave = string_copy(s);
     if (!first)
       {
-      if (smtp_write_command(outblock, SCMD_FLUSH, "*\r\n") >= 0)
-        (void) smtp_read_response(inblock, US buffer, buffsize, '2', timeout);
+      if (smtp_write_command(sx, SCMD_FLUSH, "*\r\n") >= 0)
+        (void) smtp_read_response(sx, US buffer, buffsize, '2', timeout);
       }
     if (f.expand_string_forcedfail)
       {
@@ -236,15 +235,13 @@ while ((s = string_nextinlist(&text, &sep, big_buffer, big_buffer_size)))
   if (first)
     {
     first = FALSE;
-    if (smtp_write_command(outblock, SCMD_FLUSH, "AUTH %s%s%s\r\n",
-         ablock->public_name, (len == 0)? "" : " ",
-         b64encode(ss, len)) < 0)
+    if (smtp_write_command(sx, SCMD_FLUSH, "AUTH %s%s%s\r\n",
+         ablock->public_name, len == 0 ? "" : " ", b64encode(ss, len)) < 0)
       return FAIL_SEND;
     }
   else
     {
-    if (smtp_write_command(outblock, SCMD_FLUSH, "%s\r\n",
-          b64encode(ss, len)) < 0)
+    if (smtp_write_command(sx, SCMD_FLUSH, "%s\r\n", b64encode(ss, len)) < 0)
       return FAIL_SEND;
     }
 
@@ -252,7 +249,7 @@ while ((s = string_nextinlist(&text, &sep, big_buffer, big_buffer_size)))
   has succeeded. There may be more data to send, but is there any point
   in provoking an error here? */
 
-  if (smtp_read_response(inblock, US buffer, buffsize, '2', timeout)) return OK;
+  if (smtp_read_response(sx, US buffer, buffsize, '2', timeout)) return OK;
 
   /* Not a success response. If errno != 0 there is some kind of transmission
   error. Otherwise, check the response code in the buffer. If it starts with
@@ -263,10 +260,10 @@ while ((s = string_nextinlist(&text, &sep, big_buffer, big_buffer_size)))
   /* If there is no more data to send, we have to cancel the authentication
   exchange and return ERROR. */
 
-  if (text == NULL)
+  if (!text)
     {
-    if (smtp_write_command(outblock, SCMD_FLUSH, "*\r\n") >= 0)
-      (void)smtp_read_response(inblock, US buffer, buffsize, '2', timeout);
+    if (smtp_write_command(sx, SCMD_FLUSH, "*\r\n") >= 0)
+      (void)smtp_read_response(sx, US buffer, buffsize, '2', timeout);
     string_format(buffer, buffsize, "Too few items in client_send in %s "
       "authenticator", ablock->name);
     return ERROR;
@@ -287,8 +284,8 @@ while ((s = string_nextinlist(&text, &sep, big_buffer, big_buffer_size)))
     uschar *save_bad = string_copy(buffer);
     if (!ob->client_ignore_invalid_base64)
       {
-      if (smtp_write_command(outblock, SCMD_FLUSH, "*\r\n") >= 0)
-        (void)smtp_read_response(inblock, US buffer, buffsize, '2', timeout);
+      if (smtp_write_command(sx, SCMD_FLUSH, "*\r\n") >= 0)
+        (void)smtp_read_response(sx, US buffer, buffsize, '2', timeout);
       string_format(buffer, buffsize, "Invalid base64 string in server "
         "response \"%s\"", save_bad);
       return CANCELLED;