~drizzle-trunk/drizzle/development

1086.6.1 by devananda
refactored function/version into plugin/version
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
4
 *  Copyright (C) 2008 Sun Microsystems
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 <drizzled/server_includes.h>
21
#include <drizzled/function/str/strfunc.h>
1093.1.62 by Monty Taylor
Moved UDFs to slot organization.
22
#include <drizzled/slot/function.h>
1086.6.1 by devananda
refactored function/version into plugin/version
23
24
using namespace std;
1093.1.62 by Monty Taylor
Moved UDFs to slot organization.
25
using namespace drizzled;
1086.6.1 by devananda
refactored function/version into plugin/version
26
27
class VersionFunction :public Item_str_func
28
{
29
public:
30
  String *val_str(String *str);
31
  VersionFunction() :Item_str_func() {}
32
  
33
  const char *func_name() const 
34
  { 
35
    return "version"; 
36
  }
37
  
38
  bool check_argument_count(int n)
39
  {
40
    return (n==0);
41
  }
42
43
  void fix_length_and_dec() {}
44
};
45
46
String *VersionFunction::val_str(String *str)
47
{
48
  str->set(STRING_WITH_LEN(VERSION),system_charset_info);
49
  return str;
50
}
51
1093.1.62 by Monty Taylor
Moved UDFs to slot organization.
52
plugin::Create_function<VersionFunction> *versionudf= NULL;
1086.6.1 by devananda
refactored function/version into plugin/version
53
1093.1.62 by Monty Taylor
Moved UDFs to slot organization.
54
static int initialize(plugin::Registry &registry)
1086.6.1 by devananda
refactored function/version into plugin/version
55
{
1093.1.62 by Monty Taylor
Moved UDFs to slot organization.
56
  versionudf= new plugin::Create_function<VersionFunction>("version");
57
  registry.function.add(versionudf);
1086.6.1 by devananda
refactored function/version into plugin/version
58
  return 0;
59
}
60
1093.1.62 by Monty Taylor
Moved UDFs to slot organization.
61
static int finalize(plugin::Registry &registry)
1086.6.1 by devananda
refactored function/version into plugin/version
62
{
1093.1.62 by Monty Taylor
Moved UDFs to slot organization.
63
   registry.function.remove(versionudf);
64
   delete versionudf;
1086.6.1 by devananda
refactored function/version into plugin/version
65
   return 0;
66
}
67
68
drizzle_declare_plugin(version)
69
{
70
  "version",
71
  "1.0",
72
  "Devananda van der Veen",
73
  "Return the server version",
74
  PLUGIN_LICENSE_GPL,
75
  initialize, /* Plugin Init */
76
  finalize,   /* Plugin Deinit */
77
  NULL,   /* status variables */
78
  NULL,   /* system variables */
79
  NULL    /* config options */
80
}
81
drizzle_declare_plugin_end;