~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/hello_events/hello_events.cc

Merge of VJ

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
#include "config.h"
35
35
#include <string>
36
36
#include <cstdio>
37
 
 
 
37
#include <boost/program_options.hpp>
 
38
#include <drizzled/module/option_map.h>
38
39
#include "drizzled/session.h"
39
40
#include "hello_events.h"
40
 
 
 
41
namespace po= boost::program_options;
41
42
using namespace drizzled;
42
43
using namespace plugin;
43
44
using namespace std;
285
286
 
286
287
static int init(module::Context &context)
287
288
{
 
289
  const module::option_map &vm= context.getOptions();
 
290
  if (vm.count("before-write-position"))
 
291
  { 
 
292
    if (sysvar_before_write_position < 1 || sysvar_before_write_position > INT32_MAX -1)
 
293
    {
 
294
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of before-write-position\n"));
 
295
      exit(-1);
 
296
    }
 
297
  }
 
298
 
 
299
  if (vm.count("before-update-position"))
 
300
  { 
 
301
    if (sysvar_before_update_position < 1 || sysvar_before_update_position > INT32_MAX -1)
 
302
    {
 
303
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of before-update-position\n"));
 
304
      exit(-1);
 
305
    }
 
306
  }
 
307
 
 
308
  if (vm.count("post-drop-db-position"))
 
309
  { 
 
310
    if (sysvar_post_drop_db_position > -1 || sysvar_post_drop_db_position < INT32_MIN+1)
 
311
    {
 
312
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of before-update-position\n"));
 
313
      exit(-1);
 
314
    }
 
315
  }
 
316
 
 
317
  if (vm.count("watch-databases"))
 
318
  {
 
319
    sysvar_db_list= strdup(vm["watch-databases"].as<string>().c_str());
 
320
  }
 
321
 
 
322
  else
 
323
  {
 
324
    sysvar_db_list= (char *)"";
 
325
  }
 
326
 
 
327
  if (vm.count("watch-tables"))
 
328
  {
 
329
    sysvar_table_list= strdup(vm["watch-tables"].as<string>().c_str());
 
330
  }
 
331
 
 
332
  else
 
333
  {
 
334
    sysvar_table_list= (char *)"";
 
335
  }
288
336
  hello_events= new HelloEvents(PLUGIN_NAME);
289
337
 
290
338
  context.add(hello_events);
297
345
  return 0;
298
346
}
299
347
 
 
348
static void init_options(drizzled::module::option_context &context)
 
349
{
 
350
  context("watch-databases",
 
351
          po::value<string>(),
 
352
          N_("A comma delimited list of databases to watch"));
 
353
  context("watch-tables",
 
354
          po::value<string>(),
 
355
          N_("A comma delimited list of databases to watch"));
 
356
  context("enable",
 
357
          po::value<bool>(&sysvar_hello_events_enabled)->default_value(false)->zero_tokens(),
 
358
          N_("Enable Example Events Plugin"));
 
359
  context("before-write-position",
 
360
          po::value<int32_t>(&sysvar_before_write_position)->default_value(1),
 
361
          N_("Before write row event observer call position"));
 
362
  context("before-update-position",
 
363
          po::value<int32_t>(&sysvar_before_update_position)->default_value(1),
 
364
          N_("Before update row event observer call position"));
 
365
  context("post-drop-db-position",
 
366
          po::value<int32_t>(&sysvar_post_drop_db_position)->default_value(-1),
 
367
          N_("After drop database event observer call position"));
 
368
}
 
369
 
300
370
static DRIZZLE_SYSVAR_STR(watch_databases,
301
371
                           sysvar_db_list,
302
372
                           PLUGIN_VAR_OPCMDARG,
374
444
  PLUGIN_LICENSE_BSD,
375
445
  init,   /* Plugin Init      */
376
446
  system_var, /* system variables */
377
 
  NULL    /* config options   */
 
447
  init_options    /* config options   */
378
448
}
379
449
DRIZZLE_DECLARE_PLUGIN_END;