22 #include <drizzled/internal/m_string.h>
23 #include <drizzled/charset.h>
25 #include <drizzled/typelib.h>
29 static const char field_separator=
',';
31 int TYPELIB::find_type_or_exit(
const char *x,
const char *option)
const
33 int res= find_type(x, e_dont_complete);
37 fprintf(stderr,
"No option given to %s\n", option);
39 fprintf(stderr,
"Unknown option to %s: %s\n", option, x);
40 const char **ptr= type_names;
41 fprintf(stderr,
"Alternatives are: '%s'", *ptr);
43 fprintf(stderr,
",'%s'", *ptr);
44 fprintf(stderr,
"\n");
73 int TYPELIB::find_type(
const char *x, e_find_options full_name)
const
75 assert(full_name & e_dont_complete);
81 for (
int pos= 0; (j= type_names[pos]); pos++)
84 for (; *i && *i != field_separator &&
85 my_charset_utf8_general_ci.toupper(*i) == my_charset_utf8_general_ci.toupper(*j); i++, j++)
95 if (not *i && *i != field_separator && (not *j || not (full_name & e_match_full)))
101 if (find == 0 || not x[0])
103 if (find != 1 || (full_name & e_match_full))
121 TYPELIB *TYPELIB::copy_typelib(memory::Root& root)
const
123 TYPELIB* to=
new (root) TYPELIB;
124 to->type_names= (
const char**)root.alloc((
sizeof(
char *) +
sizeof(
int)) * (count + 1));
125 to->type_lengths= (
unsigned int*)(to->type_names + count + 1);
127 to->name= name ? root.strdup(name) : NULL;
128 for (uint32_t i= 0; i < count; i++)
130 to->type_names[i]= root.strdup(type_names[i], type_lengths[i]);
131 to->type_lengths[i]= type_lengths[i];
133 to->type_names[to->count]= NULL;
134 to->type_lengths[to->count]= 0;
TODO: Rename this file - func.h is stupid.
Memory root declarations.