~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/console/console.cc

Updated an include guard thanks to a nice catch during code review from Jay. Thanks Jay!

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
   along with this program; if not, write to the Free Software
14
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
15
 
16
 
#include "config.h"
 
16
#include <drizzled/server_includes.h>
17
17
#include <drizzled/gettext.h>
18
18
#include <drizzled/plugin/listen_tcp.h>
19
19
#include <drizzled/plugin/client.h>
20
 
#include <drizzled/session.h>
21
20
 
22
21
#include <iostream>
23
22
 
26
25
 
27
26
static bool enabled= false;
28
27
static bool debug_enabled= false;
29
 
static char* user = (char*)"";
30
 
static char* password = (char*)"";
31
 
static char* db = NULL;
32
 
 
33
28
 
34
29
class ClientConsole: public plugin::Client
35
30
{
89
84
  virtual bool authenticate(void)
90
85
  {
91
86
    printDebug("authenticate");
92
 
    session->getSecurityContext().setUser(user);
93
 
    return session->checkUser(password, strlen(password), db);
 
87
    return true;
94
88
  }
95
89
 
96
90
  virtual bool readCommand(char **packet, uint32_t *packet_length)
310
304
 
311
305
static ListenConsole *listen_obj= NULL;
312
306
 
313
 
static int init(drizzled::plugin::Context &context)
 
307
static int init(drizzled::plugin::Registry &registry)
314
308
{
315
309
  listen_obj= new ListenConsole("console");
316
 
  context.add(listen_obj);
 
310
  registry.add(listen_obj);
 
311
  return 0;
 
312
}
 
313
 
 
314
static int deinit(drizzled::plugin::Registry &registry)
 
315
{
 
316
  registry.remove(listen_obj);
 
317
  delete listen_obj;
317
318
  return 0;
318
319
}
319
320
 
322
323
 
323
324
static DRIZZLE_SYSVAR_BOOL(debug, debug_enabled, PLUGIN_VAR_NOCMDARG,
324
325
                           N_("Turn on extra debugging."), NULL, NULL, false);
325
 
static DRIZZLE_SYSVAR_STR(user, user, PLUGIN_VAR_READONLY,
326
 
                          N_("User to use for auth."), NULL, NULL, NULL);
327
 
static DRIZZLE_SYSVAR_STR(password, password, PLUGIN_VAR_READONLY,
328
 
                          N_("Password to use for auth."), NULL, NULL, NULL);
329
 
static DRIZZLE_SYSVAR_STR(db, db, PLUGIN_VAR_READONLY,
330
 
                          N_("Default database to use."), NULL, NULL, NULL);
331
326
 
332
327
static drizzle_sys_var* vars[]= {
333
328
  DRIZZLE_SYSVAR(enable),
334
329
  DRIZZLE_SYSVAR(debug),
335
 
  DRIZZLE_SYSVAR(user),
336
 
  DRIZZLE_SYSVAR(password),
337
 
  DRIZZLE_SYSVAR(db),
338
330
  NULL
339
331
};
340
332
 
341
333
DRIZZLE_DECLARE_PLUGIN
342
334
{
343
 
  DRIZZLE_VERSION_ID,
344
335
  "console",
345
336
  "0.1",
346
337
  "Eric Day",
347
338
  "Console Client",
348
339
  PLUGIN_LICENSE_BSD,
349
340
  init,   /* Plugin Init */
 
341
  deinit, /* Plugin Deinit */
 
342
  NULL,   /* status variables */
350
343
  vars,   /* system variables */
351
344
  NULL    /* config options */
352
345
}