~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/md5/md5.cc

  • Committer: Padraig O'Sullivan
  • Date: 2009-09-13 00:53:34 UTC
  • mto: (1126.9.2 captain-20090915-01)
  • mto: This revision was merged to the branch mainline in revision 1133.
  • Revision ID: osullivan.padraig@gmail.com-20090913005334-6wio2sbjugskfbm3
Added calls to the connection start/end dtrace probes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
   along with this program; if not, write to the Free Software
15
15
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
16
16
 
17
 
#include "config.h"
18
 
 
19
 
#include <cstdio>
20
 
#include <cstddef>
21
 
 
22
 
#include <gcrypt.h>
23
 
 
24
 
#include <drizzled/plugin/function.h>
 
17
#include <drizzled/server_includes.h>
 
18
#include <drizzled/slot/function.h>
25
19
#include <drizzled/item/func.h>
26
 
#include "drizzled/charset.h"
27
20
#include <drizzled/function/str/strfunc.h>
28
21
 
 
22
#if defined(HAVE_LIBGNUTLS_OPENSSL)
 
23
# include <gnutls/openssl.h>
 
24
#else
 
25
# include <openssl/md5.h>
 
26
#endif /* HAVE_GNUTLS_OPENSSL */
 
27
 
 
28
#include <stdio.h>
 
29
 
29
30
using namespace std;
30
31
using namespace drizzled;
31
32
 
70
71
 
71
72
  unsigned char digest[16];
72
73
  str->set_charset(&my_charset_bin);
73
 
 
74
 
  gcry_md_hash_buffer(GCRY_MD_MD5, digest, sptr->ptr(), sptr->length());
 
74
  MD5_CTX context;
 
75
  MD5_Init(&context);
 
76
  MD5_Update(&context, (unsigned char *) sptr->ptr(), sptr->length());
 
77
  MD5_Final(digest, &context);
75
78
 
76
79
  snprintf((char *) str->ptr(), 33,
77
80
    "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
87
90
 
88
91
plugin::Create_function<Md5Function> *md5udf= NULL;
89
92
 
90
 
static int initialize(plugin::Context &context)
 
93
static int initialize(plugin::Registry &registry)
91
94
{
92
95
  md5udf= new plugin::Create_function<Md5Function>("md5");
93
 
  context.add(md5udf);
94
 
  return 0;
95
 
}
96
 
 
97
 
DRIZZLE_DECLARE_PLUGIN
98
 
{
99
 
  DRIZZLE_VERSION_ID,
 
96
  registry.function.add(md5udf);
 
97
  return 0;
 
98
}
 
99
 
 
100
static int finalize(plugin::Registry &registry)
 
101
{
 
102
  registry.function.remove(md5udf);
 
103
  delete md5udf;
 
104
  return 0;
 
105
}
 
106
 
 
107
drizzle_declare_plugin(md5)
 
108
{
100
109
  "md5",
101
110
  "1.0",
102
111
  "Stewart Smith",
103
112
  "UDF for computing md5sum",
104
113
  PLUGIN_LICENSE_GPL,
105
114
  initialize, /* Plugin Init */
 
115
  finalize,   /* Plugin Deinit */
 
116
  NULL,   /* status variables */
106
117
  NULL,   /* system variables */
107
118
  NULL    /* config options */
108
119
}
109
 
DRIZZLE_DECLARE_PLUGIN_END;
 
120
drizzle_declare_plugin_end;