37 #if defined (WIN32) && !defined (RTLD_DEFAULT) 
   38 # define RTLD_DEFAULT GetModuleHandle(NULL) 
   41 #include <my_global.h> 
   49 #if !defined (_GNU_SOURCE) 
   58 #define ORDINARY_QUESTION       "\2" 
   59 #define LAST_QUESTION           "\3" 
   60 #define PASSWORD_QUESTION       "\4" 
   61 #define LAST_PASSWORD           "\5" 
   74   if (vio->
write_packet(vio, (
const unsigned char *) PASSWORD_QUESTION 
"Password, please:", 18))
 
   88   if (vio->
write_packet(vio, (
const unsigned char *) LAST_QUESTION 
"Are you sure ?", 15))
 
   96   return strcmp((
const char *) pkt, 
"yes, of course") ? 
CR_ERROR : 
CR_OK;
 
  101   MYSQL_AUTHENTICATION_INTERFACE_VERSION,
 
  112   for (i= 0; i < 3; i++)
 
  116                 (
const unsigned char *) PASSWORD_QUESTION 
"Password, please:", 18))
 
  129     if (strcmp((
const char *) pkt, info->
auth_string) == 0)
 
  138   MYSQL_AUTHENTICATION_INTERFACE_VERSION,
 
  143 mysql_declare_plugin(dialog)
 
  145   MYSQL_AUTHENTICATION_PLUGIN,
 
  149   "Dialog plugin demo 1",
 
  160   MYSQL_AUTHENTICATION_PLUGIN,
 
  164   "Dialog plugin demo 2",
 
  174 mysql_declare_plugin_end;
 
  205 typedef char *(*mysql_authentication_dialog_ask_t)(
struct st_mysql *mysql,
 
  206                       int type, 
const char *prompt, 
char *
buf, 
int buf_len);
 
  210 static char *builtin_ask(
MYSQL *mysql __attribute__((unused)),
 
  211                          int type __attribute__((unused)),
 
  213                          char *buf, 
int buf_len)
 
  216   fputs(prompt, stdout);
 
  218   if (fgets(buf, buf_len, stdin) == NULL)
 
  220   if ((ptr= strchr(buf, 
'\n')))
 
  244   unsigned char *pkt, cmd= 0;
 
  246   char reply_buf[1024], *
reply;
 
  266       reply= mysql->passwd;
 
  273       if (cmd == 0 || cmd == 254)
 
  280       if ((cmd >> 1) == 2 && *pkt == 0)
 
  281         reply= mysql->passwd;
 
  283         reply= ask(mysql, cmd >> 1, (
const char *) pkt, 
 
  284                                    reply_buf, 
sizeof(reply_buf));
 
  289     res= vio->
write_packet(vio, (
const unsigned char *) reply, 
 
  292     if (reply != mysql->passwd && reply != reply_buf)
 
  299   } 
while ((cmd & 1) != 1);
 
  312 static int init_dialog(
char *unused1   __attribute__((unused)), 
 
  313                        size_t unused2  __attribute__((unused)), 
 
  314                        int unused3     __attribute__((unused)), 
 
  315                        va_list unused4 __attribute__((unused)))
 
  317   void *sym= dlsym(RTLD_DEFAULT, 
"mysql_authentication_dialog_ask");
 
  322 mysql_declare_client_plugin(AUTHENTICATION)
 
  325   "Dialog Client Authentication Plugin",
 
  333 mysql_end_client_plugin;