~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
/* Copyright (C) 2000 MySQL AB
2
3
   This program is free software; you can redistribute it and/or modify
4
   it under the terms of the GNU General Public License as published by
5
   the Free Software Foundation; version 2 of the License.
6
7
   This program is distributed in the hope that it will be useful,
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
   GNU General Public License for more details.
11
12
   You should have received a copy of the GNU General Public License
13
   along with this program; if not, write to the Free Software
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
16
/* make-conf.c
17
 * make a charset .conf file out of a ctype-charset.c file.
18
 */
19
20
#ifndef CHARSET
21
#error You must define the charset, e.g.:  -DCHARSET=latin1
22
#endif
23
24
/* some pre-processor tricks to get us going */
25
#define _STRINGIZE_HELPER(x)    #x
26
#define STRINGIZE(x)            _STRINGIZE_HELPER(x)
27
28
#define _JOIN_WORDS_HELPER(a, b)    a ## b
29
#define JOIN_WORDS(a, b)            _JOIN_WORDS_HELPER(a, b)
30
31
#define CH_SRC ctype- ## CHARSET ## .c
32
#define CH_INCLUDE STRINGIZE(CH_SRC)
33
34
/* aaaah, that's better */
35
#include <my_my_global.h>
36
#include CH_INCLUDE
37
38
#include <stdio.h>
39
#include <stdlib.h>
40
41
#define ROW_LEN   16
42
482 by Brian Aker
Remove uint.
43
void print_array(const char *name, const unsigned char *array, uint32_t size);
1 by brian
clean slate
44
45
int main(void)
46
{
47
  printf("# Configuration file for the "
48
         STRINGIZE(CHARSET)
49
         " character set.\n");
50
51
  print_array("ctype",      JOIN_WORDS(ctype_,      CHARSET), 257);
52
  print_array("to_lower",   JOIN_WORDS(to_lower_,   CHARSET), 256);
53
  print_array("to_upper",   JOIN_WORDS(to_upper_,   CHARSET), 256);
54
  print_array("sort_order", JOIN_WORDS(sort_order_, CHARSET), 256);
55
56
  exit(EXIT_SUCCESS);
57
}
58
482 by Brian Aker
Remove uint.
59
void print_array(const char *name, const unsigned char *array, uint32_t size)
1 by brian
clean slate
60
{
482 by Brian Aker
Remove uint.
61
  uint32_t i;
1 by brian
clean slate
62
63
  printf("\n# The %s array must have %d elements.\n", name, size);
64
65
  for (i = 0; i < size; ++i) {
66
    printf("  %02X", array[i]);
67
68
    if ((i+1) % ROW_LEN == size % ROW_LEN)
69
      printf("\n");
70
  }
71
}