00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include <config.h>
00017
00018 #include <drizzled/internal/my_sys.h>
00019 #include <drizzled/internal/m_string.h>
00020
00021 namespace drizzled
00022 {
00023 namespace internal
00024 {
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 static const char *reserved_names[]=
00035 {
00036 "CLOCK$",
00037 "CON", "PRN", "AUX", "NUL",
00038 "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9",
00039 "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9",
00040 NULL
00041 };
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 static int str_list_find(const char **list, const char *str)
00058 {
00059 const char **name;
00060 for (name= list; *name; name++)
00061 {
00062 if (!my_strcasecmp(&my_charset_utf8_general_ci, *name, str))
00063 return 1;
00064 }
00065 return 0;
00066 }
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 static char reserved_map[256]=
00077 {
00078 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
00079 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
00080 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
00081 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
00082 0,1,0,1,0,0,0,0,0,0,0,0,7,4,5,2,
00083 3,0,2,0,4,2,0,0,4,0,0,0,0,0,0,0,
00084 0,1,0,1,0,0,0,0,0,0,0,0,7,4,5,2,
00085 3,0,2,0,4,2,0,0,4,0,0,0,0,0,0,0,
00086 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
00087 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
00088 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
00089 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
00090 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
00091 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
00092 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
00093 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
00094 };
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115 int check_if_legal_tablename(const char *name)
00116 {
00117 return((reserved_map[(unsigned char) name[0]] & 1) &&
00118 (reserved_map[(unsigned char) name[1]] & 2) &&
00119 (reserved_map[(unsigned char) name[2]] & 4) &&
00120 str_list_find(&reserved_names[1], name));
00121 }
00122
00123
00124 }
00125 }