~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/hex_functions/hex_functions.cc

mergeĀ lp:~hingo/drizzle/drizzle-auth_ldap-fix-and-docs

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems
 
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
 
20
#include <config.h>
 
21
 
 
22
#include <drizzled/charset.h>
 
23
#include <drizzled/function/str/strfunc.h>
 
24
#include <drizzled/internal/m_string.h>
 
25
#include <drizzled/plugin/function.h>
21
26
#include <drizzled/util/convert.h>
22
 
#include "drizzled/internal/m_string.h"
23
 
 
24
 
#include <drizzled/plugin/function.h>
25
 
#include <drizzled/function/str/strfunc.h>
26
27
 
27
28
using namespace drizzled;
28
29
 
101
102
    if ((null_value= args[0]->null_value))
102
103
      return 0;
103
104
    ptr= internal::int64_t2str(dec,ans,16);
104
 
    if (str->copy(ans,(uint32_t) (ptr-ans),default_charset()))
105
 
      return &my_empty_string;                  // End of memory
 
105
    str->copy(ans,(uint32_t) (ptr-ans),default_charset());
106
106
    return str;
107
107
  }
108
108
 
109
109
  /* Convert given string to a hex string, character by character */
110
110
  res= args[0]->val_str(str);
111
 
  if (!res || tmp_value.alloc(res->length()*2+1))
 
111
  if (!res)
112
112
  {
113
113
    null_value=1;
114
114
    return 0;
115
115
  }
116
116
  null_value=0;
 
117
  tmp_value.alloc(res->length()*2+1);
117
118
  tmp_value.length(res->length()*2);
118
119
 
119
120
  (void) drizzled_string_to_hex((char*) tmp_value.ptr(), res->ptr(),
132
133
  assert(fixed == 1);
133
134
 
134
135
  res= args[0]->val_str(str);
135
 
  if (!res || tmp_value.alloc(length= (1+res->length())/2))
 
136
  if (!res)
136
137
  {
137
138
    null_value=1;
138
139
    return 0;
139
140
  }
 
141
  tmp_value.alloc(length= (1+res->length())/2);
140
142
 
141
143
  from= res->ptr();
142
144
  null_value= 0;
183
185
  "Convert a string to HEX() or from UNHEX()",
184
186
  PLUGIN_LICENSE_GPL,
185
187
  initialize, /* Plugin Init */
186
 
  NULL,   /* system variables */
 
188
  NULL,   /* depends */
187
189
  NULL    /* config options */
188
190
}
189
191
DRIZZLE_DECLARE_PLUGIN_END;