269
274
class ListenConsole: public plugin::Listen
277
const std::string username;
278
const std::string password;
279
const std::string db;
274
ListenConsole(const std::string &name_arg) :
275
plugin::Listen(name_arg)
282
ListenConsole(const std::string &name_arg,
283
const std::string &username_arg,
284
const std::string &password_arg,
285
const std::string &db_arg) :
286
plugin::Listen(name_arg),
287
username(username_arg),
288
password(password_arg),
316
325
assert(read(fd, buffer, 1) == 1);
317
return new ClientConsole;
326
return new ClientConsole(username, password, db);
321
330
static int init(drizzled::module::Context &context)
323
332
const module::option_map &vm= context.getOptions();
324
/* duplicating these here means they need to be freed. They're global, so
325
we'll just have the ListenConsole object do it in its destructor */
326
if (vm.count("username"))
327
username= strdup(vm["username"].as<string>().c_str());
329
username= strdup("");
331
if (vm.count("password"))
332
password= strdup(vm["password"].as<string>().c_str());
334
password= strdup("");
337
db= strdup(vm["db"].as<string>().c_str());
341
context.add(new ListenConsole("console"));
333
const string username(vm.count("username") ? vm["username"].as<string>() : "");
334
const string password(vm.count("password") ? vm["password"].as<string>() : "");
335
const string db(vm.count("db") ? vm["db"].as<string>() : "");
336
context.registerVariable(new sys_var_bool_ptr("enable", &enabled));
337
context.registerVariable(new sys_var_bool_ptr("debug_enable", &debug_enabled));
338
context.registerVariable(new sys_var_const_string_val("username", username));
339
context.registerVariable(new sys_var_const_string_val("password", password));
340
context.registerVariable(new sys_var_const_string_val("db", db));
341
context.add(new ListenConsole("console", username, password, db));
345
static DRIZZLE_SYSVAR_BOOL(enable, enabled, PLUGIN_VAR_NOCMDARG,
346
N_("Enable the console."), NULL, NULL, false);
347
static DRIZZLE_SYSVAR_BOOL(debug, debug_enabled, PLUGIN_VAR_NOCMDARG,
348
N_("Turn on extra debugging."), NULL, NULL, false);
350
static DRIZZLE_SYSVAR_STR(username, username, PLUGIN_VAR_READONLY,
351
N_("User to use for auth."), NULL, NULL, NULL);
352
static DRIZZLE_SYSVAR_STR(password, password, PLUGIN_VAR_READONLY,
353
N_("Password to use for auth."), NULL, NULL, NULL);
354
static DRIZZLE_SYSVAR_STR(db, db, PLUGIN_VAR_READONLY,
355
N_("Default database to use."), NULL, NULL, NULL);
357
345
static void init_options(drizzled::module::option_context &context)
359
347
context("enable",