Drizzled Public API Documentation

module.cc
1 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3  *
4  * Copyright 2011 Daniel Nichter
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 #include <config.h>
21 #include <drizzled/item.h>
22 #include <drizzled/plugin.h>
24 #include <boost/program_options.hpp>
25 #include "auth_schema.h"
26 
27 namespace po= boost::program_options;
28 
29 using namespace std;
30 
31 namespace drizzle_plugin {
32 namespace auth_schema {
33 
37 static AuthSchema *auth_schema= NULL;
38 
39 static bool update_table(Session*, set_var* var)
40 {
41  if (not var->value->str_value.empty())
42  return auth_schema->setTable(var->value->str_value.data());
43  errmsg_printf(error::ERROR, _("auth_schema table cannot be NULL"));
44  return true; // error
45 }
46 
47 static void init_options(module::option_context &context)
48 {
49  auth_schema= new AuthSchema(true);
50 
51  context("table",
52  po::value<string>(&auth_schema->sysvar_table)->default_value("auth.users"),
53  N_("Database-qualified auth table name"));
54 }
55 
56 static int init(module::Context &context)
57 {
58  const module::option_map &vm= context.getOptions();
59 
60  if (not vm["table"].as<string>().empty())
61  auth_schema->setTable(vm["table"].as<string>());
62 
63  context.add(auth_schema);
64  context.registerVariable(new sys_var_bool_ptr("enabled", &auth_schema->sysvar_enabled));
65  context.registerVariable(new sys_var_std_string("table", auth_schema->sysvar_table, NULL, &update_table));
66 
67  return 0;
68 }
69 
70 } /* end namespace drizzle_plugin::auth_schema */
71 } /* end namespace drizzle_plugin */
72 
73 DRIZZLE_DECLARE_PLUGIN
74 {
75  DRIZZLE_VERSION_ID,
76  "auth_schema",
77  "1.0",
78  "Daniel Nichter",
79  N_("Authentication against a table with encrypted passwords"),
80  PLUGIN_LICENSE_GPL,
81  drizzle_plugin::auth_schema::init,
82  NULL,
83  drizzle_plugin::auth_schema::init_options,
84 }
85 DRIZZLE_DECLARE_PLUGIN_END;
An Proxy Wrapper around boost::program_options::variables_map.
String str_value
Definition: item.h:107