~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/crc32/crc32udf.cc

  • Committer: Padraig O'Sullivan
  • Date: 2009-09-13 01:03:01 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-20090913010301-tcvvezipx1124acy
Added calls to the dtrace delete begin/end probes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
 
20
#include <drizzled/server_includes.h>
21
21
#include <drizzled/plugin/function.h>
22
22
#include <drizzled/item/func.h>
23
 
#include <drizzled/algorithm/crc32.h>
 
23
#include <zlib.h>
24
24
 
25
25
#include <string>
26
26
 
29
29
 
30
30
class Crc32Function :public Item_int_func
31
31
{
 
32
  String value;
32
33
public:
33
34
  int64_t val_int();
34
35
  
56
57
int64_t Crc32Function::val_int()
57
58
{
58
59
  assert(fixed == true);
59
 
  String value;
60
60
  String *res=args[0]->val_str(&value);
61
61
  
62
62
  if (res == NULL)
66
66
  }
67
67
 
68
68
  null_value= false;
69
 
  return static_cast<int64_t>(drizzled::algorithm::crc32(res->ptr(), res->length()));
 
69
  return (int64_t) crc32(0L, (unsigned char*)res->ptr(), res->length());
70
70
}
71
71
 
72
72
plugin::Create_function<Crc32Function> *crc32udf= NULL;
73
73
 
74
 
static int initialize(plugin::Context &context)
 
74
static int initialize(plugin::Registry &registry)
75
75
{
76
76
  crc32udf= new plugin::Create_function<Crc32Function>("crc32");
77
 
  context.add(crc32udf);
78
 
  return 0;
79
 
}
80
 
 
81
 
DRIZZLE_PLUGIN(initialize, NULL);
 
77
  registry.function.add(crc32udf);
 
78
  return 0;
 
79
}
 
80
 
 
81
static int finalize(plugin::Registry &registry)  
 
82
{
 
83
  registry.function.remove(crc32udf);
 
84
  delete crc32udf;
 
85
  return 0;
 
86
}
 
87
 
 
88
drizzle_declare_plugin(crc32)
 
89
{
 
90
  "crc32",
 
91
  "1.0",
 
92
  "Stewart Smith",
 
93
  "UDF for computing CRC32",
 
94
  PLUGIN_LICENSE_GPL,
 
95
  initialize, /* Plugin Init */
 
96
  finalize,   /* Plugin Deinit */
 
97
  NULL,   /* status variables */
 
98
  NULL,   /* system variables */
 
99
  NULL    /* config options */
 
100
}
 
101
drizzle_declare_plugin_end;