00001 /* Copyright (C) 2000 MySQL AB 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; either version 2 of the License, or 00006 (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 00016 00017 /* make-conf.c 00018 * make a charset .conf file out of a ctype-charset.c file. 00019 */ 00020 00021 #ifndef CHARSET 00022 #error You must define the charset, e.g.: -DCHARSET=latin1 00023 #endif 00024 00025 /* some pre-processor tricks to get us going */ 00026 #define _STRINGIZE_HELPER(x) #x 00027 #define STRINGIZE(x) _STRINGIZE_HELPER(x) 00028 00029 #define _JOIN_WORDS_HELPER(a, b) a ## b 00030 #define JOIN_WORDS(a, b) _JOIN_WORDS_HELPER(a, b) 00031 00032 #define CH_SRC ctype- ## CHARSET ## .c 00033 #define CH_INCLUDE STRINGIZE(CH_SRC) 00034 00035 /* aaaah, that's better */ 00036 #include <my_my_global.h> 00037 #include CH_INCLUDE 00038 00039 #include <stdio.h> 00040 #include <stdlib.h> 00041 00042 #define ROW_LEN 16 00043 00044 void print_array(const char *name, const uchar *array, uint size); 00045 00046 int main(void) 00047 { 00048 printf("# Configuration file for the " 00049 STRINGIZE(CHARSET) 00050 " character set.\n"); 00051 00052 print_array("ctype", JOIN_WORDS(ctype_, CHARSET), 257); 00053 print_array("to_lower", JOIN_WORDS(to_lower_, CHARSET), 256); 00054 print_array("to_upper", JOIN_WORDS(to_upper_, CHARSET), 256); 00055 print_array("sort_order", JOIN_WORDS(sort_order_, CHARSET), 256); 00056 00057 exit(EXIT_SUCCESS); 00058 } 00059 00060 void print_array(const char *name, const uchar *array, uint size) 00061 { 00062 uint i; 00063 00064 printf("\n# The %s array must have %d elements.\n", name, size); 00065 00066 for (i = 0; i < size; ++i) { 00067 printf(" %02X", array[i]); 00068 00069 if ((i+1) % ROW_LEN == size % ROW_LEN) 00070 printf("\n"); 00071 } 00072 }
1.4.7

