build: use pkg-config for i18n
[exim.git] / src / src / auths / plaintext.c
index 6c9703554ae6dd72da2df53d7f0469cedaa54530..13d05d1e5eac23c8e34f078532d6fa5be65627fd 100644 (file)
@@ -2,10 +2,14 @@
 *     Exim - an Internet mail transport agent    *
 *************************************************/
 
 *     Exim - an Internet mail transport agent    *
 *************************************************/
 
+/* Copyright (c) The Exim Maintainers 2020 - 2024 */
 /* Copyright (c) University of Cambridge 1995 - 2018 */
 /* See the file NOTICE for conditions of use and distribution. */
 /* Copyright (c) University of Cambridge 1995 - 2018 */
 /* See the file NOTICE for conditions of use and distribution. */
+/* SPDX-License-Identifier: GPL-2.0-or-later */
 
 #include "../exim.h"
 
 #include "../exim.h"
+
+#ifdef AUTH_PLAINTEXT  /* Remainder of file */
 #include "plaintext.h"
 
 
 #include "plaintext.h"
 
 
 
 optionlist auth_plaintext_options[] = {
   { "client_ignore_invalid_base64", opt_bool,
 
 optionlist auth_plaintext_options[] = {
   { "client_ignore_invalid_base64", opt_bool,
-      (void *)(offsetof(auth_plaintext_options_block, client_ignore_invalid_base64)) },
+      OPT_OFF(auth_plaintext_options_block, client_ignore_invalid_base64) },
   { "client_send",        opt_stringptr,
   { "client_send",        opt_stringptr,
-      (void *)(offsetof(auth_plaintext_options_block, client_send)) },
+      OPT_OFF(auth_plaintext_options_block, client_send) },
   { "server_prompts",     opt_stringptr,
   { "server_prompts",     opt_stringptr,
-      (void *)(offsetof(auth_plaintext_options_block, server_prompts)) }
+      OPT_OFF(auth_plaintext_options_block, server_prompts) }
 };
 
 /* Size of the options list. An extern variable has to be used so that its
 };
 
 /* Size of the options list. An extern variable has to be used so that its
@@ -38,7 +42,7 @@ auth_plaintext_options_block auth_plaintext_option_defaults = {
 #ifdef MACRO_PREDEF
 
 /* Dummy values */
 #ifdef MACRO_PREDEF
 
 /* Dummy values */
-void auth_plaintext_init(auth_instance *ablock) {}
+void auth_plaintext_init(driver_instance *ablock) {}
 int auth_plaintext_server(auth_instance *ablock, uschar *data) {return 0;}
 int auth_plaintext_client(auth_instance *ablock, void * sx, int timeout,
     uschar *buffer, int buffsize) {return 0;}
 int auth_plaintext_server(auth_instance *ablock, uschar *data) {return 0;}
 int auth_plaintext_client(auth_instance *ablock, void * sx, int timeout,
     uschar *buffer, int buffsize) {return 0;}
@@ -56,13 +60,17 @@ enable consistency checks to be done, or anything else that needs
 to be set up. */
 
 void
 to be set up. */
 
 void
-auth_plaintext_init(auth_instance *ablock)
+auth_plaintext_init(driver_instance * a)
 {
 {
-auth_plaintext_options_block *ob =
-  (auth_plaintext_options_block *)(ablock->options_block);
-if (ablock->public_name == NULL) ablock->public_name = ablock->name;
-if (ablock->server_condition != NULL) ablock->server = TRUE;
-if (ob->client_send != NULL) ablock->client = TRUE;
+auth_instance * ablock = (auth_instance *)a;
+auth_plaintext_options_block * ob = a->options_block;
+
+if (!ablock->public_name)
+  ablock->public_name = ablock->drinst.name;
+if (ablock->server_condition)
+  ablock->server = TRUE;
+if (ob->client_send)
+  ablock->client = TRUE;
 }
 
 
 }
 
 
@@ -74,14 +82,13 @@ if (ob->client_send != NULL) ablock->client = TRUE;
 /* For interface, see auths/README */
 
 int
 /* For interface, see auths/README */
 
 int
-auth_plaintext_server(auth_instance *ablock, uschar *data)
+auth_plaintext_server(auth_instance * ablock, uschar * data)
 {
 {
-auth_plaintext_options_block *ob =
-  (auth_plaintext_options_block *)(ablock->options_block);
-const uschar *prompts = ob->server_prompts;
-uschar *clear, *end, *s;
+auth_plaintext_options_block * ob = ablock->drinst.options_block;
+const uschar * prompts = ob->server_prompts;
+uschar * s;
 int number = 1;
 int number = 1;
-int len, rc;
+int rc;
 int sep = 0;
 
 /* Expand a non-empty list of prompt strings */
 int sep = 0;
 
 /* Expand a non-empty list of prompt strings */
@@ -108,7 +115,7 @@ already been provided as part of the AUTH command. For the rest, send them
 out as prompts, and get a data item back. If the data item is "*", abandon the
 authentication attempt. Otherwise, split it into items as above. */
 
 out as prompts, and get a data item back. If the data item is "*", abandon the
 authentication attempt. Otherwise, split it into items as above. */
 
-while (  (s = string_nextinlist(&prompts, &sep, big_buffer, big_buffer_size))
+while (  (s = string_nextinlist(&prompts, &sep, NULL, 0))
       && expand_nmax < EXPAND_MAXN)
   if (number++ > expand_nmax)
     if ((rc = auth_prompt(CUS s)) != OK)
       && expand_nmax < EXPAND_MAXN)
   if (number++ > expand_nmax)
     if ((rc = auth_prompt(CUS s)) != OK)
@@ -139,11 +146,9 @@ auth_plaintext_client(
   uschar *buffer,                        /* buffer for reading response */
   int buffsize)                          /* size of buffer */
 {
   uschar *buffer,                        /* buffer for reading response */
   int buffsize)                          /* size of buffer */
 {
-auth_plaintext_options_block *ob =
-  (auth_plaintext_options_block *)(ablock->options_block);
+auth_plaintext_options_block * ob = ablock->drinst.options_block;
 const uschar * text = ob->client_send;
 const uschar * s;
 const uschar * text = ob->client_send;
 const uschar * s;
-BOOL first = TRUE;
 int sep = 0;
 int auth_var_idx = 0, rc;
 int flags = AUTH_ITEM_FIRST;
 int sep = 0;
 int auth_var_idx = 0, rc;
 int flags = AUTH_ITEM_FIRST;
@@ -175,5 +180,29 @@ while ((s = string_nextinlist(&text, &sep, NULL, 0)))
 return FAIL;
 }
 
 return FAIL;
 }
 
-#endif   /*!MACRO_PREDEF*/
+
+# ifdef DYNLOOKUP
+#  define plaintext_auth_info _auth_info
+# endif
+
+auth_info plaintext_auth_info = {
+.drinfo = {
+  .driver_name =       US"plaintext",                   /* lookup name */
+  .options =           auth_plaintext_options,
+  .options_count =     &auth_plaintext_options_count,
+  .options_block =     &auth_plaintext_option_defaults,
+  .options_len =       sizeof(auth_plaintext_options_block),
+  .init =              auth_plaintext_init,
+# ifdef DYNLOOKUP
+  .dyn_magic =         AUTH_MAGIC,
+# endif
+  },
+.servercode =          auth_plaintext_server,
+.clientcode =          auth_plaintext_client,
+.version_report =      NULL,
+.macros_create =       NULL,
+};
+
+#endif /*!MACRO_PREDEF*/
+#endif /*AUTH_PLAINTEST*/
 /* End of plaintext.c */
 /* End of plaintext.c */